[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Source view] [Print] [Project Stats]
Interactivity API: Functions and hooks
File Size: | 140 lines (5 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
wp_interactivity() X-Ref |
Retrieves the main WP_Interactivity_API instance. It provides access to the WP_Interactivity_API instance, creating one if it doesn't exist yet. return: WP_Interactivity_API The main WP_Interactivity_API instance. |
wp_interactivity_process_directives( string $html ) X-Ref |
Processes the interactivity directives contained within the HTML content and updates the markup accordingly. param: string $html The HTML content to process. return: string The processed HTML content. It returns the original content when the HTML contains unbalanced tags. |
wp_interactivity_state( ?string $store_namespace = null, array $state = array() X-Ref |
Gets and/or sets the initial state of an Interactivity API store for a given namespace. If state for that store namespace already exists, it merges the new provided state with the existing one. The namespace can be omitted inside derived state getters, using the namespace where the getter is defined. param: string $store_namespace The unique store namespace identifier. param: array $state Optional. The array that will be merged with the existing state for the specified return: array The state for the specified store namespace. This will be the updated state if a $state argument was |
wp_interactivity_config( string $store_namespace, array $config = array() X-Ref |
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. 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 return: array The configuration for the specified store namespace. This will be the updated configuration if a |
wp_interactivity_data_wp_context( array $context, string $store_namespace = '' ) X-Ref |
Generates a `data-wp-context` directive attribute by encoding a context array. 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 ) ); ?>> param: array $context The array of context data to encode. param: string $store_namespace Optional. The unique store namespace identifier. return: string A complete `data-wp-context` directive with a JSON encoded value representing the context array and |
wp_interactivity_get_context( ?string $store_namespace = null ) X-Ref |
Gets the current Interactivity API context for a given namespace. The function should be used only during directive processing. If the `$store_namespace` parameter is omitted, it uses the current namespace value on the internal namespace stack. It returns an empty array when the specified namespace is not defined. param: string $store_namespace Optional. The unique store namespace identifier. return: array The context for the specified store namespace. |
wp_interactivity_get_element() X-Ref |
Returns an array representation of the current element being processed. The function should be used only during directive processing. return: array{attributes: array<string, string|bool>}|null Current element. |
Generated : Thu Nov 21 08:20:01 2024 | Cross-referenced by PHPXref |