ViewData
Class.
Data from PHP for the scripts of one framework instance: its views (of
blocks, block supports and the document), its editor scripts and its shared
modules read a value with this.data(key) or getData(key).
Inject it and set values before they are printed: on the front end the
framework prints them with the view runtime in the footer, so values from
hooks and from render() reach the views; in the editor it prints them with
the editor runtime at the end of enqueue_block_editor_assets. Setting a
value afterwards is an error. Every visitor can read the values.
Methods
get()
The value set for the key.
Returns mixed
Throws OutOfBoundsException: If no value is set for the key.
has()
Whether a value is set for the key.
Returns bool
set()
Sets a value; a later call with the same key replaces it.
Throws InvalidArgumentException: If the key or the value is invalid.
Throws LogicException: If the values are already printed and WP_DEBUG is on.