C:\xampp\htdocs\landing\wp-content\plugins\google-analytics-for-wordpress\includes\helpers.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
<?php
/**
 * Helper functions.
 *
 * @since 6.0.0
 *
 * @package MonsterInsights
 * @subpackage Helper
 * @author  Chris Christoff
 */

// Exit if accessed directly
if ( ! defined'ABSPATH' ) ) {
    exit;
}

function 
monsterinsights_is_page_reload() {
    
// Can't be a refresh without having a referrer
    
if ( ! isset( $_SERVER['HTTP_REFERER'] ) ) {
        return 
false;
    }

    
// IF the referrer is identical to the current page request, then it's a refresh
    
return ( parse_url$_SERVER['HTTP_REFERER'], PHP_URL_PATH ) === parse_url$_SERVER['REQUEST_URI'], PHP_URL_PATH ) );
}


function 
monsterinsights_track_user$user_id = -) {
    if ( 
$user_id === -) {
        
$user wp_get_current_user();
    } else {
        
$user = new WP_User$user_id );
    }

    
$track_user  true;
    
$roles     monsterinsights_get_option'ignore_users', array() );

    if ( ! empty( 
$roles ) && is_array$roles ) ) {
        foreach ( 
$roles as $role ) {
            if ( 
is_string$role ) ) {
                if ( 
user_can$user$role ) ) {
                    
$track_user false;
                    break;
                }
            }
        }
    }

    
$track_super_admin apply_filters'monsterinsights_track_super_admins'false );
    if ( 
$user_id === -&& $track_super_admin === false && is_multisite() && is_super_admin() ) {
        
$track_user false;
    }

    
// or if UA code is not entered
    
$ua_code monsterinsights_get_ua();
    if ( empty( 
$ua_code ) ) {
        
$track_user false;
    }

    return 
apply_filters'monsterinsights_track_user'$track_user$user );
}

function 
monsterinsights_get_client_id$payment_id false ) {
    if ( 
is_object$payment_id ) ) {
        
$payment_id $payment_id->ID;
    }
    
$user_cid    monsterinsights_get_uuid();
    
$saved_cid   = ! empty( $payment_id ) ? get_post_meta$payment_id'_yoast_gau_uuid'true ) : false;

    if ( ! empty( 
$payment_id ) && ! empty( $saved_cid ) ) {
        return 
$saved_cid;
    } else if ( ! empty( 
$user_cid ) ) {
        return 
$user_cid;
    } else {
        return 
monsterinsights_generate_uuid();
    }
}

/**
 * Returns the Google Analytics clientId to store for later use
 *
 * @since 6.0.0
 *
 * @link  https://developers.google.com/analytics/devguides/collection/analyticsjs/domains#getClientId
 *
 * @return bool|string False if cookie isn't set, GA UUID otherwise
 */
function monsterinsights_get_uuid() {
    if ( empty( 
$_COOKIE['_ga'] ) ) {
        return 
false;
    }

    
/**
     * Example cookie formats:
     *
     * GA1.2.XXXXXXX.YYYYY
     * _ga=1.2.XXXXXXX.YYYYYY -- We want the XXXXXXX.YYYYYY part
     *
     * for AMP pages the format is sometimes GA1.3.amp-XXXXXXXXXXXXX-XXXXXXXX
     * if the first page visited is AMP, the cookie may be in the format amp-XXXXXXXXXXXXX-XXXXXXXX
     *
     */

    
$ga_cookie    $_COOKIE['_ga'];
    
$cookie_parts explode'.'$ga_cookie );
    if ( 
is_array$cookie_parts ) && ! empty( $cookie_parts[2] ) ) {
        
$cookie_parts array_slice$cookie_parts);
        
$uuid         implode'.'$cookie_parts );
        if ( 
is_string$uuid ) ) {
            return 
$uuid;
        } else {
            return 
false;
        }
    } elseif ( 
=== strpos$ga_cookie'amp-' ) ) {
        return 
$ga_cookie;
    } else {
        return 
false;
    }
}


/**
 * Generate UUID v4 function - needed to generate a CID when one isn't available
 *
 * @link http://www.stumiller.me/implementing-google-analytics-measurement-protocol-in-php-and-wordpress/
 *
 * @since 6.1.8
 * @return string
 */
function monsterinsights_generate_uuid() {

    return 
sprintf'%04x%04x-%04x-%04x-%04x-%04x%04x%04x',

        
// 32 bits for "time_low"
        
mt_rand00xffff ), mt_rand00xffff ),

        
// 16 bits for "time_mid"
        
mt_rand00xffff ),

        
// 16 bits for "time_hi_and_version",
        // four most significant bits holds version number 4
        
mt_rand00x0fff ) | 0x4000,

        
// 16 bits, 8 bits for "clk_seq_hi_res",
        // 8 bits for "clk_seq_low",
        // two most significant bits holds zero and one for variant DCE1.1
        
mt_rand00x3fff ) | 0x8000,

        
// 48 bits for "node"
        
mt_rand00xffff ), mt_rand00xffff ), mt_rand00xffff )
    );
}

/**
 * Returns the Google Analytics clientId to store for later use
 *
 * @since 6.0.0
 *
 * @return GA UUID or error code.
 */
function monsterinsights_get_cookie$debug false ) {
    if ( empty( 
$_COOKIE['_ga'] ) ) {
        return ( 
$debug ) ? 'FCE' false;
    }

    
$ga_cookie    $_COOKIE['_ga'];
    
$cookie_parts explode'.'$ga_cookie );
    if ( 
is_array$cookie_parts ) && ! empty( $cookie_parts[2] ) ) {
        
$cookie_parts array_slice$cookie_parts);
        
$uuid         implode'.'$cookie_parts );
        if ( 
is_string$uuid ) ) {
            return 
$ga_cookie;
        } else {
            return ( 
$debug ) ? 'FA' false;
        }
    } elseif ( 
=== strpos$ga_cookie'amp-' ) ) {
        return 
$ga_cookie;
    } else {
        return ( 
$debug ) ? 'FAE' false;
    }
}


function 
monsterinsights_generate_ga_client_id() {
    return 
rand(100000000,999999999) . '.' time();
}


/**
 * Hours between two timestamps.
 *
 * @access public
 * @since 6.0.0
 *
 * @param string $start Timestamp of start time (in seconds since Unix).
 * @param string $stop  Timestamp of stop time (in seconds since Unix). Optional. If not used, current_time (in UTC 0 / GMT ) is used.
 *
 * @return int Hours between the two timestamps, rounded.
 */
function monsterinsights_hours_between$start$stop false ) {
    if ( 
$stop === false ) {
        
$stop time();
    }

    
$diff = (int) abs$stop -  $start );
    
$hours round$diff HOUR_IN_SECONDS );
    return 
$hours;
}

/**
 * Is This MonsterInsights Pro?
 *
 * We use this function monsterinsights_to determine if the install is a pro version or a lite version install of MonsterInsights.
 * If the install is a lite version we disable the install from admin functionality[1] for addons as WordPress.org requires us to,
 * we change the links for where to get support (wp.org forum for free; our site for pro), we use this determine what class to load as
 * the base class in addons (to avoid fatal errors) and we use this on the system info page to know what constants to display values for
 * as the lite and pro versions of our plugin have different constants (and names for those constants) you can declare and use.
 *
 * [1] Note: This is not "feature-locking" under GPL guidelines but rather something WordPress.org requires us to do to stay
 * in compliance with their rules. We wish we didn't have to do this, as in our oppinion this diminishes the user experience
 * of users installing our free and premium addons, and we'd love to turn this on for non-Pro installs, but we're not allowed to.
 * If WordPress.org ever changes their mind on this subject, we'd totally turn on that feature for Lite installs in a heartbeat.
 *
 * @todo  Are we allowed to turn on admin installing if the user has to manually declare a PHP constant (and thus would not be on
 * either by default or via any sort of user interface)? If so, we could add a constant for forcing Pro version so that users can see
 * for themselves that we're not feature locking anything inside the plugin + it would make it easier for our team to test stuff (both via
 * Travis-CI but also when installing addons to test with the Lite version). Also this would allow for a better user experience for users
 * who want that feature.
 *
 * @since 6.0.0
 * @access public
 *
 * @return bool True if pro version.
 */
function monsterinsights_is_pro_version() {
    if ( 
class_exists'MonsterInsights' ) ) {
        return 
true;
    } else {
        return 
false;
    }
}


/**
 * Get the user roles of this WordPress blog
 *
 * @return array
 */
function monsterinsights_get_roles() {
    global 
$wp_roles;

    
$all_roles $wp_roles->roles;
    
$roles     = array();

    
/**
     * Filter: 'editable_roles' - Allows filtering of the roles shown within the plugin (and elsewhere in WP as it's a WP filter)
     *
     * @api array $all_roles
     */
    
$editable_roles apply_filters'editable_roles'$all_roles );

    foreach ( 
$editable_roles as $id => $name ) {
        
$roles$id ] = translate_user_role$name['name'] );
    }

    return 
$roles;
}

/**
 * Get the user roles which can manage options. Used to prevent these roles from getting unselected in the settings.
 *
 * @return array
 */
function monsterinsights_get_manage_options_roles() {
    global 
$wp_roles;

    
$all_roles $wp_roles->roles;
    
$roles     = array();

    
/**
     * Filter: 'editable_roles' - Allows filtering of the roles shown within the plugin (and elsewhere in WP as it's a WP filter)
     *
     * @api array $all_roles
     */
    
$editable_roles apply_filters'editable_roles'$all_roles );

    foreach ( 
$editable_roles as $id => $role ) {
        if ( isset( 
$role['capabilities']['manage_options'] ) && $role['capabilities']['manage_options'] ) {
            
$roles$id ] = translate_user_role$role['name'] );
        }
    }

    return 
$roles;
}

/** Need to escape in advance of passing in $text. */
function monsterinsights_get_message$type 'error'$text '' ) {
    
$div '';
    if ( 
$type === 'error' || $type === 'alert' || $type === 'success' || $type === 'info' ) {
        
$base MonsterInsights();
        return 
$base->notices->display_inline_notice'monsterinsights_standard_notice'''$text$typefalse, array( 'skip_message_escape' => true ) );
    } else {
        return 
'';
    }
}

function 
monsterinsights_is_dev_url$url '' ) {
    
$is_local_url false;
    
// Trim it up
    
$url strtolowertrim$url ) );
    
