Skip to content

Commit

Permalink
Update the block-level duotone selector
Browse files Browse the repository at this point in the history
Before: .wp-duotone .wp-block-name
After:  .wp-duotone.wp-blockname
  • Loading branch information
oandregal committed Mar 29, 2023
1 parent 7f6b31d commit 8fc3110
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion lib/class-wp-duotone-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,26 @@ public static function render_duotone_support( $block_content, $block ) {
$filter_id = gutenberg_get_duotone_filter_id( array( 'slug' => $slug ) );

// Build the CSS selectors to which the filter will be applied.
$selector = WP_Theme_JSON_Gutenberg::scope_selector( '.' . $filter_id, $duotone_selector );
$scopes = explode( ',', '.' . $filter_id );
$selectors = explode( ',', $duotone_selector );

$selectors_scoped = array();
foreach ( $scopes as $outer ) {
foreach ( $selectors as $inner ) {
$outer = trim( $outer );
$inner = trim( $inner );
if ( ! empty( $outer ) && ! empty( $inner ) ) {
// unlike WP_Theme_JSON_Gutenberg::scope_selector
// this concatenates the selectors without a space.
$selectors_scoped[] = $outer . '' . $inner;
} elseif ( empty( $outer ) ) {
$selectors_scoped[] = $inner;
} elseif ( empty( $inner ) ) {
$selectors_scoped[] = $outer;
}
}
}
$selector = implode( ', ', $selectors_scoped );

// We only want to add the selector if we have it in the output already, essentially skipping 'unset'.
if ( array_key_exists( $slug, self::$output ) ) {
Expand Down

0 comments on commit 8fc3110

Please sign in to comment.