Skip to content

Align credentials with WP 7.0 connectors: per-provider options#7

Merged
swissspidy merged 5 commits intomainfrom
copilot/add-wordpress-7-0-connectors
Mar 5, 2026
Merged

Align credentials with WP 7.0 connectors: per-provider options#7
swissspidy merged 5 commits intomainfrom
copilot/add-wordpress-7-0-connectors

Conversation

Copy link
Contributor

Copilot AI commented Mar 4, 2026

WordPress 7.0 introduces a central connectors screen where each AI provider stores its API key in a dedicated option (connectors_ai_{$connector_id}_api_key) and masks it via _wp_connectors_mask_api_key(). This PR updates the wp ai credentials command to match that convention.

Changes

  • Option storage: Replaced the single wp_ai_client_provider_credentials array option with individual per-provider options, using the setting_name from each provider's connector registry entry.
  • Registry-only providers: All commands (get, set, delete, list) now exclusively operate on providers registered in _wp_connectors_get_connector_settings(). Attempting to use an unregistered provider produces Error: Provider "X" is not a supported AI connector.
  • Credential enumeration: get_all_credentials() iterates over _wp_connectors_get_connector_settings() and calls get_option() for each registered provider's setting_name. Since WP 7.0 registers an option_* filter that applies _wp_connectors_mask_api_key(), the returned values are already masked — no custom masking needed.
  • Masking removed: The local mask_api_key() method has been removed entirely; masking is delegated to WP core's option filter.
  • Sanitize bypass: set calls remove_all_filters("sanitize_option_{$option_name}") before update_option() to skip WP 7.0's live API key validation (appropriate for a trusted CLI admin tool).
# Before
wp_ai_client_provider_credentials → ['openai' => 'sk-...', 'google' => '...']  (array)
Masked: sk-*****abcd  (asterisks, first 3 + last 4)

# After
connectors_ai_openai_api_key → 'sk-...'  (option name from connector registry)
connectors_ai_google_api_key → '...'
Masked: ••••••••abcd  (bullets, last 4 only — handled by WP core filter)

# Unregistered provider
$ wp ai credentials set unknown --api-key=foo
Error: Provider "unknown" is not a supported AI connector.
Original prompt

This section details on the original issue you should resolve

<issue_title>WordPress 7.0 connectors</issue_title>
<issue_description>WordPress 7.0 will have a central connectors screen for providers.

Each provider/connector will store its credentials in a connectors_ai_{$connector_id}_api_key"

We should use similar wording and logic, for example for masking (_wp_connectors_mask_api_key)

See https://github.com/WordPress/wordpress-develop/blob/707fa78322968b590e84b29d0575de65dc785b2c/src/wp-includes/connectors.php</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Add central connectors screen for WordPress 7.0 Align credentials with WP 7.0 connectors: per-provider options and bullet masking Mar 4, 2026
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title Align credentials with WP 7.0 connectors: per-provider options and bullet masking Align credentials with WP 7.0 connectors: per-provider options Mar 4, 2026
@swissspidy swissspidy marked this pull request as ready for review March 5, 2026 10:07
Copilot AI review requested due to automatic review settings March 5, 2026 10:07

This comment was marked as resolved.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
@github-actions github-actions bot added command:ai-credentials Related to 'ai credentials' command enhancement New feature or request scope:distribution Related to distribution status:unconfirmed Issue was could not be confirmed yet labels Mar 5, 2026
@swissspidy swissspidy merged commit be5d975 into main Mar 5, 2026
55 checks passed
@swissspidy swissspidy deleted the copilot/add-wordpress-7-0-connectors branch March 5, 2026 11:33
@swissspidy swissspidy mentioned this pull request Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:ai-credentials Related to 'ai credentials' command enhancement New feature or request scope:distribution Related to distribution status:unconfirmed Issue was could not be confirmed yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WordPress 7.0 connectors

3 participants