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()


Top ↑

Return

(boolean) Successfulness


Top ↑

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;
	}

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.