Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global Styles: Update util for scoping CSS selectors #6478

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/wp-includes/class-wp-theme-json.php
Original file line number Diff line number Diff line change
Expand Up @@ -1764,12 +1764,17 @@ protected static function compute_preset_classes( $settings, $selector, $origins
* </code>
*
* @since 5.9.0
* @since 6.6.0 Added early return if missing scope or selector.
*
* @param string $scope Selector to scope to.
* @param string $selector Original selector.
* @return string Scoped selector.
*/
public static function scope_selector( $scope, $selector ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice if there were a test for this, but given that it's an existing function I think it's fine to do that separately (and tests can be added anytime during the release cycle).

if ( ! $scope || ! $selector ) {
return $selector;
}

$scopes = explode( ',', $scope );
$selectors = explode( ',', $selector );

Expand Down
Loading