wpml_enqueue_browser_redirect_language
- Type
- filter
- Category
- Site-Wide Language Information
- WPML Version
- 4.1.0
Description
This filter is used when the theme developer wants to use a custom JavaScript for handling the browser redirection.
This filters a boolean set to true by default.
If the filter returns false, the JavaScript which takes care of redirecting the visitor won’t be enqueued.
The filter is applied only if the wpml_browser_redirect_language_params filter returns a valid $param (pageLanguage and languageUrls must be set).
Arguments
pageLanguage - defines a language for the page
languageUrls - an array that contains pairs of languages and URLs to which browser should be redirected
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' );
Related hooks
wpml_decode_custom_field, wpml_footer_language_selector, wpml_add_language_form_field, wpml_ls_exclude_in_menu, wpml_is_rtl, wpml_alternate_hreflang, wpml_head_langs, wpml_must_translate_canonical_url, wpml_browser_redirect_language_params, wpml_active_languages