From 4e8f5a568e43bb59fe83822b2dfbe5534225d941 Mon Sep 17 00:00:00 2001 From: dangoodman Date: Tue, 12 Jun 2018 19:24:31 +0300 Subject: [PATCH] Fix WordPress reporting unknown compatibility of a plugin/theme update --- Puc/v4p4/UpdateChecker.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Puc/v4p4/UpdateChecker.php b/Puc/v4p4/UpdateChecker.php index 7ead6fe..76eaf44 100644 --- a/Puc/v4p4/UpdateChecker.php +++ b/Puc/v4p4/UpdateChecker.php @@ -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);