Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make filters more surgical #79

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,6 @@ public function __construct( $config = array() ) {
add_filter( 'plugins_api', array( $this, 'get_plugin_info' ), 10, 3 );
add_filter( 'upgrader_post_install', array( $this, 'upgrader_post_install' ), 10, 3 );

// set timeout
add_filter( 'http_request_timeout', array( $this, 'http_request_timeout' ) );

// set sslverify for zip download
add_filter( 'http_request_args', array( $this, 'http_request_sslverify' ), 10, 2 );
}

public function has_minimum_config() {
Expand Down Expand Up @@ -266,13 +261,21 @@ public function get_new_version() {
* @return mixed
*/
public function remote_get( $query ) {
// set timeout
add_filter( 'http_request_timeout', array( $this, 'http_request_timeout' ) );

// set sslverify for zip download
add_filter( 'http_request_args', array( $this, 'http_request_sslverify' ), 10, 2 );

if ( ! empty( $this->config['access_token'] ) )
$query = add_query_arg( array( 'access_token' => $this->config['access_token'] ), $query );

$raw_response = wp_remote_get( $query, array(
'sslverify' => $this->config['sslverify']
) );

// Remove filters so we don't globally impact http requets.
remove_filter( 'http_request_timeout', array( $this, 'http_request_timeout' ) );
remove_filter( 'http_request_args', array( $this, 'http_request_sslverify' ) );
return $raw_response;
}

Expand Down Expand Up @@ -437,4 +440,4 @@ public function upgrader_post_install( $true, $hook_extra, $result ) {
return $result;

}
}
}