Ticket #14994: 14994.2.diff

File 14994.2.diff, 1.8 KB (added by nacin, 21 months ago)
  • wp-includes/plugin.php

     
    308308        return end( $wp_current_filter ); 
    309309} 
    310310 
     311/** 
     312 * Retrieve the name of the current action. 
     313 * 
     314 * @since 3.2.0 
     315 * 
     316 * @return string Hook name of the current action. 
     317 */ 
     318function current_action() { 
     319        return current_filter(); 
     320} 
    311321 
    312322/** 
     323 * Retrieve the name of a filter currently being processed. 
     324 * 
     325 * The function current_filter() only returns the most recent filter 
     326 * or action being executed. did_action() returns true once the action 
     327 * is initially processed. This function allows detection for any filter 
     328 * currently being executed (despite not being the most recent filter to 
     329 * fire, in the case of hooks called from hook callbacks) to be verified. 
     330 * 
     331 * @since 3.2.0 
     332 * @see current_filter() 
     333 * @see did_action() 
     334 * 
     335 * @param $filter string Optional. Filter to check. Defaults to null, 
     336 *      which checks if any filter is currently being run. 
     337 * @return bool Whether the filter is currently in the stack 
     338 */ 
     339function doing_filter( $filter = null ) { 
     340        global $wp_current_filter; 
     341        if ( null === $filter ) 
     342                return empty( $wp_current_filter ); 
     343        return in_array( $filter, $wp_current_filter ); 
     344} 
     345 
     346/** 
     347 * Retrieve the name of an action currently being processed. 
     348 * 
     349 * @since 3.2.0 
     350 * @uses doing_filter() 
     351 * 
     352 * @param $action string Optional. Action to check. Defaults to null, 
     353 *      which checks if any action is currently being run. 
     354 * @return bool Whether the action is currently in the stack 
     355 */ 
     356function doing_action( $action = null ) { 
     357        return doing_filter( $action ); 
     358} 
     359 
     360/** 
    313361 * Hooks a function on to a specific action. 
    314362 * 
    315363 * Actions are the hooks that the WordPress core launches at specific points