[wp-trac] [WordPress Trac] #65002: Connectors: Replace plugin.slug with plugin.file and harden plugin data handling

WordPress Trac noreply at wordpress.org
Tue Mar 31 17:17:54 UTC 2026


#65002: Connectors: Replace plugin.slug with plugin.file and harden plugin data
handling
------------------------------+--------------------------------------
 Reporter:  jorgefilipecosta  |      Owner:  (none)
     Type:  defect (bug)      |     Status:  new
 Priority:  normal            |  Milestone:  7.0
Component:  General           |    Version:  trunk
 Severity:  normal            |   Keywords:  has-patch has-unit-tests
  Focuses:                    |
------------------------------+--------------------------------------
 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) ===

 1. '''PHPDoc''': Update `@type string $file` documentation in
 `wp_register_connector()` and `WP_Connector_Registry::register()` to
 include a single-file plugin example (`'hello.php'`).

 2. '''JS output''': Stop stripping the `.php` extension from `plugin.file`
 in `_wp_connectors_get_connector_script_module_data()`. The JS output now
 matches the PHP registration value exactly (e.g. `akismet/akismet.php`
 instead of `akismet/akismet`). This avoids the confusing situation where
 `file` meant different things in PHP vs JS contexts.

 3. '''Registry validation''': `WP_Connector_Registry::register()` now
 cherry-picks only the `file` key from the `plugin` array instead of
 storing whatever is passed. This ensures stored data always matches the
 documented shape and silently drops invalid keys.

 4. '''Test update''': Update `test_register_includes_plugin_data` to 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

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/65002>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list