WP_Theme_JSON::append_to_selector( string $selector, string $to_append, string $position = 'right' ): string
Appends a sub-selector to an existing one.
Description
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".
Parameters
-
$selector
string Required -
Original selector.
-
$to_append
string Required -
Selector to append.
-
$position
string Optional -
A position sub-selector should be appended. Default
'right'
.Default:
'right'
Return
string The new selector.
Source
File: wp-includes/class-wp-theme-json.php
.
View all references
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 );
}
Changelog
Version | Description |
---|---|
6.1.0 | Added append position. |
5.8.0 | Introduced. |