Hooks Functions
add_action() ----------Hangs a function on an event.
remove_action() ----------Deletes a function from the event.
did_action() ----------Gets a number of how many times the event was performed.
do_action() ----------Creates an event.
do_action_ref_array() ----------Creates an event. Arguments are passed in an array.
has_action() ----------Checks whether a function is hung on the event.
current_action() ----------Gets the name of the current event.
doing_action() ----------Checks if the event is being processed at the moment.
remove_all_actions() ----------Deletes all functions attached to the event.
add_filter() ----------Hangs a function on a filter.
remove_filter() ----------Deletes a function from the filter.
apply_filters() ----------Creates a filter.
apply_filters_ref_array() ----------Creates a filter. Arguments are passed in an array.
has_filter() ----------Checks whether the function is hung on the filter.
current_filter() ----------Gets the name of the current filter.
doing_filter() ----------Checks if the filter is currently being processed.
remove_all_filters() ----------Deletes all functions attached to the filter.
function my_filter_function( $str ){
return 'Hello '. $str;
}
// Let's attach a function to the filter
add_filter( 'my_filter', 'my_filter_function' );
// Call the filter
echo apply_filters( 'my_filter', 'John' ); //> Hello John
// Create a function for the event
function my_action_function( $text ){
echo 'The my_action event has been triggered just now.';
}
// Let's attach the function to the my_action event
add_action( 'my_action', 'my_action_function' );
// Action call
do_action( 'my_action' ); //> The my_action event has been triggered just now.