#61882 closed enhancement (duplicate)
Assigning same callback to multiple Actions and Filters via a single function call
Reported by: | namith.jawahar | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Plugins | Keywords: | |
Focuses: | Cc: |
Description
This is an enhancement everyone decided to leave out for lack of performance improvement more than a decade back but now we have extensive use of anonymous functions and the syntactic sugar does make sense now.
Something like this will allow not having to define a function with a name or assign a function to a variable and run it through foreach every time the same callback needs to be applied to different hooks
Something like the add_actions and add_filters function wont create an impact on existing hook while allowing cleaner and easier to read code without having to litter everywhere with foreach loops.
function add_actions($hooks, $callback, $priority = 10, $accepted_args = 1) {
foreach ($hooks as $hook) {
add_action($hook, $callback, $priority, $accepted_args);
}
}
Hoping to restart the discussion around this
Change History (1)
#1
@
7 weeks ago
- Component changed from General to Plugins
- Milestone Awaiting Review deleted
- Resolution set to duplicate
- Status changed from new to closed
Version 0, edited 7 weeks ago
by
(next)
Note: See
TracTickets for help on using
tickets.
Hi there, welcome to WordPress Trac!
Thanks for the ticket, we're already tracking this enhancement in #34309.