Passed
Branch master (29aa47)
by Chris
05:48
created
includes/admin/notice.php 1 patch
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -36,11 +36,11 @@  discard block
 block discarded – undo
36 36
      */
37 37
     public function __construct() {
38 38
 
39
-        // Populate $notices
40
-        $this->notices = get_option( 'monsterinsights_notices' );
41
-        if ( ! is_array( $this->notices ) ) {
42
-            $this->notices = array();
43
-        }
39
+	// Populate $notices
40
+	$this->notices = get_option( 'monsterinsights_notices' );
41
+	if ( ! is_array( $this->notices ) ) {
42
+	    $this->notices = array();
43
+	}
44 44
 
45 45
     }
46 46
 
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
      */
56 56
 
57 57
     public function is_dismissed( $notice ) {
58
-        if ( ! isset( $this->notices[ $notice ] ) ) {
59
-            return false;
60
-        }
61
-        return true;
58
+	if ( ! isset( $this->notices[ $notice ] ) ) {
59
+	    return false;
60
+	}
61
+	return true;
62 62
 
63 63
     }
64 64
 
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
      * @return null
73 73
      */
74 74
     public function dismiss( $notice ) {
75
-        $this->notices[ $notice ] = true;
76
-        update_option( 'monsterinsights_notices', $this->notices );
75
+	$this->notices[ $notice ] = true;
76
+	update_option( 'monsterinsights_notices', $this->notices );
77 77
 
78 78
     }
79 79
 
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
      * @return null
89 89
      */
90 90
     public function undismiss( $notice ) {
91
-        unset( $this->notices[ $notice ] );
92
-        update_option( 'monsterinsights_notices', $this->notices );
91
+	unset( $this->notices[ $notice ] );
92
+	update_option( 'monsterinsights_notices', $this->notices );
93 93
 
94 94
     }
95 95
 
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
      * @param bool      $is_dismissible     User can Dismiss Message (default: false)
109 109
      */ 
