mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Embeds: Ensure that classic embed support works in the block editor.
See https://github.com/WordPress/gutenberg/pull/6345 Fixes #45447. Props swisspidy, pento, audrasjb, aduth, jrchamp, thrijith, TimothyBlynJacobs, whyisjake. git-svn-id: https://develop.svn.wordpress.org/trunk@48135 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -193,6 +193,28 @@ final class WP_oEmbed_Controller {
|
||||
$data = _wp_oembed_get_object()->get_data( $url, $args );
|
||||
|
||||
if ( false === $data ) {
|
||||
// Try using a classic embed, instead.
|
||||
global $wp_embed;
|
||||
|
||||
/* @var WP_Embed $wp_embed */
|
||||
$html = $wp_embed->get_embed_handler_html( $args, $url );
|
||||
|
||||
if ( $html ) {
|
||||
global $wp_scripts;
|
||||
// Check if any scripts were enqueued by the shortcode, and include them in the response.
|
||||
$enqueued_scripts = array();
|
||||
|
||||
foreach ( $wp_scripts->queue as $script ) {
|
||||
$enqueued_scripts[] = $wp_scripts->registered[ $script ]->src;
|
||||
}
|
||||
|
||||
return (object) array(
|
||||
'provider_name' => __( 'Embed Handler' ),
|
||||
'html' => $html,
|
||||
'scripts' => $enqueued_scripts,
|
||||
);
|
||||
}
|
||||
|
||||
return new WP_Error( 'oembed_invalid_url', get_status_header_desc( 404 ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user