do_action [ WordPress Function ]
| Parameters: |
|
| See: | |
| Returns: |
|
| 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) && 1 == 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($args, 0, (int) $the_['accepted_args']));
} while ( next($wp_filter[$tag]) !== false );
array_pop($wp_current_filter);
}
?>
Examples [ wp-snippets.com ]
Google Arama Sonuçlarý
- Function Reference/do action « WordPress Codex
Description. Executes a hook created by add_action. Usage. <?php do_action( $ tag, $arg ); ?> Multiple Arguments: <?php do_action( $tag, $arg_a, $arg_b, $etc ) ...
codex.wordpress.org - WordPress › Support » do_action
I need help trying to understand how do_action works. I am trying to modify the login function of WordPress. I'm looking for the do_action('wp_authenicate', ...
wordpress.org - Frumph.NET - Understanding do_action() and add_action ...
Jun 14, 2010 ... The do_action(), add_action() functions of WP are a great tool to use. These functions in wordpress allow you to specify a point in the code to ...
frumph.net - do_action bbp template notices ? « bbPress Support Forums
What does <?php do_action( 'bbp_template_notices' ); ?> ... So they call a function by the plugin DO_ACTION PHP code but i can't find the ...
bbpress.org
Kullanýcý Tartýþmalarý [ wordpress.org ]
- bgentry on "do_action is not passing objects as arguments correctly"
- Dale Sattler on "Best option to allow for overriding of a plugin function"
- Zatsugami on "do_action issue with parameters handling"
- Zatsugami on "do_action issue with parameters handling"
- manoj insa on "Understanding difference between do_action & add_action"
- esmi on "Understanding difference between do_action & add_action"
- weex on "Understanding difference between do_action & add_action"
- zudie on "Difference between my_footer($args) and do_action(my_footer,$args)"
- Alex Rabe on "[nextgen-gallery] Add do_action(ngg_upload_complete)"
- comstar on "[nextgen-gallery] Add do_action(ngg_upload_complete)"