wpseek.com
A WordPress-centric search engine for devs and theme authors
wp_interactivity_data_wp_context › WordPress Function
Since6.5.0
Deprecatedn/a
› wp_interactivity_data_wp_context ( $context, $store_namespace = '' )
Parameters: (2) |
|
Returns: |
|
Defined at: | |
Codex: |
Generates a `data-wp-context` directive attribute by encoding a context array.
This helper function simplifies the creation ofdata-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:
true, 'count' => 0 ) ); ?>
Source
function wp_interactivity_data_wp_context( array $context, string $store_namespace = '' ): string { return 'data-wp-context=\'' . ( $store_namespace ? $store_namespace . '::' : '' ) . ( empty( $context ) ? '{}' : wp_json_encode( $context, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP ) ) . '\''; }