Solution:2
Two Types of WordPress Hooks: Actions and Filters
WordPress includes two types of hooks called Actions and Filters. Actions let you do something at certain predefined points in the WordPress runtime, while Filters let you modify any data processed by WordPress and return
it.
Actions are defined in the WordPress code as:
do_action( 'action_name', [optional_arguments] );
The action_name
string is the name of the action. You can specify the [optional_arguments]
variable to pass additional arguments to the callback function. If this field is not specified, then its default value will be empty.
Example: The do_action( 'wp_head' )
action can be hooked in to run custom code every time WordPress processes the site header. This action doesn’t have any other arguments.
Filters are defined in the WordPress code as:
apply_filters( 'filter_name', 'value_to_be_filtered', [optional_arguments] );
The filter_name
string is the name of the filter, the value_to_be_filtered
variable is the value that needs to be filtered and returned, and the [optional_arguments]
variable can pass additional arguments, just like with actions.
Example: The apply_filters( 'admin_footer_text' , string $text )
filter can be hooked in to modify the text displayed in the admin footer. As of WordPress 5.4, its default value will display the sentence Thank you for creating with WordPress.
in the admin area footer.