Fix WordPress reporting unknown compatibility of a plugin/theme update

This commit is contained in:
dangoodman 2018-06-12 19:24:31 +03:00
parent f26378d0c2
commit 4e8f5a568e
1 changed files with 8 additions and 0 deletions

View File

@ -301,6 +301,14 @@ if ( !class_exists('Puc_v4p4_UpdateChecker', false) ):
//Let plugins/themes modify the update.
$update = apply_filters($this->getUniqueName('request_update_result'), $update, $httpResult);
// "Tested up to" field in the plugin metadata is supposed to be in form of "major.minor",
// while WordPress core's list_plugin_updates() expects the $update->tested field to be
// the exact version, e.g. "major.minor.patch", to say it's compatible. In other case it would
// show "Compatibility: Unknown". That kinda mimics how wordpress.org API handles the "tested" field.
if (isset($update->tested) && preg_match('/^\d+\.\d+$/', $update->tested)) {
$update->tested .= ".999";
}
if ( isset($update, $update->translations) ) {
//Keep only those translation updates that apply to this site.
$update->translations = $this->filterApplicableTranslations($update->translations);