Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #864168
    #865069

    Hey 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,
    Ismael

    #865230

    Hello 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 “&#039”):

    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 1 year, 10 months ago by  JGastmann.
    #866085

    Hi,

    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,
    Ismael

    #866291

    Thank 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

    #866962

    Hi,

    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,
    Ismael

    #869017

    Hi 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,
    Joerg

    #869127

    Hi,

    Glad it worked. Please feel free to open a new thread if you need anything else. FYI, version 4.2 is now available.

    Best regards,
    Ismael

Viewing 8 posts - 1 through 8 (of 8 total)

The topic ‘Language switch for logo image file’ is closed to new replies.