author | ymh <ymh.work@gmail.com> |
Fri, 05 Sep 2025 18:40:08 +0200 | |
changeset 21 | 48c4eec2b7e6 |
parent 16 | a86126ab1dd4 |
permissions | -rw-r--r-- |
9 | 1 |
/** |
2 |
* wp-emoji.js is used to replace emoji with images in browsers when the browser |
|
3 |
* doesn't support emoji natively. |
|
4 |
* |
|
5 |
* @output wp-includes/js/wp-emoji.js |
|
6 |
*/ |
|
5 | 7 |
|
8 |
( function( window, settings ) { |
|
9 | 9 |
/** |
10 |
* Replaces emoji with images when browsers don't support emoji. |
|
11 |
* |
|
16 | 12 |
* @since 4.2.0 |
13 |
* @access private |
|
9 | 14 |
* |
15 |
* @class |
|
16 |
* |
|
17 |
* @see Twitter Emoji library |
|
18 |
* @link https://github.com/twitter/twemoji |
|
19 |
* |
|
20 |
* @return {Object} The wpEmoji parse and test functions. |
|
21 |
*/ |
|
5 | 22 |
function wpEmoji() { |
23 |
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver, |
|
24 |
||
16 | 25 |
// Compression and maintain local scope. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
26 |
document = window.document, |
5 | 27 |
|
16 | 28 |
// Private. |
5 | 29 |
twemoji, timer, |
30 |
loaded = false, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
31 |
count = 0, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
32 |
ie11 = window.navigator.userAgent.indexOf( 'Trident/7.0' ) > 0; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
33 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
34 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
35 |
* Detect if the browser supports SVG. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
36 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
37 |
* @since 4.6.0 |
9 | 38 |
* @private |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
39 |
* |
9 | 40 |
* @see Modernizr |
41 |
* @link https://github.com/Modernizr/Modernizr/blob/master/feature-detects/svg/asimg.js |
|
42 |
* |
|
43 |
* @return {boolean} True if the browser supports svg, false if not. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
44 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
45 |
function browserSupportsSvgAsImage() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
46 |
if ( !! document.implementation.hasFeature ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
47 |
return document.implementation.hasFeature( 'http://www.w3.org/TR/SVG11/feature#Image', '1.1' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
48 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
49 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
50 |
// document.implementation.hasFeature is deprecated. It can be presumed |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
51 |
// if future browsers remove it, the browser will support SVGs as images. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
52 |
return true; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
53 |
} |
5 | 54 |
|
55 |
/** |
|
9 | 56 |
* Runs when the document load event is fired, so we can do our first parse of |
57 |
* the page. |
|
58 |
* |
|
59 |
* Listens to all the DOM mutations and checks for added nodes that contain |
|
60 |
* emoji characters and replaces those with twitter emoji images. |
|
5 | 61 |
* |
62 |
* @since 4.2.0 |
|
9 | 63 |
* @private |
5 | 64 |
*/ |
65 |
function load() { |
|
66 |
if ( loaded ) { |
|
67 |
return; |
|
68 |
} |
|
69 |
||
9 | 70 |
// Ensure twemoji is available on the global window before proceeding. |
5 | 71 |
if ( typeof window.twemoji === 'undefined' ) { |
16 | 72 |
// Break if waiting for longer than 30 seconds. |
5 | 73 |
if ( count > 600 ) { |
74 |
return; |
|
75 |
} |
|
76 |
||
77 |
// Still waiting. |
|
78 |
window.clearTimeout( timer ); |
|
79 |
timer = window.setTimeout( load, 50 ); |
|
80 |
count++; |
|
81 |
||
82 |
return; |
|
83 |
} |
|
84 |
||
85 |
twemoji = window.twemoji; |
|
86 |
loaded = true; |
|
87 |
||
9 | 88 |
// Initialize the mutation observer, which checks all added nodes for |
89 |
// replaceable emoji characters. |
|
5 | 90 |
if ( MutationObserver ) { |
91 |
new MutationObserver( function( mutationRecords ) { |
|
92 |
var i = mutationRecords.length, |
|
93 |
addedNodes, removedNodes, ii, node; |
|
94 |
||
95 |
while ( i-- ) { |
|
96 |
addedNodes = mutationRecords[ i ].addedNodes; |
|
97 |
removedNodes = mutationRecords[ i ].removedNodes; |
|
98 |
ii = addedNodes.length; |
|
99 |
||
9 | 100 |
/* |
101 |
* Checks if an image has been replaced by a text element |
|
102 |
* with the same text as the alternate description of the replaced image. |
|
103 |
* (presumably because the image could not be loaded). |
|
104 |
* If it is, do absolutely nothing. |
|
105 |
* |
|
106 |
* Node type 3 is a TEXT_NODE. |
|
107 |
* |
|
108 |
* @link https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType |
|
109 |
*/ |
|
5 | 110 |
if ( |
111 |
ii === 1 && removedNodes.length === 1 && |
|
112 |
addedNodes[0].nodeType === 3 && |
|
113 |
removedNodes[0].nodeName === 'IMG' && |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
114 |
addedNodes[0].data === removedNodes[0].alt && |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
115 |
'load-failed' === removedNodes[0].getAttribute( 'data-error' ) |
5 | 116 |
) { |
117 |
return; |
|
118 |
} |
|
119 |
||
9 | 120 |
// Loop through all the added nodes. |
5 | 121 |
while ( ii-- ) { |
122 |
node = addedNodes[ ii ]; |
|
123 |
||
9 | 124 |
// Node type 3 is a TEXT_NODE. |
5 | 125 |
if ( node.nodeType === 3 ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
126 |
if ( ! node.parentNode ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
127 |
continue; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
128 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
129 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
130 |
if ( ie11 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
131 |
/* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
132 |
* IE 11's implementation of MutationObserver is buggy. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
133 |
* It unnecessarily splits text nodes when it encounters a HTML |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
134 |
* template interpolation symbol ( "{{", for example ). So, we |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
135 |
* join the text nodes back together as a work-around. |
9 | 136 |
* |
137 |
* Node type 3 is a TEXT_NODE. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
138 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
139 |
while( node.nextSibling && 3 === node.nextSibling.nodeType ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
140 |
node.nodeValue = node.nodeValue + node.nextSibling.nodeValue; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
141 |
node.parentNode.removeChild( node.nextSibling ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
142 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
143 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
144 |
|
5 | 145 |
node = node.parentNode; |
146 |
} |
|
147 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
148 |
if ( test( node.textContent ) ) { |
5 | 149 |
parse( node ); |
150 |
} |
|
151 |
} |
|
152 |
} |
|
153 |
} ).observe( document.body, { |
|
154 |
childList: true, |
|
155 |
subtree: true |
|
156 |
} ); |
|
157 |
} |
|
158 |
||
159 |
parse( document.body ); |
|
160 |
} |
|
161 |
||
162 |
/** |
|
9 | 163 |
* Tests if a text string contains emoji characters. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
164 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
165 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
166 |
* |
9 | 167 |
* @memberOf wp.emoji |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
168 |
* |
9 | 169 |
* @param {string} text The string to test. |
170 |
* |
|
171 |
* @return {boolean} Whether the string contains emoji characters. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
172 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
173 |
function test( text ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
174 |
// Single char. U+20E3 to detect keycaps. U+00A9 "copyright sign" and U+00AE "registered sign" not included. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
175 |
var single = /[\u203C\u2049\u20E3\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2300\u231A\u231B\u2328\u2388\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638\u2639\u263A\u2648-\u2653\u2660\u2663\u2665\u2666\u2668\u267B\u267F\u2692\u2693\u2694\u2696\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753\u2754\u2755\u2757\u2763\u2764\u2795\u2796\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05\u2B06\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]/, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
176 |
// Surrogate pair range. Only tests for the second half. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
177 |
pair = /[\uDC00-\uDFFF]/; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
178 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
179 |
if ( text ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
180 |
return pair.test( text ) || single.test( text ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
181 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
182 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
183 |
return false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
184 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
185 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
186 |
/** |
9 | 187 |
* Parses any emoji characters into Twemoji images. |
188 |
* |
|
189 |
* - When passed an element the emoji characters are replaced inline. |
|
190 |
* - When passed a string the emoji characters are replaced and the result is |
|
191 |
* returned. |
|
5 | 192 |
* |
193 |
* @since 4.2.0 |
|
194 |
* |
|
9 | 195 |
* @memberOf wp.emoji |
196 |
* |
|
197 |
* @param {HTMLElement|string} object The element or string to parse. |
|
198 |
* @param {Object} args Additional options for Twemoji. |
|
199 |
* |
|
200 |
* @return {HTMLElement|string} A string where all emoji are now image tags of |
|
201 |
* emoji. Or the element that was passed as the first argument. |
|
5 | 202 |
*/ |
203 |
function parse( object, args ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
204 |
var params; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
205 |
|
9 | 206 |
/* |
207 |
* If the browser has full support, twemoji is not loaded or our |
|
208 |
* object is not what was expected, we do not parse anything. |
|
209 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
210 |
if ( settings.supports.everything || ! twemoji || ! object || |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
211 |
( 'string' !== typeof object && ( ! object.childNodes || ! object.childNodes.length ) ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
212 |
|
5 | 213 |
return object; |
214 |
} |
|
215 |
||
9 | 216 |
// Compose the params for the twitter emoji library. |
5 | 217 |
args = args || {}; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
218 |
params = { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
219 |
base: browserSupportsSvgAsImage() ? settings.svgUrl : settings.baseUrl, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
220 |
ext: browserSupportsSvgAsImage() ? settings.svgExt : settings.ext, |
5 | 221 |
className: args.className || 'emoji', |
222 |
callback: function( icon, options ) { |
|
223 |
// Ignore some standard characters that TinyMCE recommends in its character map. |
|
224 |
switch ( icon ) { |
|
225 |
case 'a9': |
|
226 |
case 'ae': |
|
227 |
case '2122': |
|
228 |
case '2194': |
|
229 |
case '2660': |
|
230 |
case '2663': |
|
231 |
case '2665': |
|
232 |
case '2666': |
|
233 |
return false; |
|
234 |
} |
|
235 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
236 |
if ( settings.supports.everythingExceptFlag && |
16 | 237 |
! /^1f1(?:e[6-9a-f]|f[0-9a-f])-1f1(?:e[6-9a-f]|f[0-9a-f])$/.test( icon ) && // Country flags. |
238 |
! /^(1f3f3-fe0f-200d-1f308|1f3f4-200d-2620-fe0f)$/.test( icon ) // Rainbow and pirate flags. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
239 |
) { |
5 | 240 |
return false; |
241 |
} |
|
242 |
||
243 |
return ''.concat( options.base, icon, options.ext ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
244 |
}, |
16 | 245 |
attributes: function() { |
246 |
return { |
|
247 |
role: 'img' |
|
248 |
}; |
|
249 |
}, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
250 |
onerror: function() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
251 |
if ( twemoji.parentNode ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
252 |
this.setAttribute( 'data-error', 'load-failed' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
253 |
twemoji.parentNode.replaceChild( document.createTextNode( twemoji.alt ), twemoji ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
254 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
16
diff
changeset
|
255 |
}, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
16
diff
changeset
|
256 |
doNotParse: function( node ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
16
diff
changeset
|
257 |
if ( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
16
diff
changeset
|
258 |
node && |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
16
diff
changeset
|
259 |
node.className && |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
16
diff
changeset
|
260 |
typeof node.className === 'string' && |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
16
diff
changeset
|
261 |
node.className.indexOf( 'wp-exclude-emoji' ) !== -1 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
16
diff
changeset
|
262 |
) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
16
diff
changeset
|
263 |
// Do not parse this node. Emojis will not be replaced in this node and all sub-nodes. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
16
diff
changeset
|
264 |
return true; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
16
diff
changeset
|
265 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
16
diff
changeset
|
266 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
16
diff
changeset
|
267 |
return false; |
5 | 268 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
269 |
}; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
270 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
271 |
if ( typeof args.imgAttr === 'object' ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
272 |
params.attributes = function() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
273 |
return args.imgAttr; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
274 |
}; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
275 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
276 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
277 |
return twemoji.parse( object, params ); |
5 | 278 |
} |
279 |
||
280 |
/** |
|
281 |
* Initialize our emoji support, and set up listeners. |
|
282 |
*/ |
|
283 |
if ( settings ) { |
|
284 |
if ( settings.DOMReady ) { |
|
285 |
load(); |
|
286 |
} else { |
|
287 |
settings.readyCallback = load; |
|
288 |
} |
|
289 |
} |
|
290 |
||
291 |
return { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
292 |
parse: parse, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
293 |
test: test |
5 | 294 |
}; |
295 |
} |
|
296 |
||
297 |
window.wp = window.wp || {}; |
|
9 | 298 |
|
299 |
/** |
|
300 |
* @namespace wp.emoji |
|
301 |
*/ |
|
5 | 302 |
window.wp.emoji = new wpEmoji(); |
303 |
||
304 |
} )( window, window._wpemojiSettings ); |