droip
7 months ago
theme-compatibility
4 years ago
country.php
1 year ago
ecommerce-functions.php
10 months ago
tinymce_translate.php
1 year ago
translate-text.php
1 year ago
tutor-general-functions.php
7 months ago
tutor-template-functions.php
9 months ago
tutor-template-hook.php
4 years ago
country.php
53 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 | if ( ! defined( 'ABSPATH' ) ) { |
| 12 | exit; |
| 13 | } |
| 14 | |
| 15 | if ( ! function_exists( 'tutor_get_country_list' ) ) { |
| 16 | /** |
| 17 | * Get country list. |
| 18 | * |
| 19 | * @since 3.0.0 |
| 20 | * |
| 21 | * @return array |
| 22 | */ |
| 23 | function tutor_get_country_list() { |
| 24 | $file = trailingslashit( tutor()->path ) . 'assets/json/countries.json'; |
| 25 | if ( ! file_exists( $file ) ) { |
| 26 | return array(); |
| 27 | } |
| 28 | |
| 29 | $data = file_get_contents( $file ); |
| 30 | return json_decode( $data, true ); |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | if ( ! function_exists( 'tutor_get_country_info_by_name' ) ) { |
| 35 | /** |
| 36 | * Get country info by country name |
| 37 | * |
| 38 | * @since 3.0.0 |
| 39 | * |
| 40 | * @param string $country_name country name. |
| 41 | * |
| 42 | * @return array|null |
| 43 | */ |
| 44 | function tutor_get_country_info_by_name( $country_name ) { |
| 45 | $countries = tutor_get_country_list(); |
| 46 | foreach ( $countries as $country ) { |
| 47 | if ( strtolower( $country['name'] ) === strtolower( $country_name ) ) { |
| 48 | return $country; |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 |