w Docs

PHP API reference

3 min readUpdated November 9, 2026

All methods are static and can be called once plugins have loaded (plugins_loaded). Wrap theme code in class_exists( 'CLS_Pro' ) so your theme keeps working if the plugin is turned off.

Languages

Method Returns
CLS_Pro::current_language() Code of the page’s language, for example 'fr'
CLS_Pro::default_language() The default language code
CLS_Pro::languages() Every enabled language, keyed by code (see below)
CLS_Pro::language( 'fr' ) One language in the same shape, or null if it is not enabled
CLS_Pro::language_url( 'fr', $page_url = null ) URL of a page in a language. Default: the page being shown
CLS_Pro::is_rtl( 'ar' ) true for right-to-left languages
CLS_Pro::current_is_rtl() true when the current page’s language is right to left
CLS_Pro::active_plugin() wpml, polylang, translatepress, qtranslatex, weglot, mlp, gtranslate, bogo, wpmultilang, translatewp, linguise or manual (built-in URLs)

Each entry of CLS_Pro::languages():

'fr' => [
    'code'     => 'fr',
    'label'    => 'Français',            // as set in "How language names are written"
    'label_en' => 'French',
    'native'   => 'Français',
    'flag'     => 'fr',                  // flag code (custom flag if set)
    'flag_url' => 'https://…/assets/flags/64/fr.png',
    'rtl'      => false,
    'active'   => true,                  // the page's language
    'url'      => 'https://example.com/fr/about/',
]

Rendering

Method What it does
CLS_Pro::trigger( $args ) Returns the switcher button. $args: style, mobile_style, show_arrow. Adds the language window to the page
CLS_Pro::grid( $args ) Returns the Language Grid. $args: columns (auto, 2, 3, 4), class
CLS_Pro::enqueue_modal() Adds the language window to the page, for your own button or for CLSPro.open()
CLS_Pro::modal_html() Returns the language window’s HTML so you can place it yourself (it is then not added again in the footer)

Settings

Method Returns
CLS_Pro::settings() All settings, with defaults filled in
CLS_Pro::setting( 'dark_mode', $default ) One setting, for example 'auto', 'light' or 'dark'
CLS_Pro::version() Plugin version, for example '1.0.0'
CLS_Pro::is_active() Always true (the class only exists when the plugin is loaded)

Detection and cookie

Method Returns
CLS_Pro::detected_country() The visitor’s country code ('DE'), or null
CLS_Pro::geo_suggested_language() The language country detection would offer, or null
CLS_Pro::browser_suggested_language( $header = '' ) Best enabled language for an Accept-Language header (default: the current request’s)
CLS_Pro::cookie_language() The language saved in the visitor’s choice cookie, or null
CLS_Pro::set_cookie( 'fr', $days = null ) Saves a choice. Call before any output. Returns false if headers were already sent
CLS_Pro::clear_cookie() Removes the choice cookie
CLS_Pro::flag_url( 'fr' ) URL of a bundled flag image

Functions (same as the methods above): cls_pro_the_trigger( $args ) (echoes), cls_pro_get_trigger( $args ), cls_pro_the_grid( $args ) (echoes), cls_pro_get_grid( $args ), cls_pro_get_languages(), cls_pro_get_current_language().

Example: a custom text-only switcher

add_action( 'wp_footer', function () {
    if ( ! class_exists( 'CLS_Pro' ) ) return;
    echo '<nav class="my-langs" aria-label="Language">';
    foreach ( CLS_Pro::languages() as $lang ) {
        printf(
            '<a href="%s" hreflang="%s" lang="%s"%s>%s</a> ',
            esc_url( $lang['url'] ),
            esc_attr( $lang['code'] ),
            esc_attr( $lang['code'] ),
            $lang['active'] ? ' aria-current="page"' : '',
            esc_html( $lang['native'] )
        );
    }
    echo '</nav>';
} );