mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-08 20:01:12 +01:00
47c4ff7102
Reverting Requests 2.0.0 changes and moving to WordPress 6.0 cycle. Why? The namespace and file case renaming revealed 2 issues in Core's upgrader process. See https://core.trac.wordpress.org/ticket/54504#comment:22 for more information. Follow-up to [52327]. See #54562, #54504. Built from https://develop.svn.wordpress.org/trunk@52328 git-svn-id: http://core.svn.wordpress.org/trunk@51920 1a063a9b-81f0-0310-95a4-ce76da25c4cd
79 lines
1.9 KiB
PHP
79 lines
1.9 KiB
PHP
<?php
|
|
/**
|
|
* HTTP API: Requests hook bridge class
|
|
*
|
|
* @package WordPress
|
|
* @subpackage HTTP
|
|
* @since 4.7.0
|
|
*/
|
|
|
|
/**
|
|
* Bridge to connect Requests internal hooks to WordPress actions.
|
|
*
|
|
* @since 4.7.0
|
|
*
|
|
* @see Requests_Hooks
|
|
*/
|
|
class WP_HTTP_Requests_Hooks extends Requests_Hooks {
|
|
/**
|
|
* Requested URL.
|
|
*
|
|
* @var string Requested URL.
|
|
*/
|
|
protected $url;
|
|
|
|
/**
|
|
* WordPress WP_HTTP request data.
|
|
*
|
|
* @var array Request data in WP_Http format.
|
|
*/
|
|
protected $request = array();
|
|
|
|
/**
|
|
* Constructor.
|
|
*
|
|
* @param string $url URL to request.
|
|
* @param array $request Request data in WP_Http format.
|
|
*/
|
|
public function __construct( $url, $request ) {
|
|
$this->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 bool 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 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;
|
|
}
|
|
}
|