wp/wp-admin/load-styles.php
changeset 7 cf61fcea0001
parent 5 5e2f62d02dcd
child 9 177826044cd9
equal deleted inserted replaced
6:490d5cc509ed 7:cf61fcea0001
     6  * Set this to error_reporting( -1 ) for debugging
     6  * Set this to error_reporting( -1 ) for debugging
     7  */
     7  */
     8 error_reporting(0);
     8 error_reporting(0);
     9 
     9 
    10 /** Set ABSPATH for execution */
    10 /** Set ABSPATH for execution */
    11 define( 'ABSPATH', dirname(dirname(__FILE__)) . '/' );
    11 if ( ! defined( 'ABSPATH' ) ) {
       
    12 	define( 'ABSPATH', dirname( dirname( __FILE__ ) ) . '/' );
       
    13 }
       
    14 
    12 define( 'WPINC', 'wp-includes' );
    15 define( 'WPINC', 'wp-includes' );
    13 
    16 
    14 /**
    17 require( ABSPATH . 'wp-admin/includes/noop.php' );
    15  * @ignore
       
    16  */
       
    17 function __() {}
       
    18 
       
    19 /**
       
    20  * @ignore
       
    21  */
       
    22 function _x() {}
       
    23 
       
    24 /**
       
    25  * @ignore
       
    26  */
       
    27 function add_filter() {}
       
    28 
       
    29 /**
       
    30  * @ignore
       
    31  */
       
    32 function esc_attr() {}
       
    33 
       
    34 /**
       
    35  * @ignore
       
    36  */
       
    37 function apply_filters() {}
       
    38 
       
    39 /**
       
    40  * @ignore
       
    41  */
       
    42 function get_option() {}
       
    43 
       
    44 /**
       
    45  * @ignore
       
    46  */
       
    47 function is_lighttpd_before_150() {}
       
    48 
       
    49 /**
       
    50  * @ignore
       
    51  */
       
    52 function add_action() {}
       
    53 
       
    54 /**
       
    55  * @ignore
       
    56  */
       
    57 function do_action_ref_array() {}
       
    58 
       
    59 /**
       
    60  * @ignore
       
    61  */
       
    62 function get_bloginfo() {}
       
    63 
       
    64 /**
       
    65  * @ignore
       
    66  */
       
    67 function is_admin() {return true;}
       
    68 
       
    69 /**
       
    70  * @ignore
       
    71  */
       
    72 function site_url() {}
       
    73 
       
    74 /**
       
    75  * @ignore
       
    76  */
       
    77 function admin_url() {}
       
    78 
       
    79 /**
       
    80  * @ignore
       
    81  */
       
    82 function wp_guess_url() {}
       
    83 
       
    84 function get_file($path) {
       
    85 
       
    86 	if ( function_exists('realpath') )
       
    87 		$path = realpath($path);
       
    88 
       
    89 	if ( ! $path || ! @is_file($path) )
       
    90 		return '';
       
    91 
       
    92 	return @file_get_contents($path);
       
    93 }
       
    94 
       
    95 require( ABSPATH . WPINC . '/script-loader.php' );
    18 require( ABSPATH . WPINC . '/script-loader.php' );
    96 require( ABSPATH . WPINC . '/version.php' );
    19 require( ABSPATH . WPINC . '/version.php' );
    97 
    20 
    98 $load = preg_replace( '/[^a-z0-9,_-]+/i', '', $_GET['load'] );
    21 $load = $_GET['load'];
       
    22 if ( is_array( $load ) ) {
       
    23 	$load = implode( '', $load );
       
    24 }
       
    25 $load = preg_replace( '/[^a-z0-9,_-]+/i', '', $load );
    99 $load = array_unique( explode( ',', $load ) );
    26 $load = array_unique( explode( ',', $load ) );
   100 
    27 
   101 if ( empty($load) )
    28 if ( empty($load) )
   102 	exit;
    29 	exit;
   103 
    30 
   108 $out = '';
    35 $out = '';
   109 
    36 
   110 $wp_styles = new WP_Styles();
    37 $wp_styles = new WP_Styles();
   111 wp_default_styles($wp_styles);
    38 wp_default_styles($wp_styles);
   112 
    39 
   113 foreach( $load as $handle ) {
    40 if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) && stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) === $wp_version ) {
       
    41 	$protocol = $_SERVER['SERVER_PROTOCOL'];
       
    42 	if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0' ) ) ) {
       
    43 		$protocol = 'HTTP/1.0';
       
    44 	}
       
    45 	header( "$protocol 304 Not Modified" );
       
    46 	exit();
       
    47 }
       
    48 
       
    49 foreach ( $load as $handle ) {
   114 	if ( !array_key_exists($handle, $wp_styles->registered) )
    50 	if ( !array_key_exists($handle, $wp_styles->registered) )
   115 		continue;
    51 		continue;
   116 
    52 
   117 	$style = $wp_styles->registered[$handle];
    53 	$style = $wp_styles->registered[$handle];
       
    54 
       
    55 	if ( empty( $style->src ) ) {
       
    56 		continue;
       
    57 	}
       
    58 
   118 	$path = ABSPATH . $style->src;
    59 	$path = ABSPATH . $style->src;
   119 
    60 
   120 	if ( $rtl && ! empty( $style->extra['rtl'] ) ) {
    61 	if ( $rtl && ! empty( $style->extra['rtl'] ) ) {
   121 		// All default styles have fully independent RTL files.
    62 		// All default styles have fully independent RTL files.
   122 		$path = str_replace( '.min.css', '-rtl.min.css', $path );
    63 		$path = str_replace( '.min.css', '-rtl.min.css', $path );
   132 	} else {
    73 	} else {
   133 		$out .= str_replace( '../images/', 'images/', $content );
    74 		$out .= str_replace( '../images/', 'images/', $content );
   134 	}
    75 	}
   135 }
    76 }
   136 
    77 
       
    78 header("Etag: $wp_version");
   137 header('Content-Type: text/css; charset=UTF-8');
    79 header('Content-Type: text/css; charset=UTF-8');
   138 header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT');
    80 header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT');
   139 header("Cache-Control: public, max-age=$expires_offset");
    81 header("Cache-Control: public, max-age=$expires_offset");
   140 
    82 
   141 if ( $compress && ! ini_get('zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) {
    83 if ( $compress && ! ini_get('zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) {