Skip to content

Commit

Permalink
Avoid repeating code
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasbenedetto committed May 26, 2022
1 parent f54495a commit 4814f95
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,4 +273,32 @@ public function get_styles_for_block( $block_metadata ) {

return $block_rules;
}

/**
* Converts each style section into a list of rulesets
* containing the block styles to be appended to the stylesheet.
*
* See glossary at https://developer.mozilla.org/en-US/docs/Web/CSS/Syntax
*
* For each section this creates a new ruleset such as:
*
* block-selector {
* style-property-one: value;
* }
*
* @param array $style_nodes Nodes with styles.
* @return string The new stylesheet.
*/
protected function get_block_classes( $style_nodes ) {
$block_rules = '';

foreach ( $style_nodes as $metadata ) {
if ( null === $metadata['selector'] ) {
continue;
}
$block_rules.= static::get_styles_for_block( $metadata );
}

return $block_rules;
}
}

0 comments on commit 4814f95

Please sign in to comment.