X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/9441756a895fb4fdc4bcf20e0d228cef622663ca..607b7e02d77e7326161e8ec15639052d2040f745:/wp-includes/embed.php diff --git a/wp-includes/embed.php b/wp-includes/embed.php index 9fa1aa3d..1287c4e5 100644 --- a/wp-includes/embed.php +++ b/wp-includes/embed.php @@ -50,7 +50,7 @@ function wp_embed_unregister_handler( $id, $priority = 10 ) { * * The default height is 1.5 times the width, or 1000px, whichever is smaller. * - * The 'embed_defaults' filter can be used to adjust either of these values. + * The {@see 'embed_defaults'} filter can be used to adjust either of these values. * * @since 2.9.0 * @@ -70,7 +70,7 @@ function wp_embed_defaults( $url = '' ) { $height = min( ceil( $width * 1.5 ), 1000 ); /** - * Filter the default array of embed dimensions. + * Filters the default array of embed dimensions. * * @since 2.9.0 * @@ -161,7 +161,7 @@ function wp_oembed_remove_provider( $format ) { */ function wp_maybe_load_embeds() { /** - * Filter whether to load the default embed handlers. + * Filters whether to load the default embed handlers. * * Returning a falsey value will prevent loading the default embed handlers. * @@ -175,10 +175,8 @@ function wp_maybe_load_embeds() { wp_embed_register_handler( 'youtube_embed_url', '#https?://(www.)?youtube\.com/(?:v|embed)/([^/]+)#i', 'wp_embed_handler_youtube' ); - wp_embed_register_handler( 'googlevideo', '#http://video\.google\.([A-Za-z.]{2,5})/videoplay\?docid=([\d-]+)(.*?)#i', 'wp_embed_handler_googlevideo' ); - /** - * Filter the audio embed handler callback. + * Filters the audio embed handler callback. * * @since 3.6.0 * @@ -187,7 +185,7 @@ function wp_maybe_load_embeds() { wp_embed_register_handler( 'audio', '#^https?://.+?\.(' . join( '|', wp_get_audio_extensions() ) . ')$#i', apply_filters( 'wp_audio_embed_handler', 'wp_embed_handler_audio' ), 9999 ); /** - * Filter the video embed handler callback. + * Filters the video embed handler callback. * * @since 3.6.0 * @@ -196,43 +194,6 @@ function wp_maybe_load_embeds() { wp_embed_register_handler( 'video', '#^https?://.+?\.(' . join( '|', wp_get_video_extensions() ) . ')$#i', apply_filters( 'wp_video_embed_handler', 'wp_embed_handler_video' ), 9999 ); } -/** - * The Google Video embed handler callback. - * - * Google Video does not support oEmbed. - * - * @see WP_Embed::register_handler() - * @see WP_Embed::shortcode() - * - * @param array $matches The RegEx matches from the provided regex when calling wp_embed_register_handler(). - * @param array $attr Embed attributes. - * @param string $url The original URL that was matched by the regex. - * @param array $rawattr The original unmodified attributes. - * @return string The embed HTML. - */ -function wp_embed_handler_googlevideo( $matches, $attr, $url, $rawattr ) { - // If the user supplied a fixed width AND height, use it - if ( !empty($rawattr['width']) && !empty($rawattr['height']) ) { - $width = (int) $rawattr['width']; - $height = (int) $rawattr['height']; - } else { - list( $width, $height ) = wp_expand_dimensions( 425, 344, $attr['width'], $attr['height'] ); - } - - /** - * Filter the Google Video embed output. - * - * @since 2.9.0 - * - * @param string $html Google Video HTML embed markup. - * @param array $matches The RegEx matches from the provided regex. - * @param array $attr An array of embed attributes. - * @param string $url The original URL that was matched by the regex. - * @param array $rawattr The original unmodified attributes. - */ - return apply_filters( 'embed_googlevideo', '', $matches, $attr, $url, $rawattr ); -} - /** * YouTube iframe embed handler callback. * @@ -254,7 +215,7 @@ function wp_embed_handler_youtube( $matches, $attr, $url, $rawattr ) { $embed = $wp_embed->autoembed( "https://youtube.com/watch?v={$matches[2]}" ); /** - * Filter the YoutTube embed output. + * Filters the YoutTube embed output. * * @since 4.0.0 * @@ -283,7 +244,7 @@ function wp_embed_handler_audio( $matches, $attr, $url, $rawattr ) { $audio = sprintf( '[audio src="%s" /]', esc_url( $url ) ); /** - * Filter the audio embed output. + * Filters the audio embed output. * * @since 3.6.0 * @@ -315,7 +276,7 @@ function wp_embed_handler_video( $matches, $attr, $url, $rawattr ) { $video = sprintf( '[video %s src="%s" /]', $dimensions, esc_url( $url ) ); /** - * Filter the video embed output. + * Filters the video embed output. * * @since 3.6.0 * @@ -345,7 +306,7 @@ function wp_oembed_register_route() { function wp_oembed_add_discovery_links() { $output = ''; - if ( is_singular() && ! is_front_page() ) { + if ( is_singular() ) { $output .= '' . "\n"; if ( class_exists( 'SimpleXMLElement' ) ) { @@ -354,7 +315,7 @@ function wp_oembed_add_discovery_links() { } /** - * Filter the oEmbed discovery links HTML. + * Filters the oEmbed discovery links HTML. * * @since 4.4.0 * @@ -387,14 +348,15 @@ function get_post_embed_url( $post = null ) { return false; } - if ( get_option( 'permalink_structure' ) ) { - $embed_url = trailingslashit( get_permalink( $post ) ) . user_trailingslashit( 'embed' ); - } else { + $embed_url = trailingslashit( get_permalink( $post ) ) . user_trailingslashit( 'embed' ); + $path_conflict = get_page_by_path( str_replace( home_url(), '', $embed_url ), OBJECT, get_post_types( array( 'public' => true ) ) ); + + if ( ! get_option( 'permalink_structure' ) || $path_conflict ) { $embed_url = add_query_arg( array( 'embed' => 'true' ), get_permalink( $post ) ); } /** - * Filter the URL to embed a specific post. + * Filters the URL to embed a specific post. * * @since 4.4.0 * @@ -430,7 +392,7 @@ function get_oembed_endpoint_url( $permalink = '', $format = 'json' ) { } /** - * Filter the oEmbed endpoint URL. + * Filters the oEmbed endpoint URL. * * @since 4.4.0 * @@ -478,7 +440,7 @@ function get_post_embed_html( $width, $height, $post = null ) { * and edit wp-embed.js directly. */ $output .=<<1e3)g=1e3;else if(200>~~g)g=200;f.height=g}if("link"===d.message)if(h=b.createElement("a"),i=b.createElement("a"),h.href=f.getAttribute("src"),i.href=d.value,i.host===h.host)if(b.activeElement===f)a.top.location.href=d.value}else;}},d)a.addEventListener("message",a.wp.receiveEmbedMessage,!1),b.addEventListener("DOMContentLoaded",c,!1),a.addEventListener("load",c,!1)}(window,document); + !function(a,b){"use strict";function c(){if(!e){e=!0;var a,c,d,f,g=-1!==navigator.appVersion.indexOf("MSIE 10"),h=!!navigator.userAgent.match(/Trident.*rv:11\./),i=b.querySelectorAll("iframe.wp-embedded-content");for(c=0;c1e3)g=1e3;else if(~~g<200)g=200;f.height=g}if("link"===d.message)if(h=b.createElement("a"),i=b.createElement("a"),h.href=f.getAttribute("src"),i.href=d.value,i.host===h.host)if(b.activeElement===f)a.top.location.href=d.value}else;}},d)a.addEventListener("message",a.wp.receiveEmbedMessage,!1),b.addEventListener("DOMContentLoaded",c,!1),a.addEventListener("load",c,!1)}(window,document); JS; } $output .= "\n//-->"; @@ -489,11 +451,18 @@ JS; esc_url( $embed_url ), absint( $width ), absint( $height ), - esc_attr__( 'Embedded WordPress Post' ) + esc_attr( + sprintf( + /* translators: 1: post title, 2: site name */ + __( '“%1$s” — %2$s' ), + get_the_title( $post ), + get_bloginfo( 'name' ) + ) + ) ); /** - * Filter the embed HTML output for a given post. + * Filters the embed HTML output for a given post. * * @since 4.4.0 * @@ -515,7 +484,8 @@ JS; * @return array|false Response data on success, false if post doesn't exist. */ function get_oembed_response_data( $post, $width ) { - $post = get_post( $post ); + $post = get_post( $post ); + $width = absint( $width ); if ( ! $post ) { return false; @@ -526,7 +496,7 @@ function get_oembed_response_data( $post, $width ) { } /** - * Filter the allowed minimum and maximum widths for the oEmbed response. + * Filters the allowed minimum and maximum widths for the oEmbed response. * * @since 4.4.0 * @@ -563,7 +533,7 @@ function get_oembed_response_data( $post, $width ) { } /** - * Filter the oEmbed response data. + * Filters the oEmbed response data. * * @since 4.4.0 * @@ -776,7 +746,7 @@ function wp_filter_oembed_result( $result, $data, $url ) { if ( ! empty( $content[1] ) ) { // We have a blockquote to fall back on. Hide the iframe by default. - $html = str_replace( '