// Need to get the host...so let's add the scheme so we can use parse_url
    
if ( false === strpos$url'http://' ) && false === strpos$url'https://' ) ) {
        
$url 'http://' $url;
    }
    
$url_parts parse_url$url );
    
$host      = ! empty( $url_parts['host'] ) ? $url_parts['host'] : false;
    if ( ! empty( 
$url ) && ! empty( $host ) ) {
        if ( 
false !== ip2long$host ) ) {
            if ( ! 
filter_var$hostFILTER_VALIDATE_IPFILTER_FLAG_NO_PRIV_RANGE FILTER_FLAG_NO_RES_RANGE ) ) {
                
$is_local_url true;
            }
        } else if ( 
'localhost' === $host ) {
            
$is_local_url true;
        }

        
$tlds_to_check = array( '.local'':8888'':8080'':8081''.invalid''.example''.test' );
        foreach ( 
$tlds_to_check as $tld ) {
            if ( 
false !== strpos$host$tld ) ) {
                
$is_local_url true;
                break;
            }

        }
        if ( 
substr_count$host'.' ) > ) {
            
$subdomains_to_check =  array( 'dev.''*.staging.''beta.''test.' );
            foreach ( 
$subdomains_to_check as $subdomain ) {
                
$subdomain str_replace'.''(.)'$subdomain );
                
$subdomain str_replace( array( '*''(.)' ), '(.*)'$subdomain );
                if ( 
preg_match'/^(' $subdomain ')/'$host ) ) {
                    
$is_local_url true;
                    break;
                }
            }
        }
    }
    return 
$is_local_url;
}

// Set cookie to expire in 2 years
function monsterinsights_get_cookie_expiration_date$time ) {
    return 
date('D, j F Y H:i:s'time() + $time );
}

function 
monsterinsights_string_ends_with$string$ending ) {
    
$strlen strlen($string);
    
$endinglen strlen($ending);
    if ( 
$endinglen $strlen ) {
        return 
false;
    }
    return 
substr_compare$string$ending$strlen $endinglen$endinglen) === 0;
}

function 
monsterinsights_string_starts_with$string$start ) {
    if ( ! 
is_string$string ) || ! is_string$start ) ) {
        return 
false;
    }

    return 
substr$string0strlen$start ) ) === $start;
}

function 
monsterinsights_get_country_list$translated false ) {
    if ( 
$translated ) {
        
$countries = array(
            
''   => '',
            
'US' => __'United States''google-analytics-for-wordpress' ),
            
'CA' => __'Canada''google-analytics-for-wordpress' ),
            
'GB' => __'United Kingdom''google-analytics-for-wordpress' ),
            
'AF' => __'Afghanistan''google-analytics-for-wordpress' ),
            
'AX' => __'&#197;land Islands''google-analytics-for-wordpress' ),
            
'AL' => __'Albania''google-analytics-for-wordpress' ),
            
'DZ' => __'Algeria''google-analytics-for-wordpress' ),
            
'AS' => __'American Samoa''google-analytics-for-wordpress' ),
            
'AD' => __'Andorra''google-analytics-for-wordpress' ),
            
'AO' => __'Angola''google-analytics-for-wordpress' ),
            
'AI' => __'Anguilla''google-analytics-for-wordpress' ),
            
'AQ' => __'Antarctica''google-analytics-for-wordpress' ),
            
'AG' => __'Antigua and Barbuda''google-analytics-for-wordpress' ),
            
'AR' => __'Argentina''google-analytics-for-wordpress' ),
            
'AM' => __'Armenia''google-analytics-for-wordpress' ),
            
'AW' => __'Aruba''google-analytics-for-wordpress' ),
            
'AU' => __'Australia''google-analytics-for-wordpress' ),
            
'AT' => __'Austria''google-analytics-for-wordpress' ),
            
'AZ' => __'Azerbaijan''google-analytics-for-wordpress' ),
            
'BS' => __'Bahamas''google-analytics-for-wordpress' ),
            
'BH' => __'Bahrain''google-analytics-for-wordpress' ),
            
'BD' => __'Bangladesh''google-analytics-for-wordpress' ),
            
'BB' => __'Barbados''google-analytics-for-wordpress' ),
            
'BY' => __'Belarus''google-analytics-for-wordpress' ),
            
'BE' => __'Belgium''google-analytics-for-wordpress' ),
            
'BZ' => __'Belize''google-analytics-for-wordpress' ),
            
'BJ' => __'Benin''google-analytics-for-wordpress' ),
            
'BM' => __'Bermuda''google-analytics-for-wordpress' ),
            
'BT' => __'Bhutan''google-analytics-for-wordpress' ),
            
'BO' => __'Bolivia''google-analytics-for-wordpress' ),
            
'BQ' => __'Bonaire, Saint Eustatius and Saba''google-analytics-for-wordpress' ),
            
'BA' => __'Bosnia and Herzegovina''google-analytics-for-wordpress' ),
            
'BW' => __'Botswana''google-analytics-for-wordpress' ),
            
'BV' => __'Bouvet Island''google-analytics-for-wordpress' ),
            
'BR' => __'Brazil''google-analytics-for-wordpress' ),
            
'IO' => __'British Indian Ocean Territory''google-analytics-for-wordpress' ),
            
'BN' => __'Brunei Darrussalam''google-analytics-for-wordpress' ),
            
'BG' => __'Bulgaria''google-analytics-for-wordpress' ),
            
'BF' => __'Burkina Faso''google-analytics-for-wordpress' ),
            
'BI' => __'Burundi''google-analytics-for-wordpress' ),
            
'KH' => __'Cambodia''google-analytics-for-wordpress' ),
            
'CM' => __'Cameroon''google-analytics-for-wordpress' ),
            
'CV' => __'Cape Verde''google-analytics-for-wordpress' ),
            
'KY' => __'Cayman Islands''google-analytics-for-wordpress' ),
            
'CF' => __'Central African Republic''google-analytics-for-wordpress' ),
            
'TD' => __'Chad''google-analytics-for-wordpress' ),
            
'CL' => __'Chile''google-analytics-for-wordpress' ),
            
'CN' => __'China''google-analytics-for-wordpress' ),
            
'CX' => __'Christmas Island''google-analytics-for-wordpress' ),
            
'CC' => __'Cocos Islands''google-analytics-for-wordpress' ),
            
'CO' => __'Colombia''google-analytics-for-wordpress' ),
            
'KM' => __'Comoros''google-analytics-for-wordpress' ),
            
'CD' => __'Congo, Democratic People\'s Republic''google-analytics-for-wordpress' ),
            
'CG' => __'Congo, Republic of''google-analytics-for-wordpress' ),
            
'CK' => __'Cook Islands''google-analytics-for-wordpress' ),
            
'CR' => __'Costa Rica''google-analytics-for-wordpress' ),
            
'CI' => __'Cote d\'Ivoire''google-analytics-for-wordpress' ),
            
'HR' => __'Croatia/Hrvatska''google-analytics-for-wordpress' ),
            
'CU' => __'Cuba''google-analytics-for-wordpress' ),
            
'CW' => __'Cura&Ccedil;ao''google-analytics-for-wordpress' ),
            
'CY' => __'Cyprus''google-analytics-for-wordpress' ),
            
'CZ' => __'Czechia''google-analytics-for-wordpress' ),
            
'DK' => __'Denmark''google-analytics-for-wordpress' ),
            
'DJ' => __'Djibouti''google-analytics-for-wordpress' ),
            
'DM' => __'Dominica''google-analytics-for-wordpress' ),
            
'DO' => __'Dominican Republic''google-analytics-for-wordpress' ),
            
'TP' => __'East Timor''google-analytics-for-wordpress' ),
            
'EC' => __'Ecuador''google-analytics-for-wordpress' ),
            
'EG' => __'Egypt''google-analytics-for-wordpress' ),
            
'GQ' => __'Equatorial Guinea''google-analytics-for-wordpress' ),
            
'SV' => __'El Salvador''google-analytics-for-wordpress' ),
            
'ER' => __'Eritrea''google-analytics-for-wordpress' ),
            
'EE' => __'Estonia''google-analytics-for-wordpress' ),
            
'ET' => __'Ethiopia''google-analytics-for-wordpress' ),
            
'FK' => __'Falkland Islands''google-analytics-for-wordpress' ),
            
'FO' => __'Faroe Islands''google-analytics-for-wordpress' ),
            
'FJ' => __'Fiji''google-analytics-for-wordpress' ),
            
'FI' => __'Finland''google-analytics-for-wordpress' ),
            
'FR' => __'France''google-analytics-for-wordpress' ),
            
'GF' => __'French Guiana''google-analytics-for-wordpress' ),
            
'PF' => __'French Polynesia''google-analytics-for-wordpress' ),
            
'TF' => __'French Southern Territories''google-analytics-for-wordpress' ),
            
'GA' => __'Gabon''google-analytics-for-wordpress' ),
            
'GM' => __'Gambia''google-analytics-for-wordpress' ),
            
'GE' => __'Georgia''google-analytics-for-wordpress' ),
            
'DE' => __'Germany''google-analytics-for-wordpress' ),
            
'GR' => __'Greece''google-analytics-for-wordpress' ),
            
'GH' => __'Ghana''google-analytics-for-wordpress' ),
            
'GI' => __'Gibraltar''google-analytics-for-wordpress' ),
            
'GL' => __'Greenland''google-analytics-for-wordpress' ),
            
'GD' => __'Grenada''google-analytics-for-wordpress' ),
            
'GP' => __'Guadeloupe''google-analytics-for-wordpress' ),
            
'GU' => __'Guam''google-analytics-for-wordpress' ),
            
'GT' => __'Guatemala''google-analytics-for-wordpress' ),
            
'GG' => __'Guernsey''google-analytics-for-wordpress' ),
            
'GN' => __'Guinea''google-analytics-for-wordpress' ),
            
'GW' => __'Guinea-Bissau''google-analytics-for-wordpress' ),
            
'GY' => __'Guyana''google-analytics-for-wordpress' ),
            
'HT' => __'Haiti''google-analytics-for-wordpress' ),
            
'HM' => __'Heard and McDonald Islands''google-analytics-for-wordpress' ),
            
'VA' => __'Holy See (City Vatican State)''google-analytics-for-wordpress' ),
            
'HN' => __'Honduras''google-analytics-for-wordpress' ),
            
