Add a filter/docs: 'oembed_remote_get_args' to WP_oEmbed->discover()
and ->_fetch_with_format()
.
Props leewillis77, DrewAPicture. Fixes #23442. git-svn-id: https://develop.svn.wordpress.org/trunk@28815 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
220fda0095
commit
f5bda24b70
@ -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
Block a user