1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Helper functions. |
4
|
|
|
* |
5
|
|
|
* @since 6.0.0 |
6
|
|
|
* |
7
|
|
|
* @package MonsterInsights |
8
|
|
|
* @subpackage Helper |
9
|
|
|
* @author Chris Christoff |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
// Exit if accessed directly |
13
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
14
|
|
|
exit; |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
function monsterinsights_debug_output( $var ) { |
18
|
|
|
error_log( print_r( $var, true ) . "\n", 3, MONSTERINSIGHTS_PLUGIN_DIR . 'log.txt' ); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
function monsterinsights_is_page_reload() { |
22
|
|
|
// Can't be a refresh without having a referrer |
23
|
|
|
if ( ! isset( $_SERVER['HTTP_REFERER'] ) ) { |
24
|
|
|
return false; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
// IF the referrer is identical to the current page request, then it's a refresh |
28
|
|
|
return ( parse_url( $_SERVER['HTTP_REFERER'], PHP_URL_PATH ) === parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH ) ); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
|
32
|
|
|
function monsterinsights_track_user() { |
33
|
|
|
$user = wp_get_current_user(); |
34
|
|
|
$track_user = true; |
35
|
|
|
$roles = monsterinsights_get_option( 'ignore_users', array() ); |
36
|
|
|
|
37
|
|
|
if ( ! empty( $roles ) && is_array( $roles ) ) { |
|
|
|
|
38
|
|
|
foreach ( $roles as $role ) { |
39
|
|
|
if ( is_string( $role ) ) { |
40
|
|
|
if ( current_user_can( $role ) ) { |
41
|
|
|
$track_user = false; |
42
|
|
|
break; |
43
|
|
|
} |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
$track_super_admin = apply_filters( 'monsterinsights_track_super_admins', false ); |
49
|
|
|
if ( $track_super_admin === false && is_multisite() && is_super_admin() ) { |
50
|
|
|
$track_user = false; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
// or if UA code is not entered |
54
|
|
|
$ua_code = monsterinsights_get_ua(); |
55
|
|
|
if ( empty( $ua_code ) ) { |
56
|
|
|
$track_user = false; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
return apply_filters( 'monsterinsights_track_user', $track_user, $user ); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
function monsterinsights_get_client_id( $payment_id = false ) { |
63
|
|
|
if ( is_object( $payment_id ) ) { |
64
|
|
|
$payment_id = $payment_id->ID; |
65
|
|
|
} |
66
|
|
|
$user_cid = monsterinsights_get_uuid(); |
67
|
|
|
$saved_cid = ! empty( $payment_id ) ? get_post_meta( $payment_id, '_yoast_gau_uuid', true ) : false; |
68
|
|
|
|
69
|
|
|
if ( ! empty( $payment_id ) && ! empty( $saved_cid ) ) { |
70
|
|
|
return $saved_cid; |
71
|
|
|
} else if ( ! empty( $user_cid ) ) { |
72
|
|
|
return $user_cid; |
73
|
|
|
} else { |
74
|
|
|
return monsterinsights_generate_uuid(); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Returns the Google Analytics clientId to store for later use |
80
|
|
|
* |
81
|
|
|
* @since 6.0.0 |
82
|
|
|
* |
83
|
|
|
* @link https://developers.google.com/analytics/devguides/collection/analyticsjs/domains#getClientId |
84
|
|
|
* |
85
|
|
|
* @return bool|string False if cookie isn't set, GA UUID otherwise |
86
|
|
|
*/ |
87
|
|
|
function monsterinsights_get_uuid() { |
88
|
|
|
if ( empty( $_COOKIE['_ga'] ) ) { |
89
|
|
|
return false; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Example cookie formats: |
94
|
|
|
* |
95
|
|
|
* GA1.2.XXXXXXX.YYYYY |
96
|
|
|
* _ga=1.2.XXXXXXX.YYYYYY -- We want the XXXXXXX.YYYYYY part |
97
|
|
|
* |
98
|
|
|
*/ |
99
|
|
|
|
100
|
|
|
$ga_cookie = $_COOKIE['_ga']; |
101
|
|
|
$cookie_parts = explode('.', $ga_cookie ); |
102
|
|
|
if ( is_array( $cookie_parts ) && ! empty( $cookie_parts[2] ) && ! empty( $cookie_parts[3] ) ) { |
103
|
|
|
$uuid = (string) $cookie_parts[2] . '.' . (string) $cookie_parts[3]; |
104
|
|
|
if ( is_string( $uuid ) ) { |
|
|
|
|
105
|
|
|
return $uuid; |
106
|
|
|
} else { |
107
|
|
|
return false; |
108
|
|
|
} |
109
|
|
|
} else { |
110
|
|
|
return false; |
111
|
|
|
} |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Generate UUID v4 function - needed to generate a CID when one isn't available |
117
|
|
|
* |
118
|
|
|
* @link http://www.stumiller.me/implementing-google-analytics-measurement-protocol-in-php-and-wordpress/ |
119
|
|
|
* |
120
|
|
|
* @since 6.1.8 |
121
|
|
|
* @return string |
122
|
|
|
*/ |
123
|
|
|
function monsterinsights_generate_uuid() { |
124
|
|
|
|
125
|
|
|
return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', |
126
|
|
|
|
127
|
|
|
// 32 bits for "time_low" |
128
|
|
|
mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), |
129
|
|
|
|
130
|
|
|
// 16 bits for "time_mid" |
131
|
|
|
mt_rand( 0, 0xffff ), |
132
|
|
|
|
133
|
|
|
// 16 bits for "time_hi_and_version", |
134
|
|
|
// four most significant bits holds version number 4 |
135
|
|
|
mt_rand( 0, 0x0fff ) | 0x4000, |
136
|
|
|
|
137
|
|
|
// 16 bits, 8 bits for "clk_seq_hi_res", |
138
|
|
|
// 8 bits for "clk_seq_low", |
139
|
|
|
// two most significant bits holds zero and one for variant DCE1.1 |
140
|
|
|
mt_rand( 0, 0x3fff ) | 0x8000, |
141
|
|
|
|
142
|
|
|
// 48 bits for "node" |
143
|
|
|
mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ) |
144
|
|
|
); |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* Returns the Google Analytics clientId to store for later use |
149
|
|
|
* |
150
|
|
|
* @since 6.0.0 |
151
|
|
|
* |
152
|
|
|
* @return GA UUID or error code. |
|
|
|
|
153
|
|
|
*/ |
154
|
|
|
function monsterinsights_get_cookie( $debug = false ) { |
155
|
|
|
if ( empty( $_COOKIE['_ga'] ) ) { |
156
|
|
|
return ( $debug ) ? 'FCE' : false; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
$ga_cookie = $_COOKIE['_ga']; |
160
|
|
|
$cookie_parts = explode('.', $ga_cookie ); |
161
|
|
|
if ( is_array( $cookie_parts ) && ! empty( $cookie_parts[2] ) && ! empty( $cookie_parts[3] ) ) { |
162
|
|
|
$uuid = (string) $cookie_parts[2] . '.' . (string) $cookie_parts[3]; |
163
|
|
|
if ( is_string( $uuid ) ) { |
|
|
|
|
164
|
|
|
return $ga_cookie; |
165
|
|
|
} else { |
166
|
|
|
return ( $debug ) ? 'FA' : false; |
167
|
|
|
} |
168
|
|
|
} else { |
169
|
|
|
return ( $debug ) ? 'FAE' : false; |
170
|
|
|
} |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
|
174
|
|
|
function monsterinsights_generate_ga_client_id() { |
175
|
|
|
return rand(100000000,999999999) . '.' . time(); |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* Hours between two timestamps. |
181
|
|
|
* |
182
|
|
|
* @access public |
183
|
|
|
* @since 6.0.0 |
184
|
|
|
* |
185
|
|
|
* @param string $start Timestamp of start time (in seconds since Unix). |
186
|
|
|
* @param string $stop Timestamp of stop time (in seconds since Unix). Optional. If not used, current_time (in UTC 0 / GMT ) is used. |
187
|
|
|
* |
188
|
|
|
* @return int Hours between the two timestamps, rounded. |
189
|
|
|
*/ |
190
|
|
|
function monsterinsights_hours_between( $start, $stop = false ) { |
191
|
|
|
if ( $stop === false ) { |
192
|
|
|
$stop = time(); |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
$diff = (int) abs( $stop - $start ); |
196
|
|
|
$hours = round( $diff / HOUR_IN_SECONDS ); |
197
|
|
|
return $hours; |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* Is This MonsterInsights Pro? |
202
|
|
|
* |
203
|
|
|
* We use this function monsterinsights_to determine if the install is a pro version or a lite version install of MonsterInsights. |
204
|
|
|
* If the install is a lite version we disable the install from admin functionality[1] for addons as WordPress.org requires us to, |
205
|
|
|
* 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 |
206
|
|
|
* 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 |
207
|
|
|
* as the lite and pro versions of our plugin have different constants (and names for those constants) you can declare and use. |
208
|
|
|
* |
209
|
|
|
* [1] Note: This is not "feature-locking" under GPL guidelines but rather something WordPress.org requires us to do to stay |
210
|
|
|
* in compliance with their rules. We wish we didn't have to do this, as in our oppinion this diminishes the user experience |
211
|
|
|
* 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. |
212
|
|
|
* If WordPress.org ever changes their mind on this subject, we'd totally turn on that feature for Lite installs in a heartbeat. |
213
|
|
|
* |
214
|
|
|
* @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 |
215
|
|
|
* 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 |
216
|
|
|
* 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 |
217
|
|
|
* Travis-CI but also when installing addons to test with the Lite version). Also this would allow for a better user experience for users |
218
|
|
|
* who want that feature. |
219
|
|
|
* |
220
|
|
|
* @since 6.0.0 |
221
|
|
|
* @access public |
222
|
|
|
* |
223
|
|
|
* @return bool True if pro version. |
224
|
|
|
*/ |
225
|
|
|
function monsterinsights_is_pro_version() { |
226
|
|
|
if ( class_exists( 'MonsterInsights' ) ) { |
227
|
|
|
return true; |
228
|
|
|
} else { |
229
|
|
|
return false; |
230
|
|
|
} |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
|
234
|
|
|
/** |
235
|
|
|
* Get the user roles of this WordPress blog |
236
|
|
|
* |
237
|
|
|
* @return array |
238
|
|
|
*/ |
239
|
|
|
function monsterinsights_get_roles() { |
240
|
|
|
global $wp_roles; |
241
|
|
|
|
242
|
|
|
$all_roles = $wp_roles->roles; |
243
|
|
|
$roles = array(); |
244
|
|
|
|
245
|
|
|
/** |
246
|
|
|
* Filter: 'editable_roles' - Allows filtering of the roles shown within the plugin (and elsewhere in WP as it's a WP filter) |
247
|
|
|
* |
248
|
|
|
* @api array $all_roles |
249
|
|
|
*/ |
250
|
|
|
$editable_roles = apply_filters( 'editable_roles', $all_roles ); |
251
|
|
|
|
252
|
|
|
foreach ( $editable_roles as $id => $name ) { |
253
|
|
|
$roles[ $id ] = translate_user_role( $name['name'] ); |
254
|
|
|
} |
255
|
|
|
|
256
|
|
|
return $roles; |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
/** Need to escape in advance of passing in $text. */ |
260
|
|
|
function monsterinsights_get_message( $type = 'error', $text = '' ) { |
261
|
|
|
$div = ''; |
|
|
|
|
262
|
|
|
if ( $type === 'error' || $type === 'alert' || $type === 'success' || $type === 'info' ) { |
263
|
|
|
$base = MonsterInsights(); |
264
|
|
|
return $base->notices->display_inline_notice( 'monsterinsights_standard_notice', '', $text, $type, false, array( 'skip_message_escape' => true ) ); |
265
|
|
|
} else { |
266
|
|
|
return ''; |
267
|
|
|
} |
268
|
|
|
} |
269
|
|
|
|
270
|
|
|
function monsterinsights_is_dev_url( $url = '' ) { |
271
|
|
|
$is_local_url = false; |
272
|
|
|
// Trim it up |
273
|
|
|
$url = strtolower( trim( $url ) ); |
274
|
|
|
// Need to get the host...so let's add the scheme so we can use parse_url |
275
|
|
|
if ( false === strpos( $url, 'http://' ) && false === strpos( $url, 'https://' ) ) { |
276
|
|
|
$url = 'http://' . $url; |
277
|
|
|
} |
278
|
|
|
$url_parts = parse_url( $url ); |
279
|
|
|
$host = ! empty( $url_parts['host'] ) ? $url_parts['host'] : false; |
280
|
|
|
if ( ! empty( $url ) && ! empty( $host ) ) { |
281
|
|
|
if ( false !== ip2long( $host ) ) { |
282
|
|
|
if ( ! filter_var( $host, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) ) { |
283
|
|
|
$is_local_url = true; |
284
|
|
|
} |
285
|
|
|
} else if ( 'localhost' === $host ) { |
286
|
|
|
$is_local_url = true; |
287
|
|
|
} |
288
|
|
|
|
289
|
|
|
$tlds_to_check = array( '.dev', '.local', ':8888' ); |
290
|
|
|
foreach ( $tlds_to_check as $tld ) { |
291
|
|
|
if ( false !== strpos( $host, $tld ) ) { |
292
|
|
|
$is_local_url = true; |
293
|
|
|
continue; |
294
|
|
|
} |
295
|
|
|
|
296
|
|
|
} |
297
|
|
|
if ( substr_count( $host, '.' ) > 1 ) { |
298
|
|
|
$subdomains_to_check = array( 'dev.', '*.staging.', 'beta.', 'test.' ); |
299
|
|
|
foreach ( $subdomains_to_check as $subdomain ) { |
300
|
|
|
$subdomain = str_replace( '.', '(.)', $subdomain ); |
301
|
|
|
$subdomain = str_replace( array( '*', '(.)' ), '(.*)', $subdomain ); |
302
|
|
|
if ( preg_match( '/^(' . $subdomain . ')/', $host ) ) { |
303
|
|
|
$is_local_url = true; |
304
|
|
|
continue; |
305
|
|
|
} |
306
|
|
|
} |
307
|
|
|
} |
308
|
|
|
} |
309
|
|
|
return $is_local_url; |
310
|
|
|
} |
311
|
|
|
|
312
|
|
|
// Set cookie to expire in 2 years |
313
|
|
|
function monsterinsights_get_cookie_expiration_date( $time ) { |
314
|
|
|
return date('D, j F Y H:i:s', time() + $time ); |
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
function monsterinsights_string_ends_with( $string, $ending ) { |
318
|
|
|
$strlen = strlen($string); |
319
|
|
|
$endinglen = strlen($ending); |
320
|
|
|
if ( $endinglen > $strlen ) { |
321
|
|
|
return false; |
322
|
|
|
} |
323
|
|
|
return substr_compare( $string, $ending, $strlen - $endinglen, $endinglen) === 0; |
324
|
|
|
} |
325
|
|
|
|
326
|
|
|
function monsterinsights_string_starts_with( $string, $start ) { |
327
|
|
|
return substr( $string, 0, strlen( $start ) ) === $start; |
328
|
|
|
} |
329
|
|
|
|
330
|
|
|
function monsterinsights_get_country_list( $translated = false ) { |
331
|
|
|
if ( $translated ) { |
332
|
|
|
$countries = array( |
333
|
|
|
'' => '', |
334
|
|
|
'US' => __( 'United States', 'google-analytics-for-wordpress' ), |
335
|
|
|
'CA' => __( 'Canada', 'google-analytics-for-wordpress' ), |
336
|
|
|
'GB' => __( 'United Kingdom', 'google-analytics-for-wordpress' ), |
337
|
|
|
'AF' => __( 'Afghanistan', 'google-analytics-for-wordpress' ), |
338
|
|
|
'AX' => __( 'Åland Islands', 'google-analytics-for-wordpress' ), |
339
|
|
|
'AL' => __( 'Albania', 'google-analytics-for-wordpress' ), |
340
|
|
|
'DZ' => __( 'Algeria', 'google-analytics-for-wordpress' ), |
341
|
|
|
'AS' => __( 'American Samoa', 'google-analytics-for-wordpress' ), |
342
|
|
|
'AD' => __( 'Andorra', 'google-analytics-for-wordpress' ), |
343
|
|
|
'AO' => __( 'Angola', 'google-analytics-for-wordpress' ), |
344
|
|
|
'AI' => __( 'Anguilla', 'google-analytics-for-wordpress' ), |
345
|
|
|
'AQ' => __( 'Antarctica', 'google-analytics-for-wordpress' ), |
346
|
|
|
'AG' => __( 'Antigua and Barbuda', 'google-analytics-for-wordpress' ), |
347
|
|
|
'AR' => __( 'Argentina', 'google-analytics-for-wordpress' ), |
348
|
|
|
'AM' => __( 'Armenia', 'google-analytics-for-wordpress' ), |
349
|
|
|
'AW' => __( 'Aruba', 'google-analytics-for-wordpress' ), |
350
|
|
|
'AU' => __( 'Australia', 'google-analytics-for-wordpress' ), |
351
|
|
|
'AT' => __( 'Austria', 'google-analytics-for-wordpress' ), |
352
|
|
|
'AZ' => __( 'Azerbaijan', 'google-analytics-for-wordpress' ), |
353
|
|
|
'BS' => __( 'Bahamas', 'google-analytics-for-wordpress' ), |
354
|
|
|
'BH' => __( 'Bahrain', 'google-analytics-for-wordpress' ), |
355
|
|
|
'BD' => __( 'Bangladesh', 'google-analytics-for-wordpress' ), |
356
|
|
|
'BB' => __( 'Barbados', 'google-analytics-for-wordpress' ), |
357
|
|
|
'BY' => __( 'Belarus', 'google-analytics-for-wordpress' ), |
358
|
|
|
'BE' => __( 'Belgium', 'google-analytics-for-wordpress' ), |
359
|
|
|
'BZ' => __( 'Belize', 'google-analytics-for-wordpress' ), |
360
|
|
|
'BJ' => __( 'Benin', 'google-analytics-for-wordpress' ), |
361
|
|
|
'BM' => __( 'Bermuda', 'google-analytics-for-wordpress' ), |
362
|
|
|
'BT' => __( 'Bhutan', 'google-analytics-for-wordpress' ), |
363
|
|
|
'BO' => __( 'Bolivia', 'google-analytics-for-wordpress' ), |
364
|
|
|
'BQ' => __( 'Bonaire, Saint Eustatius and Saba', 'google-analytics-for-wordpress' ), |
365
|
|
|
'BA' => __( 'Bosnia and Herzegovina', 'google-analytics-for-wordpress' ), |
366
|
|
|
'BW' => __( 'Botswana', 'google-analytics-for-wordpress' ), |
367
|
|
|
'BV' => __( 'Bouvet Island', 'google-analytics-for-wordpress' ), |
368
|
|
|
'BR' => __( 'Brazil', 'google-analytics-for-wordpress' ), |
369
|
|
|
'IO' => __( 'British Indian Ocean Territory', 'google-analytics-for-wordpress' ), |
370
|
|
|
'BN' => __( 'Brunei Darrussalam', 'google-analytics-for-wordpress' ), |
371
|
|
|
'BG' => __( 'Bulgaria', 'google-analytics-for-wordpress' ), |
372
|
|
|
'BF' => __( 'Burkina Faso', 'google-analytics-for-wordpress' ), |
373
|
|
|
'BI' => __( 'Burundi', 'google-analytics-for-wordpress' ), |
374
|
|
|
'KH' => __( 'Cambodia', 'google-analytics-for-wordpress' ), |
375
|
|
|
'CM' => __( 'Cameroon', 'google-analytics-for-wordpress' ), |
376
|
|
|
'CV' => __( 'Cape Verde', 'google-analytics-for-wordpress' ), |
377
|
|
|
'KY' => __( 'Cayman Islands', 'google-analytics-for-wordpress' ), |
378
|
|
|
'CF' => __( 'Central African Republic', 'google-analytics-for-wordpress' ), |
379
|
|
|
'TD' => __( 'Chad', 'google-analytics-for-wordpress' ), |
380
|
|
|
'CL' => __( 'Chile', 'google-analytics-for-wordpress' ), |
381
|
|
|
'CN' => __( 'China', 'google-analytics-for-wordpress' ), |
382
|
|
|
'CX' => __( 'Christmas Island', 'google-analytics-for-wordpress' ), |
383
|
|
|
'CC' => __( 'Cocos Islands', 'google-analytics-for-wordpress' ), |
384
|
|
|
'CO' => __( 'Colombia', 'google-analytics-for-wordpress' ), |
385
|
|
|
'KM' => __( 'Comoros', 'google-analytics-for-wordpress' ), |
386
|
|
|
'CD' => __( 'Congo, Democratic People\'s Republic', 'google-analytics-for-wordpress' ), |
387
|
|
|
'CG' => __( 'Congo, Republic of', 'google-analytics-for-wordpress' ), |
388
|
|
|
'CK' => __( 'Cook Islands', 'google-analytics-for-wordpress' ), |
389
|
|
|
'CR' => __( 'Costa Rica', 'google-analytics-for-wordpress' ), |
390
|
|
|
'CI' => __( 'Cote d\'Ivoire', 'google-analytics-for-wordpress' ), |
391
|
|
|
'HR' => __( 'Croatia/Hrvatska', 'google-analytics-for-wordpress' ), |
392
|
|
|
'CU' => __( 'Cuba', 'google-analytics-for-wordpress' ), |
393
|
|
|
'CW' => __( 'CuraÇao', 'google-analytics-for-wordpress' ), |
394
|
|
|
'CY' => __( 'Cyprus', 'google-analytics-for-wordpress' ), |
395
|
|
|
'CZ' => __( 'Czechia', 'google-analytics-for-wordpress' ), |
396
|
|
|
'DK' => __( 'Denmark', 'google-analytics-for-wordpress' ), |
397
|
|
|
'DJ' => __( 'Djibouti', 'google-analytics-for-wordpress' ), |
398
|
|
|
'DM' => __( 'Dominica', 'google-analytics-for-wordpress' ), |
399
|
|
|
'DO' => __( 'Dominican Republic', 'google-analytics-for-wordpress' ), |
400
|
|
|
'TP' => __( 'East Timor', 'google-analytics-for-wordpress' ), |
401
|
|
|
'EC' => __( 'Ecuador', 'google-analytics-for-wordpress' ), |
402
|
|
|
'EG' => __( 'Egypt', 'google-analytics-for-wordpress' ), |
403
|
|
|
'GQ' => __( 'Equatorial Guinea', 'google-analytics-for-wordpress' ), |
404
|
|
|
'SV' => __( 'El Salvador', 'google-analytics-for-wordpress' ), |
405
|
|
|
'ER' => __( 'Eritrea', 'google-analytics-for-wordpress' ), |
406
|
|
|
'EE' => __( 'Estonia', 'google-analytics-for-wordpress' ), |
407
|
|
|
'ET' => __( 'Ethiopia', 'google-analytics-for-wordpress' ), |
408
|
|
|
'FK' => __( 'Falkland Islands', 'google-analytics-for-wordpress' ), |
409
|
|
|
'FO' => __( 'Faroe Islands', 'google-analytics-for-wordpress' ), |
410
|
|
|
'FJ' => __( 'Fiji', 'google-analytics-for-wordpress' ), |
411
|
|
|
'FI' => __( 'Finland', 'google-analytics-for-wordpress' ), |
412
|
|
|
'FR' => __( 'France', 'google-analytics-for-wordpress' ), |
413
|
|
|
'GF' => __( 'French Guiana', 'google-analytics-for-wordpress' ), |
414
|
|
|
'PF' => __( 'French Polynesia', 'google-analytics-for-wordpress' ), |
415
|
|
|
'TF' => __( 'French Southern Territories', 'google-analytics-for-wordpress' ), |
416
|
|
|
'GA' => __( 'Gabon', 'google-analytics-for-wordpress' ), |
417
|
|
|
'GM' => __( 'Gambia', 'google-analytics-for-wordpress' ), |
418
|
|
|
'GE' => __( 'Georgia', 'google-analytics-for-wordpress' ), |
419
|
|
|
'DE' => __( 'Germany', 'google-analytics-for-wordpress' ), |
420
|
|
|
'GR' => __( 'Greece', 'google-analytics-for-wordpress' ), |
421
|
|
|
'GH' => __( 'Ghana', 'google-analytics-for-wordpress' ), |
422
|
|
|
'GI' => __( 'Gibraltar', 'google-analytics-for-wordpress' ), |
423
|
|
|
'GL' => __( 'Greenland', 'google-analytics-for-wordpress' ), |
424
|
|
|
'GD' => __( 'Grenada', 'google-analytics-for-wordpress' ), |
425
|
|
|
'GP' => __( 'Guadeloupe', 'google-analytics-for-wordpress' ), |
426
|
|
|
'GU' => __( 'Guam', 'google-analytics-for-wordpress' ), |
427
|
|
|
'GT' => __( 'Guatemala', 'google-analytics-for-wordpress' ), |
428
|
|
|
'GG' => __( 'Guernsey', 'google-analytics-for-wordpress' ), |
429
|
|
|
'GN' => __( 'Guinea', 'google-analytics-for-wordpress' ), |
430
|
|
|
'GW' => __( 'Guinea-Bissau', 'google-analytics-for-wordpress' ), |
431
|
|
|
'GY' => __( 'Guyana', 'google-analytics-for-wordpress' ), |
432
|
|
|
'HT' => __( 'Haiti', 'google-analytics-for-wordpress' ), |
433
|
|
|
'HM' => __( 'Heard and McDonald Islands', 'google-analytics-for-wordpress' ), |
434
|
|
|
'VA' => __( 'Holy See (City Vatican State)', 'google-analytics-for-wordpress' ), |
435
|
|
|
'HN' => __( 'Honduras', 'google-analytics-for-wordpress' ), |
436
|
|
|
'HK' => __( 'Hong Kong', 'google-analytics-for-wordpress' ), |
437
|
|
|
'HU' => __( 'Hungary', 'google-analytics-for-wordpress' ), |
438
|
|
|
'IS' => __( 'Iceland', 'google-analytics-for-wordpress' ), |
439
|
|
|
'IN' => __( 'India', 'google-analytics-for-wordpress' ), |
440
|
|
|
'ID' => __( 'Indonesia', 'google-analytics-for-wordpress' ), |
441
|
|
|
'IR' => __( 'Iran', 'google-analytics-for-wordpress' ), |
442
|
|
|
'IQ' => __( 'Iraq', 'google-analytics-for-wordpress' ), |
443
|
|
|
'IE' => __( 'Ireland', 'google-analytics-for-wordpress' ), |
444
|
|
|
'IM' => __( 'Isle of Man', 'google-analytics-for-wordpress' ), |
445
|
|
|
'IL' => __( 'Israel', 'google-analytics-for-wordpress' ), |
446
|
|
|
'IT' => __( 'Italy', 'google-analytics-for-wordpress' ), |
447
|
|
|
'JM' => __( 'Jamaica', 'google-analytics-for-wordpress' ), |
448
|
|
|
'JP' => __( 'Japan', 'google-analytics-for-wordpress' ), |
449
|
|
|
'JE' => __( 'Jersey', 'google-analytics-for-wordpress' ), |
450
|
|
|
'JO' => __( 'Jordan', 'google-analytics-for-wordpress' ), |
451
|
|
|
'KZ' => __( 'Kazakhstan', 'google-analytics-for-wordpress' ), |
452
|
|
|
'KE' => __( 'Kenya', 'google-analytics-for-wordpress' ), |
453
|
|
|
'KI' => __( 'Kiribati', 'google-analytics-for-wordpress' ), |
454
|
|
|
'KW' => __( 'Kuwait', 'google-analytics-for-wordpress' ), |
455
|
|
|
'KG' => __( 'Kyrgyzstan', 'google-analytics-for-wordpress' ), |
456
|
|
|
'LA' => __( 'Lao People\'s Democratic Republic', 'google-analytics-for-wordpress' ), |
457
|
|
|
'LV' => __( 'Latvia', 'google-analytics-for-wordpress' ), |
458
|
|
|
'LB' => __( 'Lebanon', 'google-analytics-for-wordpress' ), |
459
|
|
|
'LS' => __( 'Lesotho', 'google-analytics-for-wordpress' ), |
460
|
|
|
'LR' => __( 'Liberia', 'google-analytics-for-wordpress' ), |
461
|
|
|
'LY' => __( 'Libyan Arab Jamahiriya', 'google-analytics-for-wordpress' ), |
462
|
|
|
'LI' => __( 'Liechtenstein', 'google-analytics-for-wordpress' ), |
463
|
|
|
'LT' => __( 'Lithuania', 'google-analytics-for-wordpress' ), |
464
|
|
|
'LU' => __( 'Luxembourg', 'google-analytics-for-wordpress' ), |
465
|
|
|
'MO' => __( 'Macau', 'google-analytics-for-wordpress' ), |
466
|
|
|
'MK' => __( 'Macedonia', 'google-analytics-for-wordpress' ), |
467
|
|
|
'MG' => __( 'Madagascar', 'google-analytics-for-wordpress' ), |
468
|
|
|
'MW' => __( 'Malawi', 'google-analytics-for-wordpress' ), |
469
|
|
|
'MY' => __( 'Malaysia', 'google-analytics-for-wordpress' ), |
470
|
|
|
'MV' => __( 'Maldives', 'google-analytics-for-wordpress' ), |
471
|
|
|
'ML' => __( 'Mali', 'google-analytics-for-wordpress' ), |
472
|
|
|
'MT' => __( 'Malta', 'google-analytics-for-wordpress' ), |
473
|
|
|
'MH' => __( 'Marshall Islands', 'google-analytics-for-wordpress' ), |
474
|
|
|
'MQ' => __( 'Martinique', 'google-analytics-for-wordpress' ), |
475
|
|
|
'MR' => __( 'Mauritania', 'google-analytics-for-wordpress' ), |
476
|
|
|
'MU' => __( 'Mauritius', 'google-analytics-for-wordpress' ), |
477
|
|
|
'YT' => __( 'Mayotte', 'google-analytics-for-wordpress' ), |
478
|
|
|
'MX' => __( 'Mexico', 'google-analytics-for-wordpress' ), |
479
|
|
|
'FM' => __( 'Micronesia', 'google-analytics-for-wordpress' ), |
480
|
|
|
'MD' => __( 'Moldova, Republic of', 'google-analytics-for-wordpress' ), |
481
|
|
|
'MC' => __( 'Monaco', 'google-analytics-for-wordpress' ), |
482
|
|
|
'MN' => __( 'Mongolia', 'google-analytics-for-wordpress' ), |
483
|
|
|
'ME' => __( 'Montenegro', 'google-analytics-for-wordpress' ), |
484
|
|
|
'MS' => __( 'Montserrat', 'google-analytics-for-wordpress' ), |
485
|
|
|
'MA' => __( 'Morocco', 'google-analytics-for-wordpress' ), |
486
|
|
|
'MZ' => __( 'Mozambique', 'google-analytics-for-wordpress' ), |
487
|
|
|
'MM' => __( 'Myanmar', 'google-analytics-for-wordpress' ), |
488
|
|
|
'NA' => __( 'Namibia', 'google-analytics-for-wordpress' ), |
489
|
|
|
'NR' => __( 'Nauru', 'google-analytics-for-wordpress' ), |
490
|
|
|
'NP' => __( 'Nepal', 'google-analytics-for-wordpress' ), |
491
|
|
|
'NL' => __( 'Netherlands', 'google-analytics-for-wordpress' ), |
492
|
|
|
'AN' => __( 'Netherlands Antilles', 'google-analytics-for-wordpress' ), |
493
|
|
|
'NC' => __( 'New Caledonia', 'google-analytics-for-wordpress' ), |
494
|
|
|
'NZ' => __( 'New Zealand', 'google-analytics-for-wordpress' ), |
495
|
|
|
'NI' => __( 'Nicaragua', 'google-analytics-for-wordpress' ), |
496
|
|
|
'NE' => __( 'Niger', 'google-analytics-for-wordpress' ), |
497
|
|
|
'NG' => __( 'Nigeria', 'google-analytics-for-wordpress' ), |
498
|
|
|
'NU' => __( 'Niue', 'google-analytics-for-wordpress' ), |
499
|
|
|
'NF' => __( 'Norfolk Island', 'google-analytics-for-wordpress' ), |
500
|
|
|
'KP' => __( 'North Korea', 'google-analytics-for-wordpress' ), |
501
|
|
|
'MP' => __( 'Northern Mariana Islands', 'google-analytics-for-wordpress' ), |
502
|
|
|
'NO' => __( 'Norway', 'google-analytics-for-wordpress' ), |
503
|
|
|
'OM' => __( 'Oman', 'google-analytics-for-wordpress' ), |
504
|
|
|
'PK' => __( 'Pakistan', 'google-analytics-for-wordpress' ), |
505
|
|
|
'PW' => __( 'Palau', 'google-analytics-for-wordpress' ), |
506
|
|
|
'PS' => __( 'Palestinian Territories', 'google-analytics-for-wordpress' ), |
507
|
|
|
'PA' => __( 'Panama', 'google-analytics-for-wordpress' ), |
508
|
|
|
'PG' => __( 'Papua New Guinea', 'google-analytics-for-wordpress' ), |
509
|
|
|
'PY' => __( 'Paraguay', 'google-analytics-for-wordpress' ), |
510
|
|
|
'PE' => __( 'Peru', 'google-analytics-for-wordpress' ), |
511
|
|
|
'PH' => __( 'Philippines', 'google-analytics-for-wordpress' ), |
512
|
|
|
'PN' => __( 'Pitcairn Island', 'google-analytics-for-wordpress' ), |
513
|
|
|
'PL' => __( 'Poland', 'google-analytics-for-wordpress' ), |
514
|
|
|
'PT' => __( 'Portugal', 'google-analytics-for-wordpress' ), |
515
|
|
|
'PR' => __( 'Puerto Rico', 'google-analytics-for-wordpress' ), |
516
|
|
|
'QA' => __( 'Qatar', 'google-analytics-for-wordpress' ), |
517
|
|
|
'XK' => __( 'Republic of Kosovo', 'google-analytics-for-wordpress' ), |
518
|
|
|
'RE' => __( 'Reunion Island', 'google-analytics-for-wordpress' ), |
519
|
|
|
'RO' => __( 'Romania', 'google-analytics-for-wordpress' ), |
520
|
|
|
'RU' => __( 'Russian Federation', 'google-analytics-for-wordpress' ), |
521
|
|
|
'RW' => __( 'Rwanda', 'google-analytics-for-wordpress' ), |
522
|
|
|
'BL' => __( 'Saint Barthélemy', 'google-analytics-for-wordpress' ), |
523
|
|
|
'SH' => __( 'Saint Helena', 'google-analytics-for-wordpress' ), |
524
|
|
|
'KN' => __( 'Saint Kitts and Nevis', 'google-analytics-for-wordpress' ), |
525
|
|
|
'LC' => __( 'Saint Lucia', 'google-analytics-for-wordpress' ), |
526
|
|
|
'MF' => __( 'Saint Martin (French)', 'google-analytics-for-wordpress' ), |
527
|
|
|
'SX' => __( 'Saint Martin (Dutch)', 'google-analytics-for-wordpress' ), |
528
|
|
|
'PM' => __( 'Saint Pierre and Miquelon', 'google-analytics-for-wordpress' ), |
529
|
|
|
'VC' => __( 'Saint Vincent and the Grenadines', 'google-analytics-for-wordpress' ), |
530
|
|
|
'SM' => __( 'San Marino', 'google-analytics-for-wordpress' ), |
531
|
|
|
'ST' => __( 'São Tomé and Príncipe', 'google-analytics-for-wordpress' ), |
532
|
|
|
'SA' => __( 'Saudi Arabia', 'google-analytics-for-wordpress' ), |
533
|
|
|
'SN' => __( 'Senegal', 'google-analytics-for-wordpress' ), |
534
|
|
|
'RS' => __( 'Serbia', 'google-analytics-for-wordpress' ), |
535
|
|
|
'SC' => __( 'Seychelles', 'google-analytics-for-wordpress' ), |
536
|
|
|
'SL' => __( 'Sierra Leone', 'google-analytics-for-wordpress' ), |
537
|
|
|
'SG' => __( 'Singapore', 'google-analytics-for-wordpress' ), |
538
|
|
|
'SK' => __( 'Slovak Republic', 'google-analytics-for-wordpress' ), |
539
|
|
|
'SI' => __( 'Slovenia', 'google-analytics-for-wordpress' ), |
540
|
|
|
'SB' => __( 'Solomon Islands', 'google-analytics-for-wordpress' ), |
541
|
|
|
'SO' => __( 'Somalia', 'google-analytics-for-wordpress' ), |
542
|
|
|
'ZA' => __( 'South Africa', 'google-analytics-for-wordpress' ), |
543
|
|
|
'GS' => __( 'South Georgia', 'google-analytics-for-wordpress' ), |
544
|
|
|
'KR' => __( 'South Korea', 'google-analytics-for-wordpress' ), |
545
|
|
|
'SS' => __( 'South Sudan', 'google-analytics-for-wordpress' ), |
546
|
|
|
'ES' => __( 'Spain', 'google-analytics-for-wordpress' ), |
547
|
|
|
'LK' => __( 'Sri Lanka', 'google-analytics-for-wordpress' ), |
548
|
|
|
'SD' => __( 'Sudan', 'google-analytics-for-wordpress' ), |
549
|
|
|
'SR' => __( 'Suriname', 'google-analytics-for-wordpress' ), |
550
|
|
|
'SJ' => __( 'Svalbard and Jan Mayen Islands', 'google-analytics-for-wordpress' ), |
551
|
|
|
'SZ' => __( 'Swaziland', 'google-analytics-for-wordpress' ), |
552
|
|
|
'SE' => __( 'Sweden', 'google-analytics-for-wordpress' ), |
553
|
|
|
'CH' => __( 'Switzerland', 'google-analytics-for-wordpress' ), |
554
|
|
|
'SY' => __( 'Syrian Arab Republic', 'google-analytics-for-wordpress' ), |
555
|
|
|
'TW' => __( 'Taiwan', 'google-analytics-for-wordpress' ), |
556
|
|
|
'TJ' => __( 'Tajikistan', 'google-analytics-for-wordpress' ), |
557
|
|
|
'TZ' => __( 'Tanzania', 'google-analytics-for-wordpress' ), |
558
|
|
|
'TH' => __( 'Thailand', 'google-analytics-for-wordpress' ), |
559
|
|
|
'TL' => __( 'Timor-Leste', 'google-analytics-for-wordpress' ), |
560
|
|
|
'TG' => __( 'Togo', 'google-analytics-for-wordpress' ), |
561
|
|
|
'TK' => __( 'Tokelau', 'google-analytics-for-wordpress' ), |
562
|
|
|
'TO' => __( 'Tonga', 'google-analytics-for-wordpress' ), |
563
|
|
|
'TT' => __( 'Trinidad and Tobago', 'google-analytics-for-wordpress' ), |
564
|
|
|
'TN' => __( 'Tunisia', 'google-analytics-for-wordpress' ), |
565
|
|
|
'TR' => __( 'Turkey', 'google-analytics-for-wordpress' ), |
566
|
|
|
'TM' => __( 'Turkmenistan', 'google-analytics-for-wordpress' ), |
567
|
|
|
'TC' => __( 'Turks and Caicos Islands', 'google-analytics-for-wordpress' ), |
568
|
|
|
'TV' => __( 'Tuvalu', 'google-analytics-for-wordpress' ), |
569
|
|
|
'UG' => __( 'Uganda', 'google-analytics-for-wordpress' ), |
570
|
|
|
'UA' => __( 'Ukraine', 'google-analytics-for-wordpress' ), |
571
|
|
|
'AE' => __( 'United Arab Emirates', 'google-analytics-for-wordpress' ), |
572
|
|
|
'UY' => __( 'Uruguay', 'google-analytics-for-wordpress' ), |
573
|
|
|
'UM' => __( 'US Minor Outlying Islands', 'google-analytics-for-wordpress' ), |
574
|
|
|
'UZ' => __( 'Uzbekistan', 'google-analytics-for-wordpress' ), |
575
|
|
|
'VU' => __( 'Vanuatu', 'google-analytics-for-wordpress' ), |
576
|
|
|
'VE' => __( 'Venezuela', 'google-analytics-for-wordpress' ), |
577
|
|
|
'VN' => __( 'Vietnam', 'google-analytics-for-wordpress' ), |
578
|
|
|
'VG' => __( 'Virgin Islands (British)', 'google-analytics-for-wordpress' ), |
579
|
|
|
'VI' => __( 'Virgin Islands (USA)', 'google-analytics-for-wordpress' ), |
580
|
|
|
'WF' => __( 'Wallis and Futuna Islands', 'google-analytics-for-wordpress' ), |
581
|
|
|
'EH' => __( 'Western Sahara', 'google-analytics-for-wordpress' ), |
582
|
|
|
'WS' => __( 'Western Samoa', 'google-analytics-for-wordpress' ), |
583
|
|
|
'YE' => __( 'Yemen', 'google-analytics-for-wordpress' ), |
584
|
|
|
'ZM' => __( 'Zambia', 'google-analytics-for-wordpress' ), |
585
|
|
|
'ZW' => __( 'Zimbabwe', 'google-analytics-for-wordpress' ), |
586
|
|
|
); |
587
|
|
|
} else { |
588
|
|
|
$countries = array( |
589
|
|
|
'' => '', |
590
|
|
|
'US' => 'United States', |
591
|
|
|
'CA' => 'Canada', |
592
|
|
|
'GB' => 'United Kingdom', |
593
|
|
|
'AF' => 'Afghanistan', |
594
|
|
|
'AX' => 'Åland Islands', |
595
|
|
|
'AL' => 'Albania', |
596
|
|
|
'DZ' => 'Algeria', |
597
|
|
|
'AS' => 'American Samoa', |
598
|
|
|
'AD' => 'Andorra', |
599
|
|
|
'AO' => 'Angola', |
600
|
|
|
'AI' => 'Anguilla', |
601
|
|
|
'AQ' => 'Antarctica', |
602
|
|
|
'AG' => 'Antigua and Barbuda', |
603
|
|
|
'AR' => 'Argentina', |
604
|
|
|
'AM' => 'Armenia', |
605
|
|
|
'AW' => 'Aruba', |
606
|
|
|
'AU' => 'Australia', |
607
|
|
|
'AT' => 'Austria', |
608
|
|
|
'AZ' => 'Azerbaijan', |
609
|
|
|
'BS' => 'Bahamas', |
610
|
|
|
'BH' => 'Bahrain', |
611
|
|
|
'BD' => 'Bangladesh', |
612
|
|
|
'BB' => 'Barbados', |
613
|
|
|
'BY' => 'Belarus', |
614
|
|
|
'BE' => 'Belgium', |
615
|
|
|
'BZ' => 'Belize', |
616
|
|
|
'BJ' => 'Benin', |
617
|
|
|
'BM' => 'Bermuda', |
618
|
|
|
'BT' => 'Bhutan', |
619
|
|
|
'BO' => 'Bolivia', |
620
|
|
|
'BQ' => 'Bonaire, Saint Eustatius and Saba', |
621
|
|
|
'BA' => 'Bosnia and Herzegovina', |
622
|
|
|
'BW' => 'Botswana', |
623
|
|
|
'BV' => 'Bouvet Island', |
624
|
|
|
'BR' => 'Brazil', |
625
|
|
|
'IO' => 'British Indian Ocean Territory', |
626
|
|
|
'BN' => 'Brunei Darrussalam', |
627
|
|
|
'BG' => 'Bulgaria', |
628
|
|
|
'BF' => 'Burkina Faso', |
629
|
|
|
'BI' => 'Burundi', |
630
|
|
|
'KH' => 'Cambodia', |
631
|
|
|
'CM' => 'Cameroon', |
632
|
|
|
'CV' => 'Cape Verde', |
633
|
|
|
'KY' => 'Cayman Islands', |
634
|
|
|
'CF' => 'Central African Republic', |
635
|
|
|
'TD' => 'Chad', |
636
|
|
|
'CL' => 'Chile', |
637
|
|
|
'CN' => 'China', |
638
|
|
|
'CX' => 'Christmas Island', |
639
|
|
|
'CC' => 'Cocos Islands', |
640
|
|
|
'CO' => 'Colombia', |
641
|
|
|
'KM' => 'Comoros', |
642
|
|
|
'CD' => 'Congo, Democratic People\'s Republic', |
643
|
|
|
'CG' => 'Congo, Republic of', |
644
|
|
|
'CK' => 'Cook Islands', |
645
|
|
|
'CR' => 'Costa Rica', |
646
|
|
|
'CI' => 'Cote d\'Ivoire', |
647
|
|
|
'HR' => 'Croatia/Hrvatska', |
648
|
|
|
'CU' => 'Cuba', |
649
|
|
|
'CW' => 'CuraÇao', |
650
|
|
|
'CY' => 'Cyprus', |
651
|
|
|
'CZ' => 'Czechia', |
652
|
|
|
'DK' => 'Denmark', |
653
|
|
|
'DJ' => 'Djibouti', |
654
|
|
|
'DM' => 'Dominica', |
655
|
|
|
'DO' => 'Dominican Republic', |
656
|
|
|
'TP' => 'East Timor', |
657
|
|
|
'EC' => 'Ecuador', |
658
|
|
|
'EG' => 'Egypt', |
659
|
|
|
'GQ' => 'Equatorial Guinea', |
660
|
|
|
'SV' => 'El Salvador', |
661
|
|
|
'ER' => 'Eritrea', |
662
|
|
|
'EE' => 'Estonia', |
663
|
|
|
'ET' => 'Ethiopia', |
664
|
|
|
'FK' => 'Falkland Islands', |
665
|
|
|
'FO' => 'Faroe Islands', |
666
|
|
|
'FJ' => 'Fiji', |
667
|
|
|
'FI' => 'Finland', |
668
|
|
|
'FR' => 'France', |
669
|
|
|
'GF' => 'French Guiana', |
670
|
|
|
'PF' => 'French Polynesia', |
671
|
|
|
'TF' => 'French Southern Territories', |
672
|
|
|
'GA' => 'Gabon', |
673
|
|
|
'GM' => 'Gambia', |
674
|
|
|
'GE' => 'Georgia', |
675
|
|
|
'DE' => 'Germany', |
676
|
|
|
'GR' => 'Greece', |
677
|
|
|
'GH' => 'Ghana', |
678
|
|
|
'GI' => 'Gibraltar', |
679
|
|
|
'GL' => 'Greenland', |
680
|
|
|
'GD' => 'Grenada', |
681
|
|
|
'GP' => 'Guadeloupe', |
682
|
|
|
'GU' => 'Guam', |
683
|
|
|
'GT' => 'Guatemala', |
684
|
|
|
'GG' => 'Guernsey', |
685
|
|
|
'GN' => 'Guinea', |
686
|
|
|
'GW' => 'Guinea-Bissau', |
687
|
|
|
'GY' => 'Guyana', |
688
|
|
|
'HT' => 'Haiti', |
689
|
|
|
'HM' => 'Heard and McDonald Islands', |
690
|
|
|
'VA' => 'Holy See (City Vatican State)', |
691
|
|
|
'HN' => 'Honduras', |
692
|
|
|
'HK' => 'Hong Kong', |
693
|
|
|
'HU' => 'Hungary', |
694
|
|
|
'IS' => 'Iceland', |
695
|
|
|
'IN' => 'India', |
696
|
|
|
'ID' => 'Indonesia', |
697
|
|
|
'IR' => 'Iran', |
698
|
|
|
'IQ' => 'Iraq', |
699
|
|
|
'IE' => 'Ireland', |
700
|
|
|
'IM' => 'Isle of Man', |
701
|
|
|
'IL' => 'Israel', |
702
|
|
|
'IT' => 'Italy', |
703
|
|
|
'JM' => 'Jamaica', |
704
|
|
|
'JP' => 'Japan', |
705
|
|
|
'JE' => 'Jersey', |
706
|
|
|
'JO' => 'Jordan', |
707
|
|
|
'KZ' => 'Kazakhstan', |
708
|
|
|
'KE' => 'Kenya', |
709
|
|
|
'KI' => 'Kiribati', |
710
|
|
|
'KW' => 'Kuwait', |
711
|
|
|
'KG' => 'Kyrgyzstan', |
712
|
|
|
'LA' => 'Lao People\'s Democratic Republic', |
713
|
|
|
'LV' => 'Latvia', |
714
|
|
|
'LB' => 'Lebanon', |
715
|
|
|
'LS' => 'Lesotho', |
716
|
|
|
'LR' => 'Liberia', |
717
|
|
|
'LY' => 'Libyan Arab Jamahiriya', |
718
|
|
|
'LI' => 'Liechtenstein', |
719
|
|
|
'LT' => 'Lithuania', |
720
|
|
|
'LU' => 'Luxembourg', |
721
|
|
|
'MO' => 'Macau', |
722
|
|
|
'MK' => 'Macedonia', |
723
|
|
|
'MG' => 'Madagascar', |
724
|
|
|
'MW' => 'Malawi', |
725
|
|
|
'MY' => 'Malaysia', |
726
|
|
|
'MV' => 'Maldives', |
727
|
|
|
'ML' => 'Mali', |
728
|
|
|
'MT' => 'Malta', |
729
|
|
|
'MH' => 'Marshall Islands', |
730
|
|
|
'MQ' => 'Martinique', |
731
|
|
|
'MR' => 'Mauritania', |
732
|
|
|
'MU' => 'Mauritius', |
733
|
|
|
'YT' => 'Mayotte', |
734
|
|
|
'MX' => 'Mexico', |
735
|
|
|
'FM' => 'Micronesia', |
736
|
|
|
'MD' => 'Moldova, Republic of', |
737
|
|
|
'MC' => 'Monaco', |
738
|
|
|
'MN' => 'Mongolia', |
739
|
|
|
'ME' => 'Montenegro', |
740
|
|
|
'MS' => 'Montserrat', |
741
|
|
|
'MA' => 'Morocco', |
742
|
|
|
'MZ' => 'Mozambique', |
743
|
|
|
'MM' => 'Myanmar', |
744
|
|
|
'NA' => 'Namibia', |
745
|
|
|
'NR' => 'Nauru', |
746
|
|
|
'NP' => 'Nepal', |
747
|
|
|
'NL' => 'Netherlands', |
748
|
|
|
'AN' => 'Netherlands Antilles', |
749
|
|
|
'NC' => 'New Caledonia', |
750
|
|
|
'NZ' => 'New Zealand', |
751
|
|
|
'NI' => 'Nicaragua', |
752
|
|
|
'NE' => 'Niger', |
753
|
|
|
'NG' => 'Nigeria', |
754
|
|
|
'NU' => 'Niue', |
755
|
|
|
'NF' => 'Norfolk Island', |
756
|
|
|
'KP' => 'North Korea', |
757
|
|
|
'MP' => 'Northern Mariana Islands', |
758
|
|
|
'NO' => 'Norway', |
759
|
|
|
'OM' => 'Oman', |
760
|
|
|
'PK' => 'Pakistan', |
761
|
|
|
'PW' => 'Palau', |
762
|
|
|
'PS' => 'Palestinian Territories', |
763
|
|
|
'PA' => 'Panama', |
764
|
|
|
'PG' => 'Papua New Guinea', |
765
|
|
|
'PY' => 'Paraguay', |
766
|
|
|
'PE' => 'Peru', |
767
|
|
|
'PH' => 'Philippines', |
768
|
|
|
'PN' => 'Pitcairn Island', |
769
|
|
|
'PL' => 'Poland', |
770
|
|
|
'PT' => 'Portugal', |
771
|
|
|
'PR' => 'Puerto Rico', |
772
|
|
|
'QA' => 'Qatar', |
773
|
|
|
'XK' => 'Republic of Kosovo', |
774
|
|
|
'RE' => 'Reunion Island', |
775
|
|
|
'RO' => 'Romania', |
776
|
|
|
'RU' => 'Russian Federation', |
777
|
|
|
'RW' => 'Rwanda', |
778
|
|
|
'BL' => 'Saint Barthélemy', |
779
|
|
|
'SH' => 'Saint Helena', |
780
|
|
|
'KN' => 'Saint Kitts and Nevis', |
781
|
|
|
'LC' => 'Saint Lucia', |
782
|
|
|
'MF' => 'Saint Martin (French)', |
783
|
|
|
'SX' => 'Saint Martin (Dutch)', |
784
|
|
|
'PM' => 'Saint Pierre and Miquelon', |
785
|
|
|
'VC' => 'Saint Vincent and the Grenadines', |
786
|
|
|
'SM' => 'San Marino', |
787
|
|
|
'ST' => 'São Tomé and Príncipe', |
788
|
|
|
'SA' => 'Saudi Arabia', |
789
|
|
|
'SN' => 'Senegal', |
790
|
|
|
'RS' => 'Serbia', |
791
|
|
|
'SC' => 'Seychelles', |
792
|
|
|
'SL' => 'Sierra Leone', |
793
|
|
|
'SG' => 'Singapore', |
794
|
|
|
'SK' => 'Slovak Republic', |
795
|
|
|
'SI' => 'Slovenia', |
796
|
|
|
'SB' => 'Solomon Islands', |
797
|
|
|
'SO' => 'Somalia', |
798
|
|
|
'ZA' => 'South Africa', |
799
|
|
|
'GS' => 'South Georgia', |
800
|
|
|
'KR' => 'South Korea', |
801
|
|
|
'SS' => 'South Sudan', |
802
|
|
|
'ES' => 'Spain', |
803
|
|
|
'LK' => 'Sri Lanka', |
804
|
|
|
'SD' => 'Sudan', |
805
|
|
|
'SR' => 'Suriname', |
806
|
|
|
'SJ' => 'Svalbard and Jan Mayen Islands', |
807
|
|
|
'SZ' => 'Swaziland', |
808
|
|
|
'SE' => 'Sweden', |
809
|
|
|
'CH' => 'Switzerland', |
810
|
|
|
'SY' => 'Syrian Arab Republic', |
811
|
|
|
'TW' => 'Taiwan', |
812
|
|
|
'TJ' => 'Tajikistan', |
813
|
|
|
'TZ' => 'Tanzania', |
814
|
|
|
'TH' => 'Thailand', |
815
|
|
|
'TL' => 'Timor-Leste', |
816
|
|
|
'TG' => 'Togo', |
817
|
|
|
'TK' => 'Tokelau', |
818
|
|
|
'TO' => 'Tonga', |
819
|
|
|
'TT' => 'Trinidad and Tobago', |
820
|
|
|
'TN' => 'Tunisia', |
821
|
|
|
'TR' => 'Turkey', |
822
|
|
|
'TM' => 'Turkmenistan', |
823
|
|
|
'TC' => 'Turks and Caicos Islands', |
824
|
|
|
'TV' => 'Tuvalu', |
825
|
|
|
'UG' => 'Uganda', |
826
|
|
|
'UA' => 'Ukraine', |
827
|
|
|
'AE' => 'United Arab Emirates', |
828
|
|
|
'UY' => 'Uruguay', |
829
|
|
|
'UM' => 'US Minor Outlying Islands', |
830
|
|
|
'UZ' => 'Uzbekistan', |
831
|
|
|
'VU' => 'Vanuatu', |
832
|
|
|
'VE' => 'Venezuela', |
833
|
|
|
'VN' => 'Vietnam', |
834
|
|
|
'VG' => 'Virgin Islands (British)', |
835
|
|
|
'VI' => 'Virgin Islands (USA)', |
836
|
|
|
'WF' => 'Wallis and Futuna Islands', |
837
|
|
|
'EH' => 'Western Sahara', |
838
|
|
|
'WS' => 'Western Samoa', |
839
|
|
|
'YE' => 'Yemen', |
840
|
|
|
'ZM' => 'Zambia', |
841
|
|
|
'ZW' => 'Zimbabwe', |
842
|
|
|
); |
843
|
|
|
} |
844
|
|
|
return $countries; |
845
|
|
|
} |
846
|
|
|
|
847
|
|
|
function monsterinsights_get_api_url(){ |
848
|
|
|
return apply_filters( 'monsterinsights_get_api_url', 'www.monsterinsights.com/v1/' ); |
849
|
|
|
} |
850
|
|
|
|
851
|
|
|
function monsterinsights_get_licensing_url(){ |
852
|
|
|
return apply_filters( 'monsterinsights_get_licensing_url', 'https://www.monsterinsights.com' ); |
853
|
|
|
} |
854
|
|
|
|
855
|
|
|
function monsterinsights_is_wp_seo_active( ) { |
856
|
|
|
$wp_seo_active = false; // @todo: improve this check. This is from old Yoast code. |
857
|
|
|
|
858
|
|
|
// Makes sure is_plugin_active is available when called from front end |
859
|
|
|
include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
860
|
|
|
if ( is_plugin_active( 'wordpress-seo/wp-seo.php' ) || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ) ) { |
861
|
|
|
$wp_seo_active = true; |
862
|
|
|
} |
863
|
|
|
return $wp_seo_active; |
864
|
|
|
} |
865
|
|
|
|
866
|
|
|
function monsterinsights_get_asset_version() { |
867
|
|
|
if ( monsterinsights_is_debug_mode() || ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ) { |
868
|
|
|
return time(); |
869
|
|
|
} else { |
870
|
|
|
return MONSTERINSIGHTS_VERSION; |
871
|
|
|
} |
872
|
|
|
} |
873
|
|
|
|
874
|
|
|
function monsterinsights_is_debug_mode() { |
875
|
|
|
$debug_mode = false; |
876
|
|
|
if ( defined( 'MONSTERINSIGHTS_DEBUG_MODE' ) && MONSTERINSIGHTS_DEBUG_MODE ) { |
|
|
|
|
877
|
|
|
$debug_mode = true; |
878
|
|
|
} |
879
|
|
|
|
880
|
|
|
if ( monsterinsights_get_option( 'debug_mode', false ) ) { |
881
|
|
|
$debug_mode = true; |
882
|
|
|
} |
883
|
|
|
|
884
|
|
|
return apply_filters( 'monsterinsights_is_debug_mode', $debug_mode ); |
885
|
|
|
} |
886
|
|
|
|
887
|
|
|
function monsterinsights_is_network_active() { |
888
|
|
|
if ( ! function_exists( 'is_plugin_active_for_network' ) ) { |
889
|
|
|
require_once( ABSPATH . '/wp-admin/includes/plugin.php' ); |
890
|
|
|
} |
891
|
|
|
|
892
|
|
|
if ( is_multisite() && is_plugin_active_for_network( plugin_basename( MONSTERINSIGHTS_PLUGIN_FILE ) ) ) { |
893
|
|
|
return true; |
894
|
|
|
} else { |
895
|
|
|
return false; |
896
|
|
|
} |
897
|
|
|
} |
898
|
|
|
|
899
|
|
|
if ( ! function_exists ( 'remove_class_filter' ) ) { |
900
|
|
|
/** |
901
|
|
|
* Remove Class Filter Without Access to Class Object |
902
|
|
|
* |
903
|
|
|
* In order to use the core WordPress remove_filter() on a filter added with the callback |
904
|
|
|
* to a class, you either have to have access to that class object, or it has to be a call |
905
|
|
|
* to a static method. This method allows you to remove filters with a callback to a class |
906
|
|
|
* you don't have access to. |
907
|
|
|
* |
908
|
|
|
* Works with WordPress 1.2 - 4.7+ |
909
|
|
|
* |
910
|
|
|
* @param string $tag Filter to remove |
911
|
|
|
* @param string $class_name Class name for the filter's callback |
912
|
|
|
* @param string $method_name Method name for the filter's callback |
913
|
|
|
* @param int $priority Priority of the filter (default 10) |
914
|
|
|
* |
915
|
|
|
* @return bool Whether the function is removed. |
916
|
|
|
*/ |
917
|
|
|
function remove_class_filter( $tag, $class_name = '', $method_name = '', $priority = 10 ) { |
918
|
|
|
global $wp_filter; |
919
|
|
|
// Check that filter actually exists first |
920
|
|
|
if ( ! isset( $wp_filter[ $tag ] ) ) return FALSE; |
921
|
|
|
/** |
922
|
|
|
* If filter config is an object, means we're using WordPress 4.7+ and the config is no longer |
923
|
|
|
* a simple array, rather it is an object that implements the ArrayAccess interface. |
924
|
|
|
* |
925
|
|
|
* To be backwards compatible, we set $callbacks equal to the correct array as a reference (so $wp_filter is updated) |
926
|
|
|
* |
927
|
|
|
* @see https://make.wordpress.org/core/2016/09/08/wp_hook-next-generation-actions-and-filters/ |
928
|
|
|
*/ |
929
|
|
|
if ( is_object( $wp_filter[ $tag ] ) && isset( $wp_filter[ $tag ]->callbacks ) ) { |
930
|
|
|
$callbacks = &$wp_filter[ $tag ]->callbacks; |
931
|
|
|
} else { |
932
|
|
|
$callbacks = &$wp_filter[ $tag ]; |
933
|
|
|
} |
934
|
|
|
// Exit if there aren't any callbacks for specified priority |
935
|
|
|
if ( ! isset( $callbacks[ $priority ] ) || empty( $callbacks[ $priority ] ) ) return FALSE; |
936
|
|
|
// Loop through each filter for the specified priority, looking for our class & method |
937
|
|
|
foreach( (array) $callbacks[ $priority ] as $filter_id => $filter ) { |
938
|
|
|
// Filter should always be an array - array( $this, 'method' ), if not goto next |
939
|
|
|
if ( ! isset( $filter[ 'function' ] ) || ! is_array( $filter[ 'function' ] ) ) continue; |
940
|
|
|
// If first value in array is not an object, it can't be a class |
941
|
|
|
if ( ! is_object( $filter[ 'function' ][ 0 ] ) ) continue; |
942
|
|
|
// Method doesn't match the one we're looking for, goto next |
943
|
|
|
if ( $filter[ 'function' ][ 1 ] !== $method_name ) continue; |
944
|
|
|
// Method matched, now let's check the Class |
945
|
|
|
if ( get_class( $filter[ 'function' ][ 0 ] ) === $class_name ) { |
946
|
|
|
// Now let's remove it from the array |
947
|
|
|
unset( $callbacks[ $priority ][ $filter_id ] ); |
948
|
|
|
// and if it was the only filter in that priority, unset that priority |
949
|
|
|
if ( empty( $callbacks[ $priority ] ) ) unset( $callbacks[ $priority ] ); |
950
|
|
|
// and if the only filter for that tag, set the tag to an empty array |
951
|
|
|
if ( empty( $callbacks ) ) $callbacks = array(); |
952
|
|
|
// If using WordPress older than 4.7 |
953
|
|
|
if ( ! is_object( $wp_filter[ $tag ] ) ) { |
954
|
|
|
// Remove this filter from merged_filters, which specifies if filters have been sorted |
955
|
|
|
unset( $GLOBALS[ 'merged_filters' ][ $tag ] ); |
956
|
|
|
} |
957
|
|
|
return TRUE; |
958
|
|
|
} |
959
|
|
|
} |
960
|
|
|
return FALSE; |
961
|
|
|
} |
962
|
|
|
} // End function exists |
963
|
|
|
|
964
|
|
|
if ( ! function_exists ( 'remove_class_action' ) ) { |
965
|
|
|
/** |
966
|
|
|
* Remove Class Action Without Access to Class Object |
967
|
|
|
* |
968
|
|
|
* In order to use the core WordPress remove_action() on an action added with the callback |
969
|
|
|
* to a class, you either have to have access to that class object, or it has to be a call |
970
|
|
|
* to a static method. This method allows you to remove actions with a callback to a class |
971
|
|
|
* you don't have access to. |
972
|
|
|
* |
973
|
|
|
* Works with WordPress 1.2 - 4.7+ |
974
|
|
|
* |
975
|
|
|
* @param string $tag Action to remove |
976
|
|
|
* @param string $class_name Class name for the action's callback |
977
|
|
|
* @param string $method_name Method name for the action's callback |
978
|
|
|
* @param int $priority Priority of the action (default 10) |
979
|
|
|
* |
980
|
|
|
* @return bool Whether the function is removed. |
981
|
|
|
*/ |
982
|
|
|
function remove_class_action( $tag, $class_name = '', $method_name = '', $priority = 10 ) { |
983
|
|
|
remove_class_filter( $tag, $class_name, $method_name, $priority ); |
984
|
|
|
} |
985
|
|
|
} // End function exists |
986
|
|
|
|
987
|
|
|
/** |
988
|
|
|
* Format a big number, instead of 1000000 you get 1.0M, works with billions also. |
989
|
|
|
* |
990
|
|
|
* @param int $number |
991
|
|
|
* @param int $precision |
992
|
|
|
* |
993
|
|
|
* @return string |
994
|
|
|
*/ |
995
|
|
|
function monsterinsights_round_number( $number, $precision = 2 ) { |
996
|
|
|
|
997
|
|
|
if ( $number < 1000000 ) { |
998
|
|
|
// Anything less than a million |
999
|
|
|
$number = number_format_i18n( $number ); |
1000
|
|
|
} else if ( $number < 1000000000 ) { |
1001
|
|
|
// Anything less than a billion |
1002
|
|
|
$number = number_format_i18n( $number / 1000000, $precision ) . 'M'; |
1003
|
|
|
} else { |
1004
|
|
|
// At least a billion |
1005
|
|
|
$number = number_format_i18n( $number / 1000000000, $precision ) . 'B'; |
1006
|
|
|
} |
1007
|
|
|
|
1008
|
|
|
return $number; |
1009
|
|
|
} |
1010
|
|
|
|