CARVIEW |
Select Language
HTTP/2 200
server: nginx
date: Sat, 11 Oct 2025 00:52:13 GMT
content-type: text/html;charset=utf-8
vary: Accept-Encoding
etag: W/"anonymous/Fri, 10 Oct 2025 04:17:22 GMT/e5f3d3a22ca55847ebff437f78553f98"
cache-control: must-revalidate
alt-svc: h3=":443"; ma=86400
x-nc: MISS
content-encoding: gzip
Changeset 60920 for trunk/src – WordPress Trac
- Timestamp:
- 10/10/2025 04:17:22 AM (21 hours ago)
- Author:
- westonruter
- Message:
-
Script Loader: Use original stylesheet URL for
sourceURL
when inlined.
For inline styles which had been inlined from registered external stylesheets via
wp_maybe_inline_styles()
, this defers to using the original stylesheet URL for thesourceURL
as opposed to fabricating one from the stylesheet handle. This makes thesourceURL
much more useful for debugging, as it indicates where the stylesheet is located. This allows a developer to make a change to the CSS more easily.
Developed in https://github.com/WordPress/wordpress-develop/pull/10177.
Follow-up to [50836].
Props westonruter, mukesh27, gziolo.
See #50328, #52620.
Fixes #63887.
- Location:
- trunk/src/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-styles.php
r60719 r60920 334 334 $output = $this->get_data( $handle, 'after' ); 335 335 336 if ( empty( $output ) ) {336 if ( empty( $output ) || ! is_array( $output ) ) { 337 337 return false; 338 338 } 339 339 340 340 if ( ! $this->do_concat ) { 341 342 // Obtain the original `src` for a stylesheet possibly inlined by wp_maybe_inline_styles(). 343 $inlined_src = $this->get_data( $handle, 'inlined_src' ); 344 345 // If there's only one `after` inline style, and that inline style had been inlined, then use the $inlined_src 346 // as the sourceURL. Otherwise, if there is more than one inline `after` style associated with the handle, 347 // then resort to using the handle to construct the sourceURL since there isn't a single source. 348 if ( count( $output ) === 1 && is_string( $inlined_src ) && strlen( $inlined_src ) > 0 ) { 349 $source_url = esc_url_raw( $inlined_src ); 350 } else { 351 $source_url = rawurlencode( "{$handle}-inline-css" ); 352 } 353 341 354 $output[] = sprintf( 342 355 '/*# sourceURL=%s */', 343 rawurlencode( "{$handle}-inline-css" )356 $source_url 344 357 ); 345 358 } -
trunk/src/wp-includes/script-loader.php
r60719 r60920 3117 3117 $style['css'] = _wp_normalize_relative_css_links( $style['css'], $style['src'] ); 3118 3118 3119 // Keep track of the original `src` for the style that was inlined so that the `sourceURL` comment can be added. 3120 $wp_styles->add_data( $style['handle'], 'inlined_src', $style['src'] ); 3121 3119 3122 // Set `src` to `false` and add styles inline. 3120 3123 $wp_styles->registered[ $style['handle'] ]->src = false;
Note: See TracChangeset
for help on using the changeset viewer.