From 1dbe25bc0ad45b49de25b6e670685da85e49b48c Mon Sep 17 00:00:00 2001 From: joedolson Date: Sun, 9 Feb 2020 18:26:08 +0000 Subject: [PATCH] Toolbar: Load toolbar in `wp_body_open` when available. For accessibility, the visual appearance and source order should match. Moving the toolbar to load in the new hook `wp_body_open` (5.2) fixes a long-standing source order problem. Props jankimoradiya, afercia, SergeyBiryukov, audrasjb, ocean90, xkon, dinhtungdu. Fixes #47053. Built from https://develop.svn.wordpress.org/trunk@47221 git-svn-id: http://core.svn.wordpress.org/trunk@47021 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/default-filters.php | 2 +- wp-includes/general-template.php | 8 ++++++++ wp-includes/version.php | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php index c0f7e9add6..9a46d7e2f7 100644 --- a/wp-includes/default-filters.php +++ b/wp-includes/default-filters.php @@ -537,7 +537,7 @@ add_action( 'template_redirect', '_wp_admin_bar_init', 0 ); add_action( 'admin_init', '_wp_admin_bar_init' ); add_action( 'before_signup_header', '_wp_admin_bar_init' ); add_action( 'activate_header', '_wp_admin_bar_init' ); -add_action( 'wp_footer', 'wp_admin_bar_render', 1000 ); +add_action( 'wp_body_open', 'wp_admin_bar_render', 0 ); add_action( 'in_admin_header', 'wp_admin_bar_render', 0 ); // Former admin filters that can also be hooked on the front end. diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index 54c7483089..40eb84342b 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -2889,6 +2889,14 @@ function wp_head() { * @since 1.5.1 */ function wp_footer() { + /** + * Sets up the Admin Bar if the current theme does not use `wp_body_open`. + * + * @since 5.4.0 + */ + if ( ! did_action( 'wp_body_open' ) ) { + add_action( 'wp_footer', 'wp_admin_bar_render', 1000 ); + } /** * Prints scripts or data before the closing body tag on the front end. * diff --git a/wp-includes/version.php b/wp-includes/version.php index 785d7c6107..3cc741ef40 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.4-alpha-47220'; +$wp_version = '5.4-alpha-47221'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.