函数文档

print_emoji_styles()

💡 云策文档标注

概述

print_emoji_styles() 是一个已弃用的 WordPress 函数,用于输出与表情符号相关的重要样式。自 WordPress 6.4.0 起,建议使用 wp_enqueue_emoji_styles() 替代。

关键要点

  • 函数 print_emoji_styles() 已被弃用,从 WordPress 6.4.0 开始,应改用 wp_enqueue_emoji_styles()。
  • 该函数检查当前主题是否支持 HTML5 样式,并输出相应的样式标签。
  • 函数内部使用 static 变量确保样式只被输出一次,避免重复。

注意事项

  • 在开发新代码时,避免使用此函数,以遵循 WordPress 最佳实践和兼容性。
  • 如果维护旧代码,应考虑迁移到 wp_enqueue_emoji_styles() 以保持更新。

📄 原文内容

Prints the important emoji-related styles.

Source

function print_emoji_styles() {
_deprecated_function( __FUNCTION__, '6.4.0', 'wp_enqueue_emoji_styles' );
static $printed = false;

if ( $printed ) {
return;
}

$printed = true;

$type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"';
?>
<style<?php echo $type_attr; ?>>
img.wp-smiley,
img.emoji {
display: inline !important;
border: none !important;
box-shadow: none !important;
height: 1em !important;
width: 1em !important;
margin: 0 0.07em !important;
vertical-align: -0.1em !important;
background: none !important;
padding: 0 !important;
}
</style>

</pre><p class="wporg-dot-link-list"><a href="https://developer.wordpress.org/reference/files/wp-includes/deprecated.php/">View all references</a> <a href="https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/deprecated.php#L5915">View on Trac</a> <a href="https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/deprecated.php#L5915-L5942">View on GitHub</a></p></section>

<section class="wp-block-wporg-code-reference-related" data-nosnippet="true"><h2 id="related" class="is-toc-heading wp-block-heading has-heading-5-font-size" tabindex="-1" ><a href="#related">Related</a></h2> <section style="margin-top:var(--wp--preset--spacing--20)" class="wp-block-wporg-code-table" id="uses"><figure class="wp-block-table "><table><thead><tr><th scope="col">Uses</th><th scope="col">Description</th></tr></thead><tbody><tr class=""><td><a href="https://developer.wordpress.org/reference/functions/current_theme_supports/">current_theme_supports()</a><code>wp-includes/theme.php

Checks a theme’s support for a given feature.

_deprecated_function()wp-includes/functions.php

Marks a function as deprecated and inform when it has been used.

Changelog

Version Description
6.4.0 Deprecated. Use wp_enqueue_emoji_styles() instead.
4.2.0 Introduced.