diff --git a/src/wp-includes/default-filters.php b/src/wp-includes/default-filters.php
index e99d0db3a6407..fa756427d1552 100644
--- a/src/wp-includes/default-filters.php
+++ b/src/wp-includes/default-filters.php
@@ -716,7 +716,8 @@
add_filter( 'render_block_context', '_block_template_render_without_post_block_context' );
add_filter( 'pre_wp_unique_post_slug', 'wp_filter_wp_template_unique_post_slug', 10, 5 );
add_action( 'save_post_wp_template_part', 'wp_set_unique_slug_on_create_template_part' );
-add_action( 'wp_footer', 'the_block_template_skip_link' );
+add_action( 'wp_enqueue_scripts', 'wp_enqueue_block_template_skip_link' );
+add_action( 'wp_footer', 'the_block_template_skip_link' ); // Retained for backwards-compatibility. Unhooked by wp_enqueue_block_template_skip_link().
add_action( 'setup_theme', 'wp_enable_block_templates' );
add_action( 'wp_loaded', '_add_template_loader_filters' );
diff --git a/src/wp-includes/deprecated.php b/src/wp-includes/deprecated.php
index 51d7490c87c25..e98cad915fd11 100644
--- a/src/wp-includes/deprecated.php
+++ b/src/wp-includes/deprecated.php
@@ -6124,3 +6124,112 @@ function _remove_theme_attribute_in_block_template_content( $template_content )
return $new_content;
}
+
+/**
+ * Prints the skip-link script & styles.
+ *
+ * @since 5.8.0
+ * @access private
+ * @deprecated 6.4.0 Use wp_enqueue_block_template_skip_link() instead.
+ *
+ * @global string $_wp_current_template_content
+ */
+function the_block_template_skip_link() {
+ _deprecated_function( __FUNCTION__, '6.4.0', 'wp_enqueue_block_template_skip_link()' );
+
+ global $_wp_current_template_content;
+
+ // Early exit if not a block theme.
+ if ( ! current_theme_supports( 'block-templates' ) ) {
+ return;
+ }
+
+ // Early exit if not a block template.
+ if ( ! $_wp_current_template_content ) {
+ return;
+ }
+ ?>
+
+
+
+
+
+ true ) );
wp_add_inline_script( $script_handle, $skip_link_script );
wp_enqueue_script( $script_handle );
}