WP_Interactivity_API::merge_style_property( string $style_attribute_value, string $style_property_name, string|false|null $style_property_value ): string

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.

Merges an individual style property in the style attribute of an HTML element, updating or removing the property when necessary.

Description

If a property is modified, the old one is removed and the new one is added at the end of the list.

Parameters

$style_attribute_valuestringrequired
The current style attribute value.
$style_property_namestringrequired
The style property name to set.
$style_property_valuestring|false|nullrequired
The value to set for the style property. With false, null or an empty string, it removes the style property.

Return

string The new style attribute value after the specified property has been added, updated or removed.

Source


/**
 * 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.
 *

Changelog

VersionDescription
6.5.0Introduced.

User Contributed Notes

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