From 368e5f9fc3b63f205aa1a9f7ccec2b220d7a3662 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Thu, 29 Oct 2015 23:11:24 +0000 Subject: [PATCH] Embeds: Provide a cached text fallback. Sometimes, embedded sites might suffer from less than 100% uptime. Instead of leaving the embedding site with a big blank space where the embed should be, let's fall back to a link to the embedded post, so there's at least some context for the post. Fixes #34462. Built from https://develop.svn.wordpress.org/trunk@35437 git-svn-id: http://core.svn.wordpress.org/trunk@35401 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/default-filters.php | 1 + wp-includes/embed-functions.php | 39 ++++++++++++++++++++++++++++----- wp-includes/js/wp-embed.js | 27 ++++++++++++++++------- wp-includes/js/wp-embed.min.js | 2 +- wp-includes/version.php | 2 +- 5 files changed, 55 insertions(+), 16 deletions(-) diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php index 70a9791ebc..75a171b4b0 100644 --- a/wp-includes/default-filters.php +++ b/wp-includes/default-filters.php @@ -165,6 +165,7 @@ add_filter( 'the_title_rss', 'ent2ncr', 8 ); add_filter( 'the_title_rss', 'esc_html' ); add_filter( 'the_content_rss', 'ent2ncr', 8 ); add_filter( 'the_content_feed', 'wp_staticize_emoji' ); +add_filter( 'the_content_feed', '_oembed_filter_feed_content' ); add_filter( 'the_excerpt_rss', 'convert_chars' ); add_filter( 'the_excerpt_rss', 'ent2ncr', 8 ); add_filter( 'comment_author_rss', 'ent2ncr', 8 ); diff --git a/wp-includes/embed-functions.php b/wp-includes/embed-functions.php index f28ed8692b..ebe15c5105 100644 --- a/wp-includes/embed-functions.php +++ b/wp-includes/embed-functions.php @@ -461,7 +461,9 @@ function get_post_embed_html( $post = null, $width, $height ) { $embed_url = get_post_embed_url( $post ); - $output = " 1000 ) { height = 1000; } else if ( height < 200 ) { @@ -32,7 +40,9 @@ /* Link to a specific URL on request. */ if ( 'link' === data.message ) { - var sourceURL = document.createElement( 'a' ), targetURL = document.createElement( 'a' ); + sourceURL = document.createElement( 'a' ); + targetURL = document.createElement( 'a' ); + sourceURL.href = source.getAttribute( 'src' ); targetURL.href = data.value; @@ -48,13 +58,14 @@ function onLoad() { var isIE10 = -1 !== navigator.appVersion.indexOf( 'MSIE 10' ), - isIE11 = !!navigator.userAgent.match( /Trident.*rv\:11\./ ); + isIE11 = !!navigator.userAgent.match( /Trident.*rv\:11\./ ), + iframes, iframeClone, i; /* Remove security attribute from iframes in IE10 and IE11. */ if ( isIE10 || isIE11 ) { - var iframes = document.querySelectorAll( '.wp-embedded-content[security]' ), iframeClone; + iframes = document.querySelectorAll( '.wp-embedded-content[security]' ); - for ( var i = 0; i < iframes.length; i++ ) { + for ( i = 0; i < iframes.length; i++ ) { iframeClone = iframes[ i ].cloneNode( true ); iframeClone.removeAttribute( 'security' ); iframes[ i ].parentNode.insertBefore( iframeClone, iframes[ i ].nextSibling ); diff --git a/wp-includes/js/wp-embed.min.js b/wp-includes/js/wp-embed.min.js index 71775415f4..545013fc6a 100644 --- a/wp-includes/js/wp-embed.min.js +++ b/wp-includes/js/wp-embed.min.js @@ -1 +1 @@ -!function(a,b){"use strict";function c(){var a=-1!==navigator.appVersion.indexOf("MSIE 10"),c=!!navigator.userAgent.match(/Trident.*rv\:11\./);if(a||c)for(var d,e=b.querySelectorAll(".wp-embedded-content[security]"),f=0;f1e3?h=1e3:200>h&&(h=200),g.height=h+"px"}if("link"===d.message){var i=b.createElement("a"),j=b.createElement("a");i.href=g.getAttribute("src"),j.href=d.value,j.host===i.host&&b.activeElement===g&&(a.top.location.href=d.value)}}},a.addEventListener("message",a.wp.receiveEmbedMessage,!1),b.addEventListener("DOMContentLoaded",c,!1))}(window,document); \ No newline at end of file +!function(a,b){"use strict";function c(){var a,c,d,e=-1!==navigator.appVersion.indexOf("MSIE 10"),f=!!navigator.userAgent.match(/Trident.*rv\:11\./);if(e||f)for(a=b.querySelectorAll(".wp-embedded-content[security]"),d=0;d1e3?g=1e3:200>g&&(g=200),f.height=g+"px"),"link"===d.message&&(h=b.createElement("a"),i=b.createElement("a"),h.href=f.getAttribute("src"),i.href=d.value,i.host===h.host&&b.activeElement===f&&(a.top.location.href=d.value))}},a.addEventListener("message",a.wp.receiveEmbedMessage,!1),b.addEventListener("DOMContentLoaded",c,!1))}(window,document); \ No newline at end of file diff --git a/wp-includes/version.php b/wp-includes/version.php index 9bed31e941..a83bd850ff 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-beta2-35436'; +$wp_version = '4.4-beta2-35437'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.