WP_Theme_JSON::prepend_to_selector( string $selector, string $to_prepend ): string

Prepends a sub-selector to an existing one.

Description

Given the compounded $selector "h1, h2, h3" and the $to_prepend selector ".some-class " the result will be ".some-class h1, .some-class h2, .some-class h3".

Parameters

$selectorstringrequired
Original selector.
$to_prependstringrequired
Selector to prepend.

Return

string The new selector.

Source

 *
 * @since 6.3.0
 *
 * @param string $selector   Original selector.
 * @param string $to_prepend Selector to prepend.
 * @return string The new selector.
 */
protected static function prepend_to_selector( $selector, $to_prepend ) {
	if ( ! str_contains( $selector, ',' ) ) {
		return $to_prepend . $selector;
	}

Changelog

VersionDescription
6.3.0Introduced.

User Contributed Notes

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