Passed
Push — master ( e0709e...805894 )
by Chris
06:51
created
includes/admin/ajax.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -51,60 +51,60 @@  discard block
 block discarded – undo
51 51
     check_ajax_referer( 'monsterinsights-install', 'nonce' );
52 52
 
53 53
     if ( ! current_user_can( 'install_plugins' ) ) {
54
-        echo json_encode( true );
54
+	echo json_encode( true );
55 55
     }
56 56
 
57 57
     // Install the addon.
58 58
     if ( isset( $_POST['plugin'] ) ) {
59
-        $download_url = $_POST['plugin'];
60
-        global $hook_suffix;
61
-
62
-        // Set the current screen to avoid undefined notices.
63
-        set_current_screen();
64
-
65
-        // Prepare variables.
66
-        $method = '';
67
-        $url    = add_query_arg(
68
-            array(
69
-                'page' => 'monsterinsights-settings'
70
-            ),
71
-            admin_url( 'admin.php' )
72
-        );
73
-        $url = esc_url( $url );
74
-
75
-        // Start output bufferring to catch the filesystem form if credentials are needed.
76
-        ob_start();
77
-        if ( false === ( $creds = request_filesystem_credentials( $url, $method, false, false, null ) ) ) {
78
-            $form = ob_get_clean();
79
-            echo json_encode( array( 'form' => $form ) );
80
-            wp_die();
81
-        }
82
-
83
-        // If we are not authenticated, make it happen now.
84
-        if ( ! WP_Filesystem( $creds ) ) {
85
-            ob_start();
86
-            request_filesystem_credentials( $url, $method, true, false, null );
87
-            $form = ob_get_clean();
88
-            echo json_encode( array( 'form' => $form ) );
89
-            wp_die();
90
-        }
91
-
92
-        // We do not need any extra credentials if we have gotten this far, so let's install the plugin.
93
-        require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
94
-        $base = MonsterInsights();
95
-        require_once plugin_dir_path( $base->file ) . '/includes/admin/licensing/skin.php';
96
-
97
-        // Create the plugin upgrader with our custom skin.
98
-        $installer = new Plugin_Upgrader( $skin = new MonsterInsights_Skin() );
99
-        $installer->install( $download_url );
100
-
101
-        // Flush the cache and return the newly installed plugin basename.
102
-        wp_cache_flush();
103
-        if ( $installer->plugin_info() ) {
104
-            $plugin_basename = $installer->plugin_info();
105
-            echo json_encode( array( 'plugin' => $plugin_basename ) );
106
-            wp_die();
107
-        }
59
+	$download_url = $_POST['plugin'];
60
+	global $hook_suffix;
61
+
62
+	// Set the current screen to avoid undefined notices.
63
+	set_current_screen();
64
+
65
+	// Prepare variables.
66
+	$method = '';
67
+	$url    = add_query_arg(
68
+	    array(
69
+		'page' => 'monsterinsights-settings'
70
+	    ),
71
+	    admin_url( 'admin.php' )
72
+	);
73
+	$url = esc_url( $url );
74
+
75
+	// Start output bufferring to catch the filesystem form if credentials are needed.
76
+	ob_start();
77
+	if ( false === ( $creds = request_filesystem_credentials( $url, $method, false, false, null ) ) ) {
78
+	    $form = ob_get_clean();
79
+	    echo json_encode( array( 'form' => $form ) );
80
+	    wp_die();
81
+	}
82
+
83
+	// If we are not authenticated, make it happen now.
84
+	if ( ! WP_Filesystem( $creds ) ) {
85
+	    ob_start();
86
+	    request_filesystem_credentials( $url, $method, true, false, null );
87
+	    $form = ob_get_clean();
88
+	    echo json_encode( array( 'form' => $form ) );
89
+	    wp_die();
90
+	}
91
+
92
+	// We do not need any extra credentials if we have gotten this far, so let's install the plugin.
93
+	require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
94
+	$base = MonsterInsights();
95
+	require_once plugin_dir_path( $base->file ) . '/includes/admin/licensing/skin.php';
96
+
97
+	// Create the plugin upgrader with our custom skin.
98
+	$installer = new Plugin_Upgrader( $skin = new MonsterInsights_Skin() );
99
+	$installer->install( $download_url );
100
+
101
+	// Flush the cache and return the newly installed plugin basename.
102
+	wp_cache_flush();
103
+	if ( $installer->plugin_info() ) {
104
+	    $plugin_basename = $installer->plugin_info();
105
+	    echo json_encode( array( 'plugin' => $plugin_basename ) );
106
+	    wp_die();
107
+	}
108 108
     }
