WP_HTTP_Requests_Hooks

Bridge to connect Requests internal hooks to WordPress actions.

Defined (1)

The class is defined in the following location(s).

/wp-includes/class-wp-http-requests-hooks.php  
  1. class WP_HTTP_Requests_Hooks extends Requests_Hooks { 
  2. /** 
  3. * Requested URL. 
  4. * @var string Requested URL. 
  5. */ 
  6. protected $url; 
  7.  
  8. /** 
  9. * WordPress WP_HTTP request data. 
  10. * @var array Request data in WP_Http format. 
  11. */ 
  12. protected $request = array(); 
  13.  
  14. /** 
  15. * Constructor. 
  16. * @param string $url URL to request. 
  17. * @param array $request Request data in WP_Http format. 
  18. */ 
  19. public function __construct( $url, $request ) { 
  20. $this->url = $url; 
  21. $this->request = $request; 
  22.  
  23. /** 
  24. * Dispatch a Requests hook to a native WordPress action. 
  25. * @param string $hook Hook name. 
  26. * @param array $parameters Parameters to pass to callbacks. 
  27. * @return boolean True if hooks were run, false if nothing was hooked. 
  28. */ 
  29. public function dispatch( $hook, $parameters = array() ) { 
  30. $result = parent::dispatch( $hook, $parameters ); 
  31.  
  32. // Handle back-compat actions 
  33. switch ( $hook ) { 
  34. case 'curl.before_send': 
  35. /** This action is documented in wp-includes/class-wp-http-curl.php */ 
  36. do_action_ref_array( 'http_api_curl', array( &$parameters[0], $this->request, $this->url ) ); 
  37. break; 
  38.  
  39. /** 
  40. * Transforms a native Request hook to a WordPress actions. 
  41. * This action maps Requests internal hook to a native WordPress action. 
  42. * @see https://github.com/rmccue/Requests/blob/master/docs/hooks.md 
  43. * @param array $parameters Parameters from Requests internal hook. 
  44. * @param array $request Request data in WP_Http format. 
  45. * @param string $url URL to request. 
  46. */ 
  47. do_action_ref_array( "requests-{$hook}", $parameters, $this->request, $this->url ); 
  48.  
  49. return $result;