Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: WPEX Translate WPML Shortcode
- Plugin URI: http://www.wpexplorer.com
- Description: Adds a shortcode function for translating custom strings with WPML
- Author: AJ Clarke
- Author URI: http://www.wpexplorer.com
- Version: 1.0
- */
- /***WPML Translation Shortcode****/
- if(! function_exists('wpex_wpml_lang_translate')) {
- function wpex_wpml_lang_translate( $atts, $content = null ) {
- extract(shortcode_atts(array(
- 'lang' => '',
- ), $atts));
- $current_lang = ICL_LANGUAGE_CODE; //get WPL current language
- if($lang == $current_lang{
- return do_shortcode($content);
- }
- }
- add_shortcode('wpml_translate', 'wpex_wpml_lang_translate');
- }
- /* USAGE
- *
- *[wpml_translate lang=es]Hola[/wpml_translate]
- *[wpml_translate lang=en]Hello[/wpml_translate]
- *
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement