[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/interactivity-api/ -> interactivity-api.php (summary)

Interactivity API: Functions and hooks

File Size: 170 lines (7 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 6 functions

  wp_interactivity_process_directives_of_interactive_blocks()
  wp_interactivity()
  wp_interactivity_process_directives()
  wp_interactivity_state()
  wp_interactivity_config()
  wp_interactivity_data_wp_context()

Functions
Functions that are not part of a class:

wp_interactivity_process_directives_of_interactive_blocks( array $parsed_block )   X-Ref
Processes the directives on the rendered HTML of the interactive blocks.

This processes only one root interactive block at a time because the
rendered HTML of that block contains the rendered HTML of all its inner
blocks, including any interactive block. It does so by ignoring all the
interactive inner blocks until the root interactive block is processed.

return: array The same parsed block.
param: array $parsed_block The parsed block.

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.

return: string The processed HTML content. It returns the original content when the HTML contains unbalanced tags.
param: string $html The HTML content to process.

wp_interactivity_state( string $store_namespace, 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.

return: array The state for the specified store namespace. This will be the updated state if a $state argument was
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

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.

return: array The configuration for the specified store namespace. This will be the updated configuration if a
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

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 ) ); ?>>

return: string A complete `data-wp-context` directive with a JSON encoded value representing the context array and
param: array  $context         The array of context data to encode.
param: string $store_namespace Optional. The unique store namespace identifier.



Generated : Sat Apr 27 08:20:02 2024 Cross-referenced by PHPXref