'HK' => __'Hong Kong''google-analytics-for-wordpress' ),
            
'HU' => __'Hungary''google-analytics-for-wordpress' ),
            
'IS' => __'Iceland''google-analytics-for-wordpress' ),
            
'IN' => __'India''google-analytics-for-wordpress' ),
            
'ID' => __'Indonesia''google-analytics-for-wordpress' ),
            
'IR' => __'Iran''google-analytics-for-wordpress' ),
            
'IQ' => __'Iraq''google-analytics-for-wordpress' ),
            
'IE' => __'Ireland''google-analytics-for-wordpress' ),
            
'IM' => __'Isle of Man''google-analytics-for-wordpress' ),
            
'IL' => __'Israel''google-analytics-for-wordpress' ),
            
'IT' => __'Italy''google-analytics-for-wordpress' ),
            
'JM' => __'Jamaica''google-analytics-for-wordpress' ),
            
'JP' => __'Japan''google-analytics-for-wordpress' ),
            
'JE' => __'Jersey''google-analytics-for-wordpress' ),
            
'JO' => __'Jordan''google-analytics-for-wordpress' ),
            
'KZ' => __'Kazakhstan''google-analytics-for-wordpress' ),
            
'KE' => __'Kenya''google-analytics-for-wordpress' ),
            
'KI' => __'Kiribati''google-analytics-for-wordpress' ),
            
'KW' => __'Kuwait''google-analytics-for-wordpress' ),
            
'KG' => __'Kyrgyzstan''google-analytics-for-wordpress' ),
            
'LA' => __'Lao People\'s Democratic Republic''google-analytics-for-wordpress' ),
            
'LV' => __'Latvia''google-analytics-for-wordpress' ),
            
'LB' => __'Lebanon''google-analytics-for-wordpress' ),
            
'LS' => __'Lesotho''google-analytics-for-wordpress' ),
            
'LR' => __'Liberia''google-analytics-for-wordpress' ),
            
'LY' => __'Libyan Arab Jamahiriya''google-analytics-for-wordpress' ),
            
'LI' => __'Liechtenstein''google-analytics-for-wordpress' ),
            
'LT' => __'Lithuania''google-analytics-for-wordpress' ),
            
'LU' => __'Luxembourg''google-analytics-for-wordpress' ),
            
'MO' => __'Macau''google-analytics-for-wordpress' ),
            
'MK' => __'Macedonia (FYROM)''google-analytics-for-wordpress' ),
            
'MG' => __'Madagascar''google-analytics-for-wordpress' ),
            
'MW' => __'Malawi''google-analytics-for-wordpress' ),
            
'MY' => __'Malaysia''google-analytics-for-wordpress' ),
            
'MV' => __'Maldives''google-analytics-for-wordpress' ),
            
'ML' => __'Mali''google-analytics-for-wordpress' ),
            
'MT' => __'Malta''google-analytics-for-wordpress' ),
            
'MH' => __'Marshall Islands''google-analytics-for-wordpress' ),
            
'MQ' => __'Martinique''google-analytics-for-wordpress' ),
            
'MR' => __'Mauritania''google-analytics-for-wordpress' ),
            
'MU' => __'Mauritius''google-analytics-for-wordpress' ),
            
'YT' => __'Mayotte''google-analytics-for-wordpress' ),
            
'MX' => __'Mexico''google-analytics-for-wordpress' ),
            
'FM' => __'Micronesia''google-analytics-for-wordpress' ),
            
'MD' => __'Moldova, Republic of''google-analytics-for-wordpress' ),
            
'MC' => __'Monaco''google-analytics-for-wordpress' ),
            
'MN' => __'Mongolia''google-analytics-for-wordpress' ),
            
'ME' => __'Montenegro''google-analytics-for-wordpress' ),
            
'MS' => __'Montserrat''google-analytics-for-wordpress' ),
            
'MA' => __'Morocco''google-analytics-for-wordpress' ),
            
'MZ' => __'Mozambique''google-analytics-for-wordpress' ),
            
'MM' => __'Myanmar''google-analytics-for-wordpress' ),
            
'NA' => __'Namibia''google-analytics-for-wordpress' ),
            
'NR' => __'Nauru''google-analytics-for-wordpress' ),
            
'NP' => __'Nepal''google-analytics-for-wordpress' ),
            
'NL' => __'Netherlands''google-analytics-for-wordpress' ),
            
'AN' => __'Netherlands Antilles''google-analytics-for-wordpress' ),
            
'NC' => __'New Caledonia''google-analytics-for-wordpress' ),
            
'NZ' => __'New Zealand''google-analytics-for-wordpress' ),
            
'NI' => __'Nicaragua''google-analytics-for-wordpress' ),
            
'NE' => __'Niger''google-analytics-for-wordpress' ),
            
'NG' => __'Nigeria''google-analytics-for-wordpress' ),
            
'NU' => __'Niue''google-analytics-for-wordpress' ),
            
'NF' => __'Norfolk Island''google-analytics-for-wordpress' ),
            
'KP' => __'North Korea''google-analytics-for-wordpress' ),
            
'MP' => __'Northern Mariana Islands''google-analytics-for-wordpress' ),
            
'NO' => __'Norway''google-analytics-for-wordpress' ),
            
'OM' => __'Oman''google-analytics-for-wordpress' ),
            
'PK' => __'Pakistan''google-analytics-for-wordpress' ),
            
'PW' => __'Palau''google-analytics-for-wordpress' ),
            
'PS' => __'Palestinian Territories''google-analytics-for-wordpress' ),
            
'PA' => __'Panama''google-analytics-for-wordpress' ),
            
'PG' => __'Papua New Guinea''google-analytics-for-wordpress' ),
            
'PY' => __'Paraguay''google-analytics-for-wordpress' ),
            
'PE' => __'Peru''google-analytics-for-wordpress' ),
            
'PH' => __'Philippines''google-analytics-for-wordpress' ),
            
'PN' => __'Pitcairn Island''google-analytics-for-wordpress' ),
            
'PL' => __'Poland''google-analytics-for-wordpress' ),
            
'PT' => __'Portugal''google-analytics-for-wordpress' ),
            
'PR' => __'Puerto Rico''google-analytics-for-wordpress' ),
            
'QA' => __'Qatar''google-analytics-for-wordpress' ),
            
'XK' => __'Republic of Kosovo''google-analytics-for-wordpress' ),
            
'RE' => __'Reunion Island''google-analytics-for-wordpress' ),
            
'RO' => __'Romania''google-analytics-for-wordpress' ),
            
'RU' => __'Russian Federation''google-analytics-for-wordpress' ),
            
'RW' => __'Rwanda''google-analytics-for-wordpress' ),
            
'BL' => __'Saint Barth&eacute;lemy''google-analytics-for-wordpress' ),
            
'SH' => __'Saint Helena''google-analytics-for-wordpress' ),
            
'KN' => __'Saint Kitts and Nevis''google-analytics-for-wordpress' ),
            
'LC' => __'Saint Lucia''google-analytics-for-wordpress' ),
            
'MF' => __'Saint Martin (French)''google-analytics-for-wordpress' ),
            
'SX' => __'Saint Martin (Dutch)''google-analytics-for-wordpress' ),
            
'PM' => __'Saint Pierre and Miquelon''google-analytics-for-wordpress' ),
            
'VC' => __'Saint Vincent and the Grenadines''google-analytics-for-wordpress' ),
            
'SM' => __'San Marino''google-analytics-for-wordpress' ),
            
'ST' => __'S&atilde;o Tom&eacute; and Pr&iacute;ncipe''google-analytics-for-wordpress' ),
            
'SA' => __'Saudi Arabia''google-analytics-for-wordpress' ),
            
'SN' => __'Senegal''google-analytics-for-wordpress' ),
            
'RS' => __'Serbia''google-analytics-for-wordpress' ),
            
'SC' => __'Seychelles''google-analytics-for-wordpress' ),
            
'SL' => __'Sierra Leone''google-analytics-for-wordpress' ),
            
'SG' => __'Singapore''google-analytics-for-wordpress' ),
            
'SK' => __'Slovak Republic''google-analytics-for-wordpress' ),
            
'SI' => __'Slovenia''google-analytics-for-wordpress' ),
            
'SB' => __'Solomon Islands''google-analytics-for-wordpress' ),
            
'SO' => __'Somalia''google-analytics-for-wordpress' ),
            
'ZA' => __'South Africa''google-analytics-for-wordpress' ),
            
'GS' => __'South Georgia''google-analytics-for-wordpress' ),
            
'KR' => __'South Korea''google-analytics-for-wordpress' ),
            
'SS' => __'South Sudan''google-analytics-for-wordpress' ),
            
'ES' => __'Spain''google-analytics-for-wordpress' ),
            
'LK' => __'Sri Lanka''google-analytics-for-wordpress' ),
            
'SD' => __'Sudan''google-analytics-for-wordpress' ),
            
'SR' => __'Suriname''google-analytics-for-wordpress' ),
            
'SJ' => __'Svalbard and Jan Mayen Islands''google-analytics-for-wordpress' ),
            
'SZ' => __'Swaziland''google-analytics-for-wordpress' ),
            
'SE' => __'Sweden''google-analytics-for-wordpress' ),
            
'CH' => __'Switzerland''google-analytics-for-wordpress' ),
            
'SY' => __'Syrian Arab Republic''google-analytics-for-wordpress' ),
            
'TW' => __'Taiwan''google-analytics-for-wordpress' ),
            
'TJ' => __'Tajikistan''google-analytics-for-wordpress' ),
            
'TZ' => __'Tanzania''google-analytics-for-wordpress' ),
            
'TH' => __'Thailand''google-analytics-for-wordpress' ),
            
'TL' => __'Timor-Leste''google-analytics-for-wordpress' ),
            
'TG' => __'Togo''google-analytics-for-wordpress' ),
            
'TK' => __'Tokelau''google-analytics-for-wordpress' ),
            
'TO' => __'Tonga''google-analytics-for-wordpress' ),
            
'TT' => __'Trinidad and Tobago''google-analytics-for-wordpress' ),
            
'TN' => __'Tunisia''google-analytics-for-wordpress' ),
            
'TR' => __'Turkey''google-analytics-for-wordpress' ),
            
'TM' => __'Turkmenistan''google-analytics-for-wordpress' ),
            
'TC' => __'Turks and Caicos Islands''google-analytics-for-wordpress' ),
            
