add_editor_style

Add callback for custom TinyMCE editor stylesheets.

Description

add_editor_style( (string) $stylesheet = 'editor-style.css' ); 

The parameter $stylesheet is the name of the stylesheet, relative to the theme root. It also accepts an array of stylesheets. It is optional and defaults to editor-style.css..

This function automatically adds another stylesheet with -rtl prefix, e.g. editor-style-rtl.css. If that file doesn't exist, it is removed before adding the stylesheet(s) to TinyMCE. If an array of stylesheets is passed to add_editor_style(), RTL is only added for the first stylesheet.

Since version 3.4 the TinyMCE body has .rtl CSS class. It is a better option to use that class and add any RTL styles to the main stylesheet.

Parameters (1)

0. $stylesheet — Optional. (string) => 'editor-style.css'
Stylesheet name or array thereof, relative to theme root. Defaults to editor-style.css

Usage

  1. if ( !function_exists( 'add_editor_style' ) ) { 
  2. require_once ABSPATH . WPINC . '/theme.php'; 
  3.  
  4. // Optional. Stylesheet name or array thereof, relative to theme root. 
  5. // Defaults to 'editor-style.css' 
  6. $stylesheet = 'editor-style.css'; 
  7.  
  8. // NOTICE! Understand what this does before running. 
  9. $result = add_editor_style($stylesheet); 
  10.  

Defined (1)

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

/wp-includes/theme.php  
  1. function add_editor_style( $stylesheet = 'editor-style.css' ) { 
  2. add_theme_support( 'editor-style' ); 
  3.  
  4. if ( ! is_admin() ) 
  5. return; 
  6.  
  7. global $editor_styles; 
  8. $editor_styles = (array) $editor_styles; 
  9. $stylesheet = (array) $stylesheet; 
  10. if ( is_rtl() ) { 
  11. $rtl_stylesheet = str_replace('.css', '-rtl.css', $stylesheet[0]); 
  12. $stylesheet[] = $rtl_stylesheet; 
  13.  
  14. $editor_styles = array_merge( $editor_styles, $stylesheet );