Skip to content

Conversation

@aristath
Copy link
Member

@aristath aristath commented Jan 11, 2022

When using a block theme, make sure that additional block styles enqueued using wp_enqueue_block_style only get printed when the block exists on the page.

Trac ticket: https://core.trac.wordpress.org/ticket/54790

Backports Gutenberg patch from WordPress/gutenberg#37848


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

* @param array $block The full block, including name and attributes.
* @return string Block content.
*/
$callback_separate = static function( $content, $block ) use ( $block_name, $callback ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anonymous functions as callbacks to filter/action is prohibited in Core.

To resolve, an overall architectural strategy is needed to provide the means to unhook callbacks and remove the anonymous functions.

However, as this pattern already exists in this file and it's too late in 5.9 to introduce a new architectural strategy to remove the need for these lambdas, this pattern is consistent. Plus the static keyword is for performance.

Copy link
Contributor

@hellofromtonya hellofromtonya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready for commit 👍

@hellofromtonya
Copy link
Contributor

@aristath aristath deleted the fix/54790 branch January 12, 2022 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants