Make WordPress Core


Ignore:
Timestamp:
10/07/2025 01:23:00 AM (2 months ago)
Author:
westonruter
Message:

Script Loader: Add sourceURL comments to inline SCRIPT tags manually constructed in wp-includes.

This applies to tags constructed without wp_get_inline_script_tag()/wp_print_inline_script_tag().

Developed in https://github.com/WordPress/wordpress-develop/pull/9955.

Props westonruter, jonsurrell.
See #63887.

File:
1 edited

Legend:

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

    r60783 r60909  
    519519     * back to WordPress 4.4, so in order to not break older installs this script must come at the end.
    520520     */
     521    $js_path = '/js/wp-embed' . wp_scripts_get_suffix() . '.js';
    521522    $output .= wp_get_inline_script_tag(
    522         file_get_contents( ABSPATH . WPINC . '/js/wp-embed' . wp_scripts_get_suffix() . '.js' )
     523        trim( file_get_contents( ABSPATH . WPINC . $js_path ) ) . "\n//# sourceURL=" . includes_url( $js_path )
    523524    );
    524525
     
    10911092 */
    10921093function print_embed_scripts() {
     1094    $js_path = '/js/wp-embed-template' . wp_scripts_get_suffix() . '.js';
    10931095    wp_print_inline_script_tag(
    1094         file_get_contents( ABSPATH . WPINC . '/js/wp-embed-template' . wp_scripts_get_suffix() . '.js' )
     1096        trim( file_get_contents( ABSPATH . WPINC . $js_path ) ) . "\n//# sourceURL=" . includes_url( $js_path )
    10951097    );
    10961098}
Note: See TracChangeset for help on using the changeset viewer.