#61882 closed enhancement (duplicate)
Assigning same callback to multiple Actions and Filters via a single function call
| Reported by: | namith.jawahar | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Plugins | Version: | |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: |
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
@
2 years ago
- Component General → Plugins
- Milestone Awaiting Review
- Resolution → duplicate
- Status new → closed
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Hi there, welcome to WordPress Trac!
Thanks for the ticket, we're already tracking this enhancement in #34309.