函数文档

_admin_bar_bump_cb()

💡 云策文档标注

概述

_admin_bar_bump_cb() 是一个已弃用的 WordPress 函数,用于打印默认的管理栏回调样式。自 WordPress 6.4.0 起,建议使用 wp_enqueue_admin_bar_bump_styles() 替代。

关键要点

  • _admin_bar_bump_cb() 函数已被弃用,自 WordPress 6.4.0 版本起不再推荐使用。
  • 替代函数是 wp_enqueue_admin_bar_bump_styles(),用于处理管理栏的样式加载。
  • 该函数检查当前主题是否支持 HTML5 样式属性,并据此输出相应的 CSS 类型属性。
  • 函数内部调用了 _deprecated_function() 来标记弃用状态,并提示开发者使用新函数。

注意事项

在开发中应避免使用此函数,转而使用 wp_enqueue_admin_bar_bump_styles() 以确保兼容性和最佳实践。


📄 原文内容

Prints default admin bar callback.

Source

function _admin_bar_bump_cb() {
_deprecated_function( __FUNCTION__, '6.4.0', 'wp_enqueue_admin_bar_bump_styles' );
$type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"';
?>
<style<?php echo $type_attr; ?> media="screen">
html { margin-top: 32px !important; }
@media screen and ( max-width: 782px ) {
html { margin-top: 46px !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#L5964">View on Trac</a> <a href="https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/deprecated.php#L5964-L5975">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_admin_bar_bump_styles() instead.
3.1.0 Introduced.