Processes the data-wp-style
directive.
Description
It updates the style attribute value of the current HTML element based on the evaluation of its associated references.
Parameters
$p
WP_Interactivity_API_Directives_Processorrequired- The directives processor instance.
$mode
stringrequired- Whether the processing is entering or exiting the tag.
$context_stack
arrayrequired- The reference to the context stack.
$namespace_stack
arrayrequired- The reference to the store namespace stack.
Source
if ( null !== $decoded_json || 'null' === $directive_value ) {
$directive_value = $decoded_json;
}
return array( $default_namespace, $directive_value );
}
/**
* Transforms a kebab-case string to camelCase.
*
* @param string $str The kebab-case string to transform to camelCase.
* @return string The transformed camelCase string.
*/
private function kebab_to_camel_case( string $str ): string {
return lcfirst(
preg_replace_callback(
'/(-)([a-z])/',
function ( $matches ) {
return strtoupper( $matches[2] );
},
strtolower( rtrim( $str, '-' ) )
)
);
}
/**
* Processes the `data-wp-interactive` directive.
*
* It adds the default store namespace defined in the directive value to the
* stack so that it's available for the nested interactivity elements.
*
* @since 6.5.0
*
* @param WP_Interactivity_API_Directives_Processor $p The directives processor instance.
* @param string $mode Whether the processing is entering or exiting the tag.
Changelog
Version | Description |
---|---|
6.5.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.