[wp-trac] [WordPress Trac] #52276: Feature Request - additional hooks for parent and child theme

WordPress Trac noreply at wordpress.org
Wed Jan 13 08:20:07 UTC 2021


#52276: Feature Request - additional hooks for parent and child theme
-----------------------------+------------------------------
 Reporter:  landwire         |       Owner:  (none)
     Type:  feature request  |      Status:  new
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  Themes           |     Version:  5.6
 Severity:  normal           |  Resolution:
 Keywords:                   |     Focuses:
-----------------------------+------------------------------

Comment (by landwire):

 Perfect. Thank you! Did not think of this.

 I still have a problem removing a specific action though, which led me to
 this ticket. I am adding editor styles in the parent theme:


 {{{
 add_action('after_setup_theme',
 'Proctor\BlockEditorAssets\loadBlockEditorCSS');

 function loadBlockEditorCSS()
 {
     $fe_path = FrontendPath::getFrontendPath();

     add_editor_style(get_template_directory_uri() . $fe_path .
 '/css/cssVariables.css');
     add_editor_style(get_template_directory_uri() . $fe_path .
 '/css/main.css');
     add_editor_style(get_template_directory_uri() . $fe_path .
 '/css/gutenberg.css');
 }
 }}}

 My child theme loads with after_setup_theme and priority 15 as per your
 suggestion. That works great and no new hooks are necessary!

 In the child theme I then try to remove the CSS from the parent with:

 {{{
 add_action('after_setup_theme',
 'Slate\BlockEditorAssets\removeGutenbergAssetsFromParentTheme', 20);

 function removeGutenbergAssetsFromParentTheme()
 {
     // the JS is removed !!!
     remove_action('enqueue_block_editor_assets',
 'Proctor\BlockEditorAssets\loadBlockEditorJS');
     // this does not remove CSS! -> Why?
     remove_action('after_setup_theme',
 'Proctor\BlockEditorAssets\loadBlockEditorCSS');
 }
 }}}

 Oddly enough it removes the JS, but not the CSS. What could the reason be
 for this?

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


More information about the wp-trac mailing list