@@ -47,27 +47,27 @@ discard block |
||
47 | 47 | * @since 6.0.0 |
48 | 48 | */ |
49 | 49 | public function __construct() { |
50 | - add_action( 'admin_init', array( $this, 'admin_init' ) ); |
|
50 | + add_action( 'admin_init', array( $this, 'admin_init' ) ); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | public function admin_init() { |
54 | - // Possibly verify the key. |
|
55 | - $this->maybe_verify_key(); |
|
56 | - |
|
57 | - // Add potential admin notices for actions around the admin. |
|
58 | - add_action( 'admin_notices', array( $this, 'monsterinsights_notices' ), 11 ); |
|
59 | - add_action( 'network_admin_notices', array( $this, 'monsterinsights_notices' ), 11 ); |
|
60 | - |
|
61 | - // Grab the license key. If it is not set (even after verification), return early. |
|
62 | - $this->key = is_network_admin() ? MonsterInsights()->license->get_network_license_key() : MonsterInsights()->license->get_site_license_key(); |
|
63 | - if ( ! $this->key ) { |
|
64 | - return; |
|
65 | - } |
|
66 | - |
|
67 | - // Possibly handle validating, deactivating and refreshing license keys. |
|
68 | - $this->maybe_validate_key(); |
|
69 | - $this->maybe_deactivate_key(); |
|
70 | - $this->maybe_refresh_key(); |
|
54 | + // Possibly verify the key. |
|
55 | + $this->maybe_verify_key(); |
|
56 | + |
|
57 | + // Add potential admin notices for actions around the admin. |
|
58 | + add_action( 'admin_notices', array( $this, 'monsterinsights_notices' ), 11 ); |
|
59 | + add_action( 'network_admin_notices', array( $this, 'monsterinsights_notices' ), 11 ); |
|
60 | + |
|
61 | + // Grab the license key. If it is not set (even after verification), return early. |
|
62 | + $this->key = is_network_admin() ? MonsterInsights()->license->get_network_license_key() : MonsterInsights()->license->get_site_license_key(); |
|
63 | + if ( ! $this->key ) { |
|
64 | + return; |
|
65 | + } |
|
66 | + |
|
67 | + // Possibly handle validating, deactivating and refreshing license keys. |
|
68 | + $this->maybe_validate_key(); |
|
69 | + $this->maybe_deactivate_key(); |
|
70 | + $this->maybe_refresh_key(); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -79,19 +79,19 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function maybe_verify_key() { |
81 | 81 | |
82 | - if ( empty( $_POST['monsterinsights-license-key'] ) || strlen( $_POST['monsterinsights-license-key'] ) < 10 || empty( $_POST['monsterinsights-verify-submit'] ) ) { |
|
83 | - return; |
|
84 | - } |
|
82 | + if ( empty( $_POST['monsterinsights-license-key'] ) || strlen( $_POST['monsterinsights-license-key'] ) < 10 || empty( $_POST['monsterinsights-verify-submit'] ) ) { |
|
83 | + return; |
|
84 | + } |
|
85 | 85 | |
86 | - if ( ! wp_verify_nonce( $_POST['monsterinsights-key-nonce'], 'monsterinsights-key-nonce' ) ) { |
|
87 | - return; |
|
88 | - } |
|
86 | + if ( ! wp_verify_nonce( $_POST['monsterinsights-key-nonce'], 'monsterinsights-key-nonce' ) ) { |
|
87 | + return; |
|
88 | + } |
|
89 | 89 | |
90 | - if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { |
|
91 | - return; |
|
92 | - } |
|
90 | + if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { |
|
91 | + return; |
|
92 | + } |
|
93 | 93 | |
94 | - $this->verify_key(); |
|
94 | + $this->verify_key(); |
|
95 | 95 | |
96 | 96 | } |
97 | 97 | |
@@ -102,33 +102,33 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function verify_key() { |
104 | 104 | |
105 | - // Perform a request to verify the key. |
|
106 | - $verify = $this->perform_remote_request( 'verify-key', array( 'tgm-updater-key' => trim( $_POST['monsterinsights-license-key'] ) ) ); |
|
107 | - |
|
108 | - // If it returns false, send back a generic error message and return. |
|
109 | - if ( ! $verify ) { |
|
110 | - $this->errors[] = esc_html__( 'There was an error connecting to the remote key API. Please try again later.', 'google-analytics-for-wordpress' ); |
|
111 | - return; |
|
112 | - } |
|
113 | - |
|
114 | - // If an error is returned, set the error and return. |
|
115 | - if ( ! empty( $verify->error ) ) { |
|
116 | - $this->errors[] = $verify->error; |
|
117 | - return; |
|
118 | - } |
|
119 | - |
|
120 | - // Otherwise, our request has been done successfully. Update the option and set the success message. |
|
121 | - $option = is_network_admin() ? MonsterInsights()->license->get_network_license() : MonsterInsights()->license->get_site_license(); |
|
122 | - $option['key'] = trim( $_POST['monsterinsights-license-key'] ); |
|
123 | - $option['type'] = isset( $verify->type ) ? $verify->type : $option['type']; |
|
124 | - $option['is_expired'] = false; |
|
125 | - $option['is_disabled'] = false; |
|
126 | - $option['is_invalid'] = false; |
|
127 | - $this->success[] = isset( $verify->success ) ? $verify->success : esc_html__( 'Congratulations! This site is now receiving automatic updates.', 'google-analytics-for-wordpress' ); |
|
128 | - is_network_admin() ? MonsterInsights()->license->set_network_license( $option ) : MonsterInsights()->license->set_site_license( $option ); |
|
129 | - delete_transient( '_monsterinsights_addons' ); |
|
130 | - monsterinsights_get_addons_data( $option['key'] ); |
|
131 | - // Make sure users can now update their plugins if they previously an expired key. |
|
105 | + // Perform a request to verify the key. |
|
106 | + $verify = $this->perform_remote_request( 'verify-key', array( 'tgm-updater-key' => trim( $_POST['monsterinsights-license-key'] ) ) ); |
|
107 | + |
|
108 | + // If it returns false, send back a generic error message and return. |
|
109 | + if ( ! $verify ) { |
|
110 | + $this->errors[] = esc_html__( 'There was an error connecting to the remote key API. Please try again later.', 'google-analytics-for-wordpress' ); |
|
111 | + return; |
|
112 | + } |
|
113 | + |
|
114 | + // If an error is returned, set the error and return. |
|
115 | + if ( ! empty( $verify->error ) ) { |
|
116 | + $this->errors[] = $verify->error; |
|
117 | + return; |
|
118 | + } |
|
119 | + |
|
120 | + // Otherwise, our request has been done successfully. Update the option and set the success message. |
|
121 | + $option = is_network_admin() ? MonsterInsights()->license->get_network_license() : MonsterInsights()->license->get_site_license(); |
|
122 | + $option['key'] = trim( $_POST['monsterinsights-license-key'] ); |
|
123 | + $option['type'] = isset( $verify->type ) ? $verify->type : $option['type']; |
|
124 | + $option['is_expired'] = false; |
|
125 | + $option['is_disabled'] = false; |
|
126 | + $option['is_invalid'] = false; |
|
127 | + $this->success[] = isset( $verify->success ) ? $verify->success : esc_html__( 'Congratulations! This site is now receiving automatic updates.', 'google-analytics-for-wordpress' ); |
|
128 | + is_network_admin() ? MonsterInsights()->license->set_network_license( $option ) : MonsterInsights()->license->set_site_license( $option ); |
|
129 | + delete_transient( '_monsterinsights_addons' ); |
|
130 | + monsterinsights_get_addons_data( $option['key'] ); |
|
131 | + // Make sure users can now update their plugins if they previously an expired key. |
|
132 | 132 | wp_clean_plugins_cache( true ); |
133 | 133 | } |
134 | 134 | |
@@ -140,10 +140,10 @@ discard block |
||
140 | 140 | * @return null Return early if the transient has not expired yet. |
141 | 141 | */ |
142 | 142 | public function maybe_validate_key() { |
143 | - $check = is_network_admin() ? MonsterInsights()->license->time_to_check_network_license() : MonsterInsights()->license->time_to_check_site_license(); |
|
144 | - if ( $check ) { |
|
145 | - $this->validate_key(); |
|
146 | - } |
|
143 | + $check = is_network_admin() ? MonsterInsights()->license->time_to_check_network_license() : MonsterInsights()->license->time_to_check_site_license(); |
|
144 | + if ( $check ) { |
|
145 | + $this->validate_key(); |
|
146 | + } |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -155,58 +155,58 @@ discard block |
||
155 | 155 | */ |
156 | 156 | public function validate_key( $forced = false ) { |
157 | 157 | |
158 | - $validate = $this->perform_remote_request( 'validate-key', array( 'tgm-updater-key' => $this->key ) ); |
|
159 | - |
|
160 | - // If there was a basic API error in validation, only set the transient for 10 minutes before retrying. |
|
161 | - if ( ! $validate ) { |
|
162 | - // If forced, set contextual success message. |
|
163 | - if ( $forced ) { |
|
164 | - $this->errors[] = esc_html__( 'There was an error connecting to the remote key API. Please try again later.', 'google-analytics-for-wordpress' ); |
|
165 | - } |
|
166 | - return; |
|
167 | - } |
|
168 | - |
|
169 | - $option = is_network_admin() ? MonsterInsights()->license->get_network_license() : MonsterInsights()->license->get_site_license(); |
|
170 | - $option['is_expired'] = false; |
|
171 | - $option['is_disabled'] = false; |
|
172 | - $option['is_invalid'] = false; |
|
173 | - |
|
174 | - // If a key or author error is returned, the license no longer exists or the user has been deleted, so reset license. |
|
175 | - if ( isset( $validate->key ) || isset( $validate->author ) ) { |
|
176 | - $option['is_invalid'] = true; |
|
177 | - is_network_admin() ? MonsterInsights()->license->set_network_license( $option ) : MonsterInsights()->license->set_site_license( $option ); |
|
178 | - return; |
|
179 | - } |
|
180 | - |
|
181 | - // If the license has expired, set the transient and expired flag and return. |
|
182 | - if ( isset( $validate->expired ) ) { |
|
183 | - $option['is_expired'] = true; |
|
184 | - is_network_admin() ? MonsterInsights()->license->set_network_license( $option ) : MonsterInsights()->license->set_site_license( $option ); |
|
185 | - return; |
|
186 | - } |
|
187 | - |
|
188 | - // If the license is disabled, set the transient and disabled flag and return. |
|
189 | - if ( isset( $validate->disabled ) ) { |
|
190 | - $option['is_disabled'] = true; |
|
191 | - is_network_admin() ? MonsterInsights()->license->set_network_license( $option ) : MonsterInsights()->license->set_site_license( $option ); |
|
192 | - return; |
|
193 | - } |
|
194 | - |
|
195 | - // If forced, set contextual success message. |
|
196 | - if ( ( ! empty( $validate->key ) || ! empty( $this->key ) ) && $forced ) { |
|
197 | - $key = ! empty( $validate->key ) ? $validate->key : $this->key; |
|
198 | - delete_transient( '_monsterinsights_addons' ); |
|
199 | - monsterinsights_get_addons_data( $key ); |
|
200 | - $this->success[] = esc_html__( 'Congratulations! Your key has been refreshed successfully.', 'google-analytics-for-wordpress' ); |
|
201 | - } |
|
202 | - |
|
203 | - $option = array(); |
|
204 | - $option = is_network_admin() ? MonsterInsights()->license->get_network_license() : MonsterInsights()->license->get_site_license(); |
|
205 | - $option['type'] = isset( $validate->type ) ? $validate->type : $option['type']; |
|
206 | - $option['is_expired'] = false; |
|
207 | - $option['is_disabled'] = false; |
|
208 | - $option['is_invalid'] = false; |
|
209 | - is_network_admin() ? MonsterInsights()->license->set_network_license( $option ) : MonsterInsights()->license->set_site_license( $option ); |
|
158 | + $validate = $this->perform_remote_request( 'validate-key', array( 'tgm-updater-key' => $this->key ) ); |
|
159 | + |
|
160 | + // If there was a basic API error in validation, only set the transient for 10 minutes before retrying. |
|
161 | + if ( ! $validate ) { |
|
162 | + // If forced, set contextual success message. |
|
163 | + if ( $forced ) { |
|
164 | + $this->errors[] = esc_html__( 'There was an error connecting to the remote key API. Please try again later.', 'google-analytics-for-wordpress' ); |
|
165 | + } |
|
166 | + return; |
|
167 | + } |
|
168 | + |
|
169 | + $option = is_network_admin() ? MonsterInsights()->license->get_network_license() : MonsterInsights()->license->get_site_license(); |
|
170 | + $option['is_expired'] = false; |
|
171 | + $option['is_disabled'] = false; |
|
172 | + $option['is_invalid'] = false; |
|
173 | + |
|
174 | + // If a key or author error is returned, the license no longer exists or the user has been deleted, so reset license. |
|
175 | + if ( isset( $validate->key ) || isset( $validate->author ) ) { |
|
176 | + $option['is_invalid'] = true; |
|
177 | + is_network_admin() ? MonsterInsights()->license->set_network_license( $option ) : MonsterInsights()->license->set_site_license( $option ); |
|
178 | + return; |
|
179 | + } |
|
180 | + |
|
181 | + // If the license has expired, set the transient and expired flag and return. |
|
182 | + if ( isset( $validate->expired ) ) { |
|
183 | + $option['is_expired'] = true; |
|
184 | + is_network_admin() ? MonsterInsights()->license->set_network_license( $option ) : MonsterInsights()->license->set_site_license( $option ); |
|
185 | + return; |
|
186 | + } |
|
187 | + |
|
188 | + // If the license is disabled, set the transient and disabled flag and return. |
|
189 | + if ( isset( $validate->disabled ) ) { |
|
190 | + $option['is_disabled'] = true; |
|
191 | + is_network_admin() ? MonsterInsights()->license->set_network_license( $option ) : MonsterInsights()->license->set_site_license( $option ); |
|
192 | + return; |
|
193 | + } |
|
194 | + |
|
195 | + // If forced, set contextual success message. |
|
196 | + if ( ( ! empty( $validate->key ) || ! empty( $this->key ) ) && $forced ) { |
|
197 | + $key = ! empty( $validate->key ) ? $validate->key : $this->key; |
|
198 | + delete_transient( '_monsterinsights_addons' ); |
|
199 | + monsterinsights_get_addons_data( $key ); |
|
200 | + $this->success[] = esc_html__( 'Congratulations! Your key has been refreshed successfully.', 'google-analytics-for-wordpress' ); |
|
201 | + } |
|
202 | + |
|
203 | + $option = array(); |
|
204 | + $option = is_network_admin() ? MonsterInsights()->license->get_network_license() : MonsterInsights()->license->get_site_license(); |
|
205 | + $option['type'] = isset( $validate->type ) ? $validate->type : $option['type']; |
|
206 | + $option['is_expired'] = false; |
|
207 | + $option['is_disabled'] = false; |
|
208 | + $option['is_invalid'] = false; |
|
209 | + is_network_admin() ? MonsterInsights()->license->set_network_license( $option ) : MonsterInsights()->license->set_site_license( $option ); |
|
210 | 210 | |
211 | 211 | } |
212 | 212 | |
@@ -219,19 +219,19 @@ discard block |
||
219 | 219 | */ |
220 | 220 | public function maybe_deactivate_key() { |
221 | 221 | |
222 | - if ( empty( $_POST['monsterinsights-license-key'] ) || empty( $_POST['monsterinsights-deactivate-submit'] ) ) { |
|
223 | - return; |
|
224 | - } |
|
222 | + if ( empty( $_POST['monsterinsights-license-key'] ) || empty( $_POST['monsterinsights-deactivate-submit'] ) ) { |
|
223 | + return; |
|
224 | + } |
|
225 | 225 | |
226 | - if ( ! wp_verify_nonce( $_POST['monsterinsights-key-nonce'], 'monsterinsights-key-nonce' ) ) { |
|
227 | - return; |
|
228 | - } |
|
226 | + if ( ! wp_verify_nonce( $_POST['monsterinsights-key-nonce'], 'monsterinsights-key-nonce' ) ) { |
|
227 | + return; |
|
228 | + } |
|
229 | 229 | |
230 | - if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { |
|
231 | - return; |
|
232 | - } |
|
230 | + if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { |
|
231 | + return; |
|
232 | + } |
|
233 | 233 | |
234 | - $this->deactivate_key(); |
|
234 | + $this->deactivate_key(); |
|
235 | 235 | |
236 | 236 | } |
237 | 237 | |
@@ -242,24 +242,24 @@ discard block |
||
242 | 242 | */ |
243 | 243 | public function deactivate_key() { |
244 | 244 | |
245 | - // Perform a request to deactivate the key. |
|
246 | - $deactivate = $this->perform_remote_request( 'deactivate-key', array( 'tgm-updater-key' => $_POST['monsterinsights-license-key'] ) ); |
|
245 | + // Perform a request to deactivate the key. |
|
246 | + $deactivate = $this->perform_remote_request( 'deactivate-key', array( 'tgm-updater-key' => $_POST['monsterinsights-license-key'] ) ); |
|
247 | 247 | |
248 | - // If it returns false, send back a generic error message and return. |
|
249 | - if ( ! $deactivate ) { |
|
250 | - $this->errors[] = esc_html__( 'There was an error connecting to the remote key API. Please try again later.', 'google-analytics-for-wordpress' ); |
|
251 | - return; |
|
252 | - } |
|
248 | + // If it returns false, send back a generic error message and return. |
|
249 | + if ( ! $deactivate ) { |
|
250 | + $this->errors[] = esc_html__( 'There was an error connecting to the remote key API. Please try again later.', 'google-analytics-for-wordpress' ); |
|
251 | + return; |
|
252 | + } |
|
253 | 253 | |
254 | - // If an error is returned, set the error and return. |
|
255 | - if ( ! empty( $deactivate->error ) && ! monsterinsights_is_debug_mode() ) { |
|
256 | - $this->errors[] = $deactivate->error; |
|
257 | - return; |
|
258 | - } |
|
254 | + // If an error is returned, set the error and return. |
|
255 | + if ( ! empty( $deactivate->error ) && ! monsterinsights_is_debug_mode() ) { |
|
256 | + $this->errors[] = $deactivate->error; |
|
257 | + return; |
|
258 | + } |
|
259 | 259 | |
260 | - // Otherwise, our request has been done successfully. Reset the option and set the success message. |
|
261 | - $this->success[] = isset( $deactivate->success ) ? $deactivate->success : esc_html__( 'Congratulations! You have deactivated the key from this site successfully.', 'google-analytics-for-wordpress' ); |
|
262 | - is_network_admin() ? MonsterInsights()->license->delete_network_license() : MonsterInsights()->license->delete_site_license(); |
|
260 | + // Otherwise, our request has been done successfully. Reset the option and set the success message. |
|
261 | + $this->success[] = isset( $deactivate->success ) ? $deactivate->success : esc_html__( 'Congratulations! You have deactivated the key from this site successfully.', 'google-analytics-for-wordpress' ); |
|
262 | + is_network_admin() ? MonsterInsights()->license->delete_network_license() : MonsterInsights()->license->delete_site_license(); |
|
263 | 263 | |
264 | 264 | } |
265 | 265 | |
@@ -272,20 +272,20 @@ discard block |
||
272 | 272 | */ |
273 | 273 | public function maybe_refresh_key() { |
274 | 274 | |
275 | - if ( empty( $_POST['monsterinsights-license-key'] ) || empty( $_POST['monsterinsights-refresh-submit'] ) ) { |
|
276 | - return; |
|
277 | - } |
|
275 | + if ( empty( $_POST['monsterinsights-license-key'] ) || empty( $_POST['monsterinsights-refresh-submit'] ) ) { |
|
276 | + return; |
|
277 | + } |
|
278 | 278 | |
279 | - if ( ! wp_verify_nonce( $_POST['monsterinsights-key-nonce'], 'monsterinsights-key-nonce' ) ) { |
|
280 | - return; |
|
281 | - } |
|
279 | + if ( ! wp_verify_nonce( $_POST['monsterinsights-key-nonce'], 'monsterinsights-key-nonce' ) ) { |
|
280 | + return; |
|
281 | + } |
|
282 | 282 | |
283 | - if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { |
|
284 | - return; |
|
285 | - } |
|
283 | + if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { |
|
284 | + return; |
|
285 | + } |
|
286 | 286 | |
287 | - // Refreshing is simply a word alias for validating a key. Force true to set contextual messages. |
|
288 | - $this->validate_key( true ); |
|
287 | + // Refreshing is simply a word alias for validating a key. Force true to set contextual messages. |
|
288 | + $this->validate_key( true ); |
|
289 | 289 | |
290 | 290 | } |
291 | 291 | |
@@ -295,16 +295,16 @@ discard block |
||
295 | 295 | * @since 7.0.0 |
296 | 296 | */ |
297 | 297 | public function monsterinsights_notices() { |
298 | - if ( ! monsterinsights_is_pro_version() ) { |
|
299 | - return; |
|
300 | - } |
|
298 | + if ( ! monsterinsights_is_pro_version() ) { |
|
299 | + return; |
|
300 | + } |
|
301 | 301 | |
302 | - $screen = get_current_screen(); |
|
303 | - if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) === false ) { |
|
304 | - return; |
|
305 | - } |
|
302 | + $screen = get_current_screen(); |
|
303 | + if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) === false ) { |
|
304 | + return; |
|
305 | + } |
|
306 | 306 | |
307 | - if ( ! empty( $this->errors ) ) { ?> |
|
307 | + if ( ! empty( $this->errors ) ) { ?> |
|
308 | 308 | <div class="error"> |
309 | 309 | <p><?php echo implode( '<br>', $this->errors ); ?></p> |
310 | 310 | </div> |
@@ -328,46 +328,46 @@ discard block |
||
328 | 328 | */ |
329 | 329 | public function perform_remote_request( $action, $body = array(), $headers = array(), $return_format = 'json' ) { |
330 | 330 | |
331 | - // Build the body of the request. |
|
332 | - $body = wp_parse_args( |
|
333 | - $body, |
|
334 | - array( |
|
335 | - 'tgm-updater-action' => $action, |
|
336 | - 'tgm-updater-key' => $this->key, |
|
337 | - 'tgm-updater-wp-version' => get_bloginfo( 'version' ), |
|
338 | - 'tgm-updater-referer' => site_url(), |
|
339 | - 'tgm-updater-mi-version' => MONSTERINSIGHTS_VERSION, |
|
340 | - 'tgm-updater-is-pro' => monsterinsights_is_pro_version(), |
|
341 | - ) |
|
342 | - ); |
|
343 | - $body = http_build_query( $body, '', '&' ); |
|
344 | - |
|
345 | - // Build the headers of the request. |
|
346 | - $headers = wp_parse_args( |
|
347 | - $headers, |
|
348 | - array( |
|
349 | - 'Content-Type' => 'application/x-www-form-urlencoded', |
|
350 | - 'Content-Length' => strlen( $body ) |
|
351 | - ) |
|
352 | - ); |
|
353 | - |
|
354 | - // Setup variable for wp_remote_post. |
|
355 | - $post = array( |
|
356 | - 'headers' => $headers, |
|
357 | - 'body' => $body |
|
358 | - ); |
|
359 | - |
|
360 | - // Perform the query and retrieve the response. |
|
361 | - $response = wp_remote_post( monsterinsights_get_licensing_url(), $post ); |
|
362 | - $response_code = wp_remote_retrieve_response_code( $response ); |
|
363 | - $response_body = wp_remote_retrieve_body( $response ); |
|
364 | - |
|
365 | - // Bail out early if there are any errors. |
|
366 | - if ( 200 != $response_code || is_wp_error( $response_body ) ) { |
|
367 | - return false; |
|
368 | - } |
|
369 | - |
|
370 | - // Return the json decoded content. |
|
371 | - return json_decode( $response_body ); |
|
331 | + // Build the body of the request. |
|
332 | + $body = wp_parse_args( |
|
333 | + $body, |
|
334 | + array( |
|
335 | + 'tgm-updater-action' => $action, |
|
336 | + 'tgm-updater-key' => $this->key, |
|
337 | + 'tgm-updater-wp-version' => get_bloginfo( 'version' ), |
|
338 | + 'tgm-updater-referer' => site_url(), |
|
339 | + 'tgm-updater-mi-version' => MONSTERINSIGHTS_VERSION, |
|
340 | + 'tgm-updater-is-pro' => monsterinsights_is_pro_version(), |
|
341 | + ) |
|
342 | + ); |
|
343 | + $body = http_build_query( $body, '', '&' ); |
|
344 | + |
|
345 | + // Build the headers of the request. |
|
346 | + $headers = wp_parse_args( |
|
347 | + $headers, |
|
348 | + array( |
|
349 | + 'Content-Type' => 'application/x-www-form-urlencoded', |
|
350 | + 'Content-Length' => strlen( $body ) |
|
351 | + ) |
|
352 | + ); |
|
353 | + |
|
354 | + // Setup variable for wp_remote_post. |
|
355 | + $post = array( |
|
356 | + 'headers' => $headers, |
|
357 | + 'body' => $body |
|
358 | + ); |
|
359 | + |
|
360 | + // Perform the query and retrieve the response. |
|
361 | + $response = wp_remote_post( monsterinsights_get_licensing_url(), $post ); |
|
362 | + $response_code = wp_remote_retrieve_response_code( $response ); |
|
363 | + $response_body = wp_remote_retrieve_body( $response ); |
|
364 | + |
|
365 | + // Bail out early if there are any errors. |
|
366 | + if ( 200 != $response_code || is_wp_error( $response_body ) ) { |
|
367 | + return false; |
|
368 | + } |
|
369 | + |
|
370 | + // Return the json decoded content. |
|
371 | + return json_decode( $response_body ); |
|
372 | 372 | } |
373 | 373 | } |
374 | 374 | \ No newline at end of file |
@@ -105,39 +105,39 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | //add_filter( 'mwp_premium_perform_update', array( $this, 'premium_update' ) ); |
141 | 141 | |
142 | 142 | // Add additional info if the license is expired. |
143 | - add_action( 'in_plugin_update_message-'. $this->plugin_path, array( $this, 'maybe_show_license_expired_message' ), 10, 2 ); |
|
143 | + add_action( 'in_plugin_update_message-' . $this->plugin_path, array( $this, 'maybe_show_license_expired_message' ), 10, 2 ); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | public function maybe_show_license_expired_message( $plugin_data, $response ) { |
@@ -257,18 +257,18 @@ discard block |
||
257 | 257 | |
258 | 258 | // Create a new stdClass object and populate it with our plugin information. |
259 | 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 : ''; |
|
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 | 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 : ''; |
|
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 | 269 | |
270 | - $changelog = isset( $this->info->changelog ) ? $this->info->changelog : ''; |
|
271 | - $description = isset( $this->info->description ) ? $this->info->description : ''; |
|
270 | + $changelog = isset( $this->info->changelog ) ? $this->info->changelog : ''; |
|
271 | + $description = isset( $this->info->description ) ? $this->info->description : ''; |
|
272 | 272 | |
273 | 273 | if ( ! empty( $changelog ) ) { |
274 | 274 | if ( ! empty( $description ) ) { |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | $api->sections = array(); |
284 | 284 | } |
285 | 285 | |
286 | - $api->download_link = isset( $this->info->download_link ) ? $this->info->download_link : ''; |
|
286 | + $api->download_link = isset( $this->info->download_link ) ? $this->info->download_link : ''; |
|
287 | 287 | |
288 | 288 | // Return the new API object with our custom data. |
289 | 289 | return $api; |
@@ -38,16 +38,16 @@ discard block |
||
38 | 38 | <div id="monsterinsights-main-tab-general" class="monsterinsights-main-nav-tab monsterinsights-nav-tab monsterinsights-active"> |
39 | 39 | <div id="monsterinsights-network-settings-general"> |
40 | 40 | <?php |
41 | - // Output any notices now |
|
42 | - /** |
|
43 | - * Developer Alert: |
|
44 | - * |
|
45 | - * Per the README, this is considered an internal hook and should |
|
46 | - * not be used by other developers. This hook's behavior may be modified |
|
47 | - * or the hook may be removed at any time, without warning. |
|
48 | - */ |
|
49 | - do_action( 'monsterinsights_network_settings_general_tab_notice' ); |
|
50 | - ?> |
|
41 | + // Output any notices now |
|
42 | + /** |
|
43 | + * Developer Alert: |
|
44 | + * |
|
45 | + * Per the README, this is considered an internal hook and should |
|
46 | + * not be used by other developers. This hook's behavior may be modified |
|
47 | + * or the hook may be removed at any time, without warning. |
|
48 | + */ |
|
49 | + do_action( 'monsterinsights_network_settings_general_tab_notice' ); |
|
50 | + ?> |
|
51 | 51 | <h1><?php esc_html_e( 'Network Settings', 'google-analytics-for-wordpress'); ?></h1> |
52 | 52 | <p><?php esc_html_e( 'Activate your MonsterInsights license key on this panel to hide the license key settings and addon pages for subsites.', 'google-analytics-for-wordpress'); ?></p> |
53 | 53 | <form id="monsterinsights-network-general-tab" method="post"> |
@@ -56,12 +56,12 @@ discard block |
||
56 | 56 | <tbody> |
57 | 57 | <?php if ( monsterinsights_is_pro_version() ) { |
58 | 58 | |
59 | - $license_key = MonsterInsights()->license->get_network_license_key(); |
|
60 | - $license_key = $license_key ? $license_key : MonsterInsights()->license->get_default_license_key(); |
|
59 | + $license_key = MonsterInsights()->license->get_network_license_key(); |
|
60 | + $license_key = $license_key ? $license_key : MonsterInsights()->license->get_default_license_key(); |
|
61 | 61 | |
62 | - $license_type = MonsterInsights()->license->get_network_license_type(); |
|
62 | + $license_type = MonsterInsights()->license->get_network_license_type(); |
|
63 | 63 | |
64 | - ?> |
|
64 | + ?> |
|
65 | 65 | <tr id="monsterinsights-settings-key-box"> |
66 | 66 | <th scope="row"> |
67 | 67 | <label for="monsterinsights-settings-key"><?php esc_html_e( 'License Key', 'google-analytics-for-wordpress' ); ?></label> |
@@ -136,8 +136,8 @@ discard block |
||
136 | 136 | </tr> |
137 | 137 | |
138 | 138 | <?php if ( ! MonsterInsights()->auth->get_network_viewname() ) { |
139 | - $network_ua = MonsterInsights()->auth->get_network_manual_ua(); |
|
140 | - ?> |
|
139 | + $network_ua = MonsterInsights()->auth->get_network_manual_ua(); |
|
140 | + ?> |
|
141 | 141 | <tr id="monsterinsights-google-ua-box" <?php echo (empty( $network_ua ) ? 'class="monsterinsights-hideme"' : ''); ?> > |
142 | 142 | <th scope="row"> |
143 | 143 | <label for="monsterinsights-google-ua"><?php esc_html_e( 'Network UA code', 'google-analytics-for-wordpress' ); ?></label> |
@@ -165,10 +165,10 @@ discard block |
||
165 | 165 | </tr> |
166 | 166 | <?php } ?> |
167 | 167 | <?php |
168 | - $title = esc_html__( 'Hide Announcements', 'google-analytics-for-wordpress' ); |
|
169 | - $description = esc_html__( 'Hides plugin announcements and update details. This includes critical notices we use to inform about deprecations and important required configuration changes.', 'google-analytics-for-wordpress' ); |
|
170 | - echo monsterinsights_make_checkbox( 'network_hide_am_notices', $title, $description ); |
|
171 | - ?> |
|
168 | + $title = esc_html__( 'Hide Announcements', 'google-analytics-for-wordpress' ); |
|
169 | + $description = esc_html__( 'Hides plugin announcements and update details. This includes critical notices we use to inform about deprecations and important required configuration changes.', 'google-analytics-for-wordpress' ); |
|
170 | + echo monsterinsights_make_checkbox( 'network_hide_am_notices', $title, $description ); |
|
171 | + ?> |
|
172 | 172 | </tbody> |
173 | 173 | </table> |
174 | 174 | <?php wp_nonce_field( 'monsterinsights-network-settings-nonce', 'monsterinsights-network-settings-nonce' ); ?> |
@@ -193,15 +193,15 @@ discard block |
||
193 | 193 | |
194 | 194 | // Check if user pressed the 'Update' button and nonce is valid |
195 | 195 | if ( ! isset( $_POST['monsterinsights-network-settings-submit'] ) ) { |
196 | - return; |
|
196 | + return; |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | if ( ! wp_verify_nonce( $_POST['monsterinsights-network-settings-nonce'], 'monsterinsights-network-settings-nonce' ) ) { |
200 | - return; |
|
200 | + return; |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { |
204 | - return; |
|
204 | + return; |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | $throw_notice = false; |
@@ -210,35 +210,35 @@ discard block |
||
210 | 210 | $manual_ua_code_old = MonsterInsights()->auth->get_network_manual_ua(); |
211 | 211 | |
212 | 212 | if ( $manual_ua_code && $manual_ua_code_old && $manual_ua_code_old === $manual_ua_code ) { |
213 | - // Same code we had before |
|
214 | - // Do nothing |
|
213 | + // Same code we had before |
|
214 | + // Do nothing |
|
215 | 215 | } else if ( $manual_ua_code && $manual_ua_code_old && $manual_ua_code_old !== $manual_ua_code ) { |
216 | - // Different UA code |
|
217 | - MonsterInsights()->auth->set_network_manual_ua( $manual_ua_code ); |
|
216 | + // Different UA code |
|
217 | + MonsterInsights()->auth->set_network_manual_ua( $manual_ua_code ); |
|
218 | 218 | } else if ( $manual_ua_code && empty( $manual_ua_code_old ) ) { |
219 | - // Move to manual |
|
220 | - MonsterInsights()->auth->set_network_manual_ua( $manual_ua_code ); |
|
219 | + // Move to manual |
|
220 | + MonsterInsights()->auth->set_network_manual_ua( $manual_ua_code ); |
|
221 | 221 | } else if ( empty( $manual_ua_code ) && $manual_ua_code_old ) { |
222 | - // Deleted manual |
|
223 | - MonsterInsights()->auth->delete_network_manual_ua(); |
|
222 | + // Deleted manual |
|
223 | + MonsterInsights()->auth->delete_network_manual_ua(); |
|
224 | 224 | } else if ( isset( $_POST['network_manual_ua_code'] ) && empty( $manual_ua_code ) && ! empty( $_POST['network_manual_ua_code'] ) ) { |
225 | - $throw_notice = true; |
|
225 | + $throw_notice = true; |
|
226 | 226 | } else { |
227 | - // Not UA before or after |
|
228 | - // Do nothing |
|
227 | + // Not UA before or after |
|
228 | + // Do nothing |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | $network_hide_am_notices = isset( $_POST['network_hide_am_notices'] ) ? 1 : 0; |
232 | 232 | $network_hide_am_notices_old = monsterinsights_get_option( 'network_hide_am_notices', false ); |
233 | 233 | if ( $network_hide_am_notices != $network_hide_am_notices_old ) { |
234 | - monsterinsights_update_option( 'network_hide_am_notices', $network_hide_am_notices ); |
|
234 | + monsterinsights_update_option( 'network_hide_am_notices', $network_hide_am_notices ); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | // Output an admin notice so the user knows what happened |
238 | 238 | if ( $throw_notice ) { |
239 | - add_action( 'monsterinsights_network_settings_general_tab_notice', 'monsterinsights_invalid_ua_code' ); |
|
239 | + add_action( 'monsterinsights_network_settings_general_tab_notice', 'monsterinsights_invalid_ua_code' ); |
|
240 | 240 | } else { |
241 | - add_action( 'monsterinsights_network_settings_general_tab_notice', 'monsterinsights_updated_settings' ); |
|
241 | + add_action( 'monsterinsights_network_settings_general_tab_notice', 'monsterinsights_updated_settings' ); |
|
242 | 242 | } |
243 | 243 | } |
244 | 244 | add_action( 'admin_init', 'monsterinsights_network_settings_save_general', 11 ); |
245 | 245 | \ No newline at end of file |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | */ |
49 | 49 | do_action( 'monsterinsights_network_settings_general_tab_notice' ); |
50 | 50 | ?> |
51 | - <h1><?php esc_html_e( 'Network Settings', 'google-analytics-for-wordpress'); ?></h1> |
|
52 | - <p><?php esc_html_e( 'Activate your MonsterInsights license key on this panel to hide the license key settings and addon pages for subsites.', 'google-analytics-for-wordpress'); ?></p> |
|
51 | + <h1><?php esc_html_e( 'Network Settings', 'google-analytics-for-wordpress' ); ?></h1> |
|
52 | + <p><?php esc_html_e( 'Activate your MonsterInsights license key on this panel to hide the license key settings and addon pages for subsites.', 'google-analytics-for-wordpress' ); ?></p> |
|
53 | 53 | <form id="monsterinsights-network-general-tab" method="post"> |
54 | 54 | |
55 | 55 | <table class="form-table"> |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | <form id="monsterinsights-google-authenticate" method="post"> |
115 | 115 | <?php if ( MonsterInsights()->auth->get_network_viewname() && MonsterInsights()->auth->get_network_ua() ) { ?> |
116 | 116 | <?php if ( monsterinsights_is_pro_version() && ! MonsterInsights()->license->is_network_licensed() ) { ?> |
117 | - <p><?php echo esc_html__( 'Please activate MonsterInsights Pro with an active, valid license key in order to use MonsterInsights Pro.' , 'google-analytics-for-wordpress' ); ?></p> |
|
117 | + <p><?php echo esc_html__( 'Please activate MonsterInsights Pro with an active, valid license key in order to use MonsterInsights Pro.', 'google-analytics-for-wordpress' ); ?></p> |
|
118 | 118 | <?php } else { ?> |
119 | 119 | <p><?php echo esc_html__( 'Profile Active: ', 'google-analytics-for-wordpress' ) . MonsterInsights()->auth->get_network_viewname(); ?></p> |
120 | 120 | <p><?php wp_nonce_field( 'monsterinsights-google-authenticated-nonce', 'monsterinsights-google-authenticated-nonce' ); ?> |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | <?php } ?> |
125 | 125 | <?php } else { ?> |
126 | 126 | <?php if ( monsterinsights_is_pro_version() && ! MonsterInsights()->license->is_network_licensed() ) { ?> |
127 | - <p><?php echo esc_html__( 'Please activate MonsterInsights Pro with an active, valid license key in order to use MonsterInsights Pro.' , 'google-analytics-for-wordpress' ); ?></p> |
|
127 | + <p><?php echo esc_html__( 'Please activate MonsterInsights Pro with an active, valid license key in order to use MonsterInsights Pro.', 'google-analytics-for-wordpress' ); ?></p> |
|
128 | 128 | <?php } else { ?> |
129 | 129 | <?php wp_nonce_field( 'monsterinsights-google-authenticate-nonce', 'monsterinsights-google-authenticate-nonce' ); ?> |
130 | 130 | <?php submit_button( esc_html__( 'Authenticate with your Google account', 'google-analytics-for-wordpress' ), 'button-action', 'monsterinsights-google-authenticate-submit', false ); ?> |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | <?php if ( ! MonsterInsights()->auth->get_network_viewname() ) { |
139 | 139 | $network_ua = MonsterInsights()->auth->get_network_manual_ua(); |
140 | 140 | ?> |
141 | - <tr id="monsterinsights-google-ua-box" <?php echo (empty( $network_ua ) ? 'class="monsterinsights-hideme"' : ''); ?> > |
|
141 | + <tr id="monsterinsights-google-ua-box" <?php echo ( empty( $network_ua ) ? 'class="monsterinsights-hideme"' : '' ); ?> > |
|
142 | 142 | <th scope="row"> |
143 | 143 | <label for="monsterinsights-google-ua"><?php esc_html_e( 'Network UA code', 'google-analytics-for-wordpress' ); ?></label> |
144 | 144 | </th> |
@@ -156,10 +156,10 @@ discard block |
||
156 | 156 | </th> |
157 | 157 | <td> |
158 | 158 | <p> |
159 | - <?php echo sprintf( esc_html__( 'Already purchased an upgrade to MonsterInsights Pro? To unlock your Pro features and addons, %sfollow our upgrade guide%s to install MonsterInsights Pro.' ), '<a href="'. monsterinsights_get_url( 'network-settings-page', 'go-lite-pro-link', "https://www.monsterinsights.com/docs/go-lite-pro" ) .'">', '</a>' ); ?> |
|
159 | + <?php echo sprintf( esc_html__( 'Already purchased an upgrade to MonsterInsights Pro? To unlock your Pro features and addons, %sfollow our upgrade guide%s to install MonsterInsights Pro.' ), '<a href="' . monsterinsights_get_url( 'network-settings-page', 'go-lite-pro-link', "https://www.monsterinsights.com/docs/go-lite-pro" ) . '">', '</a>' ); ?> |
|
160 | 160 | </p> |
161 | 161 | <p> |
162 | - <?php echo sprintf( esc_html__( "Don't yet have a Pro license? %sVisit our website%s to upgrade and learn more about all the amazing features, expanded report and powerful addons you unlock when you go Pro." ), '<a href="'. monsterinsights_get_upgrade_link( 'network-settings-page', 'upgrade-to-pro-link' ) .'">', '</a>' ); ?> |
|
162 | + <?php echo sprintf( esc_html__( "Don't yet have a Pro license? %sVisit our website%s to upgrade and learn more about all the amazing features, expanded report and powerful addons you unlock when you go Pro." ), '<a href="' . monsterinsights_get_upgrade_link( 'network-settings-page', 'upgrade-to-pro-link' ) . '">', '</a>' ); ?> |
|
163 | 163 | </p> |
164 | 164 | </td> |
165 | 165 | </tr> |
@@ -54,7 +54,7 @@ |
||
54 | 54 | |
55 | 55 | <table class="form-table"> |
56 | 56 | <tbody> |
57 | - <?php if ( monsterinsights_is_pro_version() ) { |
|
57 | + <?php if ( monsterinsights_is_pro_version() ) { |
|
58 | 58 | |
59 | 59 | $license_key = MonsterInsights()->license->get_network_license_key(); |
60 | 60 | $license_key = $license_key ? $license_key : MonsterInsights()->license->get_default_license_key(); |
@@ -155,25 +155,25 @@ discard block |
||
155 | 155 | $this->network = is_network_admin() || ! empty( $args['network'] ); |
156 | 156 | |
157 | 157 | $default_token = $this->network ? MonsterInsights()->auth->get_network_token() : MonsterInsights()->auth->get_token(); |
158 | - $default_key = $this->network ? MonsterInsights()->auth->get_network_key() : MonsterInsights()->auth->get_key(); |
|
158 | + $default_key = $this->network ? MonsterInsights()->auth->get_network_key() : MonsterInsights()->auth->get_key(); |
|
159 | 159 | |
160 | - $this->token = ! empty( $args['token'] ) ? $args['token'] : $default_token; |
|
161 | - $this->key = ! empty( $args['key'] ) ? $args['key'] : $default_key; |
|
162 | - $this->tt = ! empty( $args['tt'] ) ? $args['tt'] : ''; |
|
163 | - $this->return = ! empty( $args['return'] ) ? $args['return'] : ''; |
|
164 | - $this->start = ! empty( $args['start'] ) ? $args['start'] : ''; |
|
165 | - $this->end = ! empty( $args['end'] ) ? $args['end'] : ''; |
|
160 | + $this->token = ! empty( $args['token'] ) ? $args['token'] : $default_token; |
|
161 | + $this->key = ! empty( $args['key'] ) ? $args['key'] : $default_key; |
|
162 | + $this->tt = ! empty( $args['tt'] ) ? $args['tt'] : ''; |
|
163 | + $this->return = ! empty( $args['return'] ) ? $args['return'] : ''; |
|
164 | + $this->start = ! empty( $args['start'] ) ? $args['start'] : ''; |
|
165 | + $this->end = ! empty( $args['end'] ) ? $args['end'] : ''; |
|
166 | 166 | |
167 | 167 | // We need to do this hack so that the network panel + the site_url of the main site are distinct |
168 | 168 | $this->site_url = is_network_admin() ? network_admin_url() : site_url(); |
169 | 169 | |
170 | 170 | if ( monsterinsights_is_pro_version() ) { |
171 | - $this->license = $this->network ? MonsterInsights()->license->get_network_license_key() : MonsterInsights()->license->get_site_license_key(); |
|
171 | + $this->license = $this->network ? MonsterInsights()->license->get_network_license_key() : MonsterInsights()->license->get_site_license_key(); |
|
172 | 172 | } |
173 | 173 | $this->plugin = MonsterInsights()->plugin_slug; |
174 | 174 | $this->miversion = MONSTERINSIGHTS_VERSION; |
175 | - $this->sitei = ! empty( $args['sitei'] ) ? $args['sitei'] : ''; |
|
176 | - $this->testurl = ! empty( $args['testurl'] ) ? $args['testurl'] : ''; |
|
175 | + $this->sitei = ! empty( $args['sitei'] ) ? $args['sitei'] : ''; |
|
176 | + $this->testurl = ! empty( $args['testurl'] ) ? $args['testurl'] : ''; |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | public function request() { |
187 | 187 | // Make sure we're not blocked |
188 | 188 | $blocked = $this->is_blocked( $this->url ); |
189 | - if ( $blocked || is_wp_error( $blocked ) ) { |
|
189 | + if ( $blocked || is_wp_error( $blocked ) ) { |
|
190 | 190 | if ( is_wp_error( $blocked ) ) { |
191 | 191 | return new WP_Error( 'api-error', sprintf( __( 'The firewall of your server is blocking outbound calls. Please contact your hosting provider to fix this issue. %s', 'google-analytics-for-wordpress' ), $blocked->get_error_message() ) ); |
192 | 192 | } else { |
@@ -243,14 +243,14 @@ discard block |
||
243 | 243 | } |
244 | 244 | |
245 | 245 | if ( 'GET' == $this->method ) { |
246 | - $body['time'] = time(); // just to avoid caching |
|
246 | + $body['time'] = time(); // just to avoid caching |
|
247 | 247 | } |
248 | 248 | |
249 | - $body['timezone'] = date('e'); |
|
249 | + $body['timezone'] = date( 'e' ); |
|
250 | 250 | |
251 | 251 | $body['network'] = $this->network ? 'network' : 'site'; |
252 | 252 | |
253 | - $body['ip'] = ! empty( $_SERVER['SERVER_ADDR'] ) ? $_SERVER['SERVER_ADDR'] : ''; |
|
253 | + $body['ip'] = ! empty( $_SERVER['SERVER_ADDR'] ) ? $_SERVER['SERVER_ADDR'] : ''; |
|
254 | 254 | |
255 | 255 | // This filter will be removed in the future. |
256 | 256 | $body = apply_filters( 'monsterinsights_api_request_body', $body ); |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | ); |
282 | 282 | |
283 | 283 | // Perform the query and retrieve the response. |
284 | - $response = 'GET' == $this->method ? wp_remote_get( esc_url_raw( $this->url ) . '?' . $string, $data ) : wp_remote_post( esc_url_raw( $this->url ), $data ); |
|
284 | + $response = 'GET' == $this->method ? wp_remote_get( esc_url_raw( $this->url ) . '?' . $string, $data ) : wp_remote_post( esc_url_raw( $this->url ), $data ); |
|
285 | 285 | //return new WP_Error( 'debug', '<pre>' . var_export( $response, true ) . '</pre>' ); |
286 | 286 | |
287 | 287 | if ( is_wp_error( $response ) ) { |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | |
300 | 300 | // If not a 200 status header, send back error. |
301 | 301 | if ( 200 != $response_code ) { |
302 | - $type = ! empty( $response_body['type'] ) ? $response_body['type'] : 'api-error'; |
|
302 | + $type = ! empty( $response_body['type'] ) ? $response_body['type'] : 'api-error'; |
|
303 | 303 | |
304 | 304 | if ( empty( $response_code ) ) { |
305 | 305 | return new WP_Error( $type, __( 'The API was unreachable.', 'google-analytics-for-wordpress' ) ); |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | // and for image linking purposes in Google Images. We use it to test outbound connections since it is run on google.com |
390 | 390 | // and is only a few bytes large. Plus on Google's main CDN so it loads in most places in 0.07 seconds or less. Perfect for our |
391 | 391 | // use case of quickly testing outbound connections. |
392 | - $testurl = ! empty( $this->testurl ) ? $this->testurl :'http://www.google.com/blank.html'; |
|
392 | + $testurl = ! empty( $this->testurl ) ? $this->testurl : 'http://www.google.com/blank.html'; |
|
393 | 393 | if ( defined( 'WP_HTTP_BLOCK_EXTERNAL' ) && WP_HTTP_BLOCK_EXTERNAL ) { |
394 | 394 | if ( defined( 'WP_ACCESSIBLE_HOSTS' ) ) { |
395 | 395 | $wp_http = new WP_Http(); |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | 'body' => '' |
405 | 405 | ); |
406 | 406 | $response = wp_remote_get( $testurl, $params ); |
407 | - if( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) { |
|
407 | + if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) { |
|
408 | 408 | return false; |
409 | 409 | } else { |
410 | 410 | if ( is_wp_error( $response ) ) { |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | ); |
427 | 427 | $response = wp_remote_get( $testurl, $params ); |
428 | 428 | |
429 | - if( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) { |
|
429 | + if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) { |
|
430 | 430 | return false; |
431 | 431 | } else { |
432 | 432 | if ( is_wp_error( $response ) ) { |