From 11e877bcb8b9540612a22a316acbb19d50ea26f6 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Fri, 20 Jul 2012 05:25:37 +0000 Subject: [PATCH] Remove unnecessary is_null() checks from the worker loops inside do_action(), apply_filters(), etc. fixes #21321. see #21169. git-svn-id: https://develop.svn.wordpress.org/trunk@21287 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/plugin.php | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/wp-includes/plugin.php b/wp-includes/plugin.php index 914d70654c..176404a8e1 100644 --- a/wp-includes/plugin.php +++ b/wp-includes/plugin.php @@ -164,12 +164,10 @@ function apply_filters($tag, $value) { $args = func_get_args(); do { - foreach( (array) current($wp_filter[$tag]) as $the_ ) - if ( !is_null($the_['function']) ){ - $args[1] = $value; - $value = call_user_func_array($the_['function'], array_slice($args, 1, (int) $the_['accepted_args'])); - } - + foreach( (array) current($wp_filter[$tag]) as $the_ ) { + $args[1] = $value; + $value = call_user_func_array($the_['function'], array_slice($args, 1, (int) $the_['accepted_args'])); + } } while ( next($wp_filter[$tag]) !== false ); array_pop( $wp_current_filter ); @@ -222,10 +220,9 @@ function apply_filters_ref_array($tag, $args) { reset( $wp_filter[ $tag ] ); do { - foreach( (array) current($wp_filter[$tag]) as $the_ ) - if ( !is_null($the_['function']) ) - $args[0] = call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args'])); - + foreach( (array) current($wp_filter[$tag]) as $the_ ) { + $args[0] = call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args'])); + } } while ( next($wp_filter[$tag]) !== false ); array_pop( $wp_current_filter ); @@ -263,6 +260,8 @@ function remove_filter($tag, $function_to_remove, $priority = 10, $accepted_args 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 ] ) ) + unset( $GLOBALS['wp_filter'][ $tag ] ); unset($GLOBALS['merged_filters'][$tag]); } @@ -398,10 +397,9 @@ function do_action($tag, $arg = '') { reset( $wp_filter[ $tag ] ); do { - foreach ( (array) current($wp_filter[$tag]) as $the_ ) - if ( !is_null($the_['function']) ) - call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args'])); - + foreach ( (array) current($wp_filter[$tag]) as $the_ ) { + call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args'])); + } } while ( next($wp_filter[$tag]) !== false ); array_pop($wp_current_filter); @@ -479,10 +477,9 @@ function do_action_ref_array($tag, $args) { reset( $wp_filter[ $tag ] ); do { - foreach( (array) current($wp_filter[$tag]) as $the_ ) - if ( !is_null($the_['function']) ) - call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args'])); - + foreach( (array) current($wp_filter[$tag]) as $the_ ) { + call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args'])); + } } while ( next($wp_filter[$tag]) !== false ); array_pop($wp_current_filter); @@ -709,10 +706,9 @@ function _wp_call_all_hook($args) { reset( $wp_filter['all'] ); do { - foreach( (array) current($wp_filter['all']) as $the_ ) - if ( !is_null($the_['function']) ) - call_user_func_array($the_['function'], $args); - + foreach( (array) current($wp_filter['all']) as $the_ ) { + call_user_func_array($the_['function'], $args); + } } while ( next($wp_filter['all']) !== false ); }