Skip to content

Connectors: account for mu-plugins when resolving plugin.file status#76994

Merged
jorgefilipecosta merged 3 commits intoWordPress:trunkfrom
Adi-ty:feat/connectors-mu-plugin-status-fix
Apr 6, 2026
Merged

Connectors: account for mu-plugins when resolving plugin.file status#76994
jorgefilipecosta merged 3 commits intoWordPress:trunkfrom
Adi-ty:feat/connectors-mu-plugin-status-fix

Conversation

@Adi-ty
Copy link
Copy Markdown
Contributor

@Adi-ty Adi-ty commented Apr 2, 2026

What?

Closes #76984

This PR updates connector plugin status detection so connectors continue to appear when their plugin is installed as a must-use plugin.

Why?

The connectors screen was checking plugin.file in the regular plugins directory only.
If a connector plugin was moved to mu-plugins and loaded via a mu-plugin bootstrap file, the connector could disappear even though the plugin was in use.

How?

  • For connector plugin.file, check both: WP_PLUGIN_DIR and WPMU_PLUGIN_DIR
  • Mark plugin as activated when it is found in mu-plugins (mu-plugins are always loaded), or it is a regular plugin and is_plugin_active returns true.

Testing Instructions

  1. Start wordpress-develop trunk with Gutenberg plugin active from this branch.
  2. Ensure Akismet exists in wp-content/plugins/akismet and is not activated.
  3. Visit Settings > Connectors.
  4. Confirm Akismet connector is shown.
  5. Move Akismet to wp-content/mu-plugins/akismet.
  6. Create wp-content/mu-plugins/a.php with:<?php require_once __DIR__ . '/akismet/akismet.php';
  7. Reload Settings > Connectors.
  8. Confirm Akismet connector is still shown.

Screenshots or screencast

Before After
Before Screenshot After Screenshot

Use of AI Tools

@Adi-ty Adi-ty marked this pull request as ready for review April 2, 2026 06:50
@Adi-ty Adi-ty requested a review from spacedmonkey as a code owner April 2, 2026 06:50
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 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: Adi-ty <iamadisingh@git.wordpress.org>
Co-authored-by: peterwilsoncc <peterwilsoncc@git.wordpress.org>
Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>

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

@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended Connectors screen Tracks connectors screen related tasks labels Apr 2, 2026
Copy link
Copy Markdown
Contributor

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The location of a plugin relative to mu-plugins is a little less predictable than it is in the plugins directory.

It may be in the location mu-plugins/slug/file.php but depending on how the developer has configured their site, it might just as easily be in mu-plugins/file.php, mu-plugins/vendor/slug/file.php or some variation of all of these.

The most robust approach to determine if a plugin is active is to check if a function or class exists.

This would require allowing the plugin developer registering the connector to provide a callback. Using Hello Dolly as an example the callback would be:

is_active => function() { return function_exists( 'hello_dolly_get_lyric' ); }

If the callback returns true the plugin can be considered active, regardless of any other checks.

@Adi-ty
Copy link
Copy Markdown
Contributor Author

Adi-ty commented Apr 3, 2026

The location of a plugin relative to mu-plugins is a little less predictable than it is in the plugins directory.

It may be in the location mu-plugins/slug/file.php but depending on how the developer has configured their site, it might just as easily be in mu-plugins/file.php, mu-plugins/vendor/slug/file.php or some variation of all of these.

The most robust approach to determine if a plugin is active is to check if a function or class exists.

This would require allowing the plugin developer registering the connector to provide a callback. Using Hello Dolly as an example the callback would be:

is_active => function() { return function_exists( 'hello_dolly_get_lyric' ); }

If the callback returns true the plugin can be considered active, regardless of any other checks.

Thanks for the thoughtful feedback, this makes sense.

Planning to go with an optional is_active callback on connector registration if provided, it becomes the source of truth; if absent, the existing fallback (path checks + is_plugin_active()). For Akismet I'd use a class existence check like

