Skip to content

Commit

Permalink
Plugin: Ensure that translations are set correctly when overriding sc…
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed May 5, 2023
1 parent 9a31bb4 commit 0cdab08
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,8 @@ function gutenberg_override_script( $scripts, $handle, $src, $deps = array(), $v
$scripts->add( $handle, $src, $deps, $ver, ( $in_footer ? 1 : null ) );
}

/*
* `WP_Dependencies::set_translations` will fall over on itself if setting
* translations on the `wp-i18n` handle, since it internally adds `wp-i18n`
* as a dependency of itself, exhausting memory. The same applies for the
* polyfill and hooks scripts, which are dependencies _of_ `wp-i18n`.
*
* See: https://core.trac.wordpress.org/ticket/46089
*/
if ( ! in_array( $handle, array( 'wp-i18n', 'wp-polyfill', 'wp-hooks' ), true ) ) {
$scripts->set_translations( $handle, 'default' );
if ( in_array( 'wp-i18n', $deps, true ) ) {
$scripts->set_translations( $handle );
}

/*
Expand Down

0 comments on commit 0cdab08

Please sign in to comment.