From 0289b98648d5174a43117f67629897cc41d17877 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Sat, 28 Jun 2014 04:38:15 +0000 Subject: [PATCH] After [28883], `remove_filter()` should set `$GLOBALS['wp_filter'][ $tag ]` to `array()` when empty. Props wonderboymusic, sphoid. Fixes #28142. Built from https://develop.svn.wordpress.org/trunk@28884 git-svn-id: http://core.svn.wordpress.org/trunk@28683 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/plugin.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/wp-includes/plugin.php b/wp-includes/plugin.php index 610963aabf..11e335f6ca 100644 --- a/wp-includes/plugin.php +++ b/wp-includes/plugin.php @@ -273,15 +273,19 @@ function apply_filters_ref_array($tag, $args) { * @return boolean Whether the function existed before it was removed. */ function remove_filter( $tag, $function_to_remove, $priority = 10 ) { - $function_to_remove = _wp_filter_build_unique_id($tag, $function_to_remove, $priority); + $function_to_remove = _wp_filter_build_unique_id( $tag, $function_to_remove, $priority ); - $r = isset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]); + $r = isset( $GLOBALS['wp_filter'][ $tag ][ $priority ][ $function_to_remove ] ); - if ( true === $r) { - unset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]); - if ( empty($GLOBALS['wp_filter'][$tag][$priority]) ) - unset($GLOBALS['wp_filter'][$tag][$priority]); - unset($GLOBALS['merged_filters'][$tag]); + if ( true === $r ) { + unset( $GLOBALS['wp_filter'][ $tag ][ $priority ][ $function_to_remove ] ); + if ( empty( $GLOBALS['wp_filter'][ $tag ][ $priority ] ) ) { + unset( $GLOBALS['wp_filter'][ $tag ][ $priority ] ); + } + if ( empty( $GLOBALS['wp_filter'][ $tag ] ) ) { + $GLOBALS['wp_filter'][ $tag ] = array(); + } + unset( $GLOBALS['merged_filters'][ $tag ] ); } return $r;