Last active
March 6, 2016 15:19
-
-
Save timersys/16863953e301b84dddb6 to your computer and use it in GitHub Desktop.
Display Maxmind shortcodes in your own language
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 | |
| /** | |
| * In Geotargeting Pro plugin you can print countries and states using shortcodes | |
| * These are printed in English by default but Maxmind provide more languages | |
| * Get WordPress Geotargeting plugin in https://timersys.com/plugins/geotargeting-pro/ | |
| * Cities languages are only included in premium databases or insights services ( https://www.maxmind.com/en/geoip2-precision-services&rld=timersys ) | |
| * Avilable languages: | |
| * de German | |
| * en English English names may still include accented characters if that is the accepted spelling in English. In other words, English does not mean ASCII. | |
| * es Spanish | |
| * fr French | |
| * ja Japanese | |
| * pt-BR Brazilian Portuguese | |
| * ru Russian | |
| * zh-CN Chinese (Simplified) | |
| */ | |
| add_filter( 'geot/shortcodes/country_name', 'my_custom_country_shortcode', 10, 2); | |
| function my_custom_country_shortcode( $country_name, $country ) { | |
| return isset( $country->names ) ? $country->names['ja'] : $country->name; | |
| } | |
| add_filter( 'geot/shortcodes/state_name', 'my_custom_state_shortcode', 10, 2); | |
| function my_custom_state_shortcode( $state_name, $state ) { | |
| return isset( $state->names ) ? $state->names['ja'] : $state->name; | |
| } | |
| /* $city->names only available premium databases or insights services ( https://www.maxmind.com/en/geoip2-precision-services&rld=timersys ) */ | |
| add_filter( 'geot/shortcodes/city_name', 'my_custom_city_shortcode') ; | |
| function my_custom_city_shortcode( $city ) { | |
| return isset( $city->names ) ? $city->names['ja'] : $city; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment