Return based on whether the hook was removed or not. Props mdawaffe. fixes #4223

Note that this will almost definitely *not* affect existing implementations. The way most code is set up now is to just call remove_filter() or remove_action().


git-svn-id: http://svn.automattic.com/wordpress/trunk@5393 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
rob1n 2007-05-04 23:27:12 +00:00
parent bc423b6e4c
commit 8638b7ab3a

View File

@ -97,12 +97,14 @@ function merge_filters($tag) {
* @return boolean Whether the function is removed.
*/
function remove_filter($tag, $function_to_remove, $priority = 10, $accepted_args = 1) {
global $wp_filter, $merged_filters;
$function_to_remove = serialize($function_to_remove);
unset($GLOBALS['wp_filter'][$tag][$priority][serialize($function_to_remove)]);
unset( $merged_filters[ $tag ] );
$r = isset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]);
return true;
unset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]);
unset($GLOBALS['merged_filters'][$tag]);
return $r;
}
/**
@ -216,7 +218,7 @@ function do_action_ref_array($tag, $args) {
* @return boolean Whether the function is removed.
*/
function remove_action($tag, $function_to_remove, $priority = 10, $accepted_args = 1) {
remove_filter($tag, $function_to_remove, $priority, $accepted_args);
return remove_filter($tag, $function_to_remove, $priority, $accepted_args);
}
//
@ -274,4 +276,4 @@ function register_deactivation_hook($file, $function) {
add_action('deactivate_' . $file, $function);
}
?>
?>