Make WordPress Core

Opened 10 years ago

Closed 5 years ago

#30187 closed enhancement (wontfix)

Ability to not apply editor stylesheets to wp_editor

Reported by: dancameron's profile dancameron Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.3
Component: TinyMCE Keywords:
Focuses: ui, administration Cc:

Description

I'm finding that there's no way to remove the editor stylesheets from wp_editor. The mce_css filter could be used to filter out the styles added with get_editor_stylesheets but nothing is passed within the filter to distinguish an editor that should get the editor stylesheets and one that shouldn't.

I'm proposing one of two solutions:

  • Add a theme_styles bool to wp_editor to prevent get_editor_stylesheets being added to the $mce_css array.
  • Pass set to the mce_css filter so devs can filter them out.

IMO both patches should be applied, since I see the viability of the setting and the future possibilities of filtering mce_css with some context on what's being filtered.

Attachments (2)

class-wp-editor.php.diff (3.4 KB) - added by dancameron 10 years ago.
theme_styles option: Whether to add theme editor styles. Default true.
filter.class-wp-editor.php.diff (616 bytes) - added by dancameron 10 years ago.
Add context and additional information to mce_css filter

Download all attachments as: .zip

Change History (10)

@dancameron
10 years ago

theme_styles option: Whether to add theme editor styles. Default true.

@dancameron
10 years ago

Add context and additional information to mce_css filter

#1 @dancameron
10 years ago

Ideally I would be adding some unit tests to this ticket as well but I'm not certain how to approach such a test. I don't see any mce tests to work off either. Any help would be appreciated.

This ticket was mentioned in Slack in #core by dancameron. View the logs.


10 years ago

#3 @jbrinley
10 years ago

Unfortunately, I don't think that's going to accomplish what you're hoping, @dancameron. The mce_css filter only runs on the first editor instantiated for the page load. All the other editors just inherit the CSS from that one. If you want to apply different stylesheets to a single editor, you have to mess about in then tinymce initialization on the client side. I've done so by printing scripts at wp_tiny_mce_init and using said script to edit the tinyMCEPreInit.mceInit array so that I can manage the initialization of my editors independently of the global initialization.

#4 @dancameron
10 years ago

@jbrinley While this patch does accomplish what I want, you're right that I was hoping it would allow for the main editor (if present) would get the theme styles. Looks like I need to figure out a solution for both scenarios. Thanks!

#5 @azaozz
10 years ago

To be able to properly do this we would need to (somewhat) refactor WP_Editors. Currently it is geared towards adding the same editor as on the Edit Post screen somewhere else. Would need to make it work better for multiple instances of TinyMCE.

One way to accomplish removing of additional stylesheets without needing extra filters would be to hook into 'wp_editor_settings', check if it is the desired instance, then add a filter on 'tiny_mce_before_init' where the content_css setting can be emptied/tweaked.

Another way is to do the same with some JS added on the 'wp_tiny_mce_init' action.

Version 2, edited 10 years ago by azaozz (previous) (next) (diff)

#6 @boonebgorges
10 years ago

  • Version changed from trunk to 3.3

#8 @azaozz
5 years ago

  • Resolution set to wontfix
  • Status changed from new to closed

Thinking that the workaround from comment 5 is sufficient here.

Note: See TracTickets for help on using tickets.