WordPress.org

Make WordPress Core

Ticket #10561: plugin.patch

File plugin.patch, 1.2 KB (added by koopersmith, 5 years ago)

r11782, patch for do_action, did_action, and do_action_ref_array

  • plugin.php

     
    299299function do_action($tag, $arg = '') { 
    300300        global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter; 
    301301 
    302         if ( is_array($wp_actions) ) 
    303                 $wp_actions[] = $tag; 
     302        if ( ! isset($wp_actions) ) 
     303                $wp_actions = array(); 
     304         
     305        if ( ! isset($wp_actions[$tag]) ) 
     306                $wp_actions[$tag] = 1; 
    304307        else 
    305                 $wp_actions = array($tag); 
     308                ++$wp_actions[$tag]; 
    306309 
    307310        $wp_current_filter[] = $tag; 
    308311 
     
    357360function did_action($tag) { 
    358361        global $wp_actions; 
    359362 
    360         if ( empty($wp_actions) ) 
     363        if ( ! isset( $wp_actions ) || ! isset( $wp_actions[$tag] ) ) 
    361364                return 0; 
    362365 
    363         return count(array_keys($wp_actions, $tag)); 
     366        return $wp_actions[$tag]; 
    364367} 
    365368 
    366369/** 
     
    382385function do_action_ref_array($tag, $args) { 
    383386        global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter; 
    384387 
    385         if ( !is_array($wp_actions) ) 
    386                 $wp_actions = array($tag); 
     388        if ( ! isset($wp_actions) ) 
     389                $wp_actions = array(); 
     390         
     391        if ( ! isset($wp_actions[$tag]) ) 
     392                $wp_actions[$tag] = 1; 
    387393        else 
    388                 $wp_actions[] = $tag; 
     394                ++$wp_actions[$tag]; 
    389395 
    390396        $wp_current_filter[] = $tag; 
    391397