Changeset 2171321
- Timestamp:
- 10/10/2019 05:01:39 PM (6 years ago)
- Location:
- wpengine-geoip
- Files:
-
- 2 added
- 8 edited
- 1 copied
-
tags/1.2.7 (copied) (copied from wpengine-geoip/trunk)
-
tags/1.2.7/class-geoip.php (added)
-
tags/1.2.7/inc/country-list.php (modified) (1 diff)
-
tags/1.2.7/js/admin.js (modified) (1 diff)
-
tags/1.2.7/readme.txt (modified) (5 diffs)
-
tags/1.2.7/wpengine-geoip.php (modified) (2 diffs)
-
trunk/class-geoip.php (added)
-
trunk/inc/country-list.php (modified) (1 diff)
-
trunk/js/admin.js (modified) (1 diff)
-
trunk/readme.txt (modified) (5 diffs)
-
trunk/wpengine-geoip.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wpengine-geoip/tags/1.2.7/inc/country-list.php
r1699836 r2171321 13 13 $countries = array( 14 14 'AF' => array( 15 'country' => 'Afghanistan',15 'country' => 'Afghanistan', 16 16 'continent' => 'AS', 17 17 ), 18 18 'AX' => array( 19 'country' => 'Åland Islands',19 'country' => 'Åland Islands', 20 20 'continent' => 'EU', 21 21 ), 22 22 'AL' => array( 23 'country' => 'Albania',23 'country' => 'Albania', 24 24 'continent' => 'EU', 25 25 ), 26 26 'DZ' => array( 27 'country' => 'Algeria',27 'country' => 'Algeria', 28 28 'continent' => 'AF', 29 29 ), 30 30 'AS' => array( 31 'country' => 'American Samoa',31 'country' => 'American Samoa', 32 32 'continent' => 'OC', 33 33 ), 34 34 'AD' => array( 35 'country' => 'Andorra',35 'country' => 'Andorra', 36 36 'continent' => 'EU', 37 37 ), 38 38 'AO' => array( 39 'country' => 'Angola',39 'country' => 'Angola', 40 40 'continent' => 'AF', 41 41 ), 42 42 'AI' => array( 43 'country' => 'Anguilla',43 'country' => 'Anguilla', 44 44 'continent' => 'NA', 45 45 ), 46 46 'AQ' => array( 47 'country' => 'AN',47 'country' => 'AN', 48 48 'continent' => 'AN', 49 49 ), 50 50 'AG' => array( 51 'country' => 'Antigua and Barbuda',51 'country' => 'Antigua and Barbuda', 52 52 'continent' => 'NA', 53 53 ), 54 54 'AR' => array( 55 'country' => 'Argentina',55 'country' => 'Argentina', 56 56 'continent' => 'SA', 57 57 ), 58 58 'AM' => array( 59 'country' => 'Armenia',59 'country' => 'Armenia', 60 60 'continent' => 'AS', 61 61 ), 62 62 'AW' => array( 63 'country' => 'Aruba',63 'country' => 'Aruba', 64 64 'continent' => 'NA', 65 65 ), 66 66 'AU' => array( 67 'country' => 'Australia',67 'country' => 'Australia', 68 68 'continent' => 'OC', 69 69 ), 70 70 'AT' => array( 71 'country' => 'Austria',71 'country' => 'Austria', 72 72 'continent' => 'EU', 73 73 ), 74 74 'AZ' => array( 75 'country' => 'Azerbaijan',75 'country' => 'Azerbaijan', 76 76 'continent' => 'AS', 77 77 ), 78 78 'BS' => array( 79 'country' => 'Bahamas',79 'country' => 'Bahamas', 80 80 'continent' => 'NA', 81 81 ), 82 82 'BH' => array( 83 'country' => 'Bahrain',83 'country' => 'Bahrain', 84 84 'continent' => 'AS', 85 85 ), 86 86 'BD' => array( 87 'country' => 'Bangladesh',87 'country' => 'Bangladesh', 88 88 'continent' => 'AS', 89 89 ), 90 90 'BB' => array( 91 'country' => 'Barbados',91 'country' => 'Barbados', 92 92 'continent' => 'NA', 93 93 ), 94 94 'BY' => array( 95 'country' => 'Belarus',95 'country' => 'Belarus', 96 96 'continent' => 'EU', 97 97 ), 98 98 'BE' => array( 99 'country' => 'Belgium',99 'country' => 'Belgium', 100 100 'continent' => 'EU', 101 101 ), 102 102 'BZ' => array( 103 'country' => 'Belize',103 'country' => 'Belize', 104 104 'continent' => 'NA', 105 105 ), 106 106 'BJ' => array( 107 'country' => 'Benin',107 'country' => 'Benin', 108 108 'continent' => 'AF', 109 109 ), 110 110 'BM' => array( 111 'country' => 'Bermuda',111 'country' => 'Bermuda', 112 112 'continent' => 'NA', 113 113 ), 114 114 'BT' => array( 115 'country' => 'Bhutan',115 'country' => 'Bhutan', 116 116 'continent' => 'AS', 117 117 ), 118 118 'BO' => array( 119 'country' => 'Bolivia',119 'country' => 'Bolivia', 120 120 'continent' => 'SA', 121 121 ), 122 122 'BA' => array( 123 'country' => 'Bosnia and Herzegovina',123 'country' => 'Bosnia and Herzegovina', 124 124 'continent' => 'EU', 125 125 ), 126 126 'BW' => array( 127 'country' => 'Botswana',127 'country' => 'Botswana', 128 128 'continent' => 'AF', 129 129 ), 130 130 'BV' => array( 131 'country' => 'Bouvet Island',131 'country' => 'Bouvet Island', 132 132 'continent' => 'AN', 133 133 ), 134 134 'BR' => array( 135 'country' => 'Brazil',135 'country' => 'Brazil', 136 136 'continent' => 'SA', 137 137 ), 138 138 'IO' => array( 139 'country' => 'British Indian Ocean Territory',139 'country' => 'British Indian Ocean Territory', 140 140 'continent' => 'AS', 141 141 ), 142 142 'BN' => array( 143 'country' => 'Brunei Darussalam',143 'country' => 'Brunei Darussalam', 144 144 'continent' => 'AS', 145 145 ), 146 146 'BG' => array( 147 'country' => 'Bulgaria',147 'country' => 'Bulgaria', 148 148 'continent' => 'EU', 149 149 ), 150 150 'BF' => array( 151 'country' => 'Burkina Faso',151 'country' => 'Burkina Faso', 152 152 'continent' => 'AF', 153 153 ), 154 154 'BI' => array( 155 'country' => 'Burundi',155 'country' => 'Burundi', 156 156 'continent' => 'AF', 157 157 ), 158 158 'KH' => array( 159 'country' => 'Cambodia',159 'country' => 'Cambodia', 160 160 'continent' => 'AS', 161 161 ), 162 162 'CM' => array( 163 'country' => 'Cameroon',163 'country' => 'Cameroon', 164 164 'continent' => 'AF', 165 165 ), 166 166 'CA' => array( 167 'country' => 'Canada',167 'country' => 'Canada', 168 168 'continent' => 'NA', 169 169 ), 170 170 'CV' => array( 171 'country' => 'Cape Verde',171 'country' => 'Cape Verde', 172 172 'continent' => 'AF', 173 173 ), 174 174 'KY' => array( 175 'country' => 'Cayman Islands',175 'country' => 'Cayman Islands', 176 176 'continent' => 'NA', 177 177 ), 178 178 'CF' => array( 179 'country' => 'Central African Republic',179 'country' => 'Central African Republic', 180 180 'continent' => 'AF', 181 181 ), 182 182 'TD' => array( 183 'country' => 'Chad',183 'country' => 'Chad', 184 184 'continent' => 'AF', 185 185 ), 186 186 'CL' => array( 187 'country' => 'Chile',187 'country' => 'Chile', 188 188 'continent' => 'SA', 189 189 ), 190 190 'CN' => array( 191 'country' => 'China',191 'country' => 'China', 192 192 'continent' => 'AS', 193 193 ), 194 194 'CX' => array( 195 'country' => 'Christmas Island',195 'country' => 'Christmas Island', 196 196 'continent' => 'AS', 197 197 ), 198 198 'CC' => array( 199 'country' => 'Cocos (Keeling) Islands',199 'country' => 'Cocos (Keeling) Islands', 200 200 'continent' => 'AS', 201 201 ), 202 202 'CO' => array( 203 'country' => 'Colombia',203 'country' => 'Colombia', 204 204 'continent' => 'SA', 205 205 ), 206 206 'KM' => array( 207 'country' => 'Comoros',207 'country' => 'Comoros', 208 208 'continent' => 'AF', 209 209 ), 210 210 'CG' => array( 211 'country' => 'Congo',211 'country' => 'Congo', 212 212 'continent' => 'AF', 213 213 ), 214 214 'CD' => array( 215 'country' => 'The Democratic Republic of The Congo',215 'country' => 'The Democratic Republic of The Congo', 216 216 'continent' => 'AF', 217 217 ), 218 218 'CK' => array( 219 'country' => 'Cook Islands',219 'country' => 'Cook Islands', 220 220 'continent' => 'OC', 221 221 ), 222 222 'CR' => array( 223 'country' => 'Costa Rica',223 'country' => 'Costa Rica', 224 224 'continent' => 'NA', 225 225 ), 226 226 'CI' => array( 227 'country' => 'Cote D\'ivoire',227 'country' => 'Cote D\'ivoire', 228 228 'continent' => 'AF', 229 229 ), 230 230 'HR' => array( 231 'country' => 'Croatia',231 'country' => 'Croatia', 232 232 'continent' => 'EU', 233 233 ), 234 234 'CU' => array( 235 'country' => 'Cuba',235 'country' => 'Cuba', 236 236 'continent' => 'NA', 237 237 ), 238 238 'CY' => array( 239 'country' => 'Cyprus',239 'country' => 'Cyprus', 240 240 'continent' => 'AS', 241 241 ), 242 242 'CZ' => array( 243 'country' => 'Czech Republic',243 'country' => 'Czech Republic', 244 244 'continent' => 'EU', 245 245 ), 246 246 'DK' => array( 247 'country' => 'Denmark',247 'country' => 'Denmark', 248 248 'continent' => 'EU', 249 249 ), 250 250 'DJ' => array( 251 'country' => 'Djibouti',251 'country' => 'Djibouti', 252 252 'continent' => 'AF', 253 253 ), 254 254 'DM' => array( 255 'country' => 'Dominica',255 'country' => 'Dominica', 256 256 'continent' => 'NA', 257 257 ), 258 258 'DO' => array( 259 'country' => 'Dominican Republic',259 'country' => 'Dominican Republic', 260 260 'continent' => 'NA', 261 261 ), 262 262 'EC' => array( 263 'country' => 'Ecuador',263 'country' => 'Ecuador', 264 264 'continent' => 'SA', 265 265 ), 266 266 'EG' => array( 267 'country' => 'Egypt',267 'country' => 'Egypt', 268 268 'continent' => 'AF', 269 269 ), 270 270 'SV' => array( 271 'country' => 'El Salvador',271 'country' => 'El Salvador', 272 272 'continent' => 'NA', 273 273 ), 274 274 'GQ' => array( 275 'country' => 'Equatorial Guinea',275 'country' => 'Equatorial Guinea', 276 276 'continent' => 'AF', 277 277 ), 278 278 'ER' => array( 279 'country' => 'Eritrea',279 'country' => 'Eritrea', 280 280 'continent' => 'AF', 281 281 ), 282 282 'EE' => array( 283 'country' => 'Estonia',283 'country' => 'Estonia', 284 284 'continent' => 'EU', 285 285 ), 286 286 'ET' => array( 287 'country' => 'Ethiopia',287 'country' => 'Ethiopia', 288 288 'continent' => 'AF', 289 289 ), 290 290 'FK' => array( 291 'country' => 'Falkland Islands (Malvinas)',291 'country' => 'Falkland Islands (Malvinas)', 292 292 'continent' => 'SA', 293 293 ), 294 294 'FO' => array( 295 'country' => 'Faroe Islands',295 'country' => 'Faroe Islands', 296 296 'continent' => 'EU', 297 297 ), 298 298 'FJ' => array( 299 'country' => 'Fiji',299 'country' => 'Fiji', 300 300 'continent' => 'OC', 301 301 ), 302 302 'FI' => array( 303 'country' => 'Finland',303 'country' => 'Finland', 304 304 'continent' => 'EU', 305 305 ), 306 306 'FR' => array( 307 'country' => 'France',307 'country' => 'France', 308 308 'continent' => 'EU', 309 309 ), 310 310 'GF' => array( 311 'country' => 'French Guiana',311 'country' => 'French Guiana', 312 312 'continent' => 'SA', 313 313 ), 314 314 'PF' => array( 315 'country' => 'French Polynesia',315 'country' => 'French Polynesia', 316 316 'continent' => 'OC', 317 317 ), 318 318 'TF' => array( 319 'country' => 'French Southern Territories',319 'country' => 'French Southern Territories', 320 320 'continent' => 'AN', 321 321 ), 322 322 'GA' => array( 323 'country' => 'Gabon',323 'country' => 'Gabon', 324 324 'continent' => 'AF', 325 325 ), 326 326 'GM' => array( 327 'country' => 'Gambia',327 'country' => 'Gambia', 328 328 'continent' => 'AF', 329 329 ), 330 330 'GE' => array( 331 'country' => 'Georgia',331 'country' => 'Georgia', 332 332 'continent' => 'AS', 333 333 ), 334 334 'DE' => array( 335 'country' => 'Germany',335 'country' => 'Germany', 336 336 'continent' => 'EU', 337 337 ), 338 338 'GH' => array( 339 'country' => 'Ghana',339 'country' => 'Ghana', 340 340 'continent' => 'AF', 341 341 ), 342 342 'GI' => array( 343 'country' => 'Gibraltar',343 'country' => 'Gibraltar', 344 344 'continent' => 'EU', 345 345 ), 346 346 'GR' => array( 347 'country' => 'Greece',347 'country' => 'Greece', 348 348 'continent' => 'EU', 349 349 ), 350 350 'GL' => array( 351 'country' => 'Greenland',351 'country' => 'Greenland', 352 352 'continent' => 'NA', 353 353 ), 354 354 'GD' => array( 355 'country' => 'Grenada',355 'country' => 'Grenada', 356 356 'continent' => 'NA', 357 357 ), 358 358 'GP' => array( 359 'country' => 'Guadeloupe',359 'country' => 'Guadeloupe', 360 360 'continent' => 'NA', 361 361 ), 362 362 'GU' => array( 363 'country' => 'Guam',363 'country' => 'Guam', 364 364 'continent' => 'OC', 365 365 ), 366 366 'GT' => array( 367 'country' => 'Guatemala',367 'country' => 'Guatemala', 368 368 'continent' => 'NA', 369 369 ), 370 370 'GG' => array( 371 'country' => 'Guernsey',371 'country' => 'Guernsey', 372 372 'continent' => 'EU', 373 373 ), 374 374 'GN' => array( 375 'country' => 'Guinea',375 'country' => 'Guinea', 376 376 'continent' => 'AF', 377 377 ), 378 378 'GW' => array( 379 'country' => 'Guinea-bissau',379 'country' => 'Guinea-bissau', 380 380 'continent' => 'AF', 381 381 ), 382 382 'GY' => array( 383 'country' => 'Guyana',383 'country' => 'Guyana', 384 384 'continent' => 'SA', 385 385 ), 386 386 'HT' => array( 387 'country' => 'Haiti',387 'country' => 'Haiti', 388 388 'continent' => 'NA', 389 389 ), 390 390 'HM' => array( 391 'country' => 'Heard Island and Mcdonald Islands',391 'country' => 'Heard Island and Mcdonald Islands', 392 392 'continent' => 'AN', 393 393 ), 394 394 'VA' => array( 395 'country' => 'Holy See (Vatican City State)',395 'country' => 'Holy See (Vatican City State)', 396 396 'continent' => 'EU', 397 397 ), 398 398 'HN' => array( 399 'country' => 'Honduras',399 'country' => 'Honduras', 400 400 'continent' => 'NA', 401 401 ), 402 402 'HK' => array( 403 'country' => 'Hong Kong',403 'country' => 'Hong Kong', 404 404 'continent' => 'AS', 405 405 ), 406 406 'HU' => array( 407 'country' => 'Hungary',407 'country' => 'Hungary', 408 408 'continent' => 'EU', 409 409 ), 410 410 'IS' => array( 411 'country' => 'Iceland',411 'country' => 'Iceland', 412 412 'continent' => 'EU', 413 413 ), 414 414 'IN' => array( 415 'country' => 'India',415 'country' => 'India', 416 416 'continent' => 'AS', 417 417 ), 418 418 'ID' => array( 419 'country' => 'Indonesia',419 'country' => 'Indonesia', 420 420 'continent' => 'AS', 421 421 ), 422 422 'IR' => array( 423 'country' => 'Iran',423 'country' => 'Iran', 424 424 'continent' => 'AS', 425 425 ), 426 426 'IQ' => array( 427 'country' => 'Iraq',427 'country' => 'Iraq', 428 428 'continent' => 'AS', 429 429 ), 430 430 'IE' => array( 431 'country' => 'Ireland',431 'country' => 'Ireland', 432 432 'continent' => 'EU', 433 433 ), 434 434 'IM' => array( 435 'country' => 'Isle of Man',435 'country' => 'Isle of Man', 436 436 'continent' => 'EU', 437 437 ), 438 438 'IL' => array( 439 'country' => 'Israel',439 'country' => 'Israel', 440 440 'continent' => 'AS', 441 441 ), 442 442 'IT' => array( 443 'country' => 'Italy',443 'country' => 'Italy', 444 444 'continent' => 'EU', 445 445 ), 446 446 'JM' => array( 447 'country' => 'Jamaica',447 'country' => 'Jamaica', 448 448 'continent' => 'NA', 449 449 ), 450 450 'JP' => array( 451 'country' => 'Japan',451 'country' => 'Japan', 452 452 'continent' => 'AS', 453 453 ), 454 454 'JE' => array( 455 'country' => 'Jersey',455 'country' => 'Jersey', 456 456 'continent' => 'EU', 457 457 ), 458 458 'JO' => array( 459 'country' => 'Jordan',459 'country' => 'Jordan', 460 460 'continent' => 'AS', 461 461 ), 462 462 'KZ' => array( 463 'country' => 'Kazakhstan',463 'country' => 'Kazakhstan', 464 464 'continent' => 'AS', 465 465 ), 466 466 'KE' => array( 467 'country' => 'Kenya',467 'country' => 'Kenya', 468 468 'continent' => 'AF', 469 469 ), 470 470 'KI' => array( 471 'country' => 'Kiribati',471 'country' => 'Kiribati', 472 472 'continent' => 'OC', 473 473 ), 474 474 'KP' => array( 475 'country' => 'Democratic People\'s Republic of Korea',475 'country' => 'Democratic People\'s Republic of Korea', 476 476 'continent' => 'AS', 477 477 ), 478 478 'KR' => array( 479 'country' => 'Republic of Korea',479 'country' => 'Republic of Korea', 480 480 'continent' => 'AS', 481 481 ), 482 482 'KW' => array( 483 'country' => 'Kuwait',483 'country' => 'Kuwait', 484 484 'continent' => 'AS', 485 485 ), 486 486 'KG' => array( 487 'country' => 'Kyrgyzstan',487 'country' => 'Kyrgyzstan', 488 488 'continent' => 'AS', 489 489 ), 490 490 'LA' => array( 491 'country' => 'Lao People\'s Democratic Republic',491 'country' => 'Lao People\'s Democratic Republic', 492 492 'continent' => 'AS', 493 493 ), 494 494 'LV' => array( 495 'country' => 'Latvia',495 'country' => 'Latvia', 496 496 'continent' => 'EU', 497 497 ), 498 498 'LB' => array( 499 'country' => 'Lebanon',499 'country' => 'Lebanon', 500 500 'continent' => 'AS', 501 501 ), 502 502 'LS' => array( 503 'country' => 'Lesotho',503 'country' => 'Lesotho', 504 504 'continent' => 'AF', 505 505 ), 506 506 'LR' => array( 507 'country' => 'Liberia',507 'country' => 'Liberia', 508 508 'continent' => 'AF', 509 509 ), 510 510 'LY' => array( 511 'country' => 'Libya',511 'country' => 'Libya', 512 512 'continent' => 'AF', 513 513 ), 514 514 'LI' => array( 515 'country' => 'Liechtenstein',515 'country' => 'Liechtenstein', 516 516 'continent' => 'EU', 517 517 ), 518 518 'LT' => array( 519 'country' => 'Lithuania',519 'country' => 'Lithuania', 520 520 'continent' => 'EU', 521 521 ), 522 522 'LU' => array( 523 'country' => 'Luxembourg',523 'country' => 'Luxembourg', 524 524 'continent' => 'EU', 525 525 ), 526 526 'MO' => array( 527 'country' => 'Macao',527 'country' => 'Macao', 528 528 'continent' => 'AS', 529 529 ), 530 530 'MK' => array( 531 'country' => 'Macedonia',531 'country' => 'Macedonia', 532 532 'continent' => 'EU', 533 533 ), 534 534 'MG' => array( 535 'country' => 'Madagascar',535 'country' => 'Madagascar', 536 536 'continent' => 'AF', 537 537 ), 538 538 'MW' => array( 539 'country' => 'Malawi',539 'country' => 'Malawi', 540 540 'continent' => 'AF', 541 541 ), 542 542 'MY' => array( 543 'country' => 'Malaysia',543 'country' => 'Malaysia', 544 544 'continent' => 'AS', 545 545 ), 546 546 'MV' => array( 547 'country' => 'Maldives',547 'country' => 'Maldives', 548 548 'continent' => 'AS', 549 549 ), 550 550 'ML' => array( 551 'country' => 'Mali',551 'country' => 'Mali', 552 552 'continent' => 'AF', 553 553 ), 554 554 'MT' => array( 555 'country' => 'Malta',555 'country' => 'Malta', 556 556 'continent' => 'EU', 557 557 ), 558 558 'MH' => array( 559 'country' => 'Marshall Islands',559 'country' => 'Marshall Islands', 560 560 'continent' => 'OC', 561 561 ), 562 562 'MQ' => array( 563 'country' => 'Martinique',563 'country' => 'Martinique', 564 564 'continent' => 'NA', 565 565 ), 566 566 'MR' => array( 567 'country' => 'Mauritania',567 'country' => 'Mauritania', 568 568 'continent' => 'AF', 569 569 ), 570 570 'MU' => array( 571 'country' => 'Mauritius',571 'country' => 'Mauritius', 572 572 'continent' => 'AF', 573 573 ), 574 574 'YT' => array( 575 'country' => 'Mayotte',575 'country' => 'Mayotte', 576 576 'continent' => 'AF', 577 577 ), 578 578 'MX' => array( 579 'country' => 'Mexico',579 'country' => 'Mexico', 580 580 'continent' => 'NA', 581 581 ), 582 582 'FM' => array( 583 'country' => 'Micronesia',583 'country' => 'Micronesia', 584 584 'continent' => 'OC', 585 585 ), 586 586 'MD' => array( 587 'country' => 'Moldova',587 'country' => 'Moldova', 588 588 'continent' => 'EU', 589 589 ), 590 590 'MC' => array( 591 'country' => 'Monaco',591 'country' => 'Monaco', 592 592 'continent' => 'EU', 593 593 ), 594 594 'MN' => array( 595 'country' => 'Mongolia',595 'country' => 'Mongolia', 596 596 'continent' => 'AS', 597 597 ), 598 598 'ME' => array( 599 'country' => 'Montenegro',599 'country' => 'Montenegro', 600 600 'continent' => 'EU', 601 601 ), 602 602 'MS' => array( 603 'country' => 'Montserrat',603 'country' => 'Montserrat', 604 604 'continent' => 'NA', 605 605 ), 606 606 'MA' => array( 607 'country' => 'Morocco',607 'country' => 'Morocco', 608 608 'continent' => 'AF', 609 609 ), 610 610 'MZ' => array( 611 'country' => 'Mozambique',611 'country' => 'Mozambique', 612 612 'continent' => 'AF', 613 613 ), 614 614 'MM' => array( 615 'country' => 'Myanmar',615 'country' => 'Myanmar', 616 616 'continent' => 'AS', 617 617 ), 618 618 'NA' => array( 619 'country' => 'Namibia',619 'country' => 'Namibia', 620 620 'continent' => 'AF', 621 621 ), 622 622 'NR' => array( 623 'country' => 'Nauru',623 'country' => 'Nauru', 624 624 'continent' => 'OC', 625 625 ), 626 626 'NP' => array( 627 'country' => 'Nepal',627 'country' => 'Nepal', 628 628 'continent' => 'AS', 629 629 ), 630 630 'NL' => array( 631 'country' => 'Netherlands',631 'country' => 'Netherlands', 632 632 'continent' => 'EU', 633 633 ), 634 634 'AN' => array( 635 'country' => 'Netherlands Antilles',635 'country' => 'Netherlands Antilles', 636 636 'continent' => 'NA', 637 637 ), 638 638 'NC' => array( 639 'country' => 'New Caledonia',639 'country' => 'New Caledonia', 640 640 'continent' => 'OC', 641 641 ), 642 642 'NZ' => array( 643 'country' => 'New Zealand',643 'country' => 'New Zealand', 644 644 'continent' => 'OC', 645 645 ), 646 646 'NI' => array( 647 'country' => 'Nicaragua',647 'country' => 'Nicaragua', 648 648 'continent' => 'NA', 649 649 ), 650 650 'NE' => array( 651 'country' => 'Niger',651 'country' => 'Niger', 652 652 'continent' => 'AF', 653 653 ), 654 654 'NG' => array( 655 'country' => 'Nigeria',655 'country' => 'Nigeria', 656 656 'continent' => 'AF', 657 657 ), 658 658 'NU' => array( 659 'country' => 'Niue',659 'country' => 'Niue', 660 660 'continent' => 'OC', 661 661 ), 662 662 'NF' => array( 663 'country' => 'Norfolk Island',663 'country' => 'Norfolk Island', 664 664 'continent' => 'OC', 665 665 ), 666 666 'MP' => array( 667 'country' => 'Northern Mariana Islands',667 'country' => 'Northern Mariana Islands', 668 668 'continent' => 'OC', 669 669 ), 670 670 'NO' => array( 671 'country' => 'Norway',671 'country' => 'Norway', 672 672 'continent' => 'EU', 673 673 ), 674 674 'OM' => array( 675 'country' => 'Oman',675 'country' => 'Oman', 676 676 'continent' => 'AS', 677 677 ), 678 678 'PK' => array( 679 'country' => 'Pakistan',679 'country' => 'Pakistan', 680 680 'continent' => 'AS', 681 681 ), 682 682 'PW' => array( 683 'country' => 'Palau',683 'country' => 'Palau', 684 684 'continent' => 'OC', 685 685 ), 686 686 'PS' => array( 687 'country' => 'Palestinia',687 'country' => 'Palestinia', 688 688 'continent' => 'AS', 689 689 ), 690 690 'PA' => array( 691 'country' => 'Panama',691 'country' => 'Panama', 692 692 'continent' => 'NA', 693 693 ), 694 694 'PG' => array( 695 'country' => 'Papua New Guinea',695 'country' => 'Papua New Guinea', 696 696 'continent' => 'OC', 697 697 ), 698 698 'PY' => array( 699 'country' => 'Paraguay',699 'country' => 'Paraguay', 700 700 'continent' => 'SA', 701 701 ), 702 702 'PE' => array( 703 'country' => 'Peru',703 'country' => 'Peru', 704 704 'continent' => 'SA', 705 705 ), 706 706 'PH' => array( 707 'country' => 'Philippines',707 'country' => 'Philippines', 708 708 'continent' => 'AS', 709 709 ), 710 710 'PN' => array( 711 'country' => 'Pitcairn',711 'country' => 'Pitcairn', 712 712 'continent' => 'OC', 713 713 ), 714 714 'PL' => array( 715 'country' => 'Poland',715 'country' => 'Poland', 716 716 'continent' => 'EU', 717 717 ), 718 718 'PT' => array( 719 'country' => 'Portugal',719 'country' => 'Portugal', 720 720 'continent' => 'EU', 721 721 ), 722 722 'PR' => array( 723 'country' => 'Puerto Rico',723 'country' => 'Puerto Rico', 724 724 'continent' => 'NA', 725 725 ), 726 726 'QA' => array( 727 'country' => 'Qatar',727 'country' => 'Qatar', 728 728 'continent' => 'AS', 729 729 ), 730 730 'RE' => array( 731 'country' => 'Reunion',731 'country' => 'Reunion', 732 732 'continent' => 'AF', 733 733 ), 734 734 'RO' => array( 735 'country' => 'Romania',735 'country' => 'Romania', 736 736 'continent' => 'EU', 737 737 ), 738 738 'RU' => array( 739 'country' => 'Russian Federation',739 'country' => 'Russian Federation', 740 740 'continent' => 'EU', 741 741 ), 742 742 'RW' => array( 743 'country' => 'Rwanda',743 'country' => 'Rwanda', 744 744 'continent' => 'AF', 745 745 ), 746 746 'SH' => array( 747 'country' => 'Saint Helena',747 'country' => 'Saint Helena', 748 748 'continent' => 'AF', 749 749 ), 750 750 'KN' => array( 751 'country' => 'Saint Kitts and Nevis',751 'country' => 'Saint Kitts and Nevis', 752 752 'continent' => 'NA', 753 753 ), 754 754 'LC' => array( 755 'country' => 'Saint Lucia',755 'country' => 'Saint Lucia', 756 756 'continent' => 'NA', 757 757 ), 758 758 'PM' => array( 759 'country' => 'Saint Pierre and Miquelon',759 'country' => 'Saint Pierre and Miquelon', 760 760 'continent' => 'NA', 761 761 ), 762 762 'VC' => array( 763 'country' => 'Saint Vincent and The Grenadines',763 'country' => 'Saint Vincent and The Grenadines', 764 764 'continent' => 'NA', 765 765 ), 766 766 'WS' => array( 767 'country' => 'Samoa',767 'country' => 'Samoa', 768 768 'continent' => 'OC', 769 769 ), 770 770 'SM' => array( 771 'country' => 'San Marino',771 'country' => 'San Marino', 772 772 'continent' => 'EU', 773 773 ), 774 774 'ST' => array( 775 'country' => 'Sao Tome and Principe',775 'country' => 'Sao Tome and Principe', 776 776 'continent' => 'AF', 777 777 ), 778 778 'SA' => array( 779 'country' => 'Saudi Arabia',779 'country' => 'Saudi Arabia', 780 780 'continent' => 'AS', 781 781 ), 782 782 'SN' => array( 783 'country' => 'Senegal',783 'country' => 'Senegal', 784 784 'continent' => 'AF', 785 785 ), 786 786 'RS' => array( 787 'country' => 'Serbia',787 'country' => 'Serbia', 788 788 'continent' => 'EU', 789 789 ), 790 790 'SC' => array( 791 'country' => 'Seychelles',791 'country' => 'Seychelles', 792 792 'continent' => 'AF', 793 793 ), 794 794 'SL' => array( 795 'country' => 'Sierra Leone',795 'country' => 'Sierra Leone', 796 796 'continent' => 'AF', 797 797 ), 798 798 'SG' => array( 799 'country' => 'Singapore',799 'country' => 'Singapore', 800 800 'continent' => 'AS', 801 801 ), 802 802 'SK' => array( 803 'country' => 'Slovakia',803 'country' => 'Slovakia', 804 804 'continent' => 'EU', 805 805 ), 806 806 'SI' => array( 807 'country' => 'Slovenia',807 'country' => 'Slovenia', 808 808 'continent' => 'EU', 809 809 ), 810 810 'SB' => array( 811 'country' => 'Solomon Islands',811 'country' => 'Solomon Islands', 812 812 'continent' => 'OC', 813 813 ), 814 814 'SO' => array( 815 'country' => 'Somalia',815 'country' => 'Somalia', 816 816 'continent' => 'AF', 817 817 ), 818 818 'ZA' => array( 819 'country' => 'South Africa',819 'country' => 'South Africa', 820 820 'continent' => 'AF', 821 821 ), 822 822 'GS' => array( 823 'country' => 'South Georgia and The South Sandwich Islands',823 'country' => 'South Georgia and The South Sandwich Islands', 824 824 'continent' => 'AN', 825 825 ), 826 826 'ES' => array( 827 'country' => 'Spain',827 'country' => 'Spain', 828 828 'continent' => 'EU', 829 829 ), 830 830 'LK' => array( 831 'country' => 'Sri Lanka',831 'country' => 'Sri Lanka', 832 832 'continent' => 'AS', 833 833 ), 834 834 'SD' => array( 835 'country' => 'Sudan',835 'country' => 'Sudan', 836 836 'continent' => 'AF', 837 837 ), 838 838 'SR' => array( 839 'country' => 'Suriname',839 'country' => 'Suriname', 840 840 'continent' => 'SA', 841 841 ), 842 842 'SJ' => array( 843 'country' => 'Svalbard and Jan Mayen',843 'country' => 'Svalbard and Jan Mayen', 844 844 'continent' => 'EU', 845 845 ), 846 846 'SZ' => array( 847 'country' => 'Swaziland',847 'country' => 'Swaziland', 848 848 'continent' => 'AF', 849 849 ), 850 850 'SE' => array( 851 'country' => 'Sweden',851 'country' => 'Sweden', 852 852 'continent' => 'EU', 853 853 ), 854 854 'CH' => array( 855 'country' => 'Switzerland',855 'country' => 'Switzerland', 856 856 'continent' => 'EU', 857 857 ), 858 858 'SY' => array( 859 'country' => 'Syrian Arab Republic',859 'country' => 'Syrian Arab Republic', 860 860 'continent' => 'AS', 861 861 ), 862 862 'TW' => array( 863 'country' => 'Taiwan, Province of China',863 'country' => 'Taiwan, Province of China', 864 864 'continent' => 'AS', 865 865 ), 866 866 'TJ' => array( 867 'country' => 'Tajikistan',867 'country' => 'Tajikistan', 868 868 'continent' => 'AS', 869 869 ), 870 870 'TZ' => array( 871 'country' => 'Tanzania, United Republic of',871 'country' => 'Tanzania, United Republic of', 872 872 'continent' => 'AF', 873 873 ), 874 874 'TH' => array( 875 'country' => 'Thailand',875 'country' => 'Thailand', 876 876 'continent' => 'AS', 877 877 ), 878 878 'TL' => array( 879 'country' => 'Timor-leste',879 'country' => 'Timor-leste', 880 880 'continent' => 'AS', 881 881 ), 882 882 'TG' => array( 883 'country' => 'Togo',883 'country' => 'Togo', 884 884 'continent' => 'AF', 885 885 ), 886 886 'TK' => array( 887 'country' => 'Tokelau',887 'country' => 'Tokelau', 888 888 'continent' => 'OC', 889 889 ), 890 890 'TO' => array( 891 'country' => 'Tonga',891 'country' => 'Tonga', 892 892 'continent' => 'OC', 893 893 ), 894 894 'TT' => array( 895 'country' => 'Trinidad and Tobago',895 'country' => 'Trinidad and Tobago', 896 896 'continent' => 'NA', 897 897 ), 898 898 'TN' => array( 899 'country' => 'Tunisia',899 'country' => 'Tunisia', 900 900 'continent' => 'AF', 901 901 ), 902 902 'TR' => array( 903 'country' => 'Turkey',903 'country' => 'Turkey', 904 904 'continent' => 'AS', 905 905 ), 906 906 'TM' => array( 907 'country' => 'Turkmenistan',907 'country' => 'Turkmenistan', 908 908 'continent' => 'AS', 909 909 ), 910 910 'TC' => array( 911 'country' => 'Turks and Caicos Islands',911 'country' => 'Turks and Caicos Islands', 912 912 'continent' => 'NA', 913 913 ), 914 914 'TV' => array( 915 'country' => 'Tuvalu',915 'country' => 'Tuvalu', 916 916 'continent' => 'OC', 917 917 ), 918 918 'UG' => array( 919 'country' => 'Uganda',919 'country' => 'Uganda', 920 920 'continent' => 'AF', 921 921 ), 922 922 'UA' => array( 923 'country' => 'Ukraine',923 'country' => 'Ukraine', 924 924 'continent' => 'EU', 925 925 ), 926 926 'AE' => array( 927 'country' => 'United Arab Emirates',927 'country' => 'United Arab Emirates', 928 928 'continent' => 'AS', 929 929 ), 930 930 'GB' => array( 931 'country' => 'United Kingdom',931 'country' => 'United Kingdom', 932 932 'continent' => 'EU', 933 933 ), 934 934 'US' => array( 935 'country' => 'United States',935 'country' => 'United States', 936 936 'continent' => 'NA', 937 937 ), 938 938 'UM' => array( 939 'country' => 'United States Minor Outlying Islands',939 'country' => 'United States Minor Outlying Islands', 940 940 'continent' => 'OC', 941 941 ), 942 942 'UY' => array( 943 'country' => 'Uruguay',943 'country' => 'Uruguay', 944 944 'continent' => 'SA', 945 945 ), 946 946 'UZ' => array( 947 'country' => 'Uzbekistan',947 'country' => 'Uzbekistan', 948 948 'continent' => 'AS', 949 949 ), 950 950 'VU' => array( 951 'country' => 'Vanuatu',951 'country' => 'Vanuatu', 952 952 'continent' => 'OC', 953 953 ), 954 954 'VE' => array( 955 'country' => 'Venezuela',955 'country' => 'Venezuela', 956 956 'continent' => 'SA', 957 957 ), 958 958 'VN' => array( 959 'country' => 'Viet Nam',959 'country' => 'Viet Nam', 960 960 'continent' => 'AS', 961 961 ), 962 962 'VG' => array( 963 'country' => 'Virgin Islands, British',963 'country' => 'Virgin Islands, British', 964 964 'continent' => 'NA', 965 965 ), 966 966 'VI' => array( 967 'country' => 'Virgin Islands, U.S.',967 'country' => 'Virgin Islands, U.S.', 968 968 'continent' => 'NA', 969 969 ), 970 970 'WF' => array( 971 'country' => 'Wallis and Futuna',971 'country' => 'Wallis and Futuna', 972 972 'continent' => 'OC', 973 973 ), 974 974 'EH' => array( 975 'country' => 'Western Sahara',975 'country' => 'Western Sahara', 976 976 'continent' => 'AF', 977 977 ), 978 978 'YE' => array( 979 'country' => 'Yemen',979 'country' => 'Yemen', 980 980 'continent' => 'AS', 981 981 ), 982 982 'ZM' => array( 983 'country' => 'Zambia',983 'country' => 'Zambia', 984 984 'continent' => 'AF', 985 985 ), 986 986 'ZW' => array( 987 'country' => 'Zimbabwe',987 'country' => 'Zimbabwe', 988 988 'continent' => 'AF', 989 989 ), -
wpengine-geoip/tags/1.2.7/js/admin.js
r1715405 r2171321 1 document.getElementById( 'wpbody' ).addEventListener( 'click', function ( event ) { 2 // If this wasn't a click on a notice-dismiss close button, then abort3 if ( 'notice-dismiss' !== event.target.className ) {4 return;5 }1 /** 2 * This JS file sends an ajax request on admin notification close. 3 * 4 * @package wpengine-geoip 5 */ 6 6 7 // This should be our parent div for the notice 8 var parent = event.path[ 1 ] || null; 7 document.getElementById( 'wpbody' ).addEventListener( 8 'click', 9 function ( event ) { 10 // If this wasn't a click on a notice-dismiss close button, then abort. 11 if ( 'notice-dismiss' !== event.target.className ) { 12 return; 13 } 9 14 10 // If the parent div doesn't have our wpengine-geoip class, then abort 11 if ( !parent || -1 === jQuery.inArray( 'wpengine-geoip', parent.classList ) ) { 12 return; 13 } 15 // This should be our parent div for the notice. 16 var parent = event.path[ 1 ] || null; 14 17 15 // Get our notice's key 16 var key = parent.attributes[ 'data-key' ].value || null; 18 // If the parent div doesn't have our wpengine-geoip class, then abort. 19 if ( ! parent || -1 === jQuery.inArray( 'wpengine-geoip', parent.classList ) ) { 20 return; 21 } 17 22 18 // Send our POST request to admin-ajax 19 var http = new XMLHttpRequest(); 20 var params = "action=geoip_dismiss_notice&key=" + key; 21 http.open( "POST", ajaxurl, true ); 22 http.setRequestHeader( "Content-type", "application/x-www-form-urlencoded" ); 23 http.send( params ); 24 } ); 23 // Get our notice's key. 24 var key = parent.attributes[ 'data-key' ].value || null; 25 26 // Send our POST request to admin-ajax. 27 var http = new XMLHttpRequest(); 28 var params = "action=geoip_dismiss_notice&key=" + key + "&nonce=" + window.nonce; 29 http.open( "POST", ajaxurl, true ); 30 http.setRequestHeader( "Content-type", "application/x-www-form-urlencoded" ); 31 http.send( params ); 32 } 33 ); -
wpengine-geoip/tags/1.2.7/readme.txt
r1868266 r2171321 1 1 === WP Engine GeoTarget === 2 2 Contributors: wpengine, markkelnar, stevenkword, stephenlin, ryanshoover, taylor4484, nateinaction 3 Tags: wpe, wpengine, geo ip, localization, geolocation3 Tags: wpe, wpengine, geotarget, geoip, localization, geolocation 4 4 Requires at least: 3.0.1 5 Tested up to: 4.96 Stable tag: 1.2. 55 Tested up to: 5.2 6 Stable tag: 1.2.7 7 7 8 8 License: GPLv2 or later … … 15 15 WP Engine GeoTarget integrates with the variables on your WP Engine site to display content catered to the visitor’s location. With the ability to access variables from as broad as country to as specific as latitude and longitude, your website can now display geographically relevant content. 16 16 17 18 17 = Geo-Marketing = 19 18 … … 36 35 = * Please Note * = 37 36 38 This plugin will only function on your [WP Engine](http://wpengine.com/plans/?utm_source=wpengine-geoip) Business, Premium or Enterprise level account. This will not function outside of the WP Engine environment.37 Customers on Premium and Enterprise plans can use this plugin at no additional cost. If you are on another plan type and would like to use GeoTarget on one of your sites, you can add it to your plan [here](http://wpengine.com/plans/?utm_source=wpengine-geoip). This will not function outside of the WP Engine environment. 39 38 40 39 == Installation == … … 78 77 == Localized Content == 79 78 80 9) Content: `[geoip-content country="US"]Your US specific content goes here[/geoip-content]` 79 ` 80 [geoip-content country="US"]Your US specific content goes here[/geoip-content] 81 ` 82 81 83 The content shortcode allows you to hide or show specific content based on visitor geographies: 82 84 … … 262 264 == Changelog == 263 265 266 = 1.2.7 = 267 - Optimize plugin name rename loop 268 - Bump for WP 5.2 compatibility 269 270 = 1.2.6 = 271 - Bump for WP 5.0 compatibility 272 264 273 = 1.2.5 = 265 274 - Fix for anchor tag escaping in admin notice -
wpengine-geoip/tags/1.2.7/wpengine-geoip.php
r1868266 r2171321 1 1 <?php 2 2 /** 3 * Plugin Name: WP Engine GeoTarget 4 * Version: 1.2.5 5 * Description: Create a personalized user experienced based on location. 6 * Author: WP Engine 7 * Author URI: http://wpengine.com 8 * Plugin URI: https://wordpress.org/plugins/wpengine-geoip/ 9 * Text Domain: wpengine-geoip 10 * Domain Path: /languages 3 * This file helps to prevent any issues from file name change 4 * wpengine-geoip.php -> class-geoip.php to adhere to WPCS 11 5 * 12 6 * @package wpengine-geoip 13 7 */ 14 15 /*16 Examples use of how to add geoip information to post content:17 18 function geoip_append_content( $content ) {19 $geo = WPEngine\GeoIp::instance();20 $content .= "How's the weather in {$geo->city()}, {$geo->region()} {$geo->country()}?<br /><br />";21 return $content;22 }23 add_filter( 'the_content', 'geoip_append_content' );24 */25 8 26 9 namespace WPEngine; … … 32 15 33 16 /** 34 * Base class for the GeoTarget plugin, GeoTarget was formerly called GeoIP17 * Replace plugin filename in options table 35 18 */ 36 class GeoIp { 37 38 /** 39 * The single instance of this object. No need to have more than one. 40 * 41 * @var class 42 */ 43 private static $instance = null; 44 45 /** 46 * The path to the plugin. Let's just make that function call once. 47 * 48 * @var string 49 */ 50 private $geoip_path; 51 52 /** 53 * The geographical data loaded from the environment. 54 * 55 * @var array 56 */ 57 public $geos; 58 59 /** 60 * A list of countries and their continents. 61 * 62 * @var array 63 */ 64 public $countries; 65 66 /** 67 * WP-Admin errors notices. 68 * 69 * @var array 70 */ 71 private $admin_notices; 72 73 /** 74 * Text Domain. 75 * 76 * @var string 77 */ 78 const TEXT_DOMAIN = 'wpengine-geoip'; 79 80 /** 81 * Version Number. 82 * 83 * @var string 84 */ 85 const VERSION = '1.2.1'; 86 87 // Shortcodes. 88 const SHORTCODE_CONTINENT = 'geoip-continent'; 89 const SHORTCODE_COUNTRY = 'geoip-country'; 90 const SHORTCODE_REGION = 'geoip-region'; 91 const SHORTCODE_CITY = 'geoip-city'; 92 const SHORTCODE_POSTAL_CODE = 'geoip-postalcode'; 93 const SHORTCODE_LATITUDE = 'geoip-latitude'; 94 const SHORTCODE_LONGITUDE = 'geoip-longitude'; 95 const SHORTCODE_LOCATION = 'geoip-location'; 96 const SHORTCODE_CONTENT = 'geoip-content'; 97 98 /** 99 * Initialize hooks and setup environment variables 100 * 101 * @since 0.1.0 102 */ 103 public static function init() { 104 105 // Initialize. 106 add_action( 'init', array( self::instance(), 'setup' ) ); 107 add_action( 'init', array( self::instance(), 'action_init_register_shortcodes' ) ); 108 109 // Enqueue our javascript. 110 add_action( 'admin_enqueue_scripts', array( self::instance(), 'enqueue_admin_js' ) ); 111 112 // Check for dependencies. 113 add_action( 'admin_init', array( self::instance(), 'action_admin_init_check_plugin_dependencies' ), 9999 ); // check late. 114 add_action( 'admin_notices', array( self::instance(), 'action_admin_notices' ) ); 115 116 // Process AJAX requests. 117 add_action( 'wp_ajax_geoip_dismiss_notice', array( self::instance(), 'ajax_action_dismiss_notice' ) ); 118 } 119 120 /** 121 * Register singleton 122 * 123 * @since 0.1.0 124 */ 125 public static function instance() { 126 // Create a new object if it doesn't exist. 127 if ( is_null( self::$instance ) ) { 128 self::$instance = new self; 129 } 130 131 return self::$instance; 132 } 133 134 /** 135 * Setup environment variables 136 * 137 * @since 0.1.0 138 */ 139 public function setup() { 140 141 $this->geoip_path = plugin_dir_path( __FILE__ ); 142 143 // Get our array of countries and continents. 144 require_once( $this->geoip_path . '/inc/country-list.php' ); 145 146 $this->countries = apply_filters( 'geoip_country_list', geoip_country_list() ); 147 148 $this->geos = $this->get_actuals(); 149 150 $this->geos = $this->get_test_parameters( $this->geos ); 151 152 $this->geos = wp_unslash( $this->geos ); 153 154 $this->geos = apply_filters( 'geoip_location_values', $this->geos ); 155 156 // Prepopulate the admin notices array. 157 $this->admin_notices = array( 158 'info' => array(), 159 'error' => array(), 160 'success' => array(), 161 'warning' => array(), 162 ); 163 } 164 165 /** 166 * Enqueue the admin Javascript file 167 * 168 * @since 1.2.1 169 */ 170 public function enqueue_admin_js() { 171 // Only enqueue the JS if the notice will be showing. 172 if ( ! $this->helper_should_notice_show( 'dependency' ) ) { 173 return; 174 } 175 176 wp_enqueue_script( self::TEXT_DOMAIN . '-admin-js', plugins_url( 'js/admin.js', __FILE__ ), null, self::VERSION, true ); 177 } 178 179 /** 180 * Here we extract the data from headers set by nginx -- lets only send them if they are part of the cache key 181 * 182 * @since 0.1.0 183 * @return array All of the GeoTarget related environment variables available on the current server instance 184 */ 185 public function get_actuals() { 186 187 $geos = array( 188 'countrycode' => getenv( 'HTTP_GEOIP_COUNTRY_CODE' ), 189 'countrycode3' => getenv( 'HTTP_GEOIP_COUNTRY_CODE3' ), 190 'countryname' => getenv( 'HTTP_GEOIP_COUNTRY_NAME' ), 191 'latitude' => getenv( 'HTTP_GEOIP_LATITUDE' ), 192 'longitude' => getenv( 'HTTP_GEOIP_LONGITUDE' ), 193 'areacode' => getenv( 'HTTP_GEOIP_AREA_CODE' ), 194 'region' => getenv( 'HTTP_GEOIP_REGION' ), 195 'city' => getenv( 'HTTP_GEOIP_CITY' ), 196 'postalcode' => getenv( 'HTTP_GEOIP_POSTAL_CODE' ), 197 ); 198 199 $geos['active'] = ( isset( $geos['countrycode'] ) && false !== $geos['countrycode'] ) ? true : false; 200 201 $geos['continent'] = $this->continent( $geos['countrycode'] ); 202 203 return $geos; 204 } 205 206 /** 207 * We want people to be able to test the plugin, so we'll include some url parameters that will spoof a location 208 * 209 * @since 1.1.0 210 * @param array $geos Array of values for the user's location. 211 * @return array Modified version of the GeoTarget location array based on url parameters 212 */ 213 public function get_test_parameters( $geos ) { 214 215 $params = $_GET; 216 217 if ( ! isset( $params['geoip'] ) ) { 218 return $geos; 219 } 220 221 foreach ( $params as $key => $value ) { 222 223 $key = esc_attr( $key ); 224 $value = esc_attr( $value ); 225 226 $key = $this->match_label_synonyms( $key ); 227 228 if ( isset( $geos[ $key ] ) ) { 229 $geos[ $key ] = $value; 230 } 231 } 232 233 return $geos; 234 } 235 236 /** 237 * Get Continent 238 * 239 * @since 1.1.0 240 * @param string $country Two-letter country code. 241 * @return string Two-letter continent code, e.g. EU for Europe 242 */ 243 public function continent( $country = '' ) { 244 245 $continent = ''; 246 247 if ( empty( $country ) ) { 248 $country = $this->geos['countrycode']; 249 } 250 251 if ( isset( $this->countries[ $country ] ) ) { 252 $continent = $this->countries[ $country ]['continent']; 253 } 254 255 return $continent; 256 } 257 258 /** 259 * Get Country 260 * 261 * @since 0.5.0 262 * @return string Two-letter country code, e.g.) US for the United States of America 263 */ 264 public function country() { 265 return $this->geos['countrycode']; 266 } 267 268 /** 269 * Get Region 270 * 271 * @since 0.5.0 272 * @return string Two-letter region code. e.g.) CA for California 273 */ 274 public function region() { 275 return $this->geos['region']; 276 } 277 278 /** 279 * Get City 280 * 281 * @since 0.5.0 282 * @return mixed Description 283 */ 284 public function city() { 285 return $this->geos['city']; 286 } 287 288 /** 289 * Get Postal Code 290 * 291 * @since 0.6.0 292 * @return mixed Description 293 */ 294 public function postal_code() { 295 return $this->geos['postalcode']; 296 } 297 298 /** 299 * Get Latitude 300 * 301 * @since 0.6.0 302 * @return mixed Description 303 */ 304 public function latitude() { 305 return $this->geos['latitude']; 306 } 307 308 /** 309 * Get Longitude 310 * 311 * @since 0.6.0 312 * @return mixed Description 313 */ 314 public function longitude() { 315 return $this->geos['longitude']; 316 } 317 318 /** 319 * Register the shortcode(s) 320 * 321 * @since 0.5.0 322 * @uses add_shortcode() 323 */ 324 public function action_init_register_shortcodes() { 325 326 // Continent Shortcode. 327 if ( ! shortcode_exists( self::SHORTCODE_CONTINENT ) ) { 328 add_shortcode( self::SHORTCODE_CONTINENT, array( $this, 'do_shortcode_continent' ) ); 329 } 330 331 // Country Shortcode. 332 if ( ! shortcode_exists( self::SHORTCODE_COUNTRY ) ) { 333 add_shortcode( self::SHORTCODE_COUNTRY, array( $this, 'do_shortcode_country' ) ); 334 } 335 336 // Region Shortcode. 337 if ( ! shortcode_exists( self::SHORTCODE_REGION ) ) { 338 add_shortcode( self::SHORTCODE_REGION, array( $this, 'do_shortcode_region' ) ); 339 } 340 341 // City Shortcode. 342 if ( ! shortcode_exists( self::SHORTCODE_CITY ) ) { 343 add_shortcode( self::SHORTCODE_CITY, array( $this, 'do_shortcode_city' ) ); 344 } 345 346 // Postal Code Shortcode. 347 if ( ! shortcode_exists( self::SHORTCODE_POSTAL_CODE ) ) { 348 add_shortcode( self::SHORTCODE_POSTAL_CODE, array( $this, 'do_shortcode_postal_code' ) ); 349 } 350 351 // Latitude Shortcode. 352 if ( ! shortcode_exists( self::SHORTCODE_LATITUDE ) ) { 353 add_shortcode( self::SHORTCODE_LATITUDE, array( $this, 'do_shortcode_latitude' ) ); 354 } 355 356 // Longitude Shortcode. 357 if ( ! shortcode_exists( self::SHORTCODE_LONGITUDE ) ) { 358 add_shortcode( self::SHORTCODE_LONGITUDE, array( $this, 'do_shortcode_longitude' ) ); 359 } 360 361 // Smart Location Shortcode. 362 if ( ! shortcode_exists( self::SHORTCODE_LOCATION ) ) { 363 add_shortcode( self::SHORTCODE_LOCATION, array( $this, 'do_shortcode_location' ) ); 364 } 365 366 // Smart Location Shortcode. 367 if ( ! shortcode_exists( self::SHORTCODE_CONTENT ) ) { 368 add_shortcode( self::SHORTCODE_CONTENT, array( $this, 'do_shortcode_content' ) ); 19 function replace_previous_plugin_filename() { 20 $active_plugins = get_option( 'active_plugins', array() ); 21 foreach ( $active_plugins as $key => $active_plugin ) { 22 if ( strstr( $active_plugin, '/wpengine-geoip.php' ) ) { 23 $active_plugins[ $key ] = str_replace( '/wpengine-geoip.php', '/class-geoip.php', $active_plugin ); 24 break; 369 25 } 370 26 } 371 372 /** 373 * Output the current continent 374 * 375 * @since 1.1.0 376 * @param array $atts Shortcode attributes. 377 * @return string Two-letter continent code 378 */ 379 function do_shortcode_continent( $atts ) { 380 $continent = '[' . self::SHORTCODE_CONTINENT . ']'; 381 382 $country = $this->geos['countrycode']; 383 384 if ( isset( $this->countries[ $country ] ) ) { 385 $continent = $this->countries[ $country ]['continent']; 386 } 387 return $continent; 388 } 389 390 /** 391 * Output the current country 392 * 393 * @since 0.5.0 394 * @param array $atts Shortcode attributes. 395 * @return string Two-letter country code 396 */ 397 function do_shortcode_country( $atts ) { 398 if ( isset( $this->geos['countrycode'] ) ) { 399 return $this->country(); 400 } 401 return '[' . self::SHORTCODE_COUNTRY . ']'; 402 } 403 404 /** 405 * Output the current region 406 * 407 * @since 0.5.0 408 * @param array $atts Shortcode attributes. 409 * @return string Two-letter region code 410 */ 411 function do_shortcode_region( $atts ) { 412 if ( isset( $this->geos['region'] ) ) { 413 return $this->region(); 414 } 415 return '[' . self::SHORTCODE_REGION . ']'; 416 } 417 418 /** 419 * Output the current city 420 * 421 * @since 0.5.0 422 * @param array $atts Shortcode attributes. 423 * @return string City name 424 */ 425 function do_shortcode_city( $atts ) { 426 if ( isset( $this->geos['city'] ) ) { 427 return $this->city(); 428 } 429 return '[' . self::SHORTCODE_CITY . ']'; 430 } 431 432 /** 433 * Output the current postal code 434 * 435 * @since 0.6.0 436 * @param array $atts Shortcode attributes. 437 * @return string postal code 438 */ 439 function do_shortcode_postal_code( $atts ) { 440 if ( isset( $this->geos['postalcode'] ) ) { 441 return $this->postal_code(); 442 } 443 return '[' . self::SHORTCODE_POSTAL_CODE . ']'; 444 } 445 446 /** 447 * Output the current latitude 448 * 449 * @since 0.6.0 450 * @param array $atts Shortcode attributes. 451 * @return string latitude 452 */ 453 function do_shortcode_latitude( $atts ) { 454 if ( isset( $this->geos['latitude'] ) ) { 455 return $this->latitude(); 456 } 457 return '[' . self::SHORTCODE_LATITUDE . ']'; 458 } 459 460 /** 461 * Output the current longitude 462 * 463 * @since 0.6.0 464 * @param array $atts Shortcode attributes. 465 * @return string longitude 466 */ 467 function do_shortcode_longitude( $atts ) { 468 if ( isset( $this->geos['longitude'] ) ) { 469 return $this->longitude(); 470 } 471 return '[' . self::SHORTCODE_LONGITUDE . ']'; 472 } 473 474 /** 475 * Output the current human readable location, in a smart way. 476 * 477 * @since 0.5.0 478 * @param array $atts Shortcode attributes. 479 * @return string $html 480 */ 481 function do_shortcode_location( $atts ) { 482 483 $city = $this->city(); 484 if ( isset( $city ) && ! empty( $city ) ) { 485 return trim( $this->city() . ', ' . $this->region() . ' ' . $this->country() ); 486 } 487 // Fallback. 488 return trim( $this->region() . ' ' . $this->country() ); 489 } 490 491 /** 492 * Output the content filtered by region 493 * 494 * @since 1.1.0 495 * @param array $atts Shortcode attributes. 496 * @param string $content HTML content that comes between the shortcode tags. 497 * @return string HTML 498 */ 499 function do_shortcode_content( $atts, $content = null ) { 500 501 $keep = true; 502 503 $test_parameters = array(); 504 505 // Process and organzie the test parameters. 506 foreach ( $atts as $label => $value ) { 507 508 // Intialize our negation parameters. 509 $negate = 0; 510 $inline_negate = 0; 511 512 // Check to see if the attribute has "not" in it. 513 $negate = preg_match( '/not?[-_]?(.*)/', $label, $matches ); 514 515 // WordPress doesn't like a dash in shortcode parameter labels. 516 // Just in case, check to see if the value has "not-" in it. 517 if ( ! $negate ) { 518 $negate = preg_match( '/not?\-([^=]+)\=\"?([^"]+)\"?/', $value, $matches ); 519 $inline_negate = $negate; 520 } 521 522 // Label after the negation match. 523 $label = $negate ? $matches[1] : $label; 524 525 // Value after the negation match. 526 $value = $inline_negate ? $matches[2] : $value; 527 528 // Replace common synonyms with our values. 529 $label = $this->match_label_synonyms( $label ); 530 531 // Abort if the label doesn't match. 532 if ( ! isset( $this->geos[ $label ] ) ) { 533 continue; 534 } 535 536 // Find out if the value is comma delimited. 537 $test_values = (array) explode( ',', $value ); 538 539 // Add the value to the test parameters. 540 $test_parameters[ $label ] = array( 541 'test_values' => $test_values, 542 'negate' => $negate, 543 ); 544 }// End foreach(). 545 546 // Sort the test parameters by region type – largest to smallest. 547 uksort( $test_parameters, array( $this, 'compare_location_type' ) ); 548 549 $test_parameters = apply_filters( 'geoip_test_parameters', $test_parameters, $atts ); 550 551 // Process through parameters, testing to see if we have a match. 552 foreach ( $test_parameters as $label => $parameter ) { 553 554 $test_values = $parameter['test_values']; 555 556 $negate = $parameter['negate']; 557 558 // Sanitize the match value. 559 $match_value = strtolower( $this->geos[ $label ] ); 560 561 // Sanitize the test values. 562 foreach ( $test_values as &$test_value ) { 563 $test_value = strtolower( trim( $test_value, " \t\"." ) ); 564 } 565 566 $is_match = in_array( $match_value, $test_values, true ); 567 568 $is_match = ! $negate ? $is_match : ! $is_match; 569 570 if ( ! $is_match ) { 571 $keep = false; 572 } 573 } 574 575 if ( ! $keep ) { 576 return ''; 577 } 578 579 // Process any shortcodes in the content. 580 $content = do_shortcode( $content ); 581 582 return apply_filters( 'geoip_content', $content, $atts ); 583 } 584 585 /** 586 * Compare the location types 587 * 588 * Used for sorting location types from largest area to smallest area 589 * 590 * @since 1.1.2 591 * @param string $a Type of location. 592 * @param string $b Type of location. 593 * @return int Whether $a is more important than b 594 */ 595 public function compare_location_type( $a, $b ) { 596 $location_types = array( 597 'continent' => 1, 598 'countrycode' => 2, 599 'countrycode3' => 2, 600 'countryname' => 2, 601 'region' => 3, 602 'areacode' => 4, 603 'city' => 5, 604 'postalcode' => 6, 605 ); 606 607 if ( isset( $location_types[ $a ] ) && isset( $location_types[ $b ] ) ) { 608 return $location_types[ $a ] - $location_types[ $b ]; 609 } else { 610 return 0; 611 } 612 } 613 614 /** 615 * Checks if environment variable depencies are available on the server 616 * 617 * @todo Include link to query documentation when available on the Plugin Directory 618 * @since 0.5.0 619 */ 620 public function action_admin_init_check_plugin_dependencies() { 621 $notice_key = 'dependency'; 622 623 if ( $this->helper_should_notice_show( $notice_key ) ) { 624 /* translators: Tells users that the plugin won't automatically work if they're not in the right setup */ 625 $notice = __( 'WP Engine GeoTarget requires a <a href="%s">WP Engine account</a> with GeoTarget enabled for full functionality. Only testing queries will work on this site.', 'wpengine-geoip' ); 626 $this->admin_notices['warning'][ $notice_key ] = sprintf( $notice, 'http://wpengine.com/plans/?utm_source=' . self::TEXT_DOMAIN ); 627 } 628 } 629 630 /** 631 * Displays any of our registered notices 632 * 633 * @since 0.5.0 634 */ 635 public function action_admin_notices() { 636 foreach ( $this->admin_notices as $type => $notices ) { 637 foreach ( $notices as $key => $notice ) { 638 ?> 639 <div class="notice notice-<?php echo esc_attr( $type ); ?> wpengine-geoip is-dismissible" data-key="<?php echo esc_attr( $key ); ?>"> 640 <p> 641 <?php 642 echo wp_kses( 643 $notice, 644 array( 645 'a' => array( 646 'href' => array(), 647 ), 648 'span', 649 'strong', 650 'em', 651 ) 652 ); 653 ?> 654 </p> 655 </div> 656 <?php 657 } 658 } 659 } 660 661 /** 662 * Process an AJAX request to dismiss any notices 663 * Adds a user meta field marking when the notice was dismissed 664 * 665 * @since 1.2.1 666 */ 667 public function ajax_action_dismiss_notice() { 668 if ( empty( $_POST['key'] ) ) { 669 return; 670 } 671 672 $meta_key = self::TEXT_DOMAIN . '-notice-dismissed-' . esc_attr( wp_unslash( $_POST['key'] ) ); 673 674 add_user_meta( get_current_user_id(), $meta_key, time(), true ); 675 } 676 677 /** 678 * Helper: Should a notice show in the dashboard? 679 * 680 * @since 1.2.1 681 * @param string $notice Key of the notice we're testing for. 682 * @return bool Should we show the notice or not. 683 */ 684 protected function helper_should_notice_show( $notice ) { 685 if ( ! $notice ) { 686 return false; 687 } 688 689 $is_active = $this->geos['active']; 690 $is_dismissed = get_user_meta( get_current_user_id(), self::TEXT_DOMAIN . '-notice-dismissed-' . $notice, true ); 691 692 // false = GeoTarget is active, or if we've dismissed the notice before. 693 // true = GeoTarget is not active and we haven't dismissed the notice before. 694 return ! ( $is_active || $is_dismissed ); 695 } 696 697 /** 698 * As a favor to users, let's match some common synonyms 699 * 700 * @since 1.1.0 701 * @param string $label The address label that needs a synonym. 702 * @return string label 703 */ 704 private function match_label_synonyms( $label ) { 705 706 if ( 'country' === $label ) { 707 $label = 'countrycode'; 708 } 709 710 if ( 'state' === $label ) { 711 $label = 'region'; 712 } 713 714 if ( 'zipcode' === $label || 'zip' === $label ) { 715 $label = 'postalcode'; 716 } 717 718 return $label; 719 } 720 721 /** 722 * Utility function: Calculate distance to point 723 * 724 * Provided a lat/lng, calculate the distance from visitor's location 725 * Uses the Haversine Formula, accurate for short distance but not over poles or the equator 726 * 727 * Note: Test against a return value of false to make sure you got a calculated distance. Example: 728 * $geo = WPEngine\GeoIp::instance(); 729 * if ( false !== $geo->distance_to( $latitude, $longitude ) ) { 730 * // Do something 731 * } 732 * 733 * @link http://andrew.hedges.name/experiments/haversine/ 734 * @since 1.2 735 * @param float $lat Latitude of the destination in degrees. 736 * @param float $lng Longitude of the destination in degrees. 737 * @param bool $metric Whether to calculate the distance in kilometers or miles. 738 * @return float Distance in miles 739 */ 740 public function distance_to( $lat, $lng, $metric = false ) { 741 $start_lat = deg2rad( $this->latitude() ); 742 $start_lng = deg2rad( $this->longitude() ); 743 744 // Test for null values passed into the function or a 0,0 coordinate for the user. 745 // If either exist, abort. (0,0 is the result when coordinates fail). 746 if ( is_null( $lat ) || is_null( $lng ) || ( empty( $start_lat ) && empty( $start_lng ) ) ) { 747 return false; 748 } 749 750 // Choose the right radius for the results: radius of the Earth in kilometers and miles. 751 $radius = $metric ? 6373 : 3961; 752 753 // Sanitize the user submitted variables. 754 $lat = floatval( $lat ); 755 $lng = floatval( $lng ); 756 757 $dlng = $lng - $start_lng; 758 $dlat = $lat - $start_lat; 759 760 // Calculate the distance. 761 $a = ( sin( $dlat / 2 ) * sin( $dlat / 2 ) ) + ( cos( $lat ) * cos( $start_lat ) * sin( $dlng / 2 ) * sin( $dlng / 2 ) ); 762 $c = 2 * atan2( sqrt( $a ), sqrt( 1 - $a ) ); 763 $d = $radius * $c; 764 765 return $d; 766 } 27 update_option( 'active_plugins', $active_plugins ); 767 28 } 768 769 // Register the GeoTarget plugin instance. 770 GeoIp::init(); 29 replace_previous_plugin_filename(); -
wpengine-geoip/trunk/inc/country-list.php
r1699836 r2171321 13 13 $countries = array( 14 14 'AF' => array( 15 'country' => 'Afghanistan',15 'country' => 'Afghanistan', 16 16 'continent' => 'AS', 17 17 ), 18 18 'AX' => array( 19 'country' => 'Åland Islands',19 'country' => 'Åland Islands', 20 20 'continent' => 'EU', 21 21 ), 22 22 'AL' => array( 23 'country' => 'Albania',23 'country' => 'Albania', 24 24 'continent' => 'EU', 25 25 ), 26 26 'DZ' => array( 27 'country' => 'Algeria',27 'country' => 'Algeria', 28 28 'continent' => 'AF', 29 29 ), 30 30 'AS' => array( 31 'country' => 'American Samoa',31 'country' => 'American Samoa', 32 32 'continent' => 'OC', 33 33 ), 34 34 'AD' => array( 35 'country' => 'Andorra',35 'country' => 'Andorra', 36 36 'continent' => 'EU', 37 37 ), 38 38 'AO' => array( 39 'country' => 'Angola',39 'country' => 'Angola', 40 40 'continent' => 'AF', 41 41 ), 42 42 'AI' => array( 43 'country' => 'Anguilla',43 'country' => 'Anguilla', 44 44 'continent' => 'NA', 45 45 ), 46 46 'AQ' => array( 47 'country' => 'AN',47 'country' => 'AN', 48 48 'continent' => 'AN', 49 49 ), 50 50 'AG' => array( 51 'country' => 'Antigua and Barbuda',51 'country' => 'Antigua and Barbuda', 52 52 'continent' => 'NA', 53 53 ), 54 54 'AR' => array( 55 'country' => 'Argentina',55 'country' => 'Argentina', 56 56 'continent' => 'SA', 57 57 ), 58 58 'AM' => array( 59 'country' => 'Armenia',59 'country' => 'Armenia', 60 60 'continent' => 'AS', 61 61 ), 62 62 'AW' => array( 63 'country' => 'Aruba',63 'country' => 'Aruba', 64 64 'continent' => 'NA', 65 65 ), 66 66 'AU' => array( 67 'country' => 'Australia',67 'country' => 'Australia', 68 68 'continent' => 'OC', 69 69 ), 70 70 'AT' => array( 71 'country' => 'Austria',71 'country' => 'Austria', 72 72 'continent' => 'EU', 73 73 ), 74 74 'AZ' => array( 75 'country' => 'Azerbaijan',75 'country' => 'Azerbaijan', 76 76 'continent' => 'AS', 77 77 ), 78 78 'BS' => array( 79 'country' => 'Bahamas',79 'country' => 'Bahamas', 80 80 'continent' => 'NA', 81 81 ), 82 82 'BH' => array( 83 'country' => 'Bahrain',83 'country' => 'Bahrain', 84 84 'continent' => 'AS', 85 85 ), 86 86 'BD' => array( 87 'country' => 'Bangladesh',87 'country' => 'Bangladesh', 88 88 'continent' => 'AS', 89 89 ), 90 90 'BB' => array( 91 'country' => 'Barbados',91 'country' => 'Barbados', 92 92 'continent' => 'NA', 93 93 ), 94 94 'BY' => array( 95 'country' => 'Belarus',95 'country' => 'Belarus', 96 96 'continent' => 'EU', 97 97 ), 98 98 'BE' => array( 99 'country' => 'Belgium',99 'country' => 'Belgium', 100 100 'continent' => 'EU', 101 101 ), 102 102 'BZ' => array( 103 'country' => 'Belize',103 'country' => 'Belize', 104 104 'continent' => 'NA', 105 105 ), 106 106 'BJ' => array( 107 'country' => 'Benin',107 'country' => 'Benin', 108 108 'continent' => 'AF', 109 109 ), 110 110 'BM' => array( 111 'country' => 'Bermuda',111 'country' => 'Bermuda', 112 112 'continent' => 'NA', 113 113 ), 114 114 'BT' => array( 115 'country' => 'Bhutan',115 'country' => 'Bhutan', 116 116 'continent' => 'AS', 117 117 ), 118 118 'BO' => array( 119 'country' => 'Bolivia',119 'country' => 'Bolivia', 120 120 'continent' => 'SA', 121 121 ), 122 122 'BA' => array( 123 'country' => 'Bosnia and Herzegovina',123 'country' => 'Bosnia and Herzegovina', 124 124 'continent' => 'EU', 125 125 ), 126 126 'BW' => array( 127 'country' => 'Botswana',127 'country' => 'Botswana', 128 128 'continent' => 'AF', 129 129 ), 130 130 'BV' => array( 131 'country' => 'Bouvet Island',131 'country' => 'Bouvet Island', 132 132 'continent' => 'AN', 133 133 ), 134 134 'BR' => array( 135 'country' => 'Brazil',135 'country' => 'Brazil', 136 136 'continent' => 'SA', 137 137 ), 138 138 'IO' => array( 139 'country' => 'British Indian Ocean Territory',139 'country' => 'British Indian Ocean Territory', 140 140 'continent' => 'AS', 141 141 ), 142 142 'BN' => array( 143 'country' => 'Brunei Darussalam',143 'country' => 'Brunei Darussalam', 144 144 'continent' => 'AS', 145 145 ), 146 146 'BG' => array( 147 'country' => 'Bulgaria',147 'country' => 'Bulgaria', 148 148 'continent' => 'EU', 149 149 ), 150 150 'BF' => array( 151 'country' => 'Burkina Faso',151 'country' => 'Burkina Faso', 152 152 'continent' => 'AF', 153 153 ), 154 154 'BI' => array( 155 'country' => 'Burundi',155 'country' => 'Burundi', 156 156 'continent' => 'AF', 157 157 ), 158 158 'KH' => array( 159 'country' => 'Cambodia',159 'country' => 'Cambodia', 160 160 'continent' => 'AS', 161 161 ), 162 162 'CM' => array( 163 'country' => 'Cameroon',163 'country' => 'Cameroon', 164 164 'continent' => 'AF', 165 165 ), 166 166 'CA' => array( 167 'country' => 'Canada',167 'country' => 'Canada', 168 168 'continent' => 'NA', 169 169 ), 170 170 'CV' => array( 171 'country' => 'Cape Verde',171 'country' => 'Cape Verde', 172 172 'continent' => 'AF', 173 173 ), 174 174 'KY' => array( 175 'country' => 'Cayman Islands',175 'country' => 'Cayman Islands', 176 176 'continent' => 'NA', 177 177 ), 178 178 'CF' => array( 179 'country' => 'Central African Republic',179 'country' => 'Central African Republic', 180 180 'continent' => 'AF', 181 181 ), 182 182 'TD' => array( 183 'country' => 'Chad',183 'country' => 'Chad', 184 184 'continent' => 'AF', 185 185 ), 186 186 'CL' => array( 187 'country' => 'Chile',187 'country' => 'Chile', 188 188 'continent' => 'SA', 189 189 ), 190 190 'CN' => array( 191 'country' => 'China',191 'country' => 'China', 192 192 'continent' => 'AS', 193 193 ), 194 194 'CX' => array( 195 'country' => 'Christmas Island',195 'country' => 'Christmas Island', 196 196 'continent' => 'AS', 197 197 ), 198 198 'CC' => array( 199 'country' => 'Cocos (Keeling) Islands',199 'country' => 'Cocos (Keeling) Islands', 200 200 'continent' => 'AS', 201 201 ), 202 202 'CO' => array( 203 'country' => 'Colombia',203 'country' => 'Colombia', 204 204 'continent' => 'SA', 205 205 ), 206 206 'KM' => array( 207 'country' => 'Comoros',207 'country' => 'Comoros', 208 208 'continent' => 'AF', 209 209 ), 210 210 'CG' => array( 211 'country' => 'Congo',211 'country' => 'Congo', 212 212 'continent' => 'AF', 213 213 ), 214 214 'CD' => array( 215 'country' => 'The Democratic Republic of The Congo',215 'country' => 'The Democratic Republic of The Congo', 216 216 'continent' => 'AF', 217 217 ), 218 218 'CK' => array( 219 'country' => 'Cook Islands',219 'country' => 'Cook Islands', 220 220 'continent' => 'OC', 221 221 ), 222 222 'CR' => array( 223 'country' => 'Costa Rica',223 'country' => 'Costa Rica', 224 224 'continent' => 'NA', 225 225 ), 226 226 'CI' => array( 227 'country' => 'Cote D\'ivoire',227 'country' => 'Cote D\'ivoire', 228 228 'continent' => 'AF', 229 229 ), 230 230 'HR' => array( 231 'country' => 'Croatia',231 'country' => 'Croatia', 232 232 'continent' => 'EU', 233 233 ), 234 234 'CU' => array( 235 'country' => 'Cuba',235 'country' => 'Cuba', 236 236 'continent' => 'NA', 237 237 ), 238 238 'CY' => array( 239 'country' => 'Cyprus',239 'country' => 'Cyprus', 240 240 'continent' => 'AS', 241 241 ), 242 242 'CZ' => array( 243 'country' => 'Czech Republic',243 'country' => 'Czech Republic', 244 244 'continent' => 'EU', 245 245 ), 246 246 'DK' => array( 247 'country' => 'Denmark',247 'country' => 'Denmark', 248 248 'continent' => 'EU', 249 249 ), 250 250 'DJ' => array( 251 'country' => 'Djibouti',251 'country' => 'Djibouti', 252 252 'continent' => 'AF', 253 253 ), 254 254 'DM' => array( 255 'country' => 'Dominica',255 'country' => 'Dominica', 256 256 'continent' => 'NA', 257 257 ), 258 258 'DO' => array( 259 'country' => 'Dominican Republic',259 'country' => 'Dominican Republic', 260 260 'continent' => 'NA', 261 261 ), 262 262 'EC' => array( 263 'country' => 'Ecuador',263 'country' => 'Ecuador', 264 264 'continent' => 'SA', 265 265 ), 266 266 'EG' => array( 267 'country' => 'Egypt',267 'country' => 'Egypt', 268 268 'continent' => 'AF', 269 269 ), 270 270 'SV' => array( 271 'country' => 'El Salvador',271 'country' => 'El Salvador', 272 272 'continent' => 'NA', 273 273 ), 274 274 'GQ' => array( 275 'country' => 'Equatorial Guinea',275 'country' => 'Equatorial Guinea', 276 276 'continent' => 'AF', 277 277 ), 278 278 'ER' => array( 279 'country' => 'Eritrea',279 'country' => 'Eritrea', 280 280 'continent' => 'AF', 281 281 ), 282 282 'EE' => array( 283 'country' => 'Estonia',283 'country' => 'Estonia', 284 284 'continent' => 'EU', 285 285 ), 286 286 'ET' => array( 287 'country' => 'Ethiopia',287 'country' => 'Ethiopia', 288 288 'continent' => 'AF', 289 289 ), 290 290 'FK' => array( 291 'country' => 'Falkland Islands (Malvinas)',291 'country' => 'Falkland Islands (Malvinas)', 292 292 'continent' => 'SA', 293 293 ), 294 294 'FO' => array( 295 'country' => 'Faroe Islands',295 'country' => 'Faroe Islands', 296 296 'continent' => 'EU', 297 297 ), 298 298 'FJ' => array( 299 'country' => 'Fiji',299 'country' => 'Fiji', 300 300 'continent' => 'OC', 301 301 ), 302 302 'FI' => array( 303 'country' => 'Finland',303 'country' => 'Finland', 304 304 'continent' => 'EU', 305 305 ), 306 306 'FR' => array( 307 'country' => 'France',307 'country' => 'France', 308 308 'continent' => 'EU', 309 309 ), 310 310 'GF' => array( 311 'country' => 'French Guiana',311 'country' => 'French Guiana', 312 312 'continent' => 'SA', 313 313 ), 314 314 'PF' => array( 315 'country' => 'French Polynesia',315 'country' => 'French Polynesia', 316 316 'continent' => 'OC', 317 317 ), 318 318 'TF' => array( 319 'country' => 'French Southern Territories',319 'country' => 'French Southern Territories', 320 320 'continent' => 'AN', 321 321 ), 322 322 'GA' => array( 323 'country' => 'Gabon',323 'country' => 'Gabon', 324 324 'continent' => 'AF', 325 325 ), 326 326 'GM' => array( 327 'country' => 'Gambia',327 'country' => 'Gambia', 328 328 'continent' => 'AF', 329 329 ), 330 330 'GE' => array( 331 'country' => 'Georgia',331 'country' => 'Georgia', 332 332 'continent' => 'AS', 333 333 ), 334 334 'DE' => array( 335 'country' => 'Germany',335 'country' => 'Germany', 336 336 'continent' => 'EU', 337 337 ), 338 338 'GH' => array( 339 'country' => 'Ghana',339 'country' => 'Ghana', 340 340 'continent' => 'AF', 341 341 ), 342 342 'GI' => array( 343 'country' => 'Gibraltar',343 'country' => 'Gibraltar', 344 344 'continent' => 'EU', 345 345 ), 346 346 'GR' => array( 347 'country' => 'Greece',347 'country' => 'Greece', 348 348 'continent' => 'EU', 349 349 ), 350 350 'GL' => array( 351 'country' => 'Greenland',351 'country' => 'Greenland', 352 352 'continent' => 'NA', 353 353 ), 354 354 'GD' => array( 355 'country' => 'Grenada',355 'country' => 'Grenada', 356 356 'continent' => 'NA', 357 357 ), 358 358 'GP' => array( 359 'country' => 'Guadeloupe',359 'country' => 'Guadeloupe', 360 360 'continent' => 'NA', 361 361 ), 362 362 'GU' => array( 363 'country' => 'Guam',363 'country' => 'Guam', 364 364 'continent' => 'OC', 365 365 ), 366 366 'GT' => array( 367 'country' => 'Guatemala',367 'country' => 'Guatemala', 368 368 'continent' => 'NA', 369 369 ), 370 370 'GG' => array( 371 'country' => 'Guernsey',371 'country' => 'Guernsey', 372 372 'continent' => 'EU', 373 373 ), 374 374 'GN' => array( 375 'country' => 'Guinea',375 'country' => 'Guinea', 376 376 'continent' => 'AF', 377 377 ), 378 378 'GW' => array( 379 'country' => 'Guinea-bissau',379 'country' => 'Guinea-bissau', 380 380 'continent' => 'AF', 381 381 ), 382 382 'GY' => array( 383 'country' => 'Guyana',383 'country' => 'Guyana', 384 384 'continent' => 'SA', 385 385 ), 386 386 'HT' => array( 387 'country' => 'Haiti',387 'country' => 'Haiti', 388 388 'continent' => 'NA', 389 389 ), 390 390 'HM' => array( 391 'country' => 'Heard Island and Mcdonald Islands',391 'country' => 'Heard Island and Mcdonald Islands', 392 392 'continent' => 'AN', 393 393 ), 394 394 'VA' => array( 395 'country' => 'Holy See (Vatican City State)',395 'country' => 'Holy See (Vatican City State)', 396 396 'continent' => 'EU', 397 397 ), 398 398 'HN' => array( 399 'country' => 'Honduras',399 'country' => 'Honduras', 400 400 'continent' => 'NA', 401 401 ), 402 402 'HK' => array( 403 'country' => 'Hong Kong',403 'country' => 'Hong Kong', 404 404 'continent' => 'AS', 405 405 ), 406 406 'HU' => array( 407 'country' => 'Hungary',407 'country' => 'Hungary', 408 408 'continent' => 'EU', 409 409 ), 410 410 'IS' => array( 411 'country' => 'Iceland',411 'country' => 'Iceland', 412 412 'continent' => 'EU', 413 413 ), 414 414 'IN' => array( 415 'country' => 'India',415 'country' => 'India', 416 416 'continent' => 'AS', 417 417 ), 418 418 'ID' => array( 419 'country' => 'Indonesia',419 'country' => 'Indonesia', 420 420 'continent' => 'AS', 421 421 ), 422 422 'IR' => array( 423 'country' => 'Iran',423 'country' => 'Iran', 424 424 'continent' => 'AS', 425 425 ), 426 426 'IQ' => array( 427 'country' => 'Iraq',427 'country' => 'Iraq', 428 428 'continent' => 'AS', 429 429 ), 430 430 'IE' => array( 431 'country' => 'Ireland',431 'country' => 'Ireland', 432 432 'continent' => 'EU', 433 433 ), 434 434 'IM' => array( 435 'country' => 'Isle of Man',435 'country' => 'Isle of Man', 436 436 'continent' => 'EU', 437 437 ), 438 438 'IL' => array( 439 'country' => 'Israel',439 'country' => 'Israel', 440 440 'continent' => 'AS', 441 441 ), 442 442 'IT' => array( 443 'country' => 'Italy',443 'country' => 'Italy', 444 444 'continent' => 'EU', 445 445 ), 446 446 'JM' => array( 447 'country' => 'Jamaica',447 'country' => 'Jamaica', 448 448 'continent' => 'NA', 449 449 ), 450 450 'JP' => array( 451 'country' => 'Japan',451 'country' => 'Japan', 452 452 'continent' => 'AS', 453 453 ), 454 454 'JE' => array( 455 'country' => 'Jersey',455 'country' => 'Jersey', 456 456 'continent' => 'EU', 457 457 ), 458 458 'JO' => array( 459 'country' => 'Jordan',459 'country' => 'Jordan', 460 460 'continent' => 'AS', 461 461 ), 462 462 'KZ' => array( 463 'country' => 'Kazakhstan',463 'country' => 'Kazakhstan', 464 464 'continent' => 'AS', 465 465 ), 466 466 'KE' => array( 467 'country' => 'Kenya',467 'country' => 'Kenya', 468 468 'continent' => 'AF', 469 469 ), 470 470 'KI' => array( 471 'country' => 'Kiribati',471 'country' => 'Kiribati', 472 472 'continent' => 'OC', 473 473 ), 474 474 'KP' => array( 475 'country' => 'Democratic People\'s Republic of Korea',475 'country' => 'Democratic People\'s Republic of Korea', 476 476 'continent' => 'AS', 477 477 ), 478 478 'KR' => array( 479 'country' => 'Republic of Korea',479 'country' => 'Republic of Korea', 480 480 'continent' => 'AS', 481 481 ), 482 482 'KW' => array( 483 'country' => 'Kuwait',483 'country' => 'Kuwait', 484 484 'continent' => 'AS', 485 485 ), 486 486 'KG' => array( 487 'country' => 'Kyrgyzstan',487 'country' => 'Kyrgyzstan', 488 488 'continent' => 'AS', 489 489 ), 490 490 'LA' => array( 491 'country' => 'Lao People\'s Democratic Republic',491 'country' => 'Lao People\'s Democratic Republic', 492 492 'continent' => 'AS', 493 493 ), 494 494 'LV' => array( 495 'country' => 'Latvia',495 'country' => 'Latvia', 496 496 'continent' => 'EU', 497 497 ), 498 498 'LB' => array( 499 'country' => 'Lebanon',499 'country' => 'Lebanon', 500 500 'continent' => 'AS', 501 501 ), 502 502 'LS' => array( 503 'country' => 'Lesotho',503 'country' => 'Lesotho', 504 504 'continent' => 'AF', 505 505 ), 506 506 'LR' => array( 507 'country' => 'Liberia',507 'country' => 'Liberia', 508 508 'continent' => 'AF', 509 509 ), 510 510 'LY' => array( 511 'country' => 'Libya',511 'country' => 'Libya', 512 512 'continent' => 'AF', 513 513 ), 514 514 'LI' => array( 515 'country' => 'Liechtenstein',515 'country' => 'Liechtenstein', 516 516 'continent' => 'EU', 517 517 ), 518 518 'LT' => array( 519 'country' => 'Lithuania',519 'country' => 'Lithuania', 520 520 'continent' => 'EU', 521 521 ), 522 522 'LU' => array( 523 'country' => 'Luxembourg',523 'country' => 'Luxembourg', 524 524 'continent' => 'EU', 525 525 ), 526 526 'MO' => array( 527 'country' => 'Macao',527 'country' => 'Macao', 528 528 'continent' => 'AS', 529 529 ), 530 530 'MK' => array( 531 'country' => 'Macedonia',531 'country' => 'Macedonia', 532 532 'continent' => 'EU', 533 533 ), 534 534 'MG' => array( 535 'country' => 'Madagascar',535 'country' => 'Madagascar', 536 536 'continent' => 'AF', 537 537 ), 538 538 'MW' => array( 539 'country' => 'Malawi',539 'country' => 'Malawi', 540 540 'continent' => 'AF', 541 541 ), 542 542 'MY' => array( 543 'country' => 'Malaysia',543 'country' => 'Malaysia', 544 544 'continent' => 'AS', 545 545 ), 546 546 'MV' => array( 547 'country' => 'Maldives',547 'country' => 'Maldives', 548 548 'continent' => 'AS', 549 549 ), 550 550 'ML' => array( 551 'country' => 'Mali',551 'country' => 'Mali', 552 552 'continent' => 'AF', 553 553 ), 554 554 'MT' => array( 555 'country' => 'Malta',555 'country' => 'Malta', 556 556 'continent' => 'EU', 557 557 ), 558 558 'MH' => array( 559 'country' => 'Marshall Islands',559 'country' => 'Marshall Islands', 560 560 'continent' => 'OC', 561 561 ), 562 562 'MQ' => array( 563 'country' => 'Martinique',563 'country' => 'Martinique', 564 564 'continent' => 'NA', 565 565 ), 566 566 'MR' => array( 567 'country' => 'Mauritania',567 'country' => 'Mauritania', 568 568 'continent' => 'AF', 569 569 ), 570 570 'MU' => array( 571 'country' => 'Mauritius',571 'country' => 'Mauritius', 572 572 'continent' => 'AF', 573 573 ), 574 574 'YT' => array( 575 'country' => 'Mayotte',575 'country' => 'Mayotte', 576 576 'continent' => 'AF', 577 577 ), 578 578 'MX' => array( 579 'country' => 'Mexico',579 'country' => 'Mexico', 580 580 'continent' => 'NA', 581 581 ), 582 582 'FM' => array( 583 'country' => 'Micronesia',583 'country' => 'Micronesia', 584 584 'continent' => 'OC', 585 585 ), 586 586 'MD' => array( 587 'country' => 'Moldova',587 'country' => 'Moldova', 588 588 'continent' => 'EU', 589 589 ), 590 590 'MC' => array( 591 'country' => 'Monaco',591 'country' => 'Monaco', 592 592 'continent' => 'EU', 593 593 ), 594 594 'MN' => array( 595 'country' => 'Mongolia',595 'country' => 'Mongolia', 596 596 'continent' => 'AS', 597 597 ), 598 598 'ME' => array( 599 'country' => 'Montenegro',599 'country' => 'Montenegro', 600 600 'continent' => 'EU', 601 601 ), 602 602 'MS' => array( 603 'country' => 'Montserrat',603 'country' => 'Montserrat', 604 604 'continent' => 'NA', 605 605 ), 606 606 'MA' => array( 607 'country' => 'Morocco',607 'country' => 'Morocco', 608 608 'continent' => 'AF', 609 609 ), 610 610 'MZ' => array( 611 'country' => 'Mozambique',611 'country' => 'Mozambique', 612 612 'continent' => 'AF', 613 613 ), 614 614 'MM' => array( 615 'country' => 'Myanmar',615 'country' => 'Myanmar', 616 616 'continent' => 'AS', 617 617 ), 618 618 'NA' => array( 619 'country' => 'Namibia',619 'country' => 'Namibia', 620 620 'continent' => 'AF', 621 621 ), 622 622 'NR' => array( 623 'country' => 'Nauru',623 'country' => 'Nauru', 624 624 'continent' => 'OC', 625 625 ), 626 626 'NP' => array( 627 'country' => 'Nepal',627 'country' => 'Nepal', 628 628 'continent' => 'AS', 629 629 ), 630 630 'NL' => array( 631 'country' => 'Netherlands',631 'country' => 'Netherlands', 632 632 'continent' => 'EU', 633 633 ), 634 634 'AN' => array( 635 'country' => 'Netherlands Antilles',635 'country' => 'Netherlands Antilles', 636 636 'continent' => 'NA', 637 637 ), 638 638 'NC' => array( 639 'country' => 'New Caledonia',639 'country' => 'New Caledonia', 640 640 'continent' => 'OC', 641 641 ), 642 642 'NZ' => array( 643 'country' => 'New Zealand',643 'country' => 'New Zealand', 644 644 'continent' => 'OC', 645 645 ), 646 646 'NI' => array( 647 'country' => 'Nicaragua',647 'country' => 'Nicaragua', 648 648 'continent' => 'NA', 649 649 ), 650 650 'NE' => array( 651 'country' => 'Niger',651 'country' => 'Niger', 652 652 'continent' => 'AF', 653 653 ), 654 654 'NG' => array( 655 'country' => 'Nigeria',655 'country' => 'Nigeria', 656 656 'continent' => 'AF', 657 657 ), 658 658 'NU' => array( 659 'country' => 'Niue',659 'country' => 'Niue', 660 660 'continent' => 'OC', 661 661 ), 662 662 'NF' => array( 663 'country' => 'Norfolk Island',663 'country' => 'Norfolk Island', 664 664 'continent' => 'OC', 665 665 ), 666 666 'MP' => array( 667 'country' => 'Northern Mariana Islands',667 'country' => 'Northern Mariana Islands', 668 668 'continent' => 'OC', 669 669 ), 670 670 'NO' => array( 671 'country' => 'Norway',671 'country' => 'Norway', 672 672 'continent' => 'EU', 673 673 ), 674 674 'OM' => array( 675 'country' => 'Oman',675 'country' => 'Oman', 676 676 'continent' => 'AS', 677 677 ), 678 678 'PK' => array( 679 'country' => 'Pakistan',679 'country' => 'Pakistan', 680 680 'continent' => 'AS', 681 681 ), 682 682 'PW' => array( 683 'country' => 'Palau',683 'country' => 'Palau', 684 684 'continent' => 'OC', 685 685 ), 686 686 'PS' => array( 687 'country' => 'Palestinia',687 'country' => 'Palestinia', 688 688 'continent' => 'AS', 689 689 ), 690 690 'PA' => array( 691 'country' => 'Panama',691 'country' => 'Panama', 692 692 'continent' => 'NA', 693 693 ), 694 694 'PG' => array( 695 'country' => 'Papua New Guinea',695 'country' => 'Papua New Guinea', 696 696 'continent' => 'OC', 697 697 ), 698 698 'PY' => array( 699 'country' => 'Paraguay',699 'country' => 'Paraguay', 700 700 'continent' => 'SA', 701 701 ), 702 702 'PE' => array( 703 'country' => 'Peru',703 'country' => 'Peru', 704 704 'continent' => 'SA', 705 705 ), 706 706 'PH' => array( 707 'country' => 'Philippines',707 'country' => 'Philippines', 708 708 'continent' => 'AS', 709 709 ), 710 710 'PN' => array( 711 'country' => 'Pitcairn',711 'country' => 'Pitcairn', 712 712 'continent' => 'OC', 713 713 ), 714 714 'PL' => array( 715 'country' => 'Poland',715 'country' => 'Poland', 716 716 'continent' => 'EU', 717 717 ), 718 718 'PT' => array( 719 'country' => 'Portugal',719 'country' => 'Portugal', 720 720 'continent' => 'EU', 721 721 ), 722 722 'PR' => array( 723 'country' => 'Puerto Rico',723 'country' => 'Puerto Rico', 724 724 'continent' => 'NA', 725 725 ), 726 726 'QA' => array( 727 'country' => 'Qatar',727 'country' => 'Qatar', 728 728 'continent' => 'AS', 729 729 ), 730 730 'RE' => array( 731 'country' => 'Reunion',731 'country' => 'Reunion', 732 732 'continent' => 'AF', 733 733 ), 734 734 'RO' => array( 735 'country' => 'Romania',735 'country' => 'Romania', 736 736 'continent' => 'EU', 737 737 ), 738 738 'RU' => array( 739 'country' => 'Russian Federation',739 'country' => 'Russian Federation', 740 740 'continent' => 'EU', 741 741 ), 742 742 'RW' => array( 743 'country' => 'Rwanda',743 'country' => 'Rwanda', 744 744 'continent' => 'AF', 745 745 ), 746 746 'SH' => array( 747 'country' => 'Saint Helena',747 'country' => 'Saint Helena', 748 748 'continent' => 'AF', 749 749 ), 750 750 'KN' => array( 751 'country' => 'Saint Kitts and Nevis',751 'country' => 'Saint Kitts and Nevis', 752 752 'continent' => 'NA', 753 753 ), 754 754 'LC' => array( 755 'country' => 'Saint Lucia',755 'country' => 'Saint Lucia', 756 756 'continent' => 'NA', 757 757 ), 758 758 'PM' => array( 759 'country' => 'Saint Pierre and Miquelon',759 'country' => 'Saint Pierre and Miquelon', 760 760 'continent' => 'NA', 761 761 ), 762 762 'VC' => array( 763 'country' => 'Saint Vincent and The Grenadines',763 'country' => 'Saint Vincent and The Grenadines', 764 764 'continent' => 'NA', 765 765 ), 766 766 'WS' => array( 767 'country' => 'Samoa',767 'country' => 'Samoa', 768 768 'continent' => 'OC', 769 769 ), 770 770 'SM' => array( 771 'country' => 'San Marino',771 'country' => 'San Marino', 772 772 'continent' => 'EU', 773 773 ), 774 774 'ST' => array( 775 'country' => 'Sao Tome and Principe',775 'country' => 'Sao Tome and Principe', 776 776 'continent' => 'AF', 777 777 ), 778 778 'SA' => array( 779 'country' => 'Saudi Arabia',779 'country' => 'Saudi Arabia', 780 780 'continent' => 'AS', 781 781 ), 782 782 'SN' => array( 783 'country' => 'Senegal',783 'country' => 'Senegal', 784 784 'continent' => 'AF', 785 785 ), 786 786 'RS' => array( 787 'country' => 'Serbia',787 'country' => 'Serbia', 788 788 'continent' => 'EU', 789 789 ), 790 790 'SC' => array( 791 'country' => 'Seychelles',791 'country' => 'Seychelles', 792 792 'continent' => 'AF', 793 793 ), 794 794 'SL' => array( 795 'country' => 'Sierra Leone',795 'country' => 'Sierra Leone', 796 796 'continent' => 'AF', 797 797 ), 798 798 'SG' => array( 799 'country' => 'Singapore',799 'country' => 'Singapore', 800 800 'continent' => 'AS', 801 801 ), 802 802 'SK' => array( 803 'country' => 'Slovakia',803 'country' => 'Slovakia', 804 804 'continent' => 'EU', 805 805 ), 806 806 'SI' => array( 807 'country' => 'Slovenia',807 'country' => 'Slovenia', 808 808 'continent' => 'EU', 809 809 ), 810 810 'SB' => array( 811 'country' => 'Solomon Islands',811 'country' => 'Solomon Islands', 812 812 'continent' => 'OC', 813 813 ), 814 814 'SO' => array( 815 'country' => 'Somalia',815 'country' => 'Somalia', 816 816 'continent' => 'AF', 817 817 ), 818 818 'ZA' => array( 819 'country' => 'South Africa',819 'country' => 'South Africa', 820 820 'continent' => 'AF', 821 821 ), 822 822 'GS' => array( 823 'country' => 'South Georgia and The South Sandwich Islands',823 'country' => 'South Georgia and The South Sandwich Islands', 824 824 'continent' => 'AN', 825 825 ), 826 826 'ES' => array( 827 'country' => 'Spain',827 'country' => 'Spain', 828 828 'continent' => 'EU', 829 829 ), 830 830 'LK' => array( 831 'country' => 'Sri Lanka',831 'country' => 'Sri Lanka', 832 832 'continent' => 'AS', 833 833 ), 834 834 'SD' => array( 835 'country' => 'Sudan',835 'country' => 'Sudan', 836 836 'continent' => 'AF', 837 837 ), 838 838 'SR' => array( 839 'country' => 'Suriname',839 'country' => 'Suriname', 840 840 'continent' => 'SA', 841 841 ), 842 842 'SJ' => array( 843 'country' => 'Svalbard and Jan Mayen',843 'country' => 'Svalbard and Jan Mayen', 844 844 'continent' => 'EU', 845 845 ), 846 846 'SZ' => array( 847 'country' => 'Swaziland',847 'country' => 'Swaziland', 848 848 'continent' => 'AF', 849 849 ), 850 850 'SE' => array( 851 'country' => 'Sweden',851 'country' => 'Sweden', 852 852 'continent' => 'EU', 853 853 ), 854 854 'CH' => array( 855 'country' => 'Switzerland',855 'country' => 'Switzerland', 856 856 'continent' => 'EU', 857 857 ), 858 858 'SY' => array( 859 'country' => 'Syrian Arab Republic',859 'country' => 'Syrian Arab Republic', 860 860 'continent' => 'AS', 861 861 ), 862 862 'TW' => array( 863 'country' => 'Taiwan, Province of China',863 'country' => 'Taiwan, Province of China', 864 864 'continent' => 'AS', 865 865 ), 866 866 'TJ' => array( 867 'country' => 'Tajikistan',867 'country' => 'Tajikistan', 868 868 'continent' => 'AS', 869 869 ), 870 870 'TZ' => array( 871 'country' => 'Tanzania, United Republic of',871 'country' => 'Tanzania, United Republic of', 872 872 'continent' => 'AF', 873 873 ), 874 874 'TH' => array( 875 'country' => 'Thailand',875 'country' => 'Thailand', 876 876 'continent' => 'AS', 877 877 ), 878 878 'TL' => array( 879 'country' => 'Timor-leste',879 'country' => 'Timor-leste', 880 880 'continent' => 'AS', 881 881 ), 882 882 'TG' => array( 883 'country' => 'Togo',883 'country' => 'Togo', 884 884 'continent' => 'AF', 885 885 ), 886 886 'TK' => array( 887 'country' => 'Tokelau',887 'country' => 'Tokelau', 888 888 'continent' => 'OC', 889 889 ), 890 890 'TO' => array( 891 'country' => 'Tonga',891 'country' => 'Tonga', 892 892 'continent' => 'OC', 893 893 ), 894 894 'TT' => array( 895 'country' => 'Trinidad and Tobago',895 'country' => 'Trinidad and Tobago', 896 896 'continent' => 'NA', 897 897 ), 898 898 'TN' => array( 899 'country' => 'Tunisia',899 'country' => 'Tunisia', 900 900 'continent' => 'AF', 901 901 ), 902 902 'TR' => array( 903 'country' => 'Turkey',903 'country' => 'Turkey', 904 904 'continent' => 'AS', 905 905 ), 906 906 'TM' => array( 907 'country' => 'Turkmenistan',907 'country' => 'Turkmenistan', 908 908 'continent' => 'AS', 909 909 ), 910 910 'TC' => array( 911 'country' => 'Turks and Caicos Islands',911 'country' => 'Turks and Caicos Islands', 912 912 'continent' => 'NA', 913 913 ), 914 914 'TV' => array( 915 'country' => 'Tuvalu',915 'country' => 'Tuvalu', 916 916 'continent' => 'OC', 917 917 ), 918 918 'UG' => array( 919 'country' => 'Uganda',919 'country' => 'Uganda', 920 920 'continent' => 'AF', 921 921 ), 922 922 'UA' => array( 923 'country' => 'Ukraine',923 'country' => 'Ukraine', 924 924 'continent' => 'EU', 925 925 ), 926 926 'AE' => array( 927 'country' => 'United Arab Emirates',927 'country' => 'United Arab Emirates', 928 928 'continent' => 'AS', 929 929 ), 930 930 'GB' => array( 931 'country' => 'United Kingdom',931 'country' => 'United Kingdom', 932 932 'continent' => 'EU', 933 933 ), 934 934 'US' => array( 935 'country' => 'United States',935 'country' => 'United States', 936 936 'continent' => 'NA', 937 937 ), 938 938 'UM' => array( 939 'country' => 'United States Minor Outlying Islands',939 'country' => 'United States Minor Outlying Islands', 940 940 'continent' => 'OC', 941 941 ), 942 942 'UY' => array( 943 'country' => 'Uruguay',943 'country' => 'Uruguay', 944 944 'continent' => 'SA', 945 945 ), 946 946 'UZ' => array( 947 'country' => 'Uzbekistan',947 'country' => 'Uzbekistan', 948 948 'continent' => 'AS', 949 949 ), 950 950 'VU' => array( 951 'country' => 'Vanuatu',951 'country' => 'Vanuatu', 952 952 'continent' => 'OC', 953 953 ), 954 954 'VE' => array( 955 'country' => 'Venezuela',955 'country' => 'Venezuela', 956 956 'continent' => 'SA', 957 957 ), 958 958 'VN' => array( 959 'country' => 'Viet Nam',959 'country' => 'Viet Nam', 960 960 'continent' => 'AS', 961 961 ), 962 962 'VG' => array( 963 'country' => 'Virgin Islands, British',963 'country' => 'Virgin Islands, British', 964 964 'continent' => 'NA', 965 965 ), 966 966 'VI' => array( 967 'country' => 'Virgin Islands, U.S.',967 'country' => 'Virgin Islands, U.S.', 968 968 'continent' => 'NA', 969 969 ), 970 970 'WF' => array( 971 'country' => 'Wallis and Futuna',971 'country' => 'Wallis and Futuna', 972 972 'continent' => 'OC', 973 973 ), 974 974 'EH' => array( 975 'country' => 'Western Sahara',975 'country' => 'Western Sahara', 976 976 'continent' => 'AF', 977 977 ), 978 978 'YE' => array( 979 'country' => 'Yemen',979 'country' => 'Yemen', 980 980 'continent' => 'AS', 981 981 ), 982 982 'ZM' => array( 983 'country' => 'Zambia',983 'country' => 'Zambia', 984 984 'continent' => 'AF', 985 985 ), 986 986 'ZW' => array( 987 'country' => 'Zimbabwe',987 'country' => 'Zimbabwe', 988 988 'continent' => 'AF', 989 989 ), -
wpengine-geoip/trunk/js/admin.js
r1715405 r2171321 1 document.getElementById( 'wpbody' ).addEventListener( 'click', function ( event ) { 2 // If this wasn't a click on a notice-dismiss close button, then abort3 if ( 'notice-dismiss' !== event.target.className ) {4 return;5 }1 /** 2 * This JS file sends an ajax request on admin notification close. 3 * 4 * @package wpengine-geoip 5 */ 6 6 7 // This should be our parent div for the notice 8 var parent = event.path[ 1 ] || null; 7 document.getElementById( 'wpbody' ).addEventListener( 8 'click', 9 function ( event ) { 10 // If this wasn't a click on a notice-dismiss close button, then abort. 11 if ( 'notice-dismiss' !== event.target.className ) { 12 return; 13 } 9 14 10 // If the parent div doesn't have our wpengine-geoip class, then abort 11 if ( !parent || -1 === jQuery.inArray( 'wpengine-geoip', parent.classList ) ) { 12 return; 13 } 15 // This should be our parent div for the notice. 16 var parent = event.path[ 1 ] || null; 14 17 15 // Get our notice's key 16 var key = parent.attributes[ 'data-key' ].value || null; 18 // If the parent div doesn't have our wpengine-geoip class, then abort. 19 if ( ! parent || -1 === jQuery.inArray( 'wpengine-geoip', parent.classList ) ) { 20 return; 21 } 17 22 18 // Send our POST request to admin-ajax 19 var http = new XMLHttpRequest(); 20 var params = "action=geoip_dismiss_notice&key=" + key; 21 http.open( "POST", ajaxurl, true ); 22 http.setRequestHeader( "Content-type", "application/x-www-form-urlencoded" ); 23 http.send( params ); 24 } ); 23 // Get our notice's key. 24 var key = parent.attributes[ 'data-key' ].value || null; 25 26 // Send our POST request to admin-ajax. 27 var http = new XMLHttpRequest(); 28 var params = "action=geoip_dismiss_notice&key=" + key + "&nonce=" + window.nonce; 29 http.open( "POST", ajaxurl, true ); 30 http.setRequestHeader( "Content-type", "application/x-www-form-urlencoded" ); 31 http.send( params ); 32 } 33 ); -
wpengine-geoip/trunk/readme.txt
r1868266 r2171321 1 1 === WP Engine GeoTarget === 2 2 Contributors: wpengine, markkelnar, stevenkword, stephenlin, ryanshoover, taylor4484, nateinaction 3 Tags: wpe, wpengine, geo ip, localization, geolocation3 Tags: wpe, wpengine, geotarget, geoip, localization, geolocation 4 4 Requires at least: 3.0.1 5 Tested up to: 4.96 Stable tag: 1.2. 55 Tested up to: 5.2 6 Stable tag: 1.2.7 7 7 8 8 License: GPLv2 or later … … 15 15 WP Engine GeoTarget integrates with the variables on your WP Engine site to display content catered to the visitor’s location. With the ability to access variables from as broad as country to as specific as latitude and longitude, your website can now display geographically relevant content. 16 16 17 18 17 = Geo-Marketing = 19 18 … … 36 35 = * Please Note * = 37 36 38 This plugin will only function on your [WP Engine](http://wpengine.com/plans/?utm_source=wpengine-geoip) Business, Premium or Enterprise level account. This will not function outside of the WP Engine environment.37 Customers on Premium and Enterprise plans can use this plugin at no additional cost. If you are on another plan type and would like to use GeoTarget on one of your sites, you can add it to your plan [here](http://wpengine.com/plans/?utm_source=wpengine-geoip). This will not function outside of the WP Engine environment. 39 38 40 39 == Installation == … … 78 77 == Localized Content == 79 78 80 9) Content: `[geoip-content country="US"]Your US specific content goes here[/geoip-content]` 79 ` 80 [geoip-content country="US"]Your US specific content goes here[/geoip-content] 81 ` 82 81 83 The content shortcode allows you to hide or show specific content based on visitor geographies: 82 84 … … 262 264 == Changelog == 263 265 266 = 1.2.7 = 267 - Optimize plugin name rename loop 268 - Bump for WP 5.2 compatibility 269 270 = 1.2.6 = 271 - Bump for WP 5.0 compatibility 272 264 273 = 1.2.5 = 265 274 - Fix for anchor tag escaping in admin notice -
wpengine-geoip/trunk/wpengine-geoip.php
r1868266 r2171321 1 1 <?php 2 2 /** 3 * Plugin Name: WP Engine GeoTarget 4 * Version: 1.2.5 5 * Description: Create a personalized user experienced based on location. 6 * Author: WP Engine 7 * Author URI: http://wpengine.com 8 * Plugin URI: https://wordpress.org/plugins/wpengine-geoip/ 9 * Text Domain: wpengine-geoip 10 * Domain Path: /languages 3 * This file helps to prevent any issues from file name change 4 * wpengine-geoip.php -> class-geoip.php to adhere to WPCS 11 5 * 12 6 * @package wpengine-geoip 13 7 */ 14 15 /*16 Examples use of how to add geoip information to post content:17 18 function geoip_append_content( $content ) {19 $geo = WPEngine\GeoIp::instance();20 $content .= "How's the weather in {$geo->city()}, {$geo->region()} {$geo->country()}?<br /><br />";21 return $content;22 }23 add_filter( 'the_content', 'geoip_append_content' );24 */25 8 26 9 namespace WPEngine; … … 32 15 33 16 /** 34 * Base class for the GeoTarget plugin, GeoTarget was formerly called GeoIP17 * Replace plugin filename in options table 35 18 */ 36 class GeoIp { 37 38 /** 39 * The single instance of this object. No need to have more than one. 40 * 41 * @var class 42 */ 43 private static $instance = null; 44 45 /** 46 * The path to the plugin. Let's just make that function call once. 47 * 48 * @var string 49 */ 50 private $geoip_path; 51 52 /** 53 * The geographical data loaded from the environment. 54 * 55 * @var array 56 */ 57 public $geos; 58 59 /** 60 * A list of countries and their continents. 61 * 62 * @var array 63 */ 64 public $countries; 65 66 /** 67 * WP-Admin errors notices. 68 * 69 * @var array 70 */ 71 private $admin_notices; 72 73 /** 74 * Text Domain. 75 * 76 * @var string 77 */ 78 const TEXT_DOMAIN = 'wpengine-geoip'; 79 80 /** 81 * Version Number. 82 * 83 * @var string 84 */ 85 const VERSION = '1.2.1'; 86 87 // Shortcodes. 88 const SHORTCODE_CONTINENT = 'geoip-continent'; 89 const SHORTCODE_COUNTRY = 'geoip-country'; 90 const SHORTCODE_REGION = 'geoip-region'; 91 const SHORTCODE_CITY = 'geoip-city'; 92 const SHORTCODE_POSTAL_CODE = 'geoip-postalcode'; 93 const SHORTCODE_LATITUDE = 'geoip-latitude'; 94 const SHORTCODE_LONGITUDE = 'geoip-longitude'; 95 const SHORTCODE_LOCATION = 'geoip-location'; 96 const SHORTCODE_CONTENT = 'geoip-content'; 97 98 /** 99 * Initialize hooks and setup environment variables 100 * 101 * @since 0.1.0 102 */ 103 public static function init() { 104 105 // Initialize. 106 add_action( 'init', array( self::instance(), 'setup' ) ); 107 add_action( 'init', array( self::instance(), 'action_init_register_shortcodes' ) ); 108 109 // Enqueue our javascript. 110 add_action( 'admin_enqueue_scripts', array( self::instance(), 'enqueue_admin_js' ) ); 111 112 // Check for dependencies. 113 add_action( 'admin_init', array( self::instance(), 'action_admin_init_check_plugin_dependencies' ), 9999 ); // check late. 114 add_action( 'admin_notices', array( self::instance(), 'action_admin_notices' ) ); 115 116 // Process AJAX requests. 117 add_action( 'wp_ajax_geoip_dismiss_notice', array( self::instance(), 'ajax_action_dismiss_notice' ) ); 118 } 119 120 /** 121 * Register singleton 122 * 123 * @since 0.1.0 124 */ 125 public static function instance() { 126 // Create a new object if it doesn't exist. 127 if ( is_null( self::$instance ) ) { 128 self::$instance = new self; 129 } 130 131 return self::$instance; 132 } 133 134 /** 135 * Setup environment variables 136 * 137 * @since 0.1.0 138 */ 139 public function setup() { 140 141 $this->geoip_path = plugin_dir_path( __FILE__ ); 142 143 // Get our array of countries and continents. 144 require_once( $this->geoip_path . '/inc/country-list.php' ); 145 146 $this->countries = apply_filters( 'geoip_country_list', geoip_country_list() ); 147 148 $this->geos = $this->get_actuals(); 149 150 $this->geos = $this->get_test_parameters( $this->geos ); 151 152 $this->geos = wp_unslash( $this->geos ); 153 154 $this->geos = apply_filters( 'geoip_location_values', $this->geos ); 155 156 // Prepopulate the admin notices array. 157 $this->admin_notices = array( 158 'info' => array(), 159 'error' => array(), 160 'success' => array(), 161 'warning' => array(), 162 ); 163 } 164 165 /** 166 * Enqueue the admin Javascript file 167 * 168 * @since 1.2.1 169 */ 170 public function enqueue_admin_js() { 171 // Only enqueue the JS if the notice will be showing. 172 if ( ! $this->helper_should_notice_show( 'dependency' ) ) { 173 return; 174 } 175 176 wp_enqueue_script( self::TEXT_DOMAIN . '-admin-js', plugins_url( 'js/admin.js', __FILE__ ), null, self::VERSION, true ); 177 } 178 179 /** 180 * Here we extract the data from headers set by nginx -- lets only send them if they are part of the cache key 181 * 182 * @since 0.1.0 183 * @return array All of the GeoTarget related environment variables available on the current server instance 184 */ 185 public function get_actuals() { 186 187 $geos = array( 188 'countrycode' => getenv( 'HTTP_GEOIP_COUNTRY_CODE' ), 189 'countrycode3' => getenv( 'HTTP_GEOIP_COUNTRY_CODE3' ), 190 'countryname' => getenv( 'HTTP_GEOIP_COUNTRY_NAME' ), 191 'latitude' => getenv( 'HTTP_GEOIP_LATITUDE' ), 192 'longitude' => getenv( 'HTTP_GEOIP_LONGITUDE' ), 193 'areacode' => getenv( 'HTTP_GEOIP_AREA_CODE' ), 194 'region' => getenv( 'HTTP_GEOIP_REGION' ), 195 'city' => getenv( 'HTTP_GEOIP_CITY' ), 196 'postalcode' => getenv( 'HTTP_GEOIP_POSTAL_CODE' ), 197 ); 198 199 $geos['active'] = ( isset( $geos['countrycode'] ) && false !== $geos['countrycode'] ) ? true : false; 200 201 $geos['continent'] = $this->continent( $geos['countrycode'] ); 202 203 return $geos; 204 } 205 206 /** 207 * We want people to be able to test the plugin, so we'll include some url parameters that will spoof a location 208 * 209 * @since 1.1.0 210 * @param array $geos Array of values for the user's location. 211 * @return array Modified version of the GeoTarget location array based on url parameters 212 */ 213 public function get_test_parameters( $geos ) { 214 215 $params = $_GET; 216 217 if ( ! isset( $params['geoip'] ) ) { 218 return $geos; 219 } 220 221 foreach ( $params as $key => $value ) { 222 223 $key = esc_attr( $key ); 224 $value = esc_attr( $value ); 225 226 $key = $this->match_label_synonyms( $key ); 227 228 if ( isset( $geos[ $key ] ) ) { 229 $geos[ $key ] = $value; 230 } 231 } 232 233 return $geos; 234 } 235 236 /** 237 * Get Continent 238 * 239 * @since 1.1.0 240 * @param string $country Two-letter country code. 241 * @return string Two-letter continent code, e.g. EU for Europe 242 */ 243 public function continent( $country = '' ) { 244 245 $continent = ''; 246 247 if ( empty( $country ) ) { 248 $country = $this->geos['countrycode']; 249 } 250 251 if ( isset( $this->countries[ $country ] ) ) { 252 $continent = $this->countries[ $country ]['continent']; 253 } 254 255 return $continent; 256 } 257 258 /** 259 * Get Country 260 * 261 * @since 0.5.0 262 * @return string Two-letter country code, e.g.) US for the United States of America 263 */ 264 public function country() { 265 return $this->geos['countrycode']; 266 } 267 268 /** 269 * Get Region 270 * 271 * @since 0.5.0 272 * @return string Two-letter region code. e.g.) CA for California 273 */ 274 public function region() { 275 return $this->geos['region']; 276 } 277 278 /** 279 * Get City 280 * 281 * @since 0.5.0 282 * @return mixed Description 283 */ 284 public function city() { 285 return $this->geos['city']; 286 } 287 288 /** 289 * Get Postal Code 290 * 291 * @since 0.6.0 292 * @return mixed Description 293 */ 294 public function postal_code() { 295 return $this->geos['postalcode']; 296 } 297 298 /** 299 * Get Latitude 300 * 301 * @since 0.6.0 302 * @return mixed Description 303 */ 304 public function latitude() { 305 return $this->geos['latitude']; 306 } 307 308 /** 309 * Get Longitude 310 * 311 * @since 0.6.0 312 * @return mixed Description 313 */ 314 public function longitude() { 315 return $this->geos['longitude']; 316 } 317 318 /** 319 * Register the shortcode(s) 320 * 321 * @since 0.5.0 322 * @uses add_shortcode() 323 */ 324 public function action_init_register_shortcodes() { 325 326 // Continent Shortcode. 327 if ( ! shortcode_exists( self::SHORTCODE_CONTINENT ) ) { 328 add_shortcode( self::SHORTCODE_CONTINENT, array( $this, 'do_shortcode_continent' ) ); 329 } 330 331 // Country Shortcode. 332 if ( ! shortcode_exists( self::SHORTCODE_COUNTRY ) ) { 333 add_shortcode( self::SHORTCODE_COUNTRY, array( $this, 'do_shortcode_country' ) ); 334 } 335 336 // Region Shortcode. 337 if ( ! shortcode_exists( self::SHORTCODE_REGION ) ) { 338 add_shortcode( self::SHORTCODE_REGION, array( $this, 'do_shortcode_region' ) ); 339 } 340 341 // City Shortcode. 342 if ( ! shortcode_exists( self::SHORTCODE_CITY ) ) { 343 add_shortcode( self::SHORTCODE_CITY, array( $this, 'do_shortcode_city' ) ); 344 } 345 346 // Postal Code Shortcode. 347 if ( ! shortcode_exists( self::SHORTCODE_POSTAL_CODE ) ) { 348 add_shortcode( self::SHORTCODE_POSTAL_CODE, array( $this, 'do_shortcode_postal_code' ) ); 349 } 350 351 // Latitude Shortcode. 352 if ( ! shortcode_exists( self::SHORTCODE_LATITUDE ) ) { 353 add_shortcode( self::SHORTCODE_LATITUDE, array( $this, 'do_shortcode_latitude' ) ); 354 } 355 356 // Longitude Shortcode. 357 if ( ! shortcode_exists( self::SHORTCODE_LONGITUDE ) ) { 358 add_shortcode( self::SHORTCODE_LONGITUDE, array( $this, 'do_shortcode_longitude' ) ); 359 } 360 361 // Smart Location Shortcode. 362 if ( ! shortcode_exists( self::SHORTCODE_LOCATION ) ) { 363 add_shortcode( self::SHORTCODE_LOCATION, array( $this, 'do_shortcode_location' ) ); 364 } 365 366 // Smart Location Shortcode. 367 if ( ! shortcode_exists( self::SHORTCODE_CONTENT ) ) { 368 add_shortcode( self::SHORTCODE_CONTENT, array( $this, 'do_shortcode_content' ) ); 19 function replace_previous_plugin_filename() { 20 $active_plugins = get_option( 'active_plugins', array() ); 21 foreach ( $active_plugins as $key => $active_plugin ) { 22 if ( strstr( $active_plugin, '/wpengine-geoip.php' ) ) { 23 $active_plugins[ $key ] = str_replace( '/wpengine-geoip.php', '/class-geoip.php', $active_plugin ); 24 break; 369 25 } 370 26 } 371 372 /** 373 * Output the current continent 374 * 375 * @since 1.1.0 376 * @param array $atts Shortcode attributes. 377 * @return string Two-letter continent code 378 */ 379 function do_shortcode_continent( $atts ) { 380 $continent = '[' . self::SHORTCODE_CONTINENT . ']'; 381 382 $country = $this->geos['countrycode']; 383 384 if ( isset( $this->countries[ $country ] ) ) { 385 $continent = $this->countries[ $country ]['continent']; 386 } 387 return $continent; 388 } 389 390 /** 391 * Output the current country 392 * 393 * @since 0.5.0 394 * @param array $atts Shortcode attributes. 395 * @return string Two-letter country code 396 */ 397 function do_shortcode_country( $atts ) { 398 if ( isset( $this->geos['countrycode'] ) ) { 399 return $this->country(); 400 } 401 return '[' . self::SHORTCODE_COUNTRY . ']'; 402 } 403 404 /** 405 * Output the current region 406 * 407 * @since 0.5.0 408 * @param array $atts Shortcode attributes. 409 * @return string Two-letter region code 410 */ 411 function do_shortcode_region( $atts ) { 412 if ( isset( $this->geos['region'] ) ) { 413 return $this->region(); 414 } 415 return '[' . self::SHORTCODE_REGION . ']'; 416 } 417 418 /** 419 * Output the current city 420 * 421 * @since 0.5.0 422 * @param array $atts Shortcode attributes. 423 * @return string City name 424 */ 425 function do_shortcode_city( $atts ) { 426 if ( isset( $this->geos['city'] ) ) { 427 return $this->city(); 428 } 429 return '[' . self::SHORTCODE_CITY . ']'; 430 } 431 432 /** 433 * Output the current postal code 434 * 435 * @since 0.6.0 436 * @param array $atts Shortcode attributes. 437 * @return string postal code 438 */ 439 function do_shortcode_postal_code( $atts ) { 440 if ( isset( $this->geos['postalcode'] ) ) { 441 return $this->postal_code(); 442 } 443 return '[' . self::SHORTCODE_POSTAL_CODE . ']'; 444 } 445 446 /** 447 * Output the current latitude 448 * 449 * @since 0.6.0 450 * @param array $atts Shortcode attributes. 451 * @return string latitude 452 */ 453 function do_shortcode_latitude( $atts ) { 454 if ( isset( $this->geos['latitude'] ) ) { 455 return $this->latitude(); 456 } 457 return '[' . self::SHORTCODE_LATITUDE . ']'; 458 } 459 460 /** 461 * Output the current longitude 462 * 463 * @since 0.6.0 464 * @param array $atts Shortcode attributes. 465 * @return string longitude 466 */ 467 function do_shortcode_longitude( $atts ) { 468 if ( isset( $this->geos['longitude'] ) ) { 469 return $this->longitude(); 470 } 471 return '[' . self::SHORTCODE_LONGITUDE . ']'; 472 } 473 474 /** 475 * Output the current human readable location, in a smart way. 476 * 477 * @since 0.5.0 478 * @param array $atts Shortcode attributes. 479 * @return string $html 480 */ 481 function do_shortcode_location( $atts ) { 482 483 $city = $this->city(); 484 if ( isset( $city ) && ! empty( $city ) ) { 485 return trim( $this->city() . ', ' . $this->region() . ' ' . $this->country() ); 486 } 487 // Fallback. 488 return trim( $this->region() . ' ' . $this->country() ); 489 } 490 491 /** 492 * Output the content filtered by region 493 * 494 * @since 1.1.0 495 * @param array $atts Shortcode attributes. 496 * @param string $content HTML content that comes between the shortcode tags. 497 * @return string HTML 498 */ 499 function do_shortcode_content( $atts, $content = null ) { 500 501 $keep = true; 502 503 $test_parameters = array(); 504 505 // Process and organzie the test parameters. 506 foreach ( $atts as $label => $value ) { 507 508 // Intialize our negation parameters. 509 $negate = 0; 510 $inline_negate = 0; 511 512 // Check to see if the attribute has "not" in it. 513 $negate = preg_match( '/not?[-_]?(.*)/', $label, $matches ); 514 515 // WordPress doesn't like a dash in shortcode parameter labels. 516 // Just in case, check to see if the value has "not-" in it. 517 if ( ! $negate ) { 518 $negate = preg_match( '/not?\-([^=]+)\=\"?([^"]+)\"?/', $value, $matches ); 519 $inline_negate = $negate; 520 } 521 522 // Label after the negation match. 523 $label = $negate ? $matches[1] : $label; 524 525 // Value after the negation match. 526 $value = $inline_negate ? $matches[2] : $value; 527 528 // Replace common synonyms with our values. 529 $label = $this->match_label_synonyms( $label ); 530 531 // Abort if the label doesn't match. 532 if ( ! isset( $this->geos[ $label ] ) ) { 533 continue; 534 } 535 536 // Find out if the value is comma delimited. 537 $test_values = (array) explode( ',', $value ); 538 539 // Add the value to the test parameters. 540 $test_parameters[ $label ] = array( 541 'test_values' => $test_values, 542 'negate' => $negate, 543 ); 544 }// End foreach(). 545 546 // Sort the test parameters by region type – largest to smallest. 547 uksort( $test_parameters, array( $this, 'compare_location_type' ) ); 548 549 $test_parameters = apply_filters( 'geoip_test_parameters', $test_parameters, $atts ); 550 551 // Process through parameters, testing to see if we have a match. 552 foreach ( $test_parameters as $label => $parameter ) { 553 554 $test_values = $parameter['test_values']; 555 556 $negate = $parameter['negate']; 557 558 // Sanitize the match value. 559 $match_value = strtolower( $this->geos[ $label ] ); 560 561 // Sanitize the test values. 562 foreach ( $test_values as &$test_value ) { 563 $test_value = strtolower( trim( $test_value, " \t\"." ) ); 564 } 565 566 $is_match = in_array( $match_value, $test_values, true ); 567 568 $is_match = ! $negate ? $is_match : ! $is_match; 569 570 if ( ! $is_match ) { 571 $keep = false; 572 } 573 } 574 575 if ( ! $keep ) { 576 return ''; 577 } 578 579 // Process any shortcodes in the content. 580 $content = do_shortcode( $content ); 581 582 return apply_filters( 'geoip_content', $content, $atts ); 583 } 584 585 /** 586 * Compare the location types 587 * 588 * Used for sorting location types from largest area to smallest area 589 * 590 * @since 1.1.2 591 * @param string $a Type of location. 592 * @param string $b Type of location. 593 * @return int Whether $a is more important than b 594 */ 595 public function compare_location_type( $a, $b ) { 596 $location_types = array( 597 'continent' => 1, 598 'countrycode' => 2, 599 'countrycode3' => 2, 600 'countryname' => 2, 601 'region' => 3, 602 'areacode' => 4, 603 'city' => 5, 604 'postalcode' => 6, 605 ); 606 607 if ( isset( $location_types[ $a ] ) && isset( $location_types[ $b ] ) ) { 608 return $location_types[ $a ] - $location_types[ $b ]; 609 } else { 610 return 0; 611 } 612 } 613 614 /** 615 * Checks if environment variable depencies are available on the server 616 * 617 * @todo Include link to query documentation when available on the Plugin Directory 618 * @since 0.5.0 619 */ 620 public function action_admin_init_check_plugin_dependencies() { 621 $notice_key = 'dependency'; 622 623 if ( $this->helper_should_notice_show( $notice_key ) ) { 624 /* translators: Tells users that the plugin won't automatically work if they're not in the right setup */ 625 $notice = __( 'WP Engine GeoTarget requires a <a href="%s">WP Engine account</a> with GeoTarget enabled for full functionality. Only testing queries will work on this site.', 'wpengine-geoip' ); 626 $this->admin_notices['warning'][ $notice_key ] = sprintf( $notice, 'http://wpengine.com/plans/?utm_source=' . self::TEXT_DOMAIN ); 627 } 628 } 629 630 /** 631 * Displays any of our registered notices 632 * 633 * @since 0.5.0 634 */ 635 public function action_admin_notices() { 636 foreach ( $this->admin_notices as $type => $notices ) { 637 foreach ( $notices as $key => $notice ) { 638 ?> 639 <div class="notice notice-<?php echo esc_attr( $type ); ?> wpengine-geoip is-dismissible" data-key="<?php echo esc_attr( $key ); ?>"> 640 <p> 641 <?php 642 echo wp_kses( 643 $notice, 644 array( 645 'a' => array( 646 'href' => array(), 647 ), 648 'span', 649 'strong', 650 'em', 651 ) 652 ); 653 ?> 654 </p> 655 </div> 656 <?php 657 } 658 } 659 } 660 661 /** 662 * Process an AJAX request to dismiss any notices 663 * Adds a user meta field marking when the notice was dismissed 664 * 665 * @since 1.2.1 666 */ 667 public function ajax_action_dismiss_notice() { 668 if ( empty( $_POST['key'] ) ) { 669 return; 670 } 671 672 $meta_key = self::TEXT_DOMAIN . '-notice-dismissed-' . esc_attr( wp_unslash( $_POST['key'] ) ); 673 674 add_user_meta( get_current_user_id(), $meta_key, time(), true ); 675 } 676 677 /** 678 * Helper: Should a notice show in the dashboard? 679 * 680 * @since 1.2.1 681 * @param string $notice Key of the notice we're testing for. 682 * @return bool Should we show the notice or not. 683 */ 684 protected function helper_should_notice_show( $notice ) { 685 if ( ! $notice ) { 686 return false; 687 } 688 689 $is_active = $this->geos['active']; 690 $is_dismissed = get_user_meta( get_current_user_id(), self::TEXT_DOMAIN . '-notice-dismissed-' . $notice, true ); 691 692 // false = GeoTarget is active, or if we've dismissed the notice before. 693 // true = GeoTarget is not active and we haven't dismissed the notice before. 694 return ! ( $is_active || $is_dismissed ); 695 } 696 697 /** 698 * As a favor to users, let's match some common synonyms 699 * 700 * @since 1.1.0 701 * @param string $label The address label that needs a synonym. 702 * @return string label 703 */ 704 private function match_label_synonyms( $label ) { 705 706 if ( 'country' === $label ) { 707 $label = 'countrycode'; 708 } 709 710 if ( 'state' === $label ) { 711 $label = 'region'; 712 } 713 714 if ( 'zipcode' === $label || 'zip' === $label ) { 715 $label = 'postalcode'; 716 } 717 718 return $label; 719 } 720 721 /** 722 * Utility function: Calculate distance to point 723 * 724 * Provided a lat/lng, calculate the distance from visitor's location 725 * Uses the Haversine Formula, accurate for short distance but not over poles or the equator 726 * 727 * Note: Test against a return value of false to make sure you got a calculated distance. Example: 728 * $geo = WPEngine\GeoIp::instance(); 729 * if ( false !== $geo->distance_to( $latitude, $longitude ) ) { 730 * // Do something 731 * } 732 * 733 * @link http://andrew.hedges.name/experiments/haversine/ 734 * @since 1.2 735 * @param float $lat Latitude of the destination in degrees. 736 * @param float $lng Longitude of the destination in degrees. 737 * @param bool $metric Whether to calculate the distance in kilometers or miles. 738 * @return float Distance in miles 739 */ 740 public function distance_to( $lat, $lng, $metric = false ) { 741 $start_lat = deg2rad( $this->latitude() ); 742 $start_lng = deg2rad( $this->longitude() ); 743 744 // Test for null values passed into the function or a 0,0 coordinate for the user. 745 // If either exist, abort. (0,0 is the result when coordinates fail). 746 if ( is_null( $lat ) || is_null( $lng ) || ( empty( $start_lat ) && empty( $start_lng ) ) ) { 747 return false; 748 } 749 750 // Choose the right radius for the results: radius of the Earth in kilometers and miles. 751 $radius = $metric ? 6373 : 3961; 752 753 // Sanitize the user submitted variables. 754 $lat = floatval( $lat ); 755 $lng = floatval( $lng ); 756 757 $dlng = $lng - $start_lng; 758 $dlat = $lat - $start_lat; 759 760 // Calculate the distance. 761 $a = ( sin( $dlat / 2 ) * sin( $dlat / 2 ) ) + ( cos( $lat ) * cos( $start_lat ) * sin( $dlng / 2 ) * sin( $dlng / 2 ) ); 762 $c = 2 * atan2( sqrt( $a ), sqrt( 1 - $a ) ); 763 $d = $radius * $c; 764 765 return $d; 766 } 27 update_option( 'active_plugins', $active_plugins ); 767 28 } 768 769 // Register the GeoTarget plugin instance. 770 GeoIp::init(); 29 replace_previous_plugin_filename();
Note: See TracChangeset
for help on using the changeset viewer.