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


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
<?php
/**
 * Option functions.
 *
 * @since 6.0.0
 *
 * @package MonsterInsights
 * @subpackage Options
 * @author  Chris Christoff
 */

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

function 
monsterinsights_get_options() {
    
$settings = array();
    
$option_name monsterinsights_get_option_name();
    
//$settings             = get_site_option( $option_name );
    //$use_network_settings = ! empty( $use_network_settings['use_network_settings'] ) ? true : false;
    //$is_network           = is_multisite();

    //if ( $is_network && $use_network_settings ) {
    //    return $settings;
    //} else if ( $is_network ) {
        
$settings get_option$option_name );
    
//} else {
    //    return $settings;
    //}
    
if ( empty( $settings ) || ! is_array$settings ) ) {
        
$settings = array();
    }
    return 
$settings;
}

/**
 * Helper method for getting a setting's value. Falls back to the default
 * setting value if none exists in the options table.
 *
 * @since 6.0.0
 * @access public
 *
 * @param string $key   The setting key to retrieve.
 * @param mixed $default   The default value of the setting key to retrieve.
 * @return string       The value of the setting.
 */
function monsterinsights_get_option$key ''$default false ) {
    global 
$monsterinsights_settings;
    
$value = ! empty( $monsterinsights_settings$key ] ) ? $monsterinsights_settings$key ] : $default;
    
$value apply_filters'monsterinsights_get_option'$value$key$default );
    return 
apply_filters'monsterinsights_get_option_' $key$value$key$default );
}

/**
 * Helper method for getting the UA string.
 *
 * @since 6.0.0
 * @access public
 *
 * @return string The UA to use.
 */
function monsterinsights_get_ua() {
    
// Allow short circuiting (for staging sites)
    
if ( defined'MONSTERINSIGHTS_DISABLE_TRACKING' ) && MONSTERINSIGHTS_DISABLE_TRACKING ) {
        return 
'';
    }

    
// Try getting it from the auth UA
    
$ua MonsterInsights()->auth->get_ua();

    
// If that didn't work, try the manual UA at the site level
    
if ( empty( $ua ) ) {
        
$ua MonsterInsights()->auth->get_manual_ua();
        
// If that didn't work try getting it from the network
        
if ( empty( $ua ) ) {
            
$ua monsterinsights_get_network_ua();
            
// If that didn't work, try getting it from the overall constant. If it's not there, leave it blank
            
if ( empty( $ua ) ) {
                
$ua defined'MONSTERINSIGHTS_GA_UA' ) && MONSTERINSIGHTS_GA_UA monsterinsights_is_valid_uaMONSTERINSIGHTS_GA_UA ) : '';
            }
        }
    }

    
// Feed through the filter
    
$pre_filter $ua;
    
$ua apply_filters'monsterinsights_get_ua'$ua );

    
// Only run through monsterinsights_is_valid_ua if it's different than pre-filter
    
return $pre_filter === $ua $ua monsterinsights_is_valid_ua$ua );
}

/**
 * Helper method for getting the network UA string.
 *
 * @since 6.0.0
 * @access public
 *
 * @return string The UA to use.
 */
function monsterinsights_get_network_ua() {
    if ( ! 
is_multisite() ) {
        return 
'';
    }

    
// First try network auth UA
    
$ua MonsterInsights()->auth->get_network_ua();
    if ( ! empty( 
$ua ) ) {
        return 
$ua;
    }

    
// Then try manual network UA
    
$ua MonsterInsights()->auth->get_network_manual_ua();
    if ( ! empty( 
$ua ) ) {
        return 
$ua;
    }

    
// See if the constant is defined
    
if ( defined'MONSTERINSIGHTS_MS_GA_UA' ) && monsterinsights_is_valid_uaMONSTERINSIGHTS_MS_GA_UA ) ) {
        return 
MONSTERINSIGHTS_MS_GA_UA;
    }

    return 
'';
}

/**
 * Helper method for getting the UA string that's output on the frontend.
 *
 * @since 6.0.0
 * @access public
 *
 * @param array $args Allow calling functions to give args to use in future applications.
 * @return string The UA to use on frontend.
 */
