Connectors: Add Akismet as a default connector#76828
Connectors: Add Akismet as a default connector#76828jorgefilipecosta wants to merge 11 commits intotrunkfrom
Conversation
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: 0 B Total Size: 7.73 MB ℹ️ View Unchanged
|
|
Flaky tests detected in 88fba9e. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/23653186115
|
|
Overall, this works as expected. |
| } | ||
|
|
||
| // Non-AI default connectors. | ||
| $defaults['akismet'] = array( |
There was a problem hiding this comment.
One additional note, we have to test it with Akismet with the case where it also registers connector. This will go first, so it would be important to verify that the plugin can override settings.
There was a problem hiding this comment.
Well, they can also unregister and register again 🤔
There was a problem hiding this comment.
We do upsert on the registration on the client. I guess we just need to double check on the server we have the same behavior.
The default setting_name used connectors_ai_ prefix regardless of
connector type. Now uses the connector type in the prefix:
ai_provider → connectors_ai_, other types → connectors_{type}_,
no type → connectors_.
- Default setting_name is now connectors_{type}_{id}_api_key with no
special cases
- Built-in AI connectors explicitly declare setting_name, constant_name,
and env_var_name
- Third-party AI providers get explicit names at registration time
- constant_name/env_var_name are truly optional: only checked when
provided, no auto-derivation from connector ID
- _gutenberg_get_api_key_source simplified: removed $connector_id param
and all auto-derivation logic
|
I'm checking my previous comments, and it looks like everything, but #76828 (comment) was addressed. |
- Collapse setting_name fallback to single str_replace call, removing dead empty-type check since type is a required field - Remove isInstalled from script module output; client derives install status from pluginFile presence - Remove ai_provider/spam_filtering type restriction for api_key render
|
I created WordPress/wordpress-develop#11378 to sync changes to WordPress core. Let's compare these implementations and see if anything diverged. |
|
Tested using Gutenberg.run and the Beta Tester plugin pulling the nightly and the expected flows worked for me noting that Akismet was already installed, but not activated. The flow from the Connectors page was ACTIVATE and then adding the API key showed it as connected. I then deleted the Akismet plugin and the Connectors page showed INSTALL and the flow from there worked as expected. No issues on testing from my end. |
There was a problem hiding this comment.
Nice, all the feedback was addressed, and the implementation aligns with what I prepared independently for WordPress core.
This is where my PR against WordPress Core diverges from this PR:
- Stricter validation for
setting_name,constant_name, andenv_var_nameinregister()
This PR uses ! empty() && is_string() which silently ignores invalid values (e.g., empty strings, non-strings). I used isset() with explicit _doing_it_wrong() validation and returns null on invalid input, consistent with how other fields (name, type, authentication.method) are validated in the same method. This prevents silent bugs when a caller explicitly passes an invalid value.
- Default AI connector definitions don't hardcode
setting_name,constant_name,env_var_name
This PR hardcodes all three fields in each of the three built-in connector definitions (anthropic, google, openai) and generates them inline for third-party providers. My PR instead infers all three in the registration loop before calling register(), avoiding repetition. The generated values are identical — connectors_ai_{id}_api_key for setting names and {CONSTANT_CASE_ID}_API_KEY for constant/env var names.
Both differences are intentional improvements — same behavior for valid inputs, better error handling and less repetition. I don't think it's stricly necessary to apply these changes here, but I thought it was worth outlining them expliclitly for documentation purposes.
Summary
spam_filteringconnector alongside the three AI providersapi_keyauthenticationwordpress_api_keyWordPress option for Akismet's API keypluginFileso the client doesn't assume{slug}/pluginregister_setting()when the setting is already registered by the owning pluginconstant_nameandenv_var_nametruly optional — no auto-generation from connector ID, only checked when explicitly providedsetting_name,constant_name, andenv_var_namesetting_namefor new connector types followsconnectors_{type}_{id}_api_key(no special cases)Needs to be tested against the core trunk (as all connectors related functionality).
This PR is experimental to find bugs when using a non AI connector.
Test plan
OPENAI_API_KEY) or constant still detectedWPCOM_API_KEYconstant but does not auto-checkAKISMET_API_KEYenv varnpm run test:e2e -- test/e2e/specs/admin/connectors.spec.js