diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php index 1226a9e53e..20ef07e2ac 100644 --- a/src/wp-admin/includes/ajax-actions.php +++ b/src/wp-admin/includes/ajax-actions.php @@ -3004,7 +3004,6 @@ function wp_ajax_parse_embed() { $parsed = $styles . $html . $scripts; } - if ( ! empty( $no_ssl_support ) || ( is_ssl() && ( preg_match( '%<(iframe|script|embed) [^>]*src="http://%', $parsed ) || preg_match( '%]*href="http://%', $parsed ) ) ) ) { // Admin is ssl and the embed is not. Iframes, scripts, and other "active content" will be blocked. @@ -3014,10 +3013,23 @@ function wp_ajax_parse_embed() { ) ); } - wp_send_json_success( array( + $return = array( 'body' => $parsed, 'attr' => $wp_embed->last_attr - ) ); + ); + + if ( strpos( $parsed, 'class="wp-embedded-content' ) ) { + if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { + $script_src = includes_url( 'js/wp-embed.js' ); + } else { + $script_src = includes_url( 'js/wp-embed.min.js' ); + } + + $return['head'] = ''; + $return['sandbox'] = true; + } + + wp_send_json_success( $return ); } /** diff --git a/src/wp-includes/class-wp-editor.php b/src/wp-includes/class-wp-editor.php index 1d2c75c113..83777cfd8c 100644 --- a/src/wp-includes/class-wp-editor.php +++ b/src/wp-includes/class-wp-editor.php @@ -417,7 +417,6 @@ final class _WP_Editors { 'wpdialogs', 'wptextpattern', 'wpview', - 'wpembed', ); if ( ! self::$has_medialib ) { diff --git a/src/wp-includes/js/mce-view.js b/src/wp-includes/js/mce-view.js index 16d860d470..21b2c87b6a 100644 --- a/src/wp-includes/js/mce-view.js +++ b/src/wp-includes/js/mce-view.js @@ -468,7 +468,7 @@ * @param {Boolean} rendered Only set for (un)rendered nodes. Optional. */ setContent: function( content, callback, rendered ) { - if ( _.isObject( content ) && content.body.indexOf( '' + '' + '' + @@ -623,10 +626,22 @@ } function reload() { - $( node ).data( 'rendered', null ); + if ( ! editor.isHidden() ) { + $( node ).data( 'rendered', null ); - setTimeout( function() { - wp.mce.views.render(); + setTimeout( function() { + wp.mce.views.render(); + } ); + } + } + + function addObserver() { + observer = new MutationObserver( _.debounce( resize, 100 ) ); + + observer.observe( iframeDoc.body, { + attributes: true, + childList: true, + subtree: true } ); } @@ -635,13 +650,11 @@ MutationObserver = iframeWin.MutationObserver || iframeWin.WebKitMutationObserver || iframeWin.MozMutationObserver; if ( MutationObserver ) { - observer = new MutationObserver( _.debounce( resize, 100 ) ); - - observer.observe( iframeDoc.body, { - attributes: true, - childList: true, - subtree: true - } ); + if ( ! iframeDoc.body ) { + iframeDoc.addEventListener( 'DOMContentLoaded', addObserver, false ); + } else { + addObserver(); + } } else { for ( i = 1; i < 6; i++ ) { setTimeout( resize, i * 700 ); diff --git a/src/wp-includes/js/tinymce/plugins/wpembed/plugin.js b/src/wp-includes/js/tinymce/plugins/wpembed/plugin.js deleted file mode 100644 index b6efbc95bf..0000000000 --- a/src/wp-includes/js/tinymce/plugins/wpembed/plugin.js +++ /dev/null @@ -1,17 +0,0 @@ -(function ( tinymce ) { - 'use strict'; - - tinymce.PluginManager.add( 'wpembed', function ( editor, url ) { - editor.on( 'init', function () { - var scriptId = editor.dom.uniqueId(); - - var scriptElm = editor.dom.create( 'script', { - id: scriptId, - type: 'text/javascript', - src: url + '/../../../wp-embed.js' - } ); - - editor.getDoc().getElementsByTagName( 'head' )[ 0 ].appendChild( scriptElm ); - } ); - } ); -})( window.tinymce );