# Hook Server
do_action: pre-embedded hook, each time the [same parameter] is given to the callback function of the hook do_action(hook name, callback parameters)
apply_filters: Pre-embedded filters: each time the callback function of the hook takes [the result of the last filter as a parameter] filter result = apply_filters(hook name, callback parameter to filter)
add_action: add a hook action, and link the operation at the pre-embedded hook add_action(hook name, callback function, priority)
add_filter: add a hook filter, process parameters at the embedded filter, and return data add_filter(hook name, callback function, priority)
Priority: The default is 10, and multiple actions or filters with the same hook name can be added. The higher priority is executed first, and the same priority is executed according to the order of addition.
Notice:
- Action names of Action and Filter [do not repeat]
- The difference from WP is that there is only one callback parameter. So when add is not needed, the priority is followed by the number of arguments. If multiple parameters are required, please use Object to implement, such as:
Pre-buried:
var arg1 = 'xxx', arg2 = 'xxx';
do_action( 'action_name', {arg1,arg2} );
Use hooks:
add_action( 'action_name', ( {arg1,arg2} ) => {
console.log( arg1, arg2 );
} );