WP_Theme_JSON::replace_slug_in_string()protected staticWP 5.9.0

Transforms a slug into a CSS Custom Property.

Method of the class: WP_Theme_JSON{}

No Hooks.

Return

String. The CSS Custom Property. Something along the lines of --wp--preset--color--black.

Usage

$result = WP_Theme_JSON::replace_slug_in_string( $input, $slug );
$input(string) (required)
String to replace.
$slug(string) (required)
The slug value to use to generate the custom property.

Changelog

Since 5.9.0 Introduced.

WP_Theme_JSON::replace_slug_in_string() code WP 6.4.3

protected static function replace_slug_in_string( $input, $slug ) {
	return strtr( $input, array( '$slug' => $slug ) );
}