'TV' => __'Tuvalu''google-analytics-for-wordpress' ),
            
'UG' => __'Uganda''google-analytics-for-wordpress' ),
            
'UA' => __'Ukraine''google-analytics-for-wordpress' ),
            
'AE' => __'United Arab Emirates''google-analytics-for-wordpress' ),
            
'UY' => __'Uruguay''google-analytics-for-wordpress' ),
            
'UM' => __'US Minor Outlying Islands''google-analytics-for-wordpress' ),
            
'UZ' => __'Uzbekistan''google-analytics-for-wordpress' ),
            
'VU' => __'Vanuatu''google-analytics-for-wordpress' ),
            
'VE' => __'Venezuela''google-analytics-for-wordpress' ),
            
'VN' => __'Vietnam''google-analytics-for-wordpress' ),
            
'VG' => __'Virgin Islands (British)''google-analytics-for-wordpress' ),
            
'VI' => __'Virgin Islands (USA)''google-analytics-for-wordpress' ),
            
'WF' => __'Wallis and Futuna Islands''google-analytics-for-wordpress' ),
            
'EH' => __'Western Sahara''google-analytics-for-wordpress' ),
            
'WS' => __'Western Samoa''google-analytics-for-wordpress' ),
            
'YE' => __'Yemen''google-analytics-for-wordpress' ),
            
'ZM' => __'Zambia''google-analytics-for-wordpress' ),
            
'ZW' => __'Zimbabwe''google-analytics-for-wordpress' ),
            
'ZZ' => __'Unknown Country''google-analytics-for-wordpress' ),
        );
    } else {
        
$countries = array(
            
''   => '',
            
'US' => 'United States',
            
'CA' => 'Canada',
            
'GB' => 'United Kingdom',
            
'AF' => 'Afghanistan',
            
'AX' => '&#197;land Islands',
            
'AL' => 'Albania',
            
'DZ' => 'Algeria',
            
'AS' => 'American Samoa',
            
'AD' => 'Andorra',
            
'AO' => 'Angola',
            
'AI' => 'Anguilla',
            
'AQ' => 'Antarctica',
            
'AG' => 'Antigua and Barbuda',
            
'AR' => 'Argentina',
            
'AM' => 'Armenia',
            
'AW' => 'Aruba',
            
'AU' => 'Australia',
            
'AT' => 'Austria',
            
'AZ' => 'Azerbaijan',
            
'BS' => 'Bahamas',
            
'BH' => 'Bahrain',
            
'BD' => 'Bangladesh',
            
'BB' => 'Barbados',
            
'BY' => 'Belarus',
            
'BE' => 'Belgium',
            
'BZ' => 'Belize',
            
'BJ' => 'Benin',
            
'BM' => 'Bermuda',
            
'BT' => 'Bhutan',
            
'BO' => 'Bolivia',
            
'BQ' => 'Bonaire, Saint Eustatius and Saba',
            
'BA' => 'Bosnia and Herzegovina',
            
'BW' => 'Botswana',
            
'BV' => 'Bouvet Island',
            
'BR' => 'Brazil',
            
'IO' => 'British Indian Ocean Territory',
            
'BN' => 'Brunei Darrussalam',
            
'BG' => 'Bulgaria',
            
'BF' => 'Burkina Faso',
            
'BI' => 'Burundi',
            
'KH' => 'Cambodia',
            
'CM' => 'Cameroon',
            
'CV' => 'Cape Verde',
            
'KY' => 'Cayman Islands',
            
'CF' => 'Central African Republic',
            
'TD' => 'Chad',
            
'CL' => 'Chile',
            
'CN' => 'China',
            
'CX' => 'Christmas Island',
            
'CC' => 'Cocos Islands',
            
'CO' => 'Colombia',
            
'KM' => 'Comoros',
            
'CD' => 'Congo, Democratic People\'s Republic',
            
'CG' => 'Congo, Republic of',
            
'CK' => 'Cook Islands',
            
'CR' => 'Costa Rica',
            
'CI' => 'Cote d\'Ivoire',
            
'HR' => 'Croatia/Hrvatska',
            
'CU' => 'Cuba',
            
'CW' => 'Cura&Ccedil;ao',
            
'CY' => 'Cyprus',
            
'CZ' => 'Czechia',
            
'DK' => 'Denmark',
            
'DJ' => 'Djibouti',
            
'DM' => 'Dominica',
            
'DO' => 'Dominican Republic',
            
'TP' => 'East Timor',
            
'EC' => 'Ecuador',
            
'EG' => 'Egypt',
            
'GQ' => 'Equatorial Guinea',
            
'SV' => 'El Salvador',
            
'ER' => 'Eritrea',
            
'EE' => 'Estonia',
            
'ET' => 'Ethiopia',
            
'FK' => 'Falkland Islands',
            
'FO' => 'Faroe Islands',
            
'FJ' => 'Fiji',
            
'FI' => 'Finland',
            
'FR' => 'France',
            
'GF' => 'French Guiana',
            
'PF' => 'French Polynesia',
            
'TF' => 'French Southern Territories',
            
'GA' => 'Gabon',
            
'GM' => 'Gambia',
            
'GE' => 'Georgia',
            
'DE' => 'Germany',
            
'GR' => 'Greece',
            
'GH' => 'Ghana',
            
'GI' => 'Gibraltar',
            
'GL' => 'Greenland',
            
'GD' => 'Grenada',
            
'GP' => 'Guadeloupe',
            
'GU' => 'Guam',
            
'GT' => 'Guatemala',
            
'GG' => 'Guernsey',
            
'GN' => 'Guinea',
            
'GW' => 'Guinea-Bissau',
            
'GY' => 'Guyana',
            
'HT' => 'Haiti',
            
'HM' => 'Heard and McDonald Islands',
            
'VA' => 'Holy See (City Vatican State)',
            
'HN' => 'Honduras',
            
'HK' => 'Hong Kong',
            
'HU' => 'Hungary',
            
'IS' => 'Iceland',
            
'IN' => 'India',
            
'ID' => 'Indonesia',
            
'IR' => 'Iran',
            
'IQ' => 'Iraq',
            
'IE' => 'Ireland',
            
'IM' => 'Isle of Man',
            
'IL' => 'Israel',
            
'IT' => 'Italy',
            
'JM' => 'Jamaica',
            
'JP' => 'Japan',
            
'JE' => 'Jersey',
            
'JO' => 'Jordan',
            
'KZ' => 'Kazakhstan',
            
'KE' => 'Kenya',
            
'KI' => 'Kiribati',
            
'KW' => 'Kuwait',
            
'KG' => 'Kyrgyzstan',
            
'LA' => 'Lao People\'s Democratic Republic',
            
'LV' => 'Latvia',
            
'LB' => 'Lebanon',
            
'LS' => 'Lesotho',
            
'LR' => 'Liberia',
            
'LY' => 'Libyan Arab Jamahiriya',
            
'LI' => 'Liechtenstein',
            
'LT' => 'Lithuania',
            
'LU' => 'Luxembourg',
            
'MO' => 'Macau',
            
'MK' => 'Macedonia',
            
'MG' => 'Madagascar',
            
'MW' => 'Malawi',
            
'MY' => 'Malaysia',
            
'MV' => 'Maldives',
            
'ML' => 'Mali',
            
'MT' => 'Malta',
            
'MH' => 'Marshall Islands',
            
'MQ' => 'Martinique',
            
'MR' => 'Mauritania',
            
'MU' => 'Mauritius',
            
'YT' => 'Mayotte',
            
'MX' => 'Mexico',
            
'FM' => 'Micronesia',
            
'MD' => 'Moldova, Republic of',
            
'MC' => 'Monaco',
            
'MN' => 'Mongolia',
            
'ME' => 'Montenegro',
            
'MS' => 'Montserrat',
            
'MA' => 'Morocco',
            
'MZ' => 'Mozambique',
            
'MM' => 'Myanmar (Burma)',
            
'NA' => 'Namibia',
            
'NR' => 'Nauru',
            
'NP' => 'Nepal',
            
'NL' => 'Netherlands',
            
'AN' => 'Netherlands Antilles',
            
'NC' => 'New Caledonia',
            
'NZ' => 'New Zealand',
            
'NI' => 'Nicaragua',
            
'NE' => 'Niger',
            
'NG' => 'Nigeria',
            
'NU' => 'Niue',
            
'NF' => 'Norfolk Island',
            
'KP' => 'North Korea',
            
'MP' => 'Northern Mariana Islands',
            
'NO' => 'Norway',
            
'OM' => 'Oman',
            
'PK' => 'Pakistan',
            
'PW' => 'Palau',
            
'PS' => 'Palestinian Territories',
            
'PA' => 'Panama',
            
'PG' => 'Papua New Guinea',
            
'PY' => 'Paraguay',
            
'PE' => 'Peru',
            
'PH' => 'Philippines',
            
'PN' => 'Pitcairn Island',
            
'PL' => 'Poland',
            
'PT' => 'Portugal',
            
'PR' => 'Puerto Rico',
            
'QA' => 'Qatar',
            
'XK' => 'Republic of Kosovo',
            
'RE' => 'Reunion Island',
            
'RO' => 'Romania',
            
'RU' => 'Russia',
            
'RW' => 'Rwanda',
            
'BL' => 'Saint Barth&eacute;lemy',
            
'SH' => 'Saint Helena',
            
'KN' => 'Saint Kitts and Nevis',
            
'LC' => 'Saint Lucia',
            
'MF' => 'Saint Martin (French)',
            
'SX' => 'Saint Martin (Dutch)',
            
'PM' => 'Saint Pierre and Miquelon',
            
'VC' => 'Saint Vincent and the Grenadines',
            
'SM' => 'San Marino',
            
'ST' => 'S&atilde;o Tom&eacute; and Pr&iacute;ncipe',
            
'SA' => 'Saudi Arabia',
            
'SN' => 'Senegal',
            
'RS' => 'Serbia',
            
'SC' => 'Seychelles',
            
'SL' => 'Sierra Leone',
            
'SG' => 'Singapore',
            
'SK' => 'Slovak Republic',
            
'SI' => 'Slovenia',
            
'SB' => 'Solomon Islands',
            
'SO' => 'Somalia',
            
'ZA' => 'South Africa',
            
'GS' => 'South Georgia',
            
'KR' => 'South Korea',
            
'SS' => 'South Sudan',
            
'ES' => 'Spain',
            
'LK' => 'Sri Lanka',
            
'SD' => 'Sudan',
            
'SR' => 'Suriname',
            
'SJ' => 'Svalbard and Jan Mayen Islands',
            
'SZ' => 'Swaziland',
            
'SE' => 'Sweden',
            
'CH' => 'Switzerland',
            
'SY' => 'Syrian Arab Republic',
            
'TW' => 'Taiwan',
            
'TJ' => 'Tajikistan',
            
'TZ' => 'Tanzania',
            
'TH' => 'Thailand',
            
'TL' => 'Timor-Leste',
            
'TG' => 'Togo',
            
'TK' => 'Tokelau',
            
'TO' => 'Tonga',
            
'TT' => 'Trinidad and Tobago',
            
'TN' => 'Tunisia',
            
'TR' => 'Turkey',
            
'TM' => 'Turkmenistan',
            
'TC' => 'Turks and Caicos Islands',
            
'TV' => 'Tuvalu',
            
'UG' => 'Uganda',
            
'UA' => 'Ukraine',
            
'AE' => 'United Arab Emirates',
            
'UY' => 'Uruguay',
            
'UM' => 'US Minor Outlying Islands',
            
'UZ' => 'Uzbekistan',
            
'VU' => 'Vanuatu',
            
'VE' => 'Venezuela',
            
'VN' => 'Vietnam',
            
'VG' => 'Virgin Islands (British)',
            
'VI' => 'Virgin Islands (USA)',
            
'WF' => 'Wallis and Futuna Islands',
            
'EH' => 'Western Sahara',
            
'WS' => 'Western Samoa',
            
'YE' => 'Yemen',
            
'ZM' => 'Zambia',
            
'ZW' => 'Zimbabwe',
            
'ZZ' => 'Unknown Country',
        );
    }
    return 
