Skip to content

Commit

Permalink
Only add the content skip link for block templates (#32451)
Browse files Browse the repository at this point in the history
  • Loading branch information
aristath authored and youknowriad committed Jun 14, 2021
1 parent 6c6a656 commit d7754fc
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions lib/full-site-editing/templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,21 @@ function set_unique_slug_on_create_template( $post_id ) {
* @return void
*/
function gutenberg_the_skip_link() {
// Early exit if on WP 5.8+.
if ( function_exists( 'the_block_template_skip_link' ) ) {
return;
}

// Early exit if not an FSE theme.
// Early exit if not a block theme.
if ( ! gutenberg_supports_block_templates() ) {
return;
}

// Early exit if not a block template.
global $_wp_current_template_content;
if ( ! $_wp_current_template_content ) {
return;
}
?>

<?php
Expand Down Expand Up @@ -261,7 +271,12 @@ function gutenberg_the_skip_link() {

// Get the site wrapper.
// The skip-link will be injected in the beginning of it.
parentEl = document.querySelector( '.wp-site-blocks' ) || document.body,
parentEl = document.querySelector( '.wp-site-blocks' );

// Early exit if the root element was not found.
if ( ! parentEl ) {
return;
}

// Get the skip-link target's ID, and generate one if it doesn't exist.
skipLinkTargetID = skipLinkTarget.id;
Expand Down

0 comments on commit d7754fc

Please sign in to comment.