[wp-trac] [WordPress Trac] #35357: Introduce did_filter()
WordPress Trac
noreply at wordpress.org
Fri Jan 8 03:01:50 UTC 2016
#35357: Introduce did_filter()
-------------------------+------------------------
Reporter: mordauk | Owner: chriscct7
Type: enhancement | Status: accepted
Priority: normal | Milestone: 4.5
Component: Plugins | Version:
Severity: normal | Resolution:
Keywords: needs-patch | Focuses:
-------------------------+------------------------
Comment (by dd32):
Replying to [comment:10 chriscct7]:
> I stand corrected. It does indeed return 1. Therefore there is a
difference, however I don't see a use case where the way did_action which
counts per do_action call as opposed to the number of functions that run
on it (like my above patch does) makes sense for filters. I actually think
the patch method of counting is more expected for filters because of
exactly this:
>
> > I've never seen much utility for this, because filters are often run
in different, repeated contexts, rather than a single-time action.
>
Just to throw another opinion at it
- I don't see the point of counting the number of functions that've run.
- I don't think "detecting another function has already run on this
filter" is a valid use-case that should be supported. If a filter
*shouldn't* run, it should either be `remove_action()`'d or not hooked in
the first place if another filter is already hooked in.
- As filters are more likely to be called multiple times per page load it
feels more sane that it'd return the number of times that filter has run
on the current load, "the_title has run 15 times" is a lot more useful
than "the_title has had 150 functions run on it".
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35357#comment:12>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list