Requests_Hooks::dispatch() WordPress Method
This is the main entry point for the hooks system. It is used to call any registered hooks. Hooks are a powerful way to modify the behavior of WordPress. They allow you to change how WordPress does things without having to edit any core code. There are two types of hooks: actions and filters. Actions are functions that are run when a certain event happens. For example, the 'init' action is run when WordPress is initializing. Filters are functions that modify data before it is saved or displayed. For example, the 'content_save_pre' filter is run before the content is saved to the database. The dispatch() method takes two arguments: the hook name and an optional array of data. The hook name is the name of the action or filter you want to run. The data array is an optional array of data that will be passed to the hook function. So, if you want to run the 'content_save_pre' filter, you would use the following code: $data = array( 'post_content' => 'This is the content of my post.' ); $data = Requests_Hooks::dispatch( 'content_save_pre', $data );
Requests_Hooks::dispatch( string $hook, array $parameters = array() ) #
Dispatch a message
Parameters
- $hook
(string)(Required)Hook name
- $parameters
(array)(Optional)Parameters to pass to callbacks
Default value: array()
Return
(boolean) Successfulness
Source
File: wp-includes/Requests/Hooks.php
public function dispatch($hook, $parameters = array()) { if (empty($this->hooks[$hook])) { return false; } foreach ($this->hooks[$hook] as $priority => $hooked) { foreach ($hooked as $callback) { call_user_func_array($callback, $parameters); } } return true; }
Expand full source codeCollapse full source codeView on TracView on GitHub