WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WP_Theme_JSON::get_from_editor_settings() public WP 5.8.0

Transforms the given editor settings according the add_theme_support format to the theme.json format.

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

Хуков нет.

Возвращает

Массив. Config that adheres to the theme.json schema.

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

$result = WP_Theme_JSON::get_from_editor_settings( $settings );
$settings(массив) (обязательный)
Existing editor settings.

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

С версии 5.8.0 Введена.

Код WP_Theme_JSON::get_from_editor_settings() WP 5.8.1

public static function get_from_editor_settings( $settings ) {
	$theme_settings = array(
		'version'  => self::LATEST_SCHEMA,
		'settings' => array(),
	);

	// Deprecated theme supports.
	if ( isset( $settings['disableCustomColors'] ) ) {
		if ( ! isset( $theme_settings['settings']['color'] ) ) {
			$theme_settings['settings']['color'] = array();
		}
		$theme_settings['settings']['color']['custom'] = ! $settings['disableCustomColors'];
	}

	if ( isset( $settings['disableCustomGradients'] ) ) {
		if ( ! isset( $theme_settings['settings']['color'] ) ) {
			$theme_settings['settings']['color'] = array();
		}
		$theme_settings['settings']['color']['customGradient'] = ! $settings['disableCustomGradients'];
	}

	if ( isset( $settings['disableCustomFontSizes'] ) ) {
		if ( ! isset( $theme_settings['settings']['typography'] ) ) {
			$theme_settings['settings']['typography'] = array();
		}
		$theme_settings['settings']['typography']['customFontSize'] = ! $settings['disableCustomFontSizes'];
	}

	if ( isset( $settings['enableCustomLineHeight'] ) ) {
		if ( ! isset( $theme_settings['settings']['typography'] ) ) {
			$theme_settings['settings']['typography'] = array();
		}
		$theme_settings['settings']['typography']['customLineHeight'] = $settings['enableCustomLineHeight'];
	}

	if ( isset( $settings['enableCustomUnits'] ) ) {
		if ( ! isset( $theme_settings['settings']['spacing'] ) ) {
			$theme_settings['settings']['spacing'] = array();
		}
		$theme_settings['settings']['spacing']['units'] = ( true === $settings['enableCustomUnits'] ) ?
			array( 'px', 'em', 'rem', 'vh', 'vw', '%' ) :
			$settings['enableCustomUnits'];
	}

	if ( isset( $settings['colors'] ) ) {
		if ( ! isset( $theme_settings['settings']['color'] ) ) {
			$theme_settings['settings']['color'] = array();
		}
		$theme_settings['settings']['color']['palette'] = $settings['colors'];
	}

	if ( isset( $settings['gradients'] ) ) {
		if ( ! isset( $theme_settings['settings']['color'] ) ) {
			$theme_settings['settings']['color'] = array();
		}
		$theme_settings['settings']['color']['gradients'] = $settings['gradients'];
	}

	if ( isset( $settings['fontSizes'] ) ) {
		$font_sizes = $settings['fontSizes'];
		// Back-compatibility for presets without units.
		foreach ( $font_sizes as $key => $font_size ) {
			if ( is_numeric( $font_size['size'] ) ) {
				$font_sizes[ $key ]['size'] = $font_size['size'] . 'px';
			}
		}
		if ( ! isset( $theme_settings['settings']['typography'] ) ) {
			$theme_settings['settings']['typography'] = array();
		}
		$theme_settings['settings']['typography']['fontSizes'] = $font_sizes;
	}

	if ( isset( $settings['enableCustomSpacing'] ) ) {
		if ( ! isset( $theme_settings['settings']['spacing'] ) ) {
			$theme_settings['settings']['spacing'] = array();
		}
		$theme_settings['settings']['spacing']['customPadding'] = $settings['enableCustomSpacing'];
	}

	// Things that didn't land in core yet, so didn't have a setting assigned.
	if ( current( (array) get_theme_support( 'experimental-link-color' ) ) ) {
		if ( ! isset( $theme_settings['settings']['color'] ) ) {
			$theme_settings['settings']['color'] = array();
		}
		$theme_settings['settings']['color']['link'] = true;
	}

	return $theme_settings;
}