author | Anthony Ly <anthonyly.com@gmail.com> |
Mon, 19 Nov 2012 18:26:13 +0100 | |
changeset 194 | 32102edaa81b |
parent 136 | bde1974c263b |
child 204 | 09a1c134465b |
permissions | -rw-r--r-- |
136 | 1 |
<?php |
2 |
||
3 |
/** |
|
4 |
* Disable error reporting |
|
5 |
* |
|
6 |
* Set this to error_reporting( E_ALL ) or error_reporting( E_ALL | E_STRICT ) for debugging |
|
7 |
*/ |
|
8 |
error_reporting(0); |
|
9 |
||
10 |
/** Set ABSPATH for execution */ |
|
11 |
define( 'ABSPATH', dirname(dirname(__FILE__)) . '/' ); |
|
12 |
define( 'WPINC', 'wp-includes' ); |
|
13 |
||
14 |
/** |
|
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 . '/wp-includes/script-loader.php'); |
|
96 |
require(ABSPATH . '/wp-includes/version.php'); |
|
97 |
||
98 |
$load = preg_replace( '/[^a-z0-9,_-]+/i', '', $_GET['load'] ); |
|
99 |
$load = explode(',', $load); |
|
100 |
||
101 |
if ( empty($load) ) |
|
102 |
exit; |
|
103 |
||
104 |
$compress = ( isset($_GET['c']) && $_GET['c'] ); |
|
105 |
$force_gzip = ( $compress && 'gzip' == $_GET['c'] ); |
|
106 |
$rtl = ( isset($_GET['dir']) && 'rtl' == $_GET['dir'] ); |
|
107 |
$expires_offset = 31536000; |
|
108 |
$out = ''; |
|
109 |
||
110 |
$wp_styles = new WP_Styles(); |
|
111 |
wp_default_styles($wp_styles); |
|
112 |
||
113 |
foreach( $load as $handle ) { |
|
114 |
if ( !array_key_exists($handle, $wp_styles->registered) ) |
|
115 |
continue; |
|
116 |
||
117 |
$style = $wp_styles->registered[$handle]; |
|
118 |
$path = ABSPATH . $style->src; |
|
119 |
||
120 |
$content = get_file($path) . "\n"; |
|
121 |
||
122 |
if ( $rtl && isset($style->extra['rtl']) && $style->extra['rtl'] ) { |
|
123 |
$rtl_path = is_bool($style->extra['rtl']) ? str_replace( '.css', '-rtl.css', $path ) : ABSPATH . $style->extra['rtl']; |
|
124 |
$content .= get_file($rtl_path) . "\n"; |
|
125 |
} |
|
126 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
127 |
if ( strpos( $style->src, '/wp-includes/css/' ) === 0 ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
128 |
$content = str_replace( '../images/', '../wp-includes/images/', $content ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
129 |
$out .= str_replace( '../js/tinymce/', '../wp-includes/js/tinymce/', $content ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
130 |
} else { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
131 |
$out .= str_replace( '../images/', 'images/', $content ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
132 |
} |
136 | 133 |
} |
134 |
||
135 |
header('Content-Type: text/css'); |
|
136 |
header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT'); |
|
137 |
header("Cache-Control: public, max-age=$expires_offset"); |
|
138 |
||
139 |
if ( $compress && ! ini_get('zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) { |
|
140 |
header('Vary: Accept-Encoding'); // Handle proxies |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
141 |
if ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) { |
136 | 142 |
header('Content-Encoding: deflate'); |
143 |
$out = gzdeflate( $out, 3 ); |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
144 |
} elseif ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode') ) { |
136 | 145 |
header('Content-Encoding: gzip'); |
146 |
$out = gzencode( $out, 3 ); |
|
147 |
} |
|
148 |
} |
|
149 |
||
150 |
echo $out; |
|
151 |
exit; |