function monsterinsights_get_ua_to_output$args = array() ) {
    
$ua monsterinsights_get_ua();
    
$ua apply_filters'monsterinsights_get_ua_to_output'$ua$args );
    return 
monsterinsights_is_valid_ua$ua );
}

/**
 * Helper method for updating a setting's value.
 *
 * @since 6.0.0
 * @access public
 *
 * @param string $key   The setting key.
 * @param string $value The value to set for the key.
 * @return boolean True if updated, false if not.
 */
function monsterinsights_update_option$key ''$value false ) {

    
// If no key, exit
    
if ( empty( $key ) ){
        return 
false;
    }

    if ( empty( 
$value ) ) {
        
$remove_option monsterinsights_delete_option$key );
        return 
$remove_option;
    }

    
$option_name monsterinsights_get_option_name();

    
// First let's grab the current settings

    // if on network panel or if on single site using network settings
    //$settings              = get_site_option( $option_name );
    //$use_network_settings  = ! empty( $use_network_settings['use_network_settings'] ) ? true : false;
    //$is_network            = is_multisite();
    //$update_network_option = true;
    //if ( ! is_network_admin() && ! ( $is_network && $use_network_settings ) ) {
       
$settings get_option$option_name );
    
//   $update_network_option = false;
    //}

    
if ( ! is_array$settings ) ) {
        
$settings = array();
    }

    
// Let's let devs alter that value coming in
    
$value apply_filters'monsterinsights_update_option'$value$key );

    
// Next let's try to update the value
    
$settings$key ] = $value;
    
$did_update false;
    
//if ( $update_network_option ) {
    //    $did_update = update_site_option( $option_name, $settings );
    //} else {
        
$did_update update_option$option_name$settings );
    
//}

    // If it updated, let's update the global variable
    
if ( $did_update ){
        global 
$monsterinsights_settings;
        
$monsterinsights_settings$key ] = $value;
    }

    return 
$did_update;
}

 
/**
 * Helper method for deleting a setting's value.
 *
 * @since 6.0.0
 * @access public
 *
 * @param string $key   The setting key.
 * @return boolean True if removed, false if not.
 */
function monsterinsights_delete_option$key '' ) {
    
// If no key, exit
    
if ( empty( $key ) ){
        return 
false;
    }

    
$option_name monsterinsights_get_option_name();

    
// First let's grab the current settings

    // if on network panel or if on single site using network settings
    //$settings              = get_site_option( $option_name );
    //$use_network_settings  = ! empty( $use_network_settings['use_network_settings'] ) ? true : false;
    //$is_network            = is_multisite();
    //$update_network_option = true;
    //if ( ! is_network_admin() && ! ( $is_network && $use_network_settings ) ) {
       
$settings get_option$option_name );
    
//   $update_network_option = false;
    //}

    // Next let's try to remove the key
    
if( isset( $settings$key ] ) ) {
        unset( 
$settings$key ] );
    }

    
$did_update false;
    
//if ( $update_network_option ) {
    //    $did_update = update_site_option( 'monsterinsights_settings', $settings );
    //} else {
        
$did_update update_option$option_name$settings );
    
//}

    // If it updated, let's update the global variable
    
if ( $did_update ){
        global 
$monsterinsights_settings;
        
$monsterinsights_settings $settings;
    }

    return 
$did_update;
}

 
/**
 * Helper method for deleting multiple settings value.
 *
 * @since 6.0.0
 * @access public
 *
 * @param string $key   The setting key.
 * @return boolean True if removed, false if not.
 */
function monsterinsights_delete_options$keys = array() ) {
    
// If no keys, exit
    
if ( empty( $keys ) || ! is_array$keys ) ){
        return 
false;
    }

    
$option_name monsterinsights_get_option_name();

    
// First let's grab the current settings

    // if on network panel or if on single site using network settings
    //$settings              = get_site_option( $option_name );
    //$use_network_settings  = ! empty( $use_network_settings['use_network_settings'] ) ? true : false;
    //$is_network            = is_multisite();
    //$update_network_option = true;
    //if ( ! is_network_admin() && ! ( $is_network && $use_network_settings ) ) {
       
