Changeset 52741
- Timestamp:
- 02/16/2022 05:26:46 PM (3 years ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/block-supports/elements.php
r52069 r52741 47 47 $link_color_declaration = esc_html( safecss_filter_attr( "color: $link_color" ) ); 48 48 49 $style = " <style>.$class_name a{" . $link_color_declaration . ";}</style>\n";49 $style = ".$class_name a{" . $link_color_declaration . ';}'; 50 50 51 51 // Like the layout hook this assumes the hook only applies to blocks with a single wrapper. … … 69 69 } 70 70 71 /* 72 * Ideally styles should be loaded in the head, but blocks may be parsed 73 * after that, so loading in the footer for now. 74 * See https://core.trac.wordpress.org/ticket/53494. 75 */ 76 add_action( 77 'wp_footer', 78 static function () use ( $style ) { 79 echo $style; 80 } 81 ); 71 wp_enqueue_block_support( $style ); 82 72 83 73 return $content; -
trunk/src/wp-includes/block-supports/layout.php
r52434 r52741 176 176 ); 177 177 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 ); 189 179 190 180 return $content; -
trunk/src/wp-includes/blocks.php
r52699 r52741 1333 1333 } 1334 1334 add_filter( 'block_type_metadata', '_wp_multiple_block_styles' ); 1335 1336 /** 1337 * This function takes care of adding inline styles 1338 * in the proper place, depending on the theme in use. 1339 * 1340 * For block themes, it's loaded in the head. 1341 * For classic ones, it's loaded in the body 1342 * because the wp_head action (and wp_enqueue_scripts) 1343 * happens before the render_block. 1344 * 1345 * See https://core.trac.wordpress.org/ticket/53494. 1346 * 1347 * @param string $style String containing the CSS styles to be added. 1348 */ 1349 function wp_enqueue_block_support( $style ) { 1350 $action_hook_name = 'wp_footer'; 1351 if ( wp_is_block_theme() ) { 1352 $action_hook_name = 'wp_enqueue_scripts'; 1353 } 1354 add_action( 1355 $action_hook_name, 1356 function () use ( $style ) { 1357 echo "<style>$style</style>\n"; 1358 } 1359 ); 1360 }
Note: See TracChangeset
for help on using the changeset viewer.