Skip to content

Add support for deprecated actions and filters - #25

Open
daledupreez wants to merge 2 commits into
wp-hooks:trunkfrom
daledupreez:try/add-support-for-deprecated-actions-and-filters
Open

Add support for deprecated actions and filters#25
daledupreez wants to merge 2 commits into
wp-hooks:trunkfrom
daledupreez:try/add-support-for-deprecated-actions-and-filters

Conversation

@daledupreez

Copy link
Copy Markdown

This PR implements support for an optional --include-deprecated argument that allows deprecated hooks to be included in the generator output. This option is off by default, but a default can be specified via the extra fields in composer.json.

At an implementation level, the PR looks for do_action_deprecated and apply_filters_deprecated function calls, and extracts the data from the function arguments in addition to any PHPDoc for the call. For now, I am also allowing call sites with empty PHPDoc to be included by creating some stub document text, as the function arguments include fairly critical information, even if the main PHPDoc does not. But that may not be a great approach, so I am happy to remove that loophole.

In particular, the code adds three new fields for deprecated hooks:

  • deprecated_version - the version the hook was deprecated in, which is extracted from the third argument (index 2) to the hook function
  • deprecated_replacement - the name of the replacement (which may or may not be a function), which is extracted from the fourth argument (index 3) to the hook function
  • deprecated_message - the value of the message argument, which is extracted from the fifth argument (index 4) to the hook function

The PR includes updates to the types and the JSON schema, as well as bumping the package and schema versions to 1.1.0 to reflect the opt-in nature of the new feature, as it is backwards compatible for current use cases.

@daledupreez

Copy link
Copy Markdown
Author

I missed that #23 already includes this and lots of other changes. Not sure whether we want to try and get that other PR landed, or whether getting this smaller PR merged first would be worth it.

cc @kkmuffme for visibility, as it looks like work on #23 stalled a few months ago.

@daledupreez

Copy link
Copy Markdown
Author

And also a bump for @johnbillion, as I can't request a specific reviewer for the PR. Apologies for the ping, but I suspect this may not be a repo you check frequently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant