I have a multilingual website. Is there a way I can change the logo.png to a different .png after I switch to \"India\"? I am using polylang plugin
function pojo_polylang_get_multilang_logo( $value ) {
if ( function_exists( 'pll_current_language' ) ) {
$logos = array(
'en' => 'logo-en.png',
'in' => 'logo-in.png',
);
$default_logo = $logos['en'];
$current_lang = pll_current_language();
$assets_url = get_stylesheet_directory_uri() . '/assets/images/';
if ( isset( $logos[ $current_lang ] ) )
$value = $assets_url . $logos[ $current_lang ];
else
$value = $assets_url . $default_logo;
}
return $value;
}
add_filter( 'theme_mod_image_logo', 'pojo_polylang_get_multilang_logo' );
if you have a look from $assets_url to $return $value you will see an if statement :
$assets_url = get_stylesheet_directory_uri() . '/assets/images/';
if ( isset( $logos[ $current_lang ] ) )
$value = $assets_url . $logos[ $current_lang ];
else
$value = $assets_url . $default_logo;
}
return $value
from what I am looking at I can see an error as the if statement does not include {} maybe if you changed it to the following it might work?
$assets_url = get_stylesheet_directory_uri() . '/assets/images/';
if ( isset( $logos[ $current_lang ] ) ) {
$value = $assets_url . $logos[ $current_lang ];
} else {
$value = $assets_url . $default_logo;
}
}
return $value