$settings get_option$option_name );
    
//   $update_network_option = false;
    //}

    // Next let's try to remove the keys
    
foreach ( $keys as $key ) {
        if( isset( 
$settings$key ] ) ) {
            unset( 
$settings$key ] );
        }
    }

    
$did_update false;
    
//if ( $update_network_option ) {
    //    $did_update = update_site_option( 'monsterinsights_settings', $settings );
    //} else {
        
$did_update update_option$option_name$settings );
    
//}

    // If it updated, let's update the global variable
    
if ( $did_update ){
        global 
$monsterinsights_settings;
        
$monsterinsights_settings $settings;
    }

    return 
$did_update;
}

/**
 * Is valid ua code.
 *
 * @access public
 * @since 6.0.0
 *
 * @param string $ua_code UA code to check validity for.
 *
 * @return string|false Return cleaned ua string if valid, else returns false.
 */
function monsterinsights_is_valid_ua$ua_code '' ) {
    
$ua_code = (string) $ua_code// Rare case, but let's make sure it never happens.
    
$ua_code trim$ua_code );

    if ( empty( 
$ua_code ) ) {
        return 
'';
    }

    
// Replace all type of dashes (n-dash, m-dash, minus) with normal dashes.
    
$ua_code str_replace( array( '–''—''−' ), '-'$ua_code );

    if ( 
preg_match"/^(UA|YT|MO)-\d{4,}-\d+$/"strval$ua_code ) ) ) {
        return 
$ua_code;
    } else {
        return 
'';
    }
}

/**
 * Helper method for getting the license information.
 *
 * @since 6.0.0
 * @access public
 *
 * @param string $key   The setting key to retrieve.
 * @param mixed $default_value   The default value of the setting key to retrieve.
 * @return string       The value of the setting.
 */
function monsterinsights_get_license() {
    
$license  MonsterInsights()->license->get_site_license();
    
$license  $license $license MonsterInsights()->license->get_network_license();
    
$default  MonsterInsights()->license->get_default_license_key();
    if ( empty( 
$license ) && ! empty( $default ) ) {
        
$license        = array();
        
$license['key'] = MonsterInsights()->license->get_default_license_key();
    }
    return 
$license;
}

/**
 * Helper method for getting the license key.
 *
 * @since 6.0.0
 * @access public
 *
 * @param string $key   The setting key to retrieve.
 * @param mixed $default_value   The default value of the setting key to retrieve.
 * @return string       The value of the setting.
 */
function monsterinsights_get_license_key() {
    if ( 
monsterinsights_is_pro_version() ) {
        return 
MonsterInsights()->license->get_license_key();
    }
    return 
'';
}

function 
monsterinsights_get_option_name() {
    
//if ( monsterinsights_is_pro_version() ) {
        
return 'monsterinsights_settings';
    
//} else {
    //    return 'monsterinsights_settings';
    //}
}

function 
monsterinsights_export_settings() {
    
$settings monsterinsights_get_options();
    
$exclude  = array(
                
'analytics_profile',
                
'analytics_profile_code',
                
'analytics_profile_name',
                
'oauth_version',
                
'cron_last_run',
                
'monsterinsights_oauth_status',
    );

    foreach ( 
$exclude as $e ) {
        if ( ! empty( 
$settings$e ] ) ) {
            unset( 
$settings$e ] );
        }
    }
    return 
wp_json_encode$settings );
}

/**
 * Always return 'gtag' when grabbing the tracking mode.
 *
 * @param string $value The value to override.
 *
 * @return string
 */
function monsterinsights_force_tracking_mode$value ) {
    return 
'gtag';
}
add_filter'monsterinsights_get_option_tracking_mode''monsterinsights_force_tracking_mode' );

/**
 * Always return 'js' when grabbing the events mode.
 *
 * @param string $value The value to override.
 *
 * @return string
 */
function monsterinsights_force_events_mode$value ) {
    return 
'js';
}
add_filter'monsterinsights_get_option_events_mode''monsterinsights_force_events_mode' );
x

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