From 334656faaf5098a7cd306c1c16fd772fa9c39e1e Mon Sep 17 00:00:00 2001 From: Ari Stathopoulos Date: Wed, 21 Apr 2021 16:09:49 +0300 Subject: [PATCH] Add skip link to block templates (#30336) * Add skip-link to FSE themes * Add check for null selectors * Allow opt-in to auto-css for the skip-link * Escape things where needed * Add inline comment * This MUST NOT be escaped * Use wp_json_encode * Don't use an anonymous function * Allow multiple skip-links * Update lib/class-wp-theme-json.php Co-authored-by: Timothy Jacobs * fix should_add_skip_link_styles check after the refactor * make css opt-out * classList.add can add multiple classes at once * Add docs * fix merge conflicts * attempt to simplify previous implementation * more merge-conflicts * No docs tweaks needed * fix link label * This file is irrelevant to this PR * add missing textdomain * Update list of elements to check for * Use gutenberg_supports_block_templates() * Revert "Update list of elements to check for" This reverts commit a6947c4993ca2655c8cf19312eb1a586b9cd55fb. Co-authored-by: Timothy Jacobs --- lib/full-site-editing/templates.php | 91 +++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/lib/full-site-editing/templates.php b/lib/full-site-editing/templates.php index 0ecfcc9a68d8e..fd571fbef14f6 100644 --- a/lib/full-site-editing/templates.php +++ b/lib/full-site-editing/templates.php @@ -192,3 +192,94 @@ function set_unique_slug_on_create_template( $post_id ) { } } add_action( 'save_post_wp_template', 'set_unique_slug_on_create_template' ); + +/** + * Print the skip-link script & styles. + * + * @return void + */ +function gutenberg_the_skip_link() { + + // Early exit if not an FSE theme. + if ( ! gutenberg_supports_block_templates() ) { + return; + } + ?> + + + + + +