Fix PHP 7.4-8.5 / WP 6.0-7.0 compatibility and harden packaging - #15
Open
RahatSheikhLeon wants to merge 2 commits into
Open
Fix PHP 7.4-8.5 / WP 6.0-7.0 compatibility and harden packaging#15RahatSheikhLeon wants to merge 2 commits into
RahatSheikhLeon wants to merge 2 commits into
Conversation
Audit and repair the plugin so it runs across the full declared range, with
no feature or behavior change. Declared floor raised to PHP 7.4 / WP 6.0.
Fatal-path fixes:
- Guard the style-handler submodule require with file_exists(); an
uninitialised submodule previously fataled the plugin on load
- Replace the init-time `throw new Error` on missing build output with a
capability-gated admin notice, so a missing build no longer white-screens
the whole site
PHP 8.x fixes:
- Use `require` instead of `include_once` for dist/modules.asset.php; a
second *_once include returns bool, making the array offsets fatal
- Add isset()/is_array() guards around asset dependency and version reads
- Guard illegal array keys and non-string values in the font loader
- Guard missing blockName and non-array attrs in render_block handling
Hygiene:
- Sanitize $_SERVER['QUERY_STRING'] via wp_unslash + sanitize_text_field
- add_filter('init', ...) -> add_action('init', ...) for meta registration
- Add the missing ABSPATH guard to the main plugin file
- Add Requires PHP, Requires at least and Tested up to headers, which were
absent entirely, and correct the stale readme.txt values
Packaging:
- Rewrite .distignore: exclude config/ and babel config files, catch all
sourcemaps, and fix two pattern bugs that leaked files into the zip -
leading-slash entries never match, and the .git rule could not catch a
submodule's .git file. Verified against a real wp dist-archive build.
Version bumped to 1.5.0 across the plugin header, TOGGLE_CONTENT_VERSION,
readme.txt Stable tag and package.json.
Full audit, including issues flagged but deliberately not auto-fixed, is in
compatibility-report.md.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Converts readme.txt to GitHub-flavored markdown, matching the output shape of the wp_readme_to_markdown grunt task the Gruntfile declares. Generated by hand rather than via `grunt readme`: the Gruntfile loads grunt-wp-i18n and grunt-wp-readme-to-markdown, but neither is declared in package.json devDependencies, so the task cannot run without adding undeclared dependencies. README.md is already excluded by .distignore, so it does not ship in the plugin zip. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Summary
Compatibility pass over the whole declared range — PHP 7.4 → 8.5 and WordPress 6.0 → 7.0 — with no feature or behavior change. Latest stable verified live on 2026-08-10 (PHP 8.5.9, WP 7.0.3).
Detected original baseline was PHP 5.6-era / WP 5.6-declared (really 5.9+ in practice). The policy minimum won on both axes, so the declared floor is now PHP 7.4 / WP 6.0.
Two fatals fixed
lib/style-handlersubmodule required unconditionally. The submodule was uninitialised and empty in a fresh checkout, sorequire_oncefataled the plugin on load. Now guarded withfile_exists().throw new Errorfrom aninitcallback when build output is missing — an uncaughtErroroninitis a site-wide white screen. Now a capability-gated admin notice.PHP 8.x fixes
include_oncefordist/modules.asset.phpreturnsboolon a second include, making the array offsets below it fatal. Switched torequire.isset()/is_array()guards around asset dependency and version reads.blockName, and non-arrayattrs.Hygiene
$_SERVER['QUERY_STRING'](wp_unslash+sanitize_text_field).add_filter('init', …)→add_action('init', …).ABSPATHguard.Requires PHP,Requires at least,Tested up to— absent entirely before — and corrected stalereadme.txtvalues (Tested up towas 6.5, five majors behind).Packaging
.distignorerewritten. Beyond excludingconfig/and babel configs, this fixes two pattern bugs verified against a realwp dist-archivebuild:/controls/expanded to*//controls/*(literal double slash), so 4 files leaked..gitrule could not catch a submodule's.gitfile. Root.gitis a directory, so the rule became*/.git/*;lib/style-handler/.gitshipped, containing a local absolute path.dist/*.*.mapmissed nested maps —dist/frontend/index.js.mapshipped.Package now goes from 29 → 21 files, with all runtime files verified present.
Version
Bumped to 1.5.0, synced across plugin header,
TOGGLE_CONTENT_VERSION,readme.txtStable tag, andpackage.json.Test plan
php -lclean on all 10 PHP files under PHP 8.5.8npm run build) reproduces byte-identical outputwp dist-archivepackage verified: nonode_modules, no.git, top-level foldertoggle-content/, 13dist/files presentNot auto-fixed — needs a decision
Documented in
compatibility-report.md§7:is_registered('essential-blocks/countdown')guard attoggle-content.php:116checks the wrong block name, so the block silently fails to register when Essential Blocks is active.lib/style-handler(undefined constant,in_array()onfalse,array_key_exists()on non-array,count()on non-countable). Separate shared repo, needs its own PR.eb_wp_versionfloat cast — thecontrolssubmodule compares it numerically (>= 5.8), so "fixing" it to a string would break every EB sibling plugin.DOMNodeInsertedin the animation loader, removed from Chromium 127+.Note on the base branch
Targeting
latest, notmaster—masteris missing commitd04c239. The two have diverged and should be reconciled separately.🤖 Generated with Claude Code