$countries;
}

function 
monsterinsights_get_api_url(){
    return 
apply_filters'monsterinsights_get_api_url''api.monsterinsights.com/v2/' );
}

function 
monsterinsights_get_licensing_url(){
    return 
apply_filters'monsterinsights_get_licensing_url''https://www.monsterinsights.com' );
}

function 
monsterinsights_is_wp_seo_active( ) {
    
$wp_seo_active false// @todo: improve this check. This is from old Yoast code.

    // Makes sure is_plugin_active is available when called from front end
    
include_once( ABSPATH 'wp-admin/includes/plugin.php' );
    if ( 
is_plugin_active'wordpress-seo/wp-seo.php' ) || is_plugin_active'wordpress-seo-premium/wp-seo-premium.php' ) ) {
        
$wp_seo_active true;
    }
    return 
$wp_seo_active;
}

function 
monsterinsights_get_asset_version() {
    if ( 
monsterinsights_is_debug_mode() || ( defined'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ) {
        return 
time();
    } else {
        return 
MONSTERINSIGHTS_VERSION;
    }
}

function 
monsterinsights_is_debug_mode() {
    
$debug_mode false;
    if ( 
defined'MONSTERINSIGHTS_DEBUG_MODE' ) && MONSTERINSIGHTS_DEBUG_MODE ) {
        
$debug_mode true;
    }

    return 
apply_filters'monsterinsights_is_debug_mode'$debug_mode );
}

function 
monsterinsights_is_network_active() {
    if ( ! 
function_exists'is_plugin_active_for_network' ) ) {
        require_once( 
ABSPATH '/wp-admin/includes/plugin.php' );
    }

    if ( 
is_multisite() && is_plugin_active_for_networkplugin_basenameMONSTERINSIGHTS_PLUGIN_FILE ) ) ) {
        return 
true;
    } else {
        return 
false;
    }
}

if ( ! 
function_exists 'remove_class_filter' ) ) {
    
/**
     * Remove Class Filter Without Access to Class Object
     *
     * In order to use the core WordPress remove_filter() on a filter added with the callback
     * to a class, you either have to have access to that class object, or it has to be a call
     * to a static method.  This method allows you to remove filters with a callback to a class
     * you don't have access to.
     *
     * Works with WordPress 1.2 - 4.7+
     *
     * @param string $tag         Filter to remove
     * @param string $class_name  Class name for the filter's callback
     * @param string $method_name Method name for the filter's callback
     * @param int    $priority    Priority of the filter (default 10)
     *
     * @return bool Whether the function is removed.
     */
    
function remove_class_filter$tag$class_name ''$method_name ''$priority 10 ) {
        global 
$wp_filter;
        
// Check that filter actually exists first
        
if ( ! isset( $wp_filter$tag ] ) ) return FALSE;
        
/**
         * If filter config is an object, means we're using WordPress 4.7+ and the config is no longer
         * a simple array, rather it is an object that implements the ArrayAccess interface.
         *
         * To be backwards compatible, we set $callbacks equal to the correct array as a reference (so $wp_filter is updated)
         *
         * @see https://make.wordpress.org/core/2016/09/08/wp_hook-next-generation-actions-and-filters/
         */
        
if ( is_object$wp_filter$tag ] ) && isset( $wp_filter$tag ]->callbacks ) ) {
            
$callbacks = &$wp_filter$tag ]->callbacks;
        } else {
            
$callbacks = &$wp_filter$tag ];
        }
        
// Exit if there aren't any callbacks for specified priority
        
if ( ! isset( $callbacks$priority ] ) || empty( $callbacks$priority ] ) ) return FALSE;
        
// Loop through each filter for the specified priority, looking for our class & method
        
foreach( (array) $callbacks$priority ] as $filter_id => $filter ) {
            
// Filter should always be an array - array( $this, 'method' ), if not goto next
            
if ( ! isset( $filter'function' ] ) || ! is_array$filter'function' ] ) ) continue;
            
// If first value in array is not an object, it can't be a class
            
if ( ! is_object$filter'function' ][ ] ) ) continue;
            
// Method doesn't match the one we're looking for, goto next
            
if ( $filter'function' ][ ] !== $method_name ) continue;
            
// Method matched, now let's check the Class
            
if ( get_class$filter'function' ][ ] ) === $class_name ) {
                
// Now let's remove it from the array
                
unset( $callbacks$priority ][ $filter_id ] );
                
// and if it was the only filter in that priority, unset that priority
                
if ( empty( $callbacks$priority ] ) ) unset( $callbacks$priority ] );
                
// and if the only filter for that tag, set the tag to an empty array
                
if ( empty( $callbacks ) ) $callbacks = array();
                
// If using WordPress older than 4.7
                
if ( ! is_object$wp_filter$tag ] ) ) {
                    
// Remove this filter from merged_filters, which specifies if filters have been sorted
                    
unset( $GLOBALS'merged_filters' ][ $tag ] );
                }
                return 
TRUE;
            }
        }
        return 
FALSE;
    }
// End function exists

if ( ! function_exists 'remove_class_action' ) ) {
    
/**
     * Remove Class Action Without Access to Class Object
     *
     * In order to use the core WordPress remove_action() on an action added with the callback
     * to a class, you either have to have access to that class object, or it has to be a call
     * to a static method.  This method allows you to remove actions with a callback to a class
     * you don't have access to.
     *
     * Works with WordPress 1.2 - 4.7+
     *
     * @param string $tag         Action to remove
     * @param string $class_name  Class name for the action's callback
     * @param string $method_name Method name for the action's callback
     * @param int    $priority    Priority of the action (default 10)
     *
     * @return bool               Whether the function is removed.
     */
    
function remove_class_action$tag$class_name ''$method_name ''$priority 10 ) {
        
remove_class_filter$tag$class_name$method_name$priority );
    }
// End function exists

/**
 * Format a big number, instead of 1000000 you get 1.0M, works with billions also.
 *
 * @param int $number
 * @param int $precision
 *
 * @return string
 */
function monsterinsights_round_number$number$precision ) {

    if ( 
$number 1000000 ) {
        
// Anything less than a million
        
$number number_format_i18n$number );
    } else if ( 
$number 1000000000 ) {
        
// Anything less than a billion
        
$number number_format_i18n$number 1000000$precision ) . 'M';
    } else {
        
// At least a billion
        
$number number_format_i18n$number 1000000000$precision ) . 'B';
    }

    return 
$number;
}

if ( ! 
function_exists'wp_get_jed_locale_data' ) ) {
    
/**
     * Returns Jed-formatted localization data. Added for backwards-compatibility.
     *
     * @param  string $domain Translation domain.
     *
     * @return array
     */
    
function wp_get_jed_locale_data$domain ) {
        
$translations get_translations_for_domain$domain );

        
$locale = array(
            
'' => array(
                
'domain' => $domain,
                
'lang'   => is_admin() && function_exists'get_user_locale' ) ? get_user_locale() : get_locale(),
            ),
        );

        if ( ! empty( 
$translations->headers['Plural-Forms'] ) ) {
            
$locale['']['plural_forms'] = $translations->headers['Plural-Forms'];
        }

        foreach ( 
$translations->entries as $msgid => $entry ) {
            
$locale$msgid ] = $entry->translations;
        }

        return 
$locale;
    }
}

function 
monsterinsights_get_inline_menu_icon() {
    
$scheme          get_user_option'admin_color'get_current_user_id() );
    
