Prints the serialized client-side interactivity data.
Description
Encodes the config and initial state into JSON and prints them inside a script tag of type "application/json". Once in the browser, the state will be parsed and used to hydrate the client-side interactivity stores and the configuration will be available using a getConfig
utility.
Source
);
return array();
}
if ( null === $this->namespace_stack ) {
_doing_it_wrong(
__METHOD__,
__( 'The namespace can only be omitted during directive processing.' ),
'6.6.0'
);
return array();
}
$store_namespace = end( $this->namespace_stack );
}
if ( ! isset( $this->state_data[ $store_namespace ] ) ) {
$this->state_data[ $store_namespace ] = array();
}
if ( is_array( $state ) ) {
$this->state_data[ $store_namespace ] = array_replace_recursive(
$this->state_data[ $store_namespace ],
$state
);
}
return $this->state_data[ $store_namespace ];
}
/**
* Gets and/or sets the configuration of the Interactivity API for a given
* store namespace.
*
* If configuration for that store namespace exists, it merges the new
* provided configuration with the existing one.
*
* @since 6.5.0
*
* @param string $store_namespace The unique store namespace identifier.
* @param array $config Optional. The array that will be merged with the existing configuration for the
* specified store namespace.
* @return array The configuration for the specified store namespace. This will be the updated configuration if a
* $config argument was provided.
Changelog
Version | Description |
---|---|
6.5.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.