Commit c8cf34fa authored by Sergey Biryukov's avatar Sergey Biryukov
Browse files

Script Loader: Disable concatenation for scripts with translations to ensure...

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.
Merges [48897] to the 5.5 branch.
Fixes #50999.
Built from https://develop.svn.wordpress.org/branches/5.5@48898


git-svn-id: https://core.svn.wordpress.org/branches/5.5@48660 1a063a9b-81f0-0310-95a4-ce76da25c4cd
parent 110b23f5
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -311,6 +311,11 @@ class WP_Scripts extends WP_Dependencies {
			$inline_script_tag = '';
		}

		$translations = $this->print_translations( $handle, false );
		if ( $translations ) {
			$translations = sprintf( "<script%s id='%s-js-translations'>\n%s\n</script>\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( "<script%s id='%s-js-translations'>\n%s\n</script>\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;
		}
+1 −1
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@
 *
 * @global string $wp_version
 */
$wp_version = '5.5.1-alpha-48896';
$wp_version = '5.5.1-alpha-48898';

/**
 * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.