WordPress.org

Make WordPress Core


Ignore:
Timestamp:
06/23/2020 06:06:11 AM (15 months ago)
Author:
whyisjake
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-oembed-controller.php

    r48121 r48135  
    194194
    195195        if ( false === $data ) {
     196            // Try using a classic embed, instead.
     197            global $wp_embed;
     198
     199            /* @var WP_Embed $wp_embed */
     200            $html = $wp_embed->get_embed_handler_html( $args, $url );
     201
     202            if ( $html ) {
     203                global $wp_scripts;
     204                // Check if any scripts were enqueued by the shortcode, and include them in the response.
     205                $enqueued_scripts = array();
     206
     207                foreach ( $wp_scripts->queue as $script ) {
     208                    $enqueued_scripts[] = $wp_scripts->registered[ $script ]->src;
     209                }
     210
     211                return (object) array(
     212                    'provider_name' => __( 'Embed Handler' ),
     213                    'html'          => $html,
     214                    'scripts'       => $enqueued_scripts,
     215                );
     216            }
     217
    196218            return new WP_Error( 'oembed_invalid_url', get_status_header_desc( 404 ), array( 'status' => 404 ) );
    197219        }
Note: See TracChangeset for help on using the changeset viewer.