@@ -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 | |
286 | 286 | //return new WP_Error( 'debug', '<pre>' . var_export( $response, true ) . '</pre>' ); |
287 | 287 | |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | |
301 | 301 | // If not a 200 status header, send back error. |
302 | 302 | if ( 200 != $response_code ) { |
303 | - $type = ! empty( $response_body['type'] ) ? $response_body['type'] : 'api-error'; |
|
303 | + $type = ! empty( $response_body['type'] ) ? $response_body['type'] : 'api-error'; |
|
304 | 304 | |
305 | 305 | if ( empty( $response_code ) ) { |
306 | 306 | return new WP_Error( $type, __( 'The API was unreachable.', 'google-analytics-for-wordpress' ) ); |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | // and for image linking purposes in Google Images. We use it to test outbound connections since it is run on google.com |
389 | 389 | // 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 |
390 | 390 | // use case of quickly testing outbound connections. |
391 | - $testurl = ! empty( $this->testurl ) ? $this->testurl :'https://www.google.com/blank.html'; |
|
391 | + $testurl = ! empty( $this->testurl ) ? $this->testurl : 'https://www.google.com/blank.html'; |
|
392 | 392 | if ( defined( 'WP_HTTP_BLOCK_EXTERNAL' ) && WP_HTTP_BLOCK_EXTERNAL ) { |
393 | 393 | if ( defined( 'WP_ACCESSIBLE_HOSTS' ) ) { |
394 | 394 | $wp_http = new WP_Http(); |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | 'body' => '' |
404 | 404 | ); |
405 | 405 | $response = wp_remote_get( $testurl, $params ); |
406 | - if( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) { |
|
406 | + if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) { |
|
407 | 407 | return false; |
408 | 408 | } else { |
409 | 409 | if ( is_wp_error( $response ) ) { |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | ); |
426 | 426 | $response = wp_remote_get( $testurl, $params ); |
427 | 427 | |
428 | - if( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) { |
|
428 | + if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) { |
|
429 | 429 | return false; |
430 | 430 | } else { |
431 | 431 | if ( is_wp_error( $response ) ) { |