C:\xampp\htdocs\landing\wp-content\plugins\google-analytics-for-wordpress\includes\admin\ajax.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
<?php
/**
 * Handles all admin ajax interactions for the MonsterInsights plugin.
 *
 * @since 6.0.0
 *
 * @package MonsterInsights
 * @subpackage Ajax
 * @author  Chris Christoff
 */

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

/**
 * Stores a user setting for the logged-in WordPress User
 *
 * @access public
 * @since 6.0.0
 */
function monsterinsights_ajax_set_user_setting() {

    
// Run a security check first.
    
check_ajax_referer'monsterinsights-set-user-setting''nonce' );

    
// Prepare variables.
    
$name    stripslashes$_POST['name'] );
    
$value   stripslashes$_POST['value'] );

    
// Set user setting.
    
set_user_setting$name$value );

    
// Send back the response.
    
wp_send_json_success();
    
wp_die();

}
add_action'wp_ajax_monsterinsights_install_addon''monsterinsights_ajax_install_addon' );

/**
 * Installs a MonsterInsights addon.
 *
 * @access public
 * @since 6.0.0
 */
function monsterinsights_ajax_install_addon() {

    
// Run a security check first.
    
check_ajax_referer'monsterinsights-install''nonce' );

    if ( ! 
monsterinsights_can_install_plugins() ) {
        
wp_send_json( array(
            
'error' => esc_html__'You are not allowed to install plugins''google-analytics-for-wordpress' ),
        ) );
    }

    
// Install the addon.
    
if ( isset( $_POST['plugin'] ) ) {
        
$download_url $_POST['plugin'];
        global 
$hook_suffix;

        
// Set the current screen to avoid undefined notices.
        
set_current_screen();

        
// Prepare variables.
        
$method '';
        
$url    add_query_arg(
            array(
                
'page' => 'monsterinsights-settings'
            
),
            
admin_url'admin.php' )
        );
        
$url esc_url$url );

        
// Start output bufferring to catch the filesystem form if credentials are needed.
        
ob_start();
        if ( 
false === ( $creds request_filesystem_credentials$url$methodfalsefalsenull ) ) ) {
            
$form ob_get_clean();
            echo 
json_encode( array( 'form' => $form ) );
            
wp_die();
        }

        
// If we are not authenticated, make it happen now.
        
if ( ! WP_Filesystem$creds ) ) {
            
ob_start();
            
request_filesystem_credentials$url$methodtruefalsenull );
            
$form ob_get_clean();
            echo 
json_encode( array( 'form' => $form ) );
            
wp_die();
        }

        
// We do not need any extra credentials if we have gotten this far, so let's install the plugin.
        
monsterinsights_require_upgraderfalse );

        
// Create the plugin upgrader with our custom skin.
        
$installer = new Plugin_Upgrader$skin = new MonsterInsights_Skin() );
        
$installer->install$download_url );

        
// Flush the cache and return the newly installed plugin basename.
        
wp_cache_flush();
        if ( 
$installer->plugin_info() ) {
            
$plugin_basename $installer->plugin_info();
            echo 
json_encode( array( 'plugin' => $plugin_basename ) );
            
wp_die();
        }
    }

    
// Send back a response.
    
echo json_encodetrue );
    
wp_die();

}

add_action'wp_ajax_monsterinsights_activate_addon''monsterinsights_ajax_activate_addon' );
/**
 * Activates a MonsterInsights addon.
 *
 * @access public
 * @since 6.0.0
 */
function monsterinsights_ajax_activate_addon() {

    
// Run a security check first.
    
check_ajax_referer'monsterinsights-activate''nonce' );

    if ( ! 
current_user_can'activate_plugins' ) ) {
        
wp_send_json( array(
            
'error' => esc_html__'You are not allowed to activate plugins''google-analytics-for-wordpress' ),
        ) );
    }

    
// Activate the addon.
    
