WordPress.org

Make WordPress Core

Ticket #24660: 24660.diff

File 24660.diff, 1.6 KB (added by wonderboymusic, 5 years ago)
  • src/wp-includes/media.php

     
    21842184                return;
    21852185        }
    21862186
     2187        wp_embed_register_handler( 'youtube_embed_url', '#https?://(www.)?youtube\.com/embed/([^/]+)#i', 'wp_embed_handler_youtube' );
     2188
    21872189        wp_embed_register_handler( 'googlevideo', '#http://video\.google\.([A-Za-z.]{2,5})/videoplay\?docid=([\d-]+)(.*?)#i', 'wp_embed_handler_googlevideo' );
    21882190
    21892191        /**
     
    22412243}
    22422244
    22432245/**
     2246 * The YouTube embed handler callback. Catches URLs that can be parsed but aren't supported by oEmbed.
     2247 *
     2248 * @since 4.0.0
     2249 *
     2250 * @param array $matches The regex matches from the provided regex when calling {@link wp_embed_register_handler()}.
     2251 * @param array $attr Embed attributes.
     2252 * @param string $url The original URL that was matched by the regex.
     2253 * @param array $rawattr The original unmodified attributes.
     2254 * @return string The embed HTML.
     2255 */
     2256function wp_embed_handler_youtube( $matches, $attr, $url, $rawattr ) {
     2257        global $wp_embed;
     2258        $embed = $wp_embed->autoembed( "https://youtube.com/watch?v={$matches[2]}" );
     2259        /**
     2260         * Filter the YoutTube embed output.
     2261         *
     2262         * @since 4.0.0
     2263         *
     2264         * @param string $embed   YouTube embed output.
     2265         * @param array  $attr    An array of embed attributes.
     2266         * @param string $url     The original URL that was matched by the regex.
     2267         * @param array  $rawattr The original unmodified attributes.
     2268         */
     2269        return apply_filters( 'wp_embed_handler_youtube', $embed, $attr, $url, $rawattr );
     2270}
     2271
     2272/**
    22442273 * Audio embed handler callback.
    22452274 *
    22462275 * @since 3.6.0