[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/ -> class-wp-http-requests-hooks.php (source)

   1  <?php
   2  /**
   3   * HTTP API: Requests hook bridge class
   4   *
   5   * @package WordPress
   6   * @subpackage HTTP
   7   * @since 4.7.0
   8   */
   9  
  10  /**
  11   * Bridge to connect Requests internal hooks to WordPress actions.
  12   *
  13   * @since 4.7.0
  14   *
  15   * @see Requests_Hooks
  16   */
  17  class WP_HTTP_Requests_Hooks extends Requests_Hooks {
  18      /**
  19       * Requested URL.
  20       *
  21       * @var string Requested URL.
  22       */
  23      protected $url;
  24  
  25      /**
  26       * WordPress WP_HTTP request data.
  27       *
  28       * @var array Request data in WP_Http format.
  29       */
  30      protected $request = array();
  31  
  32      /**
  33       * Constructor.
  34       *
  35       * @param string $url     URL to request.
  36       * @param array  $request Request data in WP_Http format.
  37       */
  38  	public function __construct( $url, $request ) {
  39          $this->url     = $url;
  40          $this->request = $request;
  41      }
  42  
  43      /**
  44       * Dispatch a Requests hook to a native WordPress action.
  45       *
  46       * @param string $hook       Hook name.
  47       * @param array  $parameters Parameters to pass to callbacks.
  48       * @return bool True if hooks were run, false if nothing was hooked.
  49       */
  50  	public function dispatch( $hook, $parameters = array() ) {
  51          $result = parent::dispatch( $hook, $parameters );
  52  
  53          // Handle back-compat actions.
  54          switch ( $hook ) {
  55              case 'curl.before_send':
  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 ) );
  58                  break;
  59          }
  60  
  61          /**
  62           * Transforms a native Request hook to a WordPress action.
  63           *
  64           * This action maps Requests internal hook to a native WordPress action.
  65           *
  66           * @see https://github.com/WordPress/Requests/blob/master/docs/hooks.md
  67           *
  68           * @since 4.7.0
  69           *
  70           * @param array $parameters Parameters from Requests internal hook.
  71           * @param array $request Request data in WP_Http format.
  72           * @param string $url URL to request.
  73           */
  74          do_action_ref_array( "requests-{$hook}", $parameters, $this->request, $this->url ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
  75  
  76          return $result;
  77      }
  78  }


Generated: Wed Dec 25 01:00:02 2024 Cross-referenced by PHPXref 0.7.1