Changeset 59087 for trunk/src/wp-includes/class-wp-script-modules.php
- Timestamp:
- 09/25/2024 03:55:56 PM (4 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-script-modules.php
r58953 r59087 30 30 */ 31 31 private $enqueued_before_registered = array(); 32 33 /** 34 * Tracks whether the @wordpress/a11y script module is available. 35 * 36 * Some additional HTML is required on the page for the module to work. Track 37 * whether it's available to print at the appropriate time. 38 * 39 * @since 6.7.0 40 * @var bool 41 */ 42 private $a11y_available = false; 32 43 33 44 /** … … 186 197 add_action( 'wp_footer', array( $this, 'print_script_module_data' ) ); 187 198 add_action( 'admin_print_footer_scripts', array( $this, 'print_script_module_data' ) ); 199 add_action( 'wp_footer', array( $this, 'print_a11y_script_module_html' ), 20 ); 200 add_action( 'admin_print_footer_scripts', array( $this, 'print_a11y_script_module_html' ), 20 ); 188 201 } 189 202 … … 368 381 $modules = array(); 369 382 foreach ( array_keys( $this->get_marked_for_enqueue() ) as $id ) { 383 if ( '@wordpress/a11y' === $id ) { 384 $this->a11y_available = true; 385 } 370 386 $modules[ $id ] = true; 371 387 } 372 388 foreach ( array_keys( $this->get_import_map()['imports'] ) as $id ) { 389 if ( '@wordpress/a11y' === $id ) { 390 $this->a11y_available = true; 391 } 373 392 $modules[ $id ] = true; 374 393 } … … 466 485 } 467 486 } 487 488 /** 489 * @access private This is only intended to be called by the registered actions. 490 * 491 * @since 6.7.0 492 */ 493 public function print_a11y_script_module_html() { 494 if ( ! $this->a11y_available ) { 495 return; 496 } 497 echo '<div style="position:absolute;margin:-1px;padding:0;height:1px;width:1px;overflow:hidden;clip-path:inset(50%);border:0;word-wrap:normal !important;">' 498 . '<p id="a11y-speak-intro-text" class="a11y-speak-intro-text" hidden>' . esc_html__( 'Notifications' ) . '</p>' 499 . '<div id="a11y-speak-assertive" class="a11y-speak-region" aria-live="assertive" aria-relevant="additions text" aria-atomic="true"></div>' 500 . '<div id="a11y-speak-polite" class="a11y-speak-region" aria-live="polite" aria-relevant="additions text" aria-atomic="true"></div>' 501 . '</div>'; 502 } 468 503 }
Note: See TracChangeset
for help on using the changeset viewer.