# gutenberg/17.5.0/lib/experimental/interactivity-api/initial-state.php

Gutenberg, version 17.5.0. 30 lines.

- Page: https://pluginprobe.com/plugins/gutenberg/17.5.0/code/lib/experimental/interactivity-api/initial-state.php
- Raw: https://pluginprobe.com/plugins/gutenberg/17.5.0/raw/lib/experimental/interactivity-api/initial-state.php
- Modified: 2024-01-17T12:56:36+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/gutenberg/17.5.0/code/lib/experimental/interactivity-api/initial-state.php#L10-L20`.

```php
<?php
/**
 * Functions to expose the store of the WP_Interactivity_Initial_State class.
 *
 * @package Gutenberg
 * @subpackage Interactivity API
 */

if ( ! function_exists( 'wp_initial_state' ) ) {
	/**
	 * Merge data into the state with the given namespace.
	 *
	 * @param string $store_ns  Namespace.
	 * @param array  $data      State to merge.
	 *
	 * @return array The current state for the given namespace.
	 */
	function wp_initial_state( $store_ns, $data = null ) {
		if ( $data ) {
			WP_Interactivity_Initial_State::merge_state( $store_ns, $data );
		}
		return WP_Interactivity_Initial_State::get_state( $store_ns );
	}

	/**
	 * Render the Interactivity API initial state in the frontend.
	 */
	add_action( 'wp_footer', array( 'WP_Interactivity_Initial_State', 'render' ), 8 );
}

```
