WordPress.org

Make WordPress Core

Ticket #16661: 16661.diff

File 16661.diff, 5.3 KB (added by scribu, 7 years ago)
  • wp-includes/plugin.php

     
    174174}
    175175
    176176/**
    177  * Execute functions hooked on a specific filter hook, specifying arguments in an array.
    178  *
    179  * @see apply_filters() This function is identical, but the arguments passed to the
    180  * functions hooked to <tt>$tag</tt> are supplied using an array.
    181  *
    182  * @package WordPress
    183  * @subpackage Plugin
    184  * @since 3.0.0
    185  * @global array $wp_filter Stores all of the filters
    186  * @global array $merged_filters Merges the filter hooks using this function.
    187  * @global array $wp_current_filter stores the list of current filters with the current one last
    188  *
    189  * @param string $tag The name of the filter hook.
    190  * @param array $args The arguments supplied to the functions hooked to <tt>$tag</tt>
    191  * @return mixed The filtered value after all hooked functions are applied to it.
    192  */
    193 function apply_filters_ref_array($tag, $args) {
    194         global $wp_filter, $merged_filters, $wp_current_filter;
    195 
    196         $wp_current_filter[] = $tag;
    197 
    198         // Do 'all' actions first
    199         if ( isset($wp_filter['all']) ) {
    200                 $all_args = func_get_args();
    201                 _wp_call_all_hook($all_args);
    202         }
    203 
    204         if ( !isset($wp_filter[$tag]) ) {
    205                 array_pop($wp_current_filter);
    206                 return $args[0];
    207         }
    208 
    209         // Sort
    210         if ( !isset( $merged_filters[ $tag ] ) ) {
    211                 ksort($wp_filter[$tag]);
    212                 $merged_filters[ $tag ] = true;
    213         }
    214 
    215         reset( $wp_filter[ $tag ] );
    216 
    217         do {
    218                 foreach( (array) current($wp_filter[$tag]) as $the_ )
    219                         if ( !is_null($the_['function']) )
    220                                 $args[0] = call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
    221 
    222         } while ( next($wp_filter[$tag]) !== false );
    223 
    224         array_pop( $wp_current_filter );
    225 
    226         return $args[0];
    227 }
    228 
    229 /**
    230177 * Removes a function from a specified filter hook.
    231178 *
    232179 * This function removes a function attached to a specified filter hook. This
     
    420367}
    421368
    422369/**
    423  * Execute functions hooked on a specific action hook, specifying arguments in an array.
    424  *
    425  * @see do_action() This function is identical, but the arguments passed to the
    426  * functions hooked to <tt>$tag</tt> are supplied using an array.
    427  *
    428  * @package WordPress
    429  * @subpackage Plugin
    430  * @since 2.1
    431  * @global array $wp_filter Stores all of the filters
    432  * @global array $wp_actions Increments the amount of times action was triggered.
    433  *
    434  * @param string $tag The name of the action to be executed.
    435  * @param array $args The arguments supplied to the functions hooked to <tt>$tag</tt>
    436  * @return null Will return null if $tag does not exist in $wp_filter array
    437  */
    438 function do_action_ref_array($tag, $args) {
    439         global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter;
    440 
    441         if ( ! isset($wp_actions) )
    442                 $wp_actions = array();
    443 
    444         if ( ! isset($wp_actions[$tag]) )
    445                 $wp_actions[$tag] = 1;
    446         else
    447                 ++$wp_actions[$tag];
    448 
    449         $wp_current_filter[] = $tag;
    450 
    451         // Do 'all' actions first
    452         if ( isset($wp_filter['all']) ) {
    453                 $all_args = func_get_args();
    454                 _wp_call_all_hook($all_args);
    455         }
    456 
    457         if ( !isset($wp_filter[$tag]) ) {
    458                 array_pop($wp_current_filter);
    459                 return;
    460         }
    461 
    462         // Sort
    463         if ( !isset( $merged_filters[ $tag ] ) ) {
    464                 ksort($wp_filter[$tag]);
    465                 $merged_filters[ $tag ] = true;
    466         }
    467 
    468         reset( $wp_filter[ $tag ] );
    469 
    470         do {
    471                 foreach( (array) current($wp_filter[$tag]) as $the_ )
    472                         if ( !is_null($the_['function']) )
    473                                 call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
    474 
    475         } while ( next($wp_filter[$tag]) !== false );
    476 
    477         array_pop($wp_current_filter);
    478 }
    479 
    480 /**
    481370 * Check if any action has been registered for a hook.
    482371 *
    483372 * @package WordPress
  • wp-includes/deprecated.php

     
    26022602        return true;
    26032603}
    26042604
     2605
     2606/**
     2607 * Execute functions hooked on a specific action hook, specifying arguments in an array.
     2608 *
     2609 * @see do_action() This function is identical, but the arguments passed to the
     2610 * functions hooked to <tt>$tag</tt> are supplied using an array.
     2611 *
     2612 * @since 2.1
     2613 * @deprecated 3.2
     2614 *
     2615 * @param string $tag The name of the action to be executed.
     2616 * @param array $args The arguments supplied to the functions hooked to <tt>$tag</tt>
     2617 * @return null Will return null if $tag does not exist in $wp_filter array
     2618 */
     2619function do_action_ref_array( $tag, $args ) {
     2620        _deprecated_function( __FUNCTION__, '3.2', 'do_action()' );
     2621
     2622        array_unshift( $args, $tag );
     2623
     2624        return call_user_func_array( 'do_action', $args );
     2625}
     2626
     2627/**
     2628 * Execute functions hooked on a specific filter hook, specifying arguments in an array.
     2629 *
     2630 * @see apply_filters() This function is identical, but the arguments passed to the
     2631 * functions hooked to <tt>$tag</tt> are supplied using an array.
     2632 *
     2633 * @since 3.0
     2634 * @deprecated 3.2
     2635 *
     2636 * @param string $tag The name of the filter hook.
     2637 * @param array $args The arguments supplied to the functions hooked to <tt>$tag</tt>
     2638 * @return mixed The filtered value after all hooked functions are applied to it.
     2639 */
     2640function apply_filters_ref_array( $tag, $args ) {
     2641        _deprecated_function( __FUNCTION__, '3.2', 'apply_filters()' );
     2642
     2643        array_unshift( $args, $tag );
     2644
     2645        return call_user_func_array( 'apply_filters', $args );
     2646}
     2647