$use_dark_scheme $scheme === 'light';
    if ( 
$use_dark_scheme ) {
        return 
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAFQUlEQVRYha2Yb2hXZRTHP+c3nc6pm07NF0KWWUtSo0wqzBdiZRItTKMaEZXSi0zRNAsqTBKKSFOa0B8Jigqz2lSwLMtqRURgRuCCLLNmselyZups2+/04pzbnt3de3eTDlzufc5znvN8n+ec55zzXFFV8pKITANOqmpTP3JTgIKq7sutPCJVzfUABeAb4DSwMENuKdABNObV3Wv8fwB0C6DAUX8/67sQ9Q8ANsVk5v5vgIDKWHsvcAgYCWzzCbc6kFJgh/PqgVHAb8DnWTpzA3LzHARmeXuqT/Zo0L/eeZuAV/x7fbRrwJPOu9Dbc4EDgJwNoMmurAt4Bljt7cmBjACvOl+BzTEdVzj/EWAj0O3tC84G0AIf3BRMeDz0GZcbBvzqKy+L9Q30A6AxXTdmARqQcPAAyv29CBjjO1RU1SKAiIwGFgLX+MrbgBnAh5ECVe0UkUMO6nHgFLA70J1McacD5gHbfTXzg77qwBeOBysPn830PnnVwXety7wL1AAV/ZoM+MIHdQCfAdfF+s8H/koBEz0rU9xgLtAInHG5j/KYrNWf8ap6OmFD7w+2/Cugwd/NmOkqgbIUS+wEdorIEOAwFqv6UBKgihQwANNc0b2quh1ARIZi/nUqZUycOrDDcCSps5AAaJBPkkStwNVAs4i8JiLHgBPASRFpFZEGEZktIpIBqBIoIWWH4nZegtl3fIofjAKeoyemfAe8hZnu64D/NjAsRcdEl1mcx6lvc+HLU6L3O97/JXBlgszF9KSVvXhswkxUC6wLdKzIA2iWC1+fMNlK72sASlMjrQHf4LIvAw8B7fScwmNAZ7DDs7MARSmjNsYf7oqak0wBjAXuBlb5Lo9wE0Yg6rHAOdjlR2KB9Qc384o0QOe4giUx/u3OX5oA5gEsCoexqBnYAxTTfMXHlvuOF4F5SYBKHPGaGH+jTzQxxefSnnVpYAIdg9x0PwEDkwSOAHUx3hafoDzGP5AB5gQ56h/XU+NjauJxCCxRjo7xOvw9ImKISBUwIWF8RLtVtT2jP6SdWBKe1QuQiCwDLsKcNKSoqJ8e8BJTREAHc4JBVTuBn4Gx/wISkflYndyNOXdI2/29OOAd7mfSIXkBOZUDxTACt2A78SLQnmDnBszOiwLeraT70Ld5/Mf1jPMxqyLGWqxcnYoFMqVvBTgOK9y7gOVAifMfdF4SqJk5Aa3FLFMNduxagQbvvJOUfIb51/f0lKSrsROyHCtlIyDtrrMJqOoHzAysRvrA28wmSBfAtd7uk6u8vwwr/JOqxm4sl01wvZ3AfhJyo+taAPyJhYi/gekCPIXdNitV9YyIXIIFqptVdVsf13MSkVJgJlZF4rvSqKq/BzJzgNexcPEp8LFPXAHcAFzqoKcAddjR5z2Cay/m4Arcl9cp+zFJFfA0dslMOwB1wD1AewGrTw4Ei2/zVcSP/lmRqrap6irs8gAwid7xDOAuzNwlgmXxF1T14ahXRPZjtU1k3+g5Tk8pkUUFzCwVWC003N/DgGVYIXheIF/EfmQcFczDW4DnsVtBCxbUtmIOPAAzY6MPLgMG+/dlDrIADHWlYL4QpZuZWLjYgp3SOb7QMbFFFLF6LDNB7sGcri7FP7qwWmcX9t8oSWaDA6zCqomXUuZ6U1UpYDXxH5jfgKWET/y7zXfolIgkJeJMEpES/xwMXKWq3aq6CLu9PAH8Eog/Fn2UYnlkDWa2c719E3Y/f8NX0AL8GHuianAXtuXx/lZ6brR9/npgcWgHcEfEkyg6ZqyyBrt1ptE+X9SkDJl6VX0/cyKnfwBb6gwNaZ8ExgAAAABJRU5ErkJggg';
    } else {
        return 
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4AoEBjcfBsDvpwAABQBJREFUWMO1mGmollUQgJ9z79Vc01LLH0GLWRqlUhYV5o+LbRIVbVQSUSn9qJTKsqDCoqCINKUbtBEUFbbeDGyz1SIiaCHIINu18KZ1bbkuV+/Tj+arw8v7fvdVcuDjvGdmzsycM3Nm5nywE6BOVSfW4JukTmF3gtqifqJuVmc34ZunblFX7W6DzvYf2BDjPWpLRm9T7y/wzPw/DRhZmH+sfq/urb4YCp8JQwaqLwXuBXW0+pP6XjOZO+ueb9X2mE8OZTdl9MWBu199NL4XN05NvT1wh8R8prpGTbti0BEhbLt6t7ow5kdkPEl9zP/gkYKMowN/o7pU3RHzg3fFoHNj8epM4aY8ZoJvuPpj7HxwgTYgLoAFWac1091WgR8a4xxgH2Ah0JdS6gtlY4DZwAnADmAjMA14vSEgpdSrfg9sBm4BeoCVmex6gayepS6P3ZyT0SZksbDJcnikcPMmZN+zgud59Qx1RB2D3o9FW9R31ZMK9IPUP20O11XInqmuUrcG3xt1XNYVvwNSSptL+K/IjvxDoDPGteG6kcDgMkUppRXACnUIsA7YUNegERXGAEwNQZellJbHzodFfPXUjIwtwHDglzJiS4lBe4SSMugCjgfWqo+rvwF/AH+pXWqnOqOfXDMSaK06oaKf54Z/D6igj1bvzXLK5+rTYchHGf5ZdXiFjPHBc2Udg84P5qMqsvdzQf9APbaEZ2JWVj5u5KbIV7PURZmM+XUMag/mk0to1wWtUx3YT9lZErwPq9er3dkt/E3tzU54Rp2SMauA3zMErS1zhTpWvURdEKe8V7jQrOBOUwcF/97qbPWrcPP8KoP2DQFzC/gLAj+vZM1Vak8hF61V31L7msWKOjROvE89q4yhNSy+rYBfGorGV8RcFSyqESZ7hOu+UQeUMfyidhRwy0LB0AJ+TRNj/qjb/0QpUT2jpYS+ERhTkswA9sqEjALGNdGzMqXUXTNZrogi3F5sJ64GDgXGFhasjvGYDDe4HyXf1i3qKaVe4DtgbF6ZzwHuiZq0b2HN8hjzAF3Xj9IhO9mGDQX68gy8PpqoB9XuEj93hp/nZLjzmsTQZzvR9uwXaxY0EHdEuzo5EpklHeB+0bhvV69RWwN/beDKYHpNg+6I2z2hce261M4gXlRVz9RD1S+zlnRh3JBropVtQHfIXB3B38yYadEjvdZAzMjLhXpizI+tEDA4Gv+yrnFH1LJxIbdX/aKsNma9+++RIrapxyT1TmAeMDKltFU9HPgcODOl9GKTnQ0EpgMHBaobWJVS+jnjOQV4ItLFO8CbwDZgBHAqMAXoBSYBHcBm1JfzZ28EuOrl/9ODc5R6Vzwyq6BDvVTtbgHGA2sKiXFbydXfJUgpbUwpLQAateqwQj4DuDjSTWuKru+BlNIN2a6+ACYCv0dH2PhtCtfYjx0t4ZYR0a7uGeNw4GpgLnBgxt8HfAJsSOpWYD1wH7AqvocAz0Q2bgNGB62RoQfF95FhZAswLIQSZaBRbqYDPwHLogqcEhvdp7CJPqC9vwL5VtyUjor42B69zqvqXxU8S+IFOyq6iYcqdD3VONqngV8jbhol4e0sntqAnuIzumZAt8bnIOC4lNKOlNKceL3cCvyQsd/87/WNRuk29T51/5ifHu/zJ2MH69WvCz+zE+oroXdlL9pUkYdeUi/89xLU6VWAZn88fQoMjNtTBS+klF6pc6p/A2ye4OCYzm1lAAAAAElFTkSuQmCC';
    }
}


function 
monsterinsights_get_shareasale_id() {
    
// Check if there's a constant.
    
$shareasale_id '';
    if ( 
defined'MONSTERINSIGHTS_SHAREASALE_ID' ) ) {
        
$shareasale_id MONSTERINSIGHTS_SHAREASALE_ID;
    }

    
// If there's no constant, check if there's an option.
    
if ( empty( $shareasale_id ) ) {
        
$shareasale_id get_option'monsterinsights_shareasale_id''' );
    }

    
// Whether we have an ID or not, filter the ID.
    
$shareasale_id apply_filters'monsterinsights_shareasale_id'$shareasale_id );

    
// Ensure it's a number
    
$shareasale_id absint$shareasale_id );

    return 
$shareasale_id;
}

// Passed in with mandatory default redirect and shareasaleid from monsterinsights_get_upgrade_link
function monsterinsights_get_shareasale_url$shareasale_id$shareasale_redirect ) {
    
// Check if there's a constant.
    
$custom false;
    if ( 
defined'MONSTERINSIGHTS_SHAREASALE_REDIRECT_URL' ) ) {
        
$shareasale_redirect MONSTERINSIGHTS_SHAREASALE_REDIRECT_URL;
        
$custom              true;
    }

    
// If there's no constant, check if there's an option.
    
if ( empty( $custom ) ) {
        
$shareasale_redirect get_option'monsterinsights_shareasale_redirect_url''' );
        
$custom              true;
    }

    
// Whether we have an ID or not, filter the ID.
    
$shareasale_redirect apply_filters'monsterinsights_shareasale_redirect_url'$shareasale_redirect$custom );
    
$shareasale_url      sprintf'https://www.shareasale.com/r.cfm?B=971799&U=%s&M=69975&urllink=%s'$shareasale_id$shareasale_redirect );
    
$shareasale_url      apply_filters'monsterinsights_shareasale_redirect_entire_url'$shareasale_url$shareasale_id$shareasale_redirect );
    return 
$shareasale_url;
}

/**
 * Get a clean page title for archives.
 */
