From f41dc30d28e63d99970f0f0d96f908e178d4b9b6 Mon Sep 17 00:00:00 2001 From: Yahnis Elsts Date: Wed, 28 Dec 2016 16:09:28 +0200 Subject: [PATCH] Minor fixes and some comments --- Puc/v4/Metadata.php | 5 +++-- Puc/v4/Plugin/UpdateChecker.php | 15 +++++++++------ Puc/v4/Vcs/PluginUpdateChecker.php | 1 + vendor/readme-parser.php | 1 + 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Puc/v4/Metadata.php b/Puc/v4/Metadata.php index 7391e70..7bb5082 100644 --- a/Puc/v4/Metadata.php +++ b/Puc/v4/Metadata.php @@ -103,7 +103,7 @@ if ( !class_exists('Puc_v4_Metadata', false) ): if ( property_exists($from, 'slug') && !empty($from->slug) ) { //Let plugins add extra fields without having to create subclasses. - $fields = apply_filters($this->getPrefixedFilter('retain_fields') . $from->slug, $fields); + $fields = apply_filters($this->getPrefixedFilter('retain_fields') . '-' . $from->slug, $fields); } foreach ($fields as $field) { @@ -121,10 +121,11 @@ if ( !class_exists('Puc_v4_Metadata', false) ): } /** + * @param string $tag * @return string */ protected function getPrefixedFilter($tag) { - return 'puc_' . $tag . '-'; + return 'puc_' . $tag; } } diff --git a/Puc/v4/Plugin/UpdateChecker.php b/Puc/v4/Plugin/UpdateChecker.php index 3c085a7..3035a34 100644 --- a/Puc/v4/Plugin/UpdateChecker.php +++ b/Puc/v4/Plugin/UpdateChecker.php @@ -106,16 +106,16 @@ if ( !class_exists('Puc_v4_Plugin_UpdateChecker', false) ): //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 : ''; - $queryArgs = apply_filters('puc_request_info_query_args-'.$this->slug, $queryArgs); + $queryArgs = apply_filters($this->getUniqueName('request_info_query_args'), $queryArgs); //Various options for the wp_remote_get() call. Plugins can filter these, too. $options = array( 'timeout' => 10, //seconds 'headers' => array( - 'Accept' => 'application/json' + 'Accept' => 'application/json', ), ); - $options = apply_filters('puc_request_info_options-'.$this->slug, $options); + $options = apply_filters($this->getUniqueName('request_info_options'), $options); //The plugin info should be at 'http://your-api.com/url/here/$slug/info.json' $url = $this->metadataUrl; @@ -145,7 +145,7 @@ if ( !class_exists('Puc_v4_Plugin_UpdateChecker', false) ): ); } - $pluginInfo = apply_filters('puc_request_info_result-'.$this->slug, $pluginInfo, $result); + $pluginInfo = apply_filters($this->getUniqueName('request_info_result'), $pluginInfo, $result); return $pluginInfo; } @@ -388,7 +388,10 @@ if ( !class_exists('Puc_v4_Plugin_UpdateChecker', false) ): 'puc_check_for_updates' ); - $linkText = apply_filters('puc_manual_check_link-' . $this->slug, __('Check for updates', 'plugin-update-checker')); + $linkText = apply_filters( + $this->getUniqueName('manual_check_link'), + __('Check for updates', 'plugin-update-checker') + ); if ( !empty($linkText) ) { /** @noinspection HtmlUnknownTarget */ $pluginMeta[] = sprintf('%s', esc_attr($linkUrl), $linkText); @@ -441,7 +444,7 @@ if ( !class_exists('Puc_v4_Plugin_UpdateChecker', false) ): } printf( '

%s

', - apply_filters('puc_manual_check_message-' . $this->slug, $message, $status) + apply_filters($this->getUniqueName('manual_check_message'), $message, $status) ); } } diff --git a/Puc/v4/Vcs/PluginUpdateChecker.php b/Puc/v4/Vcs/PluginUpdateChecker.php index da2ba5f..acf3095 100644 --- a/Puc/v4/Vcs/PluginUpdateChecker.php +++ b/Puc/v4/Vcs/PluginUpdateChecker.php @@ -27,6 +27,7 @@ if ( !class_exists('Puc_v4_Vcs_PluginUpdateChecker') ): parent::__construct($api->getRepositoryUrl(), $pluginFile, $slug, $checkPeriod, $optionName, $muPluginFile); } + //TODO: Do something about this unused parameter. public function requestInfo($queryArgs = array()) { //We have to make several remote API requests to gather all the necessary info //which can take a while on slow networks. diff --git a/vendor/readme-parser.php b/vendor/readme-parser.php index 334bca7..d89a06e 100644 --- a/vendor/readme-parser.php +++ b/vendor/readme-parser.php @@ -240,6 +240,7 @@ class PucReadmeParser { if ( $markdown ) { // Parse markdown. if ( !class_exists('Parsedown', false) ) { + /** @noinspection PhpIncludeInspection */ require_once(dirname(__FILE__) . '/Parsedown' . (version_compare(PHP_VERSION, '5.3.0', '>=') ? '' : 'Legacy') . '.php'); } $instance = Parsedown::instance();