diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php
index 2df89a9..4f53312 100644
|
a
|
b
|
function print_emoji_detection_script() {
|
| 4527 | 4527 | |
| 4528 | 4528 | $printed = true; |
| 4529 | 4529 | |
| | 4530 | if ( ! has_filter( 'emoji_url' ) ) { |
| | 4531 | // Site is using the w.org CDN for emoji. |
| | 4532 | // Safe to presume SVG and bitmap image paths are present |
| | 4533 | $vectorPath = 'svg/'; |
| | 4534 | $bitmapPath = '72x72/'; |
| | 4535 | } |
| | 4536 | else { |
| | 4537 | // Site has filters the CDN |
| | 4538 | // Unsafe to assume presence of both SVG and bitmap paths. The site's |
| | 4539 | // developer can add these in using the filters below. |
| | 4540 | $vectorPath = null; |
| | 4541 | $bitmapPath = null; |
| | 4542 | } |
| | 4543 | |
| 4530 | 4544 | $settings = array( |
| 4531 | 4545 | /** |
| 4532 | 4546 | * Filter the URL where emoji images are hosted. |
| … |
… |
function print_emoji_detection_script() {
|
| 4535 | 4549 | * |
| 4536 | 4550 | * @param string The emoji base URL. |
| 4537 | 4551 | */ |
| 4538 | | 'baseUrl' => apply_filters( 'emoji_url', 'https://s.w.org/images/core/emoji/72x72/' ), |
| | 4552 | 'baseUrl' => apply_filters( 'emoji_url', 'https://s.w.org/images/core/emoji/' ), |
| | 4553 | |
| | 4554 | /** |
| | 4555 | * Filter the path where vector emoji images are hosted. |
| | 4556 | * |
| | 4557 | * Note: when filtering the emoji_url you will need to include a filter to set |
| | 4558 | * the vector path too. |
| | 4559 | * |
| | 4560 | * @since 4.6.0 |
| | 4561 | * |
| | 4562 | * @param string The emoji vector URL. |
| | 4563 | */ |
| | 4564 | 'vectorPath' => apply_filters( 'emoji_vector_path', $vectorPath ), |
| | 4565 | |
| | 4566 | /** |
| | 4567 | * Filter the path where bitmap emoji images are hosted. |
| | 4568 | * |
| | 4569 | * Note: when filtering the emoji_url you will need to include a filter to set |
| | 4570 | * the bitmap path too. |
| | 4571 | * |
| | 4572 | * @since 4.6.0 |
| | 4573 | * |
| | 4574 | * @param string The emoji bitmap URL. |
| | 4575 | */ |
| | 4576 | 'bitmapPath' => apply_filters( 'emoji_bitmap_path', $bitmapPath ), |
| 4539 | 4577 | |
| 4540 | 4578 | /** |
| 4541 | | * Filter the extension of the emoji files. |
| | 4579 | * Filter the bitmap extension of the emoji files. |
| 4542 | 4580 | * |
| 4543 | 4581 | * @since 4.2.0 |
| 4544 | 4582 | * |
| 4545 | 4583 | * @param string The emoji extension. Default .png. |
| 4546 | 4584 | */ |
| 4547 | 4585 | 'ext' => apply_filters( 'emoji_ext', '.png' ), |
| | 4586 | |
| | 4587 | /** |
| | 4588 | * Filter the vector extension of the emoji files. |
| | 4589 | * |
| | 4590 | * @since 4.2.0 |
| | 4591 | * |
| | 4592 | * @param string The emoji extension. Default .png. |
| | 4593 | */ |
| | 4594 | 'vectorExt' => apply_filters( 'emoji_vector_ext', '.svg' ), |
| 4548 | 4595 | ); |
| 4549 | 4596 | |
| 4550 | 4597 | $version = 'ver=' . $wp_version; |
diff --git a/src/wp-includes/js/wp-emoji.js b/src/wp-includes/js/wp-emoji.js
index dafcc36..d7652c8 100644
|
a
|
b
|
|
| 3 | 3 | function wpEmoji() { |
| 4 | 4 | var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver, |
| 5 | 5 | |
| | 6 | // Compression and maintain local scope |
| | 7 | document = window.document, |
| | 8 | |
| 6 | 9 | // Private |
| 7 | 10 | twemoji, timer, |
| 8 | 11 | loaded = false, |
| … |
… |
|
| 10 | 13 | ie11 = window.navigator.userAgent.indexOf( 'Trident/7.0' ) > 0; |
| 11 | 14 | |
| 12 | 15 | /** |
| | 16 | * Detect if the browser supports SVG. |
| | 17 | * |
| | 18 | * @since 4.6.0 |
| | 19 | * |
| | 20 | * @return {Boolean} True if the browser supports svg, false if not. |
| | 21 | */ |
| | 22 | function browserSupportsSvgAsImage() { |
| | 23 | if ( !! document.implementation.hasFeature ) { |
| | 24 | // Source: Modernizr |
| | 25 | // https://github.com/Modernizr/Modernizr/blob/master/feature-detects/svg/asimg.js |
| | 26 | return document.implementation.hasFeature( 'http://www.w3.org/TR/SVG11/feature#Image', '1.1' ); |
| | 27 | } |
| | 28 | |
| | 29 | // document.implementation.hasFeature is deprecated. It can be presumed |
| | 30 | // if future browsers remove it, the browser will support SVGs as images. |
| | 31 | return true; |
| | 32 | } |
| | 33 | |
| | 34 | function cdnUrl( settings ) { |
| | 35 | var baseUrl = settings.baseUrl; |
| | 36 | |
| | 37 | if ( ! settings.vectorPath || ! settings.bitmapPath ) { |
| | 38 | return baseUrl; |
| | 39 | } |
| | 40 | |
| | 41 | if ( browserSupportsSvgAsImage() ) { |
| | 42 | baseUrl = baseUrl + settings.vectorPath; |
| | 43 | } |
| | 44 | else { |
| | 45 | baseUrl = baseUrl + settings.bitmapPath; |
| | 46 | } |
| | 47 | |
| | 48 | return baseUrl; |
| | 49 | } |
| | 50 | |
| | 51 | function cdnExt( settings ) { |
| | 52 | var ext = settings.ext; |
| | 53 | |
| | 54 | if ( ! settings.vectorExt ) { |
| | 55 | return ext; |
| | 56 | } |
| | 57 | |
| | 58 | if ( browserSupportsSvgAsImage() ) { |
| | 59 | ext = settings.vectorExt; |
| | 60 | } |
| | 61 | else { |
| | 62 | ext = settings.ext; |
| | 63 | } |
| | 64 | |
| | 65 | return ext; |
| | 66 | } |
| | 67 | |
| | 68 | /** |
| 13 | 69 | * Runs when the document load event is fired, so we can do our first parse of the page. |
| 14 | 70 | * |
| 15 | 71 | * @since 4.2.0 |
| … |
… |
|
| 141 | 197 | |
| 142 | 198 | args = args || {}; |
| 143 | 199 | params = { |
| 144 | | base: settings.baseUrl, |
| 145 | | ext: settings.ext, |
| | 200 | base: cdnUrl( settings ), |
| | 201 | ext: cdnExt( settings ), |
| 146 | 202 | className: args.className || 'emoji', |
| 147 | 203 | callback: function( icon, options ) { |
| 148 | 204 | // Ignore some standard characters that TinyMCE recommends in its character map. |