wpseek.com
Outil de recherche WordPress pour les développeurs et auteurs de thèmes
_wp_normalize_relative_css_links is private and should not be used in themes or plugins directly.
_wp_normalize_relative_css_links › WordPress Function
Depuis5.9.0
Dépréciéen/a
› _wp_normalize_relative_css_links ( $css, $stylesheet_url )
Accès: |
|
Paramètres: (2) |
|
Retourne: |
|
Défini(e) dans: |
|
Codex: |
Makes URLs relative to the WordPress installation.
Fonctions en relation: wp_normalize_remote_block_pattern, wp_kses_normalize_entities, wp_normalize_path, wp_make_link_relative, wp_normalize_site_data
Source
function _wp_normalize_relative_css_links( $css, $stylesheet_url ) { return preg_replace_callback( '#(url\s*\(\s*[\'"]?\s*)([^\'"\)]+)#', static function ( $matches ) use ( $stylesheet_url ) { list( , $prefix, $url ) = $matches; // Short-circuit if the URL does not require normalization. if ( str_starts_with( $url, 'http:' ) || str_starts_with( $url, 'https:' ) || str_starts_with( $url, '//' ) || str_starts_with( $url, '#' ) || str_starts_with( $url, 'data:' ) ) { return $matches[0]; } // Build the absolute URL. $absolute_url = dirname( $stylesheet_url ) . '/' . $url; $absolute_url = str_replace( '/./', '/', $absolute_url ); // Convert to URL related to the site root. $url = wp_make_link_relative( $absolute_url ); return $prefix . $url; }, $css ); }