110 110
     public function display_inline_notice( $name, $title, $message, $type = 'success', $is_dismissible = false, $args = array() ) {
111
-        /* Available/Planned $args options
111
+	/* Available/Planned $args options
112 112
          * $args = array(
113 113
          *  'primary'    => array(
114 114
          *      'text'   => '',
@@ -127,110 +127,110 @@  discard block
 block discarded – undo
127 127
          */
128 128
 
129 129
 
130
-        // Check if the notice is dismissible, and if so has been dismissed.
131
-        if ( $is_dismissible && $this->is_dismissed( $name ) ) {
132
-            // Nothing to show here, return!
133
-            return '';
134
-        }
130
+	// Check if the notice is dismissible, and if so has been dismissed.
131
+	if ( $is_dismissible && $this->is_dismissed( $name ) ) {
132
+	    // Nothing to show here, return!
133
+	    return '';
134
+	}
135 135
 
136
-        $dismissible = ( $is_dismissible ) ? ' is-dismissible': '';
136
+	$dismissible = ( $is_dismissible ) ? ' is-dismissible': '';
137 137
 
138
-        // Display inline notice
139
-        ob_start();
140
-        ?>
138
+	// Display inline notice
139
+	ob_start();
140
+	?>
141 141
         <div class="monsterinsights-notice <?php echo 'monsterinsights-' . esc_attr( $type ) . '-notice' . $dismissible; ?>" data-notice="<?php echo esc_attr( $name ); ?>">
142 142
             <div class="monsterinsights-notice-icon <?php echo 'monsterinsights-' . esc_attr( $type ) . '-notice-icon'?>">
143 143
             </div>
144 144
             <div class="monsterinsights-notice-text <?php echo 'monsterinsights-' . esc_attr( $type ) . '-notice-text'?>">
145 145
                 <?php
146
-                // Title
147
-                if ( ! empty ( $title ) ) {
148
-                    ?>
146
+		// Title
147
+		if ( ! empty ( $title ) ) {
148
+		    ?>
149 149
                     <p class="monsterinsights-notice-title"><?php echo esc_html( $title ); ?></p>
150 150
                     <?php
151
-                }
151
+		}
152 152
 
153
-                // Message
154
-                if ( ! empty( $message ) ) {
155
-                    if ( empty( $args['skip_message_escape'] ) ) {
156
-                        ?>
153
+		// Message
154
+		if ( ! empty( $message ) ) {
155
+		    if ( empty( $args['skip_message_escape'] ) ) {
156
+			?>
157 157
                         <p class="monsterinsights-notice-message"><?php echo esc_html( $message ); ?></p>
158 158
                         <?php
159
-                    } else {
160
-                        ?>
159
+		    } else {
160
+			?>
161 161
                         <p class="monsterinsights-notice-message"><?php echo $message; ?></p>
162 162
                         <?php
163
-                    }
164
-                }
163
+		    }
164
+		}
165 165
                 
166
-                // Primary Button
167
-                if ( ! empty( $args['primary']['text'] ) ) {
166
+		// Primary Button
167
+		if ( ! empty( $args['primary']['text'] ) ) {
168 168
                     
169
-                    $text = '';
170
-                    if ( ! empty( $args['primary']['text'] ) ) {
171
-                        $text = $args['primary']['text'];
172
-                    }
173
-
174
-                    $url = '#';
175
-                    if ( ! empty( $args['primary']['url'] ) ) {
176
-                        $url = $args['primary']['url'];
177
-                    }
178
-
179
-                    $target = '';
180
-                    if ( ! empty( $args['primary']['target'] ) && $args['primary']['target'] === 'blank') {
181
-                        $target = ' target="_blank" rel="noopener noreferrer"';
182
-                    }
183
-
184
-                    $class = 'button button-primary';
185
-                    if ( ! empty( $args['primary']['class'] ) ) {
186
-                        $class = ' class="'. $args['primary']['class'] . '"';
187
-                    }
188
-                    ?>
169
+		    $text = '';
170
+		    if ( ! empty( $args['primary']['text'] ) ) {
171
+			$text = $args['primary']['text'];
172
+		    }
173
+
174
+		    $url = '#';
175
+		    if ( ! empty( $args['primary']['url'] ) ) {
176
+			$url = $args['primary']['url'];
177
+		    }
178
+
179
+		    $target = '';
180
+		    if ( ! empty( $args['primary']['target'] ) && $args['primary']['target'] === 'blank') {
181
+			$target = ' target="_blank" rel="noopener noreferrer"';
182
+		    }
183
+
184
+		    $class = 'button button-primary';
185
+		    if ( ! empty( $args['primary']['class'] ) ) {
186
+			$class = ' class="'. $args['primary']['class'] . '"';
187
+		    }
188
+		    ?>
189 189
                     <a href="<?php echo esc_attr( $url ); ?>"<?php echo $target; ?><?php echo $class;?>><?php echo esc_html( $text ); ?></a>
190 190
                     <?php
191
-                }
191
+		}
192 192
 
193
-                // Secondary Button
194
-                if ( ! empty( $args['secondary']['text'] ) ) {
193
+		// Secondary Button
194
+		if ( ! empty( $args['secondary']['text'] ) ) {
195 195
                     
196
-                    $text = '';
197
-                    if ( ! empty( $args['secondary']['text'] ) ) {
198
-                        $text = $args['secondary']['text'];
199
-                    }
200
-
201
-                    $url = '#';
202
-                    if ( ! empty( $args['secondary']['url'] ) ) {
203
-                        $url = $args['secondary']['url'];
204
-                    }           
205
-
206
-                    $target = '';
207
-                    if ( ! empty( $args['secondary']['target'] ) && $args['secondary']['target'] === 'blank') {
208
-                        $target = ' target="_blank" rel="noopener noreferrer"';
209
-                    }
210
-
211
-                    $class = 'button button-secondary';
212
-                    if ( ! empty( $args['secondary']['class'] ) ) {
213
-                        $class = ' class="'. $args['secondary']['class'] . '"';
214
-                    }
215
-                    ?>
196
+		    $text = '';
197
+		    if ( ! empty( $args['secondary']['text'] ) ) {
198
+			$text = $args['secondary']['text'];
199
+		    }
200
+
201
+		    $url = '#';
202
+		    if ( ! empty( $args['secondary']['url'] ) ) {
203
+			$url = $args['secondary']['url'];
204
+		    }           
205
+
206
+		    $target = '';
207
+		    if ( ! empty( $args['secondary']['target'] ) && $args['secondary']['target'] === 'blank') {
208
+			$target = ' target="_blank" rel="noopener noreferrer"';
209
+		    }
210
+
211
+		    $class = 'button button-secondary';
212
+		    if ( ! empty( $args['secondary']['class'] ) ) {
213
+			$class = ' class="'. $args['secondary']['class'] . '"';
214
+		    }
215
+		    ?>
216 216
                     <a href="<?php echo esc_attr( $url ); ?>"<?php echo $target; ?><?php echo $class;?>><?php echo esc_html( $text ); ?></a>
217 217
                     <?php
218
-                }
218
+		}
219 219
 
220
-                // Dismiss Button
221
-                if ( $is_dismissible ) {
222
-                    ?>
220
+		// Dismiss Button
221
+		if ( $is_dismissible ) {
222
+		    ?>
223 223
                     <button type="button" class="notice-dismiss<?php echo $dismissible; ?>">
224 224
                         <span class="screen-reader-text">
225 225
                             <?php esc_html_e( 'Dismiss this notice', 'google-analytics-for-wordpress' ); ?>
226 226
                         </span>
227 227
                     </button>
228 228
                     <?php
229
-                }
230
-                ?>
229
+		}
230
+		?>
231 231
             </div>
232 232
         </div>
233 233
         <?php
234
-        return ob_get_clean();
234
+	return ob_get_clean();
235 235
     }
236 236
 }
237 237
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/licensing/skin.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
      */
26 26
     public function __construct( $args = array() ) {
27 27
 
28
-        parent::__construct();
28
+	parent::__construct();
29 29
 
30 30
     }
31 31
 
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
      */
39 39
     public function set_upgrader( &$upgrader ) {
40 40
 
41
-        if ( is_object( $upgrader ) ) {
42
-            $this->upgrader =& $upgrader;
43
-        }
41
+	if ( is_object( $upgrader ) ) {
42
+	    $this->upgrader =& $upgrader;
43
+	}
44 44
 
45 45
     }
