Skip to content

Commit

Permalink
Spacing presets: Add check for 0 spacing steps (#43105)
Browse files Browse the repository at this point in the history
  • Loading branch information
glendaviesnz authored Aug 12, 2022
1 parent 9aab0c4 commit 89fe282
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,6 @@ public function set_spacing_sizes() {
$spacing_scale = _wp_array_get( $this->theme_json, array( 'settings', 'spacing', 'spacingScale' ), array() );

if ( ! is_numeric( $spacing_scale['steps'] )
|| ! $spacing_scale['steps'] > 0
|| ! isset( $spacing_scale['mediumStep'] )
|| ! isset( $spacing_scale['unit'] )
|| ! isset( $spacing_scale['operator'] )
Expand All @@ -1191,6 +1190,11 @@ public function set_spacing_sizes() {
return null;
}

// If theme authors want to prevent the generation of the core spacing scale they can set their theme.json spacingScale.steps to 0.
if ( 0 === $spacing_scale['steps'] ) {
return null;
}

$unit = '%' === $spacing_scale['unit'] ? '%' : sanitize_title( $spacing_scale['unit'] );
$current_step = $spacing_scale['mediumStep'];
$steps_mid_point = round( ( ( $spacing_scale['steps'] ) / 2 ), 0 );
Expand Down

0 comments on commit 89fe282

Please sign in to comment.