Ticket #31701: 31701.4.diff
File 31701.4.diff, 8.6 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: { … … 613 626 'uglify:media', 614 627 'uglify:jqueryui', 615 628 'concat:tinymce', 629 'concat:emoji', 616 630 'compress:tinymce', 617 631 'clean:tinymce', 618 632 'jsvalidate:build' -
src/wp-includes/default-filters.php
224 224 add_action( 'init', 'check_theme_switched', 99 ); 225 225 add_action( 'after_switch_theme', '_wp_sidebars_changed' ); 226 226 add_action( 'wp_print_styles', 'print_emoji_styles' ); 227 add_action( 'wp_print_scripts', 'print_emoji_detection_script' ); 227 228 228 229 if ( isset( $_GET['replytocom'] ) ) 229 230 add_action( 'wp_head', 'wp_no_robots' ); -
src/wp-includes/formatting.php
4082 4082 * @since 4.2.0 4083 4083 */ 4084 4084 function print_emoji_styles() { 4085 static $printed = false; 4086 if ( $printed ) { 4087 return; 4088 } 4089 $printed = true; 4085 4090 ?> 4086 4091 <style type="text/css"> 4087 4092 img.wp-smiley, … … 4100 4105 <?php 4101 4106 } 4102 4107 4108 function print_emoji_detection_script() { 4109 global $wp_version; 4110 4111 static $printed = false; 4112 if ( $printed ) { 4113 return; 4114 } 4115 $printed = true; 4116 4117 $min = SCRIPT_DEBUG ? '' : '.min'; 4118 4119 $settings = array( 4120 /** 4121 * Filter the URL where emoji images are hosted. 4122 * 4123 * @since 4.2.0 4124 * 4125 * @param string The emoji base URL. 4126 */ 4127 'baseUrl' => apply_filters( 'emoji_url', '//s0.wp.com/wp-content/mu-plugins/emoji/twemoji/72x72' ), 4128 4129 /** 4130 * Filter the extension of the emoji files. 4131 * 4132 * @since 4.2.0 4133 * 4134 * @param string The emoji extension. Default .png. 4135 */ 4136 'ext' => apply_filters( 'emoji_ext', '.png' ), 4137 'ver' => $wp_version, 4138 ); 4139 4140 if ( SCRIPT_DEBUG ) { 4141 $settings['js'] = array( 4142 'wpemoji' => includes_url( "js/wp-emoji.js" ), 4143 'twemoji' => includes_url( "js/twemoji.js" ), 4144 ); 4145 } else { 4146 $settings['js'] = array( 4147 'wpemoji' => includes_url( "js/wp-emoji-release.min.js" ), 4148 ); 4149 } 4150 4151 ?> 4152 <script type="text/javascript"> 4153 window._wpemojiSettings = <?php echo wp_json_encode( $settings ); ?>; 4154 <?php readfile( ABSPATH . WPINC . "/js/wp-emoji-loader$min.js" ); ?> 4155 </script> 4156 <?php 4157 } 4158 4103 4159 /** 4104 4160 * Convert any 4 byte emoji in a string to their equivalent HTML entity. 4105 4161 * -
src/wp-includes/js/wp-emoji-loader.js
1 ( function( window ) { 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 var browserSupportsEmoji = function( type ) { 12 var canvas = document.createElement( 'canvas' ), 13 context = canvas.getContext && canvas.getContext( '2d' ); 14 15 if ( ! context || ! context.fillText ) { 16 return false; 17 } 18 19 /* 20 * Chrome on OS X added native emoji rendering in M41. Unfortunately, 21 * it doesn't work when the font is bolder than 500 weight. So, we 22 * check for bold rendering support to avoid invisible emoji in Chrome. 23 */ 24 context.textBaseline = 'top'; 25 context.font = '600 32px Arial'; 26 27 if ( type === 'flag' ) { 28 /* 29 * This works because the image will be one of three things: 30 * - Two empty squares, if the browser doesn't render emoji 31 * - Two squares with 'G' and 'B' in them, if the browser doesn't render flag emoji 32 * - The British flag 33 * 34 * The first two will encode to small images (1-2KB data URLs), the third will encode 35 * to a larger image (4-5KB data URL). 36 */ 37 context.fillText( String.fromCharCode( 55356, 56812, 55356, 56807 ), 0, 0 ); 38 return canvas.toDataURL().length > 3000; 39 } else { 40 /* 41 * This creates a smiling emoji, and checks to see if there is any image data in the 42 * center pixel. In browsers that don't support emoji, the character will be rendered 43 * as an empty square, so the center pixel will be blank. 44 */ 45 context.fillText( String.fromCharCode( 55357, 56835 ), 0, 0 ); 46 return context.getImageData( 16, 16, 1, 1 ).data[0] !== 0; 47 } 48 }; 49 50 if ( ! browserSupportsEmoji( 'simple' ) || ! browserSupportsEmoji( 'flag' ) ) { 51 var src; 52 if ( window._wpemojiSettings.js.twemoji ) { 53 src = window._wpemojiSettings.js.twemoji; 54 } else { 55 src = window._wpemojiSettings.js.wpemoji; 56 } 57 58 var script = document.createElement( 'script' ); 59 script.src = src + '?ver=' + window._wpemojiSettings.ver; 60 script.type = 'text/javascript'; 61 document.getElementsByTagName( 'head' )[0].appendChild( script ); 62 63 if ( window._wpemojiSettings.js.twemoji ) { 64 waitForTwemoji(); 65 } 66 } 67 68 function waitForTwemoji() { 69 if ( ! window.twemoji ) { 70 // Still waiting. 71 window.setTimeout( waitForTwemoji, 50 ); 72 } 73 74 var script = document.createElement( 'script' ); 75 script.src = window._wpemojiSettings.js.wpemoji + '?ver=' + window._wpemojiSettings.ver; 76 script.type = 'text/javascript'; 77 document.getElementsByTagName( 'head' )[0].appendChild( script ); 78 } 79 80 } )( window ); -
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
165 165 supportsFlagEmoji = browserSupportsEmoji( 'flag' ); 166 166 replaceEmoji = ! supportsEmoji || ! supportsFlagEmoji; 167 167 168 if ( window.addEventListener ) { 169 window.addEventListener( 'load', load, false ); 170 } else if ( window.attachEvent ) { 171 window.attachEvent( 'onload', load ); 168 if ( 'loading' == document.readyState ) { 169 if ( window.addEventListener ) { 170 window.addEventListener( 'load', load, false ); 171 } else if ( window.attachEvent ) { 172 window.attachEvent( 'onload', load ); 173 } 174 } else { 175 load(); 172 176 } 173 177 } 174 178 -
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(