From f5bda24b70b90ad631ab63e40eb00410622e0de0 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Tue, 24 Jun 2014 00:27:55 +0000 Subject: [PATCH] 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 --- src/wp-includes/class-oembed.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/class-oembed.php b/src/wp-includes/class-oembed.php index e856683057..11f35381bd 100644 --- a/src/wp-includes/class-oembed.php +++ b/src/wp-includes/class-oembed.php @@ -171,8 +171,20 @@ class WP_oEmbed { public function discover( $url ) { $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 - $request = wp_safe_remote_get( $url ); + $request = wp_safe_remote_get( $url, $args ); if ( $html = wp_remote_retrieve_body( $request ) ) { /** @@ -272,7 +284,11 @@ class WP_oEmbed { */ private function _fetch_with_format( $provider_url_with_args, $format ) { $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 ) ) return new WP_Error( 'not-implemented' ); if ( ! $body = wp_remote_retrieve_body( $response ) )