Skip to content

Commit

Permalink
Add static to anonymous function
Browse files Browse the repository at this point in the history
  • Loading branch information
noisysocks committed Nov 9, 2021
1 parent aa5807a commit 12c72e7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/wp-includes/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,7 @@ function wp_enqueue_block_style( $block_name, $args ) {
*
* @return string
*/
$callback = function( $content ) use ( $args ) {
$callback = static function( $content ) use ( $args ) {
// Register the stylesheet.
if ( ! empty( $args['src'] ) ) {
wp_register_style( $args['handle'], $args['src'], $args['deps'], $args['ver'], $args['media'] );
Expand Down Expand Up @@ -1250,7 +1250,15 @@ function wp_enqueue_block_style( $block_name, $args ) {
$hook = "render_block_$block_name";
}

// Enqueue assets in the frontend.
/*
* The filter's callback here is an anonymous function because
* using a named function in this case is not possible.
*
* The function cannot be unhooked, however, users are still able
* to dequeue the stylesheets registered/enqueued by the callback
* which is why in this case, using an anonymous function
* was deemed acceptable.
*/
add_filter( $hook, $callback );

// Enqueue assets in the editor.
Expand Down

0 comments on commit 12c72e7

Please sign in to comment.