Minor fixes and some comments
This commit is contained in:
parent
cdf2d22243
commit
f41dc30d28
|
|
@ -103,7 +103,7 @@ if ( !class_exists('Puc_v4_Metadata', false) ):
|
||||||
|
|
||||||
if ( property_exists($from, 'slug') && !empty($from->slug) ) {
|
if ( property_exists($from, 'slug') && !empty($from->slug) ) {
|
||||||
//Let plugins add extra fields without having to create subclasses.
|
//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) {
|
foreach ($fields as $field) {
|
||||||
|
|
@ -121,10 +121,11 @@ if ( !class_exists('Puc_v4_Metadata', false) ):
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param string $tag
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function getPrefixedFilter($tag) {
|
protected function getPrefixedFilter($tag) {
|
||||||
return 'puc_' . $tag . '-';
|
return 'puc_' . $tag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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()).
|
//Query args to append to the URL. Plugins can add their own by using a filter callback (see addQueryArgFilter()).
|
||||||
$installedVersion = $this->getInstalledVersion();
|
$installedVersion = $this->getInstalledVersion();
|
||||||
$queryArgs['installed_version'] = ($installedVersion !== null) ? $installedVersion : '';
|
$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.
|
//Various options for the wp_remote_get() call. Plugins can filter these, too.
|
||||||
$options = array(
|
$options = array(
|
||||||
'timeout' => 10, //seconds
|
'timeout' => 10, //seconds
|
||||||
'headers' => array(
|
'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'
|
//The plugin info should be at 'http://your-api.com/url/here/$slug/info.json'
|
||||||
$url = $this->metadataUrl;
|
$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;
|
return $pluginInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -388,7 +388,10 @@ if ( !class_exists('Puc_v4_Plugin_UpdateChecker', false) ):
|
||||||
'puc_check_for_updates'
|
'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) ) {
|
if ( !empty($linkText) ) {
|
||||||
/** @noinspection HtmlUnknownTarget */
|
/** @noinspection HtmlUnknownTarget */
|
||||||
$pluginMeta[] = sprintf('<a href="%s">%s</a>', esc_attr($linkUrl), $linkText);
|
$pluginMeta[] = sprintf('<a href="%s">%s</a>', esc_attr($linkUrl), $linkText);
|
||||||
|
|
@ -441,7 +444,7 @@ if ( !class_exists('Puc_v4_Plugin_UpdateChecker', false) ):
|
||||||
}
|
}
|
||||||
printf(
|
printf(
|
||||||
'<div class="updated notice is-dismissible"><p>%s</p></div>',
|
'<div class="updated notice is-dismissible"><p>%s</p></div>',
|
||||||
apply_filters('puc_manual_check_message-' . $this->slug, $message, $status)
|
apply_filters($this->getUniqueName('manual_check_message'), $message, $status)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ if ( !class_exists('Puc_v4_Vcs_PluginUpdateChecker') ):
|
||||||
parent::__construct($api->getRepositoryUrl(), $pluginFile, $slug, $checkPeriod, $optionName, $muPluginFile);
|
parent::__construct($api->getRepositoryUrl(), $pluginFile, $slug, $checkPeriod, $optionName, $muPluginFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: Do something about this unused parameter.
|
||||||
public function requestInfo($queryArgs = array()) {
|
public function requestInfo($queryArgs = array()) {
|
||||||
//We have to make several remote API requests to gather all the necessary info
|
//We have to make several remote API requests to gather all the necessary info
|
||||||
//which can take a while on slow networks.
|
//which can take a while on slow networks.
|
||||||
|
|
|
||||||
|
|
@ -240,6 +240,7 @@ class PucReadmeParser {
|
||||||
|
|
||||||
if ( $markdown ) { // Parse markdown.
|
if ( $markdown ) { // Parse markdown.
|
||||||
if ( !class_exists('Parsedown', false) ) {
|
if ( !class_exists('Parsedown', false) ) {
|
||||||
|
/** @noinspection PhpIncludeInspection */
|
||||||
require_once(dirname(__FILE__) . '/Parsedown' . (version_compare(PHP_VERSION, '5.3.0', '>=') ? '' : 'Legacy') . '.php');
|
require_once(dirname(__FILE__) . '/Parsedown' . (version_compare(PHP_VERSION, '5.3.0', '>=') ? '' : 'Legacy') . '.php');
|
||||||
}
|
}
|
||||||
$instance = Parsedown::instance();
|
$instance = Parsedown::instance();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue