Ticket #31701: 31701.11.diff
File 31701.11.diff, 12.4 KB (added by , 10 years ago) |
---|
-
Gruntfile.js
464 464 BUILD_DIR + 'wp-includes/js/tinymce/plugins/*/plugin.min.js' 465 465 ], 466 466 dest: BUILD_DIR + 'wp-includes/js/tinymce/wp-tinymce.js' 467 }, 468 emoji: { 469 options: { 470 separator: '\n', 471 process: function( src, filepath ) { 472 return '// Source: ' + filepath.replace( BUILD_DIR, '' ) + '\n' + src; 473 } 474 }, 475 src: [ 476 BUILD_DIR + 'wp-includes/js/twemoji.min.js', 477 BUILD_DIR + 'wp-includes/js/wp-emoji.min.js' 478 ], 479 dest: BUILD_DIR + 'wp-includes/js/wp-emoji-release.min.js' 467 480 } 468 481 }, 469 482 compress: { … … 502 515 dest: SOURCE_DIR 503 516 } 504 517 }, 518 includes: { 519 emoji: { 520 src: BUILD_DIR + 'wp-includes/formatting.php', 521 dest: '.' 522 } 523 }, 505 524 _watch: { 506 525 all: { 507 526 files: [ … … 615 634 'concat:tinymce', 616 635 'compress:tinymce', 617 636 'clean:tinymce', 637 'concat:emoji', 638 'includes:emoji', 618 639 'jsvalidate:build' 619 640 ] ); 620 641 -
package.json
22 22 "grunt-contrib-qunit": "~0.5.2", 23 23 "grunt-contrib-uglify": "~0.8.0", 24 24 "grunt-contrib-watch": "~0.6.1", 25 "grunt-includes": "~0.4.5", 25 26 "grunt-jsvalidate": "~0.2.2", 26 27 "grunt-legacy-util": "^0.2.0", 27 28 "grunt-patch-wordpress": "~0.3.0", -
src/wp-includes/default-filters.php
213 213 add_action( 'wp_head', 'locale_stylesheet' ); 214 214 add_action( 'publish_future_post', 'check_and_publish_future_post', 10, 1 ); 215 215 add_action( 'wp_head', 'noindex', 1 ); 216 add_action( 'wp_head', 'print_emoji_detection_script', 7 ); 216 217 add_action( 'wp_head', 'wp_print_styles', 8 ); 217 218 add_action( 'wp_head', 'wp_print_head_scripts', 9 ); 218 219 add_action( 'wp_head', 'wp_generator' ); -
src/wp-includes/formatting.php
4082 4082 * @since 4.2.0 4083 4083 */ 4084 4084 function print_emoji_styles() { 4085 static $printed = false; 4086 4087 if ( $printed ) { 4088 return; 4089 } 4090 4091 $printed = true; 4085 4092 ?> 4086 4093 <style type="text/css"> 4087 4094 img.wp-smiley, … … 4100 4107 <?php 4101 4108 } 4102 4109 4110 function print_emoji_detection_script() { 4111 global $wp_version; 4112 static $printed = false; 4113 4114 if ( $printed ) { 4115 return; 4116 } 4117 4118 $printed = true; 4119 4120 $settings = array( 4121 /** 4122 * Filter the URL where emoji images are hosted. 4123 * 4124 * @since 4.2.0 4125 * 4126 * @param string The emoji base URL. 4127 */ 4128 'baseUrl' => apply_filters( 'emoji_url', set_url_scheme( '//s0.wp.com/wp-content/mu-plugins/emoji/twemoji/72x72' ) ), 4129 4130 /** 4131 * Filter the extension of the emoji files. 4132 * 4133 * @since 4.2.0 4134 * 4135 * @param string The emoji extension. Default .png. 4136 */ 4137 'ext' => apply_filters( 'emoji_ext', '.png' ), 4138 ); 4139 4140 $version = 'ver=' . $wp_version; 4141 4142 if ( SCRIPT_DEBUG ) { 4143 $settings['source'] = array( 4144 'wpemoji' => includes_url( "js/wp-emoji.js?$version" ), 4145 'twemoji' => includes_url( "js/twemoji.js?$version" ), 4146 ); 4147 4148 ?> 4149 <script type="text/javascript"> 4150 window._wpemojiSettings = <?php echo wp_json_encode( $settings ); ?>; 4151 <?php readfile( ABSPATH . WPINC . "/js/wp-emoji-loader.js" ); ?> 4152 </script> 4153 <?php 4154 } else { 4155 $settings['source'] = array( 4156 'concatemoji' => includes_url( "js/wp-emoji-release.min.js?$version" ), 4157 ); 4158 4159 ?> 4160 <script type="text/javascript"> 4161 window._wpemojiSettings = <?php echo wp_json_encode( $settings ); ?>; 4162 include "js/wp-emoji-loader.min.js" 4163 </script> 4164 <?php 4165 } 4166 } 4167 4103 4168 /** 4104 4169 * Convert any 4 byte emoji in a string to their equivalent HTML entity. 4105 4170 * … … 4163 4228 return $text; 4164 4229 } 4165 4230 4166 /** This filter is documented in wp-includes/ script-loader.php */4231 /** This filter is documented in wp-includes/formatting.php */ 4167 4232 $cdn_url = apply_filters( 'emoji_url', set_url_scheme( '//s0.wp.com/wp-content/mu-plugins/emoji/twemoji/72x72/' ) ); 4168 4233 4169 /** This filter is documented in wp-includes/s cript-loader.php */4234 /** This filter is documented in wp-includes/sformatting.php */ 4170 4235 $ext = apply_filters( 'emoji_ext', '.png' ); 4171 4236 4172 4237 $output = ''; -
src/wp-includes/js/wp-emoji-loader.js
1 ( function( window, document, settings ) { 2 /** 3 * Detect if the browser supports rendering emoji or flag emoji. Flag emoji are a single glyph 4 * made of two characters, so some browsers (notably, Firefox OS X) don't support them. 5 * 6 * @since 4.2.0 7 * 8 * @param type {String} Whether to test for support of "simple" or "flag" emoji. 9 * @return {Boolean} True if the browser can render emoji, false if it cannot. 10 */ 11 function browserSupportsEmoji( type ) { 12 var canvas = document.createElement( 'canvas' ), 13 context = canvas.getContext && canvas.getContext( '2d' ); 14 15 canvas.id = 'wp-emoji-support-tester'; 16 17 if ( ! context || ! context.fillText ) { 18 return false; 19 } 20 21 /* 22 * Chrome on OS X added native emoji rendering in M41. Unfortunately, 23 * it doesn't work when the font is bolder than 500 weight. So, we 24 * check for bold rendering support to avoid invisible emoji in Chrome. 25 */ 26 context.textBaseline = 'top'; 27 context.font = '600 32px Arial'; 28 29 if ( type === 'flag' ) { 30 /* 31 * This works because the image will be one of three things: 32 * - Two empty squares, if the browser doesn't render emoji 33 * - Two squares with 'G' and 'B' in them, if the browser doesn't render flag emoji 34 * - The British flag 35 * 36 * The first two will encode to small images (1-2KB data URLs), the third will encode 37 * to a larger image (4-5KB data URL). 38 */ 39 context.fillText( String.fromCharCode( 55356, 56812, 55356, 56807 ), 0, 0 ); 40 return canvas.toDataURL().length > 3000; 41 } else { 42 /* 43 * This creates a smiling emoji, and checks to see if there is any image data in the 44 * center pixel. In browsers that don't support emoji, the character will be rendered 45 * as an empty square, so the center pixel will be blank. 46 */ 47 context.fillText( String.fromCharCode( 55357, 56835 ), 0, 0 ); 48 return context.getImageData( 16, 16, 1, 1 ).data[0] !== 0; 49 } 50 } 51 52 function addScript( src ) { 53 var script = document.createElement( 'script' ); 54 55 script.src = src; 56 script.type = 'text/javascript'; 57 document.getElementsByTagName( 'head' )[0].appendChild( script ); 58 } 59 60 function waitForTwemoji() { 61 if ( ! window.twemoji ) { 62 // Still waiting. 63 window.setTimeout( waitForTwemoji, 50 ); 64 return; 65 } 66 67 addScript( settings.source.wpemoji ); 68 } 69 70 settings.supports = { 71 simple: browserSupportsEmoji( 'simple' ), 72 flag: browserSupportsEmoji( 'flag' ) 73 }; 74 75 if ( ! settings.supports.simple || ! settings.supports.flag ) { 76 addScript( settings.source.twemoji || settings.source.concatemoji ); 77 78 if ( settings.source.twemoji ) { 79 waitForTwemoji(); 80 } 81 } 82 83 } )( window, document, window._wpemojiSettings ); -
src/wp-includes/js/wp-emoji.js
Property changes on: src/wp-includes/js/wp-emoji-loader.js ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property
66 66 } 67 67 68 68 /** 69 * Detect if the browser supports rendering emoji or flag emoji. Flag emoji are a single glyph70 * made of two characters, so some browsers (notably, Firefox OS X) don't support them.71 *72 * @since 4.2.073 *74 * @param type {String} Whether to test for support of "simple" or "flag" emoji.75 * @return {Boolean} True if the browser can render emoji, false if it cannot.76 */77 function browserSupportsEmoji( type ) {78 var canvas = document.createElement( 'canvas' ),79 context = canvas.getContext && canvas.getContext( '2d' );80 81 if ( ! context || ! context.fillText ) {82 return false;83 }84 85 /*86 * Chrome on OS X added native emoji rendering in M41. Unfortunately,87 * it doesn't work when the font is bolder than 500 weight. So, we88 * check for bold rendering support to avoid invisible emoji in Chrome.89 */90 context.textBaseline = 'top';91 context.font = '600 32px Arial';92 93 if ( type === 'flag' ) {94 /*95 * This works because the image will be one of three things:96 * - Two empty squares, if the browser doesn't render emoji97 * - Two squares with 'G' and 'B' in them, if the browser doesn't render flag emoji98 * - The British flag99 *100 * The first two will encode to small images (1-2KB data URLs), the third will encode101 * to a larger image (4-5KB data URL).102 */103 context.fillText( String.fromCharCode( 55356, 56812, 55356, 56807 ), 0, 0 );104 return canvas.toDataURL().length > 3000;105 } else {106 /*107 * This creates a smiling emoji, and checks to see if there is any image data in the108 * center pixel. In browsers that don't support emoji, the character will be rendered109 * as an empty square, so the center pixel will be blank.110 */111 context.fillText( String.fromCharCode( 55357, 56835 ), 0, 0 );112 return context.getImageData( 16, 16, 1, 1 ).data[0] !== 0;113 }114 }115 116 /**117 69 * Given an element or string, parse any emoji characters into Twemoji images. 118 70 * 119 71 * @since 4.2.0 … … 161 113 * Initialize our emoji support, and set up listeners. 162 114 */ 163 115 if ( twemoji && settings ) { 164 supportsEmoji = browserSupportsEmoji();165 supportsFlagEmoji = browserSupportsEmoji( 'flag' );116 supportsEmoji = window._wpemojiSettings.supports.simple; 117 supportsFlagEmoji = window._wpemojiSettings.supports.flag; 166 118 replaceEmoji = ! supportsEmoji || ! supportsFlagEmoji; 167 119 168 if ( window.addEventListener ) { 169 window.addEventListener( 'load', load, false ); 170 } else if ( window.attachEvent ) { 171 window.attachEvent( 'onload', load ); 120 if ( 'loading' == document.readyState ) { 121 if ( document.addEventListener ) { 122 document.addEventListener( 'readystatechange', load, false ); 123 } else if ( document.attachEvent ) { 124 document.attachEvent( 'onreadystatechange', load ); 125 } 126 } else { 127 load(); 172 128 } 173 129 } 174 130 175 131 return { 176 browserSupportsEmoji: browserSupportsEmoji,177 132 replaceEmoji: replaceEmoji, 178 133 parse: parse 179 134 }; -
src/wp-includes/script-loader.php
424 424 $scripts->add( 'media-audiovideo', "/wp-includes/js/media/audio-video$suffix.js", array( 'media-editor' ), false, 1 ); 425 425 $scripts->add( 'mce-view', "/wp-includes/js/mce-view$suffix.js", array( 'shortcode', 'media-models', 'media-audiovideo', 'wp-playlist' ), false, 1 ); 426 426 427 $scripts->add( 'twemoji', "/wp-includes/js/twemoji$suffix.js", array(), '1.3.2', 1 );428 $scripts->add( 'emoji', "/wp-includes/js/wp-emoji$suffix.js", array( 'twemoji' ), false, 1 );429 did_action( 'init' ) && $scripts->localize( 'emoji', '_wpemojiSettings', array(430 /**431 * Filter the URL where emoji images are hosted.432 *433 * @since 4.2.0434 *435 * @param string The emoji base URL.436 */437 'baseUrl' => apply_filters( 'emoji_url', '//s0.wp.com/wp-content/mu-plugins/emoji/twemoji/72x72' ),438 439 /**440 * Filter the extension of the emoji files.441 *442 * @since 4.2.0443 *444 * @param string The emoji extension. Default .png.445 */446 'ext' => apply_filters( 'emoji_ext', '.png' ),447 ) );448 $scripts->enqueue( 'emoji' );449 450 427 if ( is_admin() ) { 451 428 $scripts->add( 'admin-tags', "/wp-admin/js/tags$suffix.js", array( 'jquery', 'wp-ajax-response' ), false, 1 ); 452 429 did_action( 'init' ) && $scripts->localize( 'admin-tags', 'tagsl10n', array(