REST API: Add endpoint for proxying requests to external oEmbed providers.
This endpoint is a prerequisite for the media widgets work (see https://github.com/xwp/wp-core-media-widgets). Also use the new endpoint in the media modal instead of the `parse-embed` AJAX action. Props westonruter, timmydcrawford, swissspidy, jnylen0. Fixes #40450. Built from https://develop.svn.wordpress.org/trunk@40628 git-svn-id: http://core.svn.wordpress.org/trunk@40489 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -318,6 +318,36 @@ class WP_oEmbed {
|
||||
self::$early_providers['remove'][] = $format;
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a URL and attempts to return the oEmbed data.
|
||||
*
|
||||
* @see WP_oEmbed::fetch()
|
||||
*
|
||||
* @since 4.8.0
|
||||
* @access public
|
||||
*
|
||||
* @param string $url The URL to the content that should be attempted to be embedded.
|
||||
* @param array|string $args Optional. Arguments, usually passed from a shortcode. Default empty.
|
||||
* @return false|object False on failure, otherwise the result in the form of an object.
|
||||
*/
|
||||
public function get_data( $url, $args = '' ) {
|
||||
$args = wp_parse_args( $args );
|
||||
|
||||
$provider = $this->get_provider( $url, $args );
|
||||
|
||||
if ( ! $provider ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$data = $this->fetch( $provider, $url, $args );
|
||||
|
||||
if ( false === $data ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* The do-it-all function that takes a URL and attempts to return the HTML.
|
||||
*
|
||||
@@ -332,8 +362,6 @@ class WP_oEmbed {
|
||||
* @return false|string False on failure, otherwise the UNSANITIZED (and potentially unsafe) HTML that should be used to embed.
|
||||
*/
|
||||
public function get_html( $url, $args = '' ) {
|
||||
$args = wp_parse_args( $args );
|
||||
|
||||
/**
|
||||
* Filters the oEmbed result before any HTTP requests are made.
|
||||
*
|
||||
@@ -355,9 +383,9 @@ class WP_oEmbed {
|
||||
return $pre;
|
||||
}
|
||||
|
||||
$provider = $this->get_provider( $url, $args );
|
||||
$data = $this->get_data( $url, $args );
|
||||
|
||||
if ( ! $provider || false === $data = $this->fetch( $provider, $url, $args ) ) {
|
||||
if ( false === $data ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user