Filters reference
| Filter | Receives | Use it to |
|---|---|---|
cls_pro_languages |
$languages (code β label, label_en, flag) |
Add a language, rename one, or change its usual flag |
cls_pro_language_urls |
$urls (code β URL), $page_url (or null for the current page) |
Change where any language link points |
cls_pro_ui_strings |
$strings (close, search, clear, no_results, recent, all, change), $lang |
Translate or reword the window’s buttons and messages |
cls_pro_search_min_languages |
6 |
Change how many languages are needed before the search box shows |
cls_pro_flag_url |
$url, $flag_code, $display_px |
Serve your own flag images |
cls_pro_country_language_map |
$map (country β language code) |
Change the built-in country list in code |
cls_pro_allow_redirect |
$allowed (bool) |
Stop automatic redirects on some pages |
cls_pro_is_bot |
$is_bot, $user_agent |
Treat more (or fewer) visitors as bots |
cls_pro_client_ip |
$ip, $via (proxy key, forwarded or direct) |
Read the visitor IP from your own proxy header |
cls_pro_proxy_sources |
$sources (key β name, marker, country, ip, ip_has_port) |
Add a CDN the plugin does not know |
cls_pro_geo_headers |
$headers (server variable β variable that must also be set, or '') |
Read the country from your host’s header |
cls_pro_ip_country |
null, $ip |
Look up the country yourself (return a two-letter code) |
cls_pro_js_data |
$data |
Add data to the front-end script’s CLS_PRO_DATA |
Examples
// Add a language that is not built in (Klingon, flag placeholder).
add_filter( 'cls_pro_languages', function ( array $langs ): array {
$langs['tlh'] = [ 'label' => 'tlhIngan Hol', 'label_en' => 'Klingon', 'flag' => 'xx' ];
return $langs;
} );
// Point French to a different site.
add_filter( 'cls_pro_language_urls', function ( array $urls ): array {
$urls['fr'] = 'https://example.fr/';
return $urls;
} );
// Never redirect on the checkout page.
add_filter( 'cls_pro_allow_redirect', function ( bool $allowed ): bool {
return $allowed && ! ( function_exists( 'is_checkout' ) && is_checkout() );
} );
// Rename "Recently used" on English pages.
add_filter( 'cls_pro_ui_strings', function ( array $s, string $lang ): array {
if ( $lang === 'en' ) $s['recent'] = 'Your languages';
return $s;
}, 10, 2 );
// Country from your own header, set by your load balancer.
add_filter( 'cls_pro_geo_headers', function ( array $headers ): array {
$headers['HTTP_X_MY_COUNTRY'] = '';
return $headers;
} );
// Show the search box from 10 languages.
add_filter( 'cls_pro_search_min_languages', fn() => 10 );