Skip to content

fix(compat): restore Connectors admin page on WP 6.9 + Gutenberg#1311

Merged
superdav42 merged 1 commit into
mainfrom
fix/gutenberg-connectors-load-order
May 10, 2026
Merged

fix(compat): restore Connectors admin page on WP 6.9 + Gutenberg#1311
superdav42 merged 1 commit into
mainfrom
fix/gutenberg-connectors-load-order

Conversation

@superdav42
Copy link
Copy Markdown
Contributor

Summary

On WP 6.9 with Gutenberg 22.8.0+ active, the Connectors admin page at options-general.php?page=options-connectors-wp-admin returns 404.

Root cause

gutenberg/lib/load.php:133 gates Connectors-page registration on a class-existence check that runs at plugin file-include time:

if ( class_exists( '\WordPress\AiClient\AiClient' ) ) {
    require __DIR__ . '/experimental/connectors/load.php';
}

WordPress loads plugins alphabetically. After we renamed from gratis-ai-agent to superdav-ai-agent, gutenberg now loads before us. At the moment Gutenberg evaluates that gate, our SdkLoader::register() (which makes \WordPress\AiClient\AiClient autoloadable from our bundled lib/php-ai-client/) has not yet run. The gate returns false, Gutenberg silently skips loading experimental/connectors/load.php, and the admin page is never registered.

Fix

New SdAiAgent\Compat\GutenbergConnectorsBridge polyfill, hooked on admin_menu priority 12 (one tick after Gutenberg's own priority 11 hook). It:

  1. Bails on WP 7.0+ (native Connectors page exists in core).
  2. Bails when Gutenberg < 22.8.0 or absent (existing JS prompts the user to install Gutenberg).
  3. Bails when the page slug is already registered under options-general.php (defence in depth).
  4. Otherwise: manually require_onces Gutenberg's build/pages/options-connectors/page-wp-admin.php (which defines gutenberg_options_connectors_wp_admin_render_page), then calls add_submenu_page() with that callback — restoring the official Gutenberg-backed Connectors UI.

Wired in AdminHandler::register_gutenberg_connectors_bridge() via #[Action(tag: 'admin_menu', priority: 12)].

Verification

  • php -l clean on both edited files.
  • No .distignore exclusion — new file ships in both full and WP.org zips.
  • DI handler attribute scanning runs on every request when compile=false and on first request after fresh install when compile=true. Fresh installs of the rebuilt 1.11.1 zip will pick up the new method.
  • Cannot reproduce locally (dev install is WP 7.1-alpha, hits the native path); user has confirmed WP 6.9 + Gutenberg 23.0.0 jurassic.ninja repro.

Notes

  • Kept on 1.11.1 (not bumped to 1.11.2) at user request — same WP.org review submission, just a corrected zip.
  • Fix is targeted: only acts on the exact failure pattern, no behavioural change on healthy installs.

aidevops.sh v3.15.23 plugin for OpenCode v1.14.41 with claude-sonnet-4-6 spent 21h 16m and 40 tokens on this as a headless worker.

… load-order race causes Gutenberg to skip its own registration

On WP 6.9 with Gutenberg 22.8.0+ active, the Connectors admin page at
options-general.php?page=options-connectors-wp-admin returns 404. Root
cause: Gutenberg's lib/load.php gates registration on
class_exists('\\WordPress\\AiClient\\AiClient') at file-include
time. Plugins load alphabetically, so 'gutenberg' runs before
'superdav-ai-agent', meaning our SdkLoader::register() (which makes the
SDK class autoloadable from lib/php-ai-client/) has not yet run. The
gate fails, Gutenberg never requires experimental/connectors/load.php,
and the admin page is never registered.

Fix: a new GutenbergConnectorsBridge polyfill, hooked on admin_menu
priority 12 (one tick after Gutenberg's own priority 11), detects this
case and manually requires Gutenberg's render-page file before calling
add_submenu_page() with its render callback. No-op on WP 7.0+ (native
page) and when Gutenberg is missing (existing JS prompts to install).

Note: this regression became user-visible after the plugin slug rename
from 'gratis-ai-agent' to 'superdav-ai-agent' moved us alphabetically
after 'gutenberg'.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 10, 2026

Warning

Rate limit exceeded

@superdav42 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 4 minutes and 11 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f5c0bb60-4759-4fa4-8d23-861bdbbfa577

📥 Commits

Reviewing files that changed from the base of the PR and between ac7669a and 492a05a.

📒 Files selected for processing (2)
  • includes/Bootstrap/AdminHandler.php
  • includes/Compat/GutenbergConnectorsBridge.php
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/gutenberg-connectors-load-order

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added the bug Auto-created from TODO.md tag label May 10, 2026
@superdav42 superdav42 merged commit 7be0066 into main May 10, 2026
14 of 16 checks passed
@superdav42 superdav42 deleted the fix/gutenberg-connectors-load-order branch May 10, 2026 00:54
superdav42 added a commit that referenced this pull request May 10, 2026
… follow-up) (#1312)

* fix(compat): force-load Gutenberg Connectors subsystem on WP 6.9

The previous PR #1311 only restored the Settings → Connectors menu item
but left Gutenberg's connectors registry, default AI providers, REST
validation, and script-module data filter unloaded. Result: the page
rendered but only Jetpack appeared, while Anthropic/Google/OpenAI
provider cards (and any other plugin-registered connectors) were
missing because the wp_connectors_init action never fired.

Root cause: Gutenberg gates lib/experimental/connectors/load.php
behind a class_exists('\\WordPress\\AiClient\\AiClient') check
evaluated at plugin file-load time. Plugins load alphabetically, so
gutenberg < superdav-ai-agent — our SdkLoader::register() runs after
Gutenberg's gate, so the gate always fails and the entire connectors
subsystem stays unloaded.

Fix: directly require Gutenberg's connectors loader on plugins_loaded:1
(after our SDK loader, before init:15 when Gutenberg's registry
initialiser fires). After this hook runs, behaviour is identical to a
fresh Gutenberg install on WP 7.0 — every default AI provider
registers, every plugin's wp_connectors_init hook fires, and the
script-module data filter populates the React app.

The existing admin_menu:12 menu polyfill stays as defence-in-depth
should a future Gutenberg release move the loader path.

No-op on WP 7.0+ (core) or without Gutenberg ≥ 22.8.0.

* fix(build): strip dev-only scripts/, playwright.config.js, .wordpress-org/ from release zips

Three top-level dev artefacts were being shipped inside both the full
GitHub release zip and the WordPress.org zip:

  - scripts/             (Node helper scripts: archive.js, add-strict-types.js)
  - playwright.config.js (E2E test runner config)
  - .wordpress-org/      (WP.org SVN-only assets + Playground blueprints)

None of them are referenced by runtime PHP. The .wordpress-org/
directory is read by WordPress.org from the SVN repository root, NOT
from the plugin zip — shipping it inside the zip wastes ~30 KB and
exposes dev-only blueprint scaffolding to end-user installs.

Verified on the rebuilt 1.11.1-wporg zip (clean install on jurassic.ninja
WP 6.9.4 + Gutenberg 23.1.1): no fatals, all three paths absent,
Connectors subsystem still loads correctly. Zip size dropped from
2.18 MB to 2.09 MB.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Auto-created from TODO.md tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant