Code Duplication    Length = 9-11 lines in 3 locations

classes/autoptimizeConfig.php 1 location

@@ 421-429 (lines=9) @@
418
    <?php
419
    if ( $this->settings_screen_do_remote_http ) {
420
        $AO_banner = get_transient( 'autoptimize_banner' );
421
        if ( empty( $AO_banner ) ) {
422
            $banner_resp = wp_remote_get( 'https://misc.optimizingmatters.com/autoptimize_news.html?ao_ver='.AUTOPTIMIZE_PLUGIN_VERSION );
423
            if ( ! is_wp_error( $banner_resp ) ) {
424
                if ( '200' == wp_remote_retrieve_response_code( $banner_resp ) ) {
425
                    $AO_banner = wp_kses_post( wp_remote_retrieve_body( $banner_resp ) );
426
                    set_transient('autoptimize_banner', $AO_banner, DAY_IN_SECONDS);
427
                }
428
            }
429
        }
430
        echo $AO_banner;
431
    }
432
    ?>

classes/autoptimizeImages.php 1 location

@@ 1069-1077 (lines=9) @@
1066
1067
            // only do the remote call if $url is not empty to make sure no parse_url
1068
            // weirdness results in useless calls.
1069
            if ( ! empty( $url ) ) {
1070
                $response = wp_remote_get( $url );
1071
                if ( ! is_wp_error( $response ) ) {
1072
                    if ( '200' == wp_remote_retrieve_response_code( $response ) ) {
1073
                        $stats = json_decode( wp_remote_retrieve_body( $response ), true );
1074
                        update_option( 'autoptimize_imgopt_provider_stat', $stats );
1075
                    }
1076
                }
1077
            }
1078
        }
1079
    }
1080

classes/autoptimizeUtils.php 1 location

@@ 311-321 (lines=11) @@
308
    public static function check_service_availability( $return_result = false )
309
    {
310
        $service_availability_resp = wp_remote_get( 'https://misc.optimizingmatters.com/api/autoptimize_service_availablity.json?from=aomain&ver=' . AUTOPTIMIZE_PLUGIN_VERSION );
311
        if ( ! is_wp_error( $service_availability_resp ) ) {
312
            if ( '200' == wp_remote_retrieve_response_code( $service_availability_resp ) ) {
313
                $availabilities = json_decode( wp_remote_retrieve_body( $service_availability_resp ), true );
314
                if ( is_array( $availabilities ) ) {
315
                    update_option( 'autoptimize_service_availablity', $availabilities );
316
                    if ( $return_result ) {
317
                        return $availabilities;
318
                    }
319
                }
320
            }
321
        }
322
    }
323
324
    /**