Make WordPress Core

Changeset 58396 for trunk


Ignore:
Timestamp:
06/12/2024 06:15:33 PM (5 months 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].

Props costdev, rajinsharwar, hellofromTonya.
Fixes #61400.

Location:
trunk
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/plugin-install.php

    r58161 r58396  
    913913 * @param bool         $compatible_php   The result of a PHP compatibility check.
    914914 * @param bool         $compatible_wp    The result of a WP compatibility check.
    915  * @return string The markup for the dependency row button.
     915 * @return string The markup for the dependency row button. An empty string if the user does not have capabilities.
    916916 */
    917917function wp_get_plugin_action_button( $name, $data, $compatible_php, $compatible_wp ) {
     
    10491049                break;
    10501050        }
    1051 
    1052         return $button;
    1053     }
     1051    }
     1052
     1053    return $button;
    10541054}
Note: See TracChangeset for help on using the changeset viewer.