Make WordPress Core


Ignore:
Timestamp:
09/26/2024 05:53:11 PM (19 months ago)
Author:
czapla
Message:

Interactivity API: Move interactivity-router i18n strings to Script Module data.

Moves the 'loading' and 'loaded' i18n strings for the interactivity-router to the script module data via the script_module_data_@wordpress/interactivity-router filter.

Key changes:

  • Add the filter_script_module_interactivity_router_data() method, hooked into the script_module_data_@wordpress/interactivity-router filter, to set the i18n data with the 'loading' and 'loaded' messages.
  • Rename the print_router_loading_and_screen_reader_markup() method to print_router_markup() and remove the screen reader markup from it because it's no longer needed.
  • Remove the loading and loaded strings from the core/router store state because they're no longer needed.
  • Initialize the core/router store with a minimal navigation object to prevent errors in the interactivity-router script module when the store is not properly initialized.
  • Update corresponding unit tests to reflect these changes.

This change ensures that the interactivity-router i18n messages are localized in a single place and removes the need to initialize them in the core/router store state.

Props jonsurrell, swissspidy, czapla.
See #60647.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-router-region.php

    r58594 r59097  
    103103     * @covers ::process_directives
    104104     */
    105     public function test_wp_router_region_adds_loading_bar_aria_live_region_only_once() {
     105    public function test_wp_router_region_adds_loading_bar_region_only_once() {
    106106        $html     = '
    107107            <div data-wp-router-region="region A">Interactive region</div>
     
    126126        $this->assertTrue( $p->next_tag( $query ) );
    127127        $this->assertFalse( $p->next_tag( $query ) );
    128         $query = array( 'class_name' => 'screen-reader-text' );
    129         $p     = new WP_HTML_Tag_Processor( $footer );
    130         $this->assertTrue( $p->next_tag( $query ) );
    131         $this->assertFalse( $p->next_tag( $query ) );
    132128    }
    133129}
Note: See TracChangeset for help on using the changeset viewer.