Skip to content

Commit

Permalink
Revert [59097] because it was renaming a public method that should be…
Browse files Browse the repository at this point in the history
… deprecated instead.

git-svn-id: https://develop.svn.wordpress.org/trunk@59098 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
michalczaplinski committed Sep 26, 2024
1 parent ad1fabe commit bbec266
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 34 deletions.
53 changes: 20 additions & 33 deletions src/wp-includes/interactivity-api/class-wp-interactivity-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,26 +199,6 @@ public function print_client_interactivity_data() {
_deprecated_function( __METHOD__, '6.7.0' );
}

/**
* Set client-side interactivity-router data.
*
* Once in the browser, the state will be parsed and used to hydrate the client-side
* interactivity stores and the configuration will be available using a `getConfig` utility.
*
* @since 6.7.0
*
* @param array $data Data to filter.
* @return array Data for the Interactivity Router script module.
*/
public function filter_script_module_interactivity_router_data( array $data ): array {
if ( ! isset( $data['i18n'] ) ) {
$data['i18n'] = array();
}
$data['i18n']['loading'] = __( 'Loading page, please wait.' );
$data['i18n']['loaded'] = __( 'Page Loaded.' );
return $data;
}

/**
* Set client-side interactivity data.
*
Expand Down Expand Up @@ -316,7 +296,6 @@ public function register_script_modules() {
*/
public function add_hooks() {
add_filter( 'script_module_data_@wordpress/interactivity', array( $this, 'filter_script_module_interactivity_data' ) );
add_filter( 'script_module_data_@wordpress/interactivity-router', array( $this, 'filter_script_module_interactivity_router_data' ) );
}

/**
Expand Down Expand Up @@ -994,21 +973,29 @@ private function get_router_animation_styles(): string {
}

/**
* Outputs markup for the @wordpress/interactivity-router script module.
* Outputs the markup for the top loading indicator and the screen reader
* notifications during client-side navigations.
*
* This method prints a div element representing a loading bar visible during
* navigation.
* navigation, as well as an aria-live region that can be read by screen
* readers to announce navigation status.
*
* @since 6.7.0
* @since 6.5.0
*/
public function print_router_markup() {
public function print_router_loading_and_screen_reader_markup() {
echo <<<HTML
<div
class="wp-interactivity-router-loading-bar"
data-wp-interactive="core/router"
data-wp-class--start-animation="state.navigation.hasStarted"
data-wp-class--finish-animation="state.navigation.hasFinished"
></div>
<div
class="screen-reader-text"
aria-live="polite"
data-wp-interactive="core/router"
data-wp-text="state.navigation.message"
></div>
HTML;
}

Expand All @@ -1029,16 +1016,16 @@ private function data_wp_router_region_processor( WP_Interactivity_API_Directive
if ( 'enter' === $mode && ! $this->has_processed_router_region ) {
$this->has_processed_router_region = true;

/*
* Initialize the `core/router` store.
* If the store is not initialized like this with minimal
* navigation object, the interactivity-router script module
* errors.
*/
// Initialize the `core/router` store.
$this->state(
'core/router',
array(
'navigation' => new stdClass(),
'navigation' => array(
'texts' => array(
'loading' => __( 'Loading page, please wait.' ),
'loaded' => __( 'Page Loaded.' ),
),
),
)
);

Expand All @@ -1048,7 +1035,7 @@ private function data_wp_router_region_processor( WP_Interactivity_API_Directive
wp_enqueue_style( 'wp-interactivity-router-animations' );

// Adds the necessary markup to the footer.
add_action( 'wp_footer', array( $this, 'print_router_markup' ) );
add_action( 'wp_footer', array( $this, 'print_router_loading_and_screen_reader_markup' ) );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function test_wp_router_region_missing() {
*
* @covers ::process_directives
*/
public function test_wp_router_region_adds_loading_bar_region_only_once() {
public function test_wp_router_region_adds_loading_bar_aria_live_region_only_once() {
$html = '
<div data-wp-router-region="region A">Interactive region</div>
<div data-wp-router-region="region B">Another interactive region</div>
Expand All @@ -125,5 +125,9 @@ public function test_wp_router_region_adds_loading_bar_region_only_once() {
$p = new WP_HTML_Tag_Processor( $footer );
$this->assertTrue( $p->next_tag( $query ) );
$this->assertFalse( $p->next_tag( $query ) );
$query = array( 'class_name' => 'screen-reader-text' );
$p = new WP_HTML_Tag_Processor( $footer );
$this->assertTrue( $p->next_tag( $query ) );
$this->assertFalse( $p->next_tag( $query ) );
}
}

0 comments on commit bbec266

Please sign in to comment.