Make WordPress Core

Changeset 52151


Ignore:
Timestamp:
11/13/2021 12:57:35 AM (5 years ago)
Author:
westonruter
Message:

Embeds: Fix inclusion of wp-embed-template script and style when SCRIPT_DEBUG is disabled.

Amends [52132].
See #44632.

File:
1 edited

Legend:

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

    r52132 r52151  
    473473
    474474        $output = wp_get_inline_script_tag(
    475                 file_get_contents( sprintf( ABSPATH . WPINC . '/js/wp-embed' . wp_scripts_get_suffix() . '.js' ) )
     475                file_get_contents( ABSPATH . WPINC . '/js/wp-embed' . wp_scripts_get_suffix() . '.js' )
    476476        );
    477477
     
    10431043function print_embed_styles() {
    10441044        $type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"';
     1045        $suffix    = SCRIPT_DEBUG ? '' : '.min';
    10451046        ?>
    10461047        <style<?php echo $type_attr; ?>>
    1047         <?php
    1048         if ( SCRIPT_DEBUG ) {
    1049                 readfile( ABSPATH . WPINC . '/css/wp-embed-template.css' );
    1050         } else {
    1051                 /*
    1052                  * If you're looking at a src version of this file, you'll see an "include"
    1053                  * statement below. This is used by the `npm run build` process to directly
    1054                  * include a minified version of wp-oembed-embed.css, instead of using the
    1055                  * readfile() method from above.
    1056                  *
    1057                  * If you're looking at a build version of this file, you'll see a string of
    1058                  * minified CSS. If you need to debug it, please turn on SCRIPT_DEBUG
    1059                  * and edit wp-embed-template.css directly.
    1060                  */
    1061                 ?>
    1062                         include "css/wp-embed-template.min.css"
    1063                 <?php
    1064         }
    1065         ?>
     1048                <?php echo file_get_contents( ABSPATH . WPINC . "/css/wp-embed-template$suffix.css" ); ?>
    10661049        </style>
    10671050        <?php
     
    10741057 */
    10751058function print_embed_scripts() {
    1076         $type_attr = current_theme_supports( 'html5', 'script' ) ? '' : ' type="text/javascript"';
    1077         ?>
    1078         <script<?php echo $type_attr; ?>>
    1079         <?php
    1080         if ( SCRIPT_DEBUG ) {
    1081                 readfile( ABSPATH . WPINC . '/js/wp-embed-template.js' );
    1082         } else {
    1083                 /*
    1084                  * If you're looking at a src version of this file, you'll see an "include"
    1085                  * statement below. This is used by the `npm run build` process to directly
    1086                  * include a minified version of wp-embed-template.js, instead of using the
    1087                  * readfile() method from above.
    1088                  *
    1089                  * If you're looking at a build version of this file, you'll see a string of
    1090                  * minified JavaScript. If you need to debug it, please turn on SCRIPT_DEBUG
    1091                  * and edit wp-embed-template.js directly.
    1092                  */
    1093                 ?>
    1094                         include "js/wp-embed-template.min.js"
    1095                 <?php
    1096         }
    1097         ?>
    1098         </script>
    1099         <?php
     1059        wp_print_inline_script_tag(
     1060                file_get_contents( ABSPATH . WPINC . '/js/wp-embed-template' . wp_scripts_get_suffix() . '.js' )
     1061        );
    11001062}
    11011063
Note: See TracChangeset for help on using the changeset viewer.