wppaste
WordPress

WP_Interactivity_API

Since
6.5.0
Source
wp-includes/interactivity-api/class-wp-interactivity-api.php:15
Class used to process the Interactivity API on the server.

Compatibility

WordPress
since 6.5.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Properties · 9

$directive_processorsarray<string,private static
Holds the mapping of directive attribute names to their processor methods.
$state_dataarrayprivate
Holds the initial state of the different Interactivity API stores.
$config_dataarrayprivate
Holds the configuration required by the different Interactivity API stores.
$derived_state_closuresarrayprivate
Keeps track of all derived state closures accessed during server-side rendering.
$has_processed_router_regionboolprivate
Flag that indicates whether the data-wp-router-region directive has been found in the HTML and processed.
$script_modules_that_can_load_on_client_navigationarray<string,private
Set of script modules that can be loaded after client-side navigation.
$namespace_stackarray<string|false>|nullprivate
Stack of namespaces defined by data-wp-interactive directives, in the order they are processed.
$context_stackarray<array<mixed>>|nullprivate
Stack of contexts defined by data-wp-context directives, in the order they are processed.
$current_elementarray{attributes:private
Representation in array format of the element currently being processed.

Methods · 30

Source code

final class WP_Interactivity_API {	/**	 * Holds the mapping of directive attribute names to their processor methods.	 *	 * @since 6.5.0	 * @var array<string, string>	 * @phpstan-var array{	 *     'data-wp-interactive': 'data_wp_interactive_processor',	 *     'data-wp-router-region': 'data_wp_router_region_processor',	 *     'data-wp-context': 'data_wp_context_processor',	 *     'data-wp-bind': 'data_wp_bind_processor',	 *     'data-wp-class': 'data_wp_class_processor',	 *     'data-wp-style': 'data_wp_style_processor',	 *     'data-wp-text': 'data_wp_text_processor',	 *     'data-wp-each': 'data_wp_each_processor',	 * }	 */	private static array $directive_processors = array(		'data-wp-interactive'   => 'data_wp_interactive_processor',		'data-wp-router-region' => 'data_wp_router_region_processor',		'data-wp-context'       => 'data_wp_context_processor',		'data-wp-bind'          => 'data_wp_bind_processor',		'data-wp-class'         => 'data_wp_class_processor',		'data-wp-style'         => 'data_wp_style_processor',		'data-wp-text'          => 'data_wp_text_processor',		/*		 * `data-wp-each` needs to be processed in the last place because it moves		 * the cursor to the end of the processed items to prevent them to be		 * processed twice.		 */		'data-wp-each'          => 'data_wp_each_processor',	); 	/**	 * Holds the initial state of the different Interactivity API stores.	 *	 * This state is used during the server directive processing. Then, it is	 * serialized and sent to the client as part of the interactivity data to be	 * recovered during the hydration of the client interactivity stores.	 *	 * @since 6.5.0	 * @var array	 */	private $state_data = array(); 	/**	 * Holds the configuration required by the different Interactivity API stores.	 *	 * This configuration is serialized and sent to the client as part of the	 * interactivity data and can be accessed by the client interactivity stores.	 *	 * @since 6.5.0	 * @var array	 */	private $config_data = array(); 	/**	 * Keeps track of all derived state closures accessed during server-side rendering.	 *	 * This data is serialized and sent to the client as part of the interactivity	 * data, and is handled later in the client to support derived state props that	 * are lazily hydrated.	 *	 * @since 6.9.0	 * @var array	 */	private $derived_state_closures = array(); 	/**	 * Flag that indicates whether the `data-wp-router-region` directive has	 * been found in the HTML and processed.	 *	 * The value is saved in a private property of the WP_Interactivity_API	 * instance instead of using a static variable inside the processor	 * function, which would hold the same value for all instances	 * independently of whether they have processed any	 * `data-wp-router-region` directive or not.	 *	 * @since 6.5.0	 * @var bool

Changelog

Introduced in 6.5.0. 5 changes between 6.7.7 and 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

6.9.7
Method add_load_on_client_navigation_attribute_to_script_modules() added.verified against source
6.9.7
Method add_client_navigation_support_to_script_module() added.verified against source
6.9.7
Method parse_directive_name() added.verified against source
6.9.7
Method get_directive_entries() added.verified against source
6.9.7
Method extract_prefix_and_suffix() removed.verified against source
6.5.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/interactivity-api/class-wp-interactivity-api.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.