get_editor_stylesheets

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

WordPress Version: 6.1

/**
 * Retrieves any registered editor stylesheet URLs.
 *
 * @since 4.0.0
 *
 * @global array $editor_styles Registered editor stylesheets
 *
 * @return string[] If registered, a list of editor stylesheet URLs.
 */
function get_editor_stylesheets()
{
    $stylesheets = array();
    // Load editor_style.css if the active theme supports it.
    if (!empty($GLOBALS['editor_styles']) && is_array($GLOBALS['editor_styles'])) {
        $editor_styles = $GLOBALS['editor_styles'];
        $editor_styles = array_unique(array_filter($editor_styles));
        $style_uri = get_stylesheet_directory_uri();
        $style_dir = get_stylesheet_directory();
        // Support externally referenced styles (like, say, fonts).
        foreach ($editor_styles as $key => $file) {
            if (preg_match('~^(https?:)?//~', $file)) {
                $stylesheets[] = sanitize_url($file);
                unset($editor_styles[$key]);
            }
        }
        // Look in a parent theme first, that way child theme CSS overrides.
        if (is_child_theme()) {
            $template_uri = get_template_directory_uri();
            $template_dir = get_template_directory();
            foreach ($editor_styles as $key => $file) {
                if ($file && file_exists("{$template_dir}/{$file}")) {
                    $stylesheets[] = "{$template_uri}/{$file}";
                }
            }
        }
        foreach ($editor_styles as $file) {
            if ($file && file_exists("{$style_dir}/{$file}")) {
                $stylesheets[] = "{$style_uri}/{$file}";
            }
        }
    }
    /**
     * Filters the array of URLs of stylesheets applied to the editor.
     *
     * @since 4.3.0
     *
     * @param string[] $stylesheets Array of URLs of stylesheets to be applied to the editor.
     */
    return apply_filters('editor_stylesheets', $stylesheets);
}

WordPress Version: 5.5

/**
 * Retrieves any registered editor stylesheet URLs.
 *
 * @since 4.0.0
 *
 * @global array $editor_styles Registered editor stylesheets
 *
 * @return string[] If registered, a list of editor stylesheet URLs.
 */
function get_editor_stylesheets()
{
    $stylesheets = array();
    // Load editor_style.css if the current theme supports it.
    if (!empty($GLOBALS['editor_styles']) && is_array($GLOBALS['editor_styles'])) {
        $editor_styles = $GLOBALS['editor_styles'];
        $editor_styles = array_unique(array_filter($editor_styles));
        $style_uri = get_stylesheet_directory_uri();
        $style_dir = get_stylesheet_directory();
        // Support externally referenced styles (like, say, fonts).
        foreach ($editor_styles as $key => $file) {
            if (preg_match('~^(https?:)?//~', $file)) {
                $stylesheets[] = esc_url_raw($file);
                unset($editor_styles[$key]);
            }
        }
        // Look in a parent theme first, that way child theme CSS overrides.
        if (is_child_theme()) {
            $template_uri = get_template_directory_uri();
            $template_dir = get_template_directory();
            foreach ($editor_styles as $key => $file) {
                if ($file && file_exists("{$template_dir}/{$file}")) {
                    $stylesheets[] = "{$template_uri}/{$file}";
                }
            }
        }
        foreach ($editor_styles as $file) {
            if ($file && file_exists("{$style_dir}/{$file}")) {
                $stylesheets[] = "{$style_uri}/{$file}";
            }
        }
    }
    /**
     * Filters the array of URLs of stylesheets applied to the editor.
     *
     * @since 4.3.0
     *
     * @param string[] $stylesheets Array of URLs of stylesheets to be applied to the editor.
     */
    return apply_filters('editor_stylesheets', $stylesheets);
}

WordPress Version: 5.4

/**
 * Retrieve any registered editor stylesheet URLs.
 *
 * @since 4.0.0
 *
 * @global array $editor_styles Registered editor stylesheets
 *
 * @return string[] If registered, a list of editor stylesheet URLs.
 */
function get_editor_stylesheets()
{
    $stylesheets = array();
    // Load editor_style.css if the current theme supports it.
    if (!empty($GLOBALS['editor_styles']) && is_array($GLOBALS['editor_styles'])) {
        $editor_styles = $GLOBALS['editor_styles'];
        $editor_styles = array_unique(array_filter($editor_styles));
        $style_uri = get_stylesheet_directory_uri();
        $style_dir = get_stylesheet_directory();
        // Support externally referenced styles (like, say, fonts).
        foreach ($editor_styles as $key => $file) {
            if (preg_match('~^(https?:)?//~', $file)) {
                $stylesheets[] = esc_url_raw($file);
                unset($editor_styles[$key]);
            }
        }
        // Look in a parent theme first, that way child theme CSS overrides.
        if (is_child_theme()) {
            $template_uri = get_template_directory_uri();
            $template_dir = get_template_directory();
            foreach ($editor_styles as $key => $file) {
                if ($file && file_exists("{$template_dir}/{$file}")) {
                    $stylesheets[] = "{$template_uri}/{$file}";
                }
            }
        }
        foreach ($editor_styles as $file) {
            if ($file && file_exists("{$style_dir}/{$file}")) {
                $stylesheets[] = "{$style_uri}/{$file}";
            }
        }
    }
    /**
     * Filters the array of URLs of stylesheets applied to the editor.
     *
     * @since 4.3.0
     *
     * @param string[] $stylesheets Array of URLs of stylesheets to be applied to the editor.
     */
    return apply_filters('editor_stylesheets', $stylesheets);
}