46 46
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
      */
54 54
     public function set_result( $result ) {
55 55
 
56
-        $this->result = $result;
56
+	$this->result = $result;
57 57
 
58 58
     }
59 59
 
@@ -82,10 +82,10 @@  discard block
 block discarded – undo
82 82
      */
83 83
     function error( $errors ) {
84 84
 
85
-        if ( ! empty( $errors ) ) {
86
-            echo json_encode( array( 'error' => esc_html__( 'There was an error installing the addon. Please try again.', 'google-analytics-for-wordpress' ) ) );
87
-            die;
88
-        }
85
+	if ( ! empty( $errors ) ) {
86
+	    echo json_encode( array( 'error' => esc_html__( 'There was an error installing the addon. Please try again.', 'google-analytics-for-wordpress' ) ) );
87
+	    die;
88
+	}
89 89
 
90 90
     }
91 91
 
Please login to merge, or discard this patch.
includes/admin/licensing/autoupdate.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -13,20 +13,20 @@  discard block
 block discarded – undo
13 13
 
14 14
     // If this is multisite and is not on the main site, return early.
15 15
     if ( is_multisite() && ! is_main_site() ) {
16
-        return $update;
16
+	return $update;
17 17
     }
18 18
     
19 19
     // If we don't have everything we need, return early.
20 20
     $item = (array) $item;
21 21
     if ( ! isset( $item['new_version'] ) || ! isset( $item['slug'] ) ) {
22
-        return $update;
22
+	return $update;
23 23
     }
24 24
 
25 25
     // If the plugin isn't ours, return early.
26 26
     $is_free = 'google-analytics-for-wordpress' === $item['slug'];
27 27
     $is_paid = isset( $item['monsterinsights_plugin'] ); // see updater class
28 28
     if ( ! $is_free && ! $is_paid ) {
29
-        return $update;
29
+	return $update;
30 30
     }
31 31
 
32 32
     $version           = $is_free ? MONSTERINSIGHTS_LITE_VERSION : $item['old_version'];
@@ -36,20 +36,20 @@  discard block
 block discarded – undo
36 36
     
37 37
     // If the opt in update allows major updates but there is no major version update, return early.
38 38
     if ( $current_major < $new_major ) {
39
-        if ( $automatic_updates === 'all' ) {
40
-            return true;
41
-        } else {
42
-            return $update;
43
-        }
39
+	if ( $automatic_updates === 'all' ) {
40
+	    return true;
41
+	} else {
42
+	    return $update;
43
+	}
44 44
     }
45 45
     
46 46
     // If the opt in update allows minor updates but there is no minor version update, return early.
47 47
     if ( $current_major == $new_major ) {
48
-        if ( $automatic_updates === 'all' || $automatic_updates === 'minor' ) {
49
-            return true;
50
-        } else {
51
-            return $update;
52
-        }
48
+	if ( $automatic_updates === 'all' || $automatic_updates === 'minor' ) {
49
+	    return true;
50
+	} else {
51
+	    return $update;
52
+	}
53 53
     }
54 54
 
55 55
     // All our checks have passed - this plugin can be updated!
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 function monsterinsights_get_major_version( $version ) {
88 88
     $exploded_version = explode( '.', $version );
89 89
     if ( isset( $exploded_version[2] ) ) {
90
-        return $exploded_version[0] . '.' . $exploded_version[1] . '.' . $exploded_version[2];
90
+	return $exploded_version[0] . '.' . $exploded_version[1] . '.' . $exploded_version[2];
91 91
     } else {
92
-        return $exploded_version[0] . '.' . $exploded_version[1] . '.0';
92
+	return $exploded_version[0] . '.' . $exploded_version[1] . '.0';
93 93
     }
94 94
 }
95 95
\ No newline at end of file
Please login to merge, or discard this patch.
includes/options.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -195,14 +195,14 @@  discard block
 block discarded – undo
195 195
 }
196 196
 
