From a2e2954becf6c5a5e6586884f4ee1846af0cdfb3 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 20 Sep 2024 21:01:48 +0200 Subject: [PATCH 1/8] Add a11y to dual script + modules list --- tools/webpack/shared.js | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/webpack/shared.js b/tools/webpack/shared.js index b446b0e0028cd..c690235a2114e 100644 --- a/tools/webpack/shared.js +++ b/tools/webpack/shared.js @@ -103,6 +103,7 @@ const MODULES = [ '@wordpress/interactivity-router', ]; const SCRIPT_AND_MODULE_DUAL_PACKAGES = [ + '@wordpress/a11y', '@wordpress/block-library', ]; const WORDPRESS_NAMESPACE = '@wordpress/'; From c9c0313e05f4fa4c43ceb630146e00b3fe4df201 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 20 Sep 2024 21:24:56 +0200 Subject: [PATCH 2/8] Update script-modules-packages file --- src/wp-includes/assets/script-modules-packages.min.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/assets/script-modules-packages.min.php b/src/wp-includes/assets/script-modules-packages.min.php index 204c67f1be50c..648752ed61fa5 100644 --- a/src/wp-includes/assets/script-modules-packages.min.php +++ b/src/wp-includes/assets/script-modules-packages.min.php @@ -1 +1 @@ - array('dependencies' => array(), 'version' => '2d6d1fdbcb3fda39c768', 'type' => 'module'), 'interactivity/debug.min.js' => array('dependencies' => array(), 'version' => '1ccc67b05c275e51a8f8', 'type' => 'module'), 'interactivity-router/index.min.js' => array('dependencies' => array('@wordpress/interactivity'), 'version' => '64645ef3cd2d32860d7d', 'type' => 'module'), 'block-library/file/view.min.js' => array('dependencies' => array('@wordpress/interactivity'), 'version' => 'fdc2f6842e015af83140', 'type' => 'module'), 'block-library/image/view.min.js' => array('dependencies' => array('@wordpress/interactivity'), 'version' => 'acfec7b3c0be4a859b31', 'type' => 'module'), 'block-library/navigation/view.min.js' => array('dependencies' => array('@wordpress/interactivity'), 'version' => '8ff192874fc8910a284c', 'type' => 'module'), 'block-library/query/view.min.js' => array('dependencies' => array('@wordpress/interactivity', array('id' => '@wordpress/interactivity-router', 'import' => 'dynamic')), 'version' => 'f4c91c89fa5271f3dad9', 'type' => 'module'), 'block-library/search/view.min.js' => array('dependencies' => array('@wordpress/interactivity'), 'version' => '2a73400a693958f604de', 'type' => 'module')); + array('dependencies' => array(), 'version' => '2d6d1fdbcb3fda39c768', 'type' => 'module'), 'interactivity/debug.min.js' => array('dependencies' => array(), 'version' => '1ccc67b05c275e51a8f8', 'type' => 'module'), 'interactivity-router/index.min.js' => array('dependencies' => array('@wordpress/interactivity', array('id' => '@wordpress/a11y', 'import' => 'dynamic')), 'version' => 'ca6f53ea8d147c724a55', 'type' => 'module'), 'a11y/index.min.js' => array('dependencies' => array(), 'version' => 'b7d06936b8bc23cff2ad', 'type' => 'module'), 'block-library/file/view.min.js' => array('dependencies' => array('@wordpress/interactivity'), 'version' => 'fdc2f6842e015af83140', 'type' => 'module'), 'block-library/image/view.min.js' => array('dependencies' => array('@wordpress/interactivity'), 'version' => 'acfec7b3c0be4a859b31', 'type' => 'module'), 'block-library/navigation/view.min.js' => array('dependencies' => array('@wordpress/interactivity'), 'version' => '8ff192874fc8910a284c', 'type' => 'module'), 'block-library/query/view.min.js' => array('dependencies' => array('@wordpress/interactivity', array('id' => '@wordpress/interactivity-router', 'import' => 'dynamic')), 'version' => 'f4c91c89fa5271f3dad9', 'type' => 'module'), 'block-library/search/view.min.js' => array('dependencies' => array('@wordpress/interactivity'), 'version' => '2a73400a693958f604de', 'type' => 'module')); From acb4d5840f8bc5e02d73bed811574a2d2bfb56ec Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 20 Sep 2024 21:25:08 +0200 Subject: [PATCH 3/8] Add a11y HTML to page --- src/wp-includes/class-wp-script-modules.php | 30 +++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/wp-includes/class-wp-script-modules.php b/src/wp-includes/class-wp-script-modules.php index 2f2cf967f4bac..296252cd1825b 100644 --- a/src/wp-includes/class-wp-script-modules.php +++ b/src/wp-includes/class-wp-script-modules.php @@ -30,6 +30,17 @@ class WP_Script_Modules { */ private $enqueued_before_registered = array(); + /** + * Tracks wehther the @wordpress/a11y script module is available. + * + * Some additional HTML is required on the page for the module to work. Track + * whether it's available to print at the appropriate time. + * + * @since 6.7.0 + * @var bool + */ + private $a11y_available = false; + /** * Registers the script module if no script module with that script module * identifier has already been registered. @@ -185,6 +196,8 @@ public function add_hooks() { add_action( 'wp_footer', array( $this, 'print_script_module_data' ) ); add_action( 'admin_print_footer_scripts', array( $this, 'print_script_module_data' ) ); + add_action( 'wp_footer', array( $this, 'print_a11y_script_module_html' ), 20 ); + add_action( 'admin_print_footer_scripts', array( $this, 'print_a11y_script_module_html' ), 20 ); } /** @@ -367,9 +380,15 @@ private function get_src( string $id ): string { public function print_script_module_data(): void { $modules = array(); foreach ( array_keys( $this->get_marked_for_enqueue() ) as $id ) { + if ( '@wordpress/a11y' === $id ) { + $this->a11y_available = true; + } $modules[ $id ] = true; } foreach ( array_keys( $this->get_import_map()['imports'] ) as $id ) { + if ( '@wordpress/a11y' === $id ) { + $this->a11y_available = true; + } $modules[ $id ] = true; } @@ -465,4 +484,15 @@ public function print_script_module_data(): void { } } } + + public function print_a11y_script_module_html() { + if ( ! $this->a11y_available ) { + return; + } + echo '
' + . '' + . '
' + . '
' + . '
'; + } } From cc5746a34c3447d53352b928962e4de8bb9b174c Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 20 Sep 2024 21:25:50 +0200 Subject: [PATCH 4/8] Add note --- src/wp-includes/class-wp-script-modules.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wp-includes/class-wp-script-modules.php b/src/wp-includes/class-wp-script-modules.php index 296252cd1825b..681807be19113 100644 --- a/src/wp-includes/class-wp-script-modules.php +++ b/src/wp-includes/class-wp-script-modules.php @@ -485,6 +485,11 @@ public function print_script_module_data(): void { } } + /** + * @access private This is only intended to be called by the registered actions. + * + * @since 6.7.0 + */ public function print_a11y_script_module_html() { if ( ! $this->a11y_available ) { return; From acef015ebee57f4187a0eaf6b2a4fc783b7887ce Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 20 Sep 2024 21:26:51 +0200 Subject: [PATCH 5/8] Remove iAPI-specific screen reader text --- .../interactivity-api/class-wp-interactivity-api.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/wp-includes/interactivity-api/class-wp-interactivity-api.php b/src/wp-includes/interactivity-api/class-wp-interactivity-api.php index 1213a5c097440..d180c5abf63e5 100644 --- a/src/wp-includes/interactivity-api/class-wp-interactivity-api.php +++ b/src/wp-includes/interactivity-api/class-wp-interactivity-api.php @@ -990,12 +990,6 @@ class="wp-interactivity-router-loading-bar" data-wp-class--start-animation="state.navigation.hasStarted" data-wp-class--finish-animation="state.navigation.hasFinished" > -
HTML; } From 244eea64b16b56aaa2efc9aefbe9f0aaddb4e1df Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 20 Sep 2024 21:26:55 +0200 Subject: [PATCH 6/8] Revert "Remove iAPI-specific screen reader text" This reverts commit 07cac5f909009f4920eb7a1a247867474330db30. --- .../interactivity-api/class-wp-interactivity-api.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/wp-includes/interactivity-api/class-wp-interactivity-api.php b/src/wp-includes/interactivity-api/class-wp-interactivity-api.php index d180c5abf63e5..1213a5c097440 100644 --- a/src/wp-includes/interactivity-api/class-wp-interactivity-api.php +++ b/src/wp-includes/interactivity-api/class-wp-interactivity-api.php @@ -990,6 +990,12 @@ class="wp-interactivity-router-loading-bar" data-wp-class--start-animation="state.navigation.hasStarted" data-wp-class--finish-animation="state.navigation.hasFinished" > +
HTML; } From d6201e3c9b05e3f04b85f519dd2fa375b6e9a388 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 20 Sep 2024 23:23:21 +0200 Subject: [PATCH 7/8] Update assets file --- src/wp-includes/assets/script-modules-packages.min.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/assets/script-modules-packages.min.php b/src/wp-includes/assets/script-modules-packages.min.php index 648752ed61fa5..e3c7915456748 100644 --- a/src/wp-includes/assets/script-modules-packages.min.php +++ b/src/wp-includes/assets/script-modules-packages.min.php @@ -1 +1 @@ - array('dependencies' => array(), 'version' => '2d6d1fdbcb3fda39c768', 'type' => 'module'), 'interactivity/debug.min.js' => array('dependencies' => array(), 'version' => '1ccc67b05c275e51a8f8', 'type' => 'module'), 'interactivity-router/index.min.js' => array('dependencies' => array('@wordpress/interactivity', array('id' => '@wordpress/a11y', 'import' => 'dynamic')), 'version' => 'ca6f53ea8d147c724a55', 'type' => 'module'), 'a11y/index.min.js' => array('dependencies' => array(), 'version' => 'b7d06936b8bc23cff2ad', 'type' => 'module'), 'block-library/file/view.min.js' => array('dependencies' => array('@wordpress/interactivity'), 'version' => 'fdc2f6842e015af83140', 'type' => 'module'), 'block-library/image/view.min.js' => array('dependencies' => array('@wordpress/interactivity'), 'version' => 'acfec7b3c0be4a859b31', 'type' => 'module'), 'block-library/navigation/view.min.js' => array('dependencies' => array('@wordpress/interactivity'), 'version' => '8ff192874fc8910a284c', 'type' => 'module'), 'block-library/query/view.min.js' => array('dependencies' => array('@wordpress/interactivity', array('id' => '@wordpress/interactivity-router', 'import' => 'dynamic')), 'version' => 'f4c91c89fa5271f3dad9', 'type' => 'module'), 'block-library/search/view.min.js' => array('dependencies' => array('@wordpress/interactivity'), 'version' => '2a73400a693958f604de', 'type' => 'module')); + array('dependencies' => array(), 'version' => '2d6d1fdbcb3fda39c768', 'type' => 'module'), 'interactivity/debug.min.js' => array('dependencies' => array(), 'version' => '1ccc67b05c275e51a8f8', 'type' => 'module'), 'interactivity-router/index.min.js' => array('dependencies' => array('@wordpress/interactivity'), 'version' => '64645ef3cd2d32860d7d', 'type' => 'module'), 'a11y/index.min.js' => array('dependencies' => array(), 'version' => 'b7d06936b8bc23cff2ad', 'type' => 'module'), 'block-library/file/view.min.js' => array('dependencies' => array('@wordpress/interactivity'), 'version' => 'fdc2f6842e015af83140', 'type' => 'module'), 'block-library/image/view.min.js' => array('dependencies' => array('@wordpress/interactivity'), 'version' => 'acfec7b3c0be4a859b31', 'type' => 'module'), 'block-library/navigation/view.min.js' => array('dependencies' => array('@wordpress/interactivity'), 'version' => '8ff192874fc8910a284c', 'type' => 'module'), 'block-library/query/view.min.js' => array('dependencies' => array('@wordpress/interactivity', array('id' => '@wordpress/interactivity-router', 'import' => 'dynamic')), 'version' => 'f4c91c89fa5271f3dad9', 'type' => 'module'), 'block-library/search/view.min.js' => array('dependencies' => array('@wordpress/interactivity'), 'version' => '2a73400a693958f604de', 'type' => 'module')); From 12636f049cae488eab276e5c87bcca70ed93e61a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Zi=C3=B3=C5=82kowski?= Date: Wed, 25 Sep 2024 08:01:02 +0200 Subject: [PATCH 8/8] Update src/wp-includes/class-wp-script-modules.php Co-authored-by: Michal --- src/wp-includes/class-wp-script-modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/class-wp-script-modules.php b/src/wp-includes/class-wp-script-modules.php index 681807be19113..384bf9ef2f59b 100644 --- a/src/wp-includes/class-wp-script-modules.php +++ b/src/wp-includes/class-wp-script-modules.php @@ -31,7 +31,7 @@ class WP_Script_Modules { private $enqueued_before_registered = array(); /** - * Tracks wehther the @wordpress/a11y script module is available. + * Tracks whether the @wordpress/a11y script module is available. * * Some additional HTML is required on the page for the module to work. Track * whether it's available to print at the appropriate time.