Title: WP_Theme_JSON::set_spacing_sizes
Published: November 2, 2022
Last modified: February 24, 2026

---

# WP_Theme_JSON::set_spacing_sizes(): null|void

## In this article

 * [Return](https://developer.wordpress.org/reference/classes/wp_theme_json/set_spacing_sizes/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_theme_json/set_spacing_sizes/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_theme_json/set_spacing_sizes/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_theme_json/set_spacing_sizes/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_theme_json/set_spacing_sizes/?output_format=md#wp--skip-link--target)

This method has been deprecated since 6.6.0. No longer used as the spacingSizes 
are automatically generated in the constructor and merge methods instead of manually
after instantiation.

Sets the spacingSizes array based on the spacingScale values from theme.json.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_theme_json/set_spacing_sizes/?output_format=md#return)󠁿

 null|void

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_theme_json/set_spacing_sizes/?output_format=md#source)󠁿

    ```php
    public function set_spacing_sizes() {
    	_deprecated_function( __METHOD__, '6.6.0' );

    	$spacing_scale = isset( $this->theme_json['settings']['spacing']['spacingScale'] )
    		? $this->theme_json['settings']['spacing']['spacingScale']
    		: array();

    	if ( ! isset( $spacing_scale['steps'] )
    		|| ! is_numeric( $spacing_scale['steps'] )
    		|| ! isset( $spacing_scale['mediumStep'] )
    		|| ! isset( $spacing_scale['unit'] )
    		|| ! isset( $spacing_scale['operator'] )
    		|| ! isset( $spacing_scale['increment'] )
    		|| ! isset( $spacing_scale['steps'] )
    		|| ! is_numeric( $spacing_scale['increment'] )
    		|| ! is_numeric( $spacing_scale['mediumStep'] )
    		|| ( '+' !== $spacing_scale['operator'] && '*' !== $spacing_scale['operator'] ) ) {
    		if ( ! empty( $spacing_scale ) ) {
    			wp_trigger_error(
    				__METHOD__,
    				sprintf(
    					/* translators: 1: theme.json, 2: settings.spacing.spacingScale */
    					__( 'Some of the %1$s %2$s values are invalid' ),
    					'theme.json',
    					'settings.spacing.spacingScale'
    				),
    				E_USER_NOTICE
    			);
    		}
    		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;
    	}

    	$spacing_sizes = static::compute_spacing_sizes( $spacing_scale );

    	// If there are 7 or fewer steps in the scale revert to numbers for labels instead of t-shirt sizes.
    	if ( $spacing_scale['steps'] <= 7 ) {
    		for ( $spacing_sizes_count = 0; $spacing_sizes_count < count( $spacing_sizes ); $spacing_sizes_count++ ) {
    			$spacing_sizes[ $spacing_sizes_count ]['name'] = (string) ( $spacing_sizes_count + 1 );
    		}
    	}

    	_wp_array_set( $this->theme_json, array( 'settings', 'spacing', 'spacingSizes', 'default' ), $spacing_sizes );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-theme-json.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/class-wp-theme-json.php#L4065)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/class-wp-theme-json.php#L4065-L4112)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_theme_json/set_spacing_sizes/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_trigger_error()](https://developer.wordpress.org/reference/functions/wp_trigger_error/)`wp-includes/functions.php` |

Generates a user-level error/warning/notice/deprecation message.

  | 
| [_wp_array_set()](https://developer.wordpress.org/reference/functions/_wp_array_set/)`wp-includes/functions.php` |

Sets an array in depth based on a path of keys.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [_deprecated_function()](https://developer.wordpress.org/reference/functions/_deprecated_function/)`wp-includes/functions.php` |

Marks a function as deprecated and inform when it has been used.

  |

[Show 2 more](https://developer.wordpress.org/reference/classes/wp_theme_json/set_spacing_sizes/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_theme_json/set_spacing_sizes/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_theme_json/set_spacing_sizes/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.6.0](https://developer.wordpress.org/reference/since/6.6.0/) | Deprecated. No longer used as the spacingSizes are automatically generated in the constructor and merge methods instead of manually after instantiation. | 
| [6.1.0](https://developer.wordpress.org/reference/since/6.1.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_theme_json%2Fset_spacing_sizes%2F)
before being able to contribute a note or feedback.