197 197
  /**
198
- * Helper method for deleting a setting's value.
199
- *
200
- * @since 6.0.0
201
- * @access public
202
- *
203
- * @param string $key   The setting key.
204
- * @return boolean True if removed, false if not.
205
- */
198
+  * Helper method for deleting a setting's value.
199
+  *
200
+  * @since 6.0.0
201
+  * @access public
202
+  *
203
+  * @param string $key   The setting key.
204
+  * @return boolean True if removed, false if not.
205
+  */
206 206
 function monsterinsights_delete_option( $key = '' ) {
207 207
 	// If no key, exit
208 208
 	if ( empty( $key ) ){
@@ -245,14 +245,14 @@  discard block
 block discarded – undo
245 245
 }
246 246
 
247 247
  /**
248
- * Helper method for deleting multiple settings value.
249
- *
250
- * @since 6.0.0
251
- * @access public
252
- *
253
- * @param string $key   The setting key.
254
- * @return boolean True if removed, false if not.
255
- */
248
+  * Helper method for deleting multiple settings value.
249
+  *
250
+  * @since 6.0.0
251
+  * @access public
252
+  *
253
+  * @param string $key   The setting key.
254
+  * @return boolean True if removed, false if not.
255
+  */
256 256
 function monsterinsights_delete_options( $keys = array() ) {
257 257
 	// If no keys, exit
258 258
 	if ( empty( $keys ) || ! is_array( $keys ) ){
Please login to merge, or discard this patch.
includes/frontend/class-tracking-abstract.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
      * @return array Array of the options to use.
59 59
      */
60 60
     public function frontend_tracking_options( ) {
61
-        return array();
61
+	return array();
62 62
     }
63 63
 
64 64
     /**
@@ -74,6 +74,6 @@  discard block
 block discarded – undo
74 74
      * @return string Javascript to output.
75 75
      */
76 76
     public function frontend_output( ) {
77
-         return "<!-- MonsterInsights Abstract Tracking class -->";
77
+	 return "<!-- MonsterInsights Abstract Tracking class -->";
78 78
     }
79 79
 }
80 80
\ No newline at end of file
Please login to merge, or discard this patch.
includes/frontend/tracking/class-tracking-preview.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      * @return array Array of the options to use.
58 58
      */
59 59
     public function frontend_tracking_options( ) {
60
-        return array();
60
+	return array();
61 61
     }
62 62
 
63 63
     /**
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
      * @return string Javascript to output.
74 74
      */
75 75
     public function frontend_output( ) {
76
-        $output  = '<!-- This site uses the Google Analytics by MonsterInsights plugin v ' . MONSTERINSIGHTS_VERSION .' - https://www.monsterinsights.com/ -->';
77
-        $output .=  '<!-- ' . esc_html__( "You are currently in a preview window. MonsterInsights doesn't track preview window traffic to avoid false visit reports.", 'google-analytics-for-wordpress' ) . ' -->';
78
-        $output .=  '<!-- / Google Analytics by MonsterInsights -->';
79
-        return $output;
76
+	$output  = '<!-- This site uses the Google Analytics by MonsterInsights plugin v ' . MONSTERINSIGHTS_VERSION .' - https://www.monsterinsights.com/ -->';
77
+	$output .=  '<!-- ' . esc_html__( "You are currently in a preview window. MonsterInsights doesn't track preview window traffic to avoid false visit reports.", 'google-analytics-for-wordpress' ) . ' -->';
78
+	$output .=  '<!-- / Google Analytics by MonsterInsights -->';
79
+	return $output;
80 80
     }
81 81
 }
82 82
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/capabilities.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -35,54 +35,54 @@
 block discarded – undo
35 35
 function monsterinsights_add_capabilities( $caps, $cap, $user_id, $args ) {
36 36
  
37 37
     switch( $cap ) {
38
-        case 'monsterinsights_view_dashboard' :
39
-            $roles = monsterinsights_get_option( 'view_reports', array() );
38
+	case 'monsterinsights_view_dashboard' :
39
+	    $roles = monsterinsights_get_option( 'view_reports', array() );
40 40
 
41
-            $user_can_via_settings = false;
42
-            if ( ! empty( $roles ) && is_array( $roles ) ) {
43
-                foreach ( $roles as $role ) {
44
-                    if ( is_string( $role ) ) {
45
-                        if ( user_can( $user_id, $role ) ) {
46
-                            $user_can_via_settings = true;
47
-                            break;
48
-                        }
49
-                    }
50
-                }
51
-            } else if ( ! empty( $roles ) && is_string( $roles ) ) {
52
-                if ( user_can( $user_id, $roles ) ) {
53
-                    $user_can_via_settings = true;
54
-                }
55
-            }
41
+	    $user_can_via_settings = false;
42
+	    if ( ! empty( $roles ) && is_array( $roles ) ) {
43
+		foreach ( $roles as $role ) {
44
+		    if ( is_string( $role ) ) {
45
+			if ( user_can( $user_id, $role ) ) {
46
+			    $user_can_via_settings = true;
47
+			    break;
48
+			}
49
+		    }
50
+		}
51
+	    } else if ( ! empty( $roles ) && is_string( $roles ) ) {
52
+		if ( user_can( $user_id, $roles ) ) {
53
+		    $user_can_via_settings = true;
54
+		}
55
+	    }
56 56
 
57
-            if ( user_can( $user_id, 'manage_options' ) || $user_can_via_settings ) {
58
-                $caps = array();
59
-            }
57
+	    if ( user_can( $user_id, 'manage_options' ) || $user_can_via_settings ) {
58
+		$caps = array();
59
+	    }
60 60
             
61
-            break;
62
-         case 'monsterinsights_save_settings' :
63
-            $roles = monsterinsights_get_option( 'save_settings', array() );
61
+	    break;
62
+	 case 'monsterinsights_save_settings' :
63
+	    $roles = monsterinsights_get_option( 'save_settings', array() );
64 64
 
65
-            $user_can_via_settings = false;
66
-            if ( ! empty( $roles ) && is_array( $roles ) ) {
67
-                foreach ( $roles as $role ) {
68
-                    if ( is_string( $role ) ) {
69
-                        if ( user_can( $user_id, $role ) ) {
70
-                            $user_can_via_settings = true;
71
-                            break;
72
-                        }
73
-                    }
74
-                }
75
-            } else if ( ! empty( $roles ) && is_string( $roles ) ) {
76
-                 if ( user_can( $user_id, $roles ) ) {
77
-                    $user_can_via_settings = true;
78
-                }
79
-            }
65
+	    $user_can_via_settings = false;
66
+	    if ( ! empty( $roles ) && is_array( $roles ) ) {
67
+		foreach ( $roles as $role ) {
68
+		    if ( is_string( $role ) ) {
69
+			if ( user_can( $user_id, $role ) ) {
70
+			    $user_can_via_settings = true;
71
+			    break;
72
+			}
73
+		    }
74
+		}
75
+	    } else if ( ! empty( $roles ) && is_string( $roles ) ) {
76
+		 if ( user_can( $user_id, $roles ) ) {
77
+		    $user_can_via_settings = true;
78
+		}
79
+	    }
80 80
 
81
-            if ( user_can( $user_id, 'manage_options' ) || $user_can_via_settings ) {
82
-                $caps = array();
83
-            }
81
+	    if ( user_can( $user_id, 'manage_options' ) || $user_can_via_settings ) {
82
+		$caps = array();
83
+	    }
84 84
 
85
-            break;
85
+	    break;
86 86
     }
87 87
     return $caps;
88 88
 }
Please login to merge, or discard this patch.
includes/admin/ajax.php 1 patch
Indentation   +71 added lines, -71 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';
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 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
-        }
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.
includes/admin/licensing/updater.php 1 patch
Indentation   +180 added lines, -180 removed lines patch added patch discarded remove patch
@@ -105,39 +105,39 @@  discard block
 block discarded – undo
