Example #1
0
 /**
  * do_action_ref_array Execute functions hooked on a specific action hook, specifying arguments in an array.
  * @access public
  * @since 0.1
  * @param string $tag The name of the action to be executed.
  * @param array $args The arguments supplied to the functions hooked to <tt>$tag</tt>
  * @return null Will return null if $tag does not exist in $filter array
  */
 public static function do_action_ref_array($tag, $args)
 {
     if (!isset(self::$actions)) {
         self::$actions = array();
     }
     if (!isset(self::$actions[$tag])) {
         self::$actions[$tag] = 1;
     } else {
         ++self::$actions[$tag];
     }
     // Do 'all' actions first
     if (isset(self::$filters['all'])) {
         self::$current_filter[] = $tag;
         $all_args = func_get_args();
         self::_call_all_hook($all_args);
     }
     if (!isset(self::$filters[$tag])) {
         if (isset(self::$filters['all'])) {
             array_pop(self::$current_filter);
         }
         return;
     }
     if (!isset(self::$filters['all'])) {
         self::$current_filter[] = $tag;
     }
     // Sort
     if (!isset($merged_filters[$tag])) {
         ksort(self::$filters[$tag]);
         $merged_filters[$tag] = true;
     }
     reset(self::$filters[$tag]);
     do {
         foreach ((array) current(self::$filters[$tag]) as $the_) {
             if (!is_null($the_['function'])) {
                 call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
             }
         }
     } while (next(self::$filters[$tag]) !== false);
     array_pop(self::$current_filter);
 }