#44831 closed defect (bug) (invalid)
apply_filters_deprecated() and do_action_deprecated() should only trigger a notice when a callback is hooked
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.6 |
Component: | Plugins | Keywords: | |
Focuses: | docs | Cc: |
Description
The inline docs for apply_filters_deprecated()
includes the following example code:
// Old filter. return apply_filters( 'wpdocs_filter', $value, $extra_arg ); // Deprecated. return apply_filters_deprecated( 'wpdocs_filter', array( $value, $extra_arg ), '4.9', 'wpdocs_new_filter' );
The problem with this code is that the deprecated notice is triggered regardless of whether a callback is hooked into the deprecated filter or not. The deprecated notice should only be triggered if a callback is hooked into the filter.
Two options to fix this. Either:
- Update the example code to include a check for
has_filter()
/has_action()
, or - Add a check for
has_filter()
/has_action()
insideapply_filters_deprecated()
/do_action_deprecated()
so the notice is only triggered when a callback is hooked.
Change History (2)
Note: See
TracTickets for help on using
tickets.
For reference, re-reading [37861], it looks like that's already the case.