Skip to content
This repository was archived by the owner on Mar 17, 2022. It is now read-only.
This repository was archived by the owner on Mar 17, 2022. It is now read-only.

broken language switcher links on search page #566

@am3000

Description

@am3000

Hey there,

on the search page the language switcher links are broken.

Also see this support question from another user: https://wordpress.org/support/topic/search-page-error-2/

I investigated and saw that it is caused by Pages::translateShopUrl()

I suggest to add

if ( is_search() ) {
            return $result;
        }

after $result = $url;

to fix this outside of the plugin this workaround should do it:

// fix an error introduced by woo-poly-integration in Pages::translateShopUrl()
add_filter('pll_get_archive_url', 'fix_language_switcher_url_error_1', 9, 2);
add_filter('pll_get_archive_url', 'fix_language_switcher_url_error_2', 11, 2);
function fix_language_switcher_url_error_1($url, $language){
    global $ARCHIVE_URL_BEFORE_WOO_POLY_HOOK;
    $ARCHIVE_URL_BEFORE_WOO_POLY_HOOK = $url;
    return $url;
}
function fix_language_switcher_url_error_2($url, $language){
    global $ARCHIVE_URL_BEFORE_WOO_POLY_HOOK;
    if(is_search()){
        $domain = get_option('siteurl');
        if(stripos($url, $domain)===false){
            $url = $ARCHIVE_URL_BEFORE_WOO_POLY_HOOK;
        }
    }
    return $url;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions