PluginProbe
Gutenberg / 17.5.2
Gutenberg v17.5.2
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
gutenberg / lib / experimental / interactivity-api / initial-state.php

initial-state.php in Gutenberg 17.5.2, at lib/experimental/interactivity-api/initial-state.php

30 lines 794 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Functions to expose the store of the WP_Interactivity_Initial_State class.
4 *
5 * @package Gutenberg
6 * @subpackage Interactivity API
7 */
8
9 if ( ! function_exists( 'wp_initial_state' ) ) {
10 /**
11 * Merge data into the state with the given namespace.
12 *
13 * @param string $store_ns Namespace.
14 * @param array $data State to merge.
15 *
16 * @return array The current state for the given namespace.
17 */
18 function wp_initial_state( $store_ns, $data = null ) {
19 if ( $data ) {
20 WP_Interactivity_Initial_State::merge_state( $store_ns, $data );
21 }
22 return WP_Interactivity_Initial_State::get_state( $store_ns );
23 }
24
25 /**
26 * Render the Interactivity API initial state in the frontend.
27 */
28 add_action( 'wp_footer', array( 'WP_Interactivity_Initial_State', 'render' ), 8 );
29 }
30