WP_Interactivity_API::data_wp_router_region_processor( WP_Interactivity_API_Directives_Processor $p, string $mode )

In this article

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

Processes the data-wp-router-region directive.


It renders in the footer a set of HTML elements to notify users about client-side navigations. More concretely, the elements added are 1) a top loading bar to visually inform that a navigation is in progress and 2) an aria-live region for accessible navigation announcements.


The directives processor instance.
Whether the processing is entering or exiting the tag.


private function data_wp_router_region_processor( WP_Interactivity_API_Directives_Processor $p, string $mode ) {
	if ( 'enter' === $mode && ! $this->has_processed_router_region ) {
		$this->has_processed_router_region = true;

		// Initialize the `core/router` store.
				'navigation' => array(
					'texts' => array(
						'loading' => __( 'Loading page, please wait.' ),
						'loaded'  => __( 'Page Loaded.' ),

		// Enqueues as an inline style.
		wp_register_style( 'wp-interactivity-router-animations', false );
		wp_add_inline_style( 'wp-interactivity-router-animations', $this->get_router_animation_styles() );
		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' ) );



User Contributed Notes

You must log in before being able to contribute a note or feedback.