Add_action function in wordpress

Well, learn to create a wordpress plugin, I downloaded one and read the codes, and I saw this. I assume that "foo" is the tag into which the action will be added.

but what exactly does array () do?

add_action('foo', array('foo1', 'foo2'));

I looked at http://codex.wordpress.org/Function_Reference/add_action and there is no clear definition about this.

+3
source share
2 answers

That's right, the first argument is the tag (to which you will add the action), and the second argument indicates the function to call (i.e. your callback).

PHP , , . :

PHP- -

, , 2. , , .

, , , , , , foo(), foo1->foo2().

+3

add_action - , hook.

function hello_header() {
 echo "I'm in the header!"; 
}

add_action('wp_head', 'hello_header');

- , .

, call_user_func. .

http://us2.php.net/manual/en/language.pseudo-types.php#language.types.callback

+2

Source: https://habr.com/ru/post/1762221/


All Articles