- Timestamp:
- 01/11/2022 03:57:09 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks.php
r52354 r52556 1255 1255 $hook = did_action( 'wp_enqueue_scripts' ) ? 'wp_footer' : 'wp_enqueue_scripts'; 1256 1256 if ( wp_should_load_separate_core_block_assets() ) { 1257 $hook = "render_block_$block_name"; 1257 /** 1258 * Callback function to register and enqueue styles. 1259 * 1260 * @param string $content The block content. 1261 * @param array $block The full block, including name and attributes. 1262 * @return string Block content. 1263 */ 1264 $callback_separate = static function( $content, $block ) use ( $block_name, $callback ) { 1265 if ( ! empty( $block['blockName'] ) && $block_name === $block['blockName'] ) { 1266 return $callback( $content ); 1267 } 1268 return $content; 1269 }; 1270 1271 /* 1272 * The filter's callback here is an anonymous function because 1273 * using a named function in this case is not possible. 1274 * 1275 * The function cannot be unhooked, however, users are still able 1276 * to dequeue the stylesheets registered/enqueued by the callback 1277 * which is why in this case, using an anonymous function 1278 * was deemed acceptable. 1279 */ 1280 add_filter( 'render_block', $callback_separate, 10, 2 ); 1281 return; 1258 1282 } 1259 1283
Note: See TracChangeset
for help on using the changeset viewer.