wp/wp-includes/class-wp-http-requests-hooks.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
    30 	protected $request = array();
    30 	protected $request = array();
    31 
    31 
    32 	/**
    32 	/**
    33 	 * Constructor.
    33 	 * Constructor.
    34 	 *
    34 	 *
    35 	 * @param string $url URL to request.
    35 	 * @param string $url     URL to request.
    36 	 * @param array $request Request data in WP_Http format.
    36 	 * @param array  $request Request data in WP_Http format.
    37 	 */
    37 	 */
    38 	public function __construct( $url, $request ) {
    38 	public function __construct( $url, $request ) {
    39 		$this->url     = $url;
    39 		$this->url     = $url;
    40 		$this->request = $request;
    40 		$this->request = $request;
    41 	}
    41 	}
    42 
    42 
    43 	/**
    43 	/**
    44 	 * Dispatch a Requests hook to a native WordPress action.
    44 	 * Dispatch a Requests hook to a native WordPress action.
    45 	 *
    45 	 *
    46 	 * @param string $hook Hook name.
    46 	 * @param string $hook       Hook name.
    47 	 * @param array $parameters Parameters to pass to callbacks.
    47 	 * @param array  $parameters Parameters to pass to callbacks.
    48 	 * @return boolean True if hooks were run, false if nothing was hooked.
    48 	 * @return boolean True if hooks were run, false if nothing was hooked.
    49 	 */
    49 	 */
    50 	public function dispatch( $hook, $parameters = array() ) {
    50 	public function dispatch( $hook, $parameters = array() ) {
    51 		$result = parent::dispatch( $hook, $parameters );
    51 		$result = parent::dispatch( $hook, $parameters );
    52 
    52 
    53 		// Handle back-compat actions
    53 		// Handle back-compat actions.
    54 		switch ( $hook ) {
    54 		switch ( $hook ) {
    55 			case 'curl.before_send':
    55 			case 'curl.before_send':
    56 				/** This action is documented in wp-includes/class-wp-http-curl.php */
    56 				/** This action is documented in wp-includes/class-wp-http-curl.php */
    57 				do_action_ref_array( 'http_api_curl', array( &$parameters[0], $this->request, $this->url ) );
    57 				do_action_ref_array( 'http_api_curl', array( &$parameters[0], $this->request, $this->url ) );
    58 				break;
    58 				break;
    67 		 *
    67 		 *
    68 		 * @param array $parameters Parameters from Requests internal hook.
    68 		 * @param array $parameters Parameters from Requests internal hook.
    69 		 * @param array $request Request data in WP_Http format.
    69 		 * @param array $request Request data in WP_Http format.
    70 		 * @param string $url URL to request.
    70 		 * @param string $url URL to request.
    71 		 */
    71 		 */
    72 		do_action_ref_array( "requests-{$hook}", $parameters, $this->request, $this->url );
    72 		do_action_ref_array( "requests-{$hook}", $parameters, $this->request, $this->url ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
    73 
    73 
    74 		return $result;
    74 		return $result;
    75 	}
    75 	}
    76 }
    76 }