Make WordPress Core


Ignore:
Timestamp:
07/20/2012 05:25:37 AM (13 years ago)
Author:
nacin
Message:

Remove unnecessary is_null() checks from the worker loops inside do_action(), apply_filters(), etc. fixes #21321. see #21169.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/plugin.php

    r19712 r21287  
    165165
    166166    do {
    167         foreach( (array) current($wp_filter[$tag]) as $the_ )
    168             if ( !is_null($the_['function']) ){
    169                 $args[1] = $value;
    170                 $value = call_user_func_array($the_['function'], array_slice($args, 1, (int) $the_['accepted_args']));
    171             }
    172 
     167        foreach( (array) current($wp_filter[$tag]) as $the_ ) {
     168            $args[1] = $value;
     169            $value = call_user_func_array($the_['function'], array_slice($args, 1, (int) $the_['accepted_args']));
     170        }
    173171    } while ( next($wp_filter[$tag]) !== false );
    174172
     
    223221
    224222    do {
    225         foreach( (array) current($wp_filter[$tag]) as $the_ )
    226             if ( !is_null($the_['function']) )
    227                 $args[0] = call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
    228 
     223        foreach( (array) current($wp_filter[$tag]) as $the_ ) {
     224            $args[0] = call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
     225        }
    229226    } while ( next($wp_filter[$tag]) !== false );
    230227
     
    264261        if ( empty($GLOBALS['wp_filter'][$tag][$priority]) )
    265262            unset($GLOBALS['wp_filter'][$tag][$priority]);
     263        if ( empty( $GLOBALS['wp_filter'][ $tag ] ) )
     264            unset( $GLOBALS['wp_filter'][ $tag ] );
    266265        unset($GLOBALS['merged_filters'][$tag]);
    267266    }
     
    399398
    400399    do {
    401         foreach ( (array) current($wp_filter[$tag]) as $the_ )
    402             if ( !is_null($the_['function']) )
    403                 call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
    404 
     400        foreach ( (array) current($wp_filter[$tag]) as $the_ ) {
     401            call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
     402        }
    405403    } while ( next($wp_filter[$tag]) !== false );
    406404
     
    480478
    481479    do {
    482         foreach( (array) current($wp_filter[$tag]) as $the_ )
    483             if ( !is_null($the_['function']) )
    484                 call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
    485 
     480        foreach( (array) current($wp_filter[$tag]) as $the_ ) {
     481            call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
     482        }
    486483    } while ( next($wp_filter[$tag]) !== false );
    487484
     
    710707    reset( $wp_filter['all'] );
    711708    do {
    712         foreach( (array) current($wp_filter['all']) as $the_ )
    713             if ( !is_null($the_['function']) )
    714                 call_user_func_array($the_['function'], $args);
    715 
     709        foreach( (array) current($wp_filter['all']) as $the_ ) {
     710            call_user_func_array($the_['function'], $args);
     711        }
    716712    } while ( next($wp_filter['all']) !== false );
    717713}
Note: See TracChangeset for help on using the changeset viewer.