function monsterinsights_get_page_title() {

    
$title __'Archives' );

    if ( 
is_category() ) {
        
/* translators: Category archive title. %s: Category name */
        
$title sprintf__'Category: %s' ), single_cat_title''false ) );
    } elseif ( 
is_tag() ) {
        
/* translators: Tag archive title. %s: Tag name */
        
$title sprintf__'Tag: %s' ), single_tag_title''false ) );
    } elseif ( 
is_author() ) {
        
/* translators: Author archive title. %s: Author name */
        
$title sprintf__'Author: %s' ), '<span class="vcard">' get_the_author() . '</span>' );
    } elseif ( 
is_year() ) {
        
/* translators: Yearly archive title. %s: Year */
        
$title sprintf__'Year: %s' ), get_the_date_x'Y''yearly archives date format' ) ) );
    } elseif ( 
is_month() ) {
        
/* translators: Monthly archive title. %s: Month name and year */
        
$title sprintf__'Month: %s' ), get_the_date_x'F Y''monthly archives date format' ) ) );
    } elseif ( 
is_day() ) {
        
/* translators: Daily archive title. %s: Date */
        
$title sprintf__'Day: %s' ), get_the_date_x'F j, Y''daily archives date format' ) ) );
    } elseif ( 
is_tax'post_format' ) ) {
        if ( 
is_tax'post_format''post-format-aside' ) ) {
            
$title _x'Asides''post format archive title' );
        } elseif ( 
is_tax'post_format''post-format-gallery' ) ) {
            
$title _x'Galleries''post format archive title' );
        } elseif ( 
is_tax'post_format''post-format-image' ) ) {
            
$title _x'Images''post format archive title' );
        } elseif ( 
is_tax'post_format''post-format-video' ) ) {
            
$title _x'Videos''post format archive title' );
        } elseif ( 
is_tax'post_format''post-format-quote' ) ) {
            
$title _x'Quotes''post format archive title' );
        } elseif ( 
is_tax'post_format''post-format-link' ) ) {
            
$title _x'Links''post format archive title' );
        } elseif ( 
is_tax'post_format''post-format-status' ) ) {
            
$title _x'Statuses''post format archive title' );
        } elseif ( 
is_tax'post_format''post-format-audio' ) ) {
            
$title _x'Audio''post format archive title' );
        } elseif ( 
is_tax'post_format''post-format-chat' ) ) {
            
$title _x'Chats''post format archive title' );
        }
    } elseif ( 
is_post_type_archive() ) {
        
/* translators: Post type archive title. %s: Post type name */
        
$title sprintf__'Archives: %s' ), post_type_archive_title''false ) );
    } elseif ( 
is_tax() ) {
        
$tax get_taxonomyget_queried_object()->taxonomy );
        
/* translators: Taxonomy term archive title. 1: Taxonomy singular name, 2: Current taxonomy term */
        
$title sprintf__'%1$s: %2$s' ), $tax->labels->singular_namesingle_term_title''false ) );
    }

    return 
$title;

}

/**
 * Count the number of occurrences of UA tags inserted by third-party plugins.
 *
 * @param $body
 *
 * @return int
 */
function monsterinsights_count_third_party_ua_codes$body ) {
    
$count 0;

    
// Grab all potential google site verification tags
    
$pattern '/content="UA-[0-9-]+"/';
    if ( 
preg_match_all$pattern$body$matches ) ) {
        
// Raise the number of UA limits
        
$count += count$matches[0] );
    }

    
// Advanced Ads plugin (https://wpadvancedads.com)
    // When `Ad blocker counter` setting is populated with an UA ID
    
if ( class_exists'Advanced_Ads' ) ) {
        
$options Advanced_Ads::get_instance()->options();

        
$pattern '/UA-[0-9-]+/';
        if ( isset( 
$options['ga-UID'] ) && preg_match$pattern$options['ga-UID'] ) ) {
            ++ 
$count;
        }
    }

    
// WP Popups plugin (https://wppopups.com/)
    // When `Google UA Code` setting is populated with an UA Id
    
if ( function_exists'wppopups_setting' ) ) {
        
$code wppopups_setting'ua-code' );

        
$pattern '/UA-[0-9-]+/';
        if ( ! empty( 
$code ) && preg_match$pattern$code ) ) {
            ++ 
$count;
        }
    }

    return 
$count;
}

/**
 * Make a request to the front page and check if the tracking code is present. Moved here from onboarding wizard
 * to be used in the site health check.
 *
 * @return array
 */
function monsterinsights_is_code_installed_frontend() {
    
// Grab the front page html.
    
$request wp_remote_requesthome_url(), array(
        
'sslverify' => false,
    ) );
    
$errors  = array();

    
$accepted_http_codes = array(
        
200,
        
503
    
);

    
$response_code wp_remote_retrieve_response_code$request );

    if ( 
in_array$response_code$accepted_http_codestrue ) ) {

        
$body            wp_remote_retrieve_body$request );
        
$current_ua_code monsterinsights_get_ua_to_output();
        
$ua_limit        'gtag' === MonsterInsights()->get_tracking_mode() ? 2;
        
// If the ads addon is installed another UA is added to the page.
        
if ( class_exists'MonsterInsights_Ads' ) ) {
            
$ua_limit++;
        }
        
// Translators: The placeholders are for making the "We noticed you're using a caching plugin" text bold.
        
$cache_error sprintfesc_html__'%1$sWe noticed you\'re using a caching plugin or caching from your hosting provider.%2$s Be sure to clear the cache to ensure the tracking appears on all pages and posts. %3$s(See this guide on how to clear cache)%4$s.''google-analytics-for-wordpress' ), '<b>''</b>'' <a href="https://www.wpbeginner.com/beginners-guide/how-to-clear-your-cache-in-wordpress/" target="_blank">''</a>' );

        
// Translators: The placeholders are for making the "We have detected multiple tracking codes" text bold & adding a link to support.
        
$message           esc_html__'%1$sWe have detected multiple tracking codes%2$s! You should remove non-MonsterInsights ones. If you need help finding them please %3$sread this article%4$s.''google-analytics-for-wordpress' );
        
$url               monsterinsights_get_url'site-health''comingsoon''https://www.monsterinsights.com/docs/how-to-find-duplicate-google-analytics-tracking-codes-in-wordpress/' );
        
$multiple_ua_error sprintf(
            
$message,
            
'<b>',
            
'</b>',
            
'<a href="' $url '" target="_blank">',
            
'</a>'
        
);

        
// First, check if the tracking frontend code is present.
        
if ( false === strpos$body'__gaTracker' ) ) {
            
$errors[] = $cache_error;
        } else {
            
// Check if the current UA code is actually present.
            
if ( $current_ua_code && false === strpos$body$current_ua_code ) ) {
                
// We have the tracking code but using another UA, so it's cached.
                
$errors[] = $cache_error;
            }

            
$ua_limit += monsterinsights_count_third_party_ua_codes$body );

            
// Grab all the UA codes from the page.
            
$pattern '/UA-[0-9]+/m';
            
preg_match_all$pattern$body$matches );
            
// If more than twice ( because MI has a ga-disable-UA also ), let them know to remove the others.
            
if ( ! empty( $matches[0] ) && is_array$matches[0] ) && count$matches[0] ) > $ua_limit ) {
                
$errors[] = $multiple_ua_error;
            }
        }
    }

    return 
$errors;
}

/**
 * Returns a HEX color to highlight menu items based on the admin color scheme.
 */
function monsterinsights_menu_highlight_color() {

    
$color_scheme get_user_option'admin_color' );
    
$color        '#7cc048';
    if ( 
'light' === $color_scheme || 'blue' === $color_scheme ) {
        
$color '#5f3ea7';
    }

    return 
$color;
}

/**
 * Track Pretty Links redirects with MonsterInsights.
 *
 * @param string $url The url to which users get redirected.
 */
function monsterinsights_custom_track_pretty_links_redirect$url ) {
    if ( ! 
function_exists'monsterinsights_mp_track_event_call' ) ) {
        return;
    }
    
// Try to determine if click originated on the same site.
    
$referer = ! empty( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : '';
    if ( ! empty( 
$referer ) ) {
        
$current_site_url    get_bloginfo'url' );
        
$current_site_parsed wp_parse_url$current_site_url );
        
$parsed_referer      wp_parse_url$referer );
        if ( ! empty( 
$parsed_referer['host'] ) && ! empty( $current_site_parsed['host'] ) && $current_site_parsed['host'] === $parsed_referer['host'] ) {
            
// Don't track clicks originating from same site as those are tracked with JS.
            
return;
        }
    }
    
// Check if this is an affiliate link and use the appropriate category.
    
$ec            'outbound-link';
    
$inbound_paths monsterinsights_get_option'affiliate_links', array() );
    
$path          = empty( $_SERVER['REQUEST_URI'] ) ? '' $_SERVER['REQUEST_URI'];
    if ( ! empty( 
$inbound_paths ) && is_array$inbound_paths ) && ! empty( $path ) ) {
        
$found false;
        foreach ( 
$inbound_paths as $inbound_path ) {
            if ( empty( 
$inbound_path['path'] ) ) {
                continue;
            }
            if ( 
=== strpos$pathtrim$inbound_path['path'] ) ) ) {
                
$label = ! empty( $inbound_path['label'] ) ? trim$inbound_path['label'] ) : 'aff';
                
$ec   .= '-' $label;
                
$found true;
                break;
            }
        }
        if ( ! 
$found ) {
            return;
        }
    } else {
        
// no paths setup in MonsterInsights settings
        
return;
    }

    
$track_args = array(
        
't'  => 'event',
        
'ec' => $ec,
        
'ea' => $url,
        
'el' => 'external-redirect',
    );
    
monsterinsights_mp_track_event_call$track_args );
}
add_action'prli_before_redirect''monsterinsights_custom_track_pretty_links_redirect' );

/**
 * Get post type in admin side
 *
 */
function monsterinsights_get_current_post_type() {
    global 
$post$typenow$current_screen;

    if ( 
$post && $post->post_type ) {
        return 
$post->post_type;
    } elseif ( 
$typenow ) {
        return 
$typenow;
    } elseif ( 
$current_screen && $current_screen->post_type ) {
        return 
$current_screen->post_type;
    } elseif ( isset( 
$_REQUEST['post_type'] ) ) {
        return 
sanitize_key$_REQUEST['post_type'] );
    }

    return 
null;
}

/** Decode special characters, both alpha- (<) and numeric-based (').
 *
 * @since 7.10.5
 *
 * @param string $string Raw string to decode.
 *
 * @return string
 */
function monsterinsights_decode_string$string ) {

    if ( ! 
is_string$string ) ) {
        return 
$string;
    }

    return 
wp_kses_decode_entitieshtml_entity_decode$stringENT_QUOTES ) );
}

add_filter'monsterinsights_email_message''monsterinsights_decode_string' );

/**
 * Sanitize a string, that can be a multiline.
 * If WP core `sanitize_textarea_field()` exists (after 4.7.0) - use it.
 * Otherwise - split onto separate lines, sanitize each one, merge again.
 *
 * @since 7.10.5
 *
 * @param string $string
 *
 * @return string If empty var is passed, or not a string - return unmodified. Otherwise - sanitize.
 */
