| 1 |
<?php |
| 2 |
|
| 3 |
if (!defined('WEBTOTEM_INIT') || WEBTOTEM_INIT !== true) { |
| 4 |
if (!headers_sent()) { |
| 5 |
/* Report invalid access if possible. */ |
| 6 |
header('HTTP/1.1 403 Forbidden'); |
| 7 |
} |
| 8 |
exit(1); |
| 9 |
} |
| 10 |
|
| 11 |
/** |
| 12 |
* WebTotem CountryManager class for Wordpress. |
| 13 |
*/ |
| 14 |
class WebTotemCountryManager { |
| 15 |
|
| 16 |
/** |
| 17 |
* An array of country code => country name pairs. |
| 18 |
*/ |
| 19 |
protected $countries; |
| 20 |
|
| 21 |
/** |
| 22 |
* Get an array of all two-letter country code => country name pairs. |
| 23 |
* |
| 24 |
* @return array |
| 25 |
* An array of country code => country name pairs. |
| 26 |
*/ |
| 27 |
public static function getStandardList() { |
| 28 |
$countries = [ |
| 29 |
'AC' => __('Ascension Island', 'wtotem'), |
| 30 |
'AD' => __('Andorra', 'wtotem'), |
| 31 |
'AE' => __('United Arab Emirates', 'wtotem'), |
| 32 |
'AF' => __('Afghanistan', 'wtotem'), |
| 33 |
'AG' => __('Antigua & Barbuda', 'wtotem'), |
| 34 |
'AI' => __('Anguilla', 'wtotem'), |
| 35 |
'AL' => __('Albania', 'wtotem'), |
| 36 |
'AM' => __('Armenia', 'wtotem'), |
| 37 |
'AN' => __('Netherlands Antilles', 'wtotem'), |
| 38 |
'AO' => __('Angola', 'wtotem'), |
| 39 |
'AQ' => __('Antarctica', 'wtotem'), |
| 40 |
'AR' => __('Argentina', 'wtotem'), |
| 41 |
'AS' => __('American Samoa', 'wtotem'), |
| 42 |
'AT' => __('Austria', 'wtotem'), |
| 43 |
'AU' => __('Australia', 'wtotem'), |
| 44 |
'AW' => __('Aruba', 'wtotem'), |
| 45 |
'AX' => __('� |
| 46 |
land Islands', 'wtotem'), |
| 47 |
'AZ' => __('Azerbaijan', 'wtotem'), |
| 48 |
'BA' => __('Bosnia & Herzegovina', 'wtotem'), |
| 49 |
'BB' => __('Barbados', 'wtotem'), |
| 50 |
'BD' => __('Bangladesh', 'wtotem'), |
| 51 |
'BE' => __('Belgium', 'wtotem'), |
| 52 |
'BF' => __('Burkina Faso', 'wtotem'), |
| 53 |
'BG' => __('Bulgaria', 'wtotem'), |
| 54 |
'BH' => __('Bahrain', 'wtotem'), |
| 55 |
'BI' => __('Burundi', 'wtotem'), |
| 56 |
'BJ' => __('Benin', 'wtotem'), |
| 57 |
'BL' => __('St. Barthélemy', 'wtotem'), |
| 58 |
'BM' => __('Bermuda', 'wtotem'), |
| 59 |
'BN' => __('Brunei', 'wtotem'), |
| 60 |
'BO' => __('Bolivia', 'wtotem'), |
| 61 |
'BQ' => __('Caribbean Netherlands', 'wtotem'), |
| 62 |
'BR' => __('Brazil', 'wtotem'), |
| 63 |
'BS' => __('Bahamas', 'wtotem'), |
| 64 |
'BT' => __('Bhutan', 'wtotem'), |
| 65 |
'BV' => __('Bouvet Island', 'wtotem'), |
| 66 |
'BW' => __('Botswana', 'wtotem'), |
| 67 |
'BY' => __('Belarus', 'wtotem'), |
| 68 |
'BZ' => __('Belize', 'wtotem'), |
| 69 |
'CA' => __('Canada', 'wtotem'), |
| 70 |
'CC' => __('Cocos (Keeling) Islands', 'wtotem'), |
| 71 |
'CD' => __('Congo - Kinshasa', 'wtotem'), |
| 72 |
'CF' => __('Central African Republic', 'wtotem'), |
| 73 |
'CG' => __('Congo - Brazzaville', 'wtotem'), |
| 74 |
'CH' => __('Switzerland', 'wtotem'), |
| 75 |
'CI' => __('Côte d’Ivoire', 'wtotem'), |
| 76 |
'CK' => __('Cook Islands', 'wtotem'), |
| 77 |
'CL' => __('Chile', 'wtotem'), |
| 78 |
'CM' => __('Cameroon', 'wtotem'), |
| 79 |
'CN' => __('China', 'wtotem'), |
| 80 |
'CO' => __('Colombia', 'wtotem'), |
| 81 |
'CP' => __('Clipperton Island', 'wtotem'), |
| 82 |
'CR' => __('Costa Rica', 'wtotem'), |
| 83 |
'CU' => __('Cuba', 'wtotem'), |
| 84 |
'CV' => __('Cape Verde', 'wtotem'), |
| 85 |
'CW' => __('Curaçao', 'wtotem'), |
| 86 |
'CX' => __('Christmas Island', 'wtotem'), |
| 87 |
'CY' => __('Cyprus', 'wtotem'), |
| 88 |
'CZ' => __('Czechia', 'wtotem'), |
| 89 |
'DE' => __('Germany', 'wtotem'), |
| 90 |
'DG' => __('Diego Garcia', 'wtotem'), |
| 91 |
'DJ' => __('Djibouti', 'wtotem'), |
| 92 |
'DK' => __('Denmark', 'wtotem'), |
| 93 |
'DM' => __('Dominica', 'wtotem'), |
| 94 |
'DO' => __('Dominican Republic', 'wtotem'), |
| 95 |
'DZ' => __('Algeria', 'wtotem'), |
| 96 |
'EA' => __('Ceuta & Melilla', 'wtotem'), |
| 97 |
'EC' => __('Ecuador', 'wtotem'), |
| 98 |
'EE' => __('Estonia', 'wtotem'), |
| 99 |
'EG' => __('Egypt', 'wtotem'), |
| 100 |
'EH' => __('Western Sahara', 'wtotem'), |
| 101 |
'ER' => __('Eritrea', 'wtotem'), |
| 102 |
'ES' => __('Spain', 'wtotem'), |
| 103 |
'ET' => __('Ethiopia', 'wtotem'), |
| 104 |
'FI' => __('Finland', 'wtotem'), |
| 105 |
'FJ' => __('Fiji', 'wtotem'), |
| 106 |
'FK' => __('Falkland Islands', 'wtotem'), |
| 107 |
'FM' => __('Micronesia', 'wtotem'), |
| 108 |
'FO' => __('Faroe Islands', 'wtotem'), |
| 109 |
'FR' => __('France', 'wtotem'), |
| 110 |
'GA' => __('Gabon', 'wtotem'), |
| 111 |
'GB' => __('United Kingdom', 'wtotem'), |
| 112 |
'GD' => __('Grenada', 'wtotem'), |
| 113 |
'GE' => __('Georgia', 'wtotem'), |
| 114 |
'GF' => __('French Guiana', 'wtotem'), |
| 115 |
'GG' => __('Guernsey', 'wtotem'), |
| 116 |
'GH' => __('Ghana', 'wtotem'), |
| 117 |
'GI' => __('Gibraltar', 'wtotem'), |
| 118 |
'GL' => __('Greenland', 'wtotem'), |
| 119 |
'GM' => __('Gambia', 'wtotem'), |
| 120 |
'GN' => __('Guinea', 'wtotem'), |
| 121 |
'GP' => __('Guadeloupe', 'wtotem'), |
| 122 |
'GQ' => __('Equatorial Guinea', 'wtotem'), |
| 123 |
'GR' => __('Greece', 'wtotem'), |
| 124 |
'GS' => __('South Georgia & South Sandwich Islands', 'wtotem'), |
| 125 |
'GT' => __('Guatemala', 'wtotem'), |
| 126 |
'GU' => __('Guam', 'wtotem'), |
| 127 |
'GW' => __('Guinea-Bissau', 'wtotem'), |
| 128 |
'GY' => __('Guyana', 'wtotem'), |
| 129 |
'HK' => __('Hong Kong SAR China', 'wtotem'), |
| 130 |
'HM' => __('Heard & McDonald Islands', 'wtotem'), |
| 131 |
'HN' => __('Honduras', 'wtotem'), |
| 132 |
'HR' => __('Croatia', 'wtotem'), |
| 133 |
'HT' => __('Haiti', 'wtotem'), |
| 134 |
'HU' => __('Hungary', 'wtotem'), |
| 135 |
'IC' => __('Canary Islands', 'wtotem'), |
| 136 |
'ID' => __('Indonesia', 'wtotem'), |
| 137 |
'IE' => __('Ireland', 'wtotem'), |
| 138 |
'IL' => __('Israel', 'wtotem'), |
| 139 |
'IM' => __('Isle of Man', 'wtotem'), |
| 140 |
'IN' => __('India', 'wtotem'), |
| 141 |
'IO' => __('British Indian Ocean Territory', 'wtotem'), |
| 142 |
'IQ' => __('Iraq', 'wtotem'), |
| 143 |
'IR' => __('Iran', 'wtotem'), |
| 144 |
'IS' => __('Iceland', 'wtotem'), |
| 145 |
'IT' => __('Italy', 'wtotem'), |
| 146 |
'JE' => __('Jersey', 'wtotem'), |
| 147 |
'JM' => __('Jamaica', 'wtotem'), |
| 148 |
'JO' => __('Jordan', 'wtotem'), |
| 149 |
'JP' => __('Japan', 'wtotem'), |
| 150 |
'KE' => __('Kenya', 'wtotem'), |
| 151 |
'KG' => __('Kyrgyzstan', 'wtotem'), |
| 152 |
'KH' => __('Cambodia', 'wtotem'), |
| 153 |
'KI' => __('Kiribati', 'wtotem'), |
| 154 |
'KM' => __('Comoros', 'wtotem'), |
| 155 |
'KN' => __('St. Kitts & Nevis', 'wtotem'), |
| 156 |
'KP' => __('North Korea', 'wtotem'), |
| 157 |
'KR' => __('South Korea', 'wtotem'), |
| 158 |
'KW' => __('Kuwait', 'wtotem'), |
| 159 |
'KY' => __('Cayman Islands', 'wtotem'), |
| 160 |
'KZ' => __('Kazakhstan', 'wtotem'), |
| 161 |
'LA' => __('Laos', 'wtotem'), |
| 162 |
'LB' => __('Lebanon', 'wtotem'), |
| 163 |
'LC' => __('St. Lucia', 'wtotem'), |
| 164 |
'LI' => __('Liechtenstein', 'wtotem'), |
| 165 |
'LK' => __('Sri Lanka', 'wtotem'), |
| 166 |
'LR' => __('Liberia', 'wtotem'), |
| 167 |
'LS' => __('Lesotho', 'wtotem'), |
| 168 |
'LT' => __('Lithuania', 'wtotem'), |
| 169 |
'LU' => __('Luxembourg', 'wtotem'), |
| 170 |
'LV' => __('Latvia', 'wtotem'), |
| 171 |
'LY' => __('Libya', 'wtotem'), |
| 172 |
'MA' => __('Morocco', 'wtotem'), |
| 173 |
'MC' => __('Monaco', 'wtotem'), |
| 174 |
'MD' => __('Moldova', 'wtotem'), |
| 175 |
'ME' => __('Montenegro', 'wtotem'), |
| 176 |
'MF' => __('St. Martin', 'wtotem'), |
| 177 |
'MG' => __('Madagascar', 'wtotem'), |
| 178 |
'MH' => __('Marshall Islands', 'wtotem'), |
| 179 |
'MK' => __('North Macedonia', 'wtotem'), |
| 180 |
'ML' => __('Mali', 'wtotem'), |
| 181 |
'MM' => __('Myanmar (Burma)', 'wtotem'), |
| 182 |
'MN' => __('Mongolia', 'wtotem'), |
| 183 |
'MO' => __('Macao SAR China', 'wtotem'), |
| 184 |
'MP' => __('Northern Mariana Islands', 'wtotem'), |
| 185 |
'MQ' => __('Martinique', 'wtotem'), |
| 186 |
'MR' => __('Mauritania', 'wtotem'), |
| 187 |
'MS' => __('Montserrat', 'wtotem'), |
| 188 |
'MT' => __('Malta', 'wtotem'), |
| 189 |
'MU' => __('Mauritius', 'wtotem'), |
| 190 |
'MV' => __('Maldives', 'wtotem'), |
| 191 |
'MW' => __('Malawi', 'wtotem'), |
| 192 |
'MX' => __('Mexico', 'wtotem'), |
| 193 |
'MY' => __('Malaysia', 'wtotem'), |
| 194 |
'MZ' => __('Mozambique', 'wtotem'), |
| 195 |
'NA' => __('Namibia', 'wtotem'), |
| 196 |
'NC' => __('New Caledonia', 'wtotem'), |
| 197 |
'NE' => __('Niger', 'wtotem'), |
| 198 |
'NF' => __('Norfolk Island', 'wtotem'), |
| 199 |
'NG' => __('Nigeria', 'wtotem'), |
| 200 |
'NI' => __('Nicaragua', 'wtotem'), |
| 201 |
'NL' => __('Netherlands', 'wtotem'), |
| 202 |
'NO' => __('Norway', 'wtotem'), |
| 203 |
'NP' => __('Nepal', 'wtotem'), |
| 204 |
'NR' => __('Nauru', 'wtotem'), |
| 205 |
'NU' => __('Niue', 'wtotem'), |
| 206 |
'NZ' => __('New Zealand', 'wtotem'), |
| 207 |
'OM' => __('Oman', 'wtotem'), |
| 208 |
'PA' => __('Panama', 'wtotem'), |
| 209 |
'PE' => __('Peru', 'wtotem'), |
| 210 |
'PF' => __('French Polynesia', 'wtotem'), |
| 211 |
'PG' => __('Papua New Guinea', 'wtotem'), |
| 212 |
'PH' => __('Philippines', 'wtotem'), |
| 213 |
'PK' => __('Pakistan', 'wtotem'), |
| 214 |
'PL' => __('Poland', 'wtotem'), |
| 215 |
'PM' => __('St. Pierre & Miquelon', 'wtotem'), |
| 216 |
'PN' => __('Pitcairn Islands', 'wtotem'), |
| 217 |
'PR' => __('Puerto Rico', 'wtotem'), |
| 218 |
'PS' => __('Palestinian Territories', 'wtotem'), |
| 219 |
'PT' => __('Portugal', 'wtotem'), |
| 220 |
'PW' => __('Palau', 'wtotem'), |
| 221 |
'PY' => __('Paraguay', 'wtotem'), |
| 222 |
'QA' => __('Qatar', 'wtotem'), |
| 223 |
'QO' => __('Outlying Oceania', 'wtotem'), |
| 224 |
'RE' => __('Réunion', 'wtotem'), |
| 225 |
'RO' => __('Romania', 'wtotem'), |
| 226 |
'RS' => __('Serbia', 'wtotem'), |
| 227 |
'RU' => __('Russia', 'wtotem'), |
| 228 |
'RW' => __('Rwanda', 'wtotem'), |
| 229 |
'SA' => __('Saudi Arabia', 'wtotem'), |
| 230 |
'SB' => __('Solomon Islands', 'wtotem'), |
| 231 |
'SC' => __('Seychelles', 'wtotem'), |
| 232 |
'SD' => __('Sudan', 'wtotem'), |
| 233 |
'SE' => __('Sweden', 'wtotem'), |
| 234 |
'SG' => __('Singapore', 'wtotem'), |
| 235 |
'SH' => __('St. Helena', 'wtotem'), |
| 236 |
'SI' => __('Slovenia', 'wtotem'), |
| 237 |
'SJ' => __('Svalbard & Jan Mayen', 'wtotem'), |
| 238 |
'SK' => __('Slovakia', 'wtotem'), |
| 239 |
'SL' => __('Sierra Leone', 'wtotem'), |
| 240 |
'SM' => __('San Marino', 'wtotem'), |
| 241 |
'SN' => __('Senegal', 'wtotem'), |
| 242 |
'SO' => __('Somalia', 'wtotem'), |
| 243 |
'SR' => __('Suriname', 'wtotem'), |
| 244 |
'SS' => __('South Sudan', 'wtotem'), |
| 245 |
'ST' => __('São Tomé & Príncipe', 'wtotem'), |
| 246 |
'SV' => __('El Salvador', 'wtotem'), |
| 247 |
'SX' => __('Sint Maarten', 'wtotem'), |
| 248 |
'SY' => __('Syria', 'wtotem'), |
| 249 |
'SZ' => __('Eswatini', 'wtotem'), |
| 250 |
'TA' => __('Tristan da Cunha', 'wtotem'), |
| 251 |
'TC' => __('Turks & Caicos Islands', 'wtotem'), |
| 252 |
'TD' => __('Chad', 'wtotem'), |
| 253 |
'TF' => __('French Southern Territories', 'wtotem'), |
| 254 |
'TG' => __('Togo', 'wtotem'), |
| 255 |
'TH' => __('Thailand', 'wtotem'), |
| 256 |
'TJ' => __('Tajikistan', 'wtotem'), |
| 257 |
'TK' => __('Tokelau', 'wtotem'), |
| 258 |
'TL' => __('Timor-Leste', 'wtotem'), |
| 259 |
'TM' => __('Turkmenistan', 'wtotem'), |
| 260 |
'TN' => __('Tunisia', 'wtotem'), |
| 261 |
'TO' => __('Tonga', 'wtotem'), |
| 262 |
'TR' => __('Turkey', 'wtotem'), |
| 263 |
'TT' => __('Trinidad & Tobago', 'wtotem'), |
| 264 |
'TV' => __('Tuvalu', 'wtotem'), |
| 265 |
'TW' => __('Taiwan', 'wtotem'), |
| 266 |
'TZ' => __('Tanzania', 'wtotem'), |
| 267 |
'UA' => __('Ukraine', 'wtotem'), |
| 268 |
'UG' => __('Uganda', 'wtotem'), |
| 269 |
'UM' => __('U.S. Outlying Islands', 'wtotem'), |
| 270 |
'US' => __('United States', 'wtotem'), |
| 271 |
'UY' => __('Uruguay', 'wtotem'), |
| 272 |
'UZ' => __('Uzbekistan', 'wtotem'), |
| 273 |
'VA' => __('Vatican City', 'wtotem'), |
| 274 |
'VC' => __('St. Vincent & Grenadines', 'wtotem'), |
| 275 |
'VE' => __('Venezuela', 'wtotem'), |
| 276 |
'VG' => __('British Virgin Islands', 'wtotem'), |
| 277 |
'VI' => __('U.S. Virgin Islands', 'wtotem'), |
| 278 |
'VN' => __('Vietnam', 'wtotem'), |
| 279 |
'VU' => __('Vanuatu', 'wtotem'), |
| 280 |
'WF' => __('Wallis & Futuna', 'wtotem'), |
| 281 |
'WS' => __('Samoa', 'wtotem'), |
| 282 |
'XK' => __('Kosovo', 'wtotem'), |
| 283 |
'YE' => __('Yemen', 'wtotem'), |
| 284 |
'YT' => __('Mayotte', 'wtotem'), |
| 285 |
'ZA' => __('South Africa', 'wtotem'), |
| 286 |
'ZM' => __('Zambia', 'wtotem'), |
| 287 |
'ZW' => __('Zimbabwe', 'wtotem'), |
| 288 |
]; |
| 289 |
|
| 290 |
// Sort the list. |
| 291 |
natcasesort($countries); |
| 292 |
|
| 293 |
return $countries; |
| 294 |
} |
| 295 |
|
| 296 |
/** |
| 297 |
* Get an array of country code => country name pairs, altered by alter hooks. |
| 298 |
* |
| 299 |
* @return array |
| 300 |
* An array of country code => country name pairs. |
| 301 |
* |
| 302 |
*/ |
| 303 |
public function getList() { |
| 304 |
// Populate the country list if it is not already populated. |
| 305 |
if (!isset($this->countries)) { |
| 306 |
$this->countries = static::getStandardList(); |
| 307 |
} |
| 308 |
|
| 309 |
return $this->countries; |
| 310 |
} |
| 311 |
|
| 312 |
} |
| 313 |
|