diff -r be944660c56a -r 3d72ae0968f4 wp/wp-includes/js/wp-embed.js --- a/wp/wp-includes/js/wp-embed.js Wed Sep 21 18:19:35 2022 +0200 +++ b/wp/wp-includes/js/wp-embed.js Tue Sep 27 16:37:53 2022 +0200 @@ -27,6 +27,11 @@ return; } + /** + * Receive embed message. + * + * @param {MessageEvent} e + */ window.wp.receiveEmbedMessage = function( e ) { var data = e.data; @@ -102,9 +107,11 @@ iframeClone, i, source, secret; for ( i = 0; i < iframes.length; i++ ) { + /** @var {IframeElement} */ source = iframes[ i ]; - if ( ! source.getAttribute( 'data-secret' ) ) { + secret = source.getAttribute( 'data-secret' ); + if ( ! secret ) { /* Add secret to iframe */ secret = Math.random().toString( 36 ).substr( 2, 10 ); source.src += '#?secret=' + secret; @@ -117,6 +124,16 @@ iframeClone.removeAttribute( 'security' ); source.parentNode.replaceChild( iframeClone, source ); } + + /* + * Let post embed window know that the parent is ready for receiving the height message, in case the iframe + * loaded before wp-embed.js was loaded. When the ready message is received by the post embed window, the + * window will then (re-)send the height message right away. + */ + source.contentWindow.postMessage( { + message: 'ready', + secret: secret + }, '*' ); } }