Passed
Push — master ( 1e9d3c...0e5897 )
by Chris
02:47
created
includes/admin/ajax.php 1 patch
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -51,58 +51,58 @@  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.
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 93
 	    monsterinsights_require_upgrader( false );
94 94
 
95
-        // Create the plugin upgrader with our custom skin.
96
-        $installer = new Plugin_Upgrader( $skin = new MonsterInsights_Skin() );
97
-        $installer->install( $download_url );
98
-
99
-        // Flush the cache and return the newly installed plugin basename.
100
-        wp_cache_flush();
101
-        if ( $installer->plugin_info() ) {
102
-            $plugin_basename = $installer->plugin_info();
103
-            echo json_encode( array( 'plugin' => $plugin_basename ) );
104
-            wp_die();
105
-        }
95
+	// Create the plugin upgrader with our custom skin.
96
+	$installer = new Plugin_Upgrader( $skin = new MonsterInsights_Skin() );
97
+	$installer->install( $download_url );
98
+
99
+	// Flush the cache and return the newly installed plugin basename.
100
+	wp_cache_flush();
101
+	if ( $installer->plugin_info() ) {
102
+	    $plugin_basename = $installer->plugin_info();
103
+	    echo json_encode( array( 'plugin' => $plugin_basename ) );
104
+	    wp_die();
105
+	}
106 106
     }
107 107
 
108 108
     // Send back a response.
@@ -124,21 +124,21 @@  discard block
 block discarded – undo
124 124
     check_ajax_referer( 'monsterinsights-activate', 'nonce' );
125 125
 
126 126
     if ( ! current_user_can( 'activate_plugins' ) ) {
127
-        echo json_encode( true );
127
+	echo json_encode( true );
128 128
     }
129 129
 
130 130
     // Activate the addon.
131 131
     if ( isset( $_POST['plugin'] ) ) {
132
-        if ( isset( $_POST['isnetwork'] ) &&  $_POST['isnetwork'] ) {
133
-            $activate = activate_plugin( $_POST['plugin'], NULL, true );
134
-        } else {
135
-            $activate = activate_plugin( $_POST['plugin'] );
136
-        }
137
-
138
-        if ( is_wp_error( $activate ) ) {
139
-            echo json_encode( array( 'error' => $activate->get_error_message() ) );
140
-            wp_die();
141
-        }
132
+	if ( isset( $_POST['isnetwork'] ) &&  $_POST['isnetwork'] ) {
133
+	    $activate = activate_plugin( $_POST['plugin'], NULL, true );
134
+	} else {
135
+	    $activate = activate_plugin( $_POST['plugin'] );
136
+	}
137
+
138
+	if ( is_wp_error( $activate ) ) {
139
+	    echo json_encode( array( 'error' => $activate->get_error_message() ) );
140
+	    wp_die();
141
+	}
142 142
     }
143 143
 
144 144
     echo json_encode( true );
@@ -159,16 +159,16 @@  discard block
 block discarded – undo
159 159
     check_ajax_referer( 'monsterinsights-deactivate', 'nonce' );
160 160
 
161 161
     if ( ! current_user_can( 'activate_plugins' ) ) {
162
-        echo json_encode( true );
162
+	echo json_encode( true );
163 163
     }
164 164
 
165 165
     // Deactivate the addon.
166 166
     if ( isset( $_POST['plugin'] ) ) {
167
-        if ( isset( $_POST['isnetwork'] ) && $_POST['isnetwork'] ) {
168
-            $deactivate = deactivate_plugins( $_POST['plugin'], false, true );
169
-        } else {
170
-            $deactivate = deactivate_plugins( $_POST['plugin'] );
171
-        }
167
+	if ( isset( $_POST['isnetwork'] ) && $_POST['isnetwork'] ) {
168
+	    $deactivate = deactivate_plugins( $_POST['plugin'], false, true );
169
+	} else {
170
+	    $deactivate = deactivate_plugins( $_POST['plugin'] );
171
+	}
172 172
     }
173 173
 
174 174
     echo json_encode( true );
@@ -191,12 +191,12 @@  discard block
 block discarded – undo
191 191
 
192 192
     // Deactivate the notice
193 193
     if ( isset( $_POST['notice'] ) ) {
194
-        // Init the notice class and mark notice as deactivated
195
-        MonsterInsights()->notices->dismiss( $_POST['notice'] );
194
+	// Init the notice class and mark notice as deactivated
195
+	MonsterInsights()->notices->dismiss( $_POST['notice'] );
196 196
 
197
-        // Return true
198
-        echo json_encode( true );
199
-        wp_die();
197
+	// Return true
198
+	echo json_encode( true );
199
+	wp_die();
200 200
     }
201 201
 
202 202
     // If here, an error occurred
Please login to merge, or discard this patch.