'is_active' => function () {
	return defined( 'AKISMET_VERSION' ) && class_exists( 'Akismet', false );
},

Does that align with what you had in mind, or do you see edge cases I should account for?

@Adi-ty Adi-ty requested a review from peterwilsoncc April 3, 2026 11:29

if ( ! empty( $connector_data['plugin']['is_active'] ) && is_callable( $connector_data['plugin']['is_active'] ) ) {
$is_activated = (bool) call_user_func( $connector_data['plugin']['is_active'] );
$is_installed = $is_activated;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we may have a connector passing an is_active callback, is_active returning false, but the plugin be installed. When call_user_func( $connector_data['plugin']['is_active'] ); returns false we should probably check if the plugin is_installed file_exists( WP_PLUGIN_DIR . '/' . $file ).

'plugin' => array(
'file' => 'akismet/akismet.php',
'file' => 'akismet/akismet.php',
'is_active' => function () {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we may be able to avoid this Akismet specific logic in core by having Akismet registering a connector which overwrites the core one with the is_active callback.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When is_active is not provided we know the plugin was not active and could rely on the normal core file exist checks.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'plugin' => array(
'file' => 'akismet/akismet.php',
'file' => 'akismet/akismet.php',
'is_active' => function () {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For all AI providers (included in core or not), we don't expect them to need to register providers, and we have standardized ways to check if they are active e.g: via plugin, so we should probably have a default customized is_active solution for these. But I can take of that, just leaving a comment to not miss it.

Copy link
Copy Markdown
Member

@jorgefilipecosta jorgefilipecosta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this @Adi-ty just left some comments but the direction seems good 👍

Updated _gutenberg_get_connector_script_module_data to prioritize the is_active callback
Removed the manual Akismet registration from _gutenberg_connectors_init
@Adi-ty
Copy link
Copy Markdown
Contributor Author

Adi-ty commented Apr 3, 2026

Thank you for working on this @Adi-ty just left some comments but the direction seems good 👍

Thanks for the feedback @jorgefilipecosta

I've removed the hardcoded Akismet-specific logic from core and prioritised the is_active callback before falling back to is_plugin_active() and file_exists() for standard plugins. I'm also happy to handle the backport for these changes to WordPress Core once we’ve finalized the logic here.

@Adi-ty Adi-ty requested a review from jorgefilipecosta April 3, 2026 17:37
Copy link
Copy Markdown
Member

@jorgefilipecosta jorgefilipecosta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic looks good to me 👍 cc: @gziolo

@jorgefilipecosta jorgefilipecosta merged commit 8b5220d into WordPress:trunk Apr 6, 2026
40 of 41 checks passed
@github-project-automation github-project-automation bot moved this from 🔎 Needs Review to ✅ Done in WordPress 7.0 Editor Tasks Apr 6, 2026
@github-actions github-actions bot added this to the Gutenberg 23.0 milestone Apr 6, 2026
@jorgefilipecosta jorgefilipecosta added Backported to WP Core Pull request that has been successfully merged into WP Core Backport to WP 7.0 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta and removed Backported to WP Core Pull request that has been successfully merged into WP Core labels Apr 6, 2026
@github-actions github-actions bot removed the Backport to WP 7.0 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Apr 6, 2026
@github-actions github-actions bot added the Backported to WP Core Pull request that has been successfully merged into WP Core label Apr 6, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 6, 2026

I just cherry-picked this PR to the wp/7.0 branch to get it included in the next release: e2970ba

jorgefilipecosta added a commit to jorgefilipecosta/wordpress-develop that referenced this pull request Apr 6, 2026
Gutenberg changelog:

- Style Book: Fix missing styles for classic themes in stylebook route (WordPress/gutenberg#76843)
- RTC: Fix stuck "Join" link in post list when lock expires (WordPress/gutenberg#76795)
- Icon: Fix center alignment in the editor for classic themes (WordPress/gutenberg#76878)
- RTC: Fix notes not syncing between collaborative editors (WordPress/gutenberg#76873)
- Latest Comments: Fix v1 deprecated block missing supports (WordPress/gutenberg#76877)
- Connectors: Add Akismet as a default connector (WordPress/gutenberg#76828)
- Restore with compaction update (WordPress/gutenberg#76872)
- Improve JSDoc for abilities API (WordPress/gutenberg#76824)
- Connectors: Replace plugin.slug with plugin.file (WordPress/gutenberg#76909)
- Block visibility badge: use canvas iframe for viewport detection (WordPress/gutenberg#76889)
- Connectors: Update help text from 'reset' to 'manage' (WordPress/gutenberg#76963)
- Connectors: Hide Akismet unless already installed (WordPress/gutenberg#76962)
- Wrap sync update processing in try/catch (WordPress/gutenberg#76968)
- Backport: Improve validation and permission checks for `WP_HTTP_Polling_Sync_Server` (WordPress/gutenberg#76987)
- Connectors: account for mu-plugins when resolving plugin.file status (WordPress/gutenberg#76994)
pento pushed a commit to WordPress/wordpress-develop that referenced this pull request Apr 6, 2026
This updates the pinned hash from the `gutenberg` from `0d133bf7e7437d65d68a06551f3d613a7d8e4361` to `e2970ba736edb99e08fb369d4fb0c378189468ee`.
The following changes are included:

- WordPress/gutenberg#76478 Boot: Fix black area below content when sidebar is taller than page c… (WordPress/gutenberg#76764)
- Style Book: Fix missing styles for classic themes in stylebook route (WordPress/gutenberg#76843)
- RTC: Fix stuck "Join" link in post list when lock expires (WordPress/gutenberg#76795)
- Icon: Fix center alignment in the editor for classic themes (WordPress/gutenberg#76878)
- RTC: Fix notes not syncing between collaborative editors (WordPress/gutenberg#76873)
- Latest Comments: Fix v1 deprecated block missing supports (WordPress/gutenberg#76877)
- Connectors: Add Akismet as a default connector (WordPress/gutenberg#76828)
- Restore with compaction update (WordPress/gutenberg#76872)
- Improve JSDoc for abilities API (WordPress/gutenberg#76824)
- Connectors: Replace plugin.slug with plugin.file (WordPress/gutenberg#76909)
- Block visibility badge: use canvas iframe for viewport detection (WordPress/gutenberg#76889)
- Connectors: Update help text from 'reset' to 'manage' (WordPress/gutenberg#76963)
- Connectors: Hide Akismet unless already installed (WordPress/gutenberg#76962)
- Wrap sync update processing in try/catch (WordPress/gutenberg#76968)
- Backport: Improve validation and permission checks for `WP_HTTP_Polling_Sync_Server` (WordPress/gutenberg#76987)
- Connectors: account for mu-plugins when resolving plugin.file status (WordPress/gutenberg#76994)


A full list of changes can be found on GitHub: https://github.com/WordPress/gutenberg/compare/0d133bf7e7437d65d68a06551f3d613a7d8e4361…e2970ba736edb99e08fb369d4fb0c378189468ee.

Log created with:

git log --reverse --format="- %s" 0d133bf7e7437d65d68a06551f3d613a7d8e4361..e2970ba736edb99e08fb369d4fb0c378189468ee | sed 's|#\([0-9][0-9]*\)|https://github.com/WordPress/gutenberg/pull/\1|g; /github\.com\/WordPress\/gutenberg\/pull/!d' | pbcopy

See #64595.

git-svn-id: https://develop.svn.wordpress.org/trunk@62209 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Apr 6, 2026
This updates the pinned hash from the `gutenberg` from `0d133bf7e7437d65d68a06551f3d613a7d8e4361` to `e2970ba736edb99e08fb369d4fb0c378189468ee`.
The following changes are included:

- WordPress/gutenberg#76478 Boot: Fix black area below content when sidebar is taller than page c… (WordPress/gutenberg#76764)
- Style Book: Fix missing styles for classic themes in stylebook route (WordPress/gutenberg#76843)
- RTC: Fix stuck "Join" link in post list when lock expires (WordPress/gutenberg#76795)
- Icon: Fix center alignment in the editor for classic themes (WordPress/gutenberg#76878)
- RTC: Fix notes not syncing between collaborative editors (WordPress/gutenberg#76873)
- Latest Comments: Fix v1 deprecated block missing supports (WordPress/gutenberg#76877)
- Connectors: Add Akismet as a default connector (WordPress/gutenberg#76828)
- Restore with compaction update (WordPress/gutenberg#76872)
- Improve JSDoc for abilities API (WordPress/gutenberg#76824)
- Connectors: Replace plugin.slug with plugin.file (WordPress/gutenberg#76909)
- Block visibility badge: use canvas iframe for viewport detection (WordPress/gutenberg#76889)
- Connectors: Update help text from 'reset' to 'manage' (WordPress/gutenberg#76963)
- Connectors: Hide Akismet unless already installed (WordPress/gutenberg#76962)
- Wrap sync update processing in try/catch (WordPress/gutenberg#76968)
- Backport: Improve validation and permission checks for `WP_HTTP_Polling_Sync_Server` (WordPress/gutenberg#76987)
- Connectors: account for mu-plugins when resolving plugin.file status (WordPress/gutenberg#76994)


A full list of changes can be found on GitHub: https://github.com/WordPress/gutenberg/compare/0d133bf7e7437d65d68a06551f3d613a7d8e4361…e2970ba736edb99e08fb369d4fb0c378189468ee.

Log created with:

git log --reverse --format="- %s" 0d133bf7e7437d65d68a06551f3d613a7d8e4361..e2970ba736edb99e08fb369d4fb0c378189468ee | sed 's|#\([0-9][0-9]*\)|https://github.com/WordPress/gutenberg/pull/\1|g; /github\.com\/WordPress\/gutenberg\/pull/!d' | pbcopy

See #64595.
Built from https://develop.svn.wordpress.org/trunk@62209


git-svn-id: http://core.svn.wordpress.org/trunk@61489 1a063a9b-81f0-0310-95a4-ce76da25c4cd
pento pushed a commit to WordPress/wordpress-develop that referenced this pull request Apr 6, 2026
This updates the pinned hash from the `gutenberg` from `0d133bf7e7437d65d68a06551f3d613a7d8e4361` to `e2970ba736edb99e08fb369d4fb0c378189468ee`.
The following changes are included:

- WordPress/gutenberg#76478 Boot: Fix black area below content when sidebar is taller than page c… (WordPress/gutenberg#76764)
- Style Book: Fix missing styles for classic themes in stylebook route (WordPress/gutenberg#76843)
- RTC: Fix stuck "Join" link in post list when lock expires (WordPress/gutenberg#76795)
- Icon: Fix center alignment in the editor for classic themes (WordPress/gutenberg#76878)
- RTC: Fix notes not syncing between collaborative editors (WordPress/gutenberg#76873)
- Latest Comments: Fix v1 deprecated block missing supports (WordPress/gutenberg#76877)
- Connectors: Add Akismet as a default connector (WordPress/gutenberg#76828)
- Restore with compaction update (WordPress/gutenberg#76872)
- Improve JSDoc for abilities API (WordPress/gutenberg#76824)
- Connectors: Replace plugin.slug with plugin.file (WordPress/gutenberg#76909)
- Block visibility badge: use canvas iframe for viewport detection (WordPress/gutenberg#76889)
- Connectors: Update help text from 'reset' to 'manage' (WordPress/gutenberg#76963)
- Connectors: Hide Akismet unless already installed (WordPress/gutenberg#76962)
- Wrap sync update processing in try/catch (WordPress/gutenberg#76968)
- Backport: Improve validation and permission checks for `WP_HTTP_Polling_Sync_Server` (WordPress/gutenberg#76987)
- Connectors: account for mu-plugins when resolving plugin.file status (WordPress/gutenberg#76994)


A full list of changes can be found on GitHub: https://github.com/WordPress/gutenberg/compare/0d133bf7e7437d65d68a06551f3d613a7d8e4361…e2970ba736edb99e08fb369d4fb0c378189468ee.

Log created with:

git log --reverse --format="- %s" 0d133bf7e7437d65d68a06551f3d613a7d8e4361..e2970ba736edb99e08fb369d4fb0c378189468ee | sed 's|#\([0-9][0-9]*\)|https://github.com/WordPress/gutenberg/pull/\1|g; /github\.com\/WordPress\/gutenberg\/pull/!d' | pbcopy

See #64595.

git-svn-id: https://develop.svn.wordpress.org/branches/7.0@62212 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Apr 6, 2026
This updates the pinned hash from the `gutenberg` from `0d133bf7e7437d65d68a06551f3d613a7d8e4361` to `e2970ba736edb99e08fb369d4fb0c378189468ee`.
The following changes are included:

- WordPress/gutenberg#76478 Boot: Fix black area below content when sidebar is taller than page c… (WordPress/gutenberg#76764)
- Style Book: Fix missing styles for classic themes in stylebook route (WordPress/gutenberg#76843)
- RTC: Fix stuck "Join" link in post list when lock expires (WordPress/gutenberg#76795)
- Icon: Fix center alignment in the editor for classic themes (WordPress/gutenberg#76878)
- RTC: Fix notes not syncing between collaborative editors (WordPress/gutenberg#76873)
- Latest Comments: Fix v1 deprecated block missing supports (WordPress/gutenberg#76877)
- Connectors: Add Akismet as a default connector (WordPress/gutenberg#76828)
- Restore with compaction update (WordPress/gutenberg#76872)
- Improve JSDoc for abilities API (WordPress/gutenberg#76824)
- Connectors: Replace plugin.slug with plugin.file (WordPress/gutenberg#76909)
- Block visibility badge: use canvas iframe for viewport detection (WordPress/gutenberg#76889)
- Connectors: Update help text from 'reset' to 'manage' (WordPress/gutenberg#76963)
- Connectors: Hide Akismet unless already installed (WordPress/gutenberg#76962)
- Wrap sync update processing in try/catch (WordPress/gutenberg#76968)
- Backport: Improve validation and permission checks for `WP_HTTP_Polling_Sync_Server` (WordPress/gutenberg#76987)
- Connectors: account for mu-plugins when resolving plugin.file status (WordPress/gutenberg#76994)


A full list of changes can be found on GitHub: https://github.com/WordPress/gutenberg/compare/0d133bf7e7437d65d68a06551f3d613a7d8e4361…e2970ba736edb99e08fb369d4fb0c378189468ee.

Log created with:

git log --reverse --format="- %s" 0d133bf7e7437d65d68a06551f3d613a7d8e4361..e2970ba736edb99e08fb369d4fb0c378189468ee | sed 's|#\([0-9][0-9]*\)|https://github.com/WordPress/gutenberg/pull/\1|g; /github\.com\/WordPress\/gutenberg\/pull/!d' | pbcopy

See #64595.
Built from https://develop.svn.wordpress.org/branches/7.0@62212


git-svn-id: http://core.svn.wordpress.org/branches/7.0@61492 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Adi-ty added a commit to Adi-ty/wordpress-develop that referenced this pull request Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backported to WP Core Pull request that has been successfully merged into WP Core Connectors screen Tracks connectors screen related tasks [Type] Bug An existing feature does not function as intended

Projects

Development

Successfully merging this pull request may close these issues.

Connectors: plugin.file does not account for mu-plugins.

4 participants