-
AuthorPosts
-
October 13, 2017 at 10:18 pm #864168
Hi,
I’m one of probably lots of customers who wonder why there is no option in Enfold to display different logos for different languages (every international websute that has a slogan in the logo needs this, so it’s highly recommendable as a feature for futire versions).
I use the multi-language plugin Polylang and found 3 php code workarounds for functions.php within the enfold child theme in this support section, supplied by Yigit:
https://kriesi.at/support/topic/different-logo-for-every-language/
It seems to have worked in cases where he helped with several php coder versions. I adapted them by editing the target URL of the imalge file and the language code (Polylang language codes are en_GB and de_DE), but none of the 3 code versions works.
Version 1
add_filter(‘avf_logo’,’av_change_logo’);
function av_change_logo($logo)
{
$lang = pll_current_language(‘locale’);switch ($lang) {
case ‘en_GB’:
$logo = “https://www.bafatex.com/wp-content/uploads/2017/10/logo-en-400×100.jpg”;
break;
case ‘de_DE’:
$logo = “https://www.bafatex.com//wp-content/uploads/2017/04/logo400x100-1.jpg”;
break;
}return $logo;
}Version 2
add_filter(‘avf_logo’,’av_change_logo’);
function av_change_logo($logo)
{
if(ICL_LANGUAGE_CODE==’en’){
$logo = “https://www.bafatex.com/wp-content/uploads/2017/10/logo-en-400×100.jpg”;
}
elseif(ICL_LANGUAGE_CODE==’de’){
$logo = “https://www.bafatex.com//wp-content/uploads/2017/04/logo400x100-1.jpg”;
}
return $logo;
}Version 3
add_filter(‘avf_logo’,’av_change_logo’);
function av_change_logo($logo)
{
$currentlang = get_bloginfo(‘language’);
if($currentlang==”en_GB”)
{
$logo = “https://www.bafatex.com/wp-content/uploads/2017/10/logo-en-400×100.jpg”;
}
if($currentlang==”de_DE”){
{
$logo = “https://www.bafatex.com//wp-content/uploads/2017/04/logo400x100-1.jpg”;
}
return $logo;
}What am I doing wrong?
Thanks a lot in advance!
Joerg from Cologne, Germany
October 17, 2017 at 4:05 am #865069Hey JGastmann,
Thank you for using Enfold
If you’re using the polylang plugin, you should be using the first version of the filter.
add_filter('avf_logo','av_change_logo'); function av_change_logo($logo) { $lang = pll_current_language('locale'); switch ($lang) { case 'en_GB': $logo .= "https://www.bafatex.com/wp-content/uploads/2017/10/logo-en-400×100.jpg"; break; case 'de_DE': $logo .= "https://www.bafatex.com//wp-content/uploads/2017/04/logo400x100-1.jpg"; break; } return $logo; }
Best regards,
IsmaelOctober 17, 2017 at 11:12 am #865230Hello Ismael,
thanks for the answer.
After inserting your code (that I received via email notification) at the bottom of the functions.php of the Enfold child theme, the website crashed. All you saw was a white page with this error message:
Parse error: syntax error, unexpected ‘&’ in /var/www/web265/html/wordpress/wp-content/themes/enfold-child/functions.php on line 31
Even a login wasn’t possible anymore. I got access to the functions.php file via my ftp client, deleted your code, and now (after an interruption of just 1 minute) the website works again.
Meanwhile I compared the code you posted here in the support section with the code that was displayed in my email. Apparently your mail server changes the content of your support system when it sends it via email. This is what my email displayed (take a look at teh following code in edit mode: lots of inserted “'”):
add_filter('avf_logo','av_change_logo');
function av_change_logo($logo)
{
$lang = pll_current_language('locale');switch ($lang) {
case 'en_GB':
$logo .= "https://www.bafatex.com/wp-content/uploads/2017/10/logo-en-400×100.jpg";
break;
case 'de_DE':
$logo .= "https://www.bafatex.com//wp-content/uploads/2017/04/logo400x100-1.jpg";
break;
}
return $logo;
}So maybe you check your email server for configuration problems?
After using the code you posted here in the support section, the english logo file isn’t displayed. This is the complete functions.php:
————————————————
<?php/*
* Add your own functions here. You can also copy some of the theme functions into this file.
* WordPress will use those functions instead of the original functions then.
*/add_shortcode(‘produktberater_de’, ‘produktberater_de’);
function produktberater_de(){
$sprache = 0;
ob_start();
require __DIR__ . “/konfigurator/produktberater.php”;
$res = ob_get_contents();
ob_end_clean();
return $res;
}add_shortcode(‘produktberater_en’, ‘produktberater_en’);
function produktberater_en(){
$sprache = 1;
ob_start();
require __DIR__ . “/konfigurator/produktberater.php”;
$res = ob_get_contents();
ob_end_clean();
return $res;
}/* logo language switch */
add_filter(‘avf_logo’,’av_change_logo’);
function av_change_logo($logo)
{
$lang = pll_current_language(‘locale’);switch ($lang) {
case ‘en_GB’:
$logo .= “https://www.bafatex.com/wp-content/uploads/2017/10/logo-en-400×100.jpg”;
break;
case ‘de_DE’:
$logo .= “https://www.bafatex.com/wp-content/uploads/2017/04/logo400x100-1.jpg”;
break;
}
return $logo;
}
————————————————————————The language codes seem to be correct, as you can see at https://www.bafatex.com/wp-content/uploads/2017/10/polylang-language-settings.jpg
Do you have an idea how to fix the problem that the english version is not displayed?
Best regards,
Joerg Gastmann
Cologne, Germany- This reply was modified 7 years, 1 month ago by JGastmann.
October 19, 2017 at 6:29 am #866085Hi,
Thank you for the update. Please copy the code directly from this forum, not from your email. And please use Pastebin.com for long codes.
Best regards,
IsmaelOctober 19, 2017 at 4:23 pm #866291Thank you very much, Ismael.
As I tried to explain above, I already did it.
First I copied the code from the Email, which made the Website crash. Then I extracted the functions.php via Filezilla from the Enfold child diretory, deleted the “add filter” code, and the website worked as before.
Then I copied your original code directly from this forum via my Notepad++ editor to the end of the functions.php and copied it via Filezilla into the Enfild child directory. Result: None of the logo files (the paths are correct) is displayed.
Then I removed your code from the functions.php (via Notepad++ and ftp / Filezilla) and tried it within the WordPress Backend environment. I started the WorfdPress Theme Editor, opened the functions.php file and copied your code from the forum, in a first attempt directly and in another attempt via pastebin.com.Same Result: With your code none of the logo files is displayed.
Could you just login into the WordPress installation and check it?
Thanks in Anvance,
Joerg
October 21, 2017 at 5:47 am #866962Hi,
Thank you for the update. We modified the code a bit.
/* logo language switch */ add_filter('avf_logo','av_change_logo'); function av_change_logo($logo) { $lang = 'de_DE'; if(function_exists('pll_current_language')) { $lang = pll_current_language('locale'); } if ($lang == 'en_GB') { $logo = 'https://www.bafatex.com/wp-content/uploads/2017/10/logo-en-400×100.jpg'; } elseif ($lang == 'de_DE') { $logo = "https://www.bafatex.com/wp-content/uploads/2017/04/logo400x100-1.jpg"; } return $logo; }
Best regards,
IsmaelOctober 26, 2017 at 12:20 am #869017Hi Ismael,
it works! Thank you very much! The ticket can be closed.
I think the previous version (I don’t see the difference to the last version) may have worked, too, as I had a cashing problem and the update of the page / functions.php just wasn’t transmitted.
Anyway: Thanks again. I recommend to include this script as a part of a new feature in a coming version.
Best regards from Cologne,
JoergOctober 26, 2017 at 8:17 am #869127 -
AuthorPosts
- The topic ‘Language switch for logo image file’ is closed to new replies.