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
This commit is contained in:
joedolson 2020-02-09 18:26:08 +00:00
parent 9429c8436d
commit 1dbe25bc0a
3 changed files with 10 additions and 2 deletions

View File

@ -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.

View File

@ -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.
*

View File

@ -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.