Plugin Directory

Changeset 2171321


Ignore:
Timestamp:
10/10/2019 05:01:39 PM (6 years ago)
Author:
nateinaction
Message:

Update to version 1.2.7 from TravisCI

Location:
wpengine-geoip
Files:
2 added
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • wpengine-geoip/tags/1.2.7/inc/country-list.php

    r1699836 r2171321  
    1313    $countries = array(
    1414        'AF' => array(
    15             'country' => 'Afghanistan',
     15            'country'   => 'Afghanistan',
    1616            'continent' => 'AS',
    1717        ),
    1818        'AX' => array(
    19             'country' => 'Åland Islands',
     19            'country'   => 'Åland Islands',
    2020            'continent' => 'EU',
    2121        ),
    2222        'AL' => array(
    23             'country' => 'Albania',
     23            'country'   => 'Albania',
    2424            'continent' => 'EU',
    2525        ),
    2626        'DZ' => array(
    27             'country' => 'Algeria',
     27            'country'   => 'Algeria',
    2828            'continent' => 'AF',
    2929        ),
    3030        'AS' => array(
    31             'country' => 'American Samoa',
     31            'country'   => 'American Samoa',
    3232            'continent' => 'OC',
    3333        ),
    3434        'AD' => array(
    35             'country' => 'Andorra',
     35            'country'   => 'Andorra',
    3636            'continent' => 'EU',
    3737        ),
    3838        'AO' => array(
    39             'country' => 'Angola',
     39            'country'   => 'Angola',
    4040            'continent' => 'AF',
    4141        ),
    4242        'AI' => array(
    43             'country' => 'Anguilla',
     43            'country'   => 'Anguilla',
    4444            'continent' => 'NA',
    4545        ),
    4646        'AQ' => array(
    47             'country' => 'AN',
     47            'country'   => 'AN',
    4848            'continent' => 'AN',
    4949        ),
    5050        'AG' => array(
    51             'country' => 'Antigua and Barbuda',
     51            'country'   => 'Antigua and Barbuda',
    5252            'continent' => 'NA',
    5353        ),
    5454        'AR' => array(
    55             'country' => 'Argentina',
     55            'country'   => 'Argentina',
    5656            'continent' => 'SA',
    5757        ),
    5858        'AM' => array(
    59             'country' => 'Armenia',
     59            'country'   => 'Armenia',
    6060            'continent' => 'AS',
    6161        ),
    6262        'AW' => array(
    63             'country' => 'Aruba',
     63            'country'   => 'Aruba',
    6464            'continent' => 'NA',
    6565        ),
    6666        'AU' => array(
    67             'country' => 'Australia',
     67            'country'   => 'Australia',
    6868            'continent' => 'OC',
    6969        ),
    7070        'AT' => array(
    71             'country' => 'Austria',
     71            'country'   => 'Austria',
    7272            'continent' => 'EU',
    7373        ),
    7474        'AZ' => array(
    75             'country' => 'Azerbaijan',
     75            'country'   => 'Azerbaijan',
    7676            'continent' => 'AS',
    7777        ),
    7878        'BS' => array(
    79             'country' => 'Bahamas',
     79            'country'   => 'Bahamas',
    8080            'continent' => 'NA',
    8181        ),
    8282        'BH' => array(
    83             'country' => 'Bahrain',
     83            'country'   => 'Bahrain',
    8484            'continent' => 'AS',
    8585        ),
    8686        'BD' => array(
    87             'country' => 'Bangladesh',
     87            'country'   => 'Bangladesh',
    8888            'continent' => 'AS',
    8989        ),
    9090        'BB' => array(
    91             'country' => 'Barbados',
     91            'country'   => 'Barbados',
    9292            'continent' => 'NA',
    9393        ),
    9494        'BY' => array(
    95             'country' => 'Belarus',
     95            'country'   => 'Belarus',
    9696            'continent' => 'EU',
    9797        ),
    9898        'BE' => array(
    99             'country' => 'Belgium',
     99            'country'   => 'Belgium',
    100100            'continent' => 'EU',
    101101        ),
    102102        'BZ' => array(
    103             'country' => 'Belize',
     103            'country'   => 'Belize',
    104104            'continent' => 'NA',
    105105        ),
    106106        'BJ' => array(
    107             'country' => 'Benin',
     107            'country'   => 'Benin',
    108108            'continent' => 'AF',
    109109        ),
    110110        'BM' => array(
    111             'country' => 'Bermuda',
     111            'country'   => 'Bermuda',
    112112            'continent' => 'NA',
    113113        ),
    114114        'BT' => array(
    115             'country' => 'Bhutan',
     115            'country'   => 'Bhutan',
    116116            'continent' => 'AS',
    117117        ),
    118118        'BO' => array(
    119             'country' => 'Bolivia',
     119            'country'   => 'Bolivia',
    120120            'continent' => 'SA',
    121121        ),
    122122        'BA' => array(
    123             'country' => 'Bosnia and Herzegovina',
     123            'country'   => 'Bosnia and Herzegovina',
    124124            'continent' => 'EU',
    125125        ),
    126126        'BW' => array(
    127             'country' => 'Botswana',
     127            'country'   => 'Botswana',
    128128            'continent' => 'AF',
    129129        ),
    130130        'BV' => array(
    131             'country' => 'Bouvet Island',
     131            'country'   => 'Bouvet Island',
    132132            'continent' => 'AN',
    133133        ),
    134134        'BR' => array(
    135             'country' => 'Brazil',
     135            'country'   => 'Brazil',
    136136            'continent' => 'SA',
    137137        ),
    138138        'IO' => array(
    139             'country' => 'British Indian Ocean Territory',
     139            'country'   => 'British Indian Ocean Territory',
    140140            'continent' => 'AS',
    141141        ),
    142142        'BN' => array(
    143             'country' => 'Brunei Darussalam',
     143            'country'   => 'Brunei Darussalam',
    144144            'continent' => 'AS',
    145145        ),
    146146        'BG' => array(
    147             'country' => 'Bulgaria',
     147            'country'   => 'Bulgaria',
    148148            'continent' => 'EU',
    149149        ),
    150150        'BF' => array(
    151             'country' => 'Burkina Faso',
     151            'country'   => 'Burkina Faso',
    152152            'continent' => 'AF',
    153153        ),
    154154        'BI' => array(
    155             'country' => 'Burundi',
     155            'country'   => 'Burundi',
    156156            'continent' => 'AF',
    157157        ),
    158158        'KH' => array(
    159             'country' => 'Cambodia',
     159            'country'   => 'Cambodia',
    160160            'continent' => 'AS',
    161161        ),
    162162        'CM' => array(
    163             'country' => 'Cameroon',
     163            'country'   => 'Cameroon',
    164164            'continent' => 'AF',
    165165        ),
    166166        'CA' => array(
    167             'country' => 'Canada',
     167            'country'   => 'Canada',
    168168            'continent' => 'NA',
    169169        ),
    170170        'CV' => array(
    171             'country' => 'Cape Verde',
     171            'country'   => 'Cape Verde',
    172172            'continent' => 'AF',
    173173        ),
    174174        'KY' => array(
    175             'country' => 'Cayman Islands',
     175            'country'   => 'Cayman Islands',
    176176            'continent' => 'NA',
    177177        ),
    178178        'CF' => array(
    179             'country' => 'Central African Republic',
     179            'country'   => 'Central African Republic',
    180180            'continent' => 'AF',
    181181        ),
    182182        'TD' => array(
    183             'country' => 'Chad',
     183            'country'   => 'Chad',
    184184            'continent' => 'AF',
    185185        ),
    186186        'CL' => array(
    187             'country' => 'Chile',
     187            'country'   => 'Chile',
    188188            'continent' => 'SA',
    189189        ),
    190190        'CN' => array(
    191             'country' => 'China',
     191            'country'   => 'China',
    192192            'continent' => 'AS',
    193193        ),
    194194        'CX' => array(
    195             'country' => 'Christmas Island',
     195            'country'   => 'Christmas Island',
    196196            'continent' => 'AS',
    197197        ),
    198198        'CC' => array(
    199             'country' => 'Cocos (Keeling) Islands',
     199            'country'   => 'Cocos (Keeling) Islands',
    200200            'continent' => 'AS',
    201201        ),
    202202        'CO' => array(
    203             'country' => 'Colombia',
     203            'country'   => 'Colombia',
    204204            'continent' => 'SA',
    205205        ),
    206206        'KM' => array(
    207             'country' => 'Comoros',
     207            'country'   => 'Comoros',
    208208            'continent' => 'AF',
    209209        ),
    210210        'CG' => array(
    211             'country' => 'Congo',
     211            'country'   => 'Congo',
    212212            'continent' => 'AF',
    213213        ),
    214214        'CD' => array(
    215             'country' => 'The Democratic Republic of The Congo',
     215            'country'   => 'The Democratic Republic of The Congo',
    216216            'continent' => 'AF',
    217217        ),
    218218        'CK' => array(
    219             'country' => 'Cook Islands',
     219            'country'   => 'Cook Islands',
    220220            'continent' => 'OC',
    221221        ),
    222222        'CR' => array(
    223             'country' => 'Costa Rica',
     223            'country'   => 'Costa Rica',
    224224            'continent' => 'NA',
    225225        ),
    226226        'CI' => array(
    227             'country' => 'Cote D\'ivoire',
     227            'country'   => 'Cote D\'ivoire',
    228228            'continent' => 'AF',
    229229        ),
    230230        'HR' => array(
    231             'country' => 'Croatia',
     231            'country'   => 'Croatia',
    232232            'continent' => 'EU',
    233233        ),
    234234        'CU' => array(
    235             'country' => 'Cuba',
     235            'country'   => 'Cuba',
    236236            'continent' => 'NA',
    237237        ),
    238238        'CY' => array(
    239             'country' => 'Cyprus',
     239            'country'   => 'Cyprus',
    240240            'continent' => 'AS',
    241241        ),
    242242        'CZ' => array(
    243             'country' => 'Czech Republic',
     243            'country'   => 'Czech Republic',
    244244            'continent' => 'EU',
    245245        ),
    246246        'DK' => array(
    247             'country' => 'Denmark',
     247            'country'   => 'Denmark',
    248248            'continent' => 'EU',
    249249        ),
    250250        'DJ' => array(
    251             'country' => 'Djibouti',
     251            'country'   => 'Djibouti',
    252252            'continent' => 'AF',
    253253        ),
    254254        'DM' => array(
    255             'country' => 'Dominica',
     255            'country'   => 'Dominica',
    256256            'continent' => 'NA',
    257257        ),
    258258        'DO' => array(
    259             'country' => 'Dominican Republic',
     259            'country'   => 'Dominican Republic',
    260260            'continent' => 'NA',
    261261        ),
    262262        'EC' => array(
    263             'country' => 'Ecuador',
     263            'country'   => 'Ecuador',
    264264            'continent' => 'SA',
    265265        ),
    266266        'EG' => array(
    267             'country' => 'Egypt',
     267            'country'   => 'Egypt',
    268268            'continent' => 'AF',
    269269        ),
    270270        'SV' => array(
    271             'country' => 'El Salvador',
     271            'country'   => 'El Salvador',
    272272            'continent' => 'NA',
    273273        ),
    274274        'GQ' => array(
    275             'country' => 'Equatorial Guinea',
     275            'country'   => 'Equatorial Guinea',
    276276            'continent' => 'AF',
    277277        ),
    278278        'ER' => array(
    279             'country' => 'Eritrea',
     279            'country'   => 'Eritrea',
    280280            'continent' => 'AF',
    281281        ),
    282282        'EE' => array(
    283             'country' => 'Estonia',
     283            'country'   => 'Estonia',
    284284            'continent' => 'EU',
    285285        ),
    286286        'ET' => array(
    287             'country' => 'Ethiopia',
     287            'country'   => 'Ethiopia',
    288288            'continent' => 'AF',
    289289        ),
    290290        'FK' => array(
    291             'country' => 'Falkland Islands (Malvinas)',
     291            'country'   => 'Falkland Islands (Malvinas)',
    292292            'continent' => 'SA',
    293293        ),
    294294        'FO' => array(
    295             'country' => 'Faroe Islands',
     295            'country'   => 'Faroe Islands',
    296296            'continent' => 'EU',
    297297        ),
    298298        'FJ' => array(
    299             'country' => 'Fiji',
     299            'country'   => 'Fiji',
    300300            'continent' => 'OC',
    301301        ),
    302302        'FI' => array(
    303             'country' => 'Finland',
     303            'country'   => 'Finland',
    304304            'continent' => 'EU',
    305305        ),
    306306        'FR' => array(
    307             'country' => 'France',
     307            'country'   => 'France',
    308308            'continent' => 'EU',
    309309        ),
    310310        'GF' => array(
    311             'country' => 'French Guiana',
     311            'country'   => 'French Guiana',
    312312            'continent' => 'SA',
    313313        ),
    314314        'PF' => array(
    315             'country' => 'French Polynesia',
     315            'country'   => 'French Polynesia',
    316316            'continent' => 'OC',
    317317        ),
    318318        'TF' => array(
    319             'country' => 'French Southern Territories',
     319            'country'   => 'French Southern Territories',
    320320            'continent' => 'AN',
    321321        ),
    322322        'GA' => array(
    323             'country' => 'Gabon',
     323            'country'   => 'Gabon',
    324324            'continent' => 'AF',
    325325        ),
    326326        'GM' => array(
    327             'country' => 'Gambia',
     327            'country'   => 'Gambia',
    328328            'continent' => 'AF',
    329329        ),
    330330        'GE' => array(
    331             'country' => 'Georgia',
     331            'country'   => 'Georgia',
    332332            'continent' => 'AS',
    333333        ),
    334334        'DE' => array(
    335             'country' => 'Germany',
     335            'country'   => 'Germany',
    336336            'continent' => 'EU',
    337337        ),
    338338        'GH' => array(
    339             'country' => 'Ghana',
     339            'country'   => 'Ghana',
    340340            'continent' => 'AF',
    341341        ),
    342342        'GI' => array(
    343             'country' => 'Gibraltar',
     343            'country'   => 'Gibraltar',
    344344            'continent' => 'EU',
    345345        ),
    346346        'GR' => array(
    347             'country' => 'Greece',
     347            'country'   => 'Greece',
    348348            'continent' => 'EU',
    349349        ),
    350350        'GL' => array(
    351             'country' => 'Greenland',
     351            'country'   => 'Greenland',
    352352            'continent' => 'NA',
    353353        ),
    354354        'GD' => array(
    355             'country' => 'Grenada',
     355            'country'   => 'Grenada',
    356356            'continent' => 'NA',
    357357        ),
    358358        'GP' => array(
    359             'country' => 'Guadeloupe',
     359            'country'   => 'Guadeloupe',
    360360            'continent' => 'NA',
    361361        ),
    362362        'GU' => array(
    363             'country' => 'Guam',
     363            'country'   => 'Guam',
    364364            'continent' => 'OC',
    365365        ),
    366366        'GT' => array(
    367             'country' => 'Guatemala',
     367            'country'   => 'Guatemala',
    368368            'continent' => 'NA',
    369369        ),
    370370        'GG' => array(
    371             'country' => 'Guernsey',
     371            'country'   => 'Guernsey',
    372372            'continent' => 'EU',
    373373        ),
    374374        'GN' => array(
    375             'country' => 'Guinea',
     375            'country'   => 'Guinea',
    376376            'continent' => 'AF',
    377377        ),
    378378        'GW' => array(
    379             'country' => 'Guinea-bissau',
     379            'country'   => 'Guinea-bissau',
    380380            'continent' => 'AF',
    381381        ),
    382382        'GY' => array(
    383             'country' => 'Guyana',
     383            'country'   => 'Guyana',
    384384            'continent' => 'SA',
    385385        ),
    386386        'HT' => array(
    387             'country' => 'Haiti',
     387            'country'   => 'Haiti',
    388388            'continent' => 'NA',
    389389        ),
    390390        'HM' => array(
    391             'country' => 'Heard Island and Mcdonald Islands',
     391            'country'   => 'Heard Island and Mcdonald Islands',
    392392            'continent' => 'AN',
    393393        ),
    394394        'VA' => array(
    395             'country' => 'Holy See (Vatican City State)',
     395            'country'   => 'Holy See (Vatican City State)',
    396396            'continent' => 'EU',
    397397        ),
    398398        'HN' => array(
    399             'country' => 'Honduras',
     399            'country'   => 'Honduras',
    400400            'continent' => 'NA',
    401401        ),
    402402        'HK' => array(
    403             'country' => 'Hong Kong',
     403            'country'   => 'Hong Kong',
    404404            'continent' => 'AS',
    405405        ),
    406406        'HU' => array(
    407             'country' => 'Hungary',
     407            'country'   => 'Hungary',
    408408            'continent' => 'EU',
    409409        ),
    410410        'IS' => array(
    411             'country' => 'Iceland',
     411            'country'   => 'Iceland',
    412412            'continent' => 'EU',
    413413        ),
    414414        'IN' => array(
    415             'country' => 'India',
     415            'country'   => 'India',
    416416            'continent' => 'AS',
    417417        ),
    418418        'ID' => array(
    419             'country' => 'Indonesia',
     419            'country'   => 'Indonesia',
    420420            'continent' => 'AS',
    421421        ),
    422422        'IR' => array(
    423             'country' => 'Iran',
     423            'country'   => 'Iran',
    424424            'continent' => 'AS',
    425425        ),
    426426        'IQ' => array(
    427             'country' => 'Iraq',
     427            'country'   => 'Iraq',
    428428            'continent' => 'AS',
    429429        ),
    430430        'IE' => array(
    431             'country' => 'Ireland',
     431            'country'   => 'Ireland',
    432432            'continent' => 'EU',
    433433        ),
    434434        'IM' => array(
    435             'country' => 'Isle of Man',
     435            'country'   => 'Isle of Man',
    436436            'continent' => 'EU',
    437437        ),
    438438        'IL' => array(
    439             'country' => 'Israel',
     439            'country'   => 'Israel',
    440440            'continent' => 'AS',
    441441        ),
    442442        'IT' => array(
    443             'country' => 'Italy',
     443            'country'   => 'Italy',
    444444            'continent' => 'EU',
    445445        ),
    446446        'JM' => array(
    447             'country' => 'Jamaica',
     447            'country'   => 'Jamaica',
    448448            'continent' => 'NA',
    449449        ),
    450450        'JP' => array(
    451             'country' => 'Japan',
     451            'country'   => 'Japan',
    452452            'continent' => 'AS',
    453453        ),
    454454        'JE' => array(
    455             'country' => 'Jersey',
     455            'country'   => 'Jersey',
    456456            'continent' => 'EU',
    457457        ),
    458458        'JO' => array(
    459             'country' => 'Jordan',
     459            'country'   => 'Jordan',
    460460            'continent' => 'AS',
    461461        ),
    462462        'KZ' => array(
    463             'country' => 'Kazakhstan',
     463            'country'   => 'Kazakhstan',
    464464            'continent' => 'AS',
    465465        ),
    466466        'KE' => array(
    467             'country' => 'Kenya',
     467            'country'   => 'Kenya',
    468468            'continent' => 'AF',
    469469        ),
    470470        'KI' => array(
    471             'country' => 'Kiribati',
     471            'country'   => 'Kiribati',
    472472            'continent' => 'OC',
    473473        ),
    474474        'KP' => array(
    475             'country' => 'Democratic People\'s Republic of Korea',
     475            'country'   => 'Democratic People\'s Republic of Korea',
    476476            'continent' => 'AS',
    477477        ),
    478478        'KR' => array(
    479             'country' => 'Republic of Korea',
     479            'country'   => 'Republic of Korea',
    480480            'continent' => 'AS',
    481481        ),
    482482        'KW' => array(
    483             'country' => 'Kuwait',
     483            'country'   => 'Kuwait',
    484484            'continent' => 'AS',
    485485        ),
    486486        'KG' => array(
    487             'country' => 'Kyrgyzstan',
     487            'country'   => 'Kyrgyzstan',
    488488            'continent' => 'AS',
    489489        ),
    490490        'LA' => array(
    491             'country' => 'Lao People\'s Democratic Republic',
     491            'country'   => 'Lao People\'s Democratic Republic',
    492492            'continent' => 'AS',
    493493        ),
    494494        'LV' => array(
    495             'country' => 'Latvia',
     495            'country'   => 'Latvia',
    496496            'continent' => 'EU',
    497497        ),
    498498        'LB' => array(
    499             'country' => 'Lebanon',
     499            'country'   => 'Lebanon',
    500500            'continent' => 'AS',
    501501        ),
    502502        'LS' => array(
    503             'country' => 'Lesotho',
     503            'country'   => 'Lesotho',
    504504            'continent' => 'AF',
    505505        ),
    506506        'LR' => array(
    507             'country' => 'Liberia',
     507            'country'   => 'Liberia',
    508508            'continent' => 'AF',
    509509        ),
    510510        'LY' => array(
    511             'country' => 'Libya',
     511            'country'   => 'Libya',
    512512            'continent' => 'AF',
    513513        ),
    514514        'LI' => array(
    515             'country' => 'Liechtenstein',
     515            'country'   => 'Liechtenstein',
    516516            'continent' => 'EU',
    517517        ),
    518518        'LT' => array(
    519             'country' => 'Lithuania',
     519            'country'   => 'Lithuania',
    520520            'continent' => 'EU',
    521521        ),
    522522        'LU' => array(
    523             'country' => 'Luxembourg',
     523            'country'   => 'Luxembourg',
    524524            'continent' => 'EU',
    525525        ),
    526526        'MO' => array(
    527             'country' => 'Macao',
     527            'country'   => 'Macao',
    528528            'continent' => 'AS',
    529529        ),
    530530        'MK' => array(
    531             'country' => 'Macedonia',
     531            'country'   => 'Macedonia',
    532532            'continent' => 'EU',
    533533        ),
    534534        'MG' => array(
    535             'country' => 'Madagascar',
     535            'country'   => 'Madagascar',
    536536            'continent' => 'AF',
    537537        ),
    538538        'MW' => array(
    539             'country' => 'Malawi',
     539            'country'   => 'Malawi',
    540540            'continent' => 'AF',
    541541        ),
    542542        'MY' => array(
    543             'country' => 'Malaysia',
     543            'country'   => 'Malaysia',
    544544            'continent' => 'AS',
    545545        ),
    546546        'MV' => array(
    547             'country' => 'Maldives',
     547            'country'   => 'Maldives',
    548548            'continent' => 'AS',
    549549        ),
    550550        'ML' => array(
    551             'country' => 'Mali',
     551            'country'   => 'Mali',
    552552            'continent' => 'AF',
    553553        ),
    554554        'MT' => array(
    555             'country' => 'Malta',
     555            'country'   => 'Malta',
    556556            'continent' => 'EU',
    557557        ),
    558558        'MH' => array(
    559             'country' => 'Marshall Islands',
     559            'country'   => 'Marshall Islands',
    560560            'continent' => 'OC',
    561561        ),
    562562        'MQ' => array(
    563             'country' => 'Martinique',
     563            'country'   => 'Martinique',
    564564            'continent' => 'NA',
    565565        ),
    566566        'MR' => array(
    567             'country' => 'Mauritania',
     567            'country'   => 'Mauritania',
    568568            'continent' => 'AF',
    569569        ),
    570570        'MU' => array(
    571             'country' => 'Mauritius',
     571            'country'   => 'Mauritius',
    572572            'continent' => 'AF',
    573573        ),
    574574        'YT' => array(
    575             'country' => 'Mayotte',
     575            'country'   => 'Mayotte',
    576576            'continent' => 'AF',
    577577        ),
    578578        'MX' => array(
    579             'country' => 'Mexico',
     579            'country'   => 'Mexico',
    580580            'continent' => 'NA',
    581581        ),
    582582        'FM' => array(
    583             'country' => 'Micronesia',
     583            'country'   => 'Micronesia',
    584584            'continent' => 'OC',
    585585        ),
    586586        'MD' => array(
    587             'country' => 'Moldova',
     587            'country'   => 'Moldova',
    588588            'continent' => 'EU',
    589589        ),
    590590        'MC' => array(
    591             'country' => 'Monaco',
     591            'country'   => 'Monaco',
    592592            'continent' => 'EU',
    593593        ),
    594594        'MN' => array(
    595             'country' => 'Mongolia',
     595            'country'   => 'Mongolia',
    596596            'continent' => 'AS',
    597597        ),
    598598        'ME' => array(
    599             'country' => 'Montenegro',
     599            'country'   => 'Montenegro',
    600600            'continent' => 'EU',
    601601        ),
    602602        'MS' => array(
    603             'country' => 'Montserrat',
     603            'country'   => 'Montserrat',
    604604            'continent' => 'NA',
    605605        ),
    606606        'MA' => array(
    607             'country' => 'Morocco',
     607            'country'   => 'Morocco',
    608608            'continent' => 'AF',
    609609        ),
    610610        'MZ' => array(
    611             'country' => 'Mozambique',
     611            'country'   => 'Mozambique',
    612612            'continent' => 'AF',
    613613        ),
    614614        'MM' => array(
    615             'country' => 'Myanmar',
     615            'country'   => 'Myanmar',
    616616            'continent' => 'AS',
    617617        ),
    618618        'NA' => array(
    619             'country' => 'Namibia',
     619            'country'   => 'Namibia',
    620620            'continent' => 'AF',
    621621        ),
    622622        'NR' => array(
    623             'country' => 'Nauru',
     623            'country'   => 'Nauru',
    624624            'continent' => 'OC',
    625625        ),
    626626        'NP' => array(
    627             'country' => 'Nepal',
     627            'country'   => 'Nepal',
    628628            'continent' => 'AS',
    629629        ),
    630630        'NL' => array(
    631             'country' => 'Netherlands',
     631            'country'   => 'Netherlands',
    632632            'continent' => 'EU',
    633633        ),
    634634        'AN' => array(
    635             'country' => 'Netherlands Antilles',
     635            'country'   => 'Netherlands Antilles',
    636636            'continent' => 'NA',
    637637        ),
    638638        'NC' => array(
    639             'country' => 'New Caledonia',
     639            'country'   => 'New Caledonia',
    640640            'continent' => 'OC',
    641641        ),
    642642        'NZ' => array(
    643             'country' => 'New Zealand',
     643            'country'   => 'New Zealand',
    644644            'continent' => 'OC',
    645645        ),
    646646        'NI' => array(
    647             'country' => 'Nicaragua',
     647            'country'   => 'Nicaragua',
    648648            'continent' => 'NA',
    649649        ),
    650650        'NE' => array(
    651             'country' => 'Niger',
     651            'country'   => 'Niger',
    652652            'continent' => 'AF',
    653653        ),
    654654        'NG' => array(
    655             'country' => 'Nigeria',
     655            'country'   => 'Nigeria',
    656656            'continent' => 'AF',
    657657        ),
    658658        'NU' => array(
    659             'country' => 'Niue',
     659            'country'   => 'Niue',
    660660            'continent' => 'OC',
    661661        ),
    662662        'NF' => array(
    663             'country' => 'Norfolk Island',
     663            'country'   => 'Norfolk Island',
    664664            'continent' => 'OC',
    665665        ),
    666666        'MP' => array(
    667             'country' => 'Northern Mariana Islands',
     667            'country'   => 'Northern Mariana Islands',
    668668            'continent' => 'OC',
    669669        ),
    670670        'NO' => array(
    671             'country' => 'Norway',
     671            'country'   => 'Norway',
    672672            'continent' => 'EU',
    673673        ),
    674674        'OM' => array(
    675             'country' => 'Oman',
     675            'country'   => 'Oman',
    676676            'continent' => 'AS',
    677677        ),
    678678        'PK' => array(
    679             'country' => 'Pakistan',
     679            'country'   => 'Pakistan',
    680680            'continent' => 'AS',
    681681        ),
    682682        'PW' => array(
    683             'country' => 'Palau',
     683            'country'   => 'Palau',
    684684            'continent' => 'OC',
    685685        ),
    686686        'PS' => array(
    687             'country' => 'Palestinia',
     687            'country'   => 'Palestinia',
    688688            'continent' => 'AS',
    689689        ),
    690690        'PA' => array(
    691             'country' => 'Panama',
     691            'country'   => 'Panama',
    692692            'continent' => 'NA',
    693693        ),
    694694        'PG' => array(
    695             'country' => 'Papua New Guinea',
     695            'country'   => 'Papua New Guinea',
    696696            'continent' => 'OC',
    697697        ),
    698698        'PY' => array(
    699             'country' => 'Paraguay',
     699            'country'   => 'Paraguay',
    700700            'continent' => 'SA',
    701701        ),
    702702        'PE' => array(
    703             'country' => 'Peru',
     703            'country'   => 'Peru',
    704704            'continent' => 'SA',
    705705        ),
    706706        'PH' => array(
    707             'country' => 'Philippines',
     707            'country'   => 'Philippines',
    708708            'continent' => 'AS',
    709709        ),
    710710        'PN' => array(
    711             'country' => 'Pitcairn',
     711            'country'   => 'Pitcairn',
    712712            'continent' => 'OC',
    713713        ),
    714714        'PL' => array(
    715             'country' => 'Poland',
     715            'country'   => 'Poland',
    716716            'continent' => 'EU',
    717717        ),
    718718        'PT' => array(
    719             'country' => 'Portugal',
     719            'country'   => 'Portugal',
    720720            'continent' => 'EU',
    721721        ),
    722722        'PR' => array(
    723             'country' => 'Puerto Rico',
     723            'country'   => 'Puerto Rico',
    724724            'continent' => 'NA',
    725725        ),
    726726        'QA' => array(
    727             'country' => 'Qatar',
     727            'country'   => 'Qatar',
    728728            'continent' => 'AS',
    729729        ),
    730730        'RE' => array(
    731             'country' => 'Reunion',
     731            'country'   => 'Reunion',
    732732            'continent' => 'AF',
    733733        ),
    734734        'RO' => array(
    735             'country' => 'Romania',
     735            'country'   => 'Romania',
    736736            'continent' => 'EU',
    737737        ),
    738738        'RU' => array(
    739             'country' => 'Russian Federation',
     739            'country'   => 'Russian Federation',
    740740            'continent' => 'EU',
    741741        ),
    742742        'RW' => array(
    743             'country' => 'Rwanda',
     743            'country'   => 'Rwanda',
    744744            'continent' => 'AF',
    745745        ),
    746746        'SH' => array(
    747             'country' => 'Saint Helena',
     747            'country'   => 'Saint Helena',
    748748            'continent' => 'AF',
    749749        ),
    750750        'KN' => array(
    751             'country' => 'Saint Kitts and Nevis',
     751            'country'   => 'Saint Kitts and Nevis',
    752752            'continent' => 'NA',
    753753        ),
    754754        'LC' => array(
    755             'country' => 'Saint Lucia',
     755            'country'   => 'Saint Lucia',
    756756            'continent' => 'NA',
    757757        ),
    758758        'PM' => array(
    759             'country' => 'Saint Pierre and Miquelon',
     759            'country'   => 'Saint Pierre and Miquelon',
    760760            'continent' => 'NA',
    761761        ),
    762762        'VC' => array(
    763             'country' => 'Saint Vincent and The Grenadines',
     763            'country'   => 'Saint Vincent and The Grenadines',
    764764            'continent' => 'NA',
    765765        ),
    766766        'WS' => array(
    767             'country' => 'Samoa',
     767            'country'   => 'Samoa',
    768768            'continent' => 'OC',
    769769        ),
    770770        'SM' => array(
    771             'country' => 'San Marino',
     771            'country'   => 'San Marino',
    772772            'continent' => 'EU',
    773773        ),
    774774        'ST' => array(
    775             'country' => 'Sao Tome and Principe',
     775            'country'   => 'Sao Tome and Principe',
    776776            'continent' => 'AF',
    777777        ),
    778778        'SA' => array(
    779             'country' => 'Saudi Arabia',
     779            'country'   => 'Saudi Arabia',
    780780            'continent' => 'AS',
    781781        ),
    782782        'SN' => array(
    783             'country' => 'Senegal',
     783            'country'   => 'Senegal',
    784784            'continent' => 'AF',
    785785        ),
    786786        'RS' => array(
    787             'country' => 'Serbia',
     787            'country'   => 'Serbia',
    788788            'continent' => 'EU',
    789789        ),
    790790        'SC' => array(
    791             'country' => 'Seychelles',
     791            'country'   => 'Seychelles',
    792792            'continent' => 'AF',
    793793        ),
    794794        'SL' => array(
    795             'country' => 'Sierra Leone',
     795            'country'   => 'Sierra Leone',
    796796            'continent' => 'AF',
    797797        ),
    798798        'SG' => array(
    799             'country' => 'Singapore',
     799            'country'   => 'Singapore',
    800800            'continent' => 'AS',
    801801        ),
    802802        'SK' => array(
    803             'country' => 'Slovakia',
     803            'country'   => 'Slovakia',
    804804            'continent' => 'EU',
    805805        ),
    806806        'SI' => array(
    807             'country' => 'Slovenia',
     807            'country'   => 'Slovenia',
    808808            'continent' => 'EU',
    809809        ),
    810810        'SB' => array(
    811             'country' => 'Solomon Islands',
     811            'country'   => 'Solomon Islands',
    812812            'continent' => 'OC',
    813813        ),
    814814        'SO' => array(
    815             'country' => 'Somalia',
     815            'country'   => 'Somalia',
    816816            'continent' => 'AF',
    817817        ),
    818818        'ZA' => array(
    819             'country' => 'South Africa',
     819            'country'   => 'South Africa',
    820820            'continent' => 'AF',
    821821        ),
    822822        'GS' => array(
    823             'country' => 'South Georgia and The South Sandwich Islands',
     823            'country'   => 'South Georgia and The South Sandwich Islands',
    824824            'continent' => 'AN',
    825825        ),
    826826        'ES' => array(
    827             'country' => 'Spain',
     827            'country'   => 'Spain',
    828828            'continent' => 'EU',
    829829        ),
    830830        'LK' => array(
    831             'country' => 'Sri Lanka',
     831            'country'   => 'Sri Lanka',
    832832            'continent' => 'AS',
    833833        ),
    834834        'SD' => array(
    835             'country' => 'Sudan',
     835            'country'   => 'Sudan',
    836836            'continent' => 'AF',
    837837        ),
    838838        'SR' => array(
    839             'country' => 'Suriname',
     839            'country'   => 'Suriname',
    840840            'continent' => 'SA',
    841841        ),
    842842        'SJ' => array(
    843             'country' => 'Svalbard and Jan Mayen',
     843            'country'   => 'Svalbard and Jan Mayen',
    844844            'continent' => 'EU',
    845845        ),
    846846        'SZ' => array(
    847             'country' => 'Swaziland',
     847            'country'   => 'Swaziland',
    848848            'continent' => 'AF',
    849849        ),
    850850        'SE' => array(
    851             'country' => 'Sweden',
     851            'country'   => 'Sweden',
    852852            'continent' => 'EU',
    853853        ),
    854854        'CH' => array(
    855             'country' => 'Switzerland',
     855            'country'   => 'Switzerland',
    856856            'continent' => 'EU',
    857857        ),
    858858        'SY' => array(
    859             'country' => 'Syrian Arab Republic',
     859            'country'   => 'Syrian Arab Republic',
    860860            'continent' => 'AS',
    861861        ),
    862862        'TW' => array(
    863             'country' => 'Taiwan, Province of China',
     863            'country'   => 'Taiwan, Province of China',
    864864            'continent' => 'AS',
    865865        ),
    866866        'TJ' => array(
    867             'country' => 'Tajikistan',
     867            'country'   => 'Tajikistan',
    868868            'continent' => 'AS',
    869869        ),
    870870        'TZ' => array(
    871             'country' => 'Tanzania, United Republic of',
     871            'country'   => 'Tanzania, United Republic of',
    872872            'continent' => 'AF',
    873873        ),
    874874        'TH' => array(
    875             'country' => 'Thailand',
     875            'country'   => 'Thailand',
    876876            'continent' => 'AS',
    877877        ),
    878878        'TL' => array(
    879             'country' => 'Timor-leste',
     879            'country'   => 'Timor-leste',
    880880            'continent' => 'AS',
    881881        ),
    882882        'TG' => array(
    883             'country' => 'Togo',
     883            'country'   => 'Togo',
    884884            'continent' => 'AF',
    885885        ),
    886886        'TK' => array(
    887             'country' => 'Tokelau',
     887            'country'   => 'Tokelau',
    888888            'continent' => 'OC',
    889889        ),
    890890        'TO' => array(
    891             'country' => 'Tonga',
     891            'country'   => 'Tonga',
    892892            'continent' => 'OC',
    893893        ),
    894894        'TT' => array(
    895             'country' => 'Trinidad and Tobago',
     895            'country'   => 'Trinidad and Tobago',
    896896            'continent' => 'NA',
    897897        ),
    898898        'TN' => array(
    899             'country' => 'Tunisia',
     899            'country'   => 'Tunisia',
    900900            'continent' => 'AF',
    901901        ),
    902902        'TR' => array(
    903             'country' => 'Turkey',
     903            'country'   => 'Turkey',
    904904            'continent' => 'AS',
    905905        ),
    906906        'TM' => array(
    907             'country' => 'Turkmenistan',
     907            'country'   => 'Turkmenistan',
    908908            'continent' => 'AS',
    909909        ),
    910910        'TC' => array(
    911             'country' => 'Turks and Caicos Islands',
     911            'country'   => 'Turks and Caicos Islands',
    912912            'continent' => 'NA',
    913913        ),
    914914        'TV' => array(
    915             'country' => 'Tuvalu',
     915            'country'   => 'Tuvalu',
    916916            'continent' => 'OC',
    917917        ),
    918918        'UG' => array(
    919             'country' => 'Uganda',
     919            'country'   => 'Uganda',
    920920            'continent' => 'AF',
    921921        ),
    922922        'UA' => array(
    923             'country' => 'Ukraine',
     923            'country'   => 'Ukraine',
    924924            'continent' => 'EU',
    925925        ),
    926926        'AE' => array(
    927             'country' => 'United Arab Emirates',
     927            'country'   => 'United Arab Emirates',
    928928            'continent' => 'AS',
    929929        ),
    930930        'GB' => array(
    931             'country' => 'United Kingdom',
     931            'country'   => 'United Kingdom',
    932932            'continent' => 'EU',
    933933        ),
    934934        'US' => array(
    935             'country' => 'United States',
     935            'country'   => 'United States',
    936936            'continent' => 'NA',
    937937        ),
    938938        'UM' => array(
    939             'country' => 'United States Minor Outlying Islands',
     939            'country'   => 'United States Minor Outlying Islands',
    940940            'continent' => 'OC',
    941941        ),
    942942        'UY' => array(
    943             'country' => 'Uruguay',
     943            'country'   => 'Uruguay',
    944944            'continent' => 'SA',
    945945        ),
    946946        'UZ' => array(
    947             'country' => 'Uzbekistan',
     947            'country'   => 'Uzbekistan',
    948948            'continent' => 'AS',
    949949        ),
    950950        'VU' => array(
    951             'country' => 'Vanuatu',
     951            'country'   => 'Vanuatu',
    952952            'continent' => 'OC',
    953953        ),
    954954        'VE' => array(
    955             'country' => 'Venezuela',
     955            'country'   => 'Venezuela',
    956956            'continent' => 'SA',
    957957        ),
    958958        'VN' => array(
    959             'country' => 'Viet Nam',
     959            'country'   => 'Viet Nam',
    960960            'continent' => 'AS',
    961961        ),
    962962        'VG' => array(
    963             'country' => 'Virgin Islands, British',
     963            'country'   => 'Virgin Islands, British',
    964964            'continent' => 'NA',
    965965        ),
    966966        'VI' => array(
    967             'country' => 'Virgin Islands, U.S.',
     967            'country'   => 'Virgin Islands, U.S.',
    968968            'continent' => 'NA',
    969969        ),
    970970        'WF' => array(
    971             'country' => 'Wallis and Futuna',
     971            'country'   => 'Wallis and Futuna',
    972972            'continent' => 'OC',
    973973        ),
    974974        'EH' => array(
    975             'country' => 'Western Sahara',
     975            'country'   => 'Western Sahara',
    976976            'continent' => 'AF',
    977977        ),
    978978        'YE' => array(
    979             'country' => 'Yemen',
     979            'country'   => 'Yemen',
    980980            'continent' => 'AS',
    981981        ),
    982982        'ZM' => array(
    983             'country' => 'Zambia',
     983            'country'   => 'Zambia',
    984984            'continent' => 'AF',
    985985        ),
    986986        'ZW' => array(
    987             'country' => 'Zimbabwe',
     987            'country'   => 'Zimbabwe',
    988988            'continent' => 'AF',
    989989        ),
  • 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 abort
    3     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 */
    66
    7     // This should be our parent div for the notice
    8     var parent = event.path[ 1 ] || null;
     7document.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        }
    914
    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;
    1417
    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        }
    1722
    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  
    11=== WP Engine GeoTarget ===
    22Contributors: wpengine, markkelnar, stevenkword, stephenlin, ryanshoover, taylor4484, nateinaction
    3 Tags: wpe, wpengine, geoip, localization, geolocation
     3Tags: wpe, wpengine, geotarget, geoip, localization, geolocation
    44Requires at least: 3.0.1
    5 Tested up to: 4.9
    6 Stable tag: 1.2.5
     5Tested up to: 5.2
     6Stable tag: 1.2.7
    77
    88License: GPLv2 or later
     
    1515WP 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.
    1616
    17 
    1817= Geo-Marketing =
    1918
     
    3635= * Please Note * =
    3736
    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.
     37Customers 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.
    3938
    4039== Installation ==
     
    7877== Localized Content ==
    7978
    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
    8183The content shortcode allows you to hide or show specific content based on visitor geographies:
    8284
     
    262264== Changelog ==
    263265
     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
    264273= 1.2.5 =
    265274- Fix for anchor tag escaping in admin notice
  • wpengine-geoip/tags/1.2.7/wpengine-geoip.php

    r1868266 r2171321  
    11<?php
    22/**
    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
    115 *
    126 * @package wpengine-geoip
    137 */
    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 */
    258
    269namespace WPEngine;
     
    3215
    3316/**
    34  * Base class for the GeoTarget plugin, GeoTarget was formerly called GeoIP
     17 * Replace plugin filename in options table
    3518 */
    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' ) );
     19function 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;
    36925        }
    37026    }
    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 );
    76728}
    768 
    769 // Register the GeoTarget plugin instance.
    770 GeoIp::init();
     29replace_previous_plugin_filename();
  • wpengine-geoip/trunk/inc/country-list.php

    r1699836 r2171321  
    1313    $countries = array(
    1414        'AF' => array(
    15             'country' => 'Afghanistan',
     15            'country'   => 'Afghanistan',
    1616            'continent' => 'AS',
    1717        ),
    1818        'AX' => array(
    19             'country' => 'Åland Islands',
     19            'country'   => 'Åland Islands',
    2020            'continent' => 'EU',
    2121        ),
    2222        'AL' => array(
    23             'country' => 'Albania',
     23            'country'   => 'Albania',
    2424            'continent' => 'EU',
    2525        ),
    2626        'DZ' => array(
    27             'country' => 'Algeria',
     27            'country'   => 'Algeria',
    2828            'continent' => 'AF',
    2929        ),
    3030        'AS' => array(
    31             'country' => 'American Samoa',
     31            'country'   => 'American Samoa',
    3232            'continent' => 'OC',
    3333        ),
    3434        'AD' => array(
    35             'country' => 'Andorra',
     35            'country'   => 'Andorra',
    3636            'continent' => 'EU',
    3737        ),
    3838        'AO' => array(
    39             'country' => 'Angola',
     39            'country'   => 'Angola',
    4040            'continent' => 'AF',
    4141        ),
    4242        'AI' => array(
    43             'country' => 'Anguilla',
     43            'country'   => 'Anguilla',
    4444            'continent' => 'NA',
    4545        ),
    4646        'AQ' => array(
    47             'country' => 'AN',
     47            'country'   => 'AN',
    4848            'continent' => 'AN',
    4949        ),
    5050        'AG' => array(
    51             'country' => 'Antigua and Barbuda',
     51            'country'   => 'Antigua and Barbuda',
    5252            'continent' => 'NA',
    5353        ),
    5454        'AR' => array(
    55             'country' => 'Argentina',
     55            'country'   => 'Argentina',
    5656            'continent' => 'SA',
    5757        ),
    5858        'AM' => array(
    59             'country' => 'Armenia',
     59            'country'   => 'Armenia',
    6060            'continent' => 'AS',
    6161        ),
    6262        'AW' => array(
    63             'country' => 'Aruba',
     63            'country'   => 'Aruba',
    6464            'continent' => 'NA',
    6565        ),
    6666        'AU' => array(
    67             'country' => 'Australia',
     67            'country'   => 'Australia',
    6868            'continent' => 'OC',
    6969        ),
    7070        'AT' => array(
    71             'country' => 'Austria',
     71            'country'   => 'Austria',
    7272            'continent' => 'EU',
    7373        ),
    7474        'AZ' => array(
    75             'country' => 'Azerbaijan',
     75            'country'   => 'Azerbaijan',
    7676            'continent' => 'AS',
    7777        ),
    7878        'BS' => array(
    79             'country' => 'Bahamas',
     79            'country'   => 'Bahamas',
    8080            'continent' => 'NA',
    8181        ),
    8282        'BH' => array(
    83             'country' => 'Bahrain',
     83            'country'   => 'Bahrain',
    8484            'continent' => 'AS',
    8585        ),
    8686        'BD' => array(
    87             'country' => 'Bangladesh',
     87            'country'   => 'Bangladesh',
    8888            'continent' => 'AS',
    8989        ),
    9090        'BB' => array(
    91             'country' => 'Barbados',
     91            'country'   => 'Barbados',
    9292            'continent' => 'NA',
    9393        ),
    9494        'BY' => array(
    95             'country' => 'Belarus',
     95            'country'   => 'Belarus',
    9696            'continent' => 'EU',
    9797        ),
    9898        'BE' => array(
    99             'country' => 'Belgium',
     99            'country'   => 'Belgium',
    100100            'continent' => 'EU',
    101101        ),
    102102        'BZ' => array(
    103             'country' => 'Belize',
     103            'country'   => 'Belize',
    104104            'continent' => 'NA',
    105105        ),
    106106        'BJ' => array(
    107             'country' => 'Benin',
     107            'country'   => 'Benin',
    108108            'continent' => 'AF',
    109109        ),
    110110        'BM' => array(
    111             'country' => 'Bermuda',
     111            'country'   => 'Bermuda',
    112112            'continent' => 'NA',
    113113        ),
    114114        'BT' => array(
    115             'country' => 'Bhutan',
     115            'country'   => 'Bhutan',
    116116            'continent' => 'AS',
    117117        ),
    118118        'BO' => array(
    119             'country' => 'Bolivia',
     119            'country'   => 'Bolivia',
    120120            'continent' => 'SA',
    121121        ),
    122122        'BA' => array(
    123             'country' => 'Bosnia and Herzegovina',
     123            'country'   => 'Bosnia and Herzegovina',
    124124            'continent' => 'EU',
    125125        ),
    126126        'BW' => array(
    127             'country' => 'Botswana',
     127            'country'   => 'Botswana',
    128128            'continent' => 'AF',
    129129        ),
    130130        'BV' => array(
    131             'country' => 'Bouvet Island',
     131            'country'   => 'Bouvet Island',
    132132            'continent' => 'AN',
    133133        ),
    134134        'BR' => array(
    135             'country' => 'Brazil',
     135            'country'   => 'Brazil',
    136136            'continent' => 'SA',
    137137        ),
    138138        'IO' => array(
    139             'country' => 'British Indian Ocean Territory',
     139            'country'   => 'British Indian Ocean Territory',
    140140            'continent' => 'AS',
    141141        ),
    142142        'BN' => array(
    143             'country' => 'Brunei Darussalam',
     143            'country'   => 'Brunei Darussalam',
    144144            'continent' => 'AS',
    145145        ),
    146146        'BG' => array(
    147             'country' => 'Bulgaria',
     147            'country'   => 'Bulgaria',
    148148            'continent' => 'EU',
    149149        ),
    150150        'BF' => array(
    151             'country' => 'Burkina Faso',
     151            'country'   => 'Burkina Faso',
    152152            'continent' => 'AF',
    153153        ),
    154154        'BI' => array(
    155             'country' => 'Burundi',
     155            'country'   => 'Burundi',
    156156            'continent' => 'AF',
    157157        ),
    158158        'KH' => array(
    159             'country' => 'Cambodia',
     159            'country'   => 'Cambodia',
    160160            'continent' => 'AS',
    161161        ),
    162162        'CM' => array(
    163             'country' => 'Cameroon',
     163            'country'   => 'Cameroon',
    164164            'continent' => 'AF',
    165165        ),
    166166        'CA' => array(
    167             'country' => 'Canada',
     167            'country'   => 'Canada',
    168168            'continent' => 'NA',
    169169        ),
    170170        'CV' => array(
    171             'country' => 'Cape Verde',
     171            'country'   => 'Cape Verde',
    172172            'continent' => 'AF',
    173173        ),
    174174        'KY' => array(
    175             'country' => 'Cayman Islands',
     175            'country'   => 'Cayman Islands',
    176176            'continent' => 'NA',
    177177        ),
    178178        'CF' => array(
    179             'country' => 'Central African Republic',
     179            'country'   => 'Central African Republic',
    180180            'continent' => 'AF',
    181181        ),
    182182        'TD' => array(
    183             'country' => 'Chad',
     183            'country'   => 'Chad',
    184184            'continent' => 'AF',
    185185        ),
    186186        'CL' => array(
    187             'country' => 'Chile',
     187            'country'   => 'Chile',
    188188            'continent' => 'SA',
    189189        ),
    190190        'CN' => array(
    191             'country' => 'China',
     191            'country'   => 'China',
    192192            'continent' => 'AS',
    193193        ),
    194194        'CX' => array(
    195             'country' => 'Christmas Island',
     195            'country'   => 'Christmas Island',
    196196            'continent' => 'AS',
    197197        ),
    198198        'CC' => array(
    199             'country' => 'Cocos (Keeling) Islands',
     199            'country'   => 'Cocos (Keeling) Islands',
    200200            'continent' => 'AS',
    201201        ),
    202202        'CO' => array(
    203             'country' => 'Colombia',
     203            'country'   => 'Colombia',
    204204            'continent' => 'SA',
    205205        ),
    206206        'KM' => array(
    207             'country' => 'Comoros',
     207            'country'   => 'Comoros',
    208208            'continent' => 'AF',
    209209        ),
    210210        'CG' => array(
    211             'country' => 'Congo',
     211            'country'   => 'Congo',
    212212            'continent' => 'AF',
    213213        ),
    214214        'CD' => array(
    215             'country' => 'The Democratic Republic of The Congo',
     215            'country'   => 'The Democratic Republic of The Congo',
    216216            'continent' => 'AF',
    217217        ),
    218218        'CK' => array(
    219             'country' => 'Cook Islands',
     219            'country'   => 'Cook Islands',
    220220            'continent' => 'OC',
    221221        ),
    222222        'CR' => array(
    223             'country' => 'Costa Rica',
     223            'country'   => 'Costa Rica',
    224224            'continent' => 'NA',
    225225        ),
    226226        'CI' => array(
    227             'country' => 'Cote D\'ivoire',
     227            'country'   => 'Cote D\'ivoire',
    228228            'continent' => 'AF',
    229229        ),
    230230        'HR' => array(
    231             'country' => 'Croatia',
     231            'country'   => 'Croatia',
    232232            'continent' => 'EU',
    233233        ),
    234234        'CU' => array(
    235             'country' => 'Cuba',
     235            'country'   => 'Cuba',
    236236            'continent' => 'NA',
    237237        ),
    238238        'CY' => array(
    239             'country' => 'Cyprus',
     239            'country'   => 'Cyprus',
    240240            'continent' => 'AS',
    241241        ),
    242242        'CZ' => array(
    243             'country' => 'Czech Republic',
     243            'country'   => 'Czech Republic',
    244244            'continent' => 'EU',
    245245        ),
    246246        'DK' => array(
    247             'country' => 'Denmark',
     247            'country'   => 'Denmark',
    248248            'continent' => 'EU',
    249249        ),
    250250        'DJ' => array(
    251             'country' => 'Djibouti',
     251            'country'   => 'Djibouti',
    252252            'continent' => 'AF',
    253253        ),
    254254        'DM' => array(
    255             'country' => 'Dominica',
     255            'country'   => 'Dominica',
    256256            'continent' => 'NA',
    257257        ),
    258258        'DO' => array(
    259             'country' => 'Dominican Republic',
     259            'country'   => 'Dominican Republic',
    260260            'continent' => 'NA',
    261261        ),
    262262        'EC' => array(
    263             'country' => 'Ecuador',
     263            'country'   => 'Ecuador',
    264264            'continent' => 'SA',
    265265        ),
    266266        'EG' => array(
    267             'country' => 'Egypt',
     267            'country'   => 'Egypt',
    268268            'continent' => 'AF',
    269269        ),
    270270        'SV' => array(
    271             'country' => 'El Salvador',
     271            'country'   => 'El Salvador',
    272272            'continent' => 'NA',
    273273        ),
    274274        'GQ' => array(
    275             'country' => 'Equatorial Guinea',
     275            'country'   => 'Equatorial Guinea',
    276276            'continent' => 'AF',
    277277        ),
    278278        'ER' => array(
    279             'country' => 'Eritrea',
     279            'country'   => 'Eritrea',
    280280            'continent' => 'AF',
    281281        ),
    282282        'EE' => array(
    283             'country' => 'Estonia',
     283            'country'   => 'Estonia',
    284284            'continent' => 'EU',
    285285        ),
    286286        'ET' => array(
    287             'country' => 'Ethiopia',
     287            'country'   => 'Ethiopia',
    288288            'continent' => 'AF',
    289289        ),
    290290        'FK' => array(
    291             'country' => 'Falkland Islands (Malvinas)',
     291            'country'   => 'Falkland Islands (Malvinas)',
    292292            'continent' => 'SA',
    293293        ),
    294294        'FO' => array(
    295             'country' => 'Faroe Islands',
     295            'country'   => 'Faroe Islands',
    296296            'continent' => 'EU',
    297297        ),
    298298        'FJ' => array(
    299             'country' => 'Fiji',
     299            'country'   => 'Fiji',
    300300            'continent' => 'OC',
    301301        ),
    302302        'FI' => array(
    303             'country' => 'Finland',
     303            'country'   => 'Finland',
    304304            'continent' => 'EU',
    305305        ),
    306306        'FR' => array(
    307             'country' => 'France',
     307            'country'   => 'France',
    308308            'continent' => 'EU',
    309309        ),
    310310        'GF' => array(
    311             'country' => 'French Guiana',
     311            'country'   => 'French Guiana',
    312312            'continent' => 'SA',
    313313        ),
    314314        'PF' => array(
    315             'country' => 'French Polynesia',
     315            'country'   => 'French Polynesia',
    316316            'continent' => 'OC',
    317317        ),
    318318        'TF' => array(
    319             'country' => 'French Southern Territories',
     319            'country'   => 'French Southern Territories',
    320320            'continent' => 'AN',
    321321        ),
    322322        'GA' => array(
    323             'country' => 'Gabon',
     323            'country'   => 'Gabon',
    324324            'continent' => 'AF',
    325325        ),
    326326        'GM' => array(
    327             'country' => 'Gambia',
     327            'country'   => 'Gambia',
    328328            'continent' => 'AF',
    329329        ),
    330330        'GE' => array(
    331             'country' => 'Georgia',
     331            'country'   => 'Georgia',
    332332            'continent' => 'AS',
    333333        ),
    334334        'DE' => array(
    335             'country' => 'Germany',
     335            'country'   => 'Germany',
    336336            'continent' => 'EU',
    337337        ),
    338338        'GH' => array(
    339             'country' => 'Ghana',
     339            'country'   => 'Ghana',
    340340            'continent' => 'AF',
    341341        ),
    342342        'GI' => array(
    343             'country' => 'Gibraltar',
     343            'country'   => 'Gibraltar',
    344344            'continent' => 'EU',
    345345        ),
    346346        'GR' => array(
    347             'country' => 'Greece',
     347            'country'   => 'Greece',
    348348            'continent' => 'EU',
    349349        ),
    350350        'GL' => array(
    351             'country' => 'Greenland',
     351            'country'   => 'Greenland',
    352352            'continent' => 'NA',
    353353        ),
    354354        'GD' => array(
    355             'country' => 'Grenada',
     355            'country'   => 'Grenada',
    356356            'continent' => 'NA',
    357357        ),
    358358        'GP' => array(
    359             'country' => 'Guadeloupe',
     359            'country'   => 'Guadeloupe',
    360360            'continent' => 'NA',
    361361        ),
    362362        'GU' => array(
    363             'country' => 'Guam',
     363            'country'   => 'Guam',
    364364            'continent' => 'OC',
    365365        ),
    366366        'GT' => array(
    367             'country' => 'Guatemala',
     367            'country'   => 'Guatemala',
    368368            'continent' => 'NA',
    369369        ),
    370370        'GG' => array(
    371             'country' => 'Guernsey',
     371            'country'   => 'Guernsey',
    372372            'continent' => 'EU',
    373373        ),
    374374        'GN' => array(
    375             'country' => 'Guinea',
     375            'country'   => 'Guinea',
    376376            'continent' => 'AF',
    377377        ),
    378378        'GW' => array(
    379             'country' => 'Guinea-bissau',
     379            'country'   => 'Guinea-bissau',
    380380            'continent' => 'AF',
    381381        ),
    382382        'GY' => array(
    383             'country' => 'Guyana',
     383            'country'   => 'Guyana',
    384384            'continent' => 'SA',
    385385        ),
    386386        'HT' => array(
    387             'country' => 'Haiti',
     387            'country'   => 'Haiti',
    388388            'continent' => 'NA',
    389389        ),
    390390        'HM' => array(
    391             'country' => 'Heard Island and Mcdonald Islands',
     391            'country'   => 'Heard Island and Mcdonald Islands',
    392392            'continent' => 'AN',
    393393        ),
    394394        'VA' => array(
    395             'country' => 'Holy See (Vatican City State)',
     395            'country'   => 'Holy See (Vatican City State)',
    396396            'continent' => 'EU',
    397397        ),
    398398        'HN' => array(
    399             'country' => 'Honduras',
     399            'country'   => 'Honduras',
    400400            'continent' => 'NA',
    401401        ),
    402402        'HK' => array(
    403             'country' => 'Hong Kong',
     403            'country'   => 'Hong Kong',
    404404            'continent' => 'AS',
    405405        ),
    406406        'HU' => array(
    407             'country' => 'Hungary',
     407            'country'   => 'Hungary',
    408408            'continent' => 'EU',
    409409        ),
    410410        'IS' => array(
    411             'country' => 'Iceland',
     411            'country'   => 'Iceland',
    412412            'continent' => 'EU',
    413413        ),
    414414        'IN' => array(
    415             'country' => 'India',
     415            'country'   => 'India',
    416416            'continent' => 'AS',
    417417        ),
    418418        'ID' => array(
    419             'country' => 'Indonesia',
     419            'country'   => 'Indonesia',
    420420            'continent' => 'AS',
    421421        ),
    422422        'IR' => array(
    423             'country' => 'Iran',
     423            'country'   => 'Iran',
    424424            'continent' => 'AS',
    425425        ),
    426426        'IQ' => array(
    427             'country' => 'Iraq',
     427            'country'   => 'Iraq',
    428428            'continent' => 'AS',
    429429        ),
    430430        'IE' => array(
    431             'country' => 'Ireland',
     431            'country'   => 'Ireland',
    432432            'continent' => 'EU',
    433433        ),
    434434        'IM' => array(
    435             'country' => 'Isle of Man',
     435            'country'   => 'Isle of Man',
    436436            'continent' => 'EU',
    437437        ),
    438438        'IL' => array(
    439             'country' => 'Israel',
     439            'country'   => 'Israel',
    440440            'continent' => 'AS',
    441441        ),
    442442        'IT' => array(
    443             'country' => 'Italy',
     443            'country'   => 'Italy',
    444444            'continent' => 'EU',
    445445        ),
    446446        'JM' => array(
    447             'country' => 'Jamaica',
     447            'country'   => 'Jamaica',
    448448            'continent' => 'NA',
    449449        ),
    450450        'JP' => array(
    451             'country' => 'Japan',
     451            'country'   => 'Japan',
    452452            'continent' => 'AS',
    453453        ),
    454454        'JE' => array(
    455             'country' => 'Jersey',
     455            'country'   => 'Jersey',
    456456            'continent' => 'EU',
    457457        ),
    458458        'JO' => array(
    459             'country' => 'Jordan',
     459            'country'   => 'Jordan',
    460460            'continent' => 'AS',
    461461        ),
    462462        'KZ' => array(
    463             'country' => 'Kazakhstan',
     463            'country'   => 'Kazakhstan',
    464464            'continent' => 'AS',
    465465        ),
    466466        'KE' => array(
    467             'country' => 'Kenya',
     467            'country'   => 'Kenya',
    468468            'continent' => 'AF',
    469469        ),
    470470        'KI' => array(
    471             'country' => 'Kiribati',
     471            'country'   => 'Kiribati',
    472472            'continent' => 'OC',
    473473        ),
    474474        'KP' => array(
    475             'country' => 'Democratic People\'s Republic of Korea',
     475            'country'   => 'Democratic People\'s Republic of Korea',
    476476            'continent' => 'AS',
    477477        ),
    478478        'KR' => array(
    479             'country' => 'Republic of Korea',
     479            'country'   => 'Republic of Korea',
    480480            'continent' => 'AS',
    481481        ),
    482482        'KW' => array(
    483             'country' => 'Kuwait',
     483            'country'   => 'Kuwait',
    484484            'continent' => 'AS',
    485485        ),
    486486        'KG' => array(
    487             'country' => 'Kyrgyzstan',
     487            'country'   => 'Kyrgyzstan',
    488488            'continent' => 'AS',
    489489        ),
    490490        'LA' => array(
    491             'country' => 'Lao People\'s Democratic Republic',
     491            'country'   => 'Lao People\'s Democratic Republic',
    492492            'continent' => 'AS',
    493493        ),
    494494        'LV' => array(
    495             'country' => 'Latvia',
     495            'country'   => 'Latvia',
    496496            'continent' => 'EU',
    497497        ),
    498498        'LB' => array(
    499             'country' => 'Lebanon',
     499            'country'   => 'Lebanon',
    500500            'continent' => 'AS',
    501501        ),
    502502        'LS' => array(
    503             'country' => 'Lesotho',
     503            'country'   => 'Lesotho',
    504504            'continent' => 'AF',
    505505        ),
    506506        'LR' => array(
    507             'country' => 'Liberia',
     507            'country'   => 'Liberia',
    508508            'continent' => 'AF',
    509509        ),
    510510        'LY' => array(
    511             'country' => 'Libya',
     511            'country'   => 'Libya',
    512512            'continent' => 'AF',
    513513        ),
    514514        'LI' => array(
    515             'country' => 'Liechtenstein',
     515            'country'   => 'Liechtenstein',
    516516            'continent' => 'EU',
    517517        ),
    518518        'LT' => array(
    519             'country' => 'Lithuania',
     519            'country'   => 'Lithuania',
    520520            'continent' => 'EU',
    521521        ),
    522522        'LU' => array(
    523             'country' => 'Luxembourg',
     523            'country'   => 'Luxembourg',
    524524            'continent' => 'EU',
    525525        ),
    526526        'MO' => array(
    527             'country' => 'Macao',
     527            'country'   => 'Macao',
    528528            'continent' => 'AS',
    529529        ),
    530530        'MK' => array(
    531             'country' => 'Macedonia',
     531            'country'   => 'Macedonia',
    532532            'continent' => 'EU',
    533533        ),
    534534        'MG' => array(
    535             'country' => 'Madagascar',
     535            'country'   => 'Madagascar',
    536536            'continent' => 'AF',
    537537        ),
    538538        'MW' => array(
    539             'country' => 'Malawi',
     539            'country'   => 'Malawi',
    540540            'continent' => 'AF',
    541541        ),
    542542        'MY' => array(
    543             'country' => 'Malaysia',
     543            'country'   => 'Malaysia',
    544544            'continent' => 'AS',
    545545        ),
    546546        'MV' => array(
    547             'country' => 'Maldives',
     547            'country'   => 'Maldives',
    548548            'continent' => 'AS',
    549549        ),
    550550        'ML' => array(
    551             'country' => 'Mali',
     551            'country'   => 'Mali',
    552552            'continent' => 'AF',
    553553        ),
    554554        'MT' => array(
    555             'country' => 'Malta',
     555            'country'   => 'Malta',
    556556            'continent' => 'EU',
    557557        ),
    558558        'MH' => array(
    559             'country' => 'Marshall Islands',
     559            'country'   => 'Marshall Islands',
    560560            'continent' => 'OC',
    561561        ),
    562562        'MQ' => array(
    563             'country' => 'Martinique',
     563            'country'   => 'Martinique',
    564564            'continent' => 'NA',
    565565        ),
    566566        'MR' => array(
    567             'country' => 'Mauritania',
     567            'country'   => 'Mauritania',
    568568            'continent' => 'AF',
    569569        ),
    570570        'MU' => array(
    571             'country' => 'Mauritius',
     571            'country'   => 'Mauritius',
    572572            'continent' => 'AF',
    573573        ),
    574574        'YT' => array(
    575             'country' => 'Mayotte',
     575            'country'   => 'Mayotte',
    576576            'continent' => 'AF',
    577577        ),
    578578        'MX' => array(
    579             'country' => 'Mexico',
     579            'country'   => 'Mexico',
    580580            'continent' => 'NA',
    581581        ),
    582582        'FM' => array(
    583             'country' => 'Micronesia',
     583            'country'   => 'Micronesia',
    584584            'continent' => 'OC',
    585585        ),
    586586        'MD' => array(
    587             'country' => 'Moldova',
     587            'country'   => 'Moldova',
    588588            'continent' => 'EU',
    589589        ),
    590590        'MC' => array(
    591             'country' => 'Monaco',
     591            'country'   => 'Monaco',
    592592            'continent' => 'EU',
    593593        ),
    594594        'MN' => array(
    595             'country' => 'Mongolia',
     595            'country'   => 'Mongolia',
    596596            'continent' => 'AS',
    597597        ),
    598598        'ME' => array(
    599             'country' => 'Montenegro',
     599            'country'   => 'Montenegro',
    600600            'continent' => 'EU',
    601601        ),
    602602        'MS' => array(
    603             'country' => 'Montserrat',
     603            'country'   => 'Montserrat',
    604604            'continent' => 'NA',
    605605        ),
    606606        'MA' => array(
    607             'country' => 'Morocco',
     607            'country'   => 'Morocco',
    608608            'continent' => 'AF',
    609609        ),
    610610        'MZ' => array(
    611             'country' => 'Mozambique',
     611            'country'   => 'Mozambique',
    612612            'continent' => 'AF',
    613613        ),
    614614        'MM' => array(
    615             'country' => 'Myanmar',
     615            'country'   => 'Myanmar',
    616616            'continent' => 'AS',
    617617        ),
    618618        'NA' => array(
    619             'country' => 'Namibia',
     619            'country'   => 'Namibia',
    620620            'continent' => 'AF',
    621621        ),
    622622        'NR' => array(
    623             'country' => 'Nauru',
     623            'country'   => 'Nauru',
    624624            'continent' => 'OC',
    625625        ),
    626626        'NP' => array(
    627             'country' => 'Nepal',
     627            'country'   => 'Nepal',
    628628            'continent' => 'AS',
    629629        ),
    630630        'NL' => array(
    631             'country' => 'Netherlands',
     631            'country'   => 'Netherlands',
    632632            'continent' => 'EU',
    633633        ),
    634634        'AN' => array(
    635             'country' => 'Netherlands Antilles',
     635            'country'   => 'Netherlands Antilles',
    636636            'continent' => 'NA',
    637637        ),
    638638        'NC' => array(
    639             'country' => 'New Caledonia',
     639            'country'   => 'New Caledonia',
    640640            'continent' => 'OC',
    641641        ),
    642642        'NZ' => array(
    643             'country' => 'New Zealand',
     643            'country'   => 'New Zealand',
    644644            'continent' => 'OC',
    645645        ),
    646646        'NI' => array(
    647             'country' => 'Nicaragua',
     647            'country'   => 'Nicaragua',
    648648            'continent' => 'NA',
    649649        ),
    650650        'NE' => array(
    651             'country' => 'Niger',
     651            'country'   => 'Niger',
    652652            'continent' => 'AF',
    653653        ),
    654654        'NG' => array(
    655             'country' => 'Nigeria',
     655            'country'   => 'Nigeria',
    656656            'continent' => 'AF',
    657657        ),
    658658        'NU' => array(
    659             'country' => 'Niue',
     659            'country'   => 'Niue',
    660660            'continent' => 'OC',
    661661        ),
    662662        'NF' => array(
    663             'country' => 'Norfolk Island',
     663            'country'   => 'Norfolk Island',
    664664            'continent' => 'OC',
    665665        ),
    666666        'MP' => array(
    667             'country' => 'Northern Mariana Islands',
     667            'country'   => 'Northern Mariana Islands',
    668668            'continent' => 'OC',
    669669        ),
    670670        'NO' => array(
    671             'country' => 'Norway',
     671            'country'   => 'Norway',
    672672            'continent' => 'EU',
    673673        ),
    674674        'OM' => array(
    675             'country' => 'Oman',
     675            'country'   => 'Oman',
    676676            'continent' => 'AS',
    677677        ),
    678678        'PK' => array(
    679             'country' => 'Pakistan',
     679            'country'   => 'Pakistan',
    680680            'continent' => 'AS',
    681681        ),
    682682        'PW' => array(
    683             'country' => 'Palau',
     683            'country'   => 'Palau',
    684684            'continent' => 'OC',
    685685        ),
    686686        'PS' => array(
    687             'country' => 'Palestinia',
     687            'country'   => 'Palestinia',
    688688            'continent' => 'AS',
    689689        ),
    690690        'PA' => array(
    691             'country' => 'Panama',
     691            'country'   => 'Panama',
    692692            'continent' => 'NA',
    693693        ),
    694694        'PG' => array(
    695             'country' => 'Papua New Guinea',
     695            'country'   => 'Papua New Guinea',
    696696            'continent' => 'OC',
    697697        ),
    698698        'PY' => array(
    699             'country' => 'Paraguay',
     699            'country'   => 'Paraguay',
    700700            'continent' => 'SA',
    701701        ),
    702702        'PE' => array(
    703             'country' => 'Peru',
     703            'country'   => 'Peru',
    704704            'continent' => 'SA',
    705705        ),
    706706        'PH' => array(
    707             'country' => 'Philippines',
     707            'country'   => 'Philippines',
    708708            'continent' => 'AS',
    709709        ),
    710710        'PN' => array(
    711             'country' => 'Pitcairn',
     711            'country'   => 'Pitcairn',
    712712            'continent' => 'OC',
    713713        ),
    714714        'PL' => array(
    715             'country' => 'Poland',
     715            'country'   => 'Poland',
    716716            'continent' => 'EU',
    717717        ),
    718718        'PT' => array(
    719             'country' => 'Portugal',
     719            'country'   => 'Portugal',
    720720            'continent' => 'EU',
    721721        ),
    722722        'PR' => array(
    723             'country' => 'Puerto Rico',
     723            'country'   => 'Puerto Rico',
    724724            'continent' => 'NA',
    725725        ),
    726726        'QA' => array(
    727             'country' => 'Qatar',
     727            'country'   => 'Qatar',
    728728            'continent' => 'AS',
    729729        ),
    730730        'RE' => array(
    731             'country' => 'Reunion',
     731            'country'   => 'Reunion',
    732732            'continent' => 'AF',
    733733        ),
    734734        'RO' => array(
    735             'country' => 'Romania',
     735            'country'   => 'Romania',
    736736            'continent' => 'EU',
    737737        ),
    738738        'RU' => array(
    739             'country' => 'Russian Federation',
     739            'country'   => 'Russian Federation',
    740740            'continent' => 'EU',
    741741        ),
    742742        'RW' => array(
    743             'country' => 'Rwanda',
     743            'country'   => 'Rwanda',
    744744            'continent' => 'AF',
    745745        ),
    746746        'SH' => array(
    747             'country' => 'Saint Helena',
     747            'country'   => 'Saint Helena',
    748748            'continent' => 'AF',
    749749        ),
    750750        'KN' => array(
    751             'country' => 'Saint Kitts and Nevis',
     751            'country'   => 'Saint Kitts and Nevis',
    752752            'continent' => 'NA',
    753753        ),
    754754        'LC' => array(
    755             'country' => 'Saint Lucia',
     755            'country'   => 'Saint Lucia',
    756756            'continent' => 'NA',
    757757        ),
    758758        'PM' => array(
    759             'country' => 'Saint Pierre and Miquelon',
     759            'country'   => 'Saint Pierre and Miquelon',
    760760            'continent' => 'NA',
    761761        ),
    762762        'VC' => array(
    763             'country' => 'Saint Vincent and The Grenadines',
     763            'country'   => 'Saint Vincent and The Grenadines',
    764764            'continent' => 'NA',
    765765        ),
    766766        'WS' => array(
    767             'country' => 'Samoa',
     767            'country'   => 'Samoa',
    768768            'continent' => 'OC',
    769769        ),
    770770        'SM' => array(
    771             'country' => 'San Marino',
     771            'country'   => 'San Marino',
    772772            'continent' => 'EU',
    773773        ),
    774774        'ST' => array(
    775             'country' => 'Sao Tome and Principe',
     775            'country'   => 'Sao Tome and Principe',
    776776            'continent' => 'AF',
    777777        ),
    778778        'SA' => array(
    779             'country' => 'Saudi Arabia',
     779            'country'   => 'Saudi Arabia',
    780780            'continent' => 'AS',
    781781        ),
    782782        'SN' => array(
    783             'country' => 'Senegal',
     783            'country'   => 'Senegal',
    784784            'continent' => 'AF',
    785785        ),
    786786        'RS' => array(
    787             'country' => 'Serbia',
     787            'country'   => 'Serbia',
    788788            'continent' => 'EU',
    789789        ),
    790790        'SC' => array(
    791             'country' => 'Seychelles',
     791            'country'   => 'Seychelles',
    792792            'continent' => 'AF',
    793793        ),
    794794        'SL' => array(
    795             'country' => 'Sierra Leone',
     795            'country'   => 'Sierra Leone',
    796796            'continent' => 'AF',
    797797        ),
    798798        'SG' => array(
    799             'country' => 'Singapore',
     799            'country'   => 'Singapore',
    800800            'continent' => 'AS',
    801801        ),
    802802        'SK' => array(
    803             'country' => 'Slovakia',
     803            'country'   => 'Slovakia',
    804804            'continent' => 'EU',
    805805        ),
    806806        'SI' => array(
    807             'country' => 'Slovenia',
     807            'country'   => 'Slovenia',
    808808            'continent' => 'EU',
    809809        ),
    810810        'SB' => array(
    811             'country' => 'Solomon Islands',
     811            'country'   => 'Solomon Islands',
    812812            'continent' => 'OC',
    813813        ),
    814814        'SO' => array(
    815             'country' => 'Somalia',
     815            'country'   => 'Somalia',
    816816            'continent' => 'AF',
    817817        ),
    818818        'ZA' => array(
    819             'country' => 'South Africa',
     819            'country'   => 'South Africa',
    820820            'continent' => 'AF',
    821821        ),
    822822        'GS' => array(
    823             'country' => 'South Georgia and The South Sandwich Islands',
     823            'country'   => 'South Georgia and The South Sandwich Islands',
    824824            'continent' => 'AN',
    825825        ),
    826826        'ES' => array(
    827             'country' => 'Spain',
     827            'country'   => 'Spain',
    828828            'continent' => 'EU',
    829829        ),
    830830        'LK' => array(
    831             'country' => 'Sri Lanka',
     831            'country'   => 'Sri Lanka',
    832832            'continent' => 'AS',
    833833        ),
    834834        'SD' => array(
    835             'country' => 'Sudan',
     835            'country'   => 'Sudan',
    836836            'continent' => 'AF',
    837837        ),
    838838        'SR' => array(
    839             'country' => 'Suriname',
     839            'country'   => 'Suriname',
    840840            'continent' => 'SA',
    841841        ),
    842842        'SJ' => array(
    843             'country' => 'Svalbard and Jan Mayen',
     843            'country'   => 'Svalbard and Jan Mayen',
    844844            'continent' => 'EU',
    845845        ),
    846846        'SZ' => array(
    847             'country' => 'Swaziland',
     847            'country'   => 'Swaziland',
    848848            'continent' => 'AF',
    849849        ),
    850850        'SE' => array(
    851             'country' => 'Sweden',
     851            'country'   => 'Sweden',
    852852            'continent' => 'EU',
    853853        ),
    854854        'CH' => array(
    855             'country' => 'Switzerland',
     855            'country'   => 'Switzerland',
    856856            'continent' => 'EU',
    857857        ),
    858858        'SY' => array(
    859             'country' => 'Syrian Arab Republic',
     859            'country'   => 'Syrian Arab Republic',
    860860            'continent' => 'AS',
    861861        ),
    862862        'TW' => array(
    863             'country' => 'Taiwan, Province of China',
     863            'country'   => 'Taiwan, Province of China',
    864864            'continent' => 'AS',
    865865        ),
    866866        'TJ' => array(
    867             'country' => 'Tajikistan',
     867            'country'   => 'Tajikistan',
    868868            'continent' => 'AS',
    869869        ),
    870870        'TZ' => array(
    871             'country' => 'Tanzania, United Republic of',
     871            'country'   => 'Tanzania, United Republic of',
    872872            'continent' => 'AF',
    873873        ),
    874874        'TH' => array(
    875             'country' => 'Thailand',
     875            'country'   => 'Thailand',
    876876            'continent' => 'AS',
    877877        ),
    878878        'TL' => array(
    879             'country' => 'Timor-leste',
     879            'country'   => 'Timor-leste',
    880880            'continent' => 'AS',
    881881        ),
    882882        'TG' => array(
    883             'country' => 'Togo',
     883            'country'   => 'Togo',
    884884            'continent' => 'AF',
    885885        ),
    886886        'TK' => array(
    887             'country' => 'Tokelau',
     887            'country'   => 'Tokelau',
    888888            'continent' => 'OC',
    889889        ),
    890890        'TO' => array(
    891             'country' => 'Tonga',
     891            'country'   => 'Tonga',
    892892            'continent' => 'OC',
    893893        ),
    894894        'TT' => array(
    895             'country' => 'Trinidad and Tobago',
     895            'country'   => 'Trinidad and Tobago',
    896896            'continent' => 'NA',
    897897        ),
    898898        'TN' => array(
    899             'country' => 'Tunisia',
     899            'country'   => 'Tunisia',
    900900            'continent' => 'AF',
    901901        ),
    902902        'TR' => array(
    903             'country' => 'Turkey',
     903            'country'   => 'Turkey',
    904904            'continent' => 'AS',
    905905        ),
    906906        'TM' => array(
    907             'country' => 'Turkmenistan',
     907            'country'   => 'Turkmenistan',
    908908            'continent' => 'AS',
    909909        ),
    910910        'TC' => array(
    911             'country' => 'Turks and Caicos Islands',
     911            'country'   => 'Turks and Caicos Islands',
    912912            'continent' => 'NA',
    913913        ),
    914914        'TV' => array(
    915             'country' => 'Tuvalu',
     915            'country'   => 'Tuvalu',
    916916            'continent' => 'OC',
    917917        ),
    918918        'UG' => array(
    919             'country' => 'Uganda',
     919            'country'   => 'Uganda',
    920920            'continent' => 'AF',
    921921        ),
    922922        'UA' => array(
    923             'country' => 'Ukraine',
     923            'country'   => 'Ukraine',
    924924            'continent' => 'EU',
    925925        ),
    926926        'AE' => array(
    927             'country' => 'United Arab Emirates',
     927            'country'   => 'United Arab Emirates',
    928928            'continent' => 'AS',
    929929        ),
    930930        'GB' => array(
    931             'country' => 'United Kingdom',
     931            'country'   => 'United Kingdom',
    932932            'continent' => 'EU',
    933933        ),
    934934        'US' => array(
    935             'country' => 'United States',
     935            'country'   => 'United States',
    936936            'continent' => 'NA',
    937937        ),
    938938        'UM' => array(
    939             'country' => 'United States Minor Outlying Islands',
     939            'country'   => 'United States Minor Outlying Islands',
    940940            'continent' => 'OC',
    941941        ),
    942942        'UY' => array(
    943             'country' => 'Uruguay',
     943            'country'   => 'Uruguay',
    944944            'continent' => 'SA',
    945945        ),
    946946        'UZ' => array(
    947             'country' => 'Uzbekistan',
     947            'country'   => 'Uzbekistan',
    948948            'continent' => 'AS',
    949949        ),
    950950        'VU' => array(
    951             'country' => 'Vanuatu',
     951            'country'   => 'Vanuatu',
    952952            'continent' => 'OC',
    953953        ),
    954954        'VE' => array(
    955             'country' => 'Venezuela',
     955            'country'   => 'Venezuela',
    956956            'continent' => 'SA',
    957957        ),
    958958        'VN' => array(
    959             'country' => 'Viet Nam',
     959            'country'   => 'Viet Nam',
    960960            'continent' => 'AS',
    961961        ),
    962962        'VG' => array(
    963             'country' => 'Virgin Islands, British',
     963            'country'   => 'Virgin Islands, British',
    964964            'continent' => 'NA',
    965965        ),
    966966        'VI' => array(
    967             'country' => 'Virgin Islands, U.S.',
     967            'country'   => 'Virgin Islands, U.S.',
    968968            'continent' => 'NA',
    969969        ),
    970970        'WF' => array(
    971             'country' => 'Wallis and Futuna',
     971            'country'   => 'Wallis and Futuna',
    972972            'continent' => 'OC',
    973973        ),
    974974        'EH' => array(
    975             'country' => 'Western Sahara',
     975            'country'   => 'Western Sahara',
    976976            'continent' => 'AF',
    977977        ),
    978978        'YE' => array(
    979             'country' => 'Yemen',
     979            'country'   => 'Yemen',
    980980            'continent' => 'AS',
    981981        ),
    982982        'ZM' => array(
    983             'country' => 'Zambia',
     983            'country'   => 'Zambia',
    984984            'continent' => 'AF',
    985985        ),
    986986        'ZW' => array(
    987             'country' => 'Zimbabwe',
     987            'country'   => 'Zimbabwe',
    988988            'continent' => 'AF',
    989989        ),
  • 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 abort
    3     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 */
    66
    7     // This should be our parent div for the notice
    8     var parent = event.path[ 1 ] || null;
     7document.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        }
    914
    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;
    1417
    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        }
    1722
    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  
    11=== WP Engine GeoTarget ===
    22Contributors: wpengine, markkelnar, stevenkword, stephenlin, ryanshoover, taylor4484, nateinaction
    3 Tags: wpe, wpengine, geoip, localization, geolocation
     3Tags: wpe, wpengine, geotarget, geoip, localization, geolocation
    44Requires at least: 3.0.1
    5 Tested up to: 4.9
    6 Stable tag: 1.2.5
     5Tested up to: 5.2
     6Stable tag: 1.2.7
    77
    88License: GPLv2 or later
     
    1515WP 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.
    1616
    17 
    1817= Geo-Marketing =
    1918
     
    3635= * Please Note * =
    3736
    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.
     37Customers 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.
    3938
    4039== Installation ==
     
    7877== Localized Content ==
    7978
    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
    8183The content shortcode allows you to hide or show specific content based on visitor geographies:
    8284
     
    262264== Changelog ==
    263265
     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
    264273= 1.2.5 =
    265274- Fix for anchor tag escaping in admin notice
  • wpengine-geoip/trunk/wpengine-geoip.php

    r1868266 r2171321  
    11<?php
    22/**
    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
    115 *
    126 * @package wpengine-geoip
    137 */
    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 */
    258
    269namespace WPEngine;
     
    3215
    3316/**
    34  * Base class for the GeoTarget plugin, GeoTarget was formerly called GeoIP
     17 * Replace plugin filename in options table
    3518 */
    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' ) );
     19function 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;
    36925        }
    37026    }
    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 );
    76728}
    768 
    769 // Register the GeoTarget plugin instance.
    770 GeoIp::init();
     29replace_previous_plugin_filename();
Note: See TracChangeset for help on using the changeset viewer.