Editor: Use static closures to avoid memory leaks.

Backports Gutenberg changes from https://github.com/WordPress/gutenberg/pull/50723.

Amends [55822].

Fixes #58323.
Props westonruter, spacedmonkey, flixos90. 


git-svn-id: https://develop.svn.wordpress.org/trunk@56038 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Weston Ruter 2023-06-26 16:58:38 +00:00
parent b6fde03ef7
commit c7597fa62f
3 changed files with 3 additions and 3 deletions

View File

@ -2423,7 +2423,7 @@ class WP_Theme_JSON {
$pseudo_matches = array_values(
array_filter(
$element_pseudo_allowed,
function( $pseudo_selector ) use ( $selector ) {
static function( $pseudo_selector ) use ( $selector ) {
return str_contains( $selector, $pseudo_selector );
}
)

View File

@ -370,7 +370,7 @@ function wp_add_global_styles_for_blocks() {
$result = array_values(
array_filter(
$metadata['path'],
function ( $item ) {
static function ( $item ) {
if ( str_contains( $item, 'core/' ) ) {
return true;
}

View File

@ -4217,7 +4217,7 @@ EOF;
$result = null;
add_filter(
'the_content',
function( $content ) use ( &$result, $context ) {
static function( $content ) use ( &$result, $context ) {
$result = wp_get_loading_attr_default( $context );
return $content;
}