<?php if (cruxstore_is_wpml()) { echo cruxstore_custom_wpml('<li class="language-switcher">', '</li>'); }
/** * Custom wpml * */ function cruxstore_custom_wpml($before = '', $after = '', $ul = 'list-lang navigation-submenu', $active = '') { if (cruxstore_is_wpml()) { $output = $language_html = ''; //$languages = apply_filters( 'wpml_active_languages', null, null ); $languages = icl_get_languages(); if (!empty($languages)) { foreach ($languages as $l) { if ($l['active']) { $selected = 'current'; $currency_lang = $l['language_code']; } else { $selected = ''; } $language_html .= '<li class="' . $selected . '">'; $language_html .= '<a href="' . esc_url($l['url']) . '">'; $language_html .= "<span>" . strtoupper($l['language_code']) . "</span>"; $language_html .= '</a>'; $language_html .= '</li>'; } if ($language_html != '') { $language_html = '<a href="#">' . $active . $currency_lang . '</a><ul class="' . $ul . '">' . $language_html . '</ul>'; } $output .= $language_html; } return $before . $output . $after; } return false; }