Skip to content

Commit

Permalink
PLUGINS-6825
Browse files Browse the repository at this point in the history
  • Loading branch information
meteor-ec committed Nov 27, 2023
1 parent 7309382 commit 926e4da
Showing 1 changed file with 1 addition and 35 deletions.
36 changes: 1 addition & 35 deletions lib/ecwid_platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

class EcwidPlatform {

protected static $http_use_streams = false;

protected static $crypt = null;

protected static $ecwid_plugin_data = null;
Expand Down Expand Up @@ -257,10 +255,6 @@ public static function fetch_url( $url, $options = array() ) {
);
}

if ( get_option( 'ecwid_http_use_stream', false ) ) {
self::$http_use_streams = true;
}

$default_timeout = 10;
$result = wp_remote_get(
$url,
Expand All @@ -273,18 +267,13 @@ public static function fetch_url( $url, $options = array() ) {
);

if ( wp_remote_retrieve_response_code( $result ) == '429' ) {

$retry_after = intval( wp_remote_retrieve_header( $result, 'retry-after' ) );

if ( $retry_after > 0 ) {
update_option( self::OPTION_ECWID_CHECK_API_RETRY_AFTER, time() + $retry_after );
}
}

if ( get_option( 'ecwid_http_use_stream', false ) ) {
self::$http_use_streams = false;
}

$return = array(
'code' => '',
'data' => '',
Expand All @@ -302,7 +291,6 @@ public static function fetch_url( $url, $options = array() ) {
'data' => $result['body'],
);
} elseif ( is_object( $result ) ) {

$return = array(
'code' => $result->get_error_code(),
'data' => $result->get_error_data(),
Expand Down Expand Up @@ -332,19 +320,7 @@ public static function http_post_request( $url, $data = array(), $params = array

$args['body'] = $data;

if ( get_option( 'ecwid_http_use_stream', false ) !== true ) {
$result = wp_remote_post( $url, $args );
}

if ( ! is_array( $result ) ) {
self::$http_use_streams = true;
$result = wp_remote_post( $url, $args );
self::$http_use_streams = false;

if ( is_array( $result ) ) {
update_option( 'ecwid_http_use_stream', true );
}
}
$result = wp_remote_post( $url, $args );

return $result;
}
Expand Down Expand Up @@ -392,14 +368,6 @@ public static function reset( $name ) {
update_option( self::OPTION_ECWID_PLUGIN_DATA, self::$ecwid_plugin_data );
}

public static function http_api_transports( $transports ) {
if ( self::$http_use_streams ) {
return array( 'streams' );
}

return $transports;
}

public static function store_in_products_cache( $url, $data ) {
self::store_in_cache( $url, 'products', $data, WEEK_IN_SECONDS );
}
Expand Down Expand Up @@ -609,5 +577,3 @@ public static function clear_all_transients() {
do_action( 'ecwid_clean_external_cache' );
}
}

add_filter( 'http_api_transports', array( 'EcwidPlatform', 'http_api_transports' ) );

0 comments on commit 926e4da

Please sign in to comment.