Add MCP abilities for maintenance mode and cookie consent - #321
Merged
davidperezgar merged 2 commits intoOct 2, 2026
Merged
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Registers frontblocks/maintenance-mode via WordPress's Abilities API (wp_register_ability(), guarded with function_exists() for sites where it isn't available). It's read/write, manage_options-gated, and idempotent, so an MCP client can check and flip maintenance mode as part of a site go-live checklist instead of requiring a manual toggle in the FrontBlocks settings screen. It also reports WooCommerce's own "Coming soon" site-visibility state independently, since the checklist treats the two as separate things to verify. Maintenance::is_enabled() becomes a public static method (plus a new set_enabled() setter) so the ability can read and flip it without instantiating the class and re-triggering its constructor's hook registrations. The cookie-consent half of #299 is dropped from this PR: trunk's Cookie Notice hard cutover (#317) removed FrontBlocks' own banner entirely in favor of the standalone FrontConsent plugin while this was in progress, so an ability for it belongs in FrontConsent's own codebase instead — left as a follow-up there. Closes #299 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Castellon-ACM
force-pushed
the
feature/mcp-abilities-maintenance-cookie-consent
branch
from
October 2, 2026 06:46
8ced824 to
f39748f
Compare
The Abilities API's registries are a lazy, process-wide singleton: wp_abilities_api_init/wp_abilities_api_categories_init fire at most once per process, the first time anything calls into wp_has_ability() et al. This test's own set_up() hooks a second McpAbilities instance on top of the one Plugin_Main::load_modules() creates at bootstrap, so if that one-time firing happened during this test, both instances tried to register the same ability name and WordPress's "already registered" guard called _doing_it_wrong() — which this suite's strict PHPUnit settings (convertWarningsToExceptions/convertNoticesToExceptions) turn into a thrown exception, failing the test on every PHP version in the matrix (it depends on the WordPress version, not the PHP version). Reduce to exactly one hooked instance before the first call that can trigger the singleton, and stop firing the hooks directly with do_action() (which bypassed the registries' own one-time guard entirely and triggered the exact same problem deterministically). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
davidperezgar
approved these changes
Oct 2, 2026
Contributor
|
Awesome! |
davidperezgar
deleted the
feature/mcp-abilities-maintenance-cookie-consent
branch
October 2, 2026 07:17
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.
Registers two abilities via WordPress's Abilities API (wp_register_ability(), guarded with function_exists() for sites where it isn't available): frontblocks/maintenance-mode and frontblocks/cookie-consent-banner. Both are read/write, manage_options-gated, and idempotent, so an MCP client can check and flip them as part of a site go-live checklist instead of requiring a manual toggle in the FrontBlocks settings screen. Maintenance mode also reports WooCommerce's own "Coming soon" site-visibility state independently, since the checklist treats the two as separate things to verify.
Maintenance::is_enabled() and CookieNotice::is_enabled() become public static methods (plus new set_enabled() setters) so the ability can read and flip them without instantiating those classes and re-triggering their constructors' hook registrations.
Closes #299