add_editor_style( array|string $stylesheet = 'editor-style.css' )
- Since
- 3.0.0
- Source
wp-includes/theme.php:2185
Description
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.
Compatibility
- WordPress
- since 3.0.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$stylesheetarray|stringoptional- Stylesheet name or array thereof, relative to theme root.
Defaults to 'editor-style.css'Default:'editor-style.css'
Performance profile
How much work a call to add_editor_style() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Trivial
- Scaling
- Constant
- Instructions
- 18–23
- Plugin surface
- None
- Called by
- 13
Touches nothing outside its own arguments.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 23.
Nothing here hands control to plugin code.
13 places in core call this, so the cost is paid more often than your own code shows.
What one call costs · 1 distinct outcome
One number would be a lie: the work depends on which branch runs. These are every distinct cost add_editor_style() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 18–23 | add_theme_support(), is_rtl(), array_merge() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 23 | 18–23 | 1 | |
| 8.5 | 23 | 18–23 | 1 | |
| 8.4 | 23 | 18–23 | 1 | 4 fewer instructions than PHP 8.3 |
| 8.3 | 27 | 18–27 | 1 | |
| 8.2 | 27 | 18–27 | 1 | |
| 8.1 | 27 | 18–27 | 1 | |
| 7.4 | 27 | 18–27 | 1 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Uses · 2
- add_theme_support()Registers theme support for a given feature.
- is_rtl()Determines whether the current locale is right-to-left (RTL).
Used by · 13
- twenty_twenty_one_setup()Sets up theme defaults and registers support for various WordPress features.
- twentyeleven_setup()Sets up theme defaults and registers support for various WordPress features.
- twentyfifteen_setup()Sets up theme defaults and registers support for various WordPress features.
- twentyfourteen_setup()Twenty Fourteen setup.
- twentynineteen_setup()Sets up theme defaults and registers support for various WordPress features.
- twentyseventeen_setup()Sets up theme defaults and registers support for various WordPress features.
- twentysixteen_setup()Sets up theme defaults and registers support for various WordPress features.
- twentyten_setup()Sets up theme defaults and registers support for various WordPress features.
- twentythirteen_setup()Twenty Thirteen setup.
- twentytwelve_setup()Twenty Twelve setup.
- twentytwenty_classic_editor_styles()Enqueues classic editor styles.
- twentytwentyfive_editor_style()Enqueues editor-style.css in the editors.
Show all 13
- twentytwentytwo_support()Sets up theme defaults and registers support for various WordPress features.
Source code
function add_editor_style( $stylesheet = 'editor-style.css' ) { global $editor_styles; add_theme_support( 'editor-style' ); $editor_styles = (array) $editor_styles; $stylesheet = (array) $stylesheet; if ( is_rtl() ) { $rtl_stylesheet = str_replace( '.css', '-rtl.css', $stylesheet[0] ); $stylesheet[] = $rtl_stylesheet; } $editor_styles = array_merge( $editor_styles, $stylesheet );}Changelog
Introduced in 3.0.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/theme.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.