Make WordPress Core

Opened 3 years ago

Last modified 9 months ago

#51755 new defect (bug)

editor-styles theme feature naming with or without trailing s

Reported by: mmems's profile mmems Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.5.2
Component: Themes Keywords:
Focuses: Cc:

Description

I tried in vain to follow the documentation about editor styles:

There is no need to explicitly add theme support for this feature since support is added automatically when calling:

add_editor_style();

But I can't make it work.

The only way to do it is to use both functions:

// in after_setup_theme action:
add_theme_support( 'editor-styles' ); // without that call, the editor-style.css
add_editor_style();

After tried all combinations, I found that the function add_editor_style, remove_editor_styles and remove_theme_support use the theme feature name editor-style (without the trailing s) where the feature is called editor-styles in wp-includes/theme.php.
Note the default file name used in add_editor_style is editor-style.css (filename without s)

Note also that, this name also used (without s) in wp-admin/includes/theme.php.

Also it exist an other theme feature called dark-editor-style (without s) which is related to editor-styles theme feature.

There is a ways to simplify that, like using the name editor-style, and editor-styles as an alias (or vice versa)?
To be consistant, use (with or) without the trailing s everywhere?

Change History (1)

#1 @mattheu
9 months ago

I've also run into this issue, and figured it was worth a note on this ticket as the issue is still very much present. @mmems's description is correct and this can be easily reproduced by trying to use add_editor_style in a classic theme on WordPress 6.2.

Note that for block themes, this is not an issue as add_theme_support( 'editor-styles' ); is called automatically as part of _add_default_theme_supports.

I'm not sure whether this difference is intentional to distinguish block theme behavior from classic themes, or just a small accident when this was introduced. However the current state is pretty confusing. Some suggestions:

  • Update the function add_editor_style to add theme support for both editor-style and editor-styles?
  • Standardize on one behaviour. It doesn't seem that the older editor-style is used by core, although it's been around a long time (14 years).
  • If it is preferred that no change is made, the documentation could be updated to note this behaviour.
Note: See TracTickets for help on using tickets.