Make WordPress Core

Ticket #26640: apply_filters.patch

File apply_filters.patch, 1.5 KB (added by dshafik, 11 years ago)
  • wp-includes/plugin.php

     
    192192        if ( empty($args) )
    193193                $args = func_get_args();
    194194
     195        $current = current($wp_filter[$tag]);
    195196        do {
    196                 foreach( (array) current($wp_filter[$tag]) as $the_ )
    197                         if ( !is_null($the_['function']) ){
     197                foreach( (array) $current as $the_ )
     198                        if ( $the_['function'] !== null ){
    198199                                $args[1] = $value;
    199                                 $value = call_user_func_array($the_['function'], array_slice($args, 1, (int) $the_['accepted_args']));
     200
     201                                $func = $the_['function'];
     202
     203                                if (!function_exists($func)) {
     204                                        trigger_error("function '$func' not found or invalid function name", E_USER_WARNING);
     205                                        continue;
     206                                }
     207
     208                                switch ((int) $the_['accepted_args']) {
     209                                        case 1:
     210                                                $value = $func($args[1]);
     211                                                break;
     212                                        case 2:
     213                                                $value = $func($args[1], $args[2]);
     214                                                break;
     215                                        case 3:
     216                                                $value = $func($args[1], $args[2], $args[3]);
     217                                                break;
     218                                        case 4:
     219                                                $value = $func($args[1], $args[2], $args[3], $args[4]);
     220                                                break;
     221                                        case 5:
     222                                                $value = $func($args[1], $args[2], $args[3], $args[4], $args[5]);
     223                                                break;
     224                                        default:
     225                                                $value = call_user_func_array($the_['function'], array_slice($args, 1, (int) $the_['accepted_args']));
     226                                }
    200227                        }
    201228
    202         } while ( next($wp_filter[$tag]) !== false );
     229        } while ( $current = next($wp_filter[$tag]) !== false );
    203230
    204231        array_pop( $wp_current_filter );
    205232