diff -r 490d5cc509ed -r cf61fcea0001 wp/wp-includes/class-wp-http-requests-hooks.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wp/wp-includes/class-wp-http-requests-hooks.php Mon Oct 14 17:39:30 2019 +0200 @@ -0,0 +1,76 @@ +url = $url; + $this->request = $request; + } + + /** + * Dispatch a Requests hook to a native WordPress action. + * + * @param string $hook Hook name. + * @param array $parameters Parameters to pass to callbacks. + * @return boolean True if hooks were run, false if nothing was hooked. + */ + 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 actions. + * + * This action maps Requests internal hook to a native WordPress action. + * + * @see https://github.com/rmccue/Requests/blob/master/docs/hooks.md + * + * @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 ); + + return $result; + } +}