availability:

WPML Version: Coming soon!

description:

This filter can be used when the theme developer wants to use a different cookie name or tweak the languageUrls array to use different URLs.

It uses the $params argument which is an associative array containing some information about the current language, the active languages and the cookie settings.

type:
filter
category:
Site-Wide Language Information
parameters:
pageLanguage
Stores the current language code.
languageUrls
Stores an associative array containing all the current page’s translation URLs. The keys of the array are the language codes. The same language can have multiple entries to match a different combination of language codes. For instance, in the case of en_US, the same URL is repeated three times with the following keys: en_us, en, and us.
cookie
Stores an associative array with the cookie settings. Please refer to Document.cookie for more details. The keys are:

  • name: the name of the cookie (defaults to _icl_visitor_lang_js).
  • domain: the domain in which the cookie must be used (defaults to the current domain and is not meant to be changed).
  • path: the path of the cookie (defaults to /).
  • expiration: the expiration in seconds is read from the value set in Remember visitors’ language preference that can be found in Browser language redirect on the WPML -> Languages.
hook example usage:

In order to use this filter Browser language redirect must be enabled on the WPML -> Languages.

The following code can be used to disable the redirect feature on a specific page:

function example( $enqueue ) {
    global $post;
    // Do not enqueue the scripts if the page ID is 123
    if ( $post->ID === 123 ) {
        $enqueue = false;
    }

    return $enqueue;
}

add_filter( 'wpml_enqueue_browser_redirect_language', 'example' );