On this page
get_editor_stylesheets(): string[]
Retrieves any registered editor stylesheet URLs.
Return
string[] If registered, a list of editor stylesheet URLs.
Source
File: wp-includes/theme.php. View all references
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 );
}
Hooks
- apply_filters( 'editor_stylesheets',
string[] $stylesheets ) -
Filters the array of URLs of stylesheets applied to the editor.
Related
Uses
| Uses | Description |
|---|---|
| get_stylesheet_directory_uri() wp-includes/theme.php | Retrieves stylesheet directory URI for the active theme. |
| get_stylesheet_directory() wp-includes/theme.php | Retrieves stylesheet directory path for the active theme. |
| get_template_directory_uri() wp-includes/theme.php | Retrieves template directory URI for the active theme. |
| get_template_directory() wp-includes/theme.php | Retrieves template directory path for the active theme. |
| is_child_theme() wp-includes/theme.php | Whether a child theme is in use. |
| sanitize_url() wp-includes/formatting.php | Sanitizes a URL for database or redirect usage. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
Used By
| Used By | Description |
|---|---|
| _WP_Editors::editor_settings() wp-includes/class-wp-editor.php |
Changelog
| Version | Description |
|---|---|
| 4.0.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_editor_stylesheets