[wp-trac] [WordPress Trac] #61400: `wp_get_plugin_action_button()` can return `void`.

WordPress Trac noreply at wordpress.org
Thu Jun 20 15:29:05 UTC 2024


#61400: `wp_get_plugin_action_button()` can return `void`.
-------------------------------------------------+-------------------------
 Reporter:  costdev                              |       Owner:
                                                 |  hellofromTonya
     Type:  defect (bug)                         |      Status:  closed
 Priority:  normal                               |   Milestone:  6.5.5
Component:  Plugins                              |     Version:  6.5
 Severity:  normal                               |  Resolution:  fixed
 Keywords:  has-patch has-unit-tests commit      |     Focuses:
  dev-reviewed                                   |
-------------------------------------------------+-------------------------
Changes (by hellofromTonya):

 * status:  reopened => closed
 * resolution:   => fixed


Comment:

 In [changeset:"58445" 58445]:
 {{{
 #!CommitTicketReference repository="" revision="58445"
 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.
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/61400#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list