print_emoji_detection_script

Print the inline Emoji detection script if it is not already printed.

Description

print_emoji_detection_script(); 

Usage

  1. if ( !function_exists( 'print_emoji_detection_script' ) ) { 
  2. require_once ABSPATH . WPINC . '/formatting.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = print_emoji_detection_script(); 
  7.  

Defined (2)

The function is defined in the following location(s).

/wp-includes/formatting.php  
  1. function print_emoji_detection_script() { 
  2. static $printed = false; 
  3.  
  4. if ( $printed ) { 
  5. return; 
  6.  
  7. $printed = true; 
  8.  
  9. _print_emoji_detection_script(); 
  1. function _print_emoji_detection_script() { 
  2. $settings = array( 
  3. /** 
  4. * Filters the URL where emoji png images are hosted. 
  5. * @since 4.2.0 
  6. * @param string The emoji base URL for png images. 
  7. */ 
  8. 'baseUrl' => apply_filters( 'emoji_url', 'https://s.w.org/images/core/emoji/2.2.1/72x72/' ),  
  9.  
  10. /** 
  11. * Filters the extension of the emoji png files. 
  12. * @since 4.2.0 
  13. * @param string The emoji extension for png files. Default .png. 
  14. */ 
  15. 'ext' => apply_filters( 'emoji_ext', '.png' ),  
  16.  
  17. /** 
  18. * Filters the URL where emoji SVG images are hosted. 
  19. * @since 4.6.0 
  20. * @param string The emoji base URL for svg images. 
  21. */ 
  22. 'svgUrl' => apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/2.2.1/svg/' ),  
  23.  
  24. /** 
  25. * Filters the extension of the emoji SVG files. 
  26. * @since 4.6.0 
  27. * @param string The emoji extension for svg files. Default .svg. 
  28. */ 
  29. 'svgExt' => apply_filters( 'emoji_svg_ext', '.svg' ),  
  30. ); 
  31.  
  32. $version = 'ver=' . get_bloginfo( 'version' ); 
  33.  
  34. if ( SCRIPT_DEBUG ) { 
  35. $settings['source'] = array( 
  36. /** This filter is documented in wp-includes/class.wp-scripts.php */ 
  37. 'wpemoji' => apply_filters( 'script_loader_src', includes_url( "js/wp-emoji.js?$version" ), 'wpemoji' ),  
  38. /** This filter is documented in wp-includes/class.wp-scripts.php */ 
  39. 'twemoji' => apply_filters( 'script_loader_src', includes_url( "js/twemoji.js?$version" ), 'twemoji' ),  
  40. ); 
  41.  
  42. ?> 
  43. <script type="text/javascript"> 
  44. window._wpemojiSettings = <?php echo wp_json_encode( $settings ); ?>; 
  45. <?php readfile( ABSPATH . WPINC . "/js/wp-emoji-loader.js" ); ?> 
  46. </script> 
  47. <?php 
  48. } else { 
  49. $settings['source'] = array( 
  50. /** This filter is documented in wp-includes/class.wp-scripts.php */ 
  51. 'concatemoji' => apply_filters( 'script_loader_src', includes_url( "js/wp-emoji-release.min.js?$version" ), 'concatemoji' ),  
  52. ); 
  53.  
  54. /** 
  55. * If you're looking at a src version of this file, you'll see an "include" 
  56. * statement below. This is used by the `grunt build` process to directly 
  57. * include a minified version of wp-emoji-loader.js, instead of using the 
  58. * readfile() method from above. 
  59. * If you're looking at a build version of this file, you'll see a string of 
  60. * minified JavaScript. If you need to debug it, please turn on SCRIPT_DEBUG 
  61. * and edit wp-emoji-loader.js directly. 
  62. */ 
  63. ?> 
  64. <script type="text/javascript"> 
  65. window._wpemojiSettings = <?php echo wp_json_encode( $settings ); ?>; 
  66. !function(a, b, c) {function d(a) {var b, c, d, e, f=String.fromCharCode;if(!k||!k.fillText)return!1;switch(k.clearRect(0, 0, j.width, j.height), k.textBaseline="top", k.font="600 32px Arial", a) {case"flag":return k.fillText(f(55356, 56826, 55356, 56819), 0, 0), !(j.toDataURL().length<3e3)&&(k.clearRect(0, 0, j.width, j.height), k.fillText(f(55356, 57331, 65039, 8205, 55356, 57096), 0, 0), b=j.toDataURL(), k.clearRect(0, 0, j.width, j.height), k.fillText(f(55356, 57331, 55356, 57096), 0, 0), c=j.toDataURL(), b!==c);case"emoji4":return k.fillText(f(55357, 56425, 55356, 57341, 8205, 55357, 56507), 0, 0), d=j.toDataURL(), k.clearRect(0, 0, j.width, j.height), k.fillText(f(55357, 56425, 55356, 57341, 55357, 56507), 0, 0), e=j.toDataURL(), d!==e}return!1}function e(a) {var c=b.createElement("script");c.src=a, c.defer=c.type="text/javascript", b.getElementsByTagName("head")[0].appendChild(c)}var f, g, h, i, j=b.createElement("canvas"), k=j.getContext&&j.getContext("2d");for(i=Array("flag", "emoji4"), c.supports={everything:!0, everythingExceptFlag:!0}, h=0;h<i.length;h++)c.supports[i[h]]=d(i[h]), c.supports.everything=c.supports.everything&&c.supports[i[h]], "flag"!==i[h]&&(c.supports.everythingExceptFlag=c.supports.everythingExceptFlag&&c.supports[i[h]]);c.supports.everythingExceptFlag=c.supports.everythingExceptFlag&&!c.supports.flag, c.DOMReady=!1, c.readyCallback=function() {c.DOMReady=!0}, c.supports.everything||(g=function() {c.readyCallback()}, b.addEventListener?(b.addEventListener("DOMContentLoaded", g, !1), a.addEventListener("load", g, !1)):(a.attachEvent("onload", g), b.attachEvent("onreadystatechange", function() {"complete"===b.readyState&&c.readyCallback()})), f=c.source||{}, f.concatemoji?e(f.concatemoji):f.wpemoji&&f.twemoji&&(e(f.twemoji), e(f.wpemoji)))}(window, document, window._wpemojiSettings); 
  67. </script> 
  68. <?php