Make WordPress Core


Ignore:
Timestamp:
02/16/2022 05:26:46 PM (3 years ago)
Author:
jorgefilipecosta
Message:

Script Loader: Load block support styles in the head for block themes.

The dynamic block styles for layout and elements should be loaded in the head for block themes. While that should also be the case for classic themes, the current mechanism we use (render_block) does not allow us to do that, hence, this PR doesn't change anything for them and will be loaded the body.

Props oandregal, youknowriad, wpsoul.
Fixes #55148.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/block-supports/layout.php

    r52434 r52741  
    176176    );
    177177
    178     /*
    179      * Ideally styles should be loaded in the head, but blocks may be parsed
    180      * after that, so loading in the footer for now.
    181      * See https://core.trac.wordpress.org/ticket/53494.
    182      */
    183     add_action(
    184         'wp_footer',
    185         static function () use ( $style ) {
    186             echo '<style>' . $style . '</style>';
    187         }
    188     );
     178    wp_enqueue_block_support( $style );
    189179
    190180    return $content;
Note: See TracChangeset for help on using the changeset viewer.