diff --git a/src/wp-admin/css/list-tables.css b/src/wp-admin/css/list-tables.css
index f6105ad5a59fb..004624e03db64 100644
--- a/src/wp-admin/css/list-tables.css
+++ b/src/wp-admin/css/list-tables.css
@@ -1602,43 +1602,6 @@ div.action-links,
.plugin-card .notice.plugin-dependencies {
margin: auto 20px 20px;
- padding: 15px;
-}
-
-.plugin-card .plugin-dependencies-explainer-text {
- margin-block: 0;
-}
-
-.plugin-card .plugin-dependency {
- align-items: center;
- display: flex;
- flex-wrap: wrap;
- margin-top: 0.5em;
- column-gap: 1%;
- row-gap: 0.5em;
-}
-
-.plugin-card .plugin-dependency:nth-child(2),
-.plugin-card .plugin-dependency:last-child {
- margin-top: 1em;
-}
-
-.plugin-card .plugin-dependency-name {
- flex-basis: 74%;
-}
-
-.plugin-card .plugin-dependency .more-details-link {
- margin-left: auto;
-}
-
-.rtl .plugin-card .plugin-dependency .more-details-link {
- margin-right: auto;
-}
-
-@media (max-width: 939px) {
- .plugin-card .plugin-dependency-name {
- flex-basis: 69%;
- }
}
.plugins #the-list .required-by,
diff --git a/src/wp-admin/includes/class-wp-plugin-install-list-table.php b/src/wp-admin/includes/class-wp-plugin-install-list-table.php
index 3f6d2a104d099..91e97f2ecfe66 100644
--- a/src/wp-admin/includes/class-wp-plugin-install-list-table.php
+++ b/src/wp-admin/includes/class-wp-plugin-install-list-table.php
@@ -843,10 +843,9 @@ protected function get_dependencies_notice( $plugin_data ) {
return '';
}
- $no_name_markup = '
%s
';
- $has_name_markup = '%s %s
';
+ $dependency_markup = '%s';
- $dependencies_list = '';
+ $dependencies = array();
foreach ( $plugin_data['requires_plugins'] as $dependency ) {
$dependency_data = WP_Plugin_Dependencies::get_dependency_data( $dependency );
@@ -856,26 +855,33 @@ protected function get_dependencies_notice( $plugin_data ) {
! empty( $dependency_data['slug'] ) &&
! empty( $dependency_data['version'] )
) {
- $more_details_link = $this->get_more_details_link( $dependency_data['name'], $dependency_data['slug'] );
- $dependencies_list .= sprintf( $has_name_markup, esc_html( $dependency_data['name'] ), $more_details_link );
+ $dependencies[] = sprintf(
+ $dependency_markup,
+ $this->get_more_details_link( $dependency_data['name'], $dependency_data['slug'], $dependency_data['name'] )
+ );
continue;
}
$result = plugins_api( 'plugin_information', array( 'slug' => $dependency ) );
if ( ! empty( $result->name ) ) {
- $more_details_link = $this->get_more_details_link( $result->name, $result->slug );
- $dependencies_list .= sprintf( $has_name_markup, esc_html( $result->name ), $more_details_link );
+ $dependencies[] = sprintf(
+ $dependency_markup,
+ $this->get_more_details_link( $result->name, $result->slug, $result->name )
+ );
continue;
}
- $dependencies_list .= sprintf( $no_name_markup, esc_html( $dependency ) );
+ $dependencies[] = sprintf( $dependency_markup, esc_html( $dependency ) );
}
$dependencies_notice = sprintf(
- '',
- '' . __( 'Additional plugins are required' ) . '',
- $dependencies_list
+ '',
+ sprintf(
+ /* translators: %s: Comma-separated list of plugin names. */
+ _n( 'Requires: %s', 'Requires: %s', count( $dependencies ) ),
+ implode( wp_get_list_item_separator(), $dependencies )
+ )
);
return $dependencies_notice;
@@ -885,12 +891,18 @@ protected function get_dependencies_notice( $plugin_data ) {
* Creates a 'More details' link for the plugin.
*
* @since 6.5.0
+ * @since 7.2.0 Added the `$link_text` parameter.
*
- * @param string $name The plugin's name.
- * @param string $slug The plugin's slug.
+ * @param string $name The plugin's name.
+ * @param string $slug The plugin's slug.
+ * @param string $link_text Optional. The text of the link. Default 'More Details'.
* @return string The 'More details' link for the plugin.
*/
- protected function get_more_details_link( $name, $slug ) {
+ protected function get_more_details_link( $name, $slug, $link_text = '' ) {
+ if ( '' === $link_text ) {
+ $link_text = __( 'More Details' );
+ }
+
$url = add_query_arg(
array(
'tab' => 'plugin-information',
@@ -908,7 +920,7 @@ protected function get_more_details_link( $name, $slug ) {
/* translators: %s: Plugin name. */
sprintf( __( 'More information about %s' ), esc_html( $name ) ),
esc_attr( $name ),
- __( 'More Details' )
+ esc_html( $link_text )
);
return $more_details_link;
diff --git a/tests/phpunit/tests/admin/wpPluginInstallListTableGetDependenciesNotice.php b/tests/phpunit/tests/admin/wpPluginInstallListTableGetDependenciesNotice.php
index 776e6f6e6cc25..b3dc3381a4128 100644
--- a/tests/phpunit/tests/admin/wpPluginInstallListTableGetDependenciesNotice.php
+++ b/tests/phpunit/tests/admin/wpPluginInstallListTableGetDependenciesNotice.php
@@ -16,7 +16,21 @@ class Tests_Admin_wpPluginInstallListTableGetDependenciesNotice extends WP_UnitT
*
* @var string
*/
- const NOTICE_START = 'Additional plugins are required
';
+ const NOTICE_START = '
Requires: ';
+
+ /**
+ * The notice after the list of dependencies.
+ *
+ * @var string
+ */
+ const NOTICE_END = '
';
+
+ /**
+ * The separator between two dependencies.
+ *
+ * @var string
+ */
+ const SEPARATOR = ', ';
/**
* The list table.
@@ -129,7 +143,7 @@ public function test_should_name_dependency_from_dependency_data() {
);
$this->assertSame(
- self::NOTICE_START . $this->get_named_dependency( 'Dep <b>&</b> "One"', 'dep-one' ) . '
',
+ self::NOTICE_START . $this->get_named_dependency( 'Dep <b>&</b> "One"', 'dep-one' ) . self::NOTICE_END,
$this->get_dependencies_notice( array( 'requires_plugins' => array( 'dep-one' ) ) ),
'The dependency should be named from the stored data.'
);
@@ -153,7 +167,7 @@ public function test_should_use_slug_from_dependency_data() {
);
$this->assertSame(
- self::NOTICE_START . $this->get_named_dependency( 'Dep One', 'dep-one-renamed' ) . '',
+ self::NOTICE_START . $this->get_named_dependency( 'Dep One', 'dep-one-renamed' ) . self::NOTICE_END,
$this->get_dependencies_notice( array( 'requires_plugins' => array( 'dep-one' ) ) )
);
}
@@ -178,7 +192,7 @@ public function test_should_fall_back_to_plugins_api_for_incomplete_dependency_d
);
$this->assertSame(
- self::NOTICE_START . $this->get_named_dependency( 'Dep One From API', 'dep-one' ) . '',
+ self::NOTICE_START . $this->get_named_dependency( 'Dep One From API', 'dep-one' ) . self::NOTICE_END,
$this->get_dependencies_notice( array( 'requires_plugins' => array( 'dep-one' ) ) ),
'The dependency should be named from the plugins API.'
);
@@ -218,7 +232,7 @@ public function test_should_use_slug_from_plugins_api() {
);
$this->assertSame(
- self::NOTICE_START . $this->get_named_dependency( 'Dep <i>One</i>', 'renamed-dep' ) . '',
+ self::NOTICE_START . $this->get_named_dependency( 'Dep <i>One</i>', 'renamed-dep' ) . self::NOTICE_END,
$this->get_dependencies_notice( array( 'requires_plugins' => array( 'dep-one' ) ) )
);
}
@@ -241,7 +255,7 @@ public function test_should_list_dependency_by_slug_without_name( $response ) {
);
$this->assertSame(
- self::NOTICE_START . 'dep<one>
',
+ self::NOTICE_START . $this->get_unnamed_dependency( 'dep<one>' ) . self::NOTICE_END,
$this->get_dependencies_notice( array( 'requires_plugins' => array( 'dep' ) ) )
);
}
@@ -283,9 +297,11 @@ public function test_should_list_all_dependencies_in_order() {
$this->assertSame(
self::NOTICE_START
. $this->get_named_dependency( 'Dep One', 'dep-one' )
+ . self::SEPARATOR
. $this->get_named_dependency( 'Dep Two', 'dep-two' )
- . 'dep-three
'
- . '',
+ . self::SEPARATOR
+ . $this->get_unnamed_dependency( 'dep-three' )
+ . self::NOTICE_END,
$this->get_dependencies_notice( array( 'requires_plugins' => array( 'dep-one', 'dep-two', 'dep-three' ) ) ),
'Each dependency should be listed in order.'
);
@@ -303,9 +319,19 @@ private function get_named_dependency( $escaped_name, $slug ) {
$url = 'http://' . WP_TESTS_DOMAIN . '/wp-admin/' . ( is_multisite() ? 'network/' : '' )
. 'plugin-install.php?tab=plugin-information&plugin=' . $slug . '&TB_iframe=true&width=600&height=550';
- return '';
+ return ''
+ . '' . $escaped_name . ''
+ . '';
+ }
+
+ /**
+ * Returns the expected markup of a dependency without a name.
+ *
+ * @param string $escaped_slug The escaped plugin slug.
+ * @return string The markup.
+ */
+ private function get_unnamed_dependency( $escaped_slug ) {
+ return '' . $escaped_slug . '';
}
/**