Skip to content

Add MCP abilities for maintenance mode and cookie consent - #321

Merged
davidperezgar merged 2 commits into
trunkfrom
feature/mcp-abilities-maintenance-cookie-consent
Oct 2, 2026
Merged

davidperezgar merged 2 commits into
trunkfrom
feature/mcp-abilities-maintenance-cookie-consent

Conversation

@Castellon-ACM

@Castellon-ACM Castellon-ACM commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

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

Open WordPress Playground Preview

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

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
Castellon-ACM force-pushed the feature/mcp-abilities-maintenance-cookie-consent branch from 8ced824 to f39748f Compare October 2, 2026 06:46
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

Copy link
Copy Markdown
Contributor

Awesome!

@davidperezgar
davidperezgar merged commit 432253b into trunk Oct 2, 2026
7 checks passed
@davidperezgar
davidperezgar deleted the feature/mcp-abilities-maintenance-cookie-consent branch October 2, 2026 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add MCP abilities for maintenance mode and cookie consent

2 participants