105 105
      * @param array $config Array of updater config args.
106 106
      */
107 107
     public function __construct( array $config ) {
108
-        // Set class properties.
109
-        $accepted_args = array(
110
-            'plugin_name',
111
-            'plugin_slug',
112
-            'plugin_path',
113
-            'plugin_url',
114
-            'remote_url',
115
-            'version',
116
-            'key'
117
-        );
118
-        foreach ( $accepted_args as $arg ) {
119
-            $this->$arg = $config[$arg];
120
-        }
121
-
122
-        // If the user cannot update plugins, stop processing here.
123
-        if ( ! current_user_can( 'update_plugins' ) && ( ! defined( 'DOING_CRON' ) || ! DOING_CRON ) ) {
124
-            return;
125
-        }
126
-
127
-        // If it's our site, then return so we don't redirect loop.
128
-        if ( strpos( site_url(), 'monsterinsights.com' ) !== false ) {
129
-            return;
130
-        }
131
-
132
-        // Load the updater hooks and filters.
133
-        add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'update_plugins_filter' ) );
134
-
135
-        add_filter( 'http_request_args', array( $this, 'http_request_args' ), 10, 2 );
136
-        add_filter( 'plugins_api', array( $this, 'plugins_api' ), 10, 3 );
137
-
138
-        // ManageWP premium update filters
139
-        //add_filter( 'mwp_premium_update_notification', array( $this, 'premium_update_push' ) );
140
-        //add_filter( 'mwp_premium_perform_update', array( $this, 'premium_update' ) );
108
+	// Set class properties.
109
+	$accepted_args = array(
110
+	    'plugin_name',
111
+	    'plugin_slug',
112
+	    'plugin_path',
113
+	    'plugin_url',
114
+	    'remote_url',
115
+	    'version',
116
+	    'key'
117
+	);
118
+	foreach ( $accepted_args as $arg ) {
119
+	    $this->$arg = $config[$arg];
120
+	}
121
+
122
+	// If the user cannot update plugins, stop processing here.
123
+	if ( ! current_user_can( 'update_plugins' ) && ( ! defined( 'DOING_CRON' ) || ! DOING_CRON ) ) {
124
+	    return;
125
+	}
126
+
127
+	// If it's our site, then return so we don't redirect loop.
128
+	if ( strpos( site_url(), 'monsterinsights.com' ) !== false ) {
129
+	    return;
130
+	}
131
+
132
+	// Load the updater hooks and filters.
133
+	add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'update_plugins_filter' ) );
134
+
135
+	add_filter( 'http_request_args', array( $this, 'http_request_args' ), 10, 2 );
136
+	add_filter( 'plugins_api', array( $this, 'plugins_api' ), 10, 3 );
137
+
138
+	// ManageWP premium update filters
139
+	//add_filter( 'mwp_premium_update_notification', array( $this, 'premium_update_push' ) );
140
+	//add_filter( 'mwp_premium_perform_update', array( $this, 'premium_update' ) );
141 141
 
142 142
 	    // Add additional info if the license is expired.
143 143
 	    add_action( 'in_plugin_update_message-'. $this->plugin_path, array( $this, 'maybe_show_license_expired_message' ), 10, 2 );
@@ -162,33 +162,33 @@  discard block
 block discarded – undo
162 162
      */
