WP_Interactivity_API::data_wp_class_processor( WP_Interactivity_API_Directives_Processor $p, string $mode, array $context_stack, array $namespace_stack )

In this article

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

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

$pWP_Interactivity_API_Directives_Processorrequired
The directives processor instance.
$modestringrequired
Whether the processing is entering or exiting the tag.
$context_stackarrayrequired
The reference to the context stack.
$namespace_stackarrayrequired
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

VersionDescription
6.5.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.