get_editor_stylesheets

Retrieve any registered editor stylesheets.

Description

(array) get_editor_stylesheets(); 

Returns (array)

If registered, a list of editor stylesheet URLs.


Usage

  1. if ( !function_exists( 'get_editor_stylesheets' ) ) { 
  2. require_once ABSPATH . WPINC . '/theme.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = get_editor_stylesheets(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/theme.php  
  1. function get_editor_stylesheets() { 
  2. $stylesheets = array(); 
  3. // load editor_style.css if the current theme supports it 
  4. if ( ! empty( $GLOBALS['editor_styles'] ) && is_array( $GLOBALS['editor_styles'] ) ) { 
  5. $editor_styles = $GLOBALS['editor_styles']; 
  6.  
  7. $editor_styles = array_unique( array_filter( $editor_styles ) ); 
  8. $style_uri = get_stylesheet_directory_uri(); 
  9. $style_dir = get_stylesheet_directory(); 
  10.  
  11. // Support externally referenced styles (like, say, fonts). 
  12. foreach ( $editor_styles as $key => $file ) { 
  13. if ( preg_match( '~^(https?:)?//~', $file ) ) { 
  14. $stylesheets[] = esc_url_raw( $file ); 
  15. unset( $editor_styles[ $key ] ); 
  16.  
  17. // Look in a parent theme first, that way child theme CSS overrides. 
  18. if ( is_child_theme() ) { 
  19. $template_uri = get_template_directory_uri(); 
  20. $template_dir = get_template_directory(); 
  21.  
  22. foreach ( $editor_styles as $key => $file ) { 
  23. if ( $file && file_exists( "$template_dir/$file" ) ) { 
  24. $stylesheets[] = "$template_uri/$file"; 
  25.  
  26. foreach ( $editor_styles as $file ) { 
  27. if ( $file && file_exists( "$style_dir/$file" ) ) { 
  28. $stylesheets[] = "$style_uri/$file"; 
  29.  
  30. /** 
  31. * Filters the array of stylesheets applied to the editor. 
  32. * @since 4.3.0 
  33. * @param array $stylesheets Array of stylesheets to be applied to the editor. 
  34. */ 
  35. return apply_filters( 'editor_stylesheets', $stylesheets );