首页 WordPress函数大全 do_action()

do_action()

2020-05-01 / 2688阅 / 悠然

如何你看完本文还不知道如何使用该函数,可以联系我定制视频教程,50元/个函数,学不会全额退款

do_action( string $tag, mixed $arg )

Execute functions hooked>

Contents

  • Description
    • Parameters
    • Source
    • Changelog
  • Related
    • Uses
    • Used By
  • User Contributed Notes

描述

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>

参数

$tag

(string)
(Required)
The name of the action to be executed.

$arg

(mixed)
(Optional)
Additional arguments which are passed on to the functions hooked to the action. Default empty.

大家谈论
    我的见解