• Hallo nochmal, Dennis,

    for building a language-switching-links in some multipurpose theme or similar i need a triple of language -> url -> current_language as array/object. I don’t found any function/method to get this information unstyled anywhere.

    I’ve build a helper, but is there an more easy way to get this infos?

    function get_msls_items () {
    
    	return array_map ( 
    
    		function ( $item ) { 
    
    			$cleaned = str_replace ( 
    
    				'"> ', 
    				'">', 
    				preg_replace ( 
    
    					"/<img[^>]+\>/i", 
    					"", 
    					$item 
    				) 
    			); 
    
    			$href = ( array ) ( new SimpleXMLElement ( $cleaned ) ) ['href'];
    
    			return array (
    
    				'href' 		=> $href[0],
    				'text' 		=> strip_tags ( $cleaned ),
    				'current'	=> ( strpos ( $cleaned, 'current_language' ) ) ? 'current_language' : ''
    			);
    		}, 
    		MslsOutput::init () -> get ( MslsOptions::instance () ) 
    	);		
    }

    Thanks,
    Christian

    • This topic was modified 6 years, 3 months ago by krizkroz.
Viewing 1 replies (of 1 total)
  • Plugin Author Dennis Ploetner

    (@realloc)

    It depends … you could consider the filter ‘msls_output_get’.

    /**
     * Returns HTML-link for an item of the output-arr
     * @since 0.9.8
     *
     * @param string $url
     * @param MslsLink $link
     * @param bool current
     */
    $arr[] = ( string ) apply_filters( 'msls_output_get', $url, $link, $current );
    
Viewing 1 replies (of 1 total)
  • The topic ‘More generic retrieving of translation links (frontend)’ is closed to new replies.