|
@@ -146,20 +146,20 @@ discard block |
|
|
block discarded – undo |
|
146
|
146
|
$this->network = is_network_admin() || ! empty( $args['network'] ); |
|
147
|
147
|
|
|
148
|
148
|
$default_token = $this->network ? MonsterInsights()->auth->get_network_token() : MonsterInsights()->auth->get_token(); |
|
149
|
|
- $default_key = $this->network ? MonsterInsights()->auth->get_network_key() : MonsterInsights()->auth->get_key(); |
|
|
149
|
+ $default_key = $this->network ? MonsterInsights()->auth->get_network_key() : MonsterInsights()->auth->get_key(); |
|
150
|
150
|
|
|
151
|
|
- $this->token = ! empty( $args['token'] ) ? $args['token'] : $default_token; |
|
152
|
|
- $this->key = ! empty( $args['key'] ) ? $args['key'] : $default_key; |
|
153
|
|
- $this->tt = ! empty( $args['tt'] ) ? $args['tt'] : ''; |
|
154
|
|
- $this->return = ! empty( $args['return'] ) ? $args['return'] : ''; |
|
155
|
|
- $this->start = ! empty( $args['start'] ) ? $args['start'] : ''; |
|
156
|
|
- $this->end = ! empty( $args['end'] ) ? $args['end'] : ''; |
|
|
151
|
+ $this->token = ! empty( $args['token'] ) ? $args['token'] : $default_token; |
|
|
152
|
+ $this->key = ! empty( $args['key'] ) ? $args['key'] : $default_key; |
|
|
153
|
+ $this->tt = ! empty( $args['tt'] ) ? $args['tt'] : ''; |
|
|
154
|
+ $this->return = ! empty( $args['return'] ) ? $args['return'] : ''; |
|
|
155
|
+ $this->start = ! empty( $args['start'] ) ? $args['start'] : ''; |
|
|
156
|
+ $this->end = ! empty( $args['end'] ) ? $args['end'] : ''; |
|
157
|
157
|
|
|
158
|
158
|
// We need to do this hack so that the network panel + the site_url of the main site are distinct |
|
159
|
159
|
$this->site_url = is_network_admin() ? network_admin_url() : site_url(); |
|
160
|
160
|
|
|
161
|
161
|
if ( monsterinsights_is_pro_version() ) { |
|
162
|
|
- $this->license = $this->network ? MonsterInsights()->license->get_network_license_key() : MonsterInsights()->license->get_site_license_key(); |
|
|
162
|
+ $this->license = $this->network ? MonsterInsights()->license->get_network_license_key() : MonsterInsights()->license->get_site_license_key(); |
|
163
|
163
|
} |
|
164
|
164
|
$this->plugin = MonsterInsights()->plugin_slug; |
|
165
|
165
|
$this->miversion = MONSTERINSIGHTS_VERSION; |
|
@@ -228,14 +228,14 @@ discard block |
|
|
block discarded – undo |
|
228
|
228
|
} |
|
229
|
229
|
|
|
230
|
230
|
if ( 'GET' == $this->method ) { |
|
231
|
|
- $body['time'] = time(); // just to avoid caching |
|
|
231
|
+ $body['time'] = time(); // just to avoid caching |
|
232
|
232
|
} |
|
233
|
233
|
|
|
234
|
|
- $body['timezone'] = date('e'); |
|
|
234
|
+ $body['timezone'] = date( 'e' ); |
|
235
|
235
|
|
|
236
|
236
|
$body['network'] = $this->network ? 'network' : 'site'; |
|
237
|
237
|
|
|
238
|
|
- $body['ip'] = ! empty( $_SERVER['SERVER_ADDR'] ) ? $_SERVER['SERVER_ADDR'] : ''; |
|
|
238
|
+ $body['ip'] = ! empty( $_SERVER['SERVER_ADDR'] ) ? $_SERVER['SERVER_ADDR'] : ''; |
|
239
|
239
|
|
|
240
|
240
|
// This filter will be removed in the future. |
|
241
|
241
|
$body = apply_filters( 'monsterinsights_api_request_body', $body ); |
|
@@ -279,7 +279,7 @@ discard block |
|
|
block discarded – undo |
|
279
|
279
|
|
|
280
|
280
|
// If not a 200 status header, send back error. |
|
281
|
281
|
if ( 200 != $response_code ) { |
|
282
|
|
- $type = ! empty( $response_body['type'] ) ? $response_body['type'] : 'api-error'; |
|
|
282
|
+ $type = ! empty( $response_body['type'] ) ? $response_body['type'] : 'api-error'; |
|
283
|
283
|
|
|
284
|
284
|
if ( empty( $response_code ) ) { |
|
285
|
285
|
return new WP_Error( $type, __( 'The API was unreachable.', 'google-analytics-for-wordpress' ) ); |
|
@@ -384,7 +384,7 @@ discard block |
|
|
block discarded – undo |
|
384
|
384
|
'body' => '' |
|
385
|
385
|
); |
|
386
|
386
|
$response = wp_remote_get( $testurl, $params ); |
|
387
|
|
- if( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) { |
|
|
387
|
+ if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) { |
|
388
|
388
|
return false; |
|
389
|
389
|
} else { |
|
390
|
390
|
return true; |
|
@@ -402,7 +402,7 @@ discard block |
|
|
block discarded – undo |
|
402
|
402
|
); |
|
403
|
403
|
$response = wp_remote_get( $testurl, $params ); |
|
404
|
404
|
|
|
405
|
|
- if( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) { |
|
|
405
|
+ if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) { |
|
406
|
406
|
return false; |
|
407
|
407
|
} else { |
|
408
|
408
|
return true; |