WP_Interactivity_API::data_wp_style_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-style directive.

Description

It updates the style attribute value of 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

	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

VersionDescription
6.5.0Introduced.

User Contributed Notes

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