Make WordPress Core

Changeset 48897


Ignore:
Timestamp:
08/27/2020 09:57:01 PM (4 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class.wp-scripts.php

    r48295 r48897  
    310310        } else {
    311311            $inline_script_tag = '';
     312        }
     313
     314        $translations = $this->print_translations( $handle, false );
     315        if ( $translations ) {
     316            $translations = sprintf( "<script%s id='%s-js-translations'>\n%s\n</script>\n", $this->type_attr, esc_attr( $handle ), $translations );
    312317        }
    313318
     
    323328            $srce = apply_filters( 'script_loader_src', $src, $handle );
    324329
    325             if ( $this->in_default_dir( $srce ) && ( $before_handle || $after_handle ) ) {
     330            if ( $this->in_default_dir( $srce ) && ( $before_handle || $after_handle || $translations ) ) {
    326331                $this->do_concat = false;
    327332
     
    365370        }
    366371
    367         $translations = $this->print_translations( $handle, false );
    368         if ( $translations ) {
    369             $translations = sprintf( "<script%s id='%s-js-translations'>\n%s\n</script>\n", $this->type_attr, esc_attr( $handle ), $translations );
    370         }
    371 
    372372        if ( ! preg_match( '|^(https?:)?//|', $src ) && ! ( $this->content_url && 0 === strpos( $src, $this->content_url ) ) ) {
    373373            $src = $this->base_url . $src;
Note: See TracChangeset for help on using the changeset viewer.