WP_Theme_JSON::update_separator_declarations()private staticWP 6.1.1

Returns a filtered declarations array if there is a separator block with only a background style defined in theme.json by adding a color attribute to reflect the changes in the front.

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

Хуков нет.

Возвращает

Массив. $declarations List of declarations filtered.

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

$result = WP_Theme_JSON::update_separator_declarations( $declarations );
$declarations(массив) (обязательный)
List of declarations.

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

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

Код WP_Theme_JSON::update_separator_declarations() WP 6.5.2

private static function update_separator_declarations( $declarations ) {
	$background_color     = '';
	$border_color_matches = false;
	$text_color_matches   = false;

	foreach ( $declarations as $declaration ) {
		if ( 'background-color' === $declaration['name'] && ! $background_color && isset( $declaration['value'] ) ) {
			$background_color = $declaration['value'];
		} elseif ( 'border-color' === $declaration['name'] ) {
			$border_color_matches = true;
		} elseif ( 'color' === $declaration['name'] ) {
			$text_color_matches = true;
		}

		if ( $background_color && $border_color_matches && $text_color_matches ) {
			break;
		}
	}

	if ( $background_color && ! $border_color_matches && ! $text_color_matches ) {
		$declarations[] = array(
			'name'  => 'color',
			'value' => $background_color,
		);
	}

	return $declarations;
}