wpseek.com
A WordPress-centric search engine for devs and theme authors
wp_split_selector_list › WordPress Function
Since7.1.0
Deprecatedn/a
› wp_split_selector_list ( $selector )
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
| Codex: |
Splits a selector list by top-level commas.
Related Functions: wp_credits_section_list, wp_print_editor_js, wp_link_category_checklist, wp_parse_list, wp_print_scripts
Source
function wp_split_selector_list( $selector ) {
if ( ! str_contains( $selector, ',' ) ) {
return array( $selector );
}
$selectors = array();
$current_selector = '';
$parentheses_depth = 0;
$selector_length = strlen( $selector );
for ( $i = 0; $i < $selector_length; $i++ ) {
$char = $selector[ $i ];
if ( '(' === $char ) {
++$parentheses_depth;
} elseif ( ')' === $char && $parentheses_depth > 0 ) {
--$parentheses_depth;
} elseif ( ',' === $char && 0 === $parentheses_depth ) {
$selectors[] = $current_selector;
$current_selector = '';
continue;
}
$current_selector .= $char;
}
$selectors[] = $current_selector;
return $selectors;
}