Processes the data-wp-class
directive.
Description
It adds or removes CSS classes in 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
/*
* Tries to decode the value as a JSON object. If it fails and the value
* isn't `null`, it returns the value as it is. Otherwise, it returns the
* decoded JSON or null for the string `null`.
*/
$decoded_json = json_decode( $directive_value, true );
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 {
Changelog
Version | Description |
---|---|
6.5.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.