Edit File by line
/home/barbar84/www/wp-inclu.../js
File: wp-emoji-loader.js
/**
[0] Fix | Delete
* @output wp-includes/js/wp-emoji-loader.js
[1] Fix | Delete
*/
[2] Fix | Delete
[3] Fix | Delete
( function( window, document, settings ) {
[4] Fix | Delete
var src, ready, ii, tests;
[5] Fix | Delete
[6] Fix | Delete
// Create a canvas element for testing native browser support of emoji.
[7] Fix | Delete
var canvas = document.createElement( 'canvas' );
[8] Fix | Delete
var context = canvas.getContext && canvas.getContext( '2d' );
[9] Fix | Delete
[10] Fix | Delete
/**
[11] Fix | Delete
* Checks if two sets of Emoji characters render the same visually.
[12] Fix | Delete
*
[13] Fix | Delete
* @since 4.9.0
[14] Fix | Delete
*
[15] Fix | Delete
* @private
[16] Fix | Delete
*
[17] Fix | Delete
* @param {number[]} set1 Set of Emoji character codes.
[18] Fix | Delete
* @param {number[]} set2 Set of Emoji character codes.
[19] Fix | Delete
*
[20] Fix | Delete
* @return {boolean} True if the two sets render the same.
[21] Fix | Delete
*/
[22] Fix | Delete
function emojiSetsRenderIdentically( set1, set2 ) {
[23] Fix | Delete
var stringFromCharCode = String.fromCharCode;
[24] Fix | Delete
[25] Fix | Delete
// Cleanup from previous test.
[26] Fix | Delete
context.clearRect( 0, 0, canvas.width, canvas.height );
[27] Fix | Delete
context.fillText( stringFromCharCode.apply( this, set1 ), 0, 0 );
[28] Fix | Delete
var rendered1 = canvas.toDataURL();
[29] Fix | Delete
[30] Fix | Delete
// Cleanup from previous test.
[31] Fix | Delete
context.clearRect( 0, 0, canvas.width, canvas.height );
[32] Fix | Delete
context.fillText( stringFromCharCode.apply( this, set2 ), 0, 0 );
[33] Fix | Delete
var rendered2 = canvas.toDataURL();
[34] Fix | Delete
[35] Fix | Delete
return rendered1 === rendered2;
[36] Fix | Delete
}
[37] Fix | Delete
[38] Fix | Delete
/**
[39] Fix | Delete
* Detects if the browser supports rendering emoji or flag emoji.
[40] Fix | Delete
*
[41] Fix | Delete
* Flag emoji are a single glyph made of two characters, so some browsers
[42] Fix | Delete
* (notably, Firefox OS X) don't support them.
[43] Fix | Delete
*
[44] Fix | Delete
* @since 4.2.0
[45] Fix | Delete
*
[46] Fix | Delete
* @private
[47] Fix | Delete
*
[48] Fix | Delete
* @param {string} type Whether to test for support of "flag" or "emoji".
[49] Fix | Delete
*
[50] Fix | Delete
* @return {boolean} True if the browser can render emoji, false if it cannot.
[51] Fix | Delete
*/
[52] Fix | Delete
function browserSupportsEmoji( type ) {
[53] Fix | Delete
var isIdentical;
[54] Fix | Delete
[55] Fix | Delete
if ( ! context || ! context.fillText ) {
[56] Fix | Delete
return false;
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
/*
[60] Fix | Delete
* Chrome on OS X added native emoji rendering in M41. Unfortunately,
[61] Fix | Delete
* it doesn't work when the font is bolder than 500 weight. So, we
[62] Fix | Delete
* check for bold rendering support to avoid invisible emoji in Chrome.
[63] Fix | Delete
*/
[64] Fix | Delete
context.textBaseline = 'top';
[65] Fix | Delete
context.font = '600 32px Arial';
[66] Fix | Delete
[67] Fix | Delete
switch ( type ) {
[68] Fix | Delete
case 'flag':
[69] Fix | Delete
/*
[70] Fix | Delete
* Test for Transgender flag compatibility. This flag is shortlisted for the Emoji 13 spec,
[71] Fix | Delete
* but has landed in Twemoji early, so we can add support for it, too.
[72] Fix | Delete
*
[73] Fix | Delete
* To test for support, we try to render it, and compare the rendering to how it would look if
[74] Fix | Delete
* the browser doesn't render it correctly (white flag emoji + transgender symbol).
[75] Fix | Delete
*/
[76] Fix | Delete
isIdentical = emojiSetsRenderIdentically(
[77] Fix | Delete
[ 0x1F3F3, 0xFE0F, 0x200D, 0x26A7, 0xFE0F ],
[78] Fix | Delete
[ 0x1F3F3, 0xFE0F, 0x200B, 0x26A7, 0xFE0F ]
[79] Fix | Delete
);
[80] Fix | Delete
[81] Fix | Delete
if ( isIdentical ) {
[82] Fix | Delete
return false;
[83] Fix | Delete
}
[84] Fix | Delete
[85] Fix | Delete
/*
[86] Fix | Delete
* Test for UN flag compatibility. This is the least supported of the letter locale flags,
[87] Fix | Delete
* so gives us an easy test for full support.
[88] Fix | Delete
*
[89] Fix | Delete
* To test for support, we try to render it, and compare the rendering to how it would look if
[90] Fix | Delete
* the browser doesn't render it correctly ([U] + [N]).
[91] Fix | Delete
*/
[92] Fix | Delete
isIdentical = emojiSetsRenderIdentically(
[93] Fix | Delete
[ 0xD83C, 0xDDFA, 0xD83C, 0xDDF3 ],
[94] Fix | Delete
[ 0xD83C, 0xDDFA, 0x200B, 0xD83C, 0xDDF3 ]
[95] Fix | Delete
);
[96] Fix | Delete
[97] Fix | Delete
if ( isIdentical ) {
[98] Fix | Delete
return false;
[99] Fix | Delete
}
[100] Fix | Delete
[101] Fix | Delete
/*
[102] Fix | Delete
* Test for English flag compatibility. England is a country in the United Kingdom, it
[103] Fix | Delete
* does not have a two letter locale code but rather an five letter sub-division code.
[104] Fix | Delete
*
[105] Fix | Delete
* To test for support, we try to render it, and compare the rendering to how it would look if
[106] Fix | Delete
* the browser doesn't render it correctly (black flag emoji + [G] + [B] + [E] + [N] + [G]).
[107] Fix | Delete
*/
[108] Fix | Delete
isIdentical = emojiSetsRenderIdentically(
[109] Fix | Delete
[ 0xD83C, 0xDFF4, 0xDB40, 0xDC67, 0xDB40, 0xDC62, 0xDB40, 0xDC65, 0xDB40, 0xDC6E, 0xDB40, 0xDC67, 0xDB40, 0xDC7F ],
[110] Fix | Delete
[ 0xD83C, 0xDFF4, 0x200B, 0xDB40, 0xDC67, 0x200B, 0xDB40, 0xDC62, 0x200B, 0xDB40, 0xDC65, 0x200B, 0xDB40, 0xDC6E, 0x200B, 0xDB40, 0xDC67, 0x200B, 0xDB40, 0xDC7F ]
[111] Fix | Delete
);
[112] Fix | Delete
[113] Fix | Delete
return ! isIdentical;
[114] Fix | Delete
case 'emoji':
[115] Fix | Delete
/*
[116] Fix | Delete
* So easy, even a baby could do it!
[117] Fix | Delete
*
[118] Fix | Delete
* To test for Emoji 13 support, try to render a new emoji: Man Feeding Baby.
[119] Fix | Delete
*
[120] Fix | Delete
* The Man Feeding Baby emoji is a ZWJ sequence combining 👨 Man, a Zero Width Joiner and 🍼 Baby Bottle.
[121] Fix | Delete
*
[122] Fix | Delete
* 0xD83D, 0xDC68 == Man emoji.
[123] Fix | Delete
* 0x200D == Zero-Width Joiner (ZWJ) that links the two code points for the new emoji or
[124] Fix | Delete
* 0x200B == Zero-Width Space (ZWS) that is rendered for clients not supporting the new emoji.
[125] Fix | Delete
* 0xD83C, 0xDF7C == Baby Bottle.
[126] Fix | Delete
*
[127] Fix | Delete
* When updating this test for future Emoji releases, ensure that individual emoji that make up the
[128] Fix | Delete
* sequence come from older emoji standards.
[129] Fix | Delete
*/
[130] Fix | Delete
isIdentical = emojiSetsRenderIdentically(
[131] Fix | Delete
[0xD83D, 0xDC68, 0x200D, 0xD83C, 0xDF7C],
[132] Fix | Delete
[0xD83D, 0xDC68, 0x200B, 0xD83C, 0xDF7C]
[133] Fix | Delete
);
[134] Fix | Delete
[135] Fix | Delete
return ! isIdentical;
[136] Fix | Delete
}
[137] Fix | Delete
[138] Fix | Delete
return false;
[139] Fix | Delete
}
[140] Fix | Delete
[141] Fix | Delete
/**
[142] Fix | Delete
* Adds a script to the head of the document.
[143] Fix | Delete
*
[144] Fix | Delete
* @ignore
[145] Fix | Delete
*
[146] Fix | Delete
* @since 4.2.0
[147] Fix | Delete
*
[148] Fix | Delete
* @param {Object} src The url where the script is located.
[149] Fix | Delete
* @return {void}
[150] Fix | Delete
*/
[151] Fix | Delete
function addScript( src ) {
[152] Fix | Delete
var script = document.createElement( 'script' );
[153] Fix | Delete
[154] Fix | Delete
script.src = src;
[155] Fix | Delete
script.defer = script.type = 'text/javascript';
[156] Fix | Delete
document.getElementsByTagName( 'head' )[0].appendChild( script );
[157] Fix | Delete
}
[158] Fix | Delete
[159] Fix | Delete
tests = Array( 'flag', 'emoji' );
[160] Fix | Delete
[161] Fix | Delete
settings.supports = {
[162] Fix | Delete
everything: true,
[163] Fix | Delete
everythingExceptFlag: true
[164] Fix | Delete
};
[165] Fix | Delete
[166] Fix | Delete
/*
[167] Fix | Delete
* Tests the browser support for flag emojis and other emojis, and adjusts the
[168] Fix | Delete
* support settings accordingly.
[169] Fix | Delete
*/
[170] Fix | Delete
for( ii = 0; ii < tests.length; ii++ ) {
[171] Fix | Delete
settings.supports[ tests[ ii ] ] = browserSupportsEmoji( tests[ ii ] );
[172] Fix | Delete
[173] Fix | Delete
settings.supports.everything = settings.supports.everything && settings.supports[ tests[ ii ] ];
[174] Fix | Delete
[175] Fix | Delete
if ( 'flag' !== tests[ ii ] ) {
[176] Fix | Delete
settings.supports.everythingExceptFlag = settings.supports.everythingExceptFlag && settings.supports[ tests[ ii ] ];
[177] Fix | Delete
}
[178] Fix | Delete
}
[179] Fix | Delete
[180] Fix | Delete
settings.supports.everythingExceptFlag = settings.supports.everythingExceptFlag && ! settings.supports.flag;
[181] Fix | Delete
[182] Fix | Delete
// Sets DOMReady to false and assigns a ready function to settings.
[183] Fix | Delete
settings.DOMReady = false;
[184] Fix | Delete
settings.readyCallback = function() {
[185] Fix | Delete
settings.DOMReady = true;
[186] Fix | Delete
};
[187] Fix | Delete
[188] Fix | Delete
// When the browser can not render everything we need to load a polyfill.
[189] Fix | Delete
if ( ! settings.supports.everything ) {
[190] Fix | Delete
ready = function() {
[191] Fix | Delete
settings.readyCallback();
[192] Fix | Delete
};
[193] Fix | Delete
[194] Fix | Delete
/*
[195] Fix | Delete
* Cross-browser version of adding a dom ready event.
[196] Fix | Delete
*/
[197] Fix | Delete
if ( document.addEventListener ) {
[198] Fix | Delete
document.addEventListener( 'DOMContentLoaded', ready, false );
[199] Fix | Delete
window.addEventListener( 'load', ready, false );
[200] Fix | Delete
} else {
[201] Fix | Delete
window.attachEvent( 'onload', ready );
[202] Fix | Delete
document.attachEvent( 'onreadystatechange', function() {
[203] Fix | Delete
if ( 'complete' === document.readyState ) {
[204] Fix | Delete
settings.readyCallback();
[205] Fix | Delete
}
[206] Fix | Delete
} );
[207] Fix | Delete
}
[208] Fix | Delete
[209] Fix | Delete
src = settings.source || {};
[210] Fix | Delete
[211] Fix | Delete
if ( src.concatemoji ) {
[212] Fix | Delete
addScript( src.concatemoji );
[213] Fix | Delete
} else if ( src.wpemoji && src.twemoji ) {
[214] Fix | Delete
addScript( src.twemoji );
[215] Fix | Delete
addScript( src.wpemoji );
[216] Fix | Delete
}
[217] Fix | Delete
}
[218] Fix | Delete
[219] Fix | Delete
} )( window, document, window._wpemojiSettings );
[220] Fix | Delete
[221] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function