do_action

The timeline below displays how wordpress function do_action has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Calls the callback functions that have been added to an action hook.
 *
 * This function invokes all functions attached to action hook `$hook_name`.
 * It is possible to create new action hooks by simply calling this function,
 * specifying the name of the new hook using the `$hook_name` parameter.
 *
 * You can pass extra arguments to the hooks, much like you can with `apply_filters()`.
 *
 * Example usage:
 *
 *     // The action callback function.
 *     function example_callback( $arg1, $arg2 ) {
 *         // (maybe) do something with the args.
 *     }
 *     add_action( 'example_action', 'example_callback', 10, 2 );
 *
 *     /*
 *      * Trigger the actions by calling the 'example_callback()' function
 *      * that's hooked onto `example_action` above.
 *      *
 *      * - 'example_action' is the action hook.
 *      * - $arg1 and $arg2 are the additional arguments passed to the callback.
 *     do_action( 'example_action', $arg1, $arg2 );
 *
 * @since 1.2.0
 * @since 5.3.0 Formalized the existing and already documented `...$arg` parameter
 *              by adding it to the function signature.
 *
 * @global WP_Hook[] $wp_filter         Stores all of the filters and actions.
 * @global int[]     $wp_actions        Stores the number of times each action was triggered.
 * @global string[]  $wp_current_filter Stores the list of current filters with the current one last.
 *
 * @param string $hook_name The name of the action to be executed.
 * @param mixed  ...$arg    Optional. Additional arguments which are passed on to the
 *                          functions hooked to the action. Default empty.
 */
function do_action($hook_name, ...$arg)
{
    global $wp_filter, $wp_actions, $wp_current_filter;
    if (!isset($wp_actions[$hook_name])) {
        $wp_actions[$hook_name] = 1;
    } else {
        ++$wp_actions[$hook_name];
    }
    // Do 'all' actions first.
    if (isset($wp_filter['all'])) {
        $wp_current_filter[] = $hook_name;
        $all_args = func_get_args();
        // phpcs:ignore PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection
        _wp_call_all_hook($all_args);
    }
    if (!isset($wp_filter[$hook_name])) {
        if (isset($wp_filter['all'])) {
            array_pop($wp_current_filter);
        }
        return;
    }
    if (!isset($wp_filter['all'])) {
        $wp_current_filter[] = $hook_name;
    }
    if (empty($arg)) {
        $arg[] = '';
    } elseif (is_array($arg[0]) && 1 === count($arg[0]) && isset($arg[0][0]) && is_object($arg[0][0])) {
        // Backward compatibility for PHP4-style passing of `array( &$this )` as action `$arg`.
        $arg[0] = $arg[0][0];
    }
    $wp_filter[$hook_name]->do_action($arg);
    array_pop($wp_current_filter);
}

WordPress Version: 5.8

/**
 * Calls the callback functions that have been added to an action hook.
 *
 * This function invokes all functions attached to action hook `$hook_name`.
 * It is possible to create new action hooks by simply calling this function,
 * specifying the name of the new hook using the `$hook_name` parameter.
 *
 * You can pass extra arguments to the hooks, much like you can with `apply_filters()`.
 *
 * Example usage:
 *
 *     // The action callback function.
 *     function example_callback( $arg1, $arg2 ) {
 *         // (maybe) do something with the args.
 *     }
 *     add_action( 'example_action', 'example_callback', 10, 2 );
 *
 *     /*
 *      * Trigger the actions by calling the 'example_callback()' function
 *      * that's hooked onto `example_action` above.
 *      *
 *      * - 'example_action' is the action hook.
 *      * - $arg1 and $arg2 are the additional arguments passed to the callback.
 *     $value = do_action( 'example_action', $arg1, $arg2 );
 *
 * @since 1.2.0
 * @since 5.3.0 Formalized the existing and already documented `...$arg` parameter
 *              by adding it to the function signature.
 *
 * @global WP_Hook[] $wp_filter         Stores all of the filters and actions.
 * @global int[]     $wp_actions        Stores the number of times each action was triggered.
 * @global string[]  $wp_current_filter Stores the list of current filters with the current one last.
 *
 * @param string $hook_name The name of the action to be executed.
 * @param mixed  ...$arg    Optional. Additional arguments which are passed on to the
 *                          functions hooked to the action. Default empty.
 */
