[wp-trac] [WordPress Trac] #37990: Introduce `WP_Hooks`

WordPress Trac noreply at wordpress.org
Thu Sep 8 14:49:26 UTC 2016


#37990: Introduce `WP_Hooks`
-------------------------+-----------------------------
 Reporter:  flixos90     |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Plugins      |    Version:  trunk
 Severity:  normal       |   Keywords:  2nd-opinion
  Focuses:               |
-------------------------+-----------------------------
 After [changeset:38571], I wonder whether we should introduce a `WP_Hooks`
 (or `WP_Hook_Manager`) class to take care of all hook-related
 functionality. This wouldn't really have any functional benefit at this
 point, but I was thinking about this more related to #37699 - since the
 changeset mentioned above already changed the global variables in a
 backward-incompatible manner, maybe we can get rid of them entirely then?

 Everything related that is currently stored as global, we could store as
 properties in the `WP_Hooks` class, and the `WP_Hooks` class could become
 accessible through a `WP::get( 'hooks' )` or similar. The current hook
 functions would become wrappers for `WP_Hooks` methods then.

 I'm aware that this would be a very critical change, however like I said,
 we already changed how the global variables work so we could also remove
 them (and direct access is discouraged anyway). Of course this would also
 require another dev note. Those people who really need direct access could
 then do `WP::get( 'hooks' )->wp_filters` instead of
 `$GLOBALS['wp_filters'].

--
Ticket URL: <https://core.trac.wordpress.org/ticket/37990>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list