3 /** |
3 /** |
4 * Disable error reporting |
4 * Disable error reporting |
5 * |
5 * |
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 if ( ! defined( 'ABSPATH' ) ) { |
11 if ( ! defined( 'ABSPATH' ) ) { |
12 define( 'ABSPATH', dirname( dirname( __FILE__ ) ) . '/' ); |
12 define( 'ABSPATH', dirname( dirname( __FILE__ ) ) . '/' ); |
13 } |
13 } |
23 $load = implode( '', $load ); |
23 $load = implode( '', $load ); |
24 } |
24 } |
25 $load = preg_replace( '/[^a-z0-9,_-]+/i', '', $load ); |
25 $load = preg_replace( '/[^a-z0-9,_-]+/i', '', $load ); |
26 $load = array_unique( explode( ',', $load ) ); |
26 $load = array_unique( explode( ',', $load ) ); |
27 |
27 |
28 if ( empty($load) ) |
28 if ( empty( $load ) ) { |
29 exit; |
29 exit; |
|
30 } |
30 |
31 |
31 $compress = ( isset($_GET['c']) && $_GET['c'] ); |
32 $rtl = ( isset( $_GET['dir'] ) && 'rtl' == $_GET['dir'] ); |
32 $force_gzip = ( $compress && 'gzip' == $_GET['c'] ); |
|
33 $rtl = ( isset($_GET['dir']) && 'rtl' == $_GET['dir'] ); |
|
34 $expires_offset = 31536000; // 1 year |
33 $expires_offset = 31536000; // 1 year |
35 $out = ''; |
34 $out = ''; |
36 |
35 |
37 $wp_styles = new WP_Styles(); |
36 $wp_styles = new WP_Styles(); |
38 wp_default_styles($wp_styles); |
37 wp_default_styles( $wp_styles ); |
39 |
38 |
40 if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) && stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) === $wp_version ) { |
39 if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) && stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) === $wp_version ) { |
41 $protocol = $_SERVER['SERVER_PROTOCOL']; |
40 $protocol = $_SERVER['SERVER_PROTOCOL']; |
42 if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0' ) ) ) { |
41 if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0' ) ) ) { |
43 $protocol = 'HTTP/1.0'; |
42 $protocol = 'HTTP/1.0'; |
45 header( "$protocol 304 Not Modified" ); |
44 header( "$protocol 304 Not Modified" ); |
46 exit(); |
45 exit(); |
47 } |
46 } |
48 |
47 |
49 foreach ( $load as $handle ) { |
48 foreach ( $load as $handle ) { |
50 if ( !array_key_exists($handle, $wp_styles->registered) ) |
49 if ( ! array_key_exists( $handle, $wp_styles->registered ) ) { |
51 continue; |
50 continue; |
|
51 } |
52 |
52 |
53 $style = $wp_styles->registered[$handle]; |
53 $style = $wp_styles->registered[ $handle ]; |
54 |
54 |
55 if ( empty( $style->src ) ) { |
55 if ( empty( $style->src ) ) { |
56 continue; |
56 continue; |
57 } |
57 } |
58 |
58 |
67 |
67 |
68 if ( strpos( $style->src, '/' . WPINC . '/css/' ) === 0 ) { |
68 if ( strpos( $style->src, '/' . WPINC . '/css/' ) === 0 ) { |
69 $content = str_replace( '../images/', '../' . WPINC . '/images/', $content ); |
69 $content = str_replace( '../images/', '../' . WPINC . '/images/', $content ); |
70 $content = str_replace( '../js/tinymce/', '../' . WPINC . '/js/tinymce/', $content ); |
70 $content = str_replace( '../js/tinymce/', '../' . WPINC . '/js/tinymce/', $content ); |
71 $content = str_replace( '../fonts/', '../' . WPINC . '/fonts/', $content ); |
71 $content = str_replace( '../fonts/', '../' . WPINC . '/fonts/', $content ); |
72 $out .= $content; |
72 $out .= $content; |
73 } else { |
73 } else { |
74 $out .= str_replace( '../images/', 'images/', $content ); |
74 $out .= str_replace( '../images/', 'images/', $content ); |
75 } |
75 } |
76 } |
76 } |
77 |
77 |
78 header("Etag: $wp_version"); |
78 header( "Etag: $wp_version" ); |
79 header('Content-Type: text/css; charset=UTF-8'); |
79 header( 'Content-Type: text/css; charset=UTF-8' ); |
80 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' ); |
81 header("Cache-Control: public, max-age=$expires_offset"); |
81 header( "Cache-Control: public, max-age=$expires_offset" ); |
82 |
|
83 if ( $compress && ! ini_get('zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) { |
|
84 header('Vary: Accept-Encoding'); // Handle proxies |
|
85 if ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) { |
|
86 header('Content-Encoding: deflate'); |
|
87 $out = gzdeflate( $out, 3 ); |
|
88 } elseif ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode') ) { |
|
89 header('Content-Encoding: gzip'); |
|
90 $out = gzencode( $out, 3 ); |
|
91 } |
|
92 } |
|
93 |
82 |
94 echo $out; |
83 echo $out; |
95 exit; |
84 exit; |