163 163
     public function update_plugins_filter( $value ) {
164 164
 
165
-        // If no update object exists, return early.
166
-        if ( empty( $value ) ) {
167
-            return $value;
168
-        }
169
-
170
-        // Run update check by pinging the external API. If it fails, return the default update object.
171
-        if ( ! $this->update ) {
172
-            $this->update = $this->perform_remote_request( 'get-plugin-update', array( 'tgm-updater-plugin' => $this->plugin_slug ) );
173
-            if ( ! $this->update || ! empty( $this->update->error ) ) {
174
-                $this->update = false;
175
-                return $value;
176
-            }
177
-        }
178
-
179
-        // Infuse the update object with our data if the version from the remote API is newer.
180
-        if ( isset( $this->update->new_version ) && version_compare( $this->version, $this->update->new_version, '<' ) ) {
181
-            // The $plugin_update object contains new_version, package, slug and last_update keys.
182
-            //$this->update->full_slug             = $this->plugin_slug;
183
-            //$this->update->name                  = $this->plugin_name;
184
-            $this->update->monsterinsights_plugin  = true;
185
-            $this->update->old_version             = $this->version;
186
-            $this->update->plugin                  = $this->plugin_path;
187
-            $value->response[$this->plugin_path]   = $this->update;
188
-        }
189
-
190
-        // Return the update object.
191
-        return $value;
165
+	// If no update object exists, return early.
166
+	if ( empty( $value ) ) {
167
+	    return $value;
168
+	}
169
+
170
+	// Run update check by pinging the external API. If it fails, return the default update object.
171
+	if ( ! $this->update ) {
172
+	    $this->update = $this->perform_remote_request( 'get-plugin-update', array( 'tgm-updater-plugin' => $this->plugin_slug ) );
173
+	    if ( ! $this->update || ! empty( $this->update->error ) ) {
174
+		$this->update = false;
175
+		return $value;
176
+	    }
177
+	}
178
+
179
+	// Infuse the update object with our data if the version from the remote API is newer.
180
+	if ( isset( $this->update->new_version ) && version_compare( $this->version, $this->update->new_version, '<' ) ) {
181
+	    // The $plugin_update object contains new_version, package, slug and last_update keys.
182
+	    //$this->update->full_slug             = $this->plugin_slug;
183
+	    //$this->update->name                  = $this->plugin_name;
184
+	    $this->update->monsterinsights_plugin  = true;
185
+	    $this->update->old_version             = $this->version;
186
+	    $this->update->plugin                  = $this->plugin_path;
187
+	    $value->response[$this->plugin_path]   = $this->update;
188
+	}
189
+
190
+	// Return the update object.
191
+	return $value;
192 192
 
193 193
     }
194 194
 
@@ -203,12 +203,12 @@  discard block
 block discarded – undo
203 203
      */
204 204
     public function http_request_args( $args, $url ) {
205 205
 
206
-        // If this is an SSL request and we are performing an upgrade routine, disable SSL verification.
207
-        if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'tgm-updater-action=get-plugin-update' ) ) {
208
-            $args['sslverify'] = false;
209
-        }
206
+	// If this is an SSL request and we are performing an upgrade routine, disable SSL verification.
207
+	if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'tgm-updater-action=get-plugin-update' ) ) {
208
+	    $args['sslverify'] = false;
209
+	}
210 210
 
211
-        return $args;
211
+	return $args;
212 212
 
213 213
     }
214 214
 
@@ -225,14 +225,14 @@  discard block
 block discarded – undo
225 225
      */
226 226
     public function plugins_api( $api, $action = '', $args = null ) {
227 227
 
228
-        $plugin = ( 'plugin_information' == $action ) && isset( $args->slug ) && ( $this->plugin_slug == $args->slug );
228
+	$plugin = ( 'plugin_information' == $action ) && isset( $args->slug ) && ( $this->plugin_slug == $args->slug );
229 229
 
230
-        // If our plugin matches the request, set our own plugin data, else return the default response.
231
-        if ( $plugin ) {
232
-            return $this->set_plugins_api( $api );
233
-        } else {
234
-            return $api;
235
-        }
230
+	// If our plugin matches the request, set our own plugin data, else return the default response.
231
+	if ( $plugin ) {
232
+	    return $this->set_plugins_api( $api );
233
+	} else {
234
+	    return $api;
235
+	}
236 236
 
237 237
     }
238 238
 
@@ -246,82 +246,82 @@  discard block
 block discarded – undo
246 246
      */
