Add handling for deprecated hooks #178
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There is a proposal up for handling hook deprecation in WordPress core in 4.6+. It introduces three new functions,
apply_filters_deprecated()
,do_action_deprecated()
and the_deprecated_hook()
utility function, all of which we need to add handling for in the parser.Background:
Implementation of hook deprecation is essentially a three-prong project in that we need to:
Thankfully, the parser is flexible enough already that we don't need to do much to handle deprecated hooks!
Hooks would be deprecated by switching to corresponding
apply_filters|do_action_deprecated()
calls and signatures. Then – just like is already done with functions and methods – pairs of@deprecated
and@see
tags will be added to the hook DocBlocks so all deprecate-able elements are handled the same way from a documentation perspective.Proposed Changes:
In this PR I've made the following changes:
apply_filters_deprecated
anddo_action_deprecated
to the list of functions recognized as "hook" functionsfilter_deprecated
andaction_deprecated
. These would be in addition the four existing types:filter
,filter_reference
,action
, andaction_reference
, used to identifyapply_filters()
,apply_filters_ref_array()
,do_action()
, anddo_action_ref_array()
, respectively._deprecated_hook()
function in storing the version the hook was deprecatedWP_Parser\is_deprecated()
which can be used for any parsed post type.WP_Parser\is_function_deprecated()
has been converted into a wrapper for it, and its namesake filter,wp_parser_is_function_deprecated
, retained for back-compat .