Completed
Pull Request — develop (#977)
by Naveen
02:07
created
src/includes/class-wordlift-countries.php 2 patches
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  * @since   3.18.0
11 11
  */
12 12
 
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -329,12 +329,12 @@  discard block
 block discarded – undo
329 329
 	 *
330 330
 	 * @return array An Array having two maps, country_code_language_map and country_code_name_map.
331 331
 	 */
332
-	public static function parse_country_code_json_file_to_array( $file_name ) {
333
-		$json_file_contents = file_get_contents( $file_name );
334
-		$decoded_array      = json_decode( $json_file_contents, true );
332
+	public static function parse_country_code_json_file_to_array($file_name) {
333
+		$json_file_contents = file_get_contents($file_name);
334
+		$decoded_array      = json_decode($json_file_contents, true);
335 335
 		// decoded array would be null if the json_decode parses
336 336
 		// invalid content.
337
-		if ( null === $decoded_array ) {
337
+		if (null === $decoded_array) {
338 338
 			return array(
339 339
 				'country_code_name_map'     => array(),
340 340
 				'country_code_language_map' => array(),
@@ -345,9 +345,9 @@  discard block
 block discarded – undo
345 345
 			$country_code_language_map = array();
346 346
 			// country_code => country_name map.
347 347
 			$country_code_name_map = array();
348
-			foreach ( $decoded_array as $key => $value ) {
349
-				$country_code_language_map[ $key ] = $value['supportedLang'];
350
-				$country_code_name_map [ $key ]    = $value['defaultLoc']['loc_name'];
348
+			foreach ($decoded_array as $key => $value) {
349
+				$country_code_language_map[$key] = $value['supportedLang'];
350
+				$country_code_name_map [$key]    = $value['defaultLoc']['loc_name'];
351 351
 			}
352 352
 			$result['country_code_language_map'] = $country_code_language_map;
353 353
 			$result['country_code_name_map']     = $country_code_name_map;
@@ -363,9 +363,9 @@  discard block
 block discarded – undo
363 363
 	 *
364 364
 	 * @return array An Array having two maps, country_code_language_map and country_code_name_map.
365 365
 	 */
366
-	public static function get_codes_from_json_file( $file_name ) {
367
-		if ( file_exists( $file_name ) ) {
368
-			return self::parse_country_code_json_file_to_array( $file_name );
366
+	public static function get_codes_from_json_file($file_name) {
367
+		if (file_exists($file_name)) {
368
+			return self::parse_country_code_json_file_to_array($file_name);
369 369
 		} else {
370 370
 			return array(
371 371
 				'country_code_name_map'     => array(),
@@ -394,38 +394,38 @@  discard block
 block discarded – undo
394 394
 	 *
395 395
 	 * @return array An array with country code => country name pairs.
396 396
 	 */
397
-	public static function get_countries( $lang = false ) {
397
+	public static function get_countries($lang = false) {
398 398
 
399 399
 		// Lazily load the countries.
400 400
 		$lang_key = false === $lang ? 'any' : $lang;
401
-		if ( isset( self::$countries[ $lang_key ] ) ) {
402
-			return self::$countries[ $lang_key ];
401
+		if (isset(self::$countries[$lang_key])) {
402
+			return self::$countries[$lang_key];
403 403
 		}
404 404
 
405 405
 		// Prepare the array.
406
-		self::$countries[ $lang ] = array();
406
+		self::$countries[$lang] = array();
407 407
 
408 408
 		// Get the country names from WP's own (multisite) function.
409
-		foreach ( self::$codes as $key => $languages ) {
409
+		foreach (self::$codes as $key => $languages) {
410 410
 			if (
411 411
 				// Process all countries if there is no language specified.
412
-				empty( $lang ) ||
412
+				empty($lang) ||
413 413
 
414 414
 				// Or if there are no language limitations for current country.
415
-				empty( self::$codes[ $key ] ) ||
415
+				empty(self::$codes[$key]) ||
416 416
 
417 417
 				// Or if the language code exists for current country.
418
-				! empty( $lang ) && in_array( $lang, self::$codes[ $key ] )
418
+				! empty($lang) && in_array($lang, self::$codes[$key])
419 419
 			) {
420
-				self::$countries[ $lang_key ][ $key ] = self::format_country_code( $key );
420
+				self::$countries[$lang_key][$key] = self::format_country_code($key);
421 421
 			}
422 422
 		}
423 423
 
424 424
 		// Sort by country name.
425
-		asort( self::$countries[ $lang_key ] );
425
+		asort(self::$countries[$lang_key]);
426 426
 
427 427
 		// We don't sort here because `asort` returns bool instead of sorted array.
428
-		return self::$countries[ $lang_key ];
428
+		return self::$countries[$lang_key];
429 429
 	}
430 430
 
431 431
 	/**
@@ -438,9 +438,9 @@  discard block
 block discarded – undo
438 438
 	 * @return string The country corresponding to $code if it exists. If it does not exist,
439 439
 	 *                then the first two letters of $code is returned.
440 440
 	 */
441
-	private static function format_country_code( $code = '' ) {
441
+	private static function format_country_code($code = '') {
442 442
 
443
-		$code = strtolower( substr( $code, 0, 2 ) );
443
+		$code = strtolower(substr($code, 0, 2));
444 444
 		/**
445 445
 		 * Filters the country codes.
446 446
 		 *
@@ -449,9 +449,9 @@  discard block
 block discarded – undo
449 449
 		 * @param array  $country_codes Key/value pair of country codes where key is the short version.
450 450
 		 * @param string $code A two-letter designation of the country.
451 451
 		 */
452
-		$country_codes = apply_filters( 'country_code', self::$country_codes, $code );
452
+		$country_codes = apply_filters('country_code', self::$country_codes, $code);
453 453
 
454
-		return strtr( $code, $country_codes );
454
+		return strtr($code, $country_codes);
455 455
 	}
456 456
 
457 457
 	/**
@@ -463,17 +463,17 @@  discard block
 block discarded – undo
463 463
 	 *
464 464
 	 * @return string|null The flag url or null if not available.
465 465
 	 */
466
-	public static function get_flag_url( $country_code ) {
466
+	public static function get_flag_url($country_code) {
467 467
 
468 468
 		// Bail out if we don't have the flag.
469
-		if ( ! isset( self::$country_flags[ $country_code ] )
470
-			|| is_null( self::$country_flags[ $country_code ] ) ) {
469
+		if ( ! isset(self::$country_flags[$country_code])
470
+			|| is_null(self::$country_flags[$country_code])) {
471 471
 			return null;
472 472
 		}
473 473
 
474
-		return plugin_dir_url( dirname( __FILE__ ) )
474
+		return plugin_dir_url(dirname(__FILE__))
475 475
 			. 'images/flags/16/'
476
-			. self::$country_flags[ $country_code ]
476
+			. self::$country_flags[$country_code]
477 477
 			. '.png';
478 478
 	}
479 479
 
@@ -486,9 +486,9 @@  discard block
 block discarded – undo
486 486
 	 *
487 487
 	 * @return null|string The country name (in English) or null if not found.
488 488
 	 */
489
-	public static function get_country_name( $country_code ) {
489
+	public static function get_country_name($country_code) {
490 490
 
491
-		return self::$country_codes[ $country_code ];
491
+		return self::$country_codes[$country_code];
492 492
 	}
493 493
 
494 494
 }
Please login to merge, or discard this patch.
Indentation   +449 added lines, -449 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 if ( ! defined( 'ABSPATH' ) ) {
14
-	exit;
14
+    exit;
15 15
 }
16 16
 
17 17
 /**
@@ -21,474 +21,474 @@  discard block
 block discarded – undo
21 21
  */
22 22
 class Wordlift_Countries {
23 23
 
24
-	/**
25
-	 * An array that will contain country codes => country names pairs. It gets lazily loaded the first time by the
26
-	 * `get_countries` function.
27
-	 *
28
-	 * @since 3.18.0
29
-	 * @var array An array of country codes => country names pairs or NULL if not initialized yet.
30
-	 */
31
-	private static $countries = array();
24
+    /**
25
+     * An array that will contain country codes => country names pairs. It gets lazily loaded the first time by the
26
+     * `get_countries` function.
27
+     *
28
+     * @since 3.18.0
29
+     * @var array An array of country codes => country names pairs or NULL if not initialized yet.
30
+     */
31
+    private static $countries = array();
32 32
 
33
-	/**
34
-	 * The list of supported country codes.
35
-	 *
36
-	 * WARNING! If you change the list of supported countries, *you have* to add the related flag
37
-	 * in the images/flags folder.
38
-	 *
39
-	 * @since 3.18.0
40
-	 *
41
-	 * @var array An array of country codes => supported_languages_array
42
-	 */
43
-	public static $codes = array();
33
+    /**
34
+     * The list of supported country codes.
35
+     *
36
+     * WARNING! If you change the list of supported countries, *you have* to add the related flag
37
+     * in the images/flags folder.
38
+     *
39
+     * @since 3.18.0
40
+     *
41
+     * @var array An array of country codes => supported_languages_array
42
+     */
43
+    public static $codes = array();
44 44
 
45
-	/**
46
-	 * The list of country codes.
47
-	 *
48
-	 * WARNING! If you change the list of supported countries, *you have* to add the related flag
49
-	 * in the images/flags folder.
50
-	 *
51
-	 * @since 3.18.0
52
-	 *
53
-	 * @var array An array of country codes => country names.
54
-	 */
55
-	private static $country_codes = array();
45
+    /**
46
+     * The list of country codes.
47
+     *
48
+     * WARNING! If you change the list of supported countries, *you have* to add the related flag
49
+     * in the images/flags folder.
50
+     *
51
+     * @since 3.18.0
52
+     *
53
+     * @var array An array of country codes => country names.
54
+     */
55
+    private static $country_codes = array();
56 56
 
57
-	/**
58
-	 * An array of flag filenames.
59
-	 *
60
-	 * @since 3.20.0
61
-	 *
62
-	 * @var array An array of flag filenames.
63
-	 */
64
-	private static $country_flags = array(
65
-		'af' => 'Afghanistan',
66
-		'ax' => 'Aland',
67
-		'al' => 'Albania',
68
-		'dz' => 'Algeria',
69
-		'as' => 'American-Samoa',
70
-		'ad' => 'Andorra',
71
-		'ao' => 'Angola',
72
-		'ai' => 'Anguilla',
73
-		'aq' => 'Antarctica',
74
-		'ag' => 'Antigua-and-Barbuda',
75
-		'ar' => 'Argentina',
76
-		'am' => 'Armenia',
77
-		'aw' => 'Aruba',
78
-		'au' => 'Australia',
79
-		'at' => 'Austria',
80
-		'az' => 'Azerbaijan',
81
-		'bs' => 'Bahamas',
82
-		'bh' => 'Bahrain',
83
-		'bd' => 'Bangladesh',
84
-		'bb' => 'Barbados',
85
-		'by' => 'Belarus',
86
-		'be' => 'Belgium',
87
-		'bz' => 'Belize',
88
-		'bj' => 'Benin',
89
-		'bm' => 'Bermuda',
90
-		'bt' => 'Bhutan',
91
-		'bo' => 'Bolivia',
92
-		// Uses Netherlands' flag, see https://en.wikipedia.org/wiki/Caribbean_Netherlands.
93
-		'bq' => 'Netherlands',
94
-		'ba' => 'Bosnia-and-Herzegovina',
95
-		'bw' => 'Botswana',
96
-		'bv' => 'Bouvet Island',
97
-		'br' => 'Brazil',
98
-		'io' => null,
99
-		'bn' => 'Brunei',
100
-		'bg' => 'Bulgaria',
101
-		'bf' => 'Burkina-Faso',
102
-		'bi' => 'Burundi',
103
-		'kh' => 'Cambodia',
104
-		'cm' => 'Cameroon',
105
-		'ca' => 'Canada',
106
-		'cv' => 'Cape-Verde',
107
-		'ky' => 'Cayman-Islands',
108
-		'cf' => 'Central-African-Republic',
109
-		'td' => 'Chad',
110
-		'cl' => 'Chile',
111
-		'cn' => 'China',
112
-		'cx' => 'Christmas-Island',
113
-		'cc' => 'Cocos-Keeling-Islands',
114
-		'co' => 'Colombia',
115
-		'km' => 'Comoros',
116
-		'cg' => 'Republic-of-the-Congo',
117
-		'cd' => 'Democratic-Republic-of-the-Congo',
118
-		'ck' => 'Cook-Islands',
119
-		'cr' => 'Costa-Rica',
120
-		'ci' => 'Cote-dIvoire',
121
-		'hr' => 'Croatia',
122
-		'cu' => 'Cuba',
123
-		'cw' => 'Curacao',
124
-		'cy' => 'Cyprus',
125
-		'cz' => 'Czech-Republic',
126
-		'dk' => 'Denmark',
127
-		'dj' => 'Djibouti',
128
-		'dm' => 'Dominica',
129
-		'do' => 'Dominican-Republic',
130
-		'ec' => 'Ecuador',
131
-		'eg' => 'Egypt',
132
-		'sv' => 'El-Salvador',
133
-		'gq' => 'Equatorial-Guinea',
134
-		'er' => 'Eritrea',
135
-		'ee' => 'Estonia',
136
-		'et' => 'Ethiopia',
137
-		'fk' => 'Falkland-Islands',
138
-		'fo' => 'Faroes',
139
-		'fj' => 'Fiji',
140
-		'fi' => 'Finland',
141
-		'fr' => 'France',
142
-		// Uses France's flag, see https://en.wikipedia.org/wiki/French_Guiana.
143
-		'gf' => 'France',
144
-		'pf' => 'French-Polynesia',
145
-		'tf' => 'French-Southern-Territories',
146
-		'ga' => 'Gabon',
147
-		'gm' => 'Gambia',
148
-		'ge' => 'Georgia',
149
-		'de' => 'Germany',
150
-		'gh' => 'Ghana',
151
-		'gi' => 'Gibraltar',
152
-		'gr' => 'Greece',
153
-		'gl' => 'Greenland',
154
-		'gd' => 'Grenada',
155
-		// Uses France's flag, see https://en.wikipedia.org/wiki/Guadeloupe.
156
-		'gp' => 'France',
157
-		'gu' => 'Guam',
158
-		'gt' => 'Guatemala',
159
-		'gg' => 'Guernsey',
160
-		'gn' => 'Guinea',
161
-		'gw' => 'Guinea-Bissau',
162
-		'gy' => 'Guyana',
163
-		'ht' => 'Haiti',
164
-		// Uses Australia's flag, see https://en.wikipedia.org/wiki/Heard_Island_and_McDonald_Islands.
165
-		'hm' => 'Australia',
166
-		'va' => 'Vatican-City',
167
-		'hn' => 'Honduras',
168
-		'hk' => 'Hong-Kong',
169
-		'hu' => 'Hungary',
170
-		'is' => 'Iceland',
171
-		'in' => 'India',
172
-		'id' => 'Indonesia',
173
-		'ir' => 'Iran',
174
-		'iq' => 'Iraq',
175
-		'ie' => 'Ireland',
176
-		'im' => 'Isle-of-Man',
177
-		'il' => 'Israel',
178
-		'it' => 'Italy',
179
-		'jm' => 'Jamaica',
180
-		'jp' => 'Japan',
181
-		'je' => 'Jersey',
182
-		'jo' => 'Jordan',
183
-		'kz' => 'Kazakhstan',
184
-		'ke' => 'Kenya',
185
-		'ki' => 'Kiribati',
186
-		'kp' => 'North-Korea',
187
-		'kr' => 'South-Korea',
188
-		'kw' => 'Kuwait',
189
-		'kg' => 'Kyrgyzstan',
190
-		'la' => 'Laos',
191
-		'lv' => 'Latvia',
192
-		'lb' => 'Lebanon',
193
-		'ls' => 'Lesotho',
194
-		'lr' => 'Liberia',
195
-		'ly' => 'Libya',
196
-		'li' => 'Liechtenstein',
197
-		'lt' => 'Lithuania',
198
-		'lu' => 'Luxembourg',
199
-		'mo' => 'Macau',
200
-		'mk' => 'Macedonia',
201
-		'mg' => 'Madagascar',
202
-		'mw' => 'Malawi',
203
-		'my' => 'Malaysia',
204
-		'mv' => 'Maldives',
205
-		'ml' => 'Mali',
206
-		'mt' => 'Malta',
207
-		'mh' => 'Marshall-Islands',
208
-		'mq' => 'Martinique',
209
-		'mr' => 'Mauritania',
210
-		'mu' => 'Mauritius',
211
-		'yt' => 'Mayotte',
212
-		'mx' => 'Mexico',
213
-		'fm' => 'Micronesia',
214
-		'md' => 'Moldova',
215
-		'mc' => 'Monaco',
216
-		'mn' => 'Mongolia',
217
-		'me' => 'Montenegro',
218
-		'ms' => 'Montserrat',
219
-		'ma' => 'Morocco',
220
-		'mz' => 'Mozambique',
221
-		'mm' => 'Myanmar',
222
-		'na' => 'Namibia',
223
-		'nr' => 'Nauru',
224
-		'np' => 'Nepal',
225
-		'nl' => 'Netherlands',
226
-		'nc' => 'New-Caledonia',
227
-		'nz' => 'New-Zealand',
228
-		'ni' => 'Nicaragua',
229
-		'ne' => 'Niger',
230
-		'ng' => 'Nigeria',
231
-		'nu' => 'Niue',
232
-		'nf' => 'Norfolk-Island',
233
-		'mp' => 'Northern-Mariana-Islands',
234
-		'no' => 'Norway',
235
-		'om' => 'Oman',
236
-		'pk' => 'Pakistan',
237
-		'pw' => 'Palau',
238
-		'ps' => 'Palestine',
239
-		'pa' => 'Panama',
240
-		'pg' => 'Papua-New-Guinea',
241
-		'py' => 'Paraguay',
242
-		'pe' => 'Peru',
243
-		'ph' => 'Philippines',
244
-		'pn' => 'Pitcairn-Islands',
245
-		'pl' => 'Poland',
246
-		'pt' => 'Portugal',
247
-		'pr' => 'Puerto Rico',
248
-		'qa' => 'Qatar',
249
-		// Uses France's flag, see https://en.wikipedia.org/wiki/R%C3%A9union.
250
-		're' => 'France',
251
-		'ro' => 'Romania',
252
-		'ru' => 'Russia',
253
-		'rw' => 'Rwanda',
254
-		'bl' => 'Saint-Barthelemy',
255
-		'sh' => 'Saint-Helena',
256
-		'kn' => 'Saint-Kitts-and-Nevis',
257
-		'lc' => 'Saint-Lucia',
258
-		'mf' => 'Saint-Martin',
259
-		// Uses France's flag, see https://en.wikipedia.org/wiki/Saint_Pierre_and_Miquelon.
260
-		'pm' => 'France',
261
-		'vc' => 'Saint-Vincent-and-the-Grenadines',
262
-		'ws' => 'Samoa',
263
-		'sm' => 'San-Marino',
264
-		'st' => 'Sao-Tome-and-Principe',
265
-		'sa' => 'Saudi-Arabia',
266
-		'sn' => 'Senegal',
267
-		'rs' => 'Serbia',
268
-		'sc' => 'Seychelles',
269
-		'sl' => 'Sierra-Leone',
270
-		'sg' => 'Singapore',
271
-		'sx' => null,
272
-		'sk' => 'Slovakia',
273
-		'si' => 'Slovenia',
274
-		'sb' => 'Solomon-Islands',
275
-		'so' => 'Somalia',
276
-		'za' => 'South-Africa',
277
-		'gs' => 'South-Georgia-and-the-South-Sandwich-Islands',
278
-		'ss' => 'South-Sudan',
279
-		'es' => 'Spain',
280
-		'lk' => 'Sri-Lanka',
281
-		'sd' => 'Sudan',
282
-		'sr' => 'Suriname',
283
-		// Uses Norway's flag, see https://en.wikipedia.org/wiki/Svalbard_and_Jan_Mayen.
284
-		'sj' => 'Norway',
285
-		'sz' => 'Swaziland',
286
-		'se' => 'Sweden',
287
-		'ch' => 'Switzerland',
288
-		'sy' => 'Syria',
289
-		'tw' => 'Taiwan',
290
-		'tj' => 'Tajikistan',
291
-		'tz' => 'Tanzania',
292
-		'th' => 'Thailand',
293
-		'tl' => 'East-Timor',
294
-		'tg' => 'Togo',
295
-		'tk' => 'Tokelau',
296
-		'to' => 'Tonga',
297
-		'tt' => 'Trinidad-and-Tobago',
298
-		'tn' => 'Tunisia',
299
-		'tr' => 'Turkey',
300
-		'tm' => 'Turkmenistan',
301
-		'tc' => 'Turks-and-Caicos-Islands',
302
-		'tv' => 'Tuvalu',
303
-		'ug' => 'Uganda',
304
-		'ua' => 'Ukraine',
305
-		'ae' => 'United-Arab-Emirates',
306
-		'gb' => 'United-Kingdom',
307
-		'uk' => 'United-Kingdom',
308
-		'us' => 'United-States',
309
-		'um' => 'United-States',
310
-		'uy' => 'Uruguay',
311
-		'uz' => 'Uzbekistan',
312
-		'vu' => 'Vanuatu',
313
-		've' => 'Venezuela',
314
-		'vn' => 'Vietnam',
315
-		'vg' => 'British-Virgin-Islands',
316
-		'vi' => 'US-Virgin-Islands',
317
-		'wf' => 'Wallis-And-Futuna',
318
-		'eh' => 'Western-Sahara',
319
-		'ye' => 'Yemen',
320
-		'zm' => 'Zambia',
321
-		'zw' => 'Zimbabwe',
322
-	);
57
+    /**
58
+     * An array of flag filenames.
59
+     *
60
+     * @since 3.20.0
61
+     *
62
+     * @var array An array of flag filenames.
63
+     */
64
+    private static $country_flags = array(
65
+        'af' => 'Afghanistan',
66
+        'ax' => 'Aland',
67
+        'al' => 'Albania',
68
+        'dz' => 'Algeria',
69
+        'as' => 'American-Samoa',
70
+        'ad' => 'Andorra',
71
+        'ao' => 'Angola',
72
+        'ai' => 'Anguilla',
73
+        'aq' => 'Antarctica',
74
+        'ag' => 'Antigua-and-Barbuda',
75
+        'ar' => 'Argentina',
76
+        'am' => 'Armenia',
77
+        'aw' => 'Aruba',
78
+        'au' => 'Australia',
79
+        'at' => 'Austria',
80
+        'az' => 'Azerbaijan',
81
+        'bs' => 'Bahamas',
82
+        'bh' => 'Bahrain',
83
+        'bd' => 'Bangladesh',
84
+        'bb' => 'Barbados',
85
+        'by' => 'Belarus',
86
+        'be' => 'Belgium',
87
+        'bz' => 'Belize',
88
+        'bj' => 'Benin',
89
+        'bm' => 'Bermuda',
90
+        'bt' => 'Bhutan',
91
+        'bo' => 'Bolivia',
92
+        // Uses Netherlands' flag, see https://en.wikipedia.org/wiki/Caribbean_Netherlands.
93
+        'bq' => 'Netherlands',
94
+        'ba' => 'Bosnia-and-Herzegovina',
95
+        'bw' => 'Botswana',
96
+        'bv' => 'Bouvet Island',
97
+        'br' => 'Brazil',
98
+        'io' => null,
99
+        'bn' => 'Brunei',
100
+        'bg' => 'Bulgaria',
101
+        'bf' => 'Burkina-Faso',
102
+        'bi' => 'Burundi',
103
+        'kh' => 'Cambodia',
104
+        'cm' => 'Cameroon',
105
+        'ca' => 'Canada',
106
+        'cv' => 'Cape-Verde',
107
+        'ky' => 'Cayman-Islands',
108
+        'cf' => 'Central-African-Republic',
109
+        'td' => 'Chad',
110
+        'cl' => 'Chile',
111
+        'cn' => 'China',
112
+        'cx' => 'Christmas-Island',
113
+        'cc' => 'Cocos-Keeling-Islands',
114
+        'co' => 'Colombia',
115
+        'km' => 'Comoros',
116
+        'cg' => 'Republic-of-the-Congo',
117
+        'cd' => 'Democratic-Republic-of-the-Congo',
118
+        'ck' => 'Cook-Islands',
119
+        'cr' => 'Costa-Rica',
120
+        'ci' => 'Cote-dIvoire',
121
+        'hr' => 'Croatia',
122
+        'cu' => 'Cuba',
123
+        'cw' => 'Curacao',
124
+        'cy' => 'Cyprus',
125
+        'cz' => 'Czech-Republic',
126
+        'dk' => 'Denmark',
127
+        'dj' => 'Djibouti',
128
+        'dm' => 'Dominica',
129
+        'do' => 'Dominican-Republic',
130
+        'ec' => 'Ecuador',
131
+        'eg' => 'Egypt',
132
+        'sv' => 'El-Salvador',
133
+        'gq' => 'Equatorial-Guinea',
134
+        'er' => 'Eritrea',
135
+        'ee' => 'Estonia',
136
+        'et' => 'Ethiopia',
137
+        'fk' => 'Falkland-Islands',
138
+        'fo' => 'Faroes',
139
+        'fj' => 'Fiji',
140
+        'fi' => 'Finland',
141
+        'fr' => 'France',
142
+        // Uses France's flag, see https://en.wikipedia.org/wiki/French_Guiana.
143
+        'gf' => 'France',
144
+        'pf' => 'French-Polynesia',
145
+        'tf' => 'French-Southern-Territories',
146
+        'ga' => 'Gabon',
147
+        'gm' => 'Gambia',
148
+        'ge' => 'Georgia',
149
+        'de' => 'Germany',
150
+        'gh' => 'Ghana',
151
+        'gi' => 'Gibraltar',
152
+        'gr' => 'Greece',
153
+        'gl' => 'Greenland',
154
+        'gd' => 'Grenada',
155
+        // Uses France's flag, see https://en.wikipedia.org/wiki/Guadeloupe.
156
+        'gp' => 'France',
157
+        'gu' => 'Guam',
158
+        'gt' => 'Guatemala',
159
+        'gg' => 'Guernsey',
160
+        'gn' => 'Guinea',
161
+        'gw' => 'Guinea-Bissau',
162
+        'gy' => 'Guyana',
163
+        'ht' => 'Haiti',
164
+        // Uses Australia's flag, see https://en.wikipedia.org/wiki/Heard_Island_and_McDonald_Islands.
165
+        'hm' => 'Australia',
166
+        'va' => 'Vatican-City',
167
+        'hn' => 'Honduras',
168
+        'hk' => 'Hong-Kong',
169
+        'hu' => 'Hungary',
170
+        'is' => 'Iceland',
171
+        'in' => 'India',
172
+        'id' => 'Indonesia',
173
+        'ir' => 'Iran',
174
+        'iq' => 'Iraq',
175
+        'ie' => 'Ireland',
176
+        'im' => 'Isle-of-Man',
177
+        'il' => 'Israel',
178
+        'it' => 'Italy',
179
+        'jm' => 'Jamaica',
180
+        'jp' => 'Japan',
181
+        'je' => 'Jersey',
182
+        'jo' => 'Jordan',
183
+        'kz' => 'Kazakhstan',
184
+        'ke' => 'Kenya',
185
+        'ki' => 'Kiribati',
186
+        'kp' => 'North-Korea',
187
+        'kr' => 'South-Korea',
188
+        'kw' => 'Kuwait',
189
+        'kg' => 'Kyrgyzstan',
190
+        'la' => 'Laos',
191
+        'lv' => 'Latvia',
192
+        'lb' => 'Lebanon',
193
+        'ls' => 'Lesotho',
194
+        'lr' => 'Liberia',
195
+        'ly' => 'Libya',
196
+        'li' => 'Liechtenstein',
197
+        'lt' => 'Lithuania',
198
+        'lu' => 'Luxembourg',
199
+        'mo' => 'Macau',
200
+        'mk' => 'Macedonia',
201
+        'mg' => 'Madagascar',
202
+        'mw' => 'Malawi',
203
+        'my' => 'Malaysia',
204
+        'mv' => 'Maldives',
205
+        'ml' => 'Mali',
206
+        'mt' => 'Malta',
207
+        'mh' => 'Marshall-Islands',
208
+        'mq' => 'Martinique',
209
+        'mr' => 'Mauritania',
210
+        'mu' => 'Mauritius',
211
+        'yt' => 'Mayotte',
212
+        'mx' => 'Mexico',
213
+        'fm' => 'Micronesia',
214
+        'md' => 'Moldova',
215
+        'mc' => 'Monaco',
216
+        'mn' => 'Mongolia',
217
+        'me' => 'Montenegro',
218
+        'ms' => 'Montserrat',
219
+        'ma' => 'Morocco',
220
+        'mz' => 'Mozambique',
221
+        'mm' => 'Myanmar',
222
+        'na' => 'Namibia',
223
+        'nr' => 'Nauru',
224
+        'np' => 'Nepal',
225
+        'nl' => 'Netherlands',
226
+        'nc' => 'New-Caledonia',
227
+        'nz' => 'New-Zealand',
228
+        'ni' => 'Nicaragua',
229
+        'ne' => 'Niger',
230
+        'ng' => 'Nigeria',
231
+        'nu' => 'Niue',
232
+        'nf' => 'Norfolk-Island',
233
+        'mp' => 'Northern-Mariana-Islands',
234
+        'no' => 'Norway',
235
+        'om' => 'Oman',
236
+        'pk' => 'Pakistan',
237
+        'pw' => 'Palau',
238
+        'ps' => 'Palestine',
239
+        'pa' => 'Panama',
240
+        'pg' => 'Papua-New-Guinea',
241
+        'py' => 'Paraguay',
242
+        'pe' => 'Peru',
243
+        'ph' => 'Philippines',
244
+        'pn' => 'Pitcairn-Islands',
245
+        'pl' => 'Poland',
246
+        'pt' => 'Portugal',
247
+        'pr' => 'Puerto Rico',
248
+        'qa' => 'Qatar',
249
+        // Uses France's flag, see https://en.wikipedia.org/wiki/R%C3%A9union.
250
+        're' => 'France',
251
+        'ro' => 'Romania',
252
+        'ru' => 'Russia',
253
+        'rw' => 'Rwanda',
254
+        'bl' => 'Saint-Barthelemy',
255
+        'sh' => 'Saint-Helena',
256
+        'kn' => 'Saint-Kitts-and-Nevis',
257
+        'lc' => 'Saint-Lucia',
258
+        'mf' => 'Saint-Martin',
259
+        // Uses France's flag, see https://en.wikipedia.org/wiki/Saint_Pierre_and_Miquelon.
260
+        'pm' => 'France',
261
+        'vc' => 'Saint-Vincent-and-the-Grenadines',
262
+        'ws' => 'Samoa',
263
+        'sm' => 'San-Marino',
264
+        'st' => 'Sao-Tome-and-Principe',
265
+        'sa' => 'Saudi-Arabia',
266
+        'sn' => 'Senegal',
267
+        'rs' => 'Serbia',
268
+        'sc' => 'Seychelles',
269
+        'sl' => 'Sierra-Leone',
270
+        'sg' => 'Singapore',
271
+        'sx' => null,
272
+        'sk' => 'Slovakia',
273
+        'si' => 'Slovenia',
274
+        'sb' => 'Solomon-Islands',
275
+        'so' => 'Somalia',
276
+        'za' => 'South-Africa',
277
+        'gs' => 'South-Georgia-and-the-South-Sandwich-Islands',
278
+        'ss' => 'South-Sudan',
279
+        'es' => 'Spain',
280
+        'lk' => 'Sri-Lanka',
281
+        'sd' => 'Sudan',
282
+        'sr' => 'Suriname',
283
+        // Uses Norway's flag, see https://en.wikipedia.org/wiki/Svalbard_and_Jan_Mayen.
284
+        'sj' => 'Norway',
285
+        'sz' => 'Swaziland',
286
+        'se' => 'Sweden',
287
+        'ch' => 'Switzerland',
288
+        'sy' => 'Syria',
289
+        'tw' => 'Taiwan',
290
+        'tj' => 'Tajikistan',
291
+        'tz' => 'Tanzania',
292
+        'th' => 'Thailand',
293
+        'tl' => 'East-Timor',
294
+        'tg' => 'Togo',
295
+        'tk' => 'Tokelau',
296
+        'to' => 'Tonga',
297
+        'tt' => 'Trinidad-and-Tobago',
298
+        'tn' => 'Tunisia',
299
+        'tr' => 'Turkey',
300
+        'tm' => 'Turkmenistan',
301
+        'tc' => 'Turks-and-Caicos-Islands',
302
+        'tv' => 'Tuvalu',
303
+        'ug' => 'Uganda',
304
+        'ua' => 'Ukraine',
305
+        'ae' => 'United-Arab-Emirates',
306
+        'gb' => 'United-Kingdom',
307
+        'uk' => 'United-Kingdom',
308
+        'us' => 'United-States',
309
+        'um' => 'United-States',
310
+        'uy' => 'Uruguay',
311
+        'uz' => 'Uzbekistan',
312
+        'vu' => 'Vanuatu',
313
+        've' => 'Venezuela',
314
+        'vn' => 'Vietnam',
315
+        'vg' => 'British-Virgin-Islands',
316
+        'vi' => 'US-Virgin-Islands',
317
+        'wf' => 'Wallis-And-Futuna',
318
+        'eh' => 'Western-Sahara',
319
+        'ye' => 'Yemen',
320
+        'zm' => 'Zambia',
321
+        'zw' => 'Zimbabwe',
322
+    );
323 323
 
324
-	/**
325
-	 * Parse_country_code_json_file_to_array.
326
-	 *
327
-	 * @param  string $file_name The json file name where the supported country
328
-	 * and languages are present.
329
-	 *
330
-	 * @return array An Array having two maps, country_code_language_map and country_code_name_map.
331
-	 */
332
-	public static function parse_country_code_json_file_to_array( $file_name ) {
333
-		$json_file_contents = file_get_contents( $file_name );
334
-		$decoded_array      = json_decode( $json_file_contents, true );
335
-		// decoded array would be null if the json_decode parses
336
-		// invalid content.
337
-		if ( null === $decoded_array ) {
338
-			return array(
339
-				'country_code_name_map'     => array(),
340
-				'country_code_language_map' => array(),
341
-			);
342
-		} else {
343
-			$result = array();
344
-			// country_code => country_language map.
345
-			$country_code_language_map = array();
346
-			// country_code => country_name map.
347
-			$country_code_name_map = array();
348
-			foreach ( $decoded_array as $key => $value ) {
349
-				$country_code_language_map[ $key ] = $value['supportedLang'];
350
-				$country_code_name_map [ $key ]    = $value['defaultLoc']['loc_name'];
351
-			}
352
-			$result['country_code_language_map'] = $country_code_language_map;
353
-			$result['country_code_name_map']     = $country_code_name_map;
354
-			return $result;
355
-		}
356
-	}
357
-	/**
358
-	 * Get the list of WordLift's supported country codes from json file mapping country_code => languages.
359
-	 *
360
-	 * @since 3.22.5.1
361
-	 *
362
-	 * @param string $file_name The json file where the supported country codes and language_codes are stored.
363
-	 *
364
-	 * @return array An Array having two maps, country_code_language_map and country_code_name_map.
365
-	 */
366
-	public static function get_codes_from_json_file( $file_name ) {
367
-		if ( file_exists( $file_name ) ) {
368
-			return self::parse_country_code_json_file_to_array( $file_name );
369
-		} else {
370
-			return array(
371
-				'country_code_name_map'     => array(),
372
-				'country_code_language_map' => array(),
373
-			);
374
-		}
375
-	}
324
+    /**
325
+     * Parse_country_code_json_file_to_array.
326
+     *
327
+     * @param  string $file_name The json file name where the supported country
328
+     * and languages are present.
329
+     *
330
+     * @return array An Array having two maps, country_code_language_map and country_code_name_map.
331
+     */
332
+    public static function parse_country_code_json_file_to_array( $file_name ) {
333
+        $json_file_contents = file_get_contents( $file_name );
334
+        $decoded_array      = json_decode( $json_file_contents, true );
335
+        // decoded array would be null if the json_decode parses
336
+        // invalid content.
337
+        if ( null === $decoded_array ) {
338
+            return array(
339
+                'country_code_name_map'     => array(),
340
+                'country_code_language_map' => array(),
341
+            );
342
+        } else {
343
+            $result = array();
344
+            // country_code => country_language map.
345
+            $country_code_language_map = array();
346
+            // country_code => country_name map.
347
+            $country_code_name_map = array();
348
+            foreach ( $decoded_array as $key => $value ) {
349
+                $country_code_language_map[ $key ] = $value['supportedLang'];
350
+                $country_code_name_map [ $key ]    = $value['defaultLoc']['loc_name'];
351
+            }
352
+            $result['country_code_language_map'] = $country_code_language_map;
353
+            $result['country_code_name_map']     = $country_code_name_map;
354
+            return $result;
355
+        }
356
+    }
357
+    /**
358
+     * Get the list of WordLift's supported country codes from json file mapping country_code => languages.
359
+     *
360
+     * @since 3.22.5.1
361
+     *
362
+     * @param string $file_name The json file where the supported country codes and language_codes are stored.
363
+     *
364
+     * @return array An Array having two maps, country_code_language_map and country_code_name_map.
365
+     */
366
+    public static function get_codes_from_json_file( $file_name ) {
367
+        if ( file_exists( $file_name ) ) {
368
+            return self::parse_country_code_json_file_to_array( $file_name );
369
+        } else {
370
+            return array(
371
+                'country_code_name_map'     => array(),
372
+                'country_code_language_map' => array(),
373
+            );
374
+        }
375
+    }
376 376
 
377
-	/**
378
-	 * Returns the country language pairs.
379
-	 *
380
-	 * @since 3.18.0
381
-	 *
382
-	 * @return array The country language pairs.
383
-	 */
384
-	public static function get_codes() {
385
-		return self::$codes;
386
-	}
377
+    /**
378
+     * Returns the country language pairs.
379
+     *
380
+     * @since 3.18.0
381
+     *
382
+     * @return array The country language pairs.
383
+     */
384
+    public static function get_codes() {
385
+        return self::$codes;
386
+    }
387 387
 
388
-	/**
389
-	 * Get the list of WordLift's supported countries in an array with country code => country name pairs.
390
-	 *
391
-	 * @since 3.18.0
392
-	 *
393
-	 * @param string|false $lang Optional. The language code we are looking for. Default `any`.
394
-	 *
395
-	 * @return array An array with country code => country name pairs.
396
-	 */
397
-	public static function get_countries( $lang = false ) {
388
+    /**
389
+     * Get the list of WordLift's supported countries in an array with country code => country name pairs.
390
+     *
391
+     * @since 3.18.0
392
+     *
393
+     * @param string|false $lang Optional. The language code we are looking for. Default `any`.
394
+     *
395
+     * @return array An array with country code => country name pairs.
396
+     */
397
+    public static function get_countries( $lang = false ) {
398 398
 
399
-		// Lazily load the countries.
400
-		$lang_key = false === $lang ? 'any' : $lang;
401
-		if ( isset( self::$countries[ $lang_key ] ) ) {
402
-			return self::$countries[ $lang_key ];
403
-		}
399
+        // Lazily load the countries.
400
+        $lang_key = false === $lang ? 'any' : $lang;
401
+        if ( isset( self::$countries[ $lang_key ] ) ) {
402
+            return self::$countries[ $lang_key ];
403
+        }
404 404
 
405
-		// Prepare the array.
406
-		self::$countries[ $lang ] = array();
405
+        // Prepare the array.
406
+        self::$countries[ $lang ] = array();
407 407
 
408
-		// Get the country names from WP's own (multisite) function.
409
-		foreach ( self::$codes as $key => $languages ) {
410
-			if (
411
-				// Process all countries if there is no language specified.
412
-				empty( $lang ) ||
408
+        // Get the country names from WP's own (multisite) function.
409
+        foreach ( self::$codes as $key => $languages ) {
410
+            if (
411
+                // Process all countries if there is no language specified.
412
+                empty( $lang ) ||
413 413
 
414
-				// Or if there are no language limitations for current country.
415
-				empty( self::$codes[ $key ] ) ||
414
+                // Or if there are no language limitations for current country.
415
+                empty( self::$codes[ $key ] ) ||
416 416
 
417
-				// Or if the language code exists for current country.
418
-				! empty( $lang ) && in_array( $lang, self::$codes[ $key ] )
419
-			) {
420
-				self::$countries[ $lang_key ][ $key ] = self::format_country_code( $key );
421
-			}
422
-		}
417
+                // Or if the language code exists for current country.
418
+                ! empty( $lang ) && in_array( $lang, self::$codes[ $key ] )
419
+            ) {
420
+                self::$countries[ $lang_key ][ $key ] = self::format_country_code( $key );
421
+            }
422
+        }
423 423
 
424
-		// Sort by country name.
425
-		asort( self::$countries[ $lang_key ] );
424
+        // Sort by country name.
425
+        asort( self::$countries[ $lang_key ] );
426 426
 
427
-		// We don't sort here because `asort` returns bool instead of sorted array.
428
-		return self::$countries[ $lang_key ];
429
-	}
427
+        // We don't sort here because `asort` returns bool instead of sorted array.
428
+        return self::$countries[ $lang_key ];
429
+    }
430 430
 
431
-	/**
432
-	 * Returns the country for a country code. This function is a clone of WP's function provided in `ms.php`.
433
-	 *
434
-	 * @since 3.18.0
435
-	 *
436
-	 * @param string $code Optional. The two-letter country code. Default empty.
437
-	 *
438
-	 * @return string The country corresponding to $code if it exists. If it does not exist,
439
-	 *                then the first two letters of $code is returned.
440
-	 */
441
-	private static function format_country_code( $code = '' ) {
431
+    /**
432
+     * Returns the country for a country code. This function is a clone of WP's function provided in `ms.php`.
433
+     *
434
+     * @since 3.18.0
435
+     *
436
+     * @param string $code Optional. The two-letter country code. Default empty.
437
+     *
438
+     * @return string The country corresponding to $code if it exists. If it does not exist,
439
+     *                then the first two letters of $code is returned.
440
+     */
441
+    private static function format_country_code( $code = '' ) {
442 442
 
443
-		$code = strtolower( substr( $code, 0, 2 ) );
444
-		/**
445
-		 * Filters the country codes.
446
-		 *
447
-		 * @since 3.18.0
448
-		 *
449
-		 * @param array  $country_codes Key/value pair of country codes where key is the short version.
450
-		 * @param string $code A two-letter designation of the country.
451
-		 */
452
-		$country_codes = apply_filters( 'country_code', self::$country_codes, $code );
443
+        $code = strtolower( substr( $code, 0, 2 ) );
444
+        /**
445
+         * Filters the country codes.
446
+         *
447
+         * @since 3.18.0
448
+         *
449
+         * @param array  $country_codes Key/value pair of country codes where key is the short version.
450
+         * @param string $code A two-letter designation of the country.
451
+         */
452
+        $country_codes = apply_filters( 'country_code', self::$country_codes, $code );
453 453
 
454
-		return strtr( $code, $country_codes );
455
-	}
454
+        return strtr( $code, $country_codes );
455
+    }
456 456
 
457
-	/**
458
-	 * Get a flag URL.
459
-	 *
460
-	 * @since 3.20.0
461
-	 *
462
-	 * @param string $country_code The country code.
463
-	 *
464
-	 * @return string|null The flag url or null if not available.
465
-	 */
466
-	public static function get_flag_url( $country_code ) {
457
+    /**
458
+     * Get a flag URL.
459
+     *
460
+     * @since 3.20.0
461
+     *
462
+     * @param string $country_code The country code.
463
+     *
464
+     * @return string|null The flag url or null if not available.
465
+     */
466
+    public static function get_flag_url( $country_code ) {
467 467
 
468
-		// Bail out if we don't have the flag.
469
-		if ( ! isset( self::$country_flags[ $country_code ] )
470
-			|| is_null( self::$country_flags[ $country_code ] ) ) {
471
-			return null;
472
-		}
468
+        // Bail out if we don't have the flag.
469
+        if ( ! isset( self::$country_flags[ $country_code ] )
470
+            || is_null( self::$country_flags[ $country_code ] ) ) {
471
+            return null;
472
+        }
473 473
 
474
-		return plugin_dir_url( dirname( __FILE__ ) )
475
-			. 'images/flags/16/'
476
-			. self::$country_flags[ $country_code ]
477
-			. '.png';
478
-	}
474
+        return plugin_dir_url( dirname( __FILE__ ) )
475
+            . 'images/flags/16/'
476
+            . self::$country_flags[ $country_code ]
477
+            . '.png';
478
+    }
479 479
 
480
-	/**
481
-	 * Get a country name given a country code.
482
-	 *
483
-	 * @since 3.20.0
484
-	 *
485
-	 * @param string $country_code The 2-letters country code.
486
-	 *
487
-	 * @return null|string The country name (in English) or null if not found.
488
-	 */
489
-	public static function get_country_name( $country_code ) {
480
+    /**
481
+     * Get a country name given a country code.
482
+     *
483
+     * @since 3.20.0
484
+     *
485
+     * @param string $country_code The 2-letters country code.
486
+     *
487
+     * @return null|string The country name (in English) or null if not found.
488
+     */
489
+    public static function get_country_name( $country_code ) {
490 490
 
491
-		return self::$country_codes[ $country_code ];
492
-	}
491
+        return self::$country_codes[ $country_code ];
492
+    }
493 493
 
494 494
 }
Please login to merge, or discard this patch.