Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




do_action [ WordPress Function ]

do_action ( $tag, $arg = '' )
Parameters:
  • (string) $tag The name of the action to be executed.
  • (mixed) $arg,... Optional additional arguments which are passed on to the functions hooked to the action.
See:
Returns:
  • (null) Will return null if $tag does not exist in $wp_filter array
Defined at:



Execute functions hooked on a specific action hook.

This function invokes all functions attached to action hook $tag. It is possible to create new action hooks by simply calling this function, specifying the name of the new hook using the $tag parameter.

You can pass extra arguments to the hooks, much like you can with apply_filters().

Source


<?php
function do_action($tag$arg '') {
    global 
$wp_filter$wp_actions$merged_filters$wp_current_filter;

    if ( ! isset(
$wp_actions) )
        
$wp_actions = array();

    if ( ! isset(
$wp_actions[$tag]) )
        
$wp_actions[$tag] = 1;
    else
        ++
$wp_actions[$tag];

    
// Do 'all' actions first
    
if ( isset($wp_filter['all']) ) {
        
$wp_current_filter[] = $tag;
        
$all_args func_get_args();
        
_wp_call_all_hook($all_args);
    }

    if ( !isset(
$wp_filter[$tag]) ) {
        if ( isset(
$wp_filter['all']) )
            
array_pop($wp_current_filter);
        return;
    }

    if ( !isset(
$wp_filter['all']) )
        
$wp_current_filter[] = $tag;

    
$args = array();
    if ( 
is_array($arg) && == count($arg) && isset($arg[0]) && is_object($arg[0]) ) // array(&$this)
        
$args[] =& $arg[0];
    else
        
$args[] = $arg;
    for ( 
$a 2$a func_num_args(); $a++ )
        
$args[] = func_get_arg($a);

    
// Sort
    
if ( !isset( $merged_filters$tag ] ) ) {
        
ksort($wp_filter[$tag]);
        
$merged_filters$tag ] = true;
    }

    
reset$wp_filter$tag ] );

    do {
        foreach ( (array) 
current($wp_filter[$tag]) as $the_ )
            if ( !
is_null($the_['function']) )
                
call_user_func_array($the_['function'], array_slice($args0, (int) $the_['accepted_args']));

    } while ( 
next($wp_filter[$tag]) !== false );

    
array_pop($wp_current_filter);
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics