wp/wp-admin/load-styles.php
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
child 22 8c2e4d02f4ef
equal deleted inserted replaced
20:7b1b88e27a20 21:48c4eec2b7e6
    46 $out            = '';
    46 $out            = '';
    47 
    47 
    48 $wp_styles = new WP_Styles();
    48 $wp_styles = new WP_Styles();
    49 wp_default_styles( $wp_styles );
    49 wp_default_styles( $wp_styles );
    50 
    50 
    51 if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) && stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) === $wp_version ) {
    51 $etag = "WP:{$wp_version};";
       
    52 
       
    53 foreach ( $load as $handle ) {
       
    54 	if ( ! array_key_exists( $handle, $wp_styles->registered ) ) {
       
    55 		continue;
       
    56 	}
       
    57 
       
    58 	$ver   = $wp_styles->registered[ $handle ]->ver ? $wp_styles->registered[ $handle ]->ver : $wp_version;
       
    59 	$etag .= "{$handle}:{$ver};";
       
    60 }
       
    61 
       
    62 /*
       
    63  * This is not intended to be cryptographically secure, just a fast way to get
       
    64  * a fixed length string based on the script versions. As this file does not
       
    65  * load the full WordPress environment, it is not possible to use the salted
       
    66  * wp_hash() function.
       
    67  */
       
    68 $etag = 'W/"' . md5( $etag ) . '"';
       
    69 
       
    70 if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) && stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) === $etag ) {
    52 	header( "$protocol 304 Not Modified" );
    71 	header( "$protocol 304 Not Modified" );
    53 	exit;
    72 	exit;
    54 }
    73 }
    55 
    74 
    56 foreach ( $load as $handle ) {
    75 foreach ( $load as $handle ) {
    71 		$path = str_replace( '.min.css', '-rtl.min.css', $path );
    90 		$path = str_replace( '.min.css', '-rtl.min.css', $path );
    72 	}
    91 	}
    73 
    92 
    74 	$content = get_file( $path ) . "\n";
    93 	$content = get_file( $path ) . "\n";
    75 
    94 
    76 	if ( strpos( $style->src, '/' . WPINC . '/css/' ) === 0 ) {
    95 	// Note: str_starts_with() is not used here, as wp-includes/compat.php is not loaded in this file.
       
    96 	if ( 0 === strpos( $style->src, '/' . WPINC . '/css/' ) ) {
    77 		$content = str_replace( '../images/', '../' . WPINC . '/images/', $content );
    97 		$content = str_replace( '../images/', '../' . WPINC . '/images/', $content );
    78 		$content = str_replace( '../js/tinymce/', '../' . WPINC . '/js/tinymce/', $content );
    98 		$content = str_replace( '../js/tinymce/', '../' . WPINC . '/js/tinymce/', $content );
    79 		$content = str_replace( '../fonts/', '../' . WPINC . '/fonts/', $content );
    99 		$content = str_replace( '../fonts/', '../' . WPINC . '/fonts/', $content );
    80 		$out    .= $content;
   100 		$out    .= $content;
    81 	} else {
   101 	} else {
    82 		$out .= str_replace( '../images/', 'images/', $content );
   102 		$out .= str_replace( '../images/', 'images/', $content );
    83 	}
   103 	}
    84 }
   104 }
    85 
   105 
    86 header( "Etag: $wp_version" );
   106 header( "Etag: $etag" );
    87 header( 'Content-Type: text/css; charset=UTF-8' );
   107 header( 'Content-Type: text/css; charset=UTF-8' );
    88 header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + $expires_offset ) . ' GMT' );
   108 header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + $expires_offset ) . ' GMT' );
    89 header( "Cache-Control: public, max-age=$expires_offset" );
   109 header( "Cache-Control: public, max-age=$expires_offset" );
    90 
   110 
    91 echo $out;
   111 echo $out;