Add handling for deprecated hooks #178

merged 5 commits into from Jun 16, 2017


None yet
1 participant

DrewAPicture commented Jun 11, 2016

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.

Implementation of hook deprecation is essentially a three-prong project in that we need to:

  1. Update core – #10411
  2. Update the parser
  3. Update the wporg-developer theme used on the code reference – #1766

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:

  • Added apply_filters_deprecated and do_action_deprecated to the list of functions recognized as "hook" functions
  • Introduced two new hook types for use by themes: filter_deprecated and action_deprecated. These would be in addition the four existing types: filter, filter_reference, action, and action_reference, used to identify apply_filters(), apply_filters_ref_array(), do_action(), and do_action_ref_array(), respectively.
  • Added handling for the new _deprecated_hook() function in storing the version the hook was deprecated
  • Added a new function (and generic hook), WP_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 .

DrewAPicture added some commits Jun 11, 2016

Introduce a generic is_deprecated() function for determining if the c…
…urrent element is deprecated.

Also converts is_function_deprecated() into a wrapper for the new function and introduces a new generic 'wp_parser_is_deprecated' hook. The 'wp_parser_is_function_deprecated' hook is retained for back-compat on the return of is_function_deprecated().

@DrewAPicture DrewAPicture self-assigned this Mar 29, 2017

@DrewAPicture DrewAPicture merged commit d49f8eb into WordPress:master Jun 16, 2017

1 check failed

continuous-integration/travis-ci/pr The Travis CI build failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment