mirror of
https://github.com/WordPress/WordPress.git
synced 2024-10-31 15:59:44 +01:00
Plugins: Improve plugin dependency admin notices.
This makes several refinements to the various notices displayed in the WordPress admin related to plugin dependencies. Additionally, it adds some conditions to display more appropriate messages for multisite installs with proper context to the user’s capabilities. Props costdev, joedolson, afragen, swissspidy, peterwilsoncc, euthelup. Fixes #60465. Built from https://develop.svn.wordpress.org/trunk@57769 git-svn-id: http://core.svn.wordpress.org/trunk@57270 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
9e0a116dbf
commit
20e57dca02
@ -1567,8 +1567,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
||||
$links[] = $this->get_dependency_view_details_link( $name, $slug );
|
||||
}
|
||||
|
||||
$dependency_note = __( 'Note: This plugin cannot be activated until the plugins that are required by it are activated.' );
|
||||
|
||||
$is_active = is_multisite() ? is_plugin_active_for_network( $dependent ) : is_plugin_active( $dependent );
|
||||
$comma = wp_get_list_item_separator();
|
||||
$requires = sprintf(
|
||||
/* translators: %s: List of dependency names. */
|
||||
@ -1576,10 +1575,27 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
||||
implode( $comma, $links )
|
||||
);
|
||||
|
||||
$notice = '';
|
||||
$error_message = '';
|
||||
if ( WP_Plugin_Dependencies::has_unmet_dependencies( $dependent ) ) {
|
||||
if ( $is_active ) {
|
||||
$error_message = __( 'This plugin is active but may not function correctly because required plugins are missing or inactive.' );
|
||||
} else {
|
||||
$error_message = __( 'This plugin cannot be activated because required plugins are missing or inactive.' );
|
||||
}
|
||||
$notice = wp_get_admin_notice(
|
||||
$error_message,
|
||||
array(
|
||||
'type' => 'error',
|
||||
'additional_classes' => array( 'inline', 'notice-alt' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
printf(
|
||||
'<div class="requires"><p>%1$s</p><p>%2$s</p></div>',
|
||||
$requires,
|
||||
$dependency_note
|
||||
$notice
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -369,10 +369,30 @@ class WP_Plugin_Dependencies {
|
||||
*/
|
||||
public static function display_admin_notice_for_unmet_dependencies() {
|
||||
if ( in_array( false, self::get_dependency_filepaths(), true ) ) {
|
||||
$error_message = __( 'Some required plugins are missing or inactive.' );
|
||||
|
||||
if ( is_multisite() ) {
|
||||
if ( current_user_can( 'manage_network_plugins' ) ) {
|
||||
$error_message .= ' ' . sprintf(
|
||||
/* translators: %s: Link to the network plugins page. */
|
||||
__( '<a href="%s">Manage plugins</a>.' ),
|
||||
esc_url( network_admin_url( 'plugins.php' ) )
|
||||
);
|
||||
} else {
|
||||
$error_message .= ' ' . __( 'Please contact your network administrator.' );
|
||||
}
|
||||
} elseif ( 'plugins' !== get_current_screen()->base ) {
|
||||
$error_message .= ' ' . sprintf(
|
||||
/* translators: %s: Link to the plugins page. */
|
||||
__( '<a href="%s">Manage plugins</a>.' ),
|
||||
esc_url( admin_url( 'plugins.php' ) )
|
||||
);
|
||||
}
|
||||
|
||||
wp_admin_notice(
|
||||
__( 'There are additional plugin dependencies that must be installed.' ),
|
||||
$error_message,
|
||||
array(
|
||||
'type' => 'info',
|
||||
'type' => 'warning',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.5-beta3-57768';
|
||||
$wp_version = '6.5-beta3-57769';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user