Generates a data-wp-context directive attribute by encoding a context array.
Description
This helper function simplifies the creation of data-wp-context directives by providing a way to pass an array of data, which encodes into a JSON string safe for direct use as a HTML attribute value.
Example:
<div <?php echo wp_interactivity_data_wp_context( array( 'isOpen' => true, 'count' => 0 ) ); ?>>Parameters
$contextarrayrequired- The array of context data to encode.
$store_namespacestringoptional- The unique store namespace identifier.
Default:
''
Source
Changelog
| Version | Description |
|---|---|
| 6.5.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.