function do_action($hook_name, ...$arg)
{
    global $wp_filter, $wp_actions, $wp_current_filter;
    if (!isset($wp_actions[$hook_name])) {
        $wp_actions[$hook_name] = 1;
    } else {
        ++$wp_actions[$hook_name];
    }
    // Do 'all' actions first.
    if (isset($wp_filter['all'])) {
        $wp_current_filter[] = $hook_name;
        $all_args = func_get_args();
        // phpcs:ignore PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection
        _wp_call_all_hook($all_args);
    }
    if (!isset($wp_filter[$hook_name])) {
        if (isset($wp_filter['all'])) {
            array_pop($wp_current_filter);
        }
        return;
    }
    if (!isset($wp_filter['all'])) {
        $wp_current_filter[] = $hook_name;
    }
    if (empty($arg)) {
        $arg[] = '';
    } elseif (is_array($arg[0]) && 1 === count($arg[0]) && isset($arg[0][0]) && is_object($arg[0][0])) {
        // Backward compatibility for PHP4-style passing of `array( &$this )` as action `$arg`.
        $arg[0] = $arg[0][0];
    }
    $wp_filter[$hook_name]->do_action($arg);
    array_pop($wp_current_filter);
}

WordPress Version: 5.6

/**
 * 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()`.
 *
 * Example usage:
 *
 *     // The action callback function.
 *     function example_callback( $arg1, $arg2 ) {
 *         // (maybe) do something with the args.
 *     }
 *     add_action( 'example_action', 'example_callback', 10, 2 );
 *
 *     /*
 *      * Trigger the actions by calling the 'example_callback()' function
 *      * that's hooked onto `example_action` above.
 *      *
 *      * - 'example_action' is the action hook.
 *      * - $arg1 and $arg2 are the additional arguments passed to the callback.
 *     $value = do_action( 'example_action', $arg1, $arg2 );
 *
 * @since 1.2.0
 * @since 5.3.0 Formalized the existing and already documented `...$arg` parameter
 *              by adding it to the function signature.
 *
 * @global WP_Hook[] $wp_filter         Stores all of the filters and actions.
 * @global int[]     $wp_actions        Stores the number of times each action was triggered.
 * @global string[]  $wp_current_filter Stores the list of current filters with the current one last.
 *
 * @param string $tag    The name of the action to be executed.
 * @param mixed  ...$arg Optional. Additional arguments which are passed on to the
 *                       functions hooked to the action. Default empty.
 */
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();
        // phpcs:ignore PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection
        _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;
    }
    if (empty($arg)) {
        $arg[] = '';
    } elseif (is_array($arg[0]) && 1 === count($arg[0]) && isset($arg[0][0]) && is_object($arg[0][0])) {
        // Backward compatibility for PHP4-style passing of `array( &$this )` as action `$arg`.
        $arg[0] = $arg[0][0];
    }
    $wp_filter[$tag]->do_action($arg);
    array_pop($wp_current_filter);
}

WordPress Version: 5.5

/**
 * 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()`.
 *
 * Example usage:
 *
 *     // The action callback function.
 *     function example_callback( $arg1, $arg2 ) {
 *         // (maybe) do something with the args.
 *     }
 *     add_action( 'example_action', 'example_callback', 10, 2 );
 *
 *     /*
 *      * Trigger the actions by calling the 'example_callback()' function
 *      * that's hooked onto `example_action` above.
 *      *
 *      * - 'example_action' is the action hook.
 *      * - $arg1 and $arg2 are the additional arguments passed to the callback.
 *     $value = do_action( 'example_action', $arg1, $arg2 );
 *
 * @since 1.2.0
 * @since 5.3.0 Formalized the existing and already documented `...$arg` parameter
 *              by adding it to the function signature.
 *
 * @global array $wp_filter         Stores all of the filters and actions.
 * @global array $wp_actions        Increments the amount of times action was triggered.
 * @global array $wp_current_filter Stores the list of current filters with the current one last.
 *
 * @param string $tag    The name of the action to be executed.
 * @param mixed  ...$arg Optional. Additional arguments which are passed on to the
 *                       functions hooked to the action. Default empty.
 */
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();
        // phpcs:ignore PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection
        _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;
    }
    if (empty($arg)) {
        $arg[] = '';
    } elseif (is_array($arg[0]) && 1 === count($arg[0]) && isset($arg[0][0]) && is_object($arg[0][0])) {
        // Backward compatibility for PHP4-style passing of `array( &$this )` as action `$arg`.
        $arg[0] = $arg[0][0];
    }
    $wp_filter[$tag]->do_action($arg);
    array_pop($wp_current_filter);
}

WordPress Version: 5.4

