Home / APIs / do_action() – Execute functions hooked on a specific action hook.

You appear to be a bot. Output may be restricted

Description

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().

Usage

do_action( $tag, $arg );

Parameters

$tag
( string ) required – The name of the action to be executed.
$arg
( mixed ) optional –

Returns

void

Source

File name: wordpress/wp-includes/plugin.php
Lines: 1 to 36 of 36

function do_action($tag, $arg = '') {
  global $wp_filter, $wp_actions, $wp_current_filter;

  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, $num = func_num_args(); $a < $num; $a++ )
    $args[] = func_get_arg($a);

  $wp_filter[ $tag ]->do_action( $args );

  array_pop($wp_current_filter);
}
 

 View on GitHub View on Trac

Published: 12th March 2017 | Last updated: 12th March 2017

Information

Function name: do_action
Plugin ref: WordPress
Version: 5.0.3
Sourcefile: wp-includes/plugin.php
File ref: wp-includes/plugin.php
Deprecated?: No
API Letters: A,D

  • Plugins
  • Themes
  • Shortcodes
  • APIs
  • Files
  • Hooks
  • Classes
  • Sites
  • Sitemap
  • Blog
WooCommerce a2z WooCommerce a2z
WooCommerce

Site:  woocommerce.wp-a2z.org
© Copyright WooCommerce a2z 2014-2019. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins