print_embed_styles()
概述
print_embed_styles() 是一个已弃用的 WordPress 函数,用于在嵌入 iframe 头部打印 CSS 样式。自 WordPress 6.4.0 起,建议使用 wp_enqueue_embed_styles() 替代。
关键要点
- 函数 print_embed_styles() 已被弃用,从 WordPress 6.4.0 版本开始,应改用 wp_enqueue_embed_styles()。
- 该函数检查当前主题是否支持 HTML5 样式属性,并基于 SCRIPT_DEBUG 常量决定是否使用压缩版 CSS 文件。
- 相关函数包括 current_theme_supports() 和 _deprecated_function(),用于主题功能检查和弃用标记。
注意事项
在开发中,避免直接调用此函数,以遵循 WordPress 弃用策略并确保代码兼容性。
Prints the CSS in the embed iframe header.
Source
function print_embed_styles() {
_deprecated_function( __FUNCTION__, '6.4.0', 'wp_enqueue_embed_styles' );
$type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"';
$suffix = SCRIPT_DEBUG ? '' : '.min';
?>
<style<?php echo $type_attr; ?>>
</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#L5897">View on Trac</a> <a href="https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/deprecated.php#L5897-L5907">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_embed_styles() instead. |
| 4.4.0 | Introduced. |