Accessibility: Toolbar: Don't output the "Skip to toolbar" link in modern themes that support the `wp_body_open` action.

The links is unnecessary there, as the toolbar is the first thing in the DOM within the `<body>` element.

For themes that don't implement the `wp_body_open` action yet and render the admin bar in the footer, the "Skip to toolbar" link with `tabindex="1"` is still necessary, to ensure it's the first focusable element in the page.

Props sarahricker, afercia, erikjandelange, audrasjb.
Fixes #50702.

git-svn-id: https://develop.svn.wordpress.org/trunk@48812 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2020-08-17 14:24:30 +00:00
parent 09a3a6e7bd
commit 7d0dc26c96
1 changed files with 1 additions and 1 deletions

View File

@ -436,7 +436,7 @@ class WP_Admin_Bar {
?>
<div id="wpadminbar" class="<?php echo $class; ?>">
<?php if ( ! is_admin() ) { ?>
<?php if ( ! is_admin() && ! did_action( 'wp_body_open' ) ) { ?>
<a class="screen-reader-shortcut" href="#wp-toolbar" tabindex="1"><?php _e( 'Skip to toolbar' ); ?></a>
<?php } ?>
<div class="quicklinks" id="wp-toolbar" role="navigation" aria-label="<?php esc_attr_e( 'Toolbar' ); ?>">