Changeset 6318

Show
Ignore:
Timestamp:
11/06/07 21:38:04 (10 months ago)
Author:
ryan
Message:

current_fiter() from tellyworth. fixes #5232

Files:

Legend:

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

    r6316 r6318  
    108108 */ 
    109109function apply_filters($tag, $value) { 
    110     global $wp_filter, $merged_filters; 
     110    global $wp_filter, $merged_filters, $wp_current_filter; 
     111 
     112    @$wp_current_filter[] = $tag; 
    111113 
    112114    // Do 'all' actions first 
     
    121123    } 
    122124 
    123     if ( !isset($wp_filter[$tag]) ) 
     125    if ( !isset($wp_filter[$tag]) ) { 
     126        array_pop($wp_current_filter); 
    124127        return $value; 
     128    } 
    125129 
    126130    // Sort 
     
    143147 
    144148    } while ( next($wp_filter[$tag]) !== false ); 
     149     
     150    array_pop( $wp_current_filter ); 
    145151 
    146152    return $value; 
     
    183189 
    184190/** 
     191 * Return the name of the current filter or action. 
     192 */ 
     193function current_filter() { 
     194    global $wp_current_filter; 
     195    return end( $wp_current_filter ); 
     196} 
     197 
     198 
     199/** 
    185200 * Hooks a function on to a specific action. 
    186201 * 
     
    234249 */ 
    235250function do_action($tag, $arg = '') { 
    236     global $wp_action, $wp_actions
     251    global $wp_action, $wp_actions, $wp_current_filter
    237252 
    238253    if ( is_array($wp_actions) ) 
     
    249264        $args[] = func_get_arg($a); 
    250265 
     266    @$wp_current_filter[] = $tag; 
     267 
    251268    // Do 'all' actions first 
    252269    if ( isset($wp_action['all']) ) { 
     
    259276    } 
    260277 
    261     if ( !isset($wp_action[$tag]) ) 
     278    if ( !isset($wp_action[$tag]) ) { 
     279        array_pop($wp_current_filter); 
    262280        return; 
    263  
     281    } 
     282         
    264283    // Sort 
    265284    if ( !isset( $merged_actions[ $tag ] ) ) { 
     
    278297    } while ( next($wp_action[$tag]) !== false ); 
    279298 
     299        array_pop($wp_current_filter); 
    280300} 
    281301