Hide language WPML Hide language WPML wordpress wordpress

Hide language WPML


You can check out the plugin WPML Flag In Menu.

You could use the plugin_wpml_flag_in_menu() function from the plugin (see source code here) and replace:

// Exclude current viewing language             if( $l['language_code'] != ICL_LANGUAGE_CODE ){    // ...}

with

// Include only the current language                if( $l['language_code'] == ICL_LANGUAGE_CODE ){    // ...}

to show only the current language/flag, if I understand you correctly.

ps: If you need further assistance, you could for exampe show us the output of this debug function for the active language:

function debug_icl_active_language(){    $languages = icl_get_languages( 'skip_missing=0' );    foreach( (array) $languages as $l )    {        if( $l['active'] )        {             printf( '<pre> Total languages: %d - Active: %s </pre>',                     count( $languages ),                     print_r( $l, TRUE ) );        }    }}


function language_selector_flags(){    $languages = icl_get_languages('skip_missing=0');    if(!empty($languages)){        $filter = array();        $filter['ar'] = array( 'he' );        // set your other filters here        $active_language = null;        foreach ($languages as $l)            if($l['active']) {                $active_language = $l['language_code'];                break;            }        $filter = $active_language && isset( $filter[$active_language] ) ? $filter[$active_language] : array();        foreach ($languages as $l) {                //Display whatever way you want -- I'm just displaying flags in anchors  (CSS: a {float:left; display:block;width:18px;height:12px;margin:0 2px;overflow:hidden;line-height:100px;})                if( in_array( $l['language_code'], $filter) )                    continue;                if($l['active']) { $class = "active"; $url=""; } else { $class = ''; $url = 'href="'.$l['url'].'"'; }                echo '<a '.$url.' class="flag '.$class.'"><img src="', $l['country_flag_url'], '" alt="', esc_attr( $l['language_code'] ), '" /></a>';            }        }    }

EDIT: If I get this right, your client(I assume) doesn't want his customers (Israelis especiay) to know that he offer service also to the arabic speaking cusomers. If it so then you can parse the Accept-Language header and filter the language selector according the result.