get_block_editor_theme_styles()

最后更新于:2021-11-26 05:43:19

get_block_editor_theme_styles()

Creates an array of theme styles to load into the block editor.

响应

(array) An array of theme styles for the block editor. Includes default font family style and theme stylesheets.

源文件

文件: gc-includes/block-editor.php

function get_block_editor_theme_styles() {
	global $editor_styles;

	if ( ! GC_Theme_JSON_Resolver::theme_has_support() ) {
		$styles = array(
			array(
				'css'            => 'body { font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif }',
				'__unstableType' => 'core',
			),
		);
	} else {
		$styles = array();
	}

	if ( $editor_styles && current_theme_supports( 'editor-styles' ) ) {
		foreach ( $editor_styles as $style ) {
			if ( preg_match( '~^(https?:)?//~', $style ) ) {
				$response = gc_remote_get( $style );
				if ( ! is_gc_error( $response ) ) {
					$styles[] = array(
						'css'            => gc_remote_retrieve_body( $response ),
						'__unstableType' => 'theme',
					);
				}
			} else {
				$file = get_theme_file_path( $style );
				if ( is_file( $file ) ) {
					$styles[] = array(
						'css'            => file_get_contents( $file ),
						'baseURL'        => get_theme_file_uri( $style ),
						'__unstableType' => 'theme',
					);
				}
			}
		}
	}

	return $styles;
}