WP_Theme_JSON::replace_slug_in_string() WordPress Method

The WP_Theme_JSON::replace_slug_in_string() method is used to replace the string "theme" with the slug of the current theme. This is useful for making sure that the correct theme is being used when making a request to the WordPress.org API.

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

Transform 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.


Top ↑

Return

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


Top ↑

Source

File: wp-includes/class-wp-theme-json.php

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

Top ↑

Changelog

Changelog
VersionDescription
5.9.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.