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_is_page_reload() { |
18
|
|
|
// Can't be a refresh without having a referrer |
19
|
|
|
if ( ! isset( $_SERVER['HTTP_REFERER'] ) ) { |
20
|
|
|
return false; |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
// IF the referrer is identical to the current page request, then it's a refresh |
24
|
|
|
return ( parse_url( $_SERVER['HTTP_REFERER'], PHP_URL_PATH ) === parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH ) ); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
|
28
|
|
|
function monsterinsights_track_user( $user_id = -1 ) { |
29
|
|
|
if ( $user_id === -1 ) { |
30
|
|
|
$user = wp_get_current_user(); |
31
|
|
|
} else { |
32
|
|
|
$user = new WP_User( $user_id ); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
$track_user = true; |
36
|
|
|
$roles = monsterinsights_get_option( 'ignore_users', array() ); |
37
|
|
|
|
38
|
|
|
if ( ! empty( $roles ) && is_array( $roles ) ) { |
|
|
|
|
39
|
|
|
foreach ( $roles as $role ) { |
40
|
|
|
if ( is_string( $role ) ) { |
41
|
|
|
if ( user_can( $user, $role ) ) { |
42
|
|
|
$track_user = false; |
43
|
|
|
break; |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
$track_super_admin = apply_filters( 'monsterinsights_track_super_admins', false ); |
50
|
|
|
if ( $track_super_admin === false && is_multisite() && is_super_admin() ) { |
51
|
|
|
$track_user = false; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
// or if UA code is not entered |
55
|
|
|
$ua_code = monsterinsights_get_ua(); |
56
|
|
|
if ( empty( $ua_code ) ) { |
57
|
|
|
$track_user = false; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
return apply_filters( 'monsterinsights_track_user', $track_user, $user ); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
function monsterinsights_get_client_id( $payment_id = false ) { |
64
|
|
|
if ( is_object( $payment_id ) ) { |
65
|
|
|
$payment_id = $payment_id->ID; |
66
|
|
|
} |
67
|
|
|
$user_cid = monsterinsights_get_uuid(); |
68
|
|
|
$saved_cid = ! empty( $payment_id ) ? get_post_meta( $payment_id, '_yoast_gau_uuid', true ) : false; |
69
|
|
|
|
70
|
|
|
if ( ! empty( $payment_id ) && ! empty( $saved_cid ) ) { |
71
|
|
|
return $saved_cid; |
72
|
|
|
} else if ( ! empty( $user_cid ) ) { |
73
|
|
|
return $user_cid; |
74
|
|
|
} else { |
75
|
|
|
return monsterinsights_generate_uuid(); |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Returns the Google Analytics clientId to store for later use |
81
|
|
|
* |
82
|
|
|
* @since 6.0.0 |
83
|
|
|
* |
84
|
|
|
* @link https://developers.google.com/analytics/devguides/collection/analyticsjs/domains#getClientId |
85
|
|
|
* |
86
|
|
|
* @return bool|string False if cookie isn't set, GA UUID otherwise |
87
|
|
|
*/ |
88
|
|
|
function monsterinsights_get_uuid() { |
89
|
|
|
if ( empty( $_COOKIE['_ga'] ) ) { |
90
|
|
|
return false; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Example cookie formats: |
95
|
|
|
* |
96
|
|
|
* GA1.2.XXXXXXX.YYYYY |
97
|
|
|
* _ga=1.2.XXXXXXX.YYYYYY -- We want the XXXXXXX.YYYYYY part |
98
|
|
|
* |
99
|
|
|
*/ |
100
|
|
|
|
101
|
|
|
$ga_cookie = $_COOKIE['_ga']; |
102
|
|
|
$cookie_parts = explode('.', $ga_cookie ); |
103
|
|
|
if ( is_array( $cookie_parts ) && ! empty( $cookie_parts[2] ) && ! empty( $cookie_parts[3] ) ) { |
104
|
|
|
$uuid = (string) $cookie_parts[2] . '.' . (string) $cookie_parts[3]; |
105
|
|
|
if ( is_string( $uuid ) ) { |
|
|
|
|
106
|
|
|
return $uuid; |
107
|
|
|
} else { |
108
|
|
|
return false; |
109
|
|
|
} |
110
|
|
|
} else { |
111
|
|
|
return false; |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* Generate UUID v4 function - needed to generate a CID when one isn't available |
118
|
|
|
* |
119
|
|
|
* @link http://www.stumiller.me/implementing-google-analytics-measurement-protocol-in-php-and-wordpress/ |
120
|
|
|
* |
121
|
|
|
* @since 6.1.8 |
122
|
|
|
* @return string |
123
|
|
|
*/ |
124
|
|
|
function monsterinsights_generate_uuid() { |
125
|
|
|
|
126
|
|
|
return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', |
127
|
|
|
|
128
|
|
|
// 32 bits for "time_low" |
129
|
|
|
mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), |
130
|
|
|
|
131
|
|
|
// 16 bits for "time_mid" |
132
|
|
|
mt_rand( 0, 0xffff ), |
133
|
|
|
|
134
|
|
|
// 16 bits for "time_hi_and_version", |
135
|
|
|
// four most significant bits holds version number 4 |
136
|
|
|
mt_rand( 0, 0x0fff ) | 0x4000, |
137
|
|
|
|
138
|
|
|
// 16 bits, 8 bits for "clk_seq_hi_res", |
139
|
|
|
// 8 bits for "clk_seq_low", |
140
|
|
|
// two most significant bits holds zero and one for variant DCE1.1 |
141
|
|
|
mt_rand( 0, 0x3fff ) | 0x8000, |
142
|
|
|
|
143
|
|
|
// 48 bits for "node" |
144
|
|
|
mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ) |
145
|
|
|
); |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* Returns the Google Analytics clientId to store for later use |
150
|
|
|
* |
151
|
|
|
* @since 6.0.0 |
152
|
|
|
* |
153
|
|
|
* @return GA UUID or error code. |
|
|
|
|
154
|
|
|
*/ |
155
|
|
|
function monsterinsights_get_cookie( $debug = false ) { |
156
|
|
|
if ( empty( $_COOKIE['_ga'] ) ) { |
157
|
|
|
return ( $debug ) ? 'FCE' : false; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
$ga_cookie = $_COOKIE['_ga']; |
161
|
|
|
$cookie_parts = explode('.', $ga_cookie ); |
162
|
|
|
if ( is_array( $cookie_parts ) && ! empty( $cookie_parts[2] ) && ! empty( $cookie_parts[3] ) ) { |
163
|
|
|
$uuid = (string) $cookie_parts[2] . '.' . (string) $cookie_parts[3]; |
164
|
|
|
if ( is_string( $uuid ) ) { |
|
|
|
|
165
|
|
|
return $ga_cookie; |
166
|
|
|
} else { |
167
|
|
|
return ( $debug ) ? 'FA' : false; |
168
|
|
|
} |
169
|
|
|
} else { |
170
|
|
|
return ( $debug ) ? 'FAE' : false; |
171
|
|
|
} |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
|
175
|
|
|
function monsterinsights_generate_ga_client_id() { |
176
|
|
|
return rand(100000000,999999999) . '.' . time(); |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* Hours between two timestamps. |
182
|
|
|
* |
183
|
|
|
* @access public |
184
|
|
|
* @since 6.0.0 |
185
|
|
|
* |
186
|
|
|
* @param string $start Timestamp of start time (in seconds since Unix). |
187
|
|
|
* @param string $stop Timestamp of stop time (in seconds since Unix). Optional. If not used, current_time (in UTC 0 / GMT ) is used. |
188
|
|
|
* |
189
|
|
|
* @return int Hours between the two timestamps, rounded. |
190
|
|
|
*/ |
191
|
|
|
function monsterinsights_hours_between( $start, $stop = false ) { |
192
|
|
|
if ( $stop === false ) { |
193
|
|
|
$stop = time(); |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
$diff = (int) abs( $stop - $start ); |
197
|
|
|
$hours = round( $diff / HOUR_IN_SECONDS ); |
198
|
|
|
return $hours; |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* Is This MonsterInsights Pro? |
203
|
|
|
* |
204
|
|
|
* We use this function monsterinsights_to determine if the install is a pro version or a lite version install of MonsterInsights. |
205
|
|
|
* If the install is a lite version we disable the install from admin functionality[1] for addons as WordPress.org requires us to, |
206
|
|
|
* 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 |
207
|
|
|
* 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 |
208
|
|
|
* as the lite and pro versions of our plugin have different constants (and names for those constants) you can declare and use. |
209
|
|
|
* |
210
|
|
|
* [1] Note: This is not "feature-locking" under GPL guidelines but rather something WordPress.org requires us to do to stay |
211
|
|
|
* in compliance with their rules. We wish we didn't have to do this, as in our oppinion this diminishes the user experience |
212
|
|
|
* 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. |
213
|
|
|
* If WordPress.org ever changes their mind on this subject, we'd totally turn on that feature for Lite installs in a heartbeat. |
214
|
|
|
* |
215
|
|
|
* @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 |
216
|
|
|
* 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 |
217
|
|
|
* 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 |
218
|
|
|
* Travis-CI but also when installing addons to test with the Lite version). Also this would allow for a better user experience for users |
219
|
|
|
* who want that feature. |
220
|
|
|
* |
221
|
|
|
* @since 6.0.0 |
222
|
|
|
* @access public |
223
|
|
|
* |
224
|
|
|
* @return bool True if pro version. |
225
|
|
|
*/ |
226
|
|
|
function monsterinsights_is_pro_version() { |
227
|
|
|
if ( class_exists( 'MonsterInsights' ) ) { |
228
|
|
|
return true; |
229
|
|
|
} else { |
230
|
|
|
return false; |
231
|
|
|
} |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* Get the user roles of this WordPress blog |
237
|
|
|
* |
238
|
|
|
* @return array |
239
|
|
|
*/ |
240
|
|
|
function monsterinsights_get_roles() { |
241
|
|
|
global $wp_roles; |
242
|
|
|
|
243
|
|
|
$all_roles = $wp_roles->roles; |
244
|
|
|
$roles = array(); |
245
|
|
|
|
246
|
|
|
/** |
247
|
|
|
* Filter: 'editable_roles' - Allows filtering of the roles shown within the plugin (and elsewhere in WP as it's a WP filter) |
248
|
|
|
* |
249
|
|
|
* @api array $all_roles |
250
|
|
|
*/ |
251
|
|
|
$editable_roles = apply_filters( 'editable_roles', $all_roles ); |
252
|
|
|
|
253
|
|
|
foreach ( $editable_roles as $id => $name ) { |
254
|
|
|
$roles[ $id ] = translate_user_role( $name['name'] ); |
255
|
|
|
} |
256
|
|
|
|
257
|
|
|
return $roles; |
258
|
|
|
} |
259
|
|
|
|
260
|
|
|
/** |
261
|
|
|
* Get the user roles which can manage options. Used to prevent these roles from getting unselected in the settings. |
262
|
|
|
* |
263
|
|
|
* @return array |
264
|
|
|
*/ |
265
|
|
|
function monsterinsights_get_manage_options_roles() { |
266
|
|
|
global $wp_roles; |
267
|
|
|
|
268
|
|
|
$all_roles = $wp_roles->roles; |
269
|
|
|
$roles = array(); |
270
|
|
|
|
271
|
|
|
/** |
272
|
|
|
* Filter: 'editable_roles' - Allows filtering of the roles shown within the plugin (and elsewhere in WP as it's a WP filter) |
273
|
|
|
* |
274
|
|
|
* @api array $all_roles |
275
|
|
|
*/ |
276
|
|
|
$editable_roles = apply_filters( 'editable_roles', $all_roles ); |
277
|
|
|
|
278
|
|
|
foreach ( $editable_roles as $id => $role ) { |
279
|
|
|
if ( isset( $role['capabilities']['manage_options'] ) && $role['capabilities']['manage_options'] ) { |
280
|
|
|
$roles[ $id ] = translate_user_role( $role['name'] ); |
281
|
|
|
} |
282
|
|
|
} |
283
|
|
|
|
284
|
|
|
return $roles; |
285
|
|
|
} |
286
|
|
|
|
287
|
|
|
/** Need to escape in advance of passing in $text. */ |
288
|
|
|
function monsterinsights_get_message( $type = 'error', $text = '' ) { |
289
|
|
|
$div = ''; |
|
|
|
|
290
|
|
|
if ( $type === 'error' || $type === 'alert' || $type === 'success' || $type === 'info' ) { |
291
|
|
|
$base = MonsterInsights(); |
292
|
|
|
return $base->notices->display_inline_notice( 'monsterinsights_standard_notice', '', $text, $type, false, array( 'skip_message_escape' => true ) ); |
293
|
|
|
} else { |
294
|
|
|
return ''; |
295
|
|
|
} |
296
|
|
|
} |
297
|
|
|
|
298
|
|
|
function monsterinsights_is_dev_url( $url = '' ) { |
299
|
|
|
$is_local_url = false; |
300
|
|
|
// Trim it up |
301
|
|
|
$url = strtolower( trim( $url ) ); |
302
|
|
|
// Need to get the host...so let's add the scheme so we can use parse_url |
303
|
|
|
if ( false === strpos( $url, 'http://' ) && false === strpos( $url, 'https://' ) ) { |
304
|
|
|
$url = 'http://' . $url; |
305
|
|
|
} |
306
|
|
|
$url_parts = parse_url( $url ); |
307
|
|
|
$host = ! empty( $url_parts['host'] ) ? $url_parts['host'] : false; |
308
|
|
|
if ( ! empty( $url ) && ! empty( $host ) ) { |
309
|
|
|
if ( false !== ip2long( $host ) ) { |
310
|
|
|
if ( ! filter_var( $host, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) ) { |
311
|
|
|
$is_local_url = true; |
312
|
|
|
} |
313
|
|
|
} else if ( 'localhost' === $host ) { |
314
|
|
|
$is_local_url = true; |
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
$tlds_to_check = array( '.local', ':8888', ':8080', ':8081', '.invalid', '.example', '.test' ); |
318
|
|
|
foreach ( $tlds_to_check as $tld ) { |
319
|
|
|
if ( false !== strpos( $host, $tld ) ) { |
320
|
|
|
$is_local_url = true; |
321
|
|
|
break; |
322
|
|
|
} |
323
|
|
|
|
324
|
|
|
} |
325
|
|
|
if ( substr_count( $host, '.' ) > 1 ) { |
326
|
|
|
$subdomains_to_check = array( 'dev.', '*.staging.', 'beta.', 'test.' ); |
327
|
|
|
foreach ( $subdomains_to_check as $subdomain ) { |
328
|
|
|
$subdomain = str_replace( '.', '(.)', $subdomain ); |
329
|
|
|
$subdomain = str_replace( array( '*', '(.)' ), '(.*)', $subdomain ); |
330
|
|
|
if ( preg_match( '/^(' . $subdomain . ')/', $host ) ) { |
331
|
|
|
$is_local_url = true; |
332
|
|
|
break; |
333
|
|
|
} |
334
|
|
|
} |
335
|
|
|
} |
336
|
|
|
} |
337
|
|
|
return $is_local_url; |
338
|
|
|
} |
339
|
|
|
|
340
|
|
|
// Set cookie to expire in 2 years |
341
|
|
|
function monsterinsights_get_cookie_expiration_date( $time ) { |
342
|
|
|
return date('D, j F Y H:i:s', time() + $time ); |
343
|
|
|
} |
344
|
|
|
|
345
|
|
|
function monsterinsights_string_ends_with( $string, $ending ) { |
346
|
|
|
$strlen = strlen($string); |
347
|
|
|
$endinglen = strlen($ending); |
348
|
|
|
if ( $endinglen > $strlen ) { |
349
|
|
|
return false; |
350
|
|
|
} |
351
|
|
|
return substr_compare( $string, $ending, $strlen - $endinglen, $endinglen) === 0; |
352
|
|
|
} |
353
|
|
|
|
354
|
|
|
function monsterinsights_string_starts_with( $string, $start ) { |
355
|
|
|
if ( ! is_string( $string ) || ! is_string( $start ) ) { |
356
|
|
|
return false; |
357
|
|
|
} |
358
|
|
|
|
359
|
|
|
return substr( $string, 0, strlen( $start ) ) === $start; |
360
|
|
|
} |
361
|
|
|
|
362
|
|
|
function monsterinsights_get_country_list( $translated = false ) { |
363
|
|
|
if ( $translated ) { |
364
|
|
|
$countries = array( |
365
|
|
|
'' => '', |
366
|
|
|
'US' => __( 'United States', 'google-analytics-for-wordpress' ), |
367
|
|
|
'CA' => __( 'Canada', 'google-analytics-for-wordpress' ), |
368
|
|
|
'GB' => __( 'United Kingdom', 'google-analytics-for-wordpress' ), |
369
|
|
|
'AF' => __( 'Afghanistan', 'google-analytics-for-wordpress' ), |
370
|
|
|
'AX' => __( 'Åland Islands', 'google-analytics-for-wordpress' ), |
371
|
|
|
'AL' => __( 'Albania', 'google-analytics-for-wordpress' ), |
372
|
|
|
'DZ' => __( 'Algeria', 'google-analytics-for-wordpress' ), |
373
|
|
|
'AS' => __( 'American Samoa', 'google-analytics-for-wordpress' ), |
374
|
|
|
'AD' => __( 'Andorra', 'google-analytics-for-wordpress' ), |
375
|
|
|
'AO' => __( 'Angola', 'google-analytics-for-wordpress' ), |
376
|
|
|
'AI' => __( 'Anguilla', 'google-analytics-for-wordpress' ), |
377
|
|
|
'AQ' => __( 'Antarctica', 'google-analytics-for-wordpress' ), |
378
|
|
|
'AG' => __( 'Antigua and Barbuda', 'google-analytics-for-wordpress' ), |
379
|
|
|
'AR' => __( 'Argentina', 'google-analytics-for-wordpress' ), |
380
|
|
|
'AM' => __( 'Armenia', 'google-analytics-for-wordpress' ), |
381
|
|
|
'AW' => __( 'Aruba', 'google-analytics-for-wordpress' ), |
382
|
|
|
'AU' => __( 'Australia', 'google-analytics-for-wordpress' ), |
383
|
|
|
'AT' => __( 'Austria', 'google-analytics-for-wordpress' ), |
384
|
|
|
'AZ' => __( 'Azerbaijan', 'google-analytics-for-wordpress' ), |
385
|
|
|
'BS' => __( 'Bahamas', 'google-analytics-for-wordpress' ), |
386
|
|
|
'BH' => __( 'Bahrain', 'google-analytics-for-wordpress' ), |
387
|
|
|
'BD' => __( 'Bangladesh', 'google-analytics-for-wordpress' ), |
388
|
|
|
'BB' => __( 'Barbados', 'google-analytics-for-wordpress' ), |
389
|
|
|
'BY' => __( 'Belarus', 'google-analytics-for-wordpress' ), |
390
|
|
|
'BE' => __( 'Belgium', 'google-analytics-for-wordpress' ), |
391
|
|
|
'BZ' => __( 'Belize', 'google-analytics-for-wordpress' ), |
392
|
|
|
'BJ' => __( 'Benin', 'google-analytics-for-wordpress' ), |
393
|
|
|
'BM' => __( 'Bermuda', 'google-analytics-for-wordpress' ), |
394
|
|
|
'BT' => __( 'Bhutan', 'google-analytics-for-wordpress' ), |
395
|
|
|
'BO' => __( 'Bolivia', 'google-analytics-for-wordpress' ), |
396
|
|
|
'BQ' => __( 'Bonaire, Saint Eustatius and Saba', 'google-analytics-for-wordpress' ), |
397
|
|
|
'BA' => __( 'Bosnia and Herzegovina', 'google-analytics-for-wordpress' ), |
398
|
|
|
'BW' => __( 'Botswana', 'google-analytics-for-wordpress' ), |
399
|
|
|
'BV' => __( 'Bouvet Island', 'google-analytics-for-wordpress' ), |
400
|
|
|
'BR' => __( 'Brazil', 'google-analytics-for-wordpress' ), |
401
|
|
|
'IO' => __( 'British Indian Ocean Territory', 'google-analytics-for-wordpress' ), |
402
|
|
|
'BN' => __( 'Brunei Darrussalam', 'google-analytics-for-wordpress' ), |
403
|
|
|
'BG' => __( 'Bulgaria', 'google-analytics-for-wordpress' ), |
404
|
|
|
'BF' => __( 'Burkina Faso', 'google-analytics-for-wordpress' ), |
405
|
|
|
'BI' => __( 'Burundi', 'google-analytics-for-wordpress' ), |
406
|
|
|
'KH' => __( 'Cambodia', 'google-analytics-for-wordpress' ), |
407
|
|
|
'CM' => __( 'Cameroon', 'google-analytics-for-wordpress' ), |
408
|
|
|
'CV' => __( 'Cape Verde', 'google-analytics-for-wordpress' ), |
409
|
|
|
'KY' => __( 'Cayman Islands', 'google-analytics-for-wordpress' ), |
410
|
|
|
'CF' => __( 'Central African Republic', 'google-analytics-for-wordpress' ), |
411
|
|
|
'TD' => __( 'Chad', 'google-analytics-for-wordpress' ), |
412
|
|
|
'CL' => __( 'Chile', 'google-analytics-for-wordpress' ), |
413
|
|
|
'CN' => __( 'China', 'google-analytics-for-wordpress' ), |
414
|
|
|
'CX' => __( 'Christmas Island', 'google-analytics-for-wordpress' ), |
415
|
|
|
'CC' => __( 'Cocos Islands', 'google-analytics-for-wordpress' ), |
416
|
|
|
'CO' => __( 'Colombia', 'google-analytics-for-wordpress' ), |
417
|
|
|
'KM' => __( 'Comoros', 'google-analytics-for-wordpress' ), |
418
|
|
|
'CD' => __( 'Congo, Democratic People\'s Republic', 'google-analytics-for-wordpress' ), |
419
|
|
|
'CG' => __( 'Congo, Republic of', 'google-analytics-for-wordpress' ), |
420
|
|
|
'CK' => __( 'Cook Islands', 'google-analytics-for-wordpress' ), |
421
|
|
|
'CR' => __( 'Costa Rica', 'google-analytics-for-wordpress' ), |
422
|
|
|
'CI' => __( 'Cote d\'Ivoire', 'google-analytics-for-wordpress' ), |
423
|
|
|
'HR' => __( 'Croatia/Hrvatska', 'google-analytics-for-wordpress' ), |
424
|
|
|
'CU' => __( 'Cuba', 'google-analytics-for-wordpress' ), |
425
|
|
|
'CW' => __( 'CuraÇao', 'google-analytics-for-wordpress' ), |
426
|
|
|
'CY' => __( 'Cyprus', 'google-analytics-for-wordpress' ), |
427
|
|
|
'CZ' => __( 'Czechia', 'google-analytics-for-wordpress' ), |
428
|
|
|
'DK' => __( 'Denmark', 'google-analytics-for-wordpress' ), |
429
|
|
|
'DJ' => __( 'Djibouti', 'google-analytics-for-wordpress' ), |
430
|
|
|
'DM' => __( 'Dominica', 'google-analytics-for-wordpress' ), |
431
|
|
|
'DO' => __( 'Dominican Republic', 'google-analytics-for-wordpress' ), |
432
|
|
|
'TP' => __( 'East Timor', 'google-analytics-for-wordpress' ), |
433
|
|
|
'EC' => __( 'Ecuador', 'google-analytics-for-wordpress' ), |
434
|
|
|
'EG' => __( 'Egypt', 'google-analytics-for-wordpress' ), |
435
|
|
|
'GQ' => __( 'Equatorial Guinea', 'google-analytics-for-wordpress' ), |
436
|
|
|
'SV' => __( 'El Salvador', 'google-analytics-for-wordpress' ), |
437
|
|
|
'ER' => __( 'Eritrea', 'google-analytics-for-wordpress' ), |
438
|
|
|
'EE' => __( 'Estonia', 'google-analytics-for-wordpress' ), |
439
|
|
|
'ET' => __( 'Ethiopia', 'google-analytics-for-wordpress' ), |
440
|
|
|
'FK' => __( 'Falkland Islands', 'google-analytics-for-wordpress' ), |
441
|
|
|
'FO' => __( 'Faroe Islands', 'google-analytics-for-wordpress' ), |
442
|
|
|
'FJ' => __( 'Fiji', 'google-analytics-for-wordpress' ), |
443
|
|
|
'FI' => __( 'Finland', 'google-analytics-for-wordpress' ), |
444
|
|
|
'FR' => __( 'France', 'google-analytics-for-wordpress' ), |
445
|
|
|
'GF' => __( 'French Guiana', 'google-analytics-for-wordpress' ), |
446
|
|
|
'PF' => __( 'French Polynesia', 'google-analytics-for-wordpress' ), |
447
|
|
|
'TF' => __( 'French Southern Territories', 'google-analytics-for-wordpress' ), |
448
|
|
|
'GA' => __( 'Gabon', 'google-analytics-for-wordpress' ), |
449
|
|
|
'GM' => __( 'Gambia', 'google-analytics-for-wordpress' ), |
450
|
|
|
'GE' => __( 'Georgia', 'google-analytics-for-wordpress' ), |
451
|
|
|
'DE' => __( 'Germany', 'google-analytics-for-wordpress' ), |
452
|
|
|
'GR' => __( 'Greece', 'google-analytics-for-wordpress' ), |
453
|
|
|
'GH' => __( 'Ghana', 'google-analytics-for-wordpress' ), |
454
|
|
|
'GI' => __( 'Gibraltar', 'google-analytics-for-wordpress' ), |
455
|
|
|
'GL' => __( 'Greenland', 'google-analytics-for-wordpress' ), |
456
|
|
|
'GD' => __( 'Grenada', 'google-analytics-for-wordpress' ), |
457
|
|
|
'GP' => __( 'Guadeloupe', 'google-analytics-for-wordpress' ), |
458
|
|
|
'GU' => __( 'Guam', 'google-analytics-for-wordpress' ), |
459
|
|
|
'GT' => __( 'Guatemala', 'google-analytics-for-wordpress' ), |
460
|
|
|
'GG' => __( 'Guernsey', 'google-analytics-for-wordpress' ), |
461
|
|
|
'GN' => __( 'Guinea', 'google-analytics-for-wordpress' ), |
462
|
|
|
'GW' => __( 'Guinea-Bissau', 'google-analytics-for-wordpress' ), |
463
|
|
|
'GY' => __( 'Guyana', 'google-analytics-for-wordpress' ), |
464
|
|
|
'HT' => __( 'Haiti', 'google-analytics-for-wordpress' ), |
465
|
|
|
'HM' => __( 'Heard and McDonald Islands', 'google-analytics-for-wordpress' ), |
466
|
|
|
'VA' => __( 'Holy See (City Vatican State)', 'google-analytics-for-wordpress' ), |
467
|
|
|
'HN' => __( 'Honduras', 'google-analytics-for-wordpress' ), |
468
|
|
|
'HK' => __( 'Hong Kong', 'google-analytics-for-wordpress' ), |
469
|
|
|
'HU' => __( 'Hungary', 'google-analytics-for-wordpress' ), |
470
|
|
|
'IS' => __( 'Iceland', 'google-analytics-for-wordpress' ), |
471
|
|
|
'IN' => __( 'India', 'google-analytics-for-wordpress' ), |
472
|
|
|
'ID' => __( 'Indonesia', 'google-analytics-for-wordpress' ), |
473
|
|
|
'IR' => __( 'Iran', 'google-analytics-for-wordpress' ), |
474
|
|
|
'IQ' => __( 'Iraq', 'google-analytics-for-wordpress' ), |
475
|
|
|
'IE' => __( 'Ireland', 'google-analytics-for-wordpress' ), |
476
|
|
|
'IM' => __( 'Isle of Man', 'google-analytics-for-wordpress' ), |
477
|
|
|
'IL' => __( 'Israel', 'google-analytics-for-wordpress' ), |
478
|
|
|
'IT' => __( 'Italy', 'google-analytics-for-wordpress' ), |
479
|
|
|
'JM' => __( 'Jamaica', 'google-analytics-for-wordpress' ), |
480
|
|
|
'JP' => __( 'Japan', 'google-analytics-for-wordpress' ), |
481
|
|
|
'JE' => __( 'Jersey', 'google-analytics-for-wordpress' ), |
482
|
|
|
'JO' => __( 'Jordan', 'google-analytics-for-wordpress' ), |
483
|
|
|
'KZ' => __( 'Kazakhstan', 'google-analytics-for-wordpress' ), |
484
|
|
|
'KE' => __( 'Kenya', 'google-analytics-for-wordpress' ), |
485
|
|
|
'KI' => __( 'Kiribati', 'google-analytics-for-wordpress' ), |
486
|
|
|
'KW' => __( 'Kuwait', 'google-analytics-for-wordpress' ), |
487
|
|
|
'KG' => __( 'Kyrgyzstan', 'google-analytics-for-wordpress' ), |
488
|
|
|
'LA' => __( 'Lao People\'s Democratic Republic', 'google-analytics-for-wordpress' ), |
489
|
|
|
'LV' => __( 'Latvia', 'google-analytics-for-wordpress' ), |
490
|
|
|
'LB' => __( 'Lebanon', 'google-analytics-for-wordpress' ), |
491
|
|
|
'LS' => __( 'Lesotho', 'google-analytics-for-wordpress' ), |
492
|
|
|
'LR' => __( 'Liberia', 'google-analytics-for-wordpress' ), |
493
|
|
|
'LY' => __( 'Libyan Arab Jamahiriya', 'google-analytics-for-wordpress' ), |
494
|
|
|
'LI' => __( 'Liechtenstein', 'google-analytics-for-wordpress' ), |
495
|
|
|
'LT' => __( 'Lithuania', 'google-analytics-for-wordpress' ), |
496
|
|
|
'LU' => __( 'Luxembourg', 'google-analytics-for-wordpress' ), |
497
|
|
|
'MO' => __( 'Macau', 'google-analytics-for-wordpress' ), |
498
|
|
|
'MK' => __( 'Macedonia (FYROM)', 'google-analytics-for-wordpress' ), |
499
|
|
|
'MG' => __( 'Madagascar', 'google-analytics-for-wordpress' ), |
500
|
|
|
'MW' => __( 'Malawi', 'google-analytics-for-wordpress' ), |
501
|
|
|
'MY' => __( 'Malaysia', 'google-analytics-for-wordpress' ), |
502
|
|
|
'MV' => __( 'Maldives', 'google-analytics-for-wordpress' ), |
503
|
|
|
'ML' => __( 'Mali', 'google-analytics-for-wordpress' ), |
504
|
|
|
'MT' => __( 'Malta', 'google-analytics-for-wordpress' ), |
505
|
|
|
'MH' => __( 'Marshall Islands', 'google-analytics-for-wordpress' ), |
506
|
|
|
'MQ' => __( 'Martinique', 'google-analytics-for-wordpress' ), |
507
|
|
|
'MR' => __( 'Mauritania', 'google-analytics-for-wordpress' ), |
508
|
|
|
'MU' => __( 'Mauritius', 'google-analytics-for-wordpress' ), |
509
|
|
|
'YT' => __( 'Mayotte', 'google-analytics-for-wordpress' ), |
510
|
|
|
'MX' => __( 'Mexico', 'google-analytics-for-wordpress' ), |
511
|
|
|
'FM' => __( 'Micronesia', 'google-analytics-for-wordpress' ), |
512
|
|
|
'MD' => __( 'Moldova, Republic of', 'google-analytics-for-wordpress' ), |
513
|
|
|
'MC' => __( 'Monaco', 'google-analytics-for-wordpress' ), |
514
|
|
|
'MN' => __( 'Mongolia', 'google-analytics-for-wordpress' ), |
515
|
|
|
'ME' => __( 'Montenegro', 'google-analytics-for-wordpress' ), |
516
|
|
|
'MS' => __( 'Montserrat', 'google-analytics-for-wordpress' ), |
517
|
|
|
'MA' => __( 'Morocco', 'google-analytics-for-wordpress' ), |
518
|
|
|
'MZ' => __( 'Mozambique', 'google-analytics-for-wordpress' ), |
519
|
|
|
'MM' => __( 'Myanmar', 'google-analytics-for-wordpress' ), |
520
|
|
|
'NA' => __( 'Namibia', 'google-analytics-for-wordpress' ), |
521
|
|
|
'NR' => __( 'Nauru', 'google-analytics-for-wordpress' ), |
522
|
|
|
'NP' => __( 'Nepal', 'google-analytics-for-wordpress' ), |
523
|
|
|
'NL' => __( 'Netherlands', 'google-analytics-for-wordpress' ), |
524
|
|
|
'AN' => __( 'Netherlands Antilles', 'google-analytics-for-wordpress' ), |
525
|
|
|
'NC' => __( 'New Caledonia', 'google-analytics-for-wordpress' ), |
526
|
|
|
'NZ' => __( 'New Zealand', 'google-analytics-for-wordpress' ), |
527
|
|
|
'NI' => __( 'Nicaragua', 'google-analytics-for-wordpress' ), |
528
|
|
|
'NE' => __( 'Niger', 'google-analytics-for-wordpress' ), |
529
|
|
|
'NG' => __( 'Nigeria', 'google-analytics-for-wordpress' ), |
530
|
|
|
'NU' => __( 'Niue', 'google-analytics-for-wordpress' ), |
531
|
|
|
'NF' => __( 'Norfolk Island', 'google-analytics-for-wordpress' ), |
532
|
|
|
'KP' => __( 'North Korea', 'google-analytics-for-wordpress' ), |
533
|
|
|
'MP' => __( 'Northern Mariana Islands', 'google-analytics-for-wordpress' ), |
534
|
|
|
'NO' => __( 'Norway', 'google-analytics-for-wordpress' ), |
535
|
|
|
'OM' => __( 'Oman', 'google-analytics-for-wordpress' ), |
536
|
|
|
'PK' => __( 'Pakistan', 'google-analytics-for-wordpress' ), |
537
|
|
|
'PW' => __( 'Palau', 'google-analytics-for-wordpress' ), |
538
|
|
|
'PS' => __( 'Palestinian Territories', 'google-analytics-for-wordpress' ), |
539
|
|
|
'PA' => __( 'Panama', 'google-analytics-for-wordpress' ), |
540
|
|
|
'PG' => __( 'Papua New Guinea', 'google-analytics-for-wordpress' ), |
541
|
|
|
'PY' => __( 'Paraguay', 'google-analytics-for-wordpress' ), |
542
|
|
|
'PE' => __( 'Peru', 'google-analytics-for-wordpress' ), |
543
|
|
|
'PH' => __( 'Philippines', 'google-analytics-for-wordpress' ), |
544
|
|
|
'PN' => __( 'Pitcairn Island', 'google-analytics-for-wordpress' ), |
545
|
|
|
'PL' => __( 'Poland', 'google-analytics-for-wordpress' ), |
546
|
|
|
'PT' => __( 'Portugal', 'google-analytics-for-wordpress' ), |
547
|
|
|
'PR' => __( 'Puerto Rico', 'google-analytics-for-wordpress' ), |
548
|
|
|
'QA' => __( 'Qatar', 'google-analytics-for-wordpress' ), |
549
|
|
|
'XK' => __( 'Republic of Kosovo', 'google-analytics-for-wordpress' ), |
550
|
|
|
'RE' => __( 'Reunion Island', 'google-analytics-for-wordpress' ), |
551
|
|
|
'RO' => __( 'Romania', 'google-analytics-for-wordpress' ), |
552
|
|
|
'RU' => __( 'Russian Federation', 'google-analytics-for-wordpress' ), |
553
|
|
|
'RW' => __( 'Rwanda', 'google-analytics-for-wordpress' ), |
554
|
|
|
'BL' => __( 'Saint Barthélemy', 'google-analytics-for-wordpress' ), |
555
|
|
|
'SH' => __( 'Saint Helena', 'google-analytics-for-wordpress' ), |
556
|
|
|
'KN' => __( 'Saint Kitts and Nevis', 'google-analytics-for-wordpress' ), |
557
|
|
|
'LC' => __( 'Saint Lucia', 'google-analytics-for-wordpress' ), |
558
|
|
|
'MF' => __( 'Saint Martin (French)', 'google-analytics-for-wordpress' ), |
559
|
|
|
'SX' => __( 'Saint Martin (Dutch)', 'google-analytics-for-wordpress' ), |
560
|
|
|
'PM' => __( 'Saint Pierre and Miquelon', 'google-analytics-for-wordpress' ), |
561
|
|
|
'VC' => __( 'Saint Vincent and the Grenadines', 'google-analytics-for-wordpress' ), |
562
|
|
|
'SM' => __( 'San Marino', 'google-analytics-for-wordpress' ), |
563
|
|
|
'ST' => __( 'São Tomé and Príncipe', 'google-analytics-for-wordpress' ), |
564
|
|
|
'SA' => __( 'Saudi Arabia', 'google-analytics-for-wordpress' ), |
565
|
|
|
'SN' => __( 'Senegal', 'google-analytics-for-wordpress' ), |
566
|
|
|
'RS' => __( 'Serbia', 'google-analytics-for-wordpress' ), |
567
|
|
|
'SC' => __( 'Seychelles', 'google-analytics-for-wordpress' ), |
568
|
|
|
'SL' => __( 'Sierra Leone', 'google-analytics-for-wordpress' ), |
569
|
|
|
'SG' => __( 'Singapore', 'google-analytics-for-wordpress' ), |
570
|
|
|
'SK' => __( 'Slovak Republic', 'google-analytics-for-wordpress' ), |
571
|
|
|
'SI' => __( 'Slovenia', 'google-analytics-for-wordpress' ), |
572
|
|
|
'SB' => __( 'Solomon Islands', 'google-analytics-for-wordpress' ), |
573
|
|
|
'SO' => __( 'Somalia', 'google-analytics-for-wordpress' ), |
574
|
|
|
'ZA' => __( 'South Africa', 'google-analytics-for-wordpress' ), |
575
|
|
|
'GS' => __( 'South Georgia', 'google-analytics-for-wordpress' ), |
576
|
|
|
'KR' => __( 'South Korea', 'google-analytics-for-wordpress' ), |
577
|
|
|
'SS' => __( 'South Sudan', 'google-analytics-for-wordpress' ), |
578
|
|
|
'ES' => __( 'Spain', 'google-analytics-for-wordpress' ), |
579
|
|
|
'LK' => __( 'Sri Lanka', 'google-analytics-for-wordpress' ), |
580
|
|
|
'SD' => __( 'Sudan', 'google-analytics-for-wordpress' ), |
581
|
|
|
'SR' => __( 'Suriname', 'google-analytics-for-wordpress' ), |
582
|
|
|
'SJ' => __( 'Svalbard and Jan Mayen Islands', 'google-analytics-for-wordpress' ), |
583
|
|
|
'SZ' => __( 'Swaziland', 'google-analytics-for-wordpress' ), |
584
|
|
|
'SE' => __( 'Sweden', 'google-analytics-for-wordpress' ), |
585
|
|
|
'CH' => __( 'Switzerland', 'google-analytics-for-wordpress' ), |
586
|
|
|
'SY' => __( 'Syrian Arab Republic', 'google-analytics-for-wordpress' ), |
587
|
|
|
'TW' => __( 'Taiwan', 'google-analytics-for-wordpress' ), |
588
|
|
|
'TJ' => __( 'Tajikistan', 'google-analytics-for-wordpress' ), |
589
|
|
|
'TZ' => __( 'Tanzania', 'google-analytics-for-wordpress' ), |
590
|
|
|
'TH' => __( 'Thailand', 'google-analytics-for-wordpress' ), |
591
|
|
|
'TL' => __( 'Timor-Leste', 'google-analytics-for-wordpress' ), |
592
|
|
|
'TG' => __( 'Togo', 'google-analytics-for-wordpress' ), |
593
|
|
|
'TK' => __( 'Tokelau', 'google-analytics-for-wordpress' ), |
594
|
|
|
'TO' => __( 'Tonga', 'google-analytics-for-wordpress' ), |
595
|
|
|
'TT' => __( 'Trinidad and Tobago', 'google-analytics-for-wordpress' ), |
596
|
|
|
'TN' => __( 'Tunisia', 'google-analytics-for-wordpress' ), |
597
|
|
|
'TR' => __( 'Turkey', 'google-analytics-for-wordpress' ), |
598
|
|
|
'TM' => __( 'Turkmenistan', 'google-analytics-for-wordpress' ), |
599
|
|
|
'TC' => __( 'Turks and Caicos Islands', 'google-analytics-for-wordpress' ), |
600
|
|
|
'TV' => __( 'Tuvalu', 'google-analytics-for-wordpress' ), |
601
|
|
|
'UG' => __( 'Uganda', 'google-analytics-for-wordpress' ), |
602
|
|
|
'UA' => __( 'Ukraine', 'google-analytics-for-wordpress' ), |
603
|
|
|
'AE' => __( 'United Arab Emirates', 'google-analytics-for-wordpress' ), |
604
|
|
|
'UY' => __( 'Uruguay', 'google-analytics-for-wordpress' ), |
605
|
|
|
'UM' => __( 'US Minor Outlying Islands', 'google-analytics-for-wordpress' ), |
606
|
|
|
'UZ' => __( 'Uzbekistan', 'google-analytics-for-wordpress' ), |
607
|
|
|
'VU' => __( 'Vanuatu', 'google-analytics-for-wordpress' ), |
608
|
|
|
'VE' => __( 'Venezuela', 'google-analytics-for-wordpress' ), |
609
|
|
|
'VN' => __( 'Vietnam', 'google-analytics-for-wordpress' ), |
610
|
|
|
'VG' => __( 'Virgin Islands (British)', 'google-analytics-for-wordpress' ), |
611
|
|
|
'VI' => __( 'Virgin Islands (USA)', 'google-analytics-for-wordpress' ), |
612
|
|
|
'WF' => __( 'Wallis and Futuna Islands', 'google-analytics-for-wordpress' ), |
613
|
|
|
'EH' => __( 'Western Sahara', 'google-analytics-for-wordpress' ), |
614
|
|
|
'WS' => __( 'Western Samoa', 'google-analytics-for-wordpress' ), |
615
|
|
|
'YE' => __( 'Yemen', 'google-analytics-for-wordpress' ), |
616
|
|
|
'ZM' => __( 'Zambia', 'google-analytics-for-wordpress' ), |
617
|
|
|
'ZW' => __( 'Zimbabwe', 'google-analytics-for-wordpress' ), |
618
|
|
|
'ZZ' => __( 'Unknown Country', 'google-analytics-for-wordpress' ), |
619
|
|
|
); |
620
|
|
|
} else { |
621
|
|
|
$countries = array( |
622
|
|
|
'' => '', |
623
|
|
|
'US' => 'United States', |
624
|
|
|
'CA' => 'Canada', |
625
|
|
|
'GB' => 'United Kingdom', |
626
|
|
|
'AF' => 'Afghanistan', |
627
|
|
|
'AX' => 'Åland Islands', |
628
|
|
|
'AL' => 'Albania', |
629
|
|
|
'DZ' => 'Algeria', |
630
|
|
|
'AS' => 'American Samoa', |
631
|
|
|
'AD' => 'Andorra', |
632
|
|
|
'AO' => 'Angola', |
633
|
|
|
'AI' => 'Anguilla', |
634
|
|
|
'AQ' => 'Antarctica', |
635
|
|
|
'AG' => 'Antigua and Barbuda', |
636
|
|
|
'AR' => 'Argentina', |
637
|
|
|
'AM' => 'Armenia', |
638
|
|
|
'AW' => 'Aruba', |
639
|
|
|
'AU' => 'Australia', |
640
|
|
|
'AT' => 'Austria', |
641
|
|
|
'AZ' => 'Azerbaijan', |
642
|
|
|
'BS' => 'Bahamas', |
643
|
|
|
'BH' => 'Bahrain', |
644
|
|
|
'BD' => 'Bangladesh', |
645
|
|
|
'BB' => 'Barbados', |
646
|
|
|
'BY' => 'Belarus', |
647
|
|
|
'BE' => 'Belgium', |
648
|
|
|
'BZ' => 'Belize', |
649
|
|
|
'BJ' => 'Benin', |
650
|
|
|
'BM' => 'Bermuda', |
651
|
|
|
'BT' => 'Bhutan', |
652
|
|
|
'BO' => 'Bolivia', |
653
|
|
|
'BQ' => 'Bonaire, Saint Eustatius and Saba', |
654
|
|
|
'BA' => 'Bosnia and Herzegovina', |
655
|
|
|
'BW' => 'Botswana', |
656
|
|
|
'BV' => 'Bouvet Island', |
657
|
|
|
'BR' => 'Brazil', |
658
|
|
|
'IO' => 'British Indian Ocean Territory', |
659
|
|
|
'BN' => 'Brunei Darrussalam', |
660
|
|
|
'BG' => 'Bulgaria', |
661
|
|
|
'BF' => 'Burkina Faso', |
662
|
|
|
'BI' => 'Burundi', |
663
|
|
|
'KH' => 'Cambodia', |
664
|
|
|
'CM' => 'Cameroon', |
665
|
|
|
'CV' => 'Cape Verde', |
666
|
|
|
'KY' => 'Cayman Islands', |
667
|
|
|
'CF' => 'Central African Republic', |
668
|
|
|
'TD' => 'Chad', |
669
|
|
|
'CL' => 'Chile', |
670
|
|
|
'CN' => 'China', |
671
|
|
|
'CX' => 'Christmas Island', |
672
|
|
|
'CC' => 'Cocos Islands', |
673
|
|
|
'CO' => 'Colombia', |
674
|
|
|
'KM' => 'Comoros', |
675
|
|
|
'CD' => 'Congo, Democratic People\'s Republic', |
676
|
|
|
'CG' => 'Congo, Republic of', |
677
|
|
|
'CK' => 'Cook Islands', |
678
|
|
|
'CR' => 'Costa Rica', |
679
|
|
|
'CI' => 'Cote d\'Ivoire', |
680
|
|
|
'HR' => 'Croatia/Hrvatska', |
681
|
|
|
'CU' => 'Cuba', |
682
|
|
|
'CW' => 'CuraÇao', |
683
|
|
|
'CY' => 'Cyprus', |
684
|
|
|
'CZ' => 'Czechia', |
685
|
|
|
'DK' => 'Denmark', |
686
|
|
|
'DJ' => 'Djibouti', |
687
|
|
|
'DM' => 'Dominica', |
688
|
|
|
'DO' => 'Dominican Republic', |
689
|
|
|
'TP' => 'East Timor', |
690
|
|
|
'EC' => 'Ecuador', |
691
|
|
|
'EG' => 'Egypt', |
692
|
|
|
'GQ' => 'Equatorial Guinea', |
693
|
|
|
'SV' => 'El Salvador', |
694
|
|
|
'ER' => 'Eritrea', |
695
|
|
|
'EE' => 'Estonia', |
696
|
|
|
'ET' => 'Ethiopia', |
697
|
|
|
'FK' => 'Falkland Islands', |
698
|
|
|
'FO' => 'Faroe Islands', |
699
|
|
|
'FJ' => 'Fiji', |
700
|
|
|
'FI' => 'Finland', |
701
|
|
|
'FR' => 'France', |
702
|
|
|
'GF' => 'French Guiana', |
703
|
|
|
'PF' => 'French Polynesia', |
704
|
|
|
'TF' => 'French Southern Territories', |
705
|
|
|
'GA' => 'Gabon', |
706
|
|
|
'GM' => 'Gambia', |
707
|
|
|
'GE' => 'Georgia', |
708
|
|
|
'DE' => 'Germany', |
709
|
|
|
'GR' => 'Greece', |
710
|
|
|
'GH' => 'Ghana', |
711
|
|
|
'GI' => 'Gibraltar', |
712
|
|
|
'GL' => 'Greenland', |
713
|
|
|
'GD' => 'Grenada', |
714
|
|
|
'GP' => 'Guadeloupe', |
715
|
|
|
'GU' => 'Guam', |
716
|
|
|
'GT' => 'Guatemala', |
717
|
|
|
'GG' => 'Guernsey', |
718
|
|
|
'GN' => 'Guinea', |
719
|
|
|
'GW' => 'Guinea-Bissau', |
720
|
|
|
'GY' => 'Guyana', |
721
|
|
|
'HT' => 'Haiti', |
722
|
|
|
'HM' => 'Heard and McDonald Islands', |
723
|
|
|
'VA' => 'Holy See (City Vatican State)', |
724
|
|
|
'HN' => 'Honduras', |
725
|
|
|
'HK' => 'Hong Kong', |
726
|
|
|
'HU' => 'Hungary', |
727
|
|
|
'IS' => 'Iceland', |
728
|
|
|
'IN' => 'India', |
729
|
|
|
'ID' => 'Indonesia', |
730
|
|
|
'IR' => 'Iran', |
731
|
|
|
'IQ' => 'Iraq', |
732
|
|
|
'IE' => 'Ireland', |
733
|
|
|
'IM' => 'Isle of Man', |
734
|
|
|
'IL' => 'Israel', |
735
|
|
|
'IT' => 'Italy', |
736
|
|
|
'JM' => 'Jamaica', |
737
|
|
|
'JP' => 'Japan', |
738
|
|
|
'JE' => 'Jersey', |
739
|
|
|
'JO' => 'Jordan', |
740
|
|
|
'KZ' => 'Kazakhstan', |
741
|
|
|
'KE' => 'Kenya', |
742
|
|
|
'KI' => 'Kiribati', |
743
|
|
|
'KW' => 'Kuwait', |
744
|
|
|
'KG' => 'Kyrgyzstan', |
745
|
|
|
'LA' => 'Lao People\'s Democratic Republic', |
746
|
|
|
'LV' => 'Latvia', |
747
|
|
|
'LB' => 'Lebanon', |
748
|
|
|
'LS' => 'Lesotho', |
749
|
|
|
'LR' => 'Liberia', |
750
|
|
|
'LY' => 'Libyan Arab Jamahiriya', |
751
|
|
|
'LI' => 'Liechtenstein', |
752
|
|
|
'LT' => 'Lithuania', |
753
|
|
|
'LU' => 'Luxembourg', |
754
|
|
|
'MO' => 'Macau', |
755
|
|
|
'MK' => 'Macedonia', |
756
|
|
|
'MG' => 'Madagascar', |
757
|
|
|
'MW' => 'Malawi', |
758
|
|
|
'MY' => 'Malaysia', |
759
|
|
|
'MV' => 'Maldives', |
760
|
|
|
'ML' => 'Mali', |
761
|
|
|
'MT' => 'Malta', |
762
|
|
|
'MH' => 'Marshall Islands', |
763
|
|
|
'MQ' => 'Martinique', |
764
|
|
|
'MR' => 'Mauritania', |
765
|
|
|
'MU' => 'Mauritius', |
766
|
|
|
'YT' => 'Mayotte', |
767
|
|
|
'MX' => 'Mexico', |
768
|
|
|
'FM' => 'Micronesia', |
769
|
|
|
'MD' => 'Moldova, Republic of', |
770
|
|
|
'MC' => 'Monaco', |
771
|
|
|
'MN' => 'Mongolia', |
772
|
|
|
'ME' => 'Montenegro', |
773
|
|
|
'MS' => 'Montserrat', |
774
|
|
|
'MA' => 'Morocco', |
775
|
|
|
'MZ' => 'Mozambique', |
776
|
|
|
'MM' => 'Myanmar (Burma)', |
777
|
|
|
'NA' => 'Namibia', |
778
|
|
|
'NR' => 'Nauru', |
779
|
|
|
'NP' => 'Nepal', |
780
|
|
|
'NL' => 'Netherlands', |
781
|
|
|
'AN' => 'Netherlands Antilles', |
782
|
|
|
'NC' => 'New Caledonia', |
783
|
|
|
'NZ' => 'New Zealand', |
784
|
|
|
'NI' => 'Nicaragua', |
785
|
|
|
'NE' => 'Niger', |
786
|
|
|
'NG' => 'Nigeria', |
787
|
|
|
'NU' => 'Niue', |
788
|
|
|
'NF' => 'Norfolk Island', |
789
|
|
|
'KP' => 'North Korea', |
790
|
|
|
'MP' => 'Northern Mariana Islands', |
791
|
|
|
'NO' => 'Norway', |
792
|
|
|
'OM' => 'Oman', |
793
|
|
|
'PK' => 'Pakistan', |
794
|
|
|
'PW' => 'Palau', |
795
|
|
|
'PS' => 'Palestinian Territories', |
796
|
|
|
'PA' => 'Panama', |
797
|
|
|
'PG' => 'Papua New Guinea', |
798
|
|
|
'PY' => 'Paraguay', |
799
|
|
|
'PE' => 'Peru', |
800
|
|
|
'PH' => 'Philippines', |
801
|
|
|
'PN' => 'Pitcairn Island', |
802
|
|
|
'PL' => 'Poland', |
803
|
|
|
'PT' => 'Portugal', |
804
|
|
|
'PR' => 'Puerto Rico', |
805
|
|
|
'QA' => 'Qatar', |
806
|
|
|
'XK' => 'Republic of Kosovo', |
807
|
|
|
'RE' => 'Reunion Island', |
808
|
|
|
'RO' => 'Romania', |
809
|
|
|
'RU' => 'Russia', |
810
|
|
|
'RW' => 'Rwanda', |
811
|
|
|
'BL' => 'Saint Barthélemy', |
812
|
|
|
'SH' => 'Saint Helena', |
813
|
|
|
'KN' => 'Saint Kitts and Nevis', |
814
|
|
|
'LC' => 'Saint Lucia', |
815
|
|
|
'MF' => 'Saint Martin (French)', |
816
|
|
|
'SX' => 'Saint Martin (Dutch)', |
817
|
|
|
'PM' => 'Saint Pierre and Miquelon', |
818
|
|
|
'VC' => 'Saint Vincent and the Grenadines', |
819
|
|
|
'SM' => 'San Marino', |
820
|
|
|
'ST' => 'São Tomé and Príncipe', |
821
|
|
|
'SA' => 'Saudi Arabia', |
822
|
|
|
'SN' => 'Senegal', |
823
|
|
|
'RS' => 'Serbia', |
824
|
|
|
'SC' => 'Seychelles', |
825
|
|
|
'SL' => 'Sierra Leone', |
826
|
|
|
'SG' => 'Singapore', |
827
|
|
|
'SK' => 'Slovak Republic', |
828
|
|
|
'SI' => 'Slovenia', |
829
|
|
|
'SB' => 'Solomon Islands', |
830
|
|
|
'SO' => 'Somalia', |
831
|
|
|
'ZA' => 'South Africa', |
832
|
|
|
'GS' => 'South Georgia', |
833
|
|
|
'KR' => 'South Korea', |
834
|
|
|
'SS' => 'South Sudan', |
835
|
|
|
'ES' => 'Spain', |
836
|
|
|
'LK' => 'Sri Lanka', |
837
|
|
|
'SD' => 'Sudan', |
838
|
|
|
'SR' => 'Suriname', |
839
|
|
|
'SJ' => 'Svalbard and Jan Mayen Islands', |
840
|
|
|
'SZ' => 'Swaziland', |
841
|
|
|
'SE' => 'Sweden', |
842
|
|
|
'CH' => 'Switzerland', |
843
|
|
|
'SY' => 'Syrian Arab Republic', |
844
|
|
|
'TW' => 'Taiwan', |
845
|
|
|
'TJ' => 'Tajikistan', |
846
|
|
|
'TZ' => 'Tanzania', |
847
|
|
|
'TH' => 'Thailand', |
848
|
|
|
'TL' => 'Timor-Leste', |
849
|
|
|
'TG' => 'Togo', |
850
|
|
|
'TK' => 'Tokelau', |
851
|
|
|
'TO' => 'Tonga', |
852
|
|
|
'TT' => 'Trinidad and Tobago', |
853
|
|
|
'TN' => 'Tunisia', |
854
|
|
|
'TR' => 'Turkey', |
855
|
|
|
'TM' => 'Turkmenistan', |
856
|
|
|
'TC' => 'Turks and Caicos Islands', |
857
|
|
|
'TV' => 'Tuvalu', |
858
|
|
|
'UG' => 'Uganda', |
859
|
|
|
'UA' => 'Ukraine', |
860
|
|
|
'AE' => 'United Arab Emirates', |
861
|
|
|
'UY' => 'Uruguay', |
862
|
|
|
'UM' => 'US Minor Outlying Islands', |
863
|
|
|
'UZ' => 'Uzbekistan', |
864
|
|
|
'VU' => 'Vanuatu', |
865
|
|
|
'VE' => 'Venezuela', |
866
|
|
|
'VN' => 'Vietnam', |
867
|
|
|
'VG' => 'Virgin Islands (British)', |
868
|
|
|
'VI' => 'Virgin Islands (USA)', |
869
|
|
|
'WF' => 'Wallis and Futuna Islands', |
870
|
|
|
'EH' => 'Western Sahara', |
871
|
|
|
'WS' => 'Western Samoa', |
872
|
|
|
'YE' => 'Yemen', |
873
|
|
|
'ZM' => 'Zambia', |
874
|
|
|
'ZW' => 'Zimbabwe', |
875
|
|
|
'ZZ' => 'Unknown Country', |
876
|
|
|
); |
877
|
|
|
} |
878
|
|
|
return $countries; |
879
|
|
|
} |
880
|
|
|
|
881
|
|
|
function monsterinsights_get_api_url(){ |
882
|
|
|
return apply_filters( 'monsterinsights_get_api_url', 'api.monsterinsights.com/v2/' ); |
883
|
|
|
} |
884
|
|
|
|
885
|
|
|
function monsterinsights_get_licensing_url(){ |
886
|
|
|
return apply_filters( 'monsterinsights_get_licensing_url', 'https://www.monsterinsights.com' ); |
887
|
|
|
} |
888
|
|
|
|
889
|
|
|
function monsterinsights_is_wp_seo_active( ) { |
890
|
|
|
$wp_seo_active = false; // @todo: improve this check. This is from old Yoast code. |
891
|
|
|
|
892
|
|
|
// Makes sure is_plugin_active is available when called from front end |
893
|
|
|
include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
894
|
|
|
if ( is_plugin_active( 'wordpress-seo/wp-seo.php' ) || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ) ) { |
895
|
|
|
$wp_seo_active = true; |
896
|
|
|
} |
897
|
|
|
return $wp_seo_active; |
898
|
|
|
} |
899
|
|
|
|
900
|
|
|
function monsterinsights_get_asset_version() { |
901
|
|
|
if ( monsterinsights_is_debug_mode() || ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ) { |
902
|
|
|
return time(); |
903
|
|
|
} else { |
904
|
|
|
return MONSTERINSIGHTS_VERSION; |
905
|
|
|
} |
906
|
|
|
} |
907
|
|
|
|
908
|
|
|
function monsterinsights_is_debug_mode() { |
909
|
|
|
$debug_mode = false; |
910
|
|
|
if ( defined( 'MONSTERINSIGHTS_DEBUG_MODE' ) && MONSTERINSIGHTS_DEBUG_MODE ) { |
|
|
|
|
911
|
|
|
$debug_mode = true; |
912
|
|
|
} |
913
|
|
|
|
914
|
|
|
return apply_filters( 'monsterinsights_is_debug_mode', $debug_mode ); |
915
|
|
|
} |
916
|
|
|
|
917
|
|
|
function monsterinsights_is_network_active() { |
918
|
|
|
if ( ! function_exists( 'is_plugin_active_for_network' ) ) { |
919
|
|
|
require_once( ABSPATH . '/wp-admin/includes/plugin.php' ); |
920
|
|
|
} |
921
|
|
|
|
922
|
|
|
if ( is_multisite() && is_plugin_active_for_network( plugin_basename( MONSTERINSIGHTS_PLUGIN_FILE ) ) ) { |
923
|
|
|
return true; |
924
|
|
|
} else { |
925
|
|
|
return false; |
926
|
|
|
} |
927
|
|
|
} |
928
|
|
|
|
929
|
|
|
if ( ! function_exists ( 'remove_class_filter' ) ) { |
930
|
|
|
/** |
931
|
|
|
* Remove Class Filter Without Access to Class Object |
932
|
|
|
* |
933
|
|
|
* In order to use the core WordPress remove_filter() on a filter added with the callback |
934
|
|
|
* to a class, you either have to have access to that class object, or it has to be a call |
935
|
|
|
* to a static method. This method allows you to remove filters with a callback to a class |
936
|
|
|
* you don't have access to. |
937
|
|
|
* |
938
|
|
|
* Works with WordPress 1.2 - 4.7+ |
939
|
|
|
* |
940
|
|
|
* @param string $tag Filter to remove |
941
|
|
|
* @param string $class_name Class name for the filter's callback |
942
|
|
|
* @param string $method_name Method name for the filter's callback |
943
|
|
|
* @param int $priority Priority of the filter (default 10) |
944
|
|
|
* |
945
|
|
|
* @return bool Whether the function is removed. |
946
|
|
|
*/ |
947
|
|
|
function remove_class_filter( $tag, $class_name = '', $method_name = '', $priority = 10 ) { |
948
|
|
|
global $wp_filter; |
949
|
|
|
// Check that filter actually exists first |
950
|
|
|
if ( ! isset( $wp_filter[ $tag ] ) ) return FALSE; |
951
|
|
|
/** |
952
|
|
|
* If filter config is an object, means we're using WordPress 4.7+ and the config is no longer |
953
|
|
|
* a simple array, rather it is an object that implements the ArrayAccess interface. |
954
|
|
|
* |
955
|
|
|
* To be backwards compatible, we set $callbacks equal to the correct array as a reference (so $wp_filter is updated) |
956
|
|
|
* |
957
|
|
|
* @see https://make.wordpress.org/core/2016/09/08/wp_hook-next-generation-actions-and-filters/ |
958
|
|
|
*/ |
959
|
|
|
if ( is_object( $wp_filter[ $tag ] ) && isset( $wp_filter[ $tag ]->callbacks ) ) { |
960
|
|
|
$callbacks = &$wp_filter[ $tag ]->callbacks; |
961
|
|
|
} else { |
962
|
|
|
$callbacks = &$wp_filter[ $tag ]; |
963
|
|
|
} |
964
|
|
|
// Exit if there aren't any callbacks for specified priority |
965
|
|
|
if ( ! isset( $callbacks[ $priority ] ) || empty( $callbacks[ $priority ] ) ) return FALSE; |
966
|
|
|
// Loop through each filter for the specified priority, looking for our class & method |
967
|
|
|
foreach( (array) $callbacks[ $priority ] as $filter_id => $filter ) { |
968
|
|
|
// Filter should always be an array - array( $this, 'method' ), if not goto next |
969
|
|
|
if ( ! isset( $filter[ 'function' ] ) || ! is_array( $filter[ 'function' ] ) ) continue; |
970
|
|
|
// If first value in array is not an object, it can't be a class |
971
|
|
|
if ( ! is_object( $filter[ 'function' ][ 0 ] ) ) continue; |
972
|
|
|
// Method doesn't match the one we're looking for, goto next |
973
|
|
|
if ( $filter[ 'function' ][ 1 ] !== $method_name ) continue; |
974
|
|
|
// Method matched, now let's check the Class |
975
|
|
|
if ( get_class( $filter[ 'function' ][ 0 ] ) === $class_name ) { |
976
|
|
|
// Now let's remove it from the array |
977
|
|
|
unset( $callbacks[ $priority ][ $filter_id ] ); |
978
|
|
|
// and if it was the only filter in that priority, unset that priority |
979
|
|
|
if ( empty( $callbacks[ $priority ] ) ) unset( $callbacks[ $priority ] ); |
980
|
|
|
// and if the only filter for that tag, set the tag to an empty array |
981
|
|
|
if ( empty( $callbacks ) ) $callbacks = array(); |
982
|
|
|
// If using WordPress older than 4.7 |
983
|
|
|
if ( ! is_object( $wp_filter[ $tag ] ) ) { |
984
|
|
|
// Remove this filter from merged_filters, which specifies if filters have been sorted |
985
|
|
|
unset( $GLOBALS[ 'merged_filters' ][ $tag ] ); |
986
|
|
|
} |
987
|
|
|
return TRUE; |
988
|
|
|
} |
989
|
|
|
} |
990
|
|
|
return FALSE; |
991
|
|
|
} |
992
|
|
|
} // End function exists |
993
|
|
|
|
994
|
|
|
if ( ! function_exists ( 'remove_class_action' ) ) { |
995
|
|
|
/** |
996
|
|
|
* Remove Class Action Without Access to Class Object |
997
|
|
|
* |
998
|
|
|
* In order to use the core WordPress remove_action() on an action added with the callback |
999
|
|
|
* to a class, you either have to have access to that class object, or it has to be a call |
1000
|
|
|
* to a static method. This method allows you to remove actions with a callback to a class |
1001
|
|
|
* you don't have access to. |
1002
|
|
|
* |
1003
|
|
|
* Works with WordPress 1.2 - 4.7+ |
1004
|
|
|
* |
1005
|
|
|
* @param string $tag Action to remove |
1006
|
|
|
* @param string $class_name Class name for the action's callback |
1007
|
|
|
* @param string $method_name Method name for the action's callback |
1008
|
|
|
* @param int $priority Priority of the action (default 10) |
1009
|
|
|
* |
1010
|
|
|
* @return bool Whether the function is removed. |
1011
|
|
|
*/ |
1012
|
|
|
function remove_class_action( $tag, $class_name = '', $method_name = '', $priority = 10 ) { |
1013
|
|
|
remove_class_filter( $tag, $class_name, $method_name, $priority ); |
1014
|
|
|
} |
1015
|
|
|
} // End function exists |
1016
|
|
|
|
1017
|
|
|
/** |
1018
|
|
|
* Format a big number, instead of 1000000 you get 1.0M, works with billions also. |
1019
|
|
|
* |
1020
|
|
|
* @param int $number |
1021
|
|
|
* @param int $precision |
1022
|
|
|
* |
1023
|
|
|
* @return string |
1024
|
|
|
*/ |
1025
|
|
|
function monsterinsights_round_number( $number, $precision = 2 ) { |
1026
|
|
|
|
1027
|
|
|
if ( $number < 1000000 ) { |
1028
|
|
|
// Anything less than a million |
1029
|
|
|
$number = number_format_i18n( $number ); |
1030
|
|
|
} else if ( $number < 1000000000 ) { |
1031
|
|
|
// Anything less than a billion |
1032
|
|
|
$number = number_format_i18n( $number / 1000000, $precision ) . 'M'; |
1033
|
|
|
} else { |
1034
|
|
|
// At least a billion |
1035
|
|
|
$number = number_format_i18n( $number / 1000000000, $precision ) . 'B'; |
1036
|
|
|
} |
1037
|
|
|
|
1038
|
|
|
return $number; |
1039
|
|
|
} |
1040
|
|
|
|
1041
|
|
|
if ( ! function_exists( 'wp_get_jed_locale_data' ) ) { |
1042
|
|
|
/** |
1043
|
|
|
* Returns Jed-formatted localization data. Added for backwards-compatibility. |
1044
|
|
|
* |
1045
|
|
|
* @param string $domain Translation domain. |
1046
|
|
|
* |
1047
|
|
|
* @return array |
1048
|
|
|
*/ |
1049
|
|
|
function wp_get_jed_locale_data( $domain ) { |
1050
|
|
|
$translations = get_translations_for_domain( $domain ); |
1051
|
|
|
|
1052
|
|
|
$locale = array( |
1053
|
|
|
'' => array( |
1054
|
|
|
'domain' => $domain, |
1055
|
|
|
'lang' => is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(), |
1056
|
|
|
), |
1057
|
|
|
); |
1058
|
|
|
|
1059
|
|
|
if ( ! empty( $translations->headers['Plural-Forms'] ) ) { |
1060
|
|
|
$locale['']['plural_forms'] = $translations->headers['Plural-Forms']; |
1061
|
|
|
} |
1062
|
|
|
|
1063
|
|
|
foreach ( $translations->entries as $msgid => $entry ) { |
1064
|
|
|
$locale[ $msgid ] = $entry->translations; |
1065
|
|
|
} |
1066
|
|
|
|
1067
|
|
|
return $locale; |
1068
|
|
|
} |
1069
|
|
|
} |
1070
|
|
|
|
1071
|
|
|
function monsterinsights_get_inline_menu_icon() { |
1072
|
|
|
$scheme = get_user_option( 'admin_color', get_current_user_id() ); |
1073
|
|
|
$use_dark_scheme = $scheme === 'light'; |
1074
|
|
|
if ( $use_dark_scheme ) { |
1075
|
|
|
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'; |
1076
|
|
|
} else { |
1077
|
|
|
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'; |
1078
|
|
|
} |
1079
|
|
|
} |
1080
|
|
|
|
1081
|
|
|
|
1082
|
|
|
function monsterinsights_get_shareasale_id() { |
1083
|
|
|
// Check if there's a constant. |
1084
|
|
|
$shareasale_id = ''; |
1085
|
|
|
if ( defined( 'MONSTERINSIGHTS_SHAREASALE_ID' ) ) { |
1086
|
|
|
$shareasale_id = MONSTERINSIGHTS_SHAREASALE_ID; |
|
|
|
|
1087
|
|
|
} |
1088
|
|
|
|
1089
|
|
|
// If there's no constant, check if there's an option. |
1090
|
|
|
if ( empty( $shareasale_id ) ) { |
1091
|
|
|
$shareasale_id = get_option( 'monsterinsights_shareasale_id', '' ); |
1092
|
|
|
} |
1093
|
|
|
|
1094
|
|
|
// Whether we have an ID or not, filter the ID. |
1095
|
|
|
$shareasale_id = apply_filters( 'monsterinsights_shareasale_id', $shareasale_id ); |
1096
|
|
|
|
1097
|
|
|
// Ensure it's a number |
1098
|
|
|
$shareasale_id = absint( $shareasale_id ); |
1099
|
|
|
|
1100
|
|
|
return $shareasale_id; |
1101
|
|
|
} |
1102
|
|
|
|
1103
|
|
|
// Passed in with mandatory default redirect and shareasaleid from monsterinsights_get_upgrade_link |
1104
|
|
|
function monsterinsights_get_shareasale_url( $shareasale_id, $shareasale_redirect ) { |
1105
|
|
|
// Check if there's a constant. |
1106
|
|
|
$custom = false; |
1107
|
|
|
if ( defined( 'MONSTERINSIGHTS_SHAREASALE_REDIRECT_URL' ) ) { |
1108
|
|
|
$shareasale_redirect = MONSTERINSIGHTS_SHAREASALE_REDIRECT_URL; |
|
|
|
|
1109
|
|
|
$custom = true; |
1110
|
|
|
} |
1111
|
|
|
|
1112
|
|
|
// If there's no constant, check if there's an option. |
1113
|
|
|
if ( empty( $custom ) ) { |
1114
|
|
|
$shareasale_redirect = get_option( 'monsterinsights_shareasale_redirect_url', '' ); |
1115
|
|
|
$custom = true; |
1116
|
|
|
} |
1117
|
|
|
|
1118
|
|
|
// Whether we have an ID or not, filter the ID. |
1119
|
|
|
$shareasale_redirect = apply_filters( 'monsterinsights_shareasale_redirect_url', $shareasale_redirect, $custom ); |
1120
|
|
|
$shareasale_url = sprintf( 'https://www.shareasale.com/r.cfm?B=971799&U=%s&M=69975&urllink=%s', $shareasale_id, $shareasale_redirect ); |
1121
|
|
|
$shareasale_url = apply_filters( 'monsterinsights_shareasale_redirect_entire_url', $shareasale_url, $shareasale_id, $shareasale_redirect ); |
1122
|
|
|
return $shareasale_url; |
1123
|
|
|
} |
1124
|
|
|
|
1125
|
|
|
/** |
1126
|
|
|
* Get a clean page title for archives. |
1127
|
|
|
*/ |
1128
|
|
|
function monsterinsights_get_page_title() { |
1129
|
|
|
|
1130
|
|
|
$title = __( 'Archives' ); |
1131
|
|
|
|
1132
|
|
|
if ( is_category() ) { |
1133
|
|
|
/* translators: Category archive title. %s: Category name */ |
1134
|
|
|
$title = sprintf( __( 'Category: %s' ), single_cat_title( '', false ) ); |
1135
|
|
|
} elseif ( is_tag() ) { |
1136
|
|
|
/* translators: Tag archive title. %s: Tag name */ |
1137
|
|
|
$title = sprintf( __( 'Tag: %s' ), single_tag_title( '', false ) ); |
1138
|
|
|
} elseif ( is_author() ) { |
1139
|
|
|
/* translators: Author archive title. %s: Author name */ |
1140
|
|
|
$title = sprintf( __( 'Author: %s' ), '<span class="vcard">' . get_the_author() . '</span>' ); |
1141
|
|
|
} elseif ( is_year() ) { |
1142
|
|
|
/* translators: Yearly archive title. %s: Year */ |
1143
|
|
|
$title = sprintf( __( 'Year: %s' ), get_the_date( _x( 'Y', 'yearly archives date format' ) ) ); |
|
|
|
|
1144
|
|
|
} elseif ( is_month() ) { |
1145
|
|
|
/* translators: Monthly archive title. %s: Month name and year */ |
1146
|
|
|
$title = sprintf( __( 'Month: %s' ), get_the_date( _x( 'F Y', 'monthly archives date format' ) ) ); |
1147
|
|
|
} elseif ( is_day() ) { |
1148
|
|
|
/* translators: Daily archive title. %s: Date */ |
1149
|
|
|
$title = sprintf( __( 'Day: %s' ), get_the_date( _x( 'F j, Y', 'daily archives date format' ) ) ); |
1150
|
|
|
} elseif ( is_tax( 'post_format' ) ) { |
1151
|
|
|
if ( is_tax( 'post_format', 'post-format-aside' ) ) { |
1152
|
|
|
$title = _x( 'Asides', 'post format archive title' ); |
1153
|
|
|
} elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) { |
1154
|
|
|
$title = _x( 'Galleries', 'post format archive title' ); |
1155
|
|
|
} elseif ( is_tax( 'post_format', 'post-format-image' ) ) { |
1156
|
|
|
$title = _x( 'Images', 'post format archive title' ); |
1157
|
|
|
} elseif ( is_tax( 'post_format', 'post-format-video' ) ) { |
1158
|
|
|
$title = _x( 'Videos', 'post format archive title' ); |
1159
|
|
|
} elseif ( is_tax( 'post_format', 'post-format-quote' ) ) { |
1160
|
|
|
$title = _x( 'Quotes', 'post format archive title' ); |
1161
|
|
|
} elseif ( is_tax( 'post_format', 'post-format-link' ) ) { |
1162
|
|
|
$title = _x( 'Links', 'post format archive title' ); |
1163
|
|
|
} elseif ( is_tax( 'post_format', 'post-format-status' ) ) { |
1164
|
|
|
$title = _x( 'Statuses', 'post format archive title' ); |
1165
|
|
|
} elseif ( is_tax( 'post_format', 'post-format-audio' ) ) { |
1166
|
|
|
$title = _x( 'Audio', 'post format archive title' ); |
1167
|
|
|
} elseif ( is_tax( 'post_format', 'post-format-chat' ) ) { |
1168
|
|
|
$title = _x( 'Chats', 'post format archive title' ); |
1169
|
|
|
} |
1170
|
|
|
} elseif ( is_post_type_archive() ) { |
1171
|
|
|
/* translators: Post type archive title. %s: Post type name */ |
1172
|
|
|
$title = sprintf( __( 'Archives: %s' ), post_type_archive_title( '', false ) ); |
1173
|
|
|
} elseif ( is_tax() ) { |
1174
|
|
|
$tax = get_taxonomy( get_queried_object()->taxonomy ); |
1175
|
|
|
/* translators: Taxonomy term archive title. 1: Taxonomy singular name, 2: Current taxonomy term */ |
1176
|
|
|
$title = sprintf( __( '%1$s: %2$s' ), $tax->labels->singular_name, single_term_title( '', false ) ); |
1177
|
|
|
} |
1178
|
|
|
|
1179
|
|
|
return $title; |
1180
|
|
|
|
1181
|
|
|
} |
1182
|
|
|
|
1183
|
|
|
/** |
1184
|
|
|
* Make a request to the front page and check if the tracking code is present. Moved here from onboarding wizard |
1185
|
|
|
* to be used in the site health check. |
1186
|
|
|
* |
1187
|
|
|
* @return array |
1188
|
|
|
*/ |
1189
|
|
|
function monsterinsights_is_code_installed_frontend() { |
1190
|
|
|
// Grab the front page html. |
1191
|
|
|
$request = wp_remote_request( home_url(), array( |
1192
|
|
|
'sslverify' => false, |
1193
|
|
|
) ); |
1194
|
|
|
$errors = array(); |
1195
|
|
|
|
1196
|
|
|
$accepted_http_codes = array( |
1197
|
|
|
200, |
1198
|
|
|
503 |
1199
|
|
|
); |
1200
|
|
|
|
1201
|
|
|
$response_code = wp_remote_retrieve_response_code( $request ); |
1202
|
|
|
|
1203
|
|
|
if ( in_array( $response_code, $accepted_http_codes, true ) ) { |
1204
|
|
|
|
1205
|
|
|
$body = wp_remote_retrieve_body( $request ); |
1206
|
|
|
$current_ua_code = monsterinsights_get_ua_to_output(); |
1207
|
|
|
$ua_limit = 2; |
1208
|
|
|
// If the ads addon is installed another UA is added to the page. |
1209
|
|
|
if ( class_exists( 'MonsterInsights_Ads' ) ) { |
1210
|
|
|
$ua_limit = 3; |
1211
|
|
|
} |
1212
|
|
|
// Translators: The placeholders are for making the "We noticed you're using a caching plugin" text bold. |
1213
|
|
|
$cache_error = sprintf( esc_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>' ); |
1214
|
|
|
|
1215
|
|
|
// Translators: The placeholders are for making the "We have detected multiple tracking codes" text bold & adding a link to support. |
1216
|
|
|
$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' ); |
1217
|
|
|
$url = monsterinsights_get_url( 'site-health', 'comingsoon', 'https://www.monsterinsights.com/docs/how-to-find-duplicate-google-analytics-tracking-codes-in-wordpress/' ); |
1218
|
|
|
$multiple_ua_error = sprintf( |
1219
|
|
|
$message, |
1220
|
|
|
'<b>', |
1221
|
|
|
'</b>', |
1222
|
|
|
'<a href="' . $url . '" target="_blank">', |
1223
|
|
|
'</a>' |
1224
|
|
|
); |
1225
|
|
|
|
1226
|
|
|
// First, check if the tracking frontend code is present. |
1227
|
|
|
if ( false === strpos( $body, '__gaTracker' ) ) { |
1228
|
|
|
$errors[] = $cache_error; |
1229
|
|
|
} else { |
1230
|
|
|
// Check if the current UA code is actually present. |
1231
|
|
|
if ( $current_ua_code && false === strpos( $body, $current_ua_code ) ) { |
1232
|
|
|
// We have the tracking code but using another UA, so it's cached. |
1233
|
|
|
$errors[] = $cache_error; |
1234
|
|
|
} |
1235
|
|
|
|
1236
|
|
|
// Grab all potential google site verification tags |
1237
|
|
|
$pattern = '/content="UA-[0-9-]+"/'; |
1238
|
|
|
if ( preg_match_all( $pattern, $body, $matches ) ) { |
1239
|
|
|
// Raise the number of UA limits |
1240
|
|
|
$ua_limit += count( $matches[0] ); |
1241
|
|
|
} |
1242
|
|
|
|
1243
|
|
|
// Grab all the UA codes from the page. |
1244
|
|
|
$pattern = '/UA-[0-9]+/m'; |
1245
|
|
|
preg_match_all( $pattern, $body, $matches ); |
1246
|
|
|
// If more than twice ( because MI has a ga-disable-UA also ), let them know to remove the others. |
1247
|
|
|
if ( ! empty( $matches[0] ) && is_array( $matches[0] ) && count( $matches[0] ) > $ua_limit ) { |
1248
|
|
|
$errors[] = $multiple_ua_error; |
1249
|
|
|
} |
1250
|
|
|
} |
1251
|
|
|
} |
1252
|
|
|
|
1253
|
|
|
return $errors; |
1254
|
|
|
} |
1255
|
|
|
|
1256
|
|
|
/** |
1257
|
|
|
* Returns a HEX color to highlight menu items based on the admin color scheme. |
1258
|
|
|
*/ |
1259
|
|
|
function monsterinsights_menu_highlight_color() { |
1260
|
|
|
|
1261
|
|
|
$color_scheme = get_user_option( 'admin_color' ); |
1262
|
|
|
$color = '#7cc048'; |
1263
|
|
|
if ( 'light' === $color_scheme || 'blue' === $color_scheme ) { |
1264
|
|
|
$color = '#5f3ea7'; |
1265
|
|
|
} |
1266
|
|
|
|
1267
|
|
|
return $color; |
1268
|
|
|
} |
1269
|
|
|
|
1270
|
|
|
/** |
1271
|
|
|
* Track Pretty Links redirects with MonsterInsights. |
1272
|
|
|
* |
1273
|
|
|
* @param string $url The url to which users get redirected. |
1274
|
|
|
*/ |
1275
|
|
|
function monsterinsights_custom_track_pretty_links_redirect( $url ) { |
1276
|
|
|
if ( ! function_exists( 'monsterinsights_mp_track_event_call' ) ) { |
1277
|
|
|
return; |
1278
|
|
|
} |
1279
|
|
|
// Try to determine if click originated on the same site. |
1280
|
|
|
$referer = ! empty( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : ''; |
1281
|
|
|
if ( ! empty( $referer ) ) { |
1282
|
|
|
$current_site_url = get_bloginfo( 'url' ); |
1283
|
|
|
$current_site_parsed = wp_parse_url( $current_site_url ); |
1284
|
|
|
$parsed_referer = wp_parse_url( $referer ); |
1285
|
|
|
if ( ! empty( $parsed_referer['host'] ) && ! empty( $current_site_parsed['host'] ) && $current_site_parsed['host'] === $parsed_referer['host'] ) { |
1286
|
|
|
// Don't track clicks originating from same site as those are tracked with JS. |
1287
|
|
|
return; |
1288
|
|
|
} |
1289
|
|
|
} |
1290
|
|
|
// Check if this is an affiliate link and use the appropriate category. |
1291
|
|
|
$ec = 'outbound-link'; |
1292
|
|
|
$inbound_paths = monsterinsights_get_option( 'affiliate_links', array() ); |
1293
|
|
|
$path = empty( $_SERVER['REQUEST_URI'] ) ? '' : $_SERVER['REQUEST_URI']; |
1294
|
|
|
if ( ! empty( $inbound_paths ) && is_array( $inbound_paths ) && ! empty( $path ) ) { |
|
|
|
|
1295
|
|
|
$found = false; |
1296
|
|
|
foreach ( $inbound_paths as $inbound_path ) { |
1297
|
|
|
if ( empty( $inbound_path['path'] ) ) { |
1298
|
|
|
continue; |
1299
|
|
|
} |
1300
|
|
|
if ( 0 === strpos( $path, trim( $inbound_path['path'] ) ) ) { |
1301
|
|
|
$label = ! empty( $inbound_path['label'] ) ? trim( $inbound_path['label'] ) : 'aff'; |
1302
|
|
|
$ec .= '-' . $label; |
1303
|
|
|
$found = true; |
1304
|
|
|
break; |
1305
|
|
|
} |
1306
|
|
|
} |
1307
|
|
|
if ( ! $found ) { |
1308
|
|
|
return; |
1309
|
|
|
} |
1310
|
|
|
} else { |
1311
|
|
|
// no paths setup in MonsterInsights settings |
1312
|
|
|
return; |
1313
|
|
|
} |
1314
|
|
|
|
1315
|
|
|
$track_args = array( |
1316
|
|
|
't' => 'event', |
1317
|
|
|
'ec' => $ec, |
1318
|
|
|
'ea' => $url, |
1319
|
|
|
'el' => 'external-redirect', |
1320
|
|
|
); |
1321
|
|
|
monsterinsights_mp_track_event_call( $track_args ); |
1322
|
|
|
} |
1323
|
|
|
add_action( 'prli_before_redirect', 'monsterinsights_custom_track_pretty_links_redirect' ); |
1324
|
|
|
|
1325
|
|
|
/** |
1326
|
|
|
* Decode special characters, both alpha- (<) and numeric-based ('). |
1327
|
|
|
* |
1328
|
|
|
* @since 7.10.5 |
1329
|
|
|
* |
1330
|
|
|
* @param string $string Raw string to decode. |
1331
|
|
|
* |
1332
|
|
|
* @return string |
1333
|
|
|
*/ |
1334
|
|
|
function monsterinsights_decode_string( $string ) { |
1335
|
|
|
|
1336
|
|
|
if ( ! is_string( $string ) ) { |
|
|
|
|
1337
|
|
|
return $string; |
1338
|
|
|
} |
1339
|
|
|
|
1340
|
|
|
return wp_kses_decode_entities( html_entity_decode( $string, ENT_QUOTES ) ); |
1341
|
|
|
} |
1342
|
|
|
|
1343
|
|
|
add_filter( 'monsterinsights_email_message', 'monsterinsights_decode_string' ); |
1344
|
|
|
|
1345
|
|
|
/** |
1346
|
|
|
* Sanitize a string, that can be a multiline. |
1347
|
|
|
* If WP core `sanitize_textarea_field()` exists (after 4.7.0) - use it. |
1348
|
|
|
* Otherwise - split onto separate lines, sanitize each one, merge again. |
1349
|
|
|
* |
1350
|
|
|
* @since 7.10.5 |
1351
|
|
|
* |
1352
|
|
|
* @param string $string |
1353
|
|
|
* |
1354
|
|
|
* @return string If empty var is passed, or not a string - return unmodified. Otherwise - sanitize. |
1355
|
|
|
*/ |
1356
|
|
|
function monsterinsights_sanitize_textarea_field( $string ) { |
1357
|
|
|
|
1358
|
|
|
if ( empty( $string ) || ! is_string( $string ) ) { |
1359
|
|
|
return $string; |
1360
|
|
|
} |
1361
|
|
|
|
1362
|
|
|
if ( function_exists( 'sanitize_textarea_field' ) ) { |
1363
|
|
|
$string = sanitize_textarea_field( $string ); |
1364
|
|
|
} else { |
1365
|
|
|
$string = implode( "\n", array_map( 'sanitize_text_field', explode( "\n", $string ) ) ); |
1366
|
|
|
} |
1367
|
|
|
|
1368
|
|
|
return $string; |
1369
|
|
|
} |
1370
|
|
|
|
1371
|
|
|
/** |
1372
|
|
|
* Trim a sentence |
1373
|
|
|
* |
1374
|
|
|
* @since 7.10.5 |
1375
|
|
|
* |
1376
|
|
|
* @param string $string |
1377
|
|
|
* @param int $count |
1378
|
|
|
* |
1379
|
|
|
* @return trimed sentence |
|
|
|
|
1380
|
|
|
*/ |
1381
|
|
|
function monsterinsights_trim_text( $text, $count ){ |
1382
|
|
|
$text = str_replace(" ", " ", $text); |
1383
|
|
|
$string = explode(" ", $text); |
1384
|
|
|
$trimed = ""; |
1385
|
|
|
|
1386
|
|
|
for ( $wordCounter = 0; $wordCounter <= $count; $wordCounter++ ) { |
1387
|
|
|
$trimed .= isset( $string[$wordCounter] ) ? $string[$wordCounter] : ''; |
1388
|
|
|
|
1389
|
|
|
if ( $wordCounter < $count ){ |
1390
|
|
|
$trimed .= " "; |
1391
|
|
|
} else { |
1392
|
|
|
$trimed .= "..."; |
1393
|
|
|
} |
1394
|
|
|
} |
1395
|
|
|
|
1396
|
|
|
$trimed = trim($trimed); |
1397
|
|
|
|
1398
|
|
|
return $trimed; |
1399
|
|
|
} |
1400
|
|
|
|
1401
|
|
|
/** |
1402
|
|
|
* Add newly generated builder URL to PrettyLinks & |
1403
|
|
|
* Clear localStorage key(MonsterInsightsURL) after saving PrettyLink |
1404
|
|
|
*/ |
1405
|
|
|
function monsterinsights_tools_copy_url_to_prettylinks() { |
1406
|
|
|
global $pagenow; |
1407
|
|
|
|
1408
|
|
|
$post_type = isset( $_GET['post_type'] ) ? $_GET['post_type'] : ''; |
1409
|
|
|
$monsterinsights_reference = isset( $_GET['monsterinsights_reference'] ) ? $_GET['monsterinsights_reference'] : ''; |
1410
|
|
|
|
1411
|
|
|
if ( 'post-new.php' === $pagenow && 'pretty-link' === $post_type && 'url_builder' === $monsterinsights_reference ) { ?> |
1412
|
|
|
<script> |
1413
|
|
|
let targetTitleField = document.querySelector("input[name='post_title']"); |
1414
|
|
|
let targetUrlField = document.querySelector("textarea[name='prli_url']"); |
1415
|
|
|
let monsterInsightsUrl = JSON.parse(localStorage.getItem('MonsterInsightsURL')); |
1416
|
|
|
if ( 'undefined' !== typeof targetUrlField && 'undefined' !== typeof monsterInsightsUrl ) { |
1417
|
|
|
let url = monsterInsightsUrl.value; |
1418
|
|
|
let postTitle = ''; |
1419
|
|
|
let pathArray = url.split('?'); |
1420
|
|
|
if ( pathArray.length <= 1 ) { |
1421
|
|
|
pathArray = url.split('#'); |
1422
|
|
|
} |
1423
|
|
|
let urlParams = new URLSearchParams(pathArray[1]); |
1424
|
|
|
if (urlParams.has('utm_campaign')) { |
1425
|
|
|
let campaign_name = urlParams.get('utm_campaign'); |
1426
|
|
|
postTitle += campaign_name; |
1427
|
|
|
} |
1428
|
|
|
if (urlParams.has('utm_medium')) { |
1429
|
|
|
let campaign_medium = urlParams.get('utm_medium'); |
1430
|
|
|
postTitle += ` ${campaign_medium}`; |
1431
|
|
|
} |
1432
|
|
|
if (urlParams.has('utm_source')) { |
1433
|
|
|
let campaign_source = urlParams.get('utm_source'); |
1434
|
|
|
postTitle += ` on ${campaign_source}`; |
1435
|
|
|
} |
1436
|
|
|
if (urlParams.has('utm_term')) { |
1437
|
|
|
let campaign_term = urlParams.get('utm_term'); |
1438
|
|
|
postTitle += ` for ${campaign_term}`; |
1439
|
|
|
} |
1440
|
|
|
if (urlParams.has('utm_content')) { |
1441
|
|
|
let campaign_content = urlParams.get('utm_content'); |
1442
|
|
|
postTitle += ` - ${campaign_content}`; |
1443
|
|
|
} |
1444
|
|
|
if ( 'undefined' !== typeof targetTitleField && postTitle ) { |
1445
|
|
|
targetTitleField.value = postTitle; |
1446
|
|
|
} |
1447
|
|
|
if( url ) { |
1448
|
|
|
targetUrlField.value = url; |
1449
|
|
|
} |
1450
|
|
|
} |
1451
|
|
|
let form = document.getElementById('post'); |
1452
|
|
|
form.addEventListener('submit', function(){ |
1453
|
|
|
localStorage.removeItem('MonsterInsightsURL'); |
1454
|
|
|
}); |
1455
|
|
|
</script> |
1456
|
|
|
<?php } |
1457
|
|
|
} |
1458
|
|
|
add_action( 'admin_footer', 'monsterinsights_tools_copy_url_to_prettylinks' ); |
1459
|
|
|
|
1460
|
|
|
/** |
1461
|
|
|
* When click on 'Create New Pretty Link" button(on tools/prettylinks-flow page) after installing & activating prettylinks plugin |
1462
|
|
|
* it redirects to PrettyLinks welcome scree page instead of prettylinks add new page. |
1463
|
|
|
* This function will skip that welcome screen |
1464
|
|
|
*/ |
1465
|
|
|
function monsterinsights_skip_prettylinks_welcome_screen() { |
1466
|
|
|
global $pagenow; |
1467
|
|
|
|
1468
|
|
|
$post_type = isset( $_GET['post_type'] ) ? $_GET['post_type'] : ''; |
1469
|
|
|
$monsterinsights_reference = isset( $_GET['monsterinsights_reference'] ) ? $_GET['monsterinsights_reference'] : ''; |
1470
|
|
|
|
1471
|
|
|
if ( 'post-new.php' === $pagenow && 'pretty-link' === $post_type && 'url_builder' === $monsterinsights_reference ) { |
1472
|
|
|
$onboard = get_option( 'prli_onboard' ); |
1473
|
|
|
|
1474
|
|
|
if ( $onboard == 'welcome' || $onboard == 'update' ) { |
1475
|
|
|
update_option( 'monsterinsights_backup_prli_onboard_value', $onboard ); |
1476
|
|
|
delete_option( 'prli_onboard' ); |
1477
|
|
|
} |
1478
|
|
|
} |
1479
|
|
|
} |
1480
|
|
|
add_action( 'wp_loaded', 'monsterinsights_skip_prettylinks_welcome_screen', 9 ); |
1481
|
|
|
|
1482
|
|
|
/** |
1483
|
|
|
* Restore the `prli_onboard` value after creating a prettylinks with monsterinsights prettylinks flow |
1484
|
|
|
* users will see the prettylinks welcome screen after fresh installation & creating prettylinks with monsterinsights prettylinks flow |
1485
|
|
|
*/ |
1486
|
|
|
function monsterinsights_restore_prettylinks_onboard_value() { |
1487
|
|
|
global $pagenow; |
1488
|
|
|
|
1489
|
|
|
$post_type = isset( $_GET['post_type'] ) ? $_GET['post_type'] : ''; |
1490
|
|
|
|
1491
|
|
|
if ( 'edit.php' === $pagenow && 'pretty-link' === $post_type ) { |
1492
|
|
|
$onboard = get_option( 'monsterinsights_backup_prli_onboard_value' ); |
1493
|
|
|
|
1494
|
|
|
if ( class_exists( 'PrliBaseController' ) && ( $onboard == 'welcome' || $onboard == 'update' ) ) { |
1495
|
|
|
update_option( 'prli_onboard', $onboard ); |
1496
|
|
|
delete_option( 'monsterinsights_backup_prli_onboard_value' ); |
1497
|
|
|
} |
1498
|
|
|
} |
1499
|
|
|
} |
1500
|
|
|
add_action( 'wp_loaded', 'monsterinsights_restore_prettylinks_onboard_value', 15 ); |