-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgravity-forms-country-province-dropdown.php
573 lines (550 loc) · 28.5 KB
/
gravity-forms-country-province-dropdown.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
<?php
/*
Plugin Name: Gravity Forms Country and Province Dropdowns
Description: Provides logic to populate Gravity Forms dropdowns with country and province/state names
Version: 1.0.5
Author: Shawn Hooper, Actionable
*/
class ActionableGravityCountryProvince {
var $countries = array(
['value' => 'CA', 'text' => 'Canada', 'native' => ''],
['value' => 'US', 'text' => 'United States', 'native' => ''],
['value' => 'AU', 'text' => 'Australia', 'native' => ''],
['value' => 'NZ', 'text' => 'New Zealand', 'native' => ''],
['value' => 'AF', 'text' => 'Afghanistan', 'native' => 'غانستان'],
['value' => 'AX', 'text' => 'Åland Islands', 'native' => 'Åland'],
['value' => 'AL', 'text' => 'Albania', 'native' => 'Shqipëri'],
['value' => 'DZ', 'text' => 'Algeria', 'native' => 'الجزائر'],
['value' => 'AS', 'text' => 'American Samoa', 'native' => ''],
['value' => 'AD', 'text' => 'Andorra', 'native' => ''],
['value' => 'AO', 'text' => 'Angola', 'native' => ''],
['value' => 'AI', 'text' => 'Anguilla', 'native' => ''],
['value' => 'AQ', 'text' => 'Antarctica', 'native' => ''],
['value' => 'AG', 'text' => 'Antigua and Barbuda', 'native' => ''],
['value' => 'AR', 'text' => 'Argentina', 'native' => ''],
['value' => 'AM', 'text' => 'Armenia', 'native' => 'Հայաստան'],
['value' => 'AW', 'text' => 'Aruba', 'native' => ''],
['value' => 'AC', 'text' => 'Ascension Island', 'native' => ''],
['value' => 'AT', 'text' => 'Austria', 'native' => 'Österreich'],
['value' => 'AZ', 'text' => 'Azerbaijan', 'native' => 'Azərbaycan'],
['value' => 'BS', 'text' => 'Bahamas', 'native' => ''],
['value' => 'BH', 'text' => 'Bahrain', 'native' => 'البحرين'],
['value' => 'BD', 'text' => 'Bangladesh', 'native' => 'বাংলাদেশ'],
['value' => 'BB', 'text' => 'Barbados', 'native' => ''],
['value' => 'BY', 'text' => 'Belarus', 'native' => 'Беларусь'],
['value' => 'BE', 'text' => 'Belgium', 'native' => 'België'],
['value' => 'BZ', 'text' => 'Belize', 'native' => ''],
['value' => 'BJ', 'text' => 'Benin', 'native' => 'Bénin'],
['value' => 'BM', 'text' => 'Bermuda', 'native' => ''],
['value' => 'BT', 'text' => 'Bhutan', 'native' => 'འབྲུག'],
['value' => 'BO', 'text' => 'Bolivia', 'native' => ''],
['value' => 'BA', 'text' => 'Bosnia and Herzegovina', 'native' => 'Босна и Херцеговина'],
['value' => 'BW', 'text' => 'Botswana', 'native' => ''],
['value' => 'BV', 'text' => 'Bouvet Island', 'native' => ''],
['value' => 'BR', 'text' => 'Brazil', 'native' => 'Brasil'],
['value' => 'IO', 'text' => 'British Indian Ocean Territory', 'native' => ''],
['value' => 'VG', 'text' => 'British Virgin Islands', 'native' => ''],
['value' => 'BN', 'text' => 'Brunei', 'native' => ''],
['value' => 'BG', 'text' => 'Bulgaria', 'native' => 'България'],
['value' => 'BF', 'text' => 'Burkina Faso', 'native' => ''],
['value' => 'BI', 'text' => 'Burundi', 'native' => 'Uburundi'],
['value' => 'KH', 'text' => 'Cambodia', 'native' => 'កម្ពុជា'],
['value' => 'CM', 'text' => 'Cameroon', 'native' => 'Cameroun'],
['value' => 'IC', 'text' => 'Canary Islands', 'native' => 'islas Canarias'],
['value' => 'CV', 'text' => 'Cape Verde', 'native' => 'Kabu Verdi'],
['value' => 'BQ', 'text' => 'Caribbean Netherlands', 'native' => ''],
['value' => 'KY', 'text' => 'Cayman Islands', 'native' => ''],
['value' => 'CF', 'text' => 'Central African Republic', 'native' => 'République centrafricaine'],
['value' => 'EA', 'text' => 'Ceuta and Melilla', 'native' => 'Ceuta y Melilla'],
['value' => 'TD', 'text' => 'Chad', 'native' => 'Tchad'],
['value' => 'CL', 'text' => 'Chile', 'native' => ''],
['value' => 'CN', 'text' => 'China', 'native' => '中国'],
['value' => 'CX', 'text' => 'Christmas Island', 'native' => ''],
['value' => 'CP', 'text' => 'Clipperton Island', 'native' => ''],
['value' => 'CC', 'text' => 'Cocos (Keeling) Islands', 'native' => 'Kepulauan Cocos (Keeling)'],
['value' => 'CO', 'text' => 'Colombia', 'native' => ''],
['value' => 'KM', 'text' => 'Comoros', 'native' => 'جزر القمر'],
['value' => 'CD', 'text' => 'Congo (DRC)', 'native' => 'Jamhuri ya Kidemokrasia ya Kongo'],
['value' => 'CG', 'text' => 'Congo (Republic)', 'native' => 'Congo-Brazzaville'],
['value' => 'CK', 'text' => 'Cook Islands', 'native' => ''],
['value' => 'CR', 'text' => 'Costa Rica', 'native' => ''],
['value' => 'CI', 'text' => 'Côte d’Ivoire', 'native' => ''],
['value' => 'HR', 'text' => 'Croatia', 'native' => 'Hrvatska'],
['value' => 'CU', 'text' => 'Cuba', 'native' => ''],
['value' => 'CW', 'text' => 'Curaçao', 'native' => ''],
['value' => 'CY', 'text' => 'Cyprus', 'native' => 'Κύπρος'],
['value' => 'CZ', 'text' => 'Czech Republic', 'native' => 'Česká republika'],
['value' => 'DK', 'text' => 'Denmark', 'native' => 'Danmark'],
['value' => 'DG', 'text' => 'Diego Garcia', 'native' => ''],
['value' => 'DJ', 'text' => 'Djibouti', 'native' => ''],
['value' => 'DM', 'text' => 'Dominica', 'native' => ''],
['value' => 'DO', 'text' => 'Dominican Republic', 'native' => 'República Dominicana'],
['value' => 'EC', 'text' => 'Ecuador', 'native' => ''],
['value' => 'EG', 'text' => 'Egypt', 'native' => 'مصر'],
['value' => 'SV', 'text' => 'El Salvador', 'native' => ''],
['value' => 'GQ', 'text' => 'Equatorial Guinea', 'native' => 'Guinea Ecuatorial'],
['value' => 'ER', 'text' => 'Eritrea', 'native' => ''],
['value' => 'EE', 'text' => 'Estonia', 'native' => 'Eesti'],
['value' => 'ET', 'text' => 'Ethiopia', 'native' => ''],
['value' => 'FK', 'text' => 'Falkland Islands', 'native' => 'Islas Malvinas'],
['value' => 'FO', 'text' => 'Faroe Islands', 'native' => 'Føroyar'],
['value' => 'FJ', 'text' => 'Fiji', 'native' => ''],
['value' => 'FI', 'text' => 'Finland', 'native' => 'Suomi'],
['value' => 'FR', 'text' => 'France', 'native' => ''],
['value' => 'GF', 'text' => 'French Guiana', 'native' => 'Guyane française'],
['value' => 'PF', 'text' => 'French Polynesia', 'native' => 'Polynésie française'],
['value' => 'TF', 'text' => 'French Southern Territories', 'native' => 'Terres australes françaises'],
['value' => 'GA', 'text' => 'Gabon', 'native' => ''],
['value' => 'GM', 'text' => 'Gambia', 'native' => ''],
['value' => 'GE', 'text' => 'Georgia', 'native' => 'საქართველო'],
['value' => 'DE', 'text' => 'Germany', 'native' => 'Deutschland'],
['value' => 'GH', 'text' => 'Ghana', 'native' => 'Gaana'],
['value' => 'GI', 'text' => 'Gibraltar', 'native' => ''],
['value' => 'GR', 'text' => 'Greece', 'native' => 'Ελλάδα'],
['value' => 'GL', 'text' => 'Greenland', 'native' => 'Kalaallit Nunaat'],
['value' => 'GD', 'text' => 'Grenada', 'native' => ''],
['value' => 'GP', 'text' => 'Guadeloupe', 'native' => ''],
['value' => 'GU', 'text' => 'Guam', 'native' => ''],
['value' => 'GT', 'text' => 'Guatemala', 'native' => ''],
['value' => 'GG', 'text' => 'Guernsey', 'native' => ''],
['value' => 'GN', 'text' => 'Guinea', 'native' => 'Guinée'],
['value' => 'GW', 'text' => 'Guinea-Bissau', 'native' => 'Guiné Bissau'],
['value' => 'GY', 'text' => 'Guyana', 'native' => ''],
['value' => 'HT', 'text' => 'Haiti', 'native' => ''],
['value' => 'HM', 'text' => 'Heard & McDonald Islands', 'native' => ''],
['value' => 'HN', 'text' => 'Honduras', 'native' => ''],
['value' => 'HK', 'text' => 'Hong Kong', 'native' => '香港'],
['value' => 'HU', 'text' => 'Hungary', 'native' => 'Magyarország'],
['value' => 'IS', 'text' => 'Iceland', 'native' => 'Ísland'],
['value' => 'IN', 'text' => 'India', 'native' => 'भारत'],
['value' => 'ID', 'text' => 'Indonesia', 'native' => ''],
['value' => 'IR', 'text' => 'Iran', 'native' => 'ایران'],
['value' => 'IQ', 'text' => 'Iraq', 'native' => 'العراق'],
['value' => 'IE', 'text' => 'Ireland', 'native' => ''],
['value' => 'IM', 'text' => 'Isle of Man', 'native' => ''],
['value' => 'IL', 'text' => 'Israel', 'native' => 'ישראל'],
['value' => 'IT', 'text' => 'Italy', 'native' => 'Italia'],
['value' => 'JM', 'text' => 'Jamaica', 'native' => ''],
['value' => 'JP', 'text' => 'Japan', 'native' => '日本'],
['value' => 'JE', 'text' => 'Jersey', 'native' => ''],
['value' => 'JO', 'text' => 'Jordan', 'native' => 'الأردن'],
['value' => 'KZ', 'text' => 'Kazakhstan', 'native' => 'Казахстан'],
['value' => 'KE', 'text' => 'Kenya', 'native' => ''],
['value' => 'KI', 'text' => 'Kiribati', 'native' => ''],
['value' => 'XK', 'text' => 'Kosovo', 'native' => 'Kosovë'],
['value' => 'KW', 'text' => 'Kuwait', 'native' => 'الكويت'],
['value' => 'KG', 'text' => 'Kyrgyzstan', 'native' => 'Кыргызстан'],
['value' => 'LA', 'text' => 'Laos', 'native' => 'ລາວ'],
['value' => 'LV', 'text' => 'Latvia', 'native' => 'Latvija'],
['value' => 'LB', 'text' => 'Lebanon', 'native' => 'لبنان'],
['value' => 'LS', 'text' => 'Lesotho', 'native' => ''],
['value' => 'LR', 'text' => 'Liberia', 'native' => ''],
['value' => 'LY', 'text' => 'Libya', 'native' => 'ليبيا'],
['value' => 'LI', 'text' => 'Liechtenstein', 'native' => ''],
['value' => 'LT', 'text' => 'Lithuania', 'native' => 'Lietuva'],
['value' => 'LU', 'text' => 'Luxembourg', 'native' => ''],
['value' => 'MO', 'text' => 'Macau', 'native' => '澳門'],
['value' => 'MK', 'text' => 'Macedonia (FYROM)', 'native' => 'Македонија'],
['value' => 'MG', 'text' => 'Madagascar', 'native' => 'Madagasikara'],
['value' => 'MW', 'text' => 'Malawi', 'native' => ''],
['value' => 'MY', 'text' => 'Malaysia', 'native' => ''],
['value' => 'MV', 'text' => 'Maldives', 'native' => ''],
['value' => 'ML', 'text' => 'Mali', 'native' => ''],
['value' => 'MT', 'text' => 'Malta', 'native' => ''],
['value' => 'MH', 'text' => 'Marshall Islands', 'native' => ''],
['value' => 'MQ', 'text' => 'Martinique', 'native' => ''],
['value' => 'MR', 'text' => 'Mauritania', 'native' => 'موريتانيا'],
['value' => 'MU', 'text' => 'Mauritius', 'native' => 'Moris'],
['value' => 'YT', 'text' => 'Mayotte', 'native' => ''],
['value' => 'MX', 'text' => 'Mexico', 'native' => ''],
['value' => 'FM', 'text' => 'Micronesia', 'native' => ''],
['value' => 'MD', 'text' => 'Moldova', 'native' => 'Republica Moldova'],
['value' => 'MC', 'text' => 'Monaco', 'native' => ''],
['value' => 'MN', 'text' => 'Mongolia', 'native' => 'Монгол'],
['value' => 'ME', 'text' => 'Montenegro', 'native' => 'Crna Gora'],
['value' => 'MS', 'text' => 'Montserrat', 'native' => ''],
['value' => 'MA', 'text' => 'Morocco', 'native' => 'المغرب'],
['value' => 'MZ', 'text' => 'Mozambique', 'native' => 'Moçambique'],
['value' => 'MM', 'text' => 'Myanmar (Burma)', 'native' => 'မြန်မာ'],
['value' => 'NA', 'text' => 'Namibia', 'native' => 'Namibië'],
['value' => 'NR', 'text' => 'Nauru', 'native' => ''],
['value' => 'NP', 'text' => 'Nepal', 'native' => 'नेपाल'],
['value' => 'NL', 'text' => 'Netherlands', 'native' => 'Nederland'],
['value' => 'NC', 'text' => 'New Caledonia', 'native' => 'Nouvelle-Calédonie'],
['value' => 'NI', 'text' => 'Nicaragua', 'native' => ''],
['value' => 'NE', 'text' => 'Niger', 'native' => 'Nijar'],
['value' => 'NG', 'text' => 'Nigeria', 'native' => ''],
['value' => 'NU', 'text' => 'Niue', 'native' => ''],
['value' => 'NF', 'text' => 'Norfolk Island', 'native' => ''],
['value' => 'MP', 'text' => 'Northern Mariana Islands', 'native' => ''],
['value' => 'KP', 'text' => 'North Korea', 'native' => '조선 민주주의 인민 공화국'],
['value' => 'NO', 'text' => 'Norway', 'native' => 'Norge'],
['value' => 'OM', 'text' => 'Oman', 'native' => 'عُمان'],
['value' => 'PK', 'text' => 'Pakistan', 'native' => 'پاکستان'],
['value' => 'PW', 'text' => 'Palau', 'native' => ''],
['value' => 'PS', 'text' => 'Palestine', 'native' => 'فلسطين'],
['value' => 'PA', 'text' => 'Panama', 'native' => ''],
['value' => 'PG', 'text' => 'Papua New Guinea', 'native' => ''],
['value' => 'PY', 'text' => 'Paraguay', 'native' => ''],
['value' => 'PE', 'text' => 'Peru', 'native' => 'Perú'],
['value' => 'PH', 'text' => 'Philippines', 'native' => ''],
['value' => 'PN', 'text' => 'Pitcairn Islands', 'native' => ''],
['value' => 'PL', 'text' => 'Poland', 'native' => 'Polska'],
['value' => 'PT', 'text' => 'Portugal', 'native' => ''],
['value' => 'PR', 'text' => 'Puerto Rico', 'native' => ''],
['value' => 'QA', 'text' => 'Qatar', 'native' => 'قطر'],
['value' => 'RE', 'text' => 'Réunion', 'native' => 'La Réunion'],
['value' => 'RO', 'text' => 'Romania', 'native' => 'România'],
['value' => 'RU', 'text' => 'Russia', 'native' => 'Россия'],
['value' => 'RW', 'text' => 'Rwanda', 'native' => ''],
['value' => 'BL', 'text' => 'Saint Barthélemy', 'native' => 'Saint-Barthélemy'],
['value' => 'SH', 'text' => 'Saint Helena', 'native' => ''],
['value' => 'KN', 'text' => 'Saint Kitts and Nevis', 'native' => ''],
['value' => 'LC', 'text' => 'Saint Lucia', 'native' => ''],
['value' => 'MF', 'text' => 'Saint Martin', 'native' => ''],
['value' => 'PM', 'text' => 'Saint Pierre and Miquelon', 'native' => 'Saint-Pierre-et-Miquelon'],
['value' => 'WS', 'text' => 'Samoa', 'native' => ''],
['value' => 'SM', 'text' => 'San Marino', 'native' => ''],
['value' => 'ST', 'text' => 'São Tomé and Príncipe', 'native' => 'São Tomé e Príncipe'],
['value' => 'SA', 'text' => 'Saudi Arabia', 'native' => 'المملكة العربية السعودية'],
['value' => 'SN', 'text' => 'Senegal', 'native' => 'Sénégal'],
['value' => 'RS', 'text' => 'Serbia', 'native' => 'Србија'],
['value' => 'SC', 'text' => 'Seychelles', 'native' => ''],
['value' => 'SL', 'text' => 'Sierra Leone', 'native' => ''],
['value' => 'SG', 'text' => 'Singapore', 'native' => ''],
['value' => 'SX', 'text' => 'Sint Maarten', 'native' => ''],
['value' => 'SK', 'text' => 'Slovakia', 'native' => 'Slovensko'],
['value' => 'SI', 'text' => 'Slovenia', 'native' => 'Slovenija'],
['value' => 'SB', 'text' => 'Solomon Islands', 'native' => ''],
['value' => 'SO', 'text' => 'Somalia', 'native' => 'Soomaaliya'],
['value' => 'ZA', 'text' => 'South Africa', 'native' => ''],
['value' => 'GS', 'text' => 'South Georgia & South Sandwich Islands', 'native' => ''],
['value' => 'KR', 'text' => 'South Korea', 'native' => '대한민국'],
['value' => 'SS', 'text' => 'South Sudan', 'native' => 'جنوب السودان'],
['value' => 'ES', 'text' => 'Spain', 'native' => 'España'],
['value' => 'LK', 'text' => 'Sri Lanka', 'native' => 'ශ්රී ලංකාව'],
['value' => 'VC', 'text' => 'St. Vincent & Grenadines', 'native' => ''],
['value' => 'SD', 'text' => 'Sudan', 'native' => 'السودان'],
['value' => 'SR', 'text' => 'Suriname', 'native' => ''],
['value' => 'SJ', 'text' => 'Svalbard and Jan Mayen', 'native' => 'Svalbard og Jan Mayen'],
['value' => 'SZ', 'text' => 'Swaziland', 'native' => ''],
['value' => 'SE', 'text' => 'Sweden', 'native' => 'Sverige'],
['value' => 'CH', 'text' => 'Switzerland', 'native' => 'Schweiz'],
['value' => 'SY', 'text' => 'Syria', 'native' => 'سوريا'],
['value' => 'TW', 'text' => 'Taiwan', 'native' => '台灣'],
['value' => 'TJ', 'text' => 'Tajikistan', 'native' => ''],
['value' => 'TZ', 'text' => 'Tanzania', 'native' => ''],
['value' => 'TH', 'text' => 'Thailand', 'native' => 'ไทย'],
['value' => 'TL', 'text' => 'Timor-Leste', 'native' => ''],
['value' => 'TG', 'text' => 'Togo', 'native' => ''],
['value' => 'TK', 'text' => 'Tokelau', 'native' => ''],
['value' => 'TO', 'text' => 'Tonga', 'native' => ''],
['value' => 'TT', 'text' => 'Trinidad and Tobago', 'native' => ''],
['value' => 'TA', 'text' => 'Tristan da Cunha', 'native' => ''],
['value' => 'TN', 'text' => 'Tunisia', 'native' => 'تونس'],
['value' => 'TR', 'text' => 'Turkey', 'native' => 'Türkiye'],
['value' => 'TM', 'text' => 'Turkmenistan', 'native' => ''],
['value' => 'TC', 'text' => 'Turks and Caicos Islands', 'native' => ''],
['value' => 'TV', 'text' => 'Tuvalu', 'native' => ''],
['value' => 'UM', 'text' => 'U.S. Outlying Islands', 'native' => ''],
['value' => 'VI', 'text' => 'U.S. Virgin Islands', 'native' => ''],
['value' => 'UG', 'text' => 'Uganda', 'native' => ''],
['value' => 'UA', 'text' => 'Ukraine', 'native' => 'Україна'],
['value' => 'AE', 'text' => 'United Arab Emirates', 'native' => 'الإمارات العربية المتحدة'],
['value' => 'GB', 'text' => 'United Kingdom', 'native' => ''],
['value' => 'UY', 'text' => 'Uruguay', 'native' => ''],
['value' => 'UZ', 'text' => 'Uzbekistan', 'native' => 'Oʻzbekiston'],
['value' => 'VU', 'text' => 'Vanuatu', 'native' => ''],
['value' => 'VA', 'text' => 'Vatican City', 'native' => 'Città del Vaticano'],
['value' => 'VE', 'text' => 'Venezuela', 'native' => ''],
['value' => 'VN', 'text' => 'Vietnam', 'native' => 'Việt Nam'],
['value' => 'WF', 'text' => 'Wallis and Futuna', 'native' => ''],
['value' => 'EH', 'text' => 'Western Sahara', 'native' => 'الصحراء الغربية'],
['value' => 'YE', 'text' => 'Yemen', 'native' => 'اليمن'],
['value' => 'ZM', 'text' => 'Zambia', 'native' => ''],
['value' => 'ZW', 'text' => 'Zimbabwe', 'native' => ''],
);
var $australian_states = array(
['value' => 'ACT', 'text' => 'Australian Capital Territory'],
['value' => 'NSW', 'text' => 'New South Wales'],
['value' => 'NT' , 'text' => 'Northern Territory'],
['value' => 'QLD', 'text' => 'Queensland'],
['value' => 'SA' , 'text' => 'South Australia'],
['value' => 'TAS', 'text' => 'Tasmania'],
['value' => 'VIC', 'text' => 'Victoria'],
['value' => 'WA' , 'text' => 'Western Australia'],
);
var $canadian_provinces = array(
['value' => 'AB', 'text' => 'Alberta'],
['value' => 'BC', 'text' => 'British Columbia'],
['value' => 'MB', 'text' => 'Manitoba'],
['value' => 'NB', 'text' => 'New Brunswick'],
['value' => 'NF', 'text' => 'Newfoundland'],
['value' => 'NT', 'text' => 'Northwest Territories'],
['value' => 'NS', 'text' => 'Nova Scotia'],
['value' => 'NU', 'text' => 'Nunavut'],
['value' => 'ON', 'text' => 'Ontario'],
['value' => 'PE', 'text' => 'Prince Edward Island'],
['value' => 'QC', 'text' => 'Quebec'],
['value' => 'SK', 'text' => 'Saskatchewan'],
['value' => 'YT', 'text' => 'Yukon'],
);
var $american_states = array(
['value' => 'AL', 'text' => 'Alabama'],
['value' => 'AK', 'text' => 'Alaska'],
['value' => 'AR', 'text' => 'Arkansas'],
['value' => 'AZ', 'text' => 'Arizona'],
['value' => 'CA', 'text' => 'California'],
['value' => 'CO', 'text' => 'Colorado'],
['value' => 'CT', 'text' => 'Connecticut'],
['value' => 'DC', 'text' => 'District of Columbia'],
['value' => 'DE', 'text' => 'Delaware'],
['value' => 'FL', 'text' => 'Florida'],
['value' => 'GA', 'text' => 'Georgia'],
['value' => 'HI', 'text' => 'Hawaii'],
['value' => 'ID', 'text' => 'Idaho'],
['value' => 'IL', 'text' => 'Illinois'],
['value' => 'IN', 'text' => 'Indiana'],
['value' => 'IA', 'text' => 'Iowa'],
['value' => 'KS', 'text' => 'Kansas'],
['value' => 'KY', 'text' => 'Kentucky'],
['value' => 'LA', 'text' => 'Louisiana'],
['value' => 'MA', 'text' => 'Massachusetts'],
['value' => 'MD', 'text' => 'Maryland'],
['value' => 'ME', 'text' => 'Maine'],
['value' => 'MI', 'text' => 'Michigan'],
['value' => 'MN', 'text' => 'Minnesota'],
['value' => 'MO', 'text' => 'Missouri'],
['value' => 'MS', 'text' => 'Mississippi'],
['value' => 'MT', 'text' => 'Montana'],
['value' => 'NC', 'text' => 'North Carolina'],
['value' => 'ND', 'text' => 'North Dakota'],
['value' => 'NE', 'text' => 'Nebraska'],
['value' => 'NH', 'text' => 'New Hampshire'],
['value' => 'NJ', 'text' => 'New Jersey'],
['value' => 'NM', 'text' => 'New Mexico'],
['value' => 'NV', 'text' => 'Nevada'],
['value' => 'NY', 'text' => 'New York'],
['value' => 'OH', 'text' => 'Ohio'],
['value' => 'OK', 'text' => 'Oklahoma'],
['value' => 'OR', 'text' => 'Oregon'],
['value' => 'PA', 'text' => 'Pennsylvania'],
['value' => 'RI', 'text' => 'Rhode Island'],
['value' => 'SC', 'text' => 'South Carolina'],
['value' => 'SD', 'text' => 'South Dakota'],
['value' => 'TN', 'text' => 'Tennessee'],
['value' => 'TX', 'text' => 'Texas'],
['value' => 'UT', 'text' => 'Utah'],
['value' => 'VA', 'text' => 'Virginia'],
['value' => 'VT', 'text' => 'Vermont'],
['value' => 'WA', 'text' => 'Washington'],
['value' => 'WI', 'text' => 'Wisconsin'],
['value' => 'WV', 'text' => 'West Virginia'],
['value' => 'WY', 'text' => 'Wyoming'],
);
var $italian_provinces = array(
['value' => 'AG', 'text' => 'Agrigento'],
['value' => 'AL', 'text' => 'Alessandria'],
['value' => 'AN', 'text' => 'Ancona'],
['value' => 'AO', 'text' => 'Aosta'],
['value' => 'AR', 'text' => 'Arezzo'],
['value' => 'AP', 'text' => 'Ascoli Piceno'],
['value' => 'AT', 'text' => 'Asti'],
['value' => 'AV', 'text' => 'Avellino'],
['value' => 'BA', 'text' => 'Bari'],
['value' => 'BT', 'text' => 'Barletta-Andria-Trani'],
['value' => 'BL', 'text' => 'Belluno'],
['value' => 'BN', 'text' => 'Benevento'],
['value' => 'BG', 'text' => 'Bergamo'],
['value' => 'BI', 'text' => 'Biella'],
['value' => 'BO', 'text' => 'Bologna'],
['value' => 'BZ', 'text' => 'Bolzano'],
['value' => 'BS', 'text' => 'Brescia'],
['value' => 'BR', 'text' => 'Brindisi'],
['value' => 'CA', 'text' => 'Cagliari'],
['value' => 'CL', 'text' => 'Caltanissetta'],
['value' => 'CB', 'text' => 'Campobasso'],
['value' => 'CI', 'text' => 'Carbonia-Iglesias'],
['value' => 'CE', 'text' => 'Caserta'],
['value' => 'CT', 'text' => 'Catania'],
['value' => 'CZ', 'text' => 'Catanzaro'],
['value' => 'CH', 'text' => 'Chieti'],
['value' => 'CO', 'text' => 'Como'],
['value' => 'CS', 'text' => 'Cosenza'],
['value' => 'CR', 'text' => 'Cremona'],
['value' => 'KR', 'text' => 'Crotone'],
['value' => 'CN', 'text' => 'Cuneo'],
['value' => 'EN', 'text' => 'Enna'],
['value' => 'FM', 'text' => 'Fermo'],
['value' => 'FE', 'text' => 'Ferrara'],
['value' => 'FI', 'text' => 'Firenze'],
['value' => 'FG', 'text' => 'Foggia'],
['value' => 'FC', 'text' => 'Forlì-Cesena'],
['value' => 'FR', 'text' => 'Frosinone'],
['value' => 'GE', 'text' => 'Genova'],
['value' => 'GO', 'text' => 'Gorizia'],
['value' => 'GR', 'text' => 'Grosseto'],
['value' => 'IM', 'text' => 'Imperia'],
['value' => 'IS', 'text' => 'Isernia'],
['value' => 'SP', 'text' => 'La Spezia'],
['value' => 'AQ', 'text' => 'L`Aquila'],
['value' => 'LT', 'text' => 'Latina'],
['value' => 'LE', 'text' => 'Lecce'],
['value' => 'LC', 'text' => 'Lecco'],
['value' => 'LI', 'text' => 'Livorno'],
['value' => 'LO', 'text' => 'Lodi'],
['value' => 'LU', 'text' => 'Lucca'],
['value' => 'MC', 'text' => 'Macerata'],
['value' => 'MN', 'text' => 'Mantova'],
['value' => 'MS', 'text' => 'Massa-Carrara'],
['value' => 'MT', 'text' => 'Matera'],
['value' => 'ME', 'text' => 'Messina'],
['value' => 'MI', 'text' => 'Milano'],
['value' => 'MO', 'text' => 'Modena'],
['value' => 'MB', 'text' => 'Monza e della Brianza'],
['value' => 'NA', 'text' => 'Napoli'],
['value' => 'NO', 'text' => 'Novara'],
['value' => 'NU', 'text' => 'Nuoro'],
['value' => 'OT', 'text' => 'Olbia-Tempio'],
['value' => 'OR', 'text' => 'Oristano'],
['value' => 'PD', 'text' => 'Padova'],
['value' => 'PA', 'text' => 'Palermo'],
['value' => 'PR', 'text' => 'Parma'],
['value' => 'PV', 'text' => 'Pavia'],
['value' => 'PG', 'text' => 'Perugia'],
['value' => 'PU', 'text' => 'Pesaro e Urbino'],
['value' => 'PE', 'text' => 'Pescara'],
['value' => 'PC', 'text' => 'Piacenza'],
['value' => 'PI', 'text' => 'Pisa'],
['value' => 'PT', 'text' => 'Pistoia'],
['value' => 'PN', 'text' => 'Pordenone'],
['value' => 'PZ', 'text' => 'Potenza'],
['value' => 'PO', 'text' => 'Prato'],
['value' => 'RG', 'text' => 'Ragusa'],
['value' => 'RA', 'text' => 'Ravenna'],
['value' => 'RC', 'text' => 'Reggio Calabria'],
['value' => 'RE', 'text' => 'Reggio Emilia'],
['value' => 'RI', 'text' => 'Rieti'],
['value' => 'RN', 'text' => 'Rimini'],
['value' => 'RM', 'text' => 'Roma'],
['value' => 'RO', 'text' => 'Rovigo'],
['value' => 'SA', 'text' => 'Salerno'],
['value' => 'VS', 'text' => 'Medio Campidano'],
['value' => 'SS', 'text' => 'Sassari'],
['value' => 'SV', 'text' => 'Savona'],
['value' => 'SI', 'text' => 'Siena'],
['value' => 'SR', 'text' => 'Siracusa'],
['value' => 'SO', 'text' => 'Sondrio'],
['value' => 'TA', 'text' => 'Taranto'],
['value' => 'TE', 'text' => 'Teramo'],
['value' => 'TR', 'text' => 'Terni'],
['value' => 'TO', 'text' => 'Torino'],
['value' => 'OG', 'text' => 'Ogliastra'],
['value' => 'TP', 'text' => 'Trapani'],
['value' => 'TN', 'text' => 'Trento'],
['value' => 'TV', 'text' => 'Treviso'],
['value' => 'TS', 'text' => 'Trieste'],
['value' => 'UD', 'text' => 'Udine'],
['value' => 'VA', 'text' => 'Varese'],
['value' => 'VE', 'text' => 'Venezia'],
['value' => 'VB', 'text' => 'Verbano-Cusio-Ossola'],
['value' => 'VC', 'text' => 'Vercelli'],
['value' => 'VR', 'text' => 'Verona'],
['value' => 'VV', 'text' => 'Vibo Valentia'],
['value' => 'VI', 'text' => 'Vicenza'],
['value' => 'VT', 'text' => 'Viterbo'],
);
function __construct() {
add_filter( 'gform_pre_render', array( $this, 'populate_countries_and_provinces' ) );
add_filter( 'gform_pre_validation', array( $this, 'populate_countries_and_provinces' ) );
add_filter( 'gform_pre_submission_filter', array( $this, 'populate_countries_and_provinces' ) );
add_filter( 'gform_admin_pre_render', array( $this, 'populate_countries_and_provinces' ) );
add_filter( 'gform_pre_validation', array( $this, 'set_selected_region_hidden_field' ) );
add_filter( 'gform_pre_submission', array( $this, 'set_selected_region_hidden_field' ) );
}
public function populate_countries_and_provinces( $form ) {
$has_country_list = false;
foreach ( $form['fields'] as &$field ) {
if ( $field->inputName == 'country_list' ) {
$has_country_list = true;
break;
}
}
if ( ! $has_country_list ) {
return $form;
}
foreach ( $form['fields'] as &$field ) {
if ( $field->inputName == 'country_list' ) {
$field->choices = $this->countries;
continue;
}
if ( $field->inputName == 'states_au' ) {
$field->choices = $this->australian_states;
continue;
}
if ( $field->inputName == 'provinces_ca' ) {
$field->choices = $this->canadian_provinces;
continue;
}
if ( $field->inputName == 'states_us' ) {
$field->choices = $this->american_states;
continue;
}
if ( $field->inputName == 'provinces_it' ) {
$field->choices = $this->italian_provinces;
continue;
}
}
return $form;
}
public function set_selected_region_hidden_field( $form ) {
global $_POST;
$hiddenFieldName = '';
$country_ca = '';
$country_au = '';
$country_us = '';
$country_it = '';
$country_list = '';
foreach ( $form['fields'] as &$field ) {
switch ( $field->inputName ) {
case 'selected_region':
$hiddenFieldName = 'input_' . $field->id;
break;
case 'country_list':
$country_list = 'input_' . $field->id;
break;
case 'states_au':
$country_au = 'input_' . $field->id;
break;
case 'provinces_ca':
$country_ca = 'input_' . $field->id;
break;
case 'states_us':
$country_us = 'input_' . $field->id;
break;
case 'provinces_it':
$country_it = 'input_' . $field->id;
break;
}
}
if ( ! isset( $_POST[$country_list] ) ) {
return $form;
}
switch( $_POST[$country_list] ) {
case 'AU':
$_POST[$hiddenFieldName] = $_POST[$country_au];
break;
case 'CA':
$_POST[$hiddenFieldName] = $_POST[$country_ca];
break;
case 'US':
$_POST[$hiddenFieldName] = $_POST[$country_us];
break;
case 'IT':
$_POST[$hiddenFieldName] = $_POST[$country_it];
break;
}
return $form;
}
}
$actionableGravityCountryProvince = new ActionableGravityCountryProvince();