247 247
     public function set_plugins_api( $default_api ) {
248 248
 
249
-        // Perform the remote request to retrieve our plugin information. If it fails, return the default object.
250
-        if ( ! $this->info ) {
251
-            $this->info = $this->perform_remote_request( 'get-plugin-info', array( 'tgm-updater-plugin' => $this->plugin_slug ) );
252
-            if ( ! $this->info || ! empty( $this->info->error ) ) {
253
-                $this->info = false;
254
-                return $default_api;
255
-            }
256
-        }
257
-
258
-        // Create a new stdClass object and populate it with our plugin information.
259
-        $api                        = new stdClass;
260
-        $api->name                  = isset( $this->info->name )           ? $this->info->name           : '';
261
-        $api->slug                  = isset( $this->info->slug )           ? $this->info->slug           : '';
262
-        $api->version               = isset( $this->info->version )        ? $this->info->version        : '';
263
-        $api->author                = isset( $this->info->author )         ? $this->info->author         : '';
264
-        $api->author_profile        = isset( $this->info->author_profile ) ? $this->info->author_profile : '';
265
-        $api->requires              = isset( $this->info->requires )       ? $this->info->requires       : '';
266
-        $api->tested                = isset( $this->info->tested )         ? $this->info->tested         : '';
267
-        $api->last_updated          = isset( $this->info->last_updated )   ? $this->info->last_updated   : '';
268
-        $api->homepage              = isset( $this->info->homepage )       ? $this->info->homepage       : '';
269
-
270
-        $changelog                  = isset( $this->info->changelog )      ? $this->info->changelog       : '';
271
-        $description                = isset( $this->info->description )    ? $this->info->description     : '';
272
-
273
-        if ( ! empty( $changelog ) ) {
274
-             if ( ! empty( $description ) ) {
275
-                $api->sections['description'] = $description;
276
-                $api->sections['changelog']   = $changelog;
277
-             } else {
278
-                $api->sections['changelog']   = $changelog;
279
-             }
280
-        } else if ( ! empty( $description ) ) {
281
-            $api->sections['description'] = $description;
282
-        } else {
283
-            $api->sections = array();
284
-        }
285
-
286
-        $api->download_link         = isset( $this->info->download_link )  ? $this->info->download_link  : '';
287
-
288
-        // Return the new API object with our custom data.
289
-        return $api;
249
+	// Perform the remote request to retrieve our plugin information. If it fails, return the default object.
250
+	if ( ! $this->info ) {
251
+	    $this->info = $this->perform_remote_request( 'get-plugin-info', array( 'tgm-updater-plugin' => $this->plugin_slug ) );
252
+	    if ( ! $this->info || ! empty( $this->info->error ) ) {
253
+		$this->info = false;
254
+		return $default_api;
255
+	    }
256
+	}
257
+
258
+	// Create a new stdClass object and populate it with our plugin information.
259
+	$api                        = new stdClass;
260
+	$api->name                  = isset( $this->info->name )           ? $this->info->name           : '';
261
+	$api->slug                  = isset( $this->info->slug )           ? $this->info->slug           : '';
262
+	$api->version               = isset( $this->info->version )        ? $this->info->version        : '';
263
+	$api->author                = isset( $this->info->author )         ? $this->info->author         : '';
264
+	$api->author_profile        = isset( $this->info->author_profile ) ? $this->info->author_profile : '';
265
+	$api->requires              = isset( $this->info->requires )       ? $this->info->requires       : '';
266
+	$api->tested                = isset( $this->info->tested )         ? $this->info->tested         : '';
267
+	$api->last_updated          = isset( $this->info->last_updated )   ? $this->info->last_updated   : '';
268
+	$api->homepage              = isset( $this->info->homepage )       ? $this->info->homepage       : '';
269
+
270
+	$changelog                  = isset( $this->info->changelog )      ? $this->info->changelog       : '';
271
+	$description                = isset( $this->info->description )    ? $this->info->description     : '';
272
+
273
+	if ( ! empty( $changelog ) ) {
274
+	     if ( ! empty( $description ) ) {
275
+		$api->sections['description'] = $description;
276
+		$api->sections['changelog']   = $changelog;
277
+	     } else {
278
+		$api->sections['changelog']   = $changelog;
279
+	     }
280
+	} else if ( ! empty( $description ) ) {
281
+	    $api->sections['description'] = $description;
282
+	} else {
283
+	    $api->sections = array();
284
+	}
285
+
286
+	$api->download_link         = isset( $this->info->download_link )  ? $this->info->download_link  : '';
287
+
288
+	// Return the new API object with our custom data.
289
+	return $api;
290 290
 
291 291
     }
292 292
 
293 293
     // Integration with ManageWP
294 294
     public function premium_update_push( $premium_update ) {
295
-        if ( ! function_exists( 'get_plugin_data' ) ) {
296
-            include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
297
-        }
298
-
299
-        $update = $this->set_plugins_api( array() );
300
-        if ( ! empty( $update ) && version_compare( MONSTERINSIGHTS_VERSION, $update->version, '<' ) ) {
301
-            $plugin_data                = get_plugin_data( $update->slug );
302
-            $plugin_data['type']        = 'plugin';
303
-            $plugin_data['slug']        = $update->slug;
304
-            $plugin_data['new_version'] = $update->version;
305
-            $premium_update[]           = $plugin_data;
306
-        }
307
-        return $premium_update;
295
+	if ( ! function_exists( 'get_plugin_data' ) ) {
296
+	    include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
297
+	}
298
+
299
+	$update = $this->set_plugins_api( array() );
300
+	if ( ! empty( $update ) && version_compare( MONSTERINSIGHTS_VERSION, $update->version, '<' ) ) {
301
+	    $plugin_data                = get_plugin_data( $update->slug );
302
+	    $plugin_data['type']        = 'plugin';
303
+	    $plugin_data['slug']        = $update->slug;
304
+	    $plugin_data['new_version'] = $update->version;
305
+	    $premium_update[]           = $plugin_data;
306
+	}
307
+	return $premium_update;
308 308
     }
