diff --git a/src/wp-includes/assets/script-modules-packages.min.php b/src/wp-includes/assets/script-modules-packages.min.php index 204c67f1be50c..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'), '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'), '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')); diff --git a/src/wp-includes/class-wp-script-modules.php b/src/wp-includes/class-wp-script-modules.php index 2f2cf967f4bac..384bf9ef2f59b 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 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. + * + * @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,20 @@ 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; + } + echo '
' + . '' + . '
' + . '
' + . '
'; + } } 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/';