add_filter should accept an array of tags
|Reported by:||sivel||Owned by:|
|Component:||Plugins||Keywords:||has-patch early needs-testing dev-feedback|
Currently when you want to hook a single callback into multiple filters/actions you create an array and loop through it calling add_action/filter each time. It would reduce code and make it easier to do this by just having add_filter accept an array of strings as it's first argument. In addition tests have shown that it also improves overall performance of WP by using this.
I talked to nacin on IRC recently about this and he was concerned about negative performance impacts that this may have, since most of our add_action/filter calls are for single tags. I did some performance benchmarking and found the following results:
With having add_filter accept an array it was 0.000002002716 seconds slower for single actions, but 0.000007534 seconds faster for a 4 action loop. Without add_filter accepting an array each iteration of a foreach in the way we are currently handling it takes 0.00000885725 seconds, accepting an array each iteration takes 0.00000697374 seconds. Which is a 0.000001884 improvement during add_action/filter iterations.
Overall on a default install of WP 3.1-alpha this modification actually improved performance by 0.00048398971558 seconds faster by having add_filter handle all of the looping.
Anyway, this is an early patch and likely could use a bit of testing and independent benchmarking.
At the moment I have not added this functionality to remove_action/filter and am not really sure we need it.
Please provide feedback, test and provide your own benchmarks.
Change History (13)
- Milestone Future Release deleted
- Resolution set to wontfix
- Status changed from new to closed