Skip to content
Browse files

Updated to remove the use of ini_set, and replaced cURL functions wit…

…h the WordPress HTTP API
  • Loading branch information...
1 parent 19f9b52 commit b0242a119c08e8a2f4359a23e4e5029447548740 @Japh Japh committed May 30, 2012
View
25 envato-wordpress-toolkit-library/class-envato-protected-api.php
@@ -113,7 +113,7 @@ public function private_user_data( $set = '', $user_name = '', $set_data = '', $
$cache_results = $this->set_cache( $transient, $url, $timeout );
$results = $cache_results;
} else {
- $results = $this->curl( $url );
+ $results = $this->remote_request( $url );
}
if ( isset( $results->error ) ) {
@@ -199,7 +199,7 @@ public function item_details( $item_id, $allow_cache = true, $timeout = 300 ) {
$cache_results = $this->set_cache( $transient, $url, $timeout );
$results = $cache_results;
} else {
- $results = $this->curl( $url );
+ $results = $this->remote_request( $url );
}
if ( isset( $results->error ) ) {
@@ -251,7 +251,7 @@ public function set_cache( $transient = '', $url = '', $timeout = 300 ) {
}
/* create the cache and allow filtering before it's saved */
- if ( $results = apply_filters( 'envato_api_set_cache', $this->curl( $url ), $transient ) ) {
+ if ( $results = apply_filters( 'envato_api_set_cache', $this->remote_request( $url ), $transient ) ) {
set_transient( $transient, $results, $timeout );
return $results;
}
@@ -325,33 +325,28 @@ public function api_errors() {
}
/**
- * Helper function to query the marketplace API via CURL.
+ * Helper function to query the marketplace API via wp_remote_request.
*
* @param string The url to access.
- * @return object The results of the curl request.
+ * @return object The results of the wp_remote_request request.
*
* @access private
* @since 1.0
*/
- protected function curl( $url ) {
+ protected function remote_request( $url ) {
if ( empty( $url ) ) {
return false;
}
- $ch = curl_init( $url );
- curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
+ $request = wp_remote_request( $url );
- $data = curl_exec( $ch );
- $info = curl_getinfo( $ch );
- curl_close( $ch );
+ $data = json_decode( $request['body'] );
- $data = json_decode( $data );
-
- if ( $info['http_code'] == 200 ) {
+ if ( $request['response']['code'] == 200 ) {
return $data;
} else {
- $this->set_error( 'http_code', $info['http_code'] );
+ $this->set_error( 'http_code', $request['response']['code'] );
}
if ( isset( $data->error ) ) {
View
2 envato-wordpress-toolkit-library/class-envato-wordpress-theme-upgrader.php
@@ -261,7 +261,7 @@ public function _http_request_args($r)
{
if ((int)ini_get("max_execution_time") < ETU_MAX_EXECUTION_TIME)
{
- ini_set("max_execution_time", ETU_MAX_EXECUTION_TIME);
+ set_time_limit( ETU_MAX_EXECUTION_TIME );
}
$r['timeout'] = ETU_MAX_EXECUTION_TIME;

0 comments on commit b0242a1

Please sign in to comment.
Something went wrong with that request. Please try again.