get_block_editor_theme_styles

The timeline below displays how wordpress function get_block_editor_theme_styles has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Creates an array of theme styles to load into the block editor.
 *
 * @since 5.8.0
 *
 * @global array $editor_styles
 *
 * @return array An array of theme styles for the block editor.
 */
function get_block_editor_theme_styles()
{
    global $editor_styles;
    $styles = array();
    if ($editor_styles && current_theme_supports('editor-styles')) {
        foreach ($editor_styles as $style) {
            if (preg_match('~^(https?:)?//~', $style)) {
                $response = wp_remote_get($style);
                if (!is_wp_error($response)) {
                    $styles[] = array('css' => wp_remote_retrieve_body($response), '__unstableType' => 'theme', 'isGlobalStyles' => false);
                }
            } 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', 'isGlobalStyles' => false);
                }
            }
        }
    }
    return $styles;
}

WordPress Version: 5.9

/**
 * Creates an array of theme styles to load into the block editor.
 *
 * @since 5.8.0
 *
 * @global array $editor_styles
 *
 * @return array An array of theme styles for the block editor.
 */
function get_block_editor_theme_styles()
{
    global $editor_styles;
    $styles = array();
    if ($editor_styles && current_theme_supports('editor-styles')) {
        foreach ($editor_styles as $style) {
            if (preg_match('~^(https?:)?//~', $style)) {
                $response = wp_remote_get($style);
                if (!is_wp_error($response)) {
                    $styles[] = array('css' => wp_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;
}

WordPress Version: 5.8

/**
 * Creates an array of theme styles to load into the block editor.
 *
 * @since 5.8.0
 *
 * @global array $editor_styles
 *
 * @return array An array of theme styles for the block editor. Includes default font family
 *               style and theme stylesheets.
 */
function get_block_editor_theme_styles()
{
    global $editor_styles;
    if (!WP_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 = wp_remote_get($style);
                if (!is_wp_error($response)) {
                    $styles[] = array('css' => wp_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;
}