/**
 * 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()`.
 *
 * Example usage:
 *
 *     // The action callback function.
 *     function example_callback( $arg1, $arg2 ) {
 *         // (maybe) do something with the args.
 *     }
 *     add_action( 'example_action', 'example_callback', 10, 2 );
 *
 *     /*
 *      * Trigger the actions by calling the 'example_callback()' function
 *      * that's hooked onto `example_action` above.
 *      *
 *      * - 'example_action' is the action hook.
 *      * - $arg1 and $arg2 are the additional arguments passed to the callback.
 *     $value = do_action( 'example_action', $arg1, $arg2 );
 *
 * @since 1.2.0
 * @since 5.3.0 Formalized the existing and already documented `...$arg` parameter
 *              by adding it to the function signature.
 *
 * @global array $wp_filter         Stores all of the filters and actions.
 * @global array $wp_actions        Increments the amount of times action was triggered.
 * @global array $wp_current_filter Stores the list of current filters with the current one last.
 *
 * @param string $tag    The name of the action to be executed.
 * @param mixed  ...$arg Optional. Additional arguments which are passed on to the
 *                       functions hooked to the action. Default empty.
 */
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;
    }
    if (empty($arg)) {
        $arg[] = '';
    } elseif (is_array($arg[0]) && 1 === count($arg[0]) && isset($arg[0][0]) && is_object($arg[0][0])) {
        // Backward compatibility for PHP4-style passing of `array( &$this )` as action `$arg`.
        $arg[0] = $arg[0][0];
    }
    $wp_filter[$tag]->do_action($arg);
    array_pop($wp_current_filter);
}

WordPress Version: 5.3

/**
 * 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()`.
 *
 * Example usage:
 *
 *     // The action callback function
 *     function example_callback( $arg1, $arg2 ) {
 *         // (maybe) do something with the args
 *     }
 *     add_action( 'example_action', 'example_callback', 10, 2 );
 *
 *     /*
 *      * Trigger the actions by calling the 'example_callback()' function that's
 *      * hooked onto `example_action` above.
 *      *
 *      * - 'example_action' is the action hook
 *      * - $arg1 and $arg2 are the additional arguments passed to the callback.
 *     $value = do_action( 'example_action', $arg1, $arg2 );
 *
 * @since 1.2.0
 * @since 5.3.0 Formalized the existing and already documented `...$arg` parameter
 *              by adding it to the function signature.
 *
 * @global array $wp_filter         Stores all of the filters
 * @global array $wp_actions        Increments the amount of times action was triggered.
 * @global array $wp_current_filter Stores the list of current filters with the current one last
 *
 * @param string $tag    The name of the action to be executed.
 * @param mixed  ...$arg Optional. Additional arguments which are passed on to the
 *                       functions hooked to the action. Default empty.
 */
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;
    }
    if (empty($arg)) {
        $arg[] = '';
    } elseif (is_array($arg[0]) && 1 === count($arg[0]) && isset($arg[0][0]) && is_object($arg[0][0])) {
        // Backward compatibility for PHP4-style passing of `array( &$this )` as action `$arg`.
        $arg[0] = $arg[0][0];
    }
    $wp_filter[$tag]->do_action($arg);
    array_pop($wp_current_filter);
}

WordPress Version: 4.7

/**
 * 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().
 *
 * @since 1.2.0
 *
 * @global array $wp_filter         Stores all of the filters
 * @global array $wp_actions        Increments the amount of times action was triggered.
 * @global array $wp_current_filter Stores the list of current filters with the current one last
 *
 * @param string $tag     The name of the action to be executed.
 * @param mixed  $arg,... Optional. Additional arguments which are passed on to the
 *                        functions hooked to the action. Default empty.
 */
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);
}

WordPress Version: 4.6

/**
 * 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().
 *
 * @since 1.2.0
 *
 * @global array $wp_filter         Stores all of the filters
 * @global array $wp_actions        Increments the amount of times action was triggered.
 * @global array $merged_filters    Merges the filter hooks using this function.
 * @global array $wp_current_filter Stores the list of current filters with the current one last
 *
 * @param string $tag     The name of the action to be executed.
 * @param mixed  $arg,... Optional. Additional arguments which are passed on to the
 *                        functions hooked to the action. Default empty.
 */
function do_action($tag, $arg = '')
{
    global $wp_filter, $wp_actions, $merged_filters, $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);
    }
    // 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);
}

WordPress Version: 4.5

/**
 * 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
 * {@see apply_filters()}.
 *
 * @since 1.2.0
 *
 * @global array $wp_filter         Stores all of the filters
 * @global array $wp_actions        Increments the amount of times action was triggered.
 * @global array $merged_filters    Merges the filter hooks using this function.
 * @global array $wp_current_filter Stores the list of current filters with the current one last
 *
 * @param string $tag     The name of the action to be executed.
 * @param mixed  $arg,... Optional. Additional arguments which are passed on to the
 *                        functions hooked to the action. Default empty.
 */
