Code Duplication    Length = 9-11 lines in 2 locations

classes/autoptimizeUtils.php 1 location

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

classes/autoptimizeImages.php 1 location

@@ 1309-1317 (lines=9) @@
1306
1307
            // only do the remote call if $url is not empty to make sure no parse_url
1308
            // weirdness results in useless calls.
1309
            if ( ! empty( $url ) ) {
1310
                $response = wp_remote_get( $url );
1311
                if ( ! is_wp_error( $response ) ) {
1312
                    if ( '200' == wp_remote_retrieve_response_code( $response ) ) {
1313
                        $stats = json_decode( wp_remote_retrieve_body( $response ), true );
1314
                        autoptimizeOptionWrapper::update_option( 'autoptimize_imgopt_provider_stat', $stats );
1315
                    }
1316
                }
1317
            }
1318
        }
1319
    }
1320