diff --git a/Puc/v4/Plugin/UpdateChecker.php b/Puc/v4/Plugin/UpdateChecker.php index 3035a34..0201bed 100644 --- a/Puc/v4/Plugin/UpdateChecker.php +++ b/Puc/v4/Plugin/UpdateChecker.php @@ -102,7 +102,7 @@ if ( !class_exists('Puc_v4_Plugin_UpdateChecker', false) ): * @param array $queryArgs Additional query arguments to append to the request. Optional. * @return Puc_v4_Plugin_Info */ - public function requestInfo($queryArgs = array()){ + public function requestInfo($queryArgs = array()) { //Query args to append to the URL. Plugins can add their own by using a filter callback (see addQueryArgFilter()). $installedVersion = $this->getInstalledVersion(); $queryArgs['installed_version'] = ($installedVersion !== null) ? $installedVersion : ''; diff --git a/Puc/v4/Vcs/Api.php b/Puc/v4/Vcs/Api.php index 7d5dd32..00034f0 100644 --- a/Puc/v4/Vcs/Api.php +++ b/Puc/v4/Vcs/Api.php @@ -14,6 +14,12 @@ if ( !class_exists('Puc_v4_Vcs_Api') ): */ protected $credentials = null; + /** + * @var string The filter tag that's used to filter options passed to wp_remote_get. + * For example, "puc_request_info_options-slug" or "puc_request_update_options_theme-slug". + */ + protected $httpFilterName = ''; + /** * Puc_v4_Vcs_Api constructor. * @@ -222,6 +228,13 @@ if ( !class_exists('Puc_v4_Vcs_Api') ): public function signDownloadUrl($url) { return $url; } + + /** + * @param string $filterName + */ + public function setHttpFilterName($filterName) { + $this->httpFilterName = $filterName; + } } endif; diff --git a/Puc/v4/Vcs/BitBucketApi.php b/Puc/v4/Vcs/BitBucketApi.php index a82139f..2d7f682 100644 --- a/Puc/v4/Vcs/BitBucketApi.php +++ b/Puc/v4/Vcs/BitBucketApi.php @@ -187,8 +187,11 @@ if ( !class_exists('Puc_v4_Vcs_BitBucketApi', false) ): $url = $this->oauth->sign($url,'GET'); } - $response = wp_remote_get($url, array('timeout' => 10)); - //var_dump($response); + $options = array('timeout' => 10); + if ( !empty($this->httpFilterName) ) { + $options = apply_filters($this->httpFilterName, $options); + } + $response = wp_remote_get($url, $options); if ( is_wp_error($response) ) { return $response; } diff --git a/Puc/v4/Vcs/GitHubApi.php b/Puc/v4/Vcs/GitHubApi.php index 3e3e74d..d3168ba 100644 --- a/Puc/v4/Vcs/GitHubApi.php +++ b/Puc/v4/Vcs/GitHubApi.php @@ -171,7 +171,11 @@ if ( !class_exists('Puc_v4_Vcs_GitHubApi', false) ): $url = add_query_arg($queryParams, $url); } - $response = wp_remote_get($url, array('timeout' => 10)); + $options = array('timeout' => 10); + if ( !empty($this->httpFilterName) ) { + $options = apply_filters($this->httpFilterName, $options); + } + $response = wp_remote_get($url, $options); if ( is_wp_error($response) ) { return $response; } diff --git a/Puc/v4/Vcs/PluginUpdateChecker.php b/Puc/v4/Vcs/PluginUpdateChecker.php index acf3095..9e0e46c 100644 --- a/Puc/v4/Vcs/PluginUpdateChecker.php +++ b/Puc/v4/Vcs/PluginUpdateChecker.php @@ -24,11 +24,12 @@ if ( !class_exists('Puc_v4_Vcs_PluginUpdateChecker') ): */ public function __construct($api, $pluginFile, $slug = '', $checkPeriod = 12, $optionName = '', $muPluginFile = '') { $this->api = $api; + $this->api->setHttpFilterName($this->getUniqueName('request_info_options')); + parent::__construct($api->getRepositoryUrl(), $pluginFile, $slug, $checkPeriod, $optionName, $muPluginFile); } - //TODO: Do something about this unused parameter. - public function requestInfo($queryArgs = array()) { + public function requestInfo($unusedParameter = null) { //We have to make several remote API requests to gather all the necessary info //which can take a while on slow networks. set_time_limit(60); diff --git a/Puc/v4/Vcs/ThemeUpdateChecker.php b/Puc/v4/Vcs/ThemeUpdateChecker.php index 5390b3d..f69832c 100644 --- a/Puc/v4/Vcs/ThemeUpdateChecker.php +++ b/Puc/v4/Vcs/ThemeUpdateChecker.php @@ -24,6 +24,8 @@ if ( !class_exists('Puc_v4_Vcs_ThemeUpdateChecker', false) ): */ public function __construct($api, $stylesheet = null, $customSlug = null, $checkPeriod = 12, $optionName = '') { $this->api = $api; + $this->api->setHttpFilterName($this->getUniqueName('request_update_options')); + parent::__construct($api->getRepositoryUrl(), $stylesheet, $customSlug, $checkPeriod, $optionName); }