WordPress.org

Make WordPress Core

Opened 9 months ago

#37990 new enhancement

Introduce `WP_Hooks`

Reported by: flixos90 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.7
Component: Plugins Keywords: 2nd-opinion
Focuses: Cc:

Description

After 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 `$GLOBALSwp_filters?.

Change History (0)

Note: See TracTickets for help on using tickets.