The print_emoji_detection_script() WordPress PHP function prints the inline Emoji detection script if it is not already printed.
Usage
print_emoji_detection_script();
Parameters
- None
More information
See WordPress Developer Resources: print_emoji_detection_script()
Examples
Basic usage
In this example, the print_emoji_detection_script() function is called in the header.php
file of a WordPress theme to print the Emoji detection script.
<head> ... // Print the Emoji detection script print_emoji_detection_script(); ... </head>
Conditionally print the script
In this example, the print_emoji_detection_script() function is only called when a certain page is being viewed.
if (is_page('emoji-page')) { // Print the Emoji detection script for the 'emoji-page' print_emoji_detection_script(); }
Print the script on a custom post type
In this example, the print_emoji_detection_script() function is called when a custom post type named ’emoji-collection’ is being viewed.
if (is_singular('emoji-collection')) { // Print the Emoji detection script for the 'emoji-collection' post type print_emoji_detection_script(); }
Print the script in a shortcode
In this example, the print_emoji_detection_script() function is called within a shortcode to ensure the Emoji detection script is printed when the shortcode is used.
function my_emoji_shortcode($atts) { // Print the Emoji detection script print_emoji_detection_script(); // Return the content for the shortcode return 'My Emoji Shortcode Content'; } add_shortcode('my_emoji', 'my_emoji_shortcode');
Print the script on a custom action
In this example, the print_emoji_detection_script() function is called on a custom action to print the Emoji detection script when the action is triggered.
function my_custom_action() { // Print the Emoji detection script print_emoji_detection_script(); } add_action('my_custom_action_hook', 'my_custom_action');