Make WordPress Core

Changeset 48898


Ignore:
Timestamp:
08/27/2020 09:59:17 PM (6 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.
Merges [48897] to the 5.5 branch.
Fixes #50999.

Location:
branches/5.5
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.5

  • branches/5.5/src/wp-includes/class.wp-scripts.php

    r48295 r48898  
    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.