Skip to content

Use WordPress 7.0 core AI client for Plugin Namer #1195

Open
davidperezgar wants to merge 7 commits intotrunkfrom
1192-fatal-error-with-wordpress-70-beta-2-using-core
Open

Use WordPress 7.0 core AI client for Plugin Namer #1195
davidperezgar wants to merge 7 commits intotrunkfrom
1192-fatal-error-with-wordpress-70-beta-2-using-core

Conversation

@davidperezgar
Copy link
Member

@davidperezgar davidperezgar commented Mar 1, 2026

Description

Fixes the fatal error when running Plugin Check on WordPress 7.0 beta 2 by removing the custom AI Connect integration and using WordPress core’s AI client API (wp_ai_client_prompt) for the Plugin Namer tool. The plugin no longer depends on external AI connection code that conflicted with core in WP 7.0 beta 2.

Fixes #1192

Changes

  • Use core AI client – Plugin Namer now uses wp_ai_client_prompt() and related core APIs instead of the previous AI Connect trait. AI execution lives in AI_Check_Names::execute_ai_request() with a function_exists('wp_ai_client_prompt') check and a clear message when the AI client is not available (WordPress 7.0+ required).
  • Remove Settings page and AI_Connect – Deleted includes/Admin/Settings_Page.php, includes/Traits/AI_Connect.php, and assets/js/admin-settings.js. AI is configured in WordPress 7.0+ core settings only; the plugin no longer provides its own AI settings screen.
  • Namer_Page – Added get_ai_config() to validate core AI availability (WP 7.0+, wp_ai_client_prompt, and is_supported_for_text_generation()). Added render_ai_notice() to show a notice on the Namer page when AI connectors are not configured.
  • Plugin_Main – Stopped instantiating/registering Settings_Page; only the main Admin page and Namer page are registered.
  • AI_Check_Names – Uses core prompt builder only; supports both snake_case and camelCase method names for compatibility with core API. No external AI client dependency.
  • readme.txt – Clarified that the Plugin Namer requires WordPress 7.0+ and configured AI connectors in core settings.
  • composer.json / composer.lock – Removed any AI Connect–related dependency and kept the rest of the tooling intact.
  • phpmd.xml – Adjusted exclusions/comments to match the removal of the Settings page.

Benefits

  • Eliminates the fatal error when using Plugin Check with WordPress 7.0 beta 2.
  • Aligns the Plugin Namer with WordPress core’s AI features and avoids maintaining a separate AI connection layer.
  • Users configure AI once in WordPress 7.0+ settings; no duplicate plugin-specific AI settings.
  • Clear messaging when WP < 7.0 or when AI connectors are not set up.

Testing Instructions

  1. Check out this branch and ensure the plugin is active in a WordPress 7.0 beta 2 (or newer) environment.
  2. Go to Tools → Plugin Check and confirm the main Plugin Check page loads without errors.
  3. Go to Tools → Plugin Check Namer and confirm:
    • On WP 7.0+ with AI connectors configured: the form loads and you can run a name check.
    • On WP 7.0+ without AI configured: a notice explains that AI connectors must be configured in WordPress 7.0+ settings; the page still loads without a fatal.
  4. On WordPress < 7.0, open Tools → Plugin Check Namer and confirm the page shows the requirement for WordPress 7.0+ and does not fatally error.
  5. Run composer lint and composer phpstan (if applicable) and fix any reported issues.

Checklist

  • Code follows WordPress Coding Standards
  • Self-reviewed the code
  • Added necessary comments
  • No new linter errors
@davidperezgar davidperezgar linked an issue Mar 1, 2026 that may be closed by this pull request
@github-actions
Copy link

github-actions bot commented Mar 1, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: davidperezgar <davidperez@git.wordpress.org>
Co-authored-by: jonathanbossenger <psykro@git.wordpress.org>
Co-authored-by: ernilambar <nilambar@git.wordpress.org>
Co-authored-by: threadi <threadi@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@jonathanbossenger
Copy link

Testing notes

Installed PCP on a WordPress version older than 7.0:

  • ✅ The Settings page is not displayed in the menu
  • On the Plugin Check Namer page, the Configure AI Connectors button appears.

Upgraded to WordPress 7.0 beta 2:

  • On the Plugin Check Namer page, the Plugin Name, Author Name, and AI Model selection fields are shown, even though I haven't configured a connector
  • Attempted to add the Anthropic connector, but was unable to save the API Key. I had to disable PCP to be able to add the connector.
  • Added the Anthropic connector, reactivated PCPC. On the Plugin Check Namer page, I can't select the Model
  • Attempting to check a name, the Ajax request responds with "No models found that support text_generation for this prompt"
  • Checking the connectors page, and it appears my Anthropic connector is not connected anymore. Disabling PCP and the connector shows as connected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants