Make WordPress Core

Changeset 58445

Timestamp:
06/20/2024 03:28:49 PM (7 weeks ago)
Author:
hellofromTonya
Message:

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.

Location:
branches/6.5
Files:
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/6.5

  • branches/6.5/src/wp-admin/includes/plugin-install.php

    r58404 r58445  
    918918 * @param bool         $compatible_php   The result of a PHP compatibility check.
    919919 * @param bool         $compatible_wp    The result of a WP compatibility check.
    920  * @return string $button The markup for the dependency row button.
     920 * @return string .
    921921 */
    922922function wp_get_plugin_action_button( $name, $data, $compatible_php, $compatible_wp ) {
     
    10441044                break;
    10451045        }
    1046 
    1047         return $button;
    1048     }
     1046    }
     1047
     1048   
    10491049}
Note: See TracChangeset for help on using the changeset viewer.