Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 32 additions & 3 deletions src/wp-admin/includes/class-wp-plugins-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -1619,7 +1619,36 @@ protected function add_dependents_to_dependency_plugin_row( $dependency ) {
return;
}

$dependency_note = __( 'Note: This plugin cannot be deactivated or deleted until the plugins that require it are deactivated or deleted.' );
$dependency_note = '';

if ( $this->screen->in_admin( 'network' ) ) {
$is_network_active = is_plugin_active_for_network( $dependency );

if ( $is_network_active && current_user_can( 'manage_network_plugins' ) && WP_Plugin_Dependencies::has_active_dependents( $dependency ) ) {
$dependency_note = __( 'Note: This plugin cannot be deactivated until the plugins that require it are deactivated.' );
} elseif ( ! $is_network_active && ! is_plugin_active( $dependency ) && current_user_can( 'delete_plugins' ) ) {
$dependency_note = __( 'Note: This plugin cannot be deleted until the plugins that require it are deleted.' );
}
} else {
$is_active = is_plugin_active( $dependency );

if ( $is_active && current_user_can( 'deactivate_plugin', $dependency ) && WP_Plugin_Dependencies::has_active_dependents( $dependency ) ) {
$dependency_note = __( 'Note: This plugin cannot be deactivated until the plugins that require it are deactivated.' );
} elseif ( ! $is_active && ! is_multisite() && current_user_can( 'delete_plugins' ) ) {
$dependency_note = __( 'Note: This plugin cannot be deleted until the plugins that require it are deleted.' );
}
}

$dependency_notice = '';
if ( '' !== $dependency_note ) {
$dependency_notice = wp_get_admin_notice(
$dependency_note,
array(
'type' => 'error',
'additional_classes' => array( 'inline' ),
)
);
}

$comma = wp_get_list_item_separator();
$required_by = sprintf(
Expand All @@ -1629,9 +1658,9 @@ protected function add_dependents_to_dependency_plugin_row( $dependency ) {
);

printf(
'<div class="required-by"><p>%1$s</p><p>%2$s</p></div>',
'<div class="required-by"><p>%1$s</p>%2$s</div>',
$required_by,
$dependency_note
$dependency_notice
);
}

Expand Down
Loading