Code tags do not properly work
-
If you add ( in text editor – text mode) code as the below following, nicely wrapped into opening and closing code tags, the inserted code gets messed up.
This is a problem, if you want to build a code library.
Can anybody mention a workaround or solution to this problem?
Test with this Code:
add_filter('wp_nav_menu_items', 'wpml_secondary_lang_nav_menu_item', 10, 2); function wpml_secondary_lang_nav_menu_item($items, $args) { // uncomment this to find your theme's menu location //echo "args: <pre>"; print_r($args); echo "</pre>"; // adjust $args->theme_location == 'primary' in the conditional below to specify the menu location if(function_exists('icl_get_languages') && $args->theme_location == 'primary'){ global $sitepress_settings, $sitepress; $languages = $sitepress->get_ls_languages(); if(!empty($languages)){ // collect secondary languages in array $secondary_languages = array(); foreach($languages as $code => $lang){ if(!$lang['active']){ $secondary_languages[] = $lang; } } if(!empty($secondary_languages)){ $items .= '<li class="menu-item menu-item-language">'; if(isset($args->before)){ $items .= $args->before; } $items .= '<a href="' . $secondary_languages[0]['url'] . '">'; if(isset($args->link_before)){ $items .= $args->link_before; } // from this point on, uncomment whatever output you like // flag-only /*$items .= '<img class="iclflag" src="' . $secondary_languages[0]['country_flag_url'] . '" width="18" height="12" alt="' . $secondary_languages[0]['translated_name'] . '" />';*/ // translated name - only /*$items .= $secondary_languages[0]['translated_name'];*/ if(isset($args->link_after)){ $items .= $args->link_after; } $items .= '</a>'; if(isset($args->after)){ $items .= $args->after; } $items .= '</li>'; } } } return $items; }Actually I am quiet surprised it does not get cut off in this very post!
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘Code tags do not properly work’ is closed to new replies.