Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@deckerweb
Created April 26, 2012 22:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save deckerweb/2503953 to your computer and use it in GitHub Desktop.
Save deckerweb/2503953 to your computer and use it in GitHub Desktop.
WPML Plugin: Conditional Switching Languages - helper code
<?php
/**
* WPML: Conditional Switching Languages
*
* @author David Decker - DECKERWEB
* @link http://twitter.com/deckerweb
*
* @global mixed $sitepress
*/
function is_language( $current_lang ) {
global $sitepress;
if ( $current_lang == $sitepress->get_current_language() ) {
return true;
}
}
/**
* *Note:* Be careful with the function name 'is_language' - this only works
* if there's no other function in your install with that name!
* If it's already taken (very rare case though), then just add a prefix
* like `my_custom_is_language()`.
* /
/**
* Support for WPML Language codes like: de, es, nl, fr, ...
* You now can use conditionals like that:
*/
if ( is_language( 'de' ) ) {
// do something for German language...
} elseif ( is_language( 'es' ) ) {
// do something for Spanish language...
} elseif ( is_language( 'nl' ) ) {
// do something for Dutch language...
} elseif ( is_language( 'fr' ) ) {
// do something for French language...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment