WP_Interactivity_API::data_wp_router_region_processor()privateWP 6.5.0

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.

Method of the class: WP_Interactivity_API{}

No Hooks.

Returns

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->data_wp_router_region_processor( $p, $mode );
$p(WP_Interactivity_API_Directives_Processor) (required)
The directives processor instance.
$mode(string) (required)
Whether the processing is entering or exiting the tag.

Changelog

Since 6.5.0 Introduced.

WP_Interactivity_API::data_wp_router_region_processor() code WP 6.8.1

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;

		// 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_markup' ) );
	}
}