• beda69

    (@beda69)


    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)
  • Thread Starter beda69

    (@beda69)

    also pre formatting with <pre and </pre tags, does not really make it nicer

    catacaustic

    (@catacaustic)

    In ‘Text’ mode, the editor will see the HTML tags as just that – tags. Not part of a code snippet. You need to either use the full HTML entities for each tag or enter the code in ‘Visual’ mode.

    Thread Starter beda69

    (@beda69)

    Why is it working in this very forum?

    Does ww.wp.xz.cn use a special plugin or custom code to render the code properly?

    It makes poor sense that the very support forum accepts my code above, but the default (user end) WP “Text” Editor cuts of code, makes <img src> tags to links and $code to /code>

    This is odd.

    Any suggestion from the devs of this very support forum is very welcome

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Code tags do not properly work’ is closed to new replies.