Make WordPress Core

Changeset 59098


Ignore:
Timestamp:
09/26/2024 07:35:26 PM (17 months ago)
Author:
czapla
Message:

Revert [59097] because it was renaming a public method that should be deprecated instead.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/interactivity-api/class-wp-interactivity-api.php

    r59097 r59098  
    201201
    202202    /**
    203      * Set client-side interactivity-router data.
    204      *
    205      * Once in the browser, the state will be parsed and used to hydrate the client-side
    206      * interactivity stores and the configuration will be available using a `getConfig` utility.
    207      *
    208      * @since 6.7.0
    209      *
    210      * @param array $data Data to filter.
    211      * @return array Data for the Interactivity Router script module.
    212      */
    213     public function filter_script_module_interactivity_router_data( array $data ): array {
    214         if ( ! isset( $data['i18n'] ) ) {
    215             $data['i18n'] = array();
    216         }
    217         $data['i18n']['loading'] = __( 'Loading page, please wait.' );
    218         $data['i18n']['loaded']  = __( 'Page Loaded.' );
    219         return $data;
    220     }
    221 
    222     /**
    223203     * Set client-side interactivity data.
    224204     *
     
    317297    public function add_hooks() {
    318298        add_filter( 'script_module_data_@wordpress/interactivity', array( $this, 'filter_script_module_interactivity_data' ) );
    319         add_filter( 'script_module_data_@wordpress/interactivity-router', array( $this, 'filter_script_module_interactivity_router_data' ) );
    320299    }
    321300
     
    995974
    996975    /**
    997      * Outputs markup for the @wordpress/interactivity-router script module.
     976     * Outputs the markup for the top loading indicator and the screen reader
     977     * notifications during client-side navigations.
    998978     *
    999979     * This method prints a div element representing a loading bar visible during
    1000      * navigation.
    1001      *
    1002      * @since 6.7.0
    1003      */
    1004     public function print_router_markup() {
     980     * navigation, as well as an aria-live region that can be read by screen
     981     * readers to announce navigation status.
     982     *
     983     * @since 6.5.0
     984     */
     985    public function print_router_loading_and_screen_reader_markup() {
    1005986        echo <<<HTML
    1006987            <div
     
    1010991                data-wp-class--finish-animation="state.navigation.hasFinished"
    1011992            ></div>
     993            <div
     994                class="screen-reader-text"
     995                aria-live="polite"
     996                data-wp-interactive="core/router"
     997                data-wp-text="state.navigation.message"
     998            ></div>
    1012999HTML;
    10131000    }
     
    10301017            $this->has_processed_router_region = true;
    10311018
    1032             /*
    1033              * Initialize the `core/router` store.
    1034              * If the store is not initialized like this with minimal
    1035              * navigation object, the interactivity-router script module
    1036              * errors.
    1037              */
     1019            // Initialize the `core/router` store.
    10381020            $this->state(
    10391021                'core/router',
    10401022                array(
    1041                     'navigation' => new stdClass(),
     1023                    'navigation' => array(
     1024                        'texts' => array(
     1025                            'loading' => __( 'Loading page, please wait.' ),
     1026                            'loaded'  => __( 'Page Loaded.' ),
     1027                        ),
     1028                    ),
    10421029                )
    10431030            );
     
    10491036
    10501037            // Adds the necessary markup to the footer.
    1051             add_action( 'wp_footer', array( $this, 'print_router_markup' ) );
     1038            add_action( 'wp_footer', array( $this, 'print_router_loading_and_screen_reader_markup' ) );
    10521039        }
    10531040    }
  • trunk/tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-router-region.php

    r59097 r59098  
    103103     * @covers ::process_directives
    104104     */
    105     public function test_wp_router_region_adds_loading_bar_region_only_once() {
     105    public function test_wp_router_region_adds_loading_bar_aria_live_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 ) );
    128132    }
    129133}
Note: See TracChangeset for help on using the changeset viewer.