annelyse
11/29/2017 - 3:27 PM

Custom select language dropdown wpml

#language_list{
    padding: 10px;
    position: absolute;
    font-size: 1.6em;
    font-size: 16px;
    margin: 0;
    right: 90px;
    top: 19px;
    z-index: 2;
    max-width: 3.3em;
    overflow: hidden;
    transition: all ease 500ms;


    ul{
        list-style: none;
        text-transform: uppercase;
        padding: 0;
        overflow: hidden;
        transition: all ease 500ms;
        margin: 0;
        float: right;
        height: 2em;
        width: 11em;

        li{
            padding: 5px;
            display: inline-block;
            width: 2em;
            border: 1px solid #FFF;
            height: 2em;
            line-height: inherit;
            margin-left: 12px;
            text-align: center;
            color: #fff;
            cursor: pointer;
            transition: border-color ease 600ms;
            border-radius: 50%;
            background: #000;
            float: right;

            a{
                color: #fff;
            }

            &:hover{
                border-color: $brand-secondary;

                a{
                    color: $brand-secondary;  
                }                
            }


            &:first-of-type{
                float: right;
            }
            &:last-of-type{
                margin-right : 0;
            }
        }
    }

    &:hover{
        max-width: 12em;
        width: 100%;
    }
}
//select language base to wpml
function languages_list_footer(){
    $languages = icl_get_languages('skip_missing=0&orderby=code');
    if(!empty($languages)){

        echo '<div id="language_list"><ul>';
        
        foreach($languages as $l){ 
            if( $l["active"] == '1' ){
                echo '<li>';
                echo $l['code']; 
                echo '</li>';
                unset($languages[$l['code']]);
            } 
        }

        foreach($languages as $l){
            echo '<li>';
            if($l['active']){
                echo $l['code'];
            } 

            if(!$l['active']){
                echo '<a href="'.$l['url'].'">';
                echo $l['code'];
                echo '</a>';
            } 
            echo '</li>';
        }
        echo '</ul></div>';
    }
}