Multilingual press switcher for your theme header

If you have multilingual press installed on your multisite you can have a selector or switcher showing on your header by using the following function:

mlp_show_linked_elements();

In fact, you can have this function to show either text or a flag, and to show the current blog or not.  Let’s do a basic configuration:

mlp_show_linked_elements(
  array(
   'link_text' => 'text',
   'show_current_blog' => FALSE
  )
);

Now something better would be to have it always defaulting to whatever plugin is installed.  So let’s do a trick that will allow you to show the language switcher in every possible situation:

<?php if ( function_exists( 'the_msls' ) ): the_msls(); ?>
<?php elseif ( function_exists( 'mlp_show_linked_elements' ) ): 
 mlp_show_linked_elements(
 array(
 'link_text' => 'text',
 'show_current_blog' => FALSE
 )
 );
else: ?> 
 <a class="fr <?php if ( __('en','mytheme') == 'fr' ) echo 'current_language' ?>" href="<?php echo site_url()?>/fr/"></a>
 <a class="en <?php if ( __('en','mytheme') == 'en' ) echo 'current_language' ?>" href="<?php echo site_url()?>/"></a>
 <?php endif; ?>

If you see, we’re setting it to automatically read whatever language plugin is installed on your multisite and if there’s none defaulting to the normal /fr/ configuration.

Feel free to adjust the code to your own scenario!

One Comment Add yours

  1. Rafter says:

    Multisite has been given me headaches since a while!!

Leave a Reply