-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Interactivity Router: Update for latest GB changes. #7304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c137e90
0d310f3
252648f
c03c18b
531dea9
f2ba5de
e7c6cfe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -199,6 +199,26 @@ 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. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -296,6 +316,7 @@ 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' ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -973,29 +994,21 @@ private function get_router_animation_styles(): string { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Outputs the markup for the top loading indicator and the screen reader | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * notifications during client-side navigations. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Outputs markup for the @wordpress/interactivity-router script module. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * This method prints a div element representing a loading bar visible during | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * navigation, as well as an aria-live region that can be read by screen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * readers to announce navigation status. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * navigation. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @since 6.5.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @since 6.7.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public function print_router_loading_and_screen_reader_markup() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public function print_router_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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry to bring this up after having already approved! I've just noticed that we should rename the function to
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a public method, extenders could be calling it or modifying its behavior in filters. Renaming the method could be disruptive. It's true the method name isn't a perfect description now. What do you think of adding a note in the method documentation instead of changing the name?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we could do this:
I think that might be the way to go. I’m looking at some existing functions/methods that have the @deprecated docstring. For example this function is deprecated, calls wordpress-develop/src/wp-includes/class-wp-scripts.php Lines 479 to 505 in 9e29083
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All right! |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class="screen-reader-text" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| aria-live="polite" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| data-wp-interactive="core/router" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| data-wp-text="state.navigation.message" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ></div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| HTML; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -1016,16 +1029,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. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Initialize the `core/router` store. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * If the store is not initialized like this with minimal | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * navigation object, the interactivity-router script module | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * errors. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $this->state( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'core/router', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| array( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'navigation' => array( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'texts' => array( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'loading' => __( 'Loading page, please wait.' ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'loaded' => __( 'Page Loaded.' ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'navigation' => new stdClass(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
sirreal marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -1035,7 +1048,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_loading_and_screen_reader_markup' ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| add_action( 'wp_footer', array( $this, 'print_router_markup' ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.