309 309
 
310 310
     // Integration with ManageWP
311 311
     public function premium_update( $premium_update ) {
312
-        if ( ! function_exists( 'get_plugin_data' ) ) {
313
-            include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
314
-        }
315
-
316
-        $update = $this->set_plugins_api( array() );
317
-        if ( ! empty( $update ) && version_compare( MONSTERINSIGHTS_VERSION, $update->version, '<' ) ) {
318
-            $plugin_data                = get_plugin_data( $update->slug );
319
-            $plugin_data['type']        = 'plugin';
320
-            $plugin_data['slug']        = $update->slug;
321
-            $plugin_data['url']         = $update->download_link; // OR provide your own callback function for managing the update
322
-            array_push( $premium_update, $plugin_data );
323
-        }
324
-        return $premium_update;
312
+	if ( ! function_exists( 'get_plugin_data' ) ) {
313
+	    include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
314
+	}
315
+
316
+	$update = $this->set_plugins_api( array() );
317
+	if ( ! empty( $update ) && version_compare( MONSTERINSIGHTS_VERSION, $update->version, '<' ) ) {
318
+	    $plugin_data                = get_plugin_data( $update->slug );
319
+	    $plugin_data['type']        = 'plugin';
320
+	    $plugin_data['slug']        = $update->slug;
321
+	    $plugin_data['url']         = $update->download_link; // OR provide your own callback function for managing the update
322
+	    array_push( $premium_update, $plugin_data );
323
+	}
324
+	return $premium_update;
325 325
     }
326 326
 
327 327
     /**
@@ -337,47 +337,47 @@  discard block
 block discarded – undo
337 337
      */
338 338
     public function perform_remote_request( $action, $body = array(), $headers = array(), $return_format = 'json' ) {
339 339
 
340
-        // Build the body of the request.
341
-        $body = wp_parse_args(
342
-            $body,
343
-            array(
344
-                'tgm-updater-action'     => $action,
345
-                'tgm-updater-key'        => $this->key,
346
-                'tgm-updater-wp-version' => get_bloginfo( 'version' ),
347
-                'tgm-updater-referer'    => site_url(),
348
-                'tgm-updater-mi-version' => MONSTERINSIGHTS_VERSION,
349
-                'tgm-updater-is-pro'     => monsterinsights_is_pro_version(),
350
-            )
351
-        );
352
-        $body = http_build_query( $body, '', '&' );
353
-
354
-        // Build the headers of the request.
355
-        $headers = wp_parse_args(
356
-            $headers,
357
-            array(
358
-                'Content-Type'   => 'application/x-www-form-urlencoded',
359
-                'Content-Length' => strlen( $body )
360
-            )
361
-        );
362
-
363
-        // Setup variable for wp_remote_post.
364
-        $post = array(
365
-            'headers' => $headers,
366
-            'body'    => $body
367
-        );
368
-
369
-        // Perform the query and retrieve the response.
370
-        $response      = wp_remote_post( esc_url_raw( $this->remote_url ), $post );
371
-        $response_code = wp_remote_retrieve_response_code( $response );
372
-        $response_body = wp_remote_retrieve_body( $response );
373
-
374
-        // Bail out early if there are any errors.
375
-        if ( 200 != $response_code || is_wp_error( $response_body ) ) {
376
-            return false;
377
-        }
378
-
379
-        // Return the json decoded content.
380
-        return json_decode( $response_body );
340
+	// Build the body of the request.
341
+	$body = wp_parse_args(
342
+	    $body,
343
+	    array(
344
+		'tgm-updater-action'     => $action,
345
+		'tgm-updater-key'        => $this->key,
346
+		'tgm-updater-wp-version' => get_bloginfo( 'version' ),
347
+		'tgm-updater-referer'    => site_url(),
348
+		'tgm-updater-mi-version' => MONSTERINSIGHTS_VERSION,
349
+		'tgm-updater-is-pro'     => monsterinsights_is_pro_version(),
350
+	    )
351
+	);
352
+	$body = http_build_query( $body, '', '&' );
353
+
354
+	// Build the headers of the request.
355
+	$headers = wp_parse_args(
356
+	    $headers,
357
+	    array(
358
+		'Content-Type'   => 'application/x-www-form-urlencoded',
359
+		'Content-Length' => strlen( $body )
360
+	    )
361
+	);
362
+
363
+	// Setup variable for wp_remote_post.
364
+	$post = array(
365
+	    'headers' => $headers,
366
+	    'body'    => $body
367
+	);
368
+
369
+	// Perform the query and retrieve the response.
370
+	$response      = wp_remote_post( esc_url_raw( $this->remote_url ), $post );
371
+	$response_code = wp_remote_retrieve_response_code( $response );
372
+	$response_body = wp_remote_retrieve_body( $response );
373
+
374
+	// Bail out early if there are any errors.
375
+	if ( 200 != $response_code || is_wp_error( $response_body ) ) {
376
+	    return false;
377
+	}
378
+
379
+	// Return the json decoded content.
380
+	return json_decode( $response_body );
381 381
 
382 382
     }
383 383
 }
Please login to merge, or discard this patch.