Add rule to warn when using deprecated actions/filters
Is your feature request related to a problem?
I notice sometimes when using the PHPStorm autocompletion for WordPress hooks that some hooks I use to used don't show up in the hints. I guess it's because PHPStorm only suggest hooks from apply_filters and do_action functions and not from apply_filters_deprecated and do_action_deprecated.
Even if it would be relatively safe to keep using deprecated hooks (at least for hooks in WordPress core) it would be really useful to be warn when a deprecated usage is detected.
Describe the solution you'd like
Usage of a deprecated action/filter should trigger a CS warning.
add_filter( 'allowed_block_types', 'my_callback_function' ); // deprecated since WordPress 5.8.0
Additional context (optional)
I was thinking of something along the line of the Sniff WordPress.WP.DeprecatedFunctions which provide details about the deprecation and the replacement if available.
wp_setcookie() has been deprecated since WordPress version 2.5.0. Use wp_set_auth_cookie() instead (WordPress.WP.DeprecatedFunctions.wp_setcookieFound)
Related to and partial duplicate of #576.
This would be a great sniff to add. The biggest concern is the initial creation and subsequent maintenance of the "list" of deprecated hooks.
Sorry for missing the existing issue. I didn't realize this would require a static list.
The first step for moving forward with the issue would be to have a tools to scan for deprecated hooks and build a list with the details for each ones ?
The first step for moving forward with the issue would be to have a tools to scan for deprecated hooks and build a list with the details for each ones ?
This is what we currently use to keep the DeprecatedFunctions sniff up to date: https://github.com/JDGrimes/wp-deprecated-code-scanner
Also see https://github.com/WordPress/WordPress-Coding-Standards/issues/1803