[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Source view] [Print] [Project Stats]
Interactivity API: WP_Interactivity_API class.
File Size: | 1228 lines (44 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
state( ?string $store_namespace = null, ?array $state = null ) 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. When no namespace is specified, it returns the state defined for the current value in the internal namespace stack during a `process_directives` call. return: array The current state for the specified store namespace. This will be the updated state if a $state param: string $store_namespace Optional. The unique store namespace identifier. param: array $state Optional. The array that will be merged with the existing state for the specified |
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 |
print_client_interactivity_data() X-Ref |
Prints the serialized client-side interactivity data. Encodes the config and initial state into JSON and prints them inside a script tag of type "application/json". Once in the browser, the state will be parsed and used to hydrate the client-side interactivity stores and the configuration will be available using a `getConfig` utility. |
filter_script_module_interactivity_router_data( array $data ) X-Ref |
Set client-side interactivity-router data. Once in the browser, the state will be parsed and used to hydrate the client-side interactivity stores and the configuration will be available using a `getConfig` utility. return: array Data for the Interactivity Router script module. param: array $data Data to filter. |
filter_script_module_interactivity_data( array $data ) X-Ref |
Set client-side interactivity data. Once in the browser, the state will be parsed and used to hydrate the client-side interactivity stores and the configuration will be available using a `getConfig` utility. return: array Data for the Interactivity API script module. param: array $data Data to filter. |
get_context( ?string $store_namespace = null ) X-Ref |
Returns the latest value on the context stack with the passed namespace. When the namespace is omitted, it uses the current namespace on the namespace stack during a `process_directives` call. param: string $store_namespace Optional. The unique store namespace identifier. |
get_element() X-Ref |
Returns an array representation of the current element being processed. The returned array contains a copy of the element attributes. return: array{attributes: array<string, string|bool>}|null Current element. |
register_script_modules() X-Ref |
Registers the `@wordpress/interactivity` script modules. |
add_hooks() X-Ref |
Adds the necessary hooks for the Interactivity API. |
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. |
_process_directives( string $html ) X-Ref |
Processes the interactivity directives contained within the HTML content and updates the markup accordingly. It uses the WP_Interactivity_API instance's context and namespace stacks, which are shared between all calls. This method returns null if the HTML contains unbalanced tags. return: string|null The processed HTML content. It returns null when the HTML contains unbalanced tags. param: string $html The HTML content to process. |
evaluate( $directive_value ) X-Ref |
Evaluates the reference path passed to a directive based on the current store namespace, state and context. return: mixed|null The result of the evaluation. Null if the reference path doesn't exist or the namespace is falsy. param: string|true $directive_value The directive attribute value string or `true` when it's a boolean attribute. |
extract_prefix_and_suffix( string $directive_name ) X-Ref |
Extracts the directive attribute name to separate and return the directive prefix and an optional suffix. The suffix is the string after the first double hyphen and the prefix is everything that comes before the suffix. Example: extract_prefix_and_suffix( 'data-wp-interactive' ) => array( 'data-wp-interactive', null ) extract_prefix_and_suffix( 'data-wp-bind--src' ) => array( 'data-wp-bind', 'src' ) extract_prefix_and_suffix( 'data-wp-foo--and--bar' ) => array( 'data-wp-foo', 'and--bar' ) return: array An array containing the directive prefix and optional suffix. param: string $directive_name The directive attribute name. |
extract_directive_value( $directive_value, $default_namespace = null ) X-Ref |
Parses and extracts the namespace and reference path from the given directive attribute value. If the value doesn't contain an explicit namespace, it returns the default one. If the value contains a JSON object instead of a reference path, the function tries to parse it and return the resulting array. If the value contains strings that represent booleans ("true" and "false"), numbers ("1" and "1.2") or "null", the function also transform them to regular booleans, numbers and `null`. Example: extract_directive_value( 'actions.foo', 'myPlugin' ) => array( 'myPlugin', 'actions.foo' ) extract_directive_value( 'otherPlugin::actions.foo', 'myPlugin' ) => array( 'otherPlugin', 'actions.foo' ) extract_directive_value( '{ "isOpen": false }', 'myPlugin' ) => array( 'myPlugin', array( 'isOpen' => false ) ) extract_directive_value( 'otherPlugin::{ "isOpen": false }', 'myPlugin' ) => array( 'otherPlugin', array( 'isOpen' => false ) ) return: array An array containing the namespace in the first item and the JSON, the reference path, or null on the param: string|true $directive_value The directive attribute value. It can be `true` when it's a boolean param: string|null $default_namespace Optional. The default namespace if none is explicitly defined. |
kebab_to_camel_case( string $str ) X-Ref |
Transforms a kebab-case string to camelCase. return: string The transformed camelCase string. param: string $str The kebab-case string to transform to camelCase. |
data_wp_interactive_processor( WP_Interactivity_API_Directives_Processor $p, string $mode ) X-Ref |
No description |
data_wp_context_processor( WP_Interactivity_API_Directives_Processor $p, string $mode ) X-Ref |
Processes the `data-wp-context` directive. It adds the context defined in the directive value to the stack so that it's available for the nested interactivity elements. param: WP_Interactivity_API_Directives_Processor $p The directives processor instance. param: string $mode Whether the processing is entering or exiting the tag. |
data_wp_bind_processor( WP_Interactivity_API_Directives_Processor $p, string $mode ) X-Ref |
Processes the `data-wp-bind` directive. It updates or removes the bound attributes based on the evaluation of its associated reference. param: WP_Interactivity_API_Directives_Processor $p The directives processor instance. param: string $mode Whether the processing is entering or exiting the tag. |
data_wp_class_processor( WP_Interactivity_API_Directives_Processor $p, string $mode ) X-Ref |
Processes the `data-wp-class` directive. It adds or removes CSS classes in the current HTML element based on the evaluation of its associated references. param: WP_Interactivity_API_Directives_Processor $p The directives processor instance. param: string $mode Whether the processing is entering or exiting the tag. |
data_wp_style_processor( WP_Interactivity_API_Directives_Processor $p, string $mode ) X-Ref |
Processes the `data-wp-style` directive. It updates the style attribute value of the current HTML element based on the evaluation of its associated references. param: WP_Interactivity_API_Directives_Processor $p The directives processor instance. param: string $mode Whether the processing is entering or exiting the tag. |
merge_style_property( string $style_attribute_value, string $style_property_name, $style_property_value ) X-Ref |
Merges an individual style property in the `style` attribute of an HTML element, updating or removing the property when necessary. If a property is modified, the old one is removed and the new one is added at the end of the list. return: string The new style attribute value after the specified property has been added, updated or removed. param: string $style_attribute_value The current style attribute value. param: string $style_property_name The style property name to set. param: string|false|null $style_property_value The value to set for the style property. With false, null or an |
data_wp_text_processor( WP_Interactivity_API_Directives_Processor $p, string $mode ) X-Ref |
Processes the `data-wp-text` directive. It updates the inner content of the current HTML element based on the evaluation of its associated reference. param: WP_Interactivity_API_Directives_Processor $p The directives processor instance. param: string $mode Whether the processing is entering or exiting the tag. |
get_router_animation_styles() X-Ref |
Returns the CSS styles for animating the top loading bar in the router. return: string The CSS styles for the router's top loading bar animation. |
print_router_loading_and_screen_reader_markup() X-Ref |
Deprecated. |
print_router_markup() X-Ref |
Outputs markup for the @wordpress/interactivity-router script module. This method prints a div element representing a loading bar visible during navigation. |
data_wp_router_region_processor( WP_Interactivity_API_Directives_Processor $p, string $mode ) X-Ref |
Processes the `data-wp-router-region` directive. It renders in the footer a set of HTML elements to notify users about client-side navigations. More concretely, the elements added are 1) a top loading bar to visually inform that a navigation is in progress and 2) an `aria-live` region for accessible navigation announcements. param: WP_Interactivity_API_Directives_Processor $p The directives processor instance. param: string $mode Whether the processing is entering or exiting the tag. |
data_wp_each_processor( WP_Interactivity_API_Directives_Processor $p, string $mode, array &$tag_stack ) X-Ref |
Processes the `data-wp-each` directive. This directive gets an array passed as reference and iterates over it generating new content for each item based on the inner markup of the `template` tag. param: WP_Interactivity_API_Directives_Processor $p The directives processor instance. param: string $mode Whether the processing is entering or exiting the tag. param: array $tag_stack The reference to the tag stack. |
Generated : Sat Dec 21 08:20:01 2024 | Cross-referenced by PHPXref |