From 0071965c1271c8e48776e26fe8a683d56139ac97 Mon Sep 17 00:00:00 2001 From: ozh Date: Mon, 11 May 2015 11:50:01 +0200 Subject: [PATCH] Add yourls_remove_all_(filters|actions) --- includes/functions-plugins.php | 39 ++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/includes/functions-plugins.php b/includes/functions-plugins.php index 1bcafcb..f03870d 100644 --- a/includes/functions-plugins.php +++ b/includes/functions-plugins.php @@ -250,6 +250,45 @@ function yourls_remove_action( $hook, $function_to_remove, $priority = 10 ) { return yourls_remove_filter( $hook, $function_to_remove, $priority ); } +/** + * Removes all functions from a specified action hook. + * + * @see yourls_remove_all_filters() + * @since 1.7.1 + * + * @param string $hook The action to remove hooks from + * @param int $priority optional. The priority of the functions to remove + * @return boolean true when it's finished + */ + +function yourls_remove_all_actions( $hook, $priority = false ) { + return yourls_remove_all_filters( $hook, $priority ); +} + +/** + * Removes all functions from a specified filter hook. + * + * @since 1.7.1 + * + * @param string $hook The filter to remove hooks from + * @param int $priority optional. The priority of the functions to remove + * @return boolean true when it's finished + */ + +function yourls_remove_all_filters( $hook, $priority = false ) { + global $yourls_filters; + + if( isset( $yourls_filters[ $hook ] ) ) { + if( $priority === false ) { + unset( $yourls_filters[ $hook ] ); + } else if ( isset( $yourls_filters[ $hook ][ $priority ] ) ) { + unset( $yourls_filters[ $hook ][ $priority ] ); + } + } + + return true; +} + /** * Check if any filter has been registered for a hook. * -- 2.45.0