[wp-trac] [WordPress Trac] #36778: Parent theme editor-style.css cannot be disabled
WordPress Trac
noreply at wordpress.org
Mon Feb 27 00:05:08 UTC 2017
#36778: Parent theme editor-style.css cannot be disabled
-------------------------------------+-----------------------------
Reporter: matthewmcvickar | Owner:
Type: enhancement | Status: reopened
Priority: normal | Milestone:
Component: Editor | Version:
Severity: normal | Resolution:
Keywords: needs-patch 2nd-opinion | Focuses: administration
-------------------------------------+-----------------------------
Comment (by azaozz):
Replying to [comment:7 eclare]:
> ...since the `mce_css` filter feels hacky.
No, it's the opposite :) `mce_css` is the best way to add or remove any
style for the editor. This is the best way for both themes and plugins.
`add_editor_style()` was added later as "dumbed down hand-holding" for
theme authors as apparently it is too hard for many of them to use
filters... I didn't like the idea then, I dislike it even more now. As you
mention lots and lots of themes use that to add all kinds of sub-standard
CSS to the editor often breaking some functionality or making it behave
unexpectedly.
There are several ways to remove theme added stylesheets from the editor.
The most straight-forward is:
{{{
add_action( 'admin_init', 'my_remove_parent_styles' );
function my_remove_parent_styles() {
remove_editor_styles();
add_editor_style( 'child-editor-style.css' );
}
}}}
(note that the child theme's stylesheet is called `child-editor-style.css`
here).
If the parent theme adds several stylesheets (for example external fonts),
it would be better to use `mce_css` and loop through them to determine
which to keep.
> (theme developers will) edit the parent theme's PHP file instead of
Googling around for this particular page for a solution.
All ''serious'' developers would know better than editing somebody else's
files. Perhaps we can include some more help to the `add_editor_style()`
docblock (and a link to this ticket) to help them out? Patch welcome :)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/36778#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list