1/** 2 * WordPress inline HTML embed 3 * 4 * @since 4.4.0 5 * 6 * This file cannot have ampersands in it. This is to ensure 7 * it can be embedded in older versions of WordPress. 8 * See https://core.trac.wordpress.org/changeset/35708. 9 */ 10(function ( window, document ) { 11 'use strict'; 12 13 var supportedBrowser = false, 14 loaded = false; 15 16 if ( document.querySelector ) { 17 if ( window.addEventListener ) { 18 supportedBrowser = true; 19 } 20 } 21 22 window.wp = window.wp || {}; 23 24 if ( !! window.wp.receiveEmbedMessage ) { 25 return; 26 } 27 28 window.wp.receiveEmbedMessage = function( e ) { 29 var data = e.data; 30 if ( ! ( data.secret || data.message || data.value ) ) { 31 return; 32 } 33 34 if ( /[^a-zA-Z0-9]/.test( data.secret ) ) { 35 return; 36 } 37 38 var iframes = document.querySelectorAll( 'iframe[data-secret="' + data.secret + '"]' ), 39 blockquotes = document.querySelectorAll( 'blockquote[data-secret="' + data.secret + '"]' ), 40 allowedProtocols = new RegExp( '^https?:$', 'i' ), 41 i, source, height, sourceURL, targetURL; 42 43 for ( i = 0; i < blockquotes.length; i++ ) { 44 blockquotes[ i ].style.display = 'none'; 45 } 46 47 for ( i = 0; i < iframes.length; i++ ) { 48 source = iframes[ i ]; 49 50 if ( e.source !== source.contentWindow ) { 51 continue; 52 } 53 54 source.removeAttribute( 'style' ); 55 56 /* Resize the iframe on request. */ 57 if ( 'height' === data.message ) { 58 height = parseInt( data.value, 10 ); 59 if ( height > 1000 ) { 60 height = 1000; 61 } else if ( ~~height < 200 ) { 62 height = 200; 63 } 64 65 source.height = height; 66 } 67 68 /* Link to a specific URL on request. */ 69 if ( 'link' === data.message ) { 70 sourceURL = document.createElement( 'a' ); 71 targetURL = document.createElement( 'a' ); 72 73 sourceURL.href = source.getAttribute( 'src' ); 74 targetURL.href = data.value; 75 76 /* Only follow link if the protocol is in the allow list. */ 77 if ( ! allowedProtocols.test( targetURL.protocol ) ) { 78 continue; 79 } 80 81 /* Only continue if link hostname matches iframe's hostname. */ 82 if ( targetURL.host === sourceURL.host ) { 83 if ( document.activeElement === source ) { 84 window.top.location.href = data.value; 85 } 86 } 87 } 88 } 89 }; 90 91 function onLoad() { 92 if ( loaded ) { 93 return; 94 } 95 96 loaded = true; 97 98 var isIE10 = -1 !== navigator.appVersion.indexOf( 'MSIE 10' ), 99 isIE11 = !!navigator.userAgent.match( /Trident.*rv:11\./ ), 100 iframes = document.querySelectorAll( 'iframe.wp-embedded-content' ), 101 iframeClone, i, source, secret; 102 103 for ( i = 0; i < iframes.length; i++ ) { 104 source = iframes[ i ]; 105 106 if ( source.getAttribute( 'data-secret' ) ) { 107 continue; 108 } 109 110 /* Add secret to iframe */ 111 secret = Math.random().toString( 36 ).substr( 2, 10 ); 112 source.src += '#?secret=' + secret;
113 source.setAttribute( 'data-secret', secret ); 114 115 /* Remove security attribute from iframes in IE10 and IE11. */ 116 if ( ( isIE10 || isIE11 ) ) { 117 iframeClone = source.cloneNode( true ); 118 iframeClone.removeAttribute( 'security' ); 119 source.parentNode.replaceChild( iframeClone, source ); 120 } 121 } 122 } 123 124 if ( supportedBrowser ) { 125 window.addEventListener( 'message', window.wp.receiveEmbedMessage, false ); 126 document.addEventListener( 'DOMContentLoaded', onLoad, false ); 127 window.addEventListener( 'load', onLoad, false ); 128 } 129})( window, document );
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.