Created
April 26, 2012 22:58
-
-
Save deckerweb/2503953 to your computer and use it in GitHub Desktop.
WPML Plugin: Conditional Switching Languages - helper code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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