From 2a8a9110d7eaf096d8f33ac9a372185143321e78 Mon Sep 17 00:00:00 2001 From: hellofromTonya Date: Thu, 20 Jun 2024 15:30:11 +0000 Subject: [PATCH] Plugins: Ensure wp_get_plugin_action_button() returns a string. [57545] introduced `wp_get_plugin_action_button()`. This function is documented to return a `string`. However, if the user does not have the appropriate capabilities, it returned `void`, which is unexpected. Resolves the issue by moving the `return $button` to the bottom of the function to ensure it always returns a `string` type. On success, the button's HTML string is returned; else, an empty string is returned. Unit tests are included. Follow-up to [57545]. Reviewed by jorbin. Merges [58396] to the 6.5 branch. Props costdev, rajinsharwar, hellofromTonya. Fixes #61400. Built from https://develop.svn.wordpress.org/branches/6.5@58445 git-svn-id: http://core.svn.wordpress.org/branches/6.5@57894 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/plugin-install.php | 6 +++--- wp-includes/version.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/wp-admin/includes/plugin-install.php b/wp-admin/includes/plugin-install.php index be795ed600..704d81b9a6 100644 --- a/wp-admin/includes/plugin-install.php +++ b/wp-admin/includes/plugin-install.php @@ -917,7 +917,7 @@ function install_plugin_information() { * } * @param bool $compatible_php The result of a PHP compatibility check. * @param bool $compatible_wp The result of a WP compatibility check. - * @return string $button The markup for the dependency row button. + * @return string The markup for the dependency row button. An empty string if the user does not have capabilities. */ function wp_get_plugin_action_button( $name, $data, $compatible_php, $compatible_wp ) { $button = ''; @@ -1043,7 +1043,7 @@ function wp_get_plugin_action_button( $name, $data, $compatible_php, $compatible } break; } - - return $button; } + + return $button; } diff --git a/wp-includes/version.php b/wp-includes/version.php index d8c7e3e39b..e662fda02f 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.5.5-alpha-58404'; +$wp_version = '6.5.5-alpha-58445'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.