[wp-trac] [WordPress Trac] #46635: Improve identifying of non–trivial callbacks in hooks

WordPress Trac noreply at wordpress.org
Fri Jul 12 15:40:03 UTC 2019


#46635: Improve identifying of non–trivial callbacks in hooks
-------------------------+-------------------------------
 Reporter:  Rarst        |       Owner:  (none)
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  General      |     Version:
 Severity:  normal       |  Resolution:
 Keywords:               |     Focuses:  coding-standards
-------------------------+-------------------------------

Comment (by azaozz):

 > Since API had already been established for many years it is not viable
 to introduce new mandatory behavior
 > ...
 > While new opt in behavior could be introduced, as above I strongly
 believe that would not be an adequate solution.

 Not sure I agree :)

 Would that mean the API is "frozen in time" and shouldn't evolve (in a
 backwards-compatible way)?

 Looking at the proposed solutions, seems the API can be enhanced to
 support removal of closures in a simple and fully backwards-compatible
 way. For now I like what @schlessera posted in
 [https://core.trac.wordpress.org/ticket/46635#comment:17 comment 17] the
 best. Passing a (standardized) object when adding a filter or action is
 futureproof and very simple to use. Only I'd probably change the name to
 something related to WP hooks, perhaps `new Add_WP_Action()` with an alias
 of `Add_WP_Filter()`.

 Then Core will also be able to use closures in hooks, and we can think of
 a "nice way" to get plugins to switch to it too.

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


More information about the wp-trac mailing list