droip
1 week ago
kirki
1 week ago
theme-compatibility
1 day ago
country.php
1 day ago
ecommerce-functions.php
1 day ago
tinymce_translate.php
1 day ago
translate-text.php
1 day ago
tutor-general-functions.php
1 day ago
tutor-template-functions.php
1 day ago
tutor-template-hook.php
4 years ago
country.php
51 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Country List |
| 4 | * |
| 5 | * @package Tutor\Includes |
| 6 | * @author Themeum <support@themeum.com> |
| 7 | * @link https://themeum.com |
| 8 | * @since 3.0.0 |
| 9 | */ |
| 10 | |
| 11 | defined( 'ABSPATH' ) || exit; |
| 12 | |
| 13 | if ( ! function_exists( 'tutor_get_country_list' ) ) { |
| 14 | /** |
| 15 | * Get country list. |
| 16 | * |
| 17 | * @since 3.0.0 |
| 18 | * |
| 19 | * @return array |
| 20 | */ |
| 21 | function tutor_get_country_list() { |
| 22 | $file = trailingslashit( tutor()->path ) . 'assets/json/countries.json'; |
| 23 | if ( ! file_exists( $file ) ) { |
| 24 | return array(); |
| 25 | } |
| 26 | |
| 27 | $data = file_get_contents( $file ); |
| 28 | return json_decode( $data, true ); |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | if ( ! function_exists( 'tutor_get_country_info_by_name' ) ) { |
| 33 | /** |
| 34 | * Get country info by country name |
| 35 | * |
| 36 | * @since 3.0.0 |
| 37 | * |
| 38 | * @param string $country_name country name. |
| 39 | * |
| 40 | * @return array|null |
| 41 | */ |
| 42 | function tutor_get_country_info_by_name( $country_name ) { |
| 43 | $countries = tutor_get_country_list(); |
| 44 | foreach ( $countries as $country ) { |
| 45 | if ( strtolower( $country['name'] ) === strtolower( $country_name ) ) { |
| 46 | return $country; |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | } |
| 51 |