diff --git a/wp-includes/class-wp-editor.php b/wp-includes/class-wp-editor.php index 32f638240f..8812c770ab 100644 --- a/wp-includes/class-wp-editor.php +++ b/wp-includes/class-wp-editor.php @@ -1663,19 +1663,24 @@ final class _WP_Editors { ?> ( function() { - var init, id, $wrap; + var initialize = function() { + var init, id, inPostbox, $wrap; + var readyState = document.readyState; - if ( typeof tinymce !== 'undefined' ) { - if ( tinymce.Env.ie && tinymce.Env.ie < 11 ) { - tinymce.$( '.wp-editor-wrap ' ).removeClass( 'tmce-active' ).addClass( 'html-active' ); + if ( readyState !== 'complete' && readyState !== 'interactive' ) { return; } for ( id in tinyMCEPreInit.mceInit ) { - init = tinyMCEPreInit.mceInit[id]; - $wrap = tinymce.$( '#wp-' + id + '-wrap' ); + init = tinyMCEPreInit.mceInit[id]; + $wrap = tinymce.$( '#wp-' + id + '-wrap' ); + inPostbox = $wrap.parents( '.postbox' ).length > 0; - if ( ( $wrap.hasClass( 'tmce-active' ) || ! tinyMCEPreInit.qtInit.hasOwnProperty( id ) ) && ! init.wp_skip_init ) { + if ( + ! init.wp_skip_init && + ( $wrap.hasClass( 'tmce-active' ) || ! tinyMCEPreInit.qtInit.hasOwnProperty( id ) ) && + ( readyState === 'complete' || ( ! inPostbox && readyState === 'interactive' ) ) + ) { tinymce.init( init ); if ( ! window.wpActiveEditor ) { @@ -1685,6 +1690,18 @@ final class _WP_Editors { } } + if ( typeof tinymce !== 'undefined' ) { + if ( tinymce.Env.ie && tinymce.Env.ie < 11 ) { + tinymce.$( '.wp-editor-wrap ' ).removeClass( 'tmce-active' ).addClass( 'html-active' ); + } else { + if ( document.readyState === 'complete' ) { + initialize(); + } else { + document.addEventListener( 'readystatechange', initialize ); + } + } + } + if ( typeof quicktags !== 'undefined' ) { for ( id in tinyMCEPreInit.qtInit ) { quicktags( tinyMCEPreInit.qtInit[id] ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 5c76d4dd4e..f157aab402 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.8-alpha-51081'; +$wp_version = '5.8-alpha-51082'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.