WordPress Version: 4.6

/**
 * Retrieve any registered editor stylesheets
 *
 * @since 4.0.0
 *
 * @global array $editor_styles Registered editor stylesheets
 *
 * @return array If registered, a list of editor stylesheet URLs.
 */
function get_editor_stylesheets()
{
    $stylesheets = array();
    // load editor_style.css if the current theme supports it
    if (!empty($GLOBALS['editor_styles']) && is_array($GLOBALS['editor_styles'])) {
        $editor_styles = $GLOBALS['editor_styles'];
        $editor_styles = array_unique(array_filter($editor_styles));
        $style_uri = get_stylesheet_directory_uri();
        $style_dir = get_stylesheet_directory();
        // Support externally referenced styles (like, say, fonts).
        foreach ($editor_styles as $key => $file) {
            if (preg_match('~^(https?:)?//~', $file)) {
                $stylesheets[] = esc_url_raw($file);
                unset($editor_styles[$key]);
            }
        }
        // Look in a parent theme first, that way child theme CSS overrides.
        if (is_child_theme()) {
            $template_uri = get_template_directory_uri();
            $template_dir = get_template_directory();
            foreach ($editor_styles as $key => $file) {
                if ($file && file_exists("{$template_dir}/{$file}")) {
                    $stylesheets[] = "{$template_uri}/{$file}";
                }
            }
        }
        foreach ($editor_styles as $file) {
            if ($file && file_exists("{$style_dir}/{$file}")) {
                $stylesheets[] = "{$style_uri}/{$file}";
            }
        }
    }
    /**
     * Filters the array of stylesheets applied to the editor.
     *
     * @since 4.3.0
     *
     * @param array $stylesheets Array of stylesheets to be applied to the editor.
     */
    return apply_filters('editor_stylesheets', $stylesheets);
}

WordPress Version: 4.3

/**
 * Retrieve any registered editor stylesheets
 *
 * @since 4.0.0
 *
 * @global array $editor_styles Registered editor stylesheets
 *
 * @return array If registered, a list of editor stylesheet URLs.
 */
function get_editor_stylesheets()
{
    $stylesheets = array();
    // load editor_style.css if the current theme supports it
    if (!empty($GLOBALS['editor_styles']) && is_array($GLOBALS['editor_styles'])) {
        $editor_styles = $GLOBALS['editor_styles'];
        $editor_styles = array_unique(array_filter($editor_styles));
        $style_uri = get_stylesheet_directory_uri();
        $style_dir = get_stylesheet_directory();
        // Support externally referenced styles (like, say, fonts).
        foreach ($editor_styles as $key => $file) {
            if (preg_match('~^(https?:)?//~', $file)) {
                $stylesheets[] = esc_url_raw($file);
                unset($editor_styles[$key]);
            }
        }
        // Look in a parent theme first, that way child theme CSS overrides.
        if (is_child_theme()) {
            $template_uri = get_template_directory_uri();
            $template_dir = get_template_directory();
            foreach ($editor_styles as $key => $file) {
                if ($file && file_exists("{$template_dir}/{$file}")) {
                    $stylesheets[] = "{$template_uri}/{$file}";
                }
            }
        }
        foreach ($editor_styles as $file) {
            if ($file && file_exists("{$style_dir}/{$file}")) {
                $stylesheets[] = "{$style_uri}/{$file}";
            }
        }
    }
    /**
     * Filter the array of stylesheets applied to the editor.
     *
     * @since 4.3.0
     *
     * @param array $stylesheets Array of stylesheets to be applied to the editor.
     */
    return apply_filters('editor_stylesheets', $stylesheets);
}

WordPress Version: 4.0

/**
 * Retrieve any registered editor stylesheets
 *
 * @since 4.0.0
 *
 * @global $editor_styles Registered editor stylesheets
 *
 * @return array If registered, a list of editor stylesheet URLs.
 */
function get_editor_stylesheets()
{
    $stylesheets = array();
    // load editor_style.css if the current theme supports it
    if (!empty($GLOBALS['editor_styles']) && is_array($GLOBALS['editor_styles'])) {
        $editor_styles = $GLOBALS['editor_styles'];
        $editor_styles = array_unique(array_filter($editor_styles));
        $style_uri = get_stylesheet_directory_uri();
        $style_dir = get_stylesheet_directory();
        // Support externally referenced styles (like, say, fonts).
        foreach ($editor_styles as $key => $file) {
            if (preg_match('~^(https?:)?//~', $file)) {
                $stylesheets[] = esc_url_raw($file);
                unset($editor_styles[$key]);
            }
        }
        // Look in a parent theme first, that way child theme CSS overrides.
        if (is_child_theme()) {
            $template_uri = get_template_directory_uri();
            $template_dir = get_template_directory();
            foreach ($editor_styles as $key => $file) {
                if ($file && file_exists("{$template_dir}/{$file}")) {
                    $stylesheets[] = "{$template_uri}/{$file}";
                }
            }
        }
        foreach ($editor_styles as $file) {
            if ($file && file_exists("{$style_dir}/{$file}")) {
                $stylesheets[] = "{$style_uri}/{$file}";
            }
        }
    }
    return $stylesheets;
}