]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/load-styles.php
WordPress 4.3.1
[autoinstalls/wordpress.git] / wp-admin / load-styles.php
1 <?php
2
3 /**
4  * Disable error reporting
5  *
6  * Set this to error_reporting( -1 ) 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 /**
85  *
86  * @param string $path
87  * @return string
88  */
89 function get_file($path) {
90
91         if ( function_exists('realpath') )
92                 $path = realpath($path);
93
94         if ( ! $path || ! @is_file($path) )
95                 return '';
96
97         return @file_get_contents($path);
98 }
99
100 require( ABSPATH . WPINC . '/script-loader.php' );
101 require( ABSPATH . WPINC . '/version.php' );
102
103 $load = preg_replace( '/[^a-z0-9,_-]+/i', '', $_GET['load'] );
104 $load = array_unique( explode( ',', $load ) );
105
106 if ( empty($load) )
107         exit;
108
109 $compress = ( isset($_GET['c']) && $_GET['c'] );
110 $force_gzip = ( $compress && 'gzip' == $_GET['c'] );
111 $rtl = ( isset($_GET['dir']) && 'rtl' == $_GET['dir'] );
112 $expires_offset = 31536000; // 1 year
113 $out = '';
114
115 $wp_styles = new WP_Styles();
116 wp_default_styles($wp_styles);
117
118 foreach( $load as $handle ) {
119         if ( !array_key_exists($handle, $wp_styles->registered) )
120                 continue;
121
122         $style = $wp_styles->registered[$handle];
123         $path = ABSPATH . $style->src;
124
125         if ( $rtl && ! empty( $style->extra['rtl'] ) ) {
126                 // All default styles have fully independent RTL files.
127                 $path = str_replace( '.min.css', '-rtl.min.css', $path );
128         }
129
130         $content = get_file( $path ) . "\n";
131
132         if ( strpos( $style->src, '/' . WPINC . '/css/' ) === 0 ) {
133                 $content = str_replace( '../images/', '../' . WPINC . '/images/', $content );
134                 $content = str_replace( '../js/tinymce/', '../' . WPINC . '/js/tinymce/', $content );
135                 $content = str_replace( '../fonts/', '../' . WPINC . '/fonts/', $content );
136                 $out .= $content;
137         } else {
138                 $out .= str_replace( '../images/', 'images/', $content );
139         }
140 }
141
142 header('Content-Type: text/css; charset=UTF-8');
143 header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT');
144 header("Cache-Control: public, max-age=$expires_offset");
145
146 if ( $compress && ! ini_get('zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) {
147         header('Vary: Accept-Encoding'); // Handle proxies
148         if ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) {
149                 header('Content-Encoding: deflate');
150                 $out = gzdeflate( $out, 3 );
151         } elseif ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode') ) {
152                 header('Content-Encoding: gzip');
153                 $out = gzencode( $out, 3 );
154         }
155 }
156
157 echo $out;
158 exit;