Ticket #5232: wp-current-filter-r6720.patch

File wp-current-filter-r6720.patch, 1.5 KB (added by tellyworth, 5 years ago)
  • wordpress/wp-includes/plugin.php

     
    4040 * @return string The text in <tt>$string</tt> after all hooked functions are applied to it. 
    4141 */ 
    4242function apply_filters($tag, $string) { 
    43         global $wp_filter, $merged_filters; 
     43        global $wp_filter, $merged_filters, $wp_current_filter; 
    4444 
    4545        if ( !isset( $merged_filters[ $tag ] ) ) 
    4646                merge_filters($tag); 
     
    5151        reset( $wp_filter[ $tag ] ); 
    5252 
    5353        $args = func_get_args(); 
     54         
     55        $last_filter = @$wp_current_filter; 
     56        $wp_current_filter = $tag; 
    5457 
    5558        do{ 
    5659                foreach( (array) current($wp_filter[$tag]) as $the_ ) 
     
    6164 
    6265        } while ( next($wp_filter[$tag]) !== false ); 
    6366 
     67        $wp_current_filter = $last_filter; 
     68 
    6469        return $string; 
    6570} 
    6671 
     
    138143 * @param mixed $arg,... Optional additional arguments which are passed on to the functions hooked to the action. 
    139144 */ 
    140145function do_action($tag, $arg = '') { 
    141         global $wp_filter, $wp_actions; 
     146        global $wp_filter, $wp_actions, $wp_current_action; 
    142147 
    143148        if ( is_array($wp_actions) ) 
    144149                $wp_actions[] = $tag; 
     
    158163        if ( !isset($wp_filter[$tag]) ) 
    159164                return; 
    160165 
     166        $last_action = @$wp_current_action; 
     167        $wp_current_action = $tag; 
     168 
    161169        do{ 
    162170                foreach( (array) current($wp_filter[$tag]) as $the_ ) 
    163171                        if ( !is_null($the_['function']) ) 
     
    165173 
    166174        } while ( next($wp_filter[$tag]) !== false ); 
    167175 
     176        $wp_current_action = $last_action; 
    168177} 
    169178 
    170179/**