WP_HTTP_Requests_Hooks::dispatch() WordPress Method

The dispatch() method is the central method of the WP_HTTP_Requests_Hooks class. It is responsible for dispatching HTTP requests to the appropriate methods. The dispatch() method is called by the run() method.

WP_HTTP_Requests_Hooks::dispatch( string $hook, array $parameters = array() ) #

Dispatch a Requests hook to a native WordPress action.


Parameters

$hook

(string)(Required)Hook name.

$parameters

(array)(Optional)Parameters to pass to callbacks.

Default value: array()


Top ↑

Return

(bool) True if hooks were run, false if nothing was hooked.


Top ↑

Source

File: wp-includes/class-wp-http-requests-hooks.php

	public function dispatch( $hook, $parameters = array() ) {
		$result = parent::dispatch( $hook, $parameters );

		// Handle back-compat actions.
		switch ( $hook ) {
			case 'curl.before_send':
				/** This action is documented in wp-includes/class-wp-http-curl.php */
				do_action_ref_array( 'http_api_curl', array( &$parameters[0], $this->request, $this->url ) );
				break;
		}

		/**
		 * Transforms a native Request hook to a WordPress action.
		 *
		 * This action maps Requests internal hook to a native WordPress action.
		 *
		 * @see https://github.com/WordPress/Requests/blob/master/docs/hooks.md
		 *
		 * @since 4.7.0
		 *
		 * @param array $parameters Parameters from Requests internal hook.
		 * @param array $request Request data in WP_Http format.
		 * @param string $url URL to request.
		 */
		do_action_ref_array( "requests-{$hook}", $parameters, $this->request, $this->url ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores

		return $result;
	}

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.