File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -188,10 +188,16 @@ function gutenberg_the_skip_link() {
188188 return ;
189189 }
190190
191- // Early exit if not an FSE theme.
191+ // Early exit if not a block theme.
192192 if ( ! gutenberg_supports_block_templates () ) {
193193 return ;
194194 }
195+
196+ // Early exit if not a block template.
197+ global $ _wp_current_template_content ;
198+ if ( ! $ _wp_current_template_content ) {
199+ return ;
200+ }
195201 ?>
196202
197203 <?php
@@ -249,7 +255,12 @@ function gutenberg_the_skip_link() {
249255
250256 // Get the site wrapper.
251257 // The skip-link will be injected in the beginning of it.
252- parentEl = document.querySelector( '.wp-site-blocks' ) || document.body,
258+ parentEl = document.querySelector( '.wp-site-blocks' );
259+
260+ // Early exit if the root element was not found.
261+ if ( ! parentEl ) {
262+ return;
263+ }
253264
254265 // Get the skip-link target's ID, and generate one if it doesn't exist.
255266 skipLinkTargetID = skipLinkTarget.id;
You can’t perform that action at this time.
0 commit comments