if ( isset( $_POST['plugin'] ) ) {
        if ( isset( 
$_POST['isnetwork'] ) &&  $_POST['isnetwork'] ) {
            
$activate activate_plugin$_POST['plugin'], NULLtrue );
        } else {
            
$activate activate_plugin$_POST['plugin'] );
        }

        if ( 
is_wp_error$activate ) ) {
            echo 
json_encode( array( 'error' => $activate->get_error_message() ) );
            
wp_die();
        }
    }

    echo 
json_encodetrue );
    
wp_die();

}

add_action'wp_ajax_monsterinsights_deactivate_addon''monsterinsights_ajax_deactivate_addon' );
/**
 * Deactivates a MonsterInsights addon.
 *
 * @access public
 * @since 6.0.0
 */
function monsterinsights_ajax_deactivate_addon() {

    
// Run a security check first.
    
check_ajax_referer'monsterinsights-deactivate''nonce' );

    if ( ! 
current_user_can'deactivate_plugins' ) ) {
        
wp_send_json( array(
            
'error' => esc_html__'You are not allowed to deactivate plugins''google-analytics-for-wordpress' ),
        ) );
    }

    
// Deactivate the addon.
    
if ( isset( $_POST['plugin'] ) ) {
        if ( isset( 
$_POST['isnetwork'] ) && $_POST['isnetwork'] ) {
            
$deactivate deactivate_plugins$_POST['plugin'], falsetrue );
        } else {
            
$deactivate deactivate_plugins$_POST['plugin'] );
        }
    }

    echo 
json_encodetrue );
    
wp_die();
}

/**
 * Called whenever a notice is dismissed in MonsterInsights or its Addons.
 *
 * Updates a key's value in the options table to mark the notice as dismissed,
 * preventing it from displaying again
 *
 * @access public
 * @since 6.0.0
 */
function monsterinsights_ajax_dismiss_notice() {

    
// Run a security check first.
    
check_ajax_referer'monsterinsights-dismiss-notice''nonce' );

    
// Deactivate the notice
    
if ( isset( $_POST['notice'] ) ) {
        
// Init the notice class and mark notice as deactivated
        
MonsterInsights()->notices->dismiss$_POST['notice'] );

        
// Return true
        
echo json_encodetrue );
        
wp_die();
    }

    
// If here, an error occurred
    
echo json_encodefalse );
    
wp_die();

}
add_action'wp_ajax_monsterinsights_ajax_dismiss_notice''monsterinsights_ajax_dismiss_notice' );

/**
 * Dismiss SEMRush CTA
 *
 * @access public
 * @since 7.12.3
 */
function monsterinsights_ajax_dismiss_semrush_cta() {
    
check_ajax_referer'mi-admin-nonce''nonce' );

    if ( ! 
current_user_can'monsterinsights_save_settings' ) ) {
        return;
    }

    
// Deactivate the notice
    
if ( update_option'monsterinsights_dismiss_semrush_cta''yes' ) ) {
        
// Return true
        
wp_send_json( array(
            
'dismissed' => 'yes',
        ) );
        
wp_die();
    }

    
// If here, an error occurred
    
wp_send_json( array(
        
'dismissed' => 'no',
    ) );
    
wp_die();
}
add_action'wp_ajax_monsterinsights_vue_dismiss_semrush_cta''monsterinsights_ajax_dismiss_semrush_cta' );

/**
 * Get the sem rush cta dismiss status value
 */
function monsterinsights_get_sem_rush_cta_status() {
    
check_ajax_referer'mi-admin-nonce''nonce' );

    
$dismissed_cta get_option'monsterinsights_dismiss_semrush_cta''no' );

    
wp_send_json( array(
        
'dismissed' => $dismissed_cta,
    ) );
}

add_action'wp_ajax_monsterinsights_get_sem_rush_cta_status''monsterinsights_get_sem_rush_cta_status' );
x

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