[wp-trac] [WordPress Trac] #36778: Parent theme editor-style.css cannot be disabled

WordPress Trac noreply at wordpress.org
Tue Jun 14 15:52:27 UTC 2016


#36778: Parent theme editor-style.css cannot be disabled
-----------------------------+-----------------------------
 Reporter:  matthewmcvickar  |       Owner:
     Type:  enhancement      |      Status:  new
 Priority:  normal           |   Milestone:  Future Release
Component:  Editor           |     Version:
 Severity:  normal           |  Resolution:
 Keywords:  needs-patch      |     Focuses:  administration
-----------------------------+-----------------------------

Comment (by matthewmcvickar):

 Hello @ocean90 and thank you!

 I'm afraid neither of those approaches work when I try them.

 My parent theme has an {{{editor-style.css}}}; my child theme does not.

 When I use
 [https://developer.wordpress.org/reference/functions/remove_editor_styles
 remove_editor_styles()] in the child theme, the parent theme’s editor
 stylesheet is still used.

 Similarly, when hooking into the
 [https://developer.wordpress.org/reference/hooks/editor_stylesheets/
 editor_stylesheets] filter, neither {{{unset}}}ting the array passed into
 the filter nor {{{unset}}}ting the {{{$GLOBALS['editor_styles']}}} array
 nor returning {{{false}}} has any effect—the parent theme’s editor
 stylesheet is still loaded.

 (So far, I've gotten around this by checking if that file exists and
 deleting it if it does—that seems to be the only way around this that I
 can figure out.)

 {{{#!php
 // Doesn't work.
 remove_editor_styles();

 // Doesn't work.
 add_filter('editor_stylesheets', 'remove_parent_theme_editor_stylesheet');
 function remove_parent_theme_editor_stylesheet($stylesheets) {
   unset($stylesheets);
   unset($GLOBALS['editor_styles']);
   return $stylesheets;
 }

 // Does work, but very ugly.
 add_action('admin_init', 'remove_parent_theme_editor_stylesheet_file');
 function remove_parent_theme_editor_stylesheet_file() {
   $parent_theme_editor_css = get_template_directory() . '/editor-
 style.css';
   if (file_exists($parent_theme_editor_css)) {
     unlink($parent_theme_editor_css);
   }
 }
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/36778#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list