Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1368106

    Hi Enfold-Team!

    I want to create a localized version of both the regular logo and the transparency-logo using Snippets (Polylang-Module).
    Addditional usecase: there are two languages (EN and ES). Could you help please?
    I am using this snippet:

    add_filter(‘avf_logo’,’av_change_logo’);
    function av_change_logo($logo)
    {
    $lang = pll_current_language(‘locale’);

    switch ($lang) {
    case ‘en_US’:
    $logo = “/wp-content/uploads/2022/10/logo-en.png”;
    break;
    case ‘af’:
    $logo = “/wp-content/uploads/2022/10/logo-en.png”;
    break;
    case ‘es_CL’:
    $logo = “/wp-content/uploads/2022/10/logo-es.png”;
    break;
    case ‘af’:
    $logo = “/wp-content/uploads/2022/10/logo-es.png”;
    break;
    }

    return $logo;
    }

    #1368191

    Hi fritzves,

    Thanks for giving us admin access.
    Please try to add this code snippet for transparency logo:

    add_filter('avf_logo_subtext', 'kriesi_logo_addition');
    
    function kriesi_logo_addition($sub) {
    
        $lang = pll_current_language('locale');
    
        switch ($lang) {
            case 'en_US':
                $sub = '<img src="https://www.website.com/wp-content/uploads/2022/09/transparent-logo-en.png" class="alternate" alt="" title="alternate logo">';
                break;
            case 'es_CL':
                $sub = '<img src="https://www.website.com/wp-content/uploads/2022/09/transparent-logo-es.png" class="alternate" alt="" title="alternate logo">';
                break;
            default:
                $sub = '<img src="https://www.website.com/wp-content/uploads/2022/09/transparent-logo-default.png" class="alternate" alt="" title="alternate logo">';
        }
         
        return $sub;
    }

    Just change the image links and adjust the code as you see fit.

    Also, I have modified your code snippet to remove unnecessary codes, however, since you have three languages installed I suggest adding a default:

    add_filter('avf_logo','av_change_logo');
    
    function av_change_logo($logo) {
        $lang = pll_current_language('locale');
    
        switch ($lang) {
            case 'en_US':
                $logo = "https://www.website.com/wp-content/uploads/2022/09/logo-en.png";
                break;
            case 'es_CL':
                $logo = "https://www.website.com/wp-content/uploads/2022/09/logo-es.png";
                break;
            default:
                $logo = "https://www.website.com/wp-content/uploads/2022/09/logo-default.png";
        }
    
        return $logo;
    }

    Hope this helps.

    Best regards,
    Nikko

    • This reply was modified 2 years, 1 month ago by Nikko.
    #1368336

    When copying the code from the email there was a small error. I found it out by myself.
    Great job! It works :-)

    Thanks!

    • This reply was modified 2 years, 1 month ago by fritzves.
    #1368354

    Hi fritzves,

    You’re welcome :)
    Thanks for using Enfold and have a great day!

    Best regards,
    Nikko

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Internationalization Logo Transparency Snippets’ is closed to new replies.