Repository navigation
Fix fatal is_plugin_active() error in wp-admin on WordPress 6.7 and older - #1239
Conversation
…lder The Yoast SEO module and the Util plugin-detection helpers call is_plugin_active() during init. WordPress before 6.8 only loads wp-admin/includes/plugin.php for wp-admin after init, so every admin screen failed with "Call to undefined function is_plugin_active()" when Yoast SEO was not active. Before 2.29.0, Plugin::deactivateLegacyPlugin() loaded that file on init as a side effect; removing it exposed the bug. Add Util::isPluginActive(), which loads wp-admin/includes/plugin.php when needed, and use it in all plugin-detection helpers. The Yoast module now uses Util::isYoastSeoActivated() instead of its own copy. Fixes #1238 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review: Safe to merge ✅Code. The diff adds Tests. Fresh SandyWP sandboxes (not cloned from any customer site), PHP 8.3,
The PHP debug log had no PHP notices, warnings or errors in any run with this PR. On Evidence. These links need a Repile login, so the images can't be embedded here:
Unrelated, already on Verdict: Safe to merge. It fixes the 2.29.0 fatal on WP 6.7 and older and shows no regressions on 6.7 or 7.1.3, with or without Yoast. |
Description
On WordPress 6.7 and older, with Yoast SEO not active, every wp-admin screen fails with
Call to undefined function is_plugin_active()inmodules/yoastseo/yoastseo.php:120. This affects the released 2.29.0 and currentdevelopment.PPCH_Yoastseo::isYoastSEOActivated()and theUtil::is*Activated()helpers callis_plugin_active()duringinit(LegacyPlugin::init, priority 1000). WordPress before 6.8 only loadswp-admin/includes/plugin.phpfor wp-admin afterinit. Until 2.29.0,Plugin::deactivateLegacyPlugin()ran oninitat priority 10 and loaded that file as a side effect. Removing it in 4fee77b (#380) exposed the bug. WordPress 6.8+ loads the file inwp-settings.php, so it doesn't show there.Changes:
Util::isPluginActive(), which loadswp-admin/includes/plugin.phpwhenis_plugin_active()isn't available yet. This is the same guardLegacyPlugin::isBlockEditorActive()already uses.Util::is*Activated()helpers (Rank Math, AIOSEO, WooCommerce, Yoast SEO, ACF) and inLegacyPlugin::isClassicEditorInstalled().PPCH_Yoastseo::isYoastSEOActivated()now callsUtil::isYoastSeoActivated()instead of keeping its own copy.Tested
Fresh SandyWP sandboxes, PHP 8.3,
WP_DEBUG_LOGon.development@358d914(= 2.29.0)The PHP debug log had no plugin entries in any run with this PR.
development, WP 6.7, no Yoast)Recordings: before · after: Dashboard, Checklists, Settings, block editor, front end
Test site
Open a copy of the test site. Each click opens a fresh copy, signed in to wp-admin as admin.
development/2.29.0.Benefits
wp-admin works again on WordPress 5.5–6.7 (the plugin's declared minimum is 5.5) without depending on another plugin to load
wp-admin/includes/plugin.php. Pro calls the sameUtil::is*Activated()helpers, so it is covered too.Possible drawbacks
wp-admin/includes/plugin.phpis now loaded duringiniton WordPress before 6.8 when one of these checks runs. WordPress 6.8+ already does this itself, and 2.28.0 and earlier did the same viadeactivateLegacyPlugin().Applicable issues
Fixes #1238
Checklist
developmentbranch.development, feature/hotfix/release branch. (Do not submit to the master branch!)🤖 Generated with Claude Code