wordpress / latest / classes / wp_theme_json / replace_slug_in_string.html

WP_Theme_JSON::replace_slug_in_string( string $input, string $slug ): string

Transforms a slug into a CSS Custom Property.

Parameters

$input string Required
String to replace.
$slug string Required
The slug value to use to generate the custom property.

Return

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

Source

File: wp-includes/class-wp-theme-json.php. View all references

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

Changelog

Version Description
5.9.0 Introduced.

© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_theme_json/replace_slug_in_string