]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/load-styles.php
WordPress 4.4-scripts
[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 require( ABSPATH . 'wp-admin/includes/noop.php' );
15 require( ABSPATH . WPINC . '/script-loader.php' );
16 require( ABSPATH . WPINC . '/version.php' );
17
18 $load = preg_replace( '/[^a-z0-9,_-]+/i', '', $_GET['load'] );
19 $load = array_unique( explode( ',', $load ) );
20
21 if ( empty($load) )
22         exit;
23
24 $compress = ( isset($_GET['c']) && $_GET['c'] );
25 $force_gzip = ( $compress && 'gzip' == $_GET['c'] );
26 $rtl = ( isset($_GET['dir']) && 'rtl' == $_GET['dir'] );
27 $expires_offset = 31536000; // 1 year
28 $out = '';
29
30 $wp_styles = new WP_Styles();
31 wp_default_styles($wp_styles);
32
33 foreach ( $load as $handle ) {
34         if ( !array_key_exists($handle, $wp_styles->registered) )
35                 continue;
36
37         $style = $wp_styles->registered[$handle];
38         $path = ABSPATH . $style->src;
39
40         if ( $rtl && ! empty( $style->extra['rtl'] ) ) {
41                 // All default styles have fully independent RTL files.
42                 $path = str_replace( '.min.css', '-rtl.min.css', $path );
43         }
44
45         $content = get_file( $path ) . "\n";
46
47         if ( strpos( $style->src, '/' . WPINC . '/css/' ) === 0 ) {
48                 $content = str_replace( '../images/', '../' . WPINC . '/images/', $content );
49                 $content = str_replace( '../js/tinymce/', '../' . WPINC . '/js/tinymce/', $content );
50                 $content = str_replace( '../fonts/', '../' . WPINC . '/fonts/', $content );
51                 $out .= $content;
52         } else {
53                 $out .= str_replace( '../images/', 'images/', $content );
54         }
55 }
56
57 header('Content-Type: text/css; charset=UTF-8');
58 header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT');
59 header("Cache-Control: public, max-age=$expires_offset");
60
61 if ( $compress && ! ini_get('zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) {
62         header('Vary: Accept-Encoding'); // Handle proxies
63         if ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) {
64                 header('Content-Encoding: deflate');
65                 $out = gzdeflate( $out, 3 );
66         } elseif ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode') ) {
67                 header('Content-Encoding: gzip');
68                 $out = gzencode( $out, 3 );
69         }
70 }
71
72 echo $out;
73 exit;