#65002 closed defect (bug) (fixed)
Connectors: Replace plugin.slug with plugin.file and harden plugin data handling
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 7.0 | Priority: | normal |
| Severity: | normal | Version: | trunk |
| Component: | General | Keywords: | has-patch has-unit-tests dev-reviewed |
| Focuses: | Cc: |
Description
The Connectors API currently uses plugin.slug (the WordPress.org slug) to identify plugins associated with a connector. This is insufficient because:
- It requires a
get_plugins()call to map slugs to file paths for status checks, adding unnecessary overhead. - The slug alone doesn't uniquely identify a plugin file.
This ticket replaces plugin.slug with plugin.file — the plugin's main file path relative to the plugins directory (e.g. akismet/akismet.php or hello.php). This simplifies the backend by allowing direct file_exists() and is_plugin_active() checks without the slug-to-file mapping step.
Changes
PHP (backend)
- PHPDoc: Update
@type string $filedocumentation inwp_register_connector()andWP_Connector_Registry::register()to include a single-file plugin example ('hello.php').
- JS output: Stop stripping the
.phpextension fromplugin.filein_wp_connectors_get_connector_script_module_data(). The JS output now matches the PHP registration value exactly (e.g.akismet/akismet.phpinstead ofakismet/akismet). This avoids the confusing situation wherefilemeant different things in PHP vs JS contexts.
- Registry validation:
WP_Connector_Registry::register()now cherry-picks only thefilekey from thepluginarray instead of storing whatever is passed. This ensures stored data always matches the documented shape and silently drops invalid keys.
- Test update: Update
test_register_includes_plugin_datato use'file' => 'my-plugin/my-plugin.php'instead of the outdated'slug' => 'my-plugin'.
PR: https://github.com/WordPress/wordpress-develop/pull/11400
Testing
- Run PHPUnit:
phpunit --filter WP_Connector_Registry - Verify connectors page loads and shows correct plugin status (installed/not installed/active)
- Verify install and activate flows still work for AI provider plugins
Change History (5)
This ticket was mentioned in PR #11400 on WordPress/wordpress-develop by @jorgefilipecosta.
7 weeks ago
#1
#3
@
7 weeks ago
- Owner set to jorgefilipecosta
- Resolution set to fixed
- Status changed from new to closed
In 62192:
#5
@
12 days ago
@jorgefilipecosta Please remember to follow the commit message guidelines https://make.wordpress.org/core/handbook/best-practices/commit-messages/ so that it's easy to track what has been merged.
## Summary
plugin.slugwithplugin.file(the full plugin file path, e.g.akismet/akismet.php) in connector registrationsget_plugins()slug-to-file map, usefile_exists()andis_plugin_active()directlyisInstalledto the frontend plugin dataTicket: https://core.trac.wordpress.org/ticket/65002
## Test plan