wpseek.com
Outil de recherche WordPress pour les développeurs et auteurs de thèmes
wp_interactivity_data_wp_context › WordPress Function
Depuis6.5.0
Dépréciéen/a
› wp_interactivity_data_wp_context ( $context, $store_namespace = '' )
| Paramètres: (2) |
|
| Retourne: |
|
| Défini(e) dans: | |
| 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 ) ); ?>
Fonctions en relation: wp_interactivity_get_context, wp_interactivity_state, wp_interactivity_config, wp_interactivity_get_element, wp_interactivity
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 ) ) .
'\'';
}