Skip to content

Commit

Permalink
Whoa horsey! Let's simplify this and check for explicit Gutenberg CSS…
Browse files Browse the repository at this point in the history
… custom properties.
  • Loading branch information
ramonjd committed Aug 9, 2022
1 parent e274549 commit 959939e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/style-engine/class-wp-style-engine-css-declarations.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
* @access private
*/
class WP_Style_Engine_CSS_Declarations {
/**
* An array of valid CSS custom properties.
*/
const VALID_CUSTOM_PROPERTIES = array(
'--wp--style--unstable-gallery-gap',
);

/**
* An array of CSS declarations (property => value pairs).
Expand Down Expand Up @@ -124,6 +130,10 @@ public function get_declarations() {
*/
protected static function filter_declaration( $property, $value, $spacer = '' ) {
if ( isset( $property ) && isset( $value ) ) {
// Allow CSS custom properties starting with `--wp--`.
if ( in_array( $property, static::VALID_CUSTOM_PROPERTIES, true ) ) {
return "{$property}:{$spacer}{$value}";
}
return safecss_filter_attr( "{$property}:{$spacer}{$value}" );
}
return '';
Expand Down

0 comments on commit 959939e

Please sign in to comment.