Advertisement
wpexplorer

Simple WPML Language Shortcode by WPExplorer.com

Sep 17th, 2012
583
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: WPEX Translate WPML Shortcode
  4. Plugin URI: http://www.wpexplorer.com
  5. Description: Adds a shortcode function for translating custom strings with WPML
  6. Author: AJ Clarke
  7. Author URI: http://www.wpexplorer.com
  8. Version: 1.0
  9. */
  10.  
  11. /***WPML Translation Shortcode****/
  12. if(! function_exists('wpex_wpml_lang_translate')) {
  13. function wpex_wpml_lang_translate( $atts, $content = null ) {
  14. extract(shortcode_atts(array(
  15. 'lang' => '',
  16. ), $atts));
  17.  
  18. $current_lang = ICL_LANGUAGE_CODE; //get WPL current language
  19.  
  20. if($lang == $current_lang{
  21. return do_shortcode($content);
  22. }
  23. }
  24. add_shortcode('wpml_translate', 'wpex_wpml_lang_translate');
  25. }
  26.  
  27.  
  28. /* USAGE
  29. *
  30. *[wpml_translate lang=es]Hola[/wpml_translate]
  31. *[wpml_translate lang=en]Hello[/wpml_translate]
  32. *
  33. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement