| @@ 313-323 (lines=11) @@ | ||
| 310 | public static function check_service_availability( $return_result = false ) |
|
| 311 | { |
|
| 312 | $service_availability_resp = wp_remote_get( 'https://misc.optimizingmatters.com/api/autoptimize_service_availablity.json?from=aomain&ver=' . AUTOPTIMIZE_PLUGIN_VERSION ); |
|
| 313 | if ( ! is_wp_error( $service_availability_resp ) ) { |
|
| 314 | if ( '200' == wp_remote_retrieve_response_code( $service_availability_resp ) ) { |
|
| 315 | $availabilities = json_decode( wp_remote_retrieve_body( $service_availability_resp ), true ); |
|
| 316 | if ( is_array( $availabilities ) ) { |
|
| 317 | autoptimizeOptionWrapper::update_option( 'autoptimize_service_availablity', $availabilities ); |
|
| 318 | if ( $return_result ) { |
|
| 319 | return $availabilities; |
|
| 320 | } |
|
| 321 | } |
|
| 322 | } |
|
| 323 | } |
|
| 324 | return null; |
|
| 325 | } |
|
| 326 | ||
| @@ 1237-1245 (lines=9) @@ | ||
| 1234 | ||
| 1235 | // only do the remote call if $url is not empty to make sure no parse_url |
|
| 1236 | // weirdness results in useless calls. |
|
| 1237 | if ( ! empty( $url ) ) { |
|
| 1238 | $response = wp_remote_get( $url ); |
|
| 1239 | if ( ! is_wp_error( $response ) ) { |
|
| 1240 | if ( '200' == wp_remote_retrieve_response_code( $response ) ) { |
|
| 1241 | $stats = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
| 1242 | autoptimizeOptionWrapper::update_option( 'autoptimize_imgopt_provider_stat', $stats ); |
|
| 1243 | } |
|
| 1244 | } |
|
| 1245 | } |
|
| 1246 | } |
|
| 1247 | } |
|
| 1248 | ||