mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-02 11:44:33 +00:00
Allow action and filter hooks to be deprecated.
When a filter or action hook is deprecated, the corresponding `apply_filters()` or `do_action()` calls should be switched out with `apply_filters_deprecated()` or `do_action_deprecated()`. The latter functions will throw a deprecation before invoking the original hook. Props solarissmoke, SergeyBiryukov, DrewAPicture. Fixes #10441. git-svn-id: https://develop.svn.wordpress.org/trunk@37861 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -655,6 +655,60 @@ function remove_all_actions($tag, $priority = false) {
|
||||
return remove_all_filters($tag, $priority);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fires functions attached to a deprecated filter hook.
|
||||
*
|
||||
* When a filter hook is deprecated, the apply_filters() call is replaced with
|
||||
* apply_filters_deprecated(), which triggers a deprecation notice and then fires
|
||||
* the original filter hook.
|
||||
*
|
||||
* @since 4.6.0
|
||||
*
|
||||
* @see _deprecated_hook()
|
||||
*
|
||||
* @param string $tag The name of the filter hook.
|
||||
* @param array $args Array of additional function arguments to be passed to apply_filters().
|
||||
* @param string $version The version of WordPress that deprecated the hook.
|
||||
* @param string $replacement Optional. The hook that should have been used.
|
||||
* @param string $message Optional. A message regarding the change.
|
||||
*/
|
||||
function apply_filters_deprecated( $tag, $args, $version, $replacement = false, $message = null ) {
|
||||
if ( ! has_filter( $tag ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
_deprecated_hook( $tag, $version, $replacement, $message );
|
||||
|
||||
return apply_filters_ref_array( $tag, $args );
|
||||
}
|
||||
|
||||
/**
|
||||
* Fires functions attached to a deprecated action hook.
|
||||
*
|
||||
* When an action hook is deprecated, the do_action() call is replaced with
|
||||
* do_action_deprecated(), which triggers a deprecation notice and then fires
|
||||
* the original hook.
|
||||
*
|
||||
* @since 4.6.0
|
||||
*
|
||||
* @see _deprecated_hook()
|
||||
*
|
||||
* @param string $tag The name of the action hook.
|
||||
* @param array $args Array of additional function arguments to be passed to do_action().
|
||||
* @param string $version The version of WordPress that deprecated the hook.
|
||||
* @param string $replacement Optional. The hook that should have been used.
|
||||
* @param string $message Optional. A message regarding the change.
|
||||
*/
|
||||
function do_action_deprecated( $tag, $args, $version, $replacement = false, $message = null ) {
|
||||
if ( ! has_action( $tag ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
_deprecated_hook( $tag, $version, $replacement, $message );
|
||||
|
||||
do_action_ref_array( $tag, $args );
|
||||
}
|
||||
|
||||
//
|
||||
// Functions for handling plugins.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user