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 /** @namespace wp */ 23 window.wp = window.wp || {}; 24 25 if ( !! window.wp.receiveEmbedMessage ) { 26 return; 27 } 28 29 window.wp.receiveEmbedMessage = function( e ) { 30 var data = e.data; 31 32 if ( ! data ) { 33 return; 34 } 35 36 if ( ! ( data.secret || data.message || data.value ) ) { 37 return; 38 } 39 40 if ( /[^a-zA-Z0-9]/.test( data.secret ) ) { 41 return; 42 } 43 44 var iframes = document.querySelectorAll( 'iframe[data-secret="' + data.secret + '"]' ), 45 blockquotes = document.querySelectorAll( 'blockquote[data-secret="' + data.secret + '"]' ), 46 allowedProtocols = new RegExp( '^https?:$', 'i' ), 47 i, source, height, sourceURL, targetURL; 48 49 for ( i = 0; i < blockquotes.length; i++ ) { 50 blockquotes[ i ].style.display = 'none'; 51 } 52 53 for ( i = 0; i < iframes.length; i++ ) { 54 source = iframes[ i ]; 55 56 if ( e.source !== source.contentWindow ) { 57 continue; 58 } 59 60 source.removeAttribute( 'style' ); 61 62 /* Resize the iframe on request. */ 63 if ( 'height' === data.message ) { 64 height = parseInt( data.value, 10 ); 65 if ( height > 1000 ) { 66 height = 1000; 67 } else if ( ~~height < 200 ) { 68 height = 200; 69 } 70 71 source.height = height; 72 } 73 74 /* Link to a specific URL on request. */ 75 if ( 'link' === data.message ) { 76 sourceURL = document.createElement( 'a' ); 77 targetURL = document.createElement( 'a' ); 78 79 sourceURL.href = source.getAttribute( 'src' ); 80 targetURL.href = data.value; 81 82 /* Only follow link if the protocol is in the allow list. */ 83 if ( ! allowedProtocols.test( targetURL.protocol ) ) { 84 continue; 85 } 86 87 /* Only continue if link hostname matches iframe's hostname. */ 88 if ( targetURL.host === sourceURL.host ) { 89 if ( document.activeElement === source ) { 90 window.top.location.href = data.value; 91 } 92 } 93 } 94 } 95 }; 96 97 function onLoad() { 98 if ( loaded ) { 99 return; 100 } 101 102 loaded = true; 103 104 var isIE10 = -1 !== navigator.appVersion.indexOf( 'MSIE 10' ), 105 isIE11 = !!navigator.userAgent.match( /Trident.*rv:11\./ ), 106 iframes = document.querySelectorAll( 'iframe.wp-embedded-content' ), 107 iframeClone, i, source, secret; 108 109 for ( i = 0; i < iframes.length; i++ ) { 110 source = iframes[ i ]; 111 112 if ( ! source.getAttribute( 'data-secret' ) ) { 113 /* Add secret to iframe */ 114 secret = Math.random().toString( 36 ).substr( 2, 10 ); 115 source.src += '#?secret=' + secret;
116 source.setAttribute( 'data-secret', secret ); 117 } 118 119 /* Remove security attribute from iframes in IE10 and IE11. */ 120 if ( ( isIE10 || isIE11 ) ) { 121 iframeClone = source.cloneNode( true ); 122 iframeClone.removeAttribute( 'security' ); 123 source.parentNode.replaceChild( iframeClone, source ); 124 } 125 } 126 } 127 128 if ( supportedBrowser ) { 129 window.addEventListener( 'message', window.wp.receiveEmbedMessage, false ); 130 document.addEventListener( 'DOMContentLoaded', onLoad, false ); 131 window.addEventListener( 'load', onLoad, false ); 132 } 133})( 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.