wp_sensitive_page_meta()
概述
wp_sensitive_page_meta() 是一个已弃用的 WordPress 函数,用于在页面头部输出 noindex,noarchive 和 referrer strict-origin-when-cross-origin 元标签,以控制搜索引擎索引和跨源引用行为。
关键要点
- 函数 wp_sensitive_page_meta() 自 WordPress 5.7.0 起已弃用,建议使用 wp_robots_sensitive_page() 和 wp_strict_cross_origin_referrer() 替代。
- 输出 noindex,noarchive 元标签,阻止搜索引擎索引和缓存页面内容。
- 输出 referrer strict-origin-when-cross-origin 元标签,限制跨源资源加载时的引用信息发送。
- 典型用法是作为 'wp_head' 钩子的回调函数,例如:add_action('wp_head', 'wp_sensitive_page_meta')。
注意事项
此函数已弃用,开发者应更新代码以避免使用,转而采用推荐的替代函数。
Display a noindex,noarchive meta tag and referrer strict-origin-when-cross-origin meta tag.
Description
Outputs a noindex,noarchive meta tag that tells web robots not to index or cache the page content.
Outputs a referrer strict-origin-when-cross-origin meta tag that tells the browser not to send the full URL as a referrer to other sites when cross-origin assets are loaded.
Typical usage is as a ‘wp_head’ callback:
add_action( 'wp_head', 'wp_sensitive_page_meta' );
See also
Source
function wp_sensitive_page_meta() {
_deprecated_function( __FUNCTION__, '5.7.0', 'wp_robots_sensitive_page()' );
?>
<meta name='robots' content='noindex,noarchive' />
</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#L4205">View on Trac</a> <a href="https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/deprecated.php#L4205-L4212">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/wp_strict_cross_origin_referrer/">wp_strict_cross_origin_referrer()</a><code>wp-includes/general-template.php
Displays a referrer strict-origin-when-cross-origin meta tag.
_deprecated_function()wp-includes/functions.php
Marks a function as deprecated and inform when it has been used.
Changelog
| Version | Description |
|---|---|
| 5.7.0 | Deprecated. Use wp_robots_sensitive_page() instead on 'wp_robots' filter and wp_strict_cross_origin_referrer() on 'wp_head' action. |
| 5.0.1 | Introduced. |