Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/wp-includes/class-wp-scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ public function print_extra_script( $handle, $display = true ) {
return;
}

$output .= sprintf(
"\n//# sourceURL=inline:%s",
rawurlencode( "{$handle}-js-extra" )
);

if ( ! $display ) {
return $output;
}
Expand Down Expand Up @@ -521,6 +526,11 @@ public function get_inline_script_data( $handle, $position = 'after' ) {
return '';
}

$data[] = sprintf(
'//# sourceURL=inline:%s',
rawurlencode( "{$handle}-js-{$position}" )
);

return trim( implode( "\n", $data ), "\n" );
}

Expand Down
5 changes: 5 additions & 0 deletions src/wp-includes/class-wp-styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,11 @@ public function print_inline_style( $handle, $display = true ) {
return false;
}

$output[] = sprintf(
'/*# sourceURL=inline:%s */',
rawurlencode( "{$handle}-inline-css" )
);

$output = implode( "\n", $output );

if ( ! $display ) {
Expand Down
1 change: 1 addition & 0 deletions tests/phpunit/tests/blocks/editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,7 @@ public function test_ensure_preload_data_script_tag_closes() {
<script src="{$baseurl}/wp-includes/js/dist/api-fetch.min.js?ver=test" id="wp-api-fetch-js"></script>
<script id="wp-api-fetch-js-after">
wp.apiFetch.use( wp.apiFetch.createPreloadingMiddleware( {"/test/v0/test-62797":{"body":["Unclosed comment and a script open tag \\u003C!--\\u003Cscript\\u003E"],"headers":{"Allow":"GET"}}} ) );
//# sourceURL=inline:wp-api-fetch-js-after
</script>

HTML;
Expand Down
Loading
Loading