Add a filter/docs: 'oembed_remote_get_args' to `WP_oEmbed->discover()` and `->_fetch_with_format()`.
Props leewillis77, DrewAPicture. Fixes #23442. Built from https://develop.svn.wordpress.org/trunk@28815 git-svn-id: http://core.svn.wordpress.org/trunk@28622 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
3ebd519a3e
commit
04933ab8cf
|
@ -171,8 +171,20 @@ class WP_oEmbed {
|
||||||
public function discover( $url ) {
|
public function discover( $url ) {
|
||||||
$providers = array();
|
$providers = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter oEmbed remote get arguments.
|
||||||
|
*
|
||||||
|
* @since 4.0.0
|
||||||
|
*
|
||||||
|
* @see WP_Http::request()
|
||||||
|
*
|
||||||
|
* @param array $args oEmbed remote get arguments.
|
||||||
|
* @param string $url URL to be inspected.
|
||||||
|
*/
|
||||||
|
$args = apply_filters( 'oembed_remote_get_args', array(), $url );
|
||||||
|
|
||||||
// Fetch URL content
|
// Fetch URL content
|
||||||
$request = wp_safe_remote_get( $url );
|
$request = wp_safe_remote_get( $url, $args );
|
||||||
if ( $html = wp_remote_retrieve_body( $request ) ) {
|
if ( $html = wp_remote_retrieve_body( $request ) ) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -272,7 +284,11 @@ class WP_oEmbed {
|
||||||
*/
|
*/
|
||||||
private function _fetch_with_format( $provider_url_with_args, $format ) {
|
private function _fetch_with_format( $provider_url_with_args, $format ) {
|
||||||
$provider_url_with_args = add_query_arg( 'format', $format, $provider_url_with_args );
|
$provider_url_with_args = add_query_arg( 'format', $format, $provider_url_with_args );
|
||||||
$response = wp_safe_remote_get( $provider_url_with_args );
|
|
||||||
|
/** This filter is documented in wp-includes/class-oembed.php */
|
||||||
|
$args = apply_filters( 'oembed_remote_get_args', array(), $provider_url_with_args );
|
||||||
|
|
||||||
|
$response = wp_safe_remote_get( $provider_url_with_args, $args );
|
||||||
if ( 501 == wp_remote_retrieve_response_code( $response ) )
|
if ( 501 == wp_remote_retrieve_response_code( $response ) )
|
||||||
return new WP_Error( 'not-implemented' );
|
return new WP_Error( 'not-implemented' );
|
||||||
if ( ! $body = wp_remote_retrieve_body( $response ) )
|
if ( ! $body = wp_remote_retrieve_body( $response ) )
|
||||||
|
|
Loading…
Reference in New Issue