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
stringrequired- Original selector.
$to_append
stringrequired- Selector to append.
Source
* @since 6.1.0 Added append position.
* @since 6.3.0 Removed append position parameter.
*
* @param string $selector Original selector.
* @param string $to_append Selector to append.
* @return string The new selector.
*/
protected static function append_to_selector( $selector, $to_append ) {
if ( ! str_contains( $selector, ',' ) ) {
return $selector . $to_append;
}
User Contributed Notes
You must log in before being able to contribute a note or feedback.