function do_action($tag, $arg = '')
{
    global $wp_filter, $wp_actions, $merged_filters, $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);
    }
    // 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);
}

WordPress Version: 4.3

/**
 * 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
 * {@see apply_filters()}.
 *
 * @since 1.2.0
 *
 * @global array $wp_filter         Stores all of the filters
 * @global array $wp_actions        Increments the amount of times action was triggered.
 * @global array $merged_filters    Merges the filter hooks using this function.
 * @global array $wp_current_filter Stores the list of current filters with the current one last
 *
 * @param string $tag The name of the action to be executed.
 * @param mixed  $arg Optional. Additional arguments which are passed on to the
 *                    functions hooked to the action. Default empty.
 */
function do_action($tag, $arg = '')
{
    global $wp_filter, $wp_actions, $merged_filters, $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);
    }
    // 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);
}

WordPress Version: 4.2

/**
 * 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
 * {@see apply_filters()}.
 *
 * @since 1.2.0
 *
 * @global array $wp_filter  Stores all of the filters
 * @global array $wp_actions Increments the amount of times action was triggered.
 *
 * @param string $tag The name of the action to be executed.
 * @param mixed  $arg Optional. Additional arguments which are passed on to the
 *                    functions hooked to the action. Default empty.
 * @return null Will return null if $tag does not exist in $wp_filter array.
 */
function do_action($tag, $arg = '')
{
    global $wp_filter, $wp_actions, $merged_filters, $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);
    }
    // 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);
}

WordPress Version: 4.1

/**
 * 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
 * {@see apply_filters()}.
 *
 * @since 1.2.0
 *
 * @global array $wp_filter  Stores all of the filters
 * @global array $wp_actions Increments the amount of times action was triggered.
 *
 * @param string $tag The name of the action to be executed.
 * @param mixed  $arg Optional. Additional arguments which are passed on to the
 *                    functions hooked to the action. Default empty.
 * @return null Will return null if $tag does not exist in $wp_filter array.
 */
function do_action($tag, $arg = '')
{
    global $wp_filter, $wp_actions, $merged_filters, $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; $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);
}

WordPress Version: 4.0

/**
 * 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 <tt>$tag</tt> parameter.
 *
 * You can pass extra arguments to the hooks, much like you can with
 * apply_filters().
 *
 * @since 1.2.0
 *
 * @see apply_filters() This function works similar with the exception that nothing
 *                      is returned and only the functions or methods are called.
 * @global array $wp_filter  Stores all of the filters
 * @global array $wp_actions Increments the amount of times action was triggered.
 *
 * @param string $tag The name of the action to be executed.
 * @param mixed  $arg Optional. Additional arguments which are passed on to the
 *                    functions hooked to the action. Default empty.
 * @return null Will return null if $tag does not exist in $wp_filter array.
 */
function do_action($tag, $arg = '')
{
    global $wp_filter, $wp_actions, $merged_filters, $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; $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);
}

WordPress Version: 3.9

/**
 * 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 <tt>$tag</tt> parameter.
 *
 * You can pass extra arguments to the hooks, much like you can with
 * apply_filters().
 *
 * @see apply_filters() This function works similar with the exception that
 * nothing is returned and only the functions or methods are called.
 *
 * @since 1.2.0
 *
 * @global array $wp_filter Stores all of the filters
 * @global array $wp_actions Increments the amount of times action was triggered.
 *
 * @param string $tag The name of the action to be executed.
 * @param mixed $arg,... Optional additional arguments which are passed on to the functions hooked to the action.
 * @return null Will return null if $tag does not exist in $wp_filter array
 */
function do_action($tag, $arg = '')
{
    global $wp_filter, $wp_actions, $merged_filters, $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; $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);
}

WordPress Version: 3.7

/**
 * 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 <tt>$tag</tt> parameter.
 *
 * You can pass extra arguments to the hooks, much like you can with
 * apply_filters().
 *
 * @see apply_filters() This function works similar with the exception that
 * nothing is returned and only the functions or methods are called.
 *
 * @package WordPress
 * @subpackage Plugin
 * @since 1.2
 * @global array $wp_filter Stores all of the filters
 * @global array $wp_actions Increments the amount of times action was triggered.
 *
 * @param string $tag The name of the action to be executed.
 * @param mixed $arg,... Optional additional arguments which are passed on to the functions hooked to the action.
 * @return null Will return null if $tag does not exist in $wp_filter array
 */
function do_action($tag, $arg = '')
{
    global $wp_filter, $wp_actions, $merged_filters, $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; $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);
}