fix(wp): make the plugin's WordPress version check read the header it declares - #40
Draft
DavidBabinec wants to merge 1 commit into
Draft
DavidBabinec wants to merge 1 commit into
DavidBabinec wants to merge 1 commit into
Conversation
Plugin::data() asked get_file_data() for a "Requires WP" header that core-framework.php has never declared, so requiredWP() was always an empty string and the plugin's own WordPress version guard never fired. The header map is now a class constant so a test can check every entry against the headers the plugin file actually declares.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The plugin's own WordPress version check never ran.
Plugin::data()read aRequires WPheader, butcore-framework.phpdeclaresRequires at least(6.6 since #32), sorequiredWP()returned an empty string andRequirements::versionCompare()always passed.Requires PHPwas already correct.The header map is now a
Plugin::HEADERSconstant, withrequired-wppointing atRequires at least. The newPluginHeadersTestchecks that every entry is declared in the plugin file and that both requirement values matchreadme.txt.Why
WordPress core still blocks activating or updating on an unsupported version. But a site that gets 2.1.0 onto WordPress 6.5 anyway (files copied in by hand, or a core downgrade) kept the plugin active. It now shows the plugin's notice and deactivates on the next admin load. I checked this in Docker with the release ZIP on WordPress 6.5: the plugin stayed active with the old key and deactivated with the fix.
Verification