WP_Theme_JSON::append_to_selector()protected staticWP 5.8.0

Appends a sub-selector to an existing one.

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

Метод класса: WP_Theme_JSON{}

Хуков нет.

Возвращает

Строку. The new selector.

Использование

$result = WP_Theme_JSON::append_to_selector( $selector, $to_append, $position );
$selector(строка) (обязательный)
Original selector.
$to_append(строка) (обязательный)
Selector to append.
$position(строка)
A position sub-selector should be appended.
По умолчанию: 'right'

Список изменений

С версии 5.8.0 Введена.
С версии 6.1.0 Added append position.

Код WP_Theme_JSON::append_to_selector() WP 6.1.1

protected static function append_to_selector( $selector, $to_append, $position = 'right' ) {
	$new_selectors = array();
	$selectors     = explode( ',', $selector );
	foreach ( $selectors as $sel ) {
		$new_selectors[] = 'right' === $position ? $sel . $to_append : $to_append . $sel;
	}
	return implode( ',', $new_selectors );
}