PluginProbe
AliNext – WooCommerce Dropshipping Plugin for AliExpress / trunk
AliNext – WooCommerce Dropshipping Plugin for AliExpress vtrunk
ali2woo-lite / includes / classes / model / Country.php

Country.php in AliNext – WooCommerce Dropshipping Plugin for AliExpress trunk, at includes/classes/model/Country.php

93 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Description of Country
5 *
6 * @author Ali2Woo Team
7 */
8
9 namespace AliNext_Lite;;
10
11 class Country
12 {
13 private static $countries = array();
14 private static $states = array();
15 private static $ali_states = array();
16
17 public static function get_countries()
18 {
19 if (empty(self::$countries)) {
20 unload_textdomain('woocommerce');
21 self::$countries = apply_filters('woocommerce_countries', include WC()->plugin_path() . '/i18n/countries.php');
22 if (apply_filters('woocommerce_sort_countries', true) && function_exists('wc_asort_by_locale')) {
23 wc_asort_by_locale(self::$countries);
24 }
25 $locale = determine_locale();
26 $locale = apply_filters('plugin_locale', $locale, 'woocommerce');
27 load_textdomain('woocommerce', WP_LANG_DIR . '/woocommerce/woocommerce-' . $locale . '.mo');
28 load_plugin_textdomain('woocommerce', false, plugin_basename(dirname(WC_PLUGIN_FILE)) . '/i18n/languages');
29 }
30
31 return self::$countries;
32 }
33
34 public static function getHotCountryLabels(): array
35 {
36 return [
37 'BR' => 'Brasil',
38 'US' => 'United States',
39 'UK' => 'United Kingdom',
40 'FR' => 'France',
41 'AU' => 'Australia',
42 ];
43 }
44
45 public static function get_country($code): ?string
46 {
47 $countries = self::get_countries();
48 foreach ($countries as $c => $n) {
49 if ($c === $code) {
50 return $n;
51 }
52 }
53
54 return null;
55 }
56
57 public static function get_states($cc)
58 {
59 if (empty(self::$states)) {
60 unload_textdomain('woocommerce');
61 self::$states = apply_filters('woocommerce_states', include WC()->plugin_path() . '/i18n/states.php');
62 $locale = determine_locale();
63 $locale = apply_filters('plugin_locale', $locale, 'woocommerce');
64 load_textdomain('woocommerce', WP_LANG_DIR . '/woocommerce/woocommerce-' . $locale . '.mo');
65 load_plugin_textdomain('woocommerce', false, plugin_basename(dirname(WC_PLUGIN_FILE)) . '/i18n/languages');
66 }
67
68 if (!is_null($cc)) {
69 return isset(self::$states[$cc]) ? self::$states[$cc] : false;
70 } else {
71 return self::$states;
72 }
73 }
74
75 public static function get_ali_states($cc)
76 {
77 if (empty(self::$ali_states)) {
78 ini_set('memory_limit', -1);
79 // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
80 self::$ali_states = file_get_contents(A2WL()->plugin_path() . '/assets/data/aliexpress_states.json');
81 self::$ali_states = a2wl_json_decode(self::$ali_states);
82 }
83
84 return isset(self::$ali_states[$cc]) ? self::$ali_states[$cc] : array();
85 }
86
87 public static function is_support_other_city($cc)
88 {
89 return in_array($cc, array('BR', 'CL', 'FR', 'IN', 'ID', 'IT', 'KZ', 'KR', 'NL', 'NZ', 'PL', 'RU', 'SA', 'ES', 'TR', 'UA', 'UK', 'US'));
90 }
91
92 }
93