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
| // put this in functions.php | |
| // this customizes the Google Maps language interface, when Toolset is being used to render Google Maps and WPML is being used to set a language | |
| // if there is a language value set by WPML, then deregister the script enqueued in the Toolset Maps plugin, and rewrite it with a language argument | |
| if ( ! empty( ICL_LANGUAGE_CODE ) ) { | |
| wp_deregister_script( 'google-maps'); | |
| // where FOOBARBAZ is your Google Maps API key | |
| wp_register_script( 'google-maps', 'https://maps.googleapis.com/maps/api/js?libraries=places&key=FOOBARBAZ&ver=3.5.2&language=' . ICL_LANGUAGE_CODE , array(), '3.5.2', true ); |
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
| // put this code in functions.php | |
| // add a body class with the current WPML language | |
| add_filter('body_class', 'append_language_class'); | |
| function append_language_class($classes){ | |
| $classes[] = ICL_LANGUAGE_CODE; //or however you want to name your class based on the language code | |
| return $classes; | |
| } |
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
| /* put this code in header.php */ | |
| <?php | |
| $currentLanguage = ICL_LANGUAGE_CODE; | |
| $jsonCurrentLanguage = wp_json_encode($currentLanguage); | |
| ?> | |
| <script type="text/javascript"> | |
| //<![CDATA[ | |
| var currentLanguageCode = jQuery.parseJSON( ' <?php echo $jsonCurrentLanguage; ?>' ); |
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
| // Put this code in functions.php | |
| // assign the WML constant that stores the current language to a PHP variable. | |
| $currentLanguage = ICL_LANGUAGE_CODE; | |
| // then write javascript to DOM that declares the that variables value as a global javascript variable, for use elsewhere | |
| echo "<script> var currentLanguage = '$currentLanguage';</script>"; |