mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Toolbar: Move the logic for rendering the admin bar on wp_footer to wp_admin_bar_render().
Clarify in the function documentation that it is now called on `wp_body_open` action first, with `wp_footer` as a fallback. Follow-up to [47221]. Fixes #47053. git-svn-id: https://develop.svn.wordpress.org/trunk@47455 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -55,8 +55,11 @@ function _wp_admin_bar_init() {
|
||||
/**
|
||||
* Renders the admin bar to the page based on the $wp_admin_bar->menu member var.
|
||||
*
|
||||
* This is called very late on the footer actions so that it will render after
|
||||
* anything else being added to the footer.
|
||||
* This is called very early on the {@see 'wp_body_open'} action so that it will render
|
||||
* before anything else being added to the page body.
|
||||
*
|
||||
* For backward compatibility with themes not using the 'wp_body_open' action,
|
||||
* the function is also called late on {@see 'wp_footer'}.
|
||||
*
|
||||
* It includes the {@see 'admin_bar_menu'} action which should be used to hook in and
|
||||
* add new menus to the admin bar. That way you can be sure that you are adding at most
|
||||
@@ -64,11 +67,19 @@ function _wp_admin_bar_init() {
|
||||
* the `$post` global, among others.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @since 5.4.0 Called on 'wp_body_open' action first, with 'wp_footer' as a fallback.
|
||||
*
|
||||
* @global WP_Admin_Bar $wp_admin_bar
|
||||
*
|
||||
* @staticvar bool $rendered
|
||||
*/
|
||||
function wp_admin_bar_render() {
|
||||
global $wp_admin_bar;
|
||||
static $rendered = false;
|
||||
|
||||
if ( $rendered ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! is_admin_bar_showing() || ! is_object( $wp_admin_bar ) ) {
|
||||
return;
|
||||
@@ -100,6 +111,8 @@ function wp_admin_bar_render() {
|
||||
* @since 3.1.0
|
||||
*/
|
||||
do_action( 'wp_after_admin_bar_render' );
|
||||
|
||||
$rendered = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user