From a0b40ebd6a50386c8e47a8c41206748fa46b2844 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 27 Aug 2020 21:57:01 +0000 Subject: [PATCH] Script Loader: Disable concatenation for scripts with translations to ensure they are printed in the right order. Props herregroen, ocean90, desrosj, mikeyarce, bobbingwide, audrasjb, johnbillion. Fixes #50999. git-svn-id: https://develop.svn.wordpress.org/trunk@48897 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class.wp-scripts.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/wp-includes/class.wp-scripts.php b/src/wp-includes/class.wp-scripts.php index f63517f7e1..aa4935da6b 100644 --- a/src/wp-includes/class.wp-scripts.php +++ b/src/wp-includes/class.wp-scripts.php @@ -311,6 +311,11 @@ class WP_Scripts extends WP_Dependencies { $inline_script_tag = ''; } + $translations = $this->print_translations( $handle, false ); + if ( $translations ) { + $translations = sprintf( "\n%s\n\n", $this->type_attr, esc_attr( $handle ), $translations ); + } + if ( $this->do_concat ) { /** * Filters the script loader source. @@ -322,7 +327,7 @@ class WP_Scripts extends WP_Dependencies { */ $srce = apply_filters( 'script_loader_src', $src, $handle ); - if ( $this->in_default_dir( $srce ) && ( $before_handle || $after_handle ) ) { + if ( $this->in_default_dir( $srce ) && ( $before_handle || $after_handle || $translations ) ) { $this->do_concat = false; // Have to print the so-far concatenated scripts right away to maintain the right order. @@ -364,11 +369,6 @@ class WP_Scripts extends WP_Dependencies { return true; } - $translations = $this->print_translations( $handle, false ); - if ( $translations ) { - $translations = sprintf( "\n%s\n\n", $this->type_attr, esc_attr( $handle ), $translations ); - } - if ( ! preg_match( '|^(https?:)?//|', $src ) && ! ( $this->content_url && 0 === strpos( $src, $this->content_url ) ) ) { $src = $this->base_url . $src; }