Make WordPress Core

Changeset 55669


Ignore:
Timestamp:
04/21/2023 03:11:46 AM (3 years ago)
Author:
azaozz
Message:

Script Loader: Improve code style and readability in _wp_normalize_relative_css_links().

Props: westonruter.
See: 58069.

Location:
trunk
Files:
2 edited

Legend:

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

    r55658 r55669  
    29452945                        list( , $prefix, $url ) = $matches;
    29462946
    2947                         if ( ! (
    2948                                 str_starts_with( $url, 'http:' )
    2949                                 ||
    2950                                 str_starts_with( $url, 'https:' )
    2951                                 ||
    2952                                 str_starts_with( $url, '//' )
    2953                                 ||
    2954                                 str_starts_with( $url, '#' )
    2955                                 ||
     2947                        // Short-circuit if the URL does not require normalization.
     2948                        if (
     2949                                str_starts_with( $url, 'http:' ) ||
     2950                                str_starts_with( $url, 'https:' ) ||
     2951                                str_starts_with( $url, '//' ) ||
     2952                                str_starts_with( $url, '#' ) ||
    29562953                                str_starts_with( $url, 'data:' )
    2957                         ) ) {
    2958                                 // Build the absolute URL.
    2959                                 $absolute_url = dirname( $stylesheet_url ) . '/' . $url;
    2960                                 $absolute_url = str_replace( '/./', '/', $absolute_url );
    2961 
    2962                                 // Convert to URL related to the site root.
    2963                                 $url = wp_make_link_relative( $absolute_url );
     2954                        ) {
     2955                                return $matches[0];
    29642956                        }
     2957
     2958                        // Build the absolute URL.
     2959                        $absolute_url = dirname( $stylesheet_url ) . '/' . $url;
     2960                        $absolute_url = str_replace( '/./', '/', $absolute_url );
     2961
     2962                        // Convert to URL related to the site root.
     2963                        $url = wp_make_link_relative( $absolute_url );
    29652964
    29662965                        return $prefix . $url;
  • trunk/tests/phpunit/tests/dependencies/styles.php

    r55658 r55669  
    197197         * @ticket 54243
    198198         * @ticket 54922
     199         * @ticket 58069
    199200         *
    200201         * @covers ::_wp_normalize_relative_css_links
Note: See TracChangeset for help on using the changeset viewer.