Make WordPress Core


Ignore:
Timestamp:
12/08/2006 03:45:34 AM (20 years ago)
Author:
ryan
Message:

did_action()

File:
1 edited

Legend:

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

    r4626 r4630  
    9393
    9494function do_action($tag, $arg = '') {
    95         global $wp_filter;
     95        global $wp_filter, $wp_actions;
     96
    9697        $args = array();
    9798        if ( is_array($arg) && 1 == count($arg) && is_object($arg[0]) ) // array(&$this)
    … …  
    124125                }
    125126        }
     127
     128        if ( is_array($wp_actions) )
     129                $wp_actions[] = $tag;
     130        else
     131                $wp_actions = array($tag);
     132}
     133
     134// Returns the number of times an action has been done
     135function did_action($tag) {
     136        global $wp_actions;
     137
     138        return count(array_keys($wp_actions, $tag));
    126139}
    127140
    128141function do_action_ref_array($tag, $args) {
    129         global $wp_filter;
     142        global $wp_filter, $wp_actions;
     143
     144        if ( !is_array($wp_actions) )
     145                $wp_actions = array($tag);
     146        else
     147                $wp_actions[] = $tag;
    130148
    131149        merge_filters($tag);
Note: See TracChangeset for help on using the changeset viewer.