109 109
 
110 110
     // Send back a response.
@@ -126,21 +126,21 @@  discard block
 block discarded – undo
126 126
     check_ajax_referer( 'monsterinsights-activate', 'nonce' );
127 127
 
128 128
     if ( ! current_user_can( 'activate_plugins' ) ) {
129
-        echo json_encode( true );
129
+	echo json_encode( true );
130 130
     }
131 131
 
132 132
     // Activate the addon.
133 133
     if ( isset( $_POST['plugin'] ) ) {
134
-        if ( isset( $_POST['isnetwork'] ) &&  $_POST['isnetwork'] ) {
135
-            $activate = activate_plugin( $_POST['plugin'], NULL, true );
136
-        } else {
137
-            $activate = activate_plugin( $_POST['plugin'] );
138
-        }
139
-
140
-        if ( is_wp_error( $activate ) ) {
141
-            echo json_encode( array( 'error' => $activate->get_error_message() ) );
142
-            wp_die();
143
-        }
134
+	if ( isset( $_POST['isnetwork'] ) &&  $_POST['isnetwork'] ) {
135
+	    $activate = activate_plugin( $_POST['plugin'], NULL, true );
136
+	} else {
137
+	    $activate = activate_plugin( $_POST['plugin'] );
138
+	}
139
+
140
+	if ( is_wp_error( $activate ) ) {
141
+	    echo json_encode( array( 'error' => $activate->get_error_message() ) );
142
+	    wp_die();
143
+	}
144 144
     }
145 145
 
146 146
     echo json_encode( true );
@@ -161,16 +161,16 @@  discard block
 block discarded – undo
161 161
     check_ajax_referer( 'monsterinsights-deactivate', 'nonce' );
162 162
 
163 163
     if ( ! current_user_can( 'activate_plugins' ) ) {
164
-        echo json_encode( true );
164
+	echo json_encode( true );
165 165
     }
166 166
 
167 167
     // Deactivate the addon.
168 168
     if ( isset( $_POST['plugin'] ) ) {
169
-        if ( isset( $_POST['isnetwork'] ) && $_POST['isnetwork'] ) {
170
-            $deactivate = deactivate_plugins( $_POST['plugin'], false, true );
171
-        } else {
172
-            $deactivate = deactivate_plugins( $_POST['plugin'] );
173
-        }
169
+	if ( isset( $_POST['isnetwork'] ) && $_POST['isnetwork'] ) {
170
+	    $deactivate = deactivate_plugins( $_POST['plugin'], false, true );
171
+	} else {
172
+	    $deactivate = deactivate_plugins( $_POST['plugin'] );
173
+	}
174 174
     }
175 175
 
176 176
     echo json_encode( true );
@@ -193,12 +193,12 @@  discard block
 block discarded – undo
193 193
 
194 194
     // Deactivate the notice
195 195
     if ( isset( $_POST['notice'] ) ) {
196
-        // Init the notice class and mark notice as deactivated
197
-        MonsterInsights()->notices->dismiss( $_POST['notice'] );
196
+	// Init the notice class and mark notice as deactivated
197
+	MonsterInsights()->notices->dismiss( $_POST['notice'] );
198 198
 
199
-        // Return true
200
-        echo json_encode( true );
201
-        wp_die();
199
+	// Return true
200
+	echo json_encode( true );
201
+	wp_die();
202 202
     }
203 203
 
204 204
     // If here, an error occurred
Please login to merge, or discard this patch.