function monsterinsights_sanitize_textarea_field$string ) {

    if ( empty( 
$string ) || ! is_string$string ) ) {
        return 
$string;
    }

    if ( 
function_exists'sanitize_textarea_field' ) ) {
        
$string sanitize_textarea_field$string );
    } else {
        
$string implode"\n"array_map'sanitize_text_field'explode"\n"$string ) ) );
    }

    return 
$string;
}

/**
 * Trim a sentence
 *
 * @since 7.10.5
 *
 * @param string $string
 * @param int $count
 *
 * @return trimed sentence
 */
function monsterinsights_trim_text$text$count ){
    
$text     str_replace("  "" "$text);
    
$string explode(" "$text);
    
$trimed "";

    for ( 
$wordCounter 0$wordCounter <= $count$wordCounter++ ) {
        
$trimed .= isset( $string[$wordCounter] ) ? $string[$wordCounter] : '';

        if ( 
$wordCounter $count ){
            
$trimed .= " ";
        } else {
            
$trimed .= "...";
        }
    }

    
$trimed trim($trimed);

    return 
$trimed;
}

/**
 * Add newly generated builder URL to PrettyLinks &
 * Clear localStorage key(MonsterInsightsURL) after saving PrettyLink
 */
function monsterinsights_tools_copy_url_to_prettylinks() {
    global 
$pagenow;

    
$post_type                 = isset( $_GET['post_type'] ) ? $_GET['post_type'] : '';
    
$monsterinsights_reference = isset( $_GET['monsterinsights_reference'] ) ? $_GET['monsterinsights_reference'] : '';

    if ( 
'post-new.php' === $pagenow && 'pretty-link' === $post_type && 'url_builder' === $monsterinsights_reference ) { ?>
        <script>
            let targetTitleField = document.querySelector("input[name='post_title']");
            let targetUrlField = document.querySelector("textarea[name='prli_url']");
            let MonsterInsightsUrl = JSON.parse(localStorage.getItem('MonsterInsightsURL'));
            if ( 'undefined' !== typeof targetUrlField && 'undefined' !== typeof MonsterInsightsUrl ) {
                let url = MonsterInsightsUrl.value;
                let postTitle = '';
                let pathArray = url.split('?');
                if ( pathArray.length <= 1 ) {
                    pathArray = url.split('#');
                }
                let urlParams = new URLSearchParams(pathArray[1]);
                if (urlParams.has('utm_campaign')) {
                    let campaign_name = urlParams.get('utm_campaign');
                    postTitle += campaign_name;
                }
                if (urlParams.has('utm_medium')) {
                    let campaign_medium = urlParams.get('utm_medium');
                    postTitle += ` ${campaign_medium}`;
                }
                if (urlParams.has('utm_source')) {
                    let campaign_source = urlParams.get('utm_source');
                    postTitle += ` on ${campaign_source}`;
                }
                if (urlParams.has('utm_term')) {
                    let campaign_term = urlParams.get('utm_term');
                    postTitle += ` for ${campaign_term}`;
                }
                if (urlParams.has('utm_content')) {
                    let campaign_content = urlParams.get('utm_content');
                    postTitle += ` - ${campaign_content}`;
                }
                if ( 'undefined' !== typeof targetTitleField && postTitle ) {
                    targetTitleField.value = postTitle;
                }
                if( url ) {
                    targetUrlField.value = url;
                }
            }
            let form = document.getElementById('post');
            form.addEventListener('submit', function(){
                localStorage.removeItem('MonsterInsightsURL');
            });
        </script>
    <?php }
}
add_action'admin_footer''monsterinsights_tools_copy_url_to_prettylinks' );

/**
 * When click on 'Create New Pretty Link" button(on tools/prettylinks-flow page) after installing & activating prettylinks plugin
 * it redirects to PrettyLinks welcome scree page instead of prettylinks add new page.
 * This function will skip that welcome screen
 */
function monsterinsights_skip_prettylinks_welcome_screen() {
    global 
$pagenow;

    
$post_type                 = isset( $_GET['post_type'] ) ? $_GET['post_type'] : '';
    
$monsterinsights_reference = isset( $_GET['monsterinsights_reference'] ) ? $_GET['monsterinsights_reference'] : '';

    if ( 
'post-new.php' === $pagenow && 'pretty-link' === $post_type && 'url_builder' === $monsterinsights_reference ) {
        
$onboard  get_option'prli_onboard' );

        if ( 
$onboard == 'welcome' || $onboard == 'update' ) {
            
update_option'monsterinsights_backup_prli_onboard_value'$onboard );
            
delete_option'prli_onboard' );
        }
    }
}
add_action'wp_loaded''monsterinsights_skip_prettylinks_welcome_screen');

/**
 * Restore the `prli_onboard` value after creating a prettylinks with monsterinsights prettylinks flow
 * users will see the prettylinks welcome screen after fresh installation & creating prettylinks with monsterinsights prettylinks flow
 */
function monsterinsights_restore_prettylinks_onboard_value() {
    global 
$pagenow;

    
$post_type = isset( $_GET['post_type'] ) ? $_GET['post_type'] : '';

    if ( 
'edit.php' === $pagenow && 'pretty-link' === $post_type ) {
        
$onboard   get_option'monsterinsights_backup_prli_onboard_value' );

        if ( 
class_exists'PrliBaseController' ) && ( $onboard == 'welcome' || $onboard == 'update' ) ) {
            
update_option'prli_onboard'$onboard );
            
delete_option'monsterinsights_backup_prli_onboard_value' );
        }
    }
}
add_action'wp_loaded''monsterinsights_restore_prettylinks_onboard_value'15 );

/**
 * Check WP version and include the compatible upgrader skin.
 *
 * @param bool $custom_upgrader If true it will include our custom upgrader, otherwise it will use the default WP one.
 */
function monsterinsights_require_upgrader$custom_upgrader true ) {

    global 
$wp_version;

    
$base MonsterInsights();

    if ( ! 
$custom_upgrader ) {
        require_once 
ABSPATH 'wp-admin/includes/class-wp-upgrader.php';
    }

    
// WP 5.3 changes the upgrader skin.
    
if ( version_compare$wp_version'5.3''<' ) ) {
        if ( 
$custom_upgrader ) {
            require_once 
plugin_dir_path$base->file ) . 'includes/admin/licensing/plugin-upgrader.php';
        }
        require_once 
plugin_dir_path$base->file ) . '/includes/admin/licensing/skin-legacy.php';
    } else {
        if ( 
$custom_upgrader ) {
            require_once 
plugin_dir_path$base->file ) . 'includes/admin/licensing/plugin-upgrader.php';
        }
        require_once 
plugin_dir_path$base->file ) . '/includes/admin/licensing/skin.php';
    }

}

/**
 * Load headline analyzer if wp version is higher than/equal to 5.4
 *
 * @return boolean
 * @since 7.12.3
 *
 */
function monsterinsights_load_gutenberg_app() {
    global 
$wp_version;

    if ( 
version_compare$wp_version'5.4''<' ) ) {
        return 
false;
    }

    return 
true;
}

/**
 * Helper function for frontend script attributes
 *
 * @return string
 * @since 7.12.3
 *
 *
 */
function monsterinsights_get_frontend_analytics_script_atts() {
    
$attr_string '';

    
$attributes apply_filters'monsterinsights_tracking_analytics_script_attributes', array(
        
'type'         => "text/javascript",
        
'data-cfasync' => 'false'
    
) );

    if ( ! empty( 
$attributes ) ) {
        foreach ( 
$attributes as $attr_name => $attr_value ) {
            if ( ! empty( 
$attr_name ) ) {
                
$attr_string .= ' ' sanitize_key$attr_name ) . '="' esc_attr$attr_value ) . '"';
            } else {
                
$attr_string .= ' ' esc_attr$attr_value );
            }
        }
    }

    return 
$attr_string;
}

/**
 * Get native english speaking countries
 *
 * @return array
 *
 * @since 7.12.3
 */
function monsterinsights_get_english_speaking_countries() {
    return array(
        
'AG' => __'Antigua and Barbuda''google-analytics-for-wordpress' ),
        
'AU' => __'Australia''google-analytics-for-wordpress' ),
        
'BS' => __'The Bahamas''google-analytics-for-wordpress' ),
        
'BB' => __'Barbados''google-analytics-for-wordpress' ),
        
'BZ' => __'Belize''google-analytics-for-wordpress' ),
        
'CA' => __'Canada''google-analytics-for-wordpress' ),
        
'DM' => __'Dominica''google-analytics-for-wordpress' ),
        
'GD' => __'Grenada''google-analytics-for-wordpress' ),
        
'GY' => __'Guyana''google-analytics-for-wordpress' ),
        
'IE' => __'Ireland''google-analytics-for-wordpress' ),
        
'JM' => __'Jamaica''google-analytics-for-wordpress' ),
        
'NZ' => __'New Zealand''google-analytics-for-wordpress' ),
        
'KN' => __'St Kitts and Nevis''google-analytics-for-wordpress' ),
        
'LC' => __'St Lucia''google-analytics-for-wordpress' ),
        
'VC' => __'St Vincent and the Grenadines''google-analytics-for-wordpress' ),
        
'TT' => __'Trinidad and Tobago''google-analytics-for-wordpress' ),
        
'GB' => __'United Kingdom''google-analytics-for-wordpress' ),
        
'US' => __'United States of America''google-analytics-for-wordpress' ),
    );
}

/**
 * Helper function to check if the current user can install a plugin.
 *
 * @return bool
 */
function monsterinsights_can_install_plugins() {

    if ( ! 
current_user_can'install_plugins' ) ) {
        return 
false;
    }

    
// Determine whether file modifications are allowed.
    
if ( function_exists'wp_is_file_mod_allowed' ) && ! wp_is_file_mod_allowed'monsterinsights_can_install' ) ) {
        return 
false;
    }

    return 
true;
}

/**
 * Check if current date is between given dates. Date format: Y-m-d.
 *
 * @since 7.13.2
 *
 * @param string $start_date Start Date. Eg: 2021-01-01.
 * @param string $end_date   End Date. Eg: 2021-01-14.
 *
 * @return bool
 */
function monsterinsights_date_is_between$start_date$end_date ) {

    
$current_date current_time'Y-m-d' );

    
$start_date date'Y-m-d'strtotime$start_date ) );
    
$end_date   date'Y-m-d'strtotime$end_date ) );

    if ( ( 
$current_date >= $start_date ) && ( $current_date <= $end_date ) ) {
        return 
true;
    }

    return 
false;
}
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586