@@ -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 ) ) { |