Make WordPress Core

Opened 9 months ago

Last modified 8 days ago

#64493 accepted defect (bug)

Plugin dependencies: better messaging or management of plugin active states

Reported by: joedolson Owned by: joedolson
Priority: normal Milestone: 7.2
Component: Plugins Version: 6.5
Severity: normal Keywords: has-patch
Cc: Focuses: administration, ui-copy

Description

Currently, if a plugin cannot be deleted due to plugin dependencies, it has a single message that shows "Note: This plugin cannot be deactivated or deleted until the plugins that require it are deactivated or deleted."

The message is inaccurate in two ways - you cannot delete a plugin unless the plugins that require it are deleted; deactivating is not sufficient; and it does not reflect the current state of the plugin. If the plugin with dependents is already deactivated, it still states that it cannot be deactivated.

Much of the structure of plugin dependencies seems to ignore whether a referenced plugin is active or not.

The checks are dependent on get_dependent_names(), which does not contain any reference to whether or not a plugin is active.

At minimum, the messages should be improved so that they accurately reflect what needs to happen; alternately, the messages and states should be matched so that the possible scenarios are reflected more accurately.

Attachments (2)

2026-01-13-13-23-42@2x.png​ (142.3 KB ) - added by johnbillion 9 months ago.
Screenshot of a misleading dependency message
64493-fix-plugin-dependency-note.patch​ (918 bytes ) - added by solankisoftware 9 months ago.

Download all attachments as: .zip

Change History (13)

#1 @joedolson
9 months ago

  • Component General → Plugins

#2 @joedolson
9 months ago

Related, but not the same: #64475

@johnbillion
9 months ago

Screenshot of a misleading dependency message

#3 @solankisoftware
9 months ago

  • Keywords has-patch added

The dependency note shown in the Plugins list table currently states that both
deactivation and deletion are blocked, which is misleading.

This patch updates add_dependents_to_dependency_plugin_row() to distinguish
between:

  • blocking deactivation when dependent plugins are active, and
  • blocking deletion when dependents exist but are inactive.

The change reuses WP_Plugin_Dependencies::has_active_dependents() and is
messaging-only.
Patch attached.

#4 @joedolson
5 months ago

  • Owner set to joedolson
  • Status assigned → accepted

#5 @joedolson
5 months ago

  • Milestone Awaiting Review → 7.1

#6 @bridgetwillard
5 months ago

"This plugin enhances the functionality of [main plugin]. It may not be de-activated until the parent plugin is also de-activated."

#7 @joedolson
3 months ago

  • Milestone 7.1 → 7.2

This doesn't have a patch started yet, and since we're nearing the end of beta, I think it's best to bump this to 7.2.

This ticket was mentioned in ​PR #12732 on ​WordPress/wordpress-develop by ​@hbhalodia.


3 months ago
#8

Trac ticket: https://core.trac.wordpress.org/ticket/64493

## Use of AI Tools

  • Claude Code, Opus 5
  • Used on inital implementation and drafting the message and PR description. Final implementation reviwed by me and tested in local env.

---

## AI Summary

The "Required by" note on the Plugins screen uses a single static message that doesn't match reality. This change generates it from the plugin's current state so it reflects the action that's actually available.

## Problem

For any plugin with dependents, the note always reads:

Note: This plugin cannot be deactivated or deleted until the plugins that require it are deactivated or deleted.

This is wrong in two ways:

  1. Deletion — a dependent must be *deleted*; deactivating it is not sufficient. So "deactivated or deleted" is inaccurate.
  2. State — the message never changes. It claims a plugin "cannot be deactivated" even when it has no active dependents (deactivation is actually allowed), or when the plugin is already inactive. It also mentions deletion for active plugins, which can't be deleted anyway (Delete is only offered for inactive plugins).

## Fix

The note in WP_Plugins_List_Table::add_dependents_to_dependency_plugin_row() now branches on the plugin's active state, using the same signals that gate the action links (is_plugin_active() / has_active_dependents()):

  • Active plugin, with an active dependent → Note: This plugin cannot be deactivated until the plugins that require it are deactivated.
  • Active plugin, no active dependents → no note (deactivation is allowed).
  • Inactive plugin → Note: This plugin cannot be deleted until the plugins that require it are deleted.

The message is also now rendered as an inline admin notice via wp_get_admin_notice() (type => 'error', additional_classes => array( 'inline' )) instead of a plain paragraph, so it's styled consistently with other admin notices.

When there is no applicable restriction, no notice is output.

## Example

Plugin "Example Dependency" is required by "Example Dependent One":

Scenario Old note New note
Both active cannot be deactivated or deleted until … deactivated or deleted cannot be deactivated until … deactivated
Dependency active, dependent inactive _(same wrong message)_ _(no note — deactivation is allowed)_
Dependency inactive _(same wrong message)_ cannot be deleted until … deleted

#9 @hbhalodia
3 months ago

Hi Team, Have raised the PR with the fix, which now correctly shows the message and differentiate it correctly.

Thanks,

This ticket was mentioned in ​Slack in #core by im3dabasia1. ​View the logs.


8 days ago

#11 @im3dabasia1
8 days ago

As per today's 7.2 bug scrub:

I see a ​PR has been raised for this and is waiting for review. @joedolson @hbhalodia, do we have a realistic shot at landing this in 7.2?

Note: See TracTickets for help on using tickets.