WP_Theme_JSON::set_spacing_sizes()publicWP 6.1.0

Устарела с версии 6.6.0. Больше не поддерживается и может быть удалена. Используйте d as spacingSizes are automatically generated in constructor and merge methods of manually after instantiation.

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

Метод класса: WP_Theme_JSON{}

Хуков нет.

Возвращает

null|null.

Использование

$WP_Theme_JSON = new WP_Theme_JSON();
$WP_Theme_JSON->set_spacing_sizes();

Список изменений

С версии 6.1.0 Введена.
Устарела с 6.6.0 No longer used as the spacingSizes are automatically
generated in the constructor and merge methods instead
of manually after instantiation.

Код WP_Theme_JSON::set_spacing_sizes() WP 6.8.1

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 );
}