WP_Theme_JSON::get_custom_css()publicWP 6.2.0

Returns the global styles custom CSS.

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

Хуков нет.

Возвращает

Строку. The global styles custom CSS.

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

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

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

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

Код WP_Theme_JSON::get_custom_css() WP 6.5.2

public function get_custom_css() {
	// Add the global styles root CSS.
	$stylesheet = isset( $this->theme_json['styles']['css'] ) ? $this->theme_json['styles']['css'] : '';

	// Add the global styles block CSS.
	if ( isset( $this->theme_json['styles']['blocks'] ) ) {
		foreach ( $this->theme_json['styles']['blocks'] as $name => $node ) {
			$custom_block_css = isset( $this->theme_json['styles']['blocks'][ $name ]['css'] )
				? $this->theme_json['styles']['blocks'][ $name ]['css']
				: null;
			if ( $custom_block_css ) {
				$selector    = static::$blocks_metadata[ $name ]['selector'];
				$stylesheet .= $this->process_blocks_custom_css( $custom_block_css, $selector );
			}
		}
	}

	return $stylesheet;
}