| 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 | if ( ! defined( 'ABSPATH' ) ) { |
|---|
| 12 | define( 'ABSPATH', dirname( dirname( __FILE__ ) ) . '/' ); |
|---|
| 13 | } |
|---|
| 14 | |
|---|
| 15 | define( 'WPINC', 'wp-includes' ); |
|---|
| 16 | |
|---|
| 17 | require( ABSPATH . 'wp-admin/includes/noop.php' ); |
|---|
| 18 | require( ABSPATH . WPINC . '/script-loader.php' ); |
|---|
| 19 | require( ABSPATH . WPINC . '/version.php' ); |
|---|
| 20 | |
|---|
| 21 | $load = $_GET['load']; |
|---|
| 22 | if ( is_array( $load ) ) { |
|---|
| 23 | $load = implode( '', $load ); |
|---|
| 24 | } |
|---|
| 25 | $load = preg_replace( '/[^a-z0-9,_-]+/i', '', $load ); |
|---|
| 26 | $load = array_unique( explode( ',', $load ) ); |
|---|
| 27 | |
|---|
| 28 | if ( empty( $load ) ) { |
|---|
| 29 | exit; |
|---|
| 30 | } |
|---|
| 31 | |
|---|
| 32 | $rtl = ( isset( $_GET['dir'] ) && 'rtl' == $_GET['dir'] ); |
|---|
| 33 | $expires_offset = 31536000; // 1 year |
|---|
| 34 | $out = ''; |
|---|
| 35 | |
|---|
| 36 | $wp_styles = new WP_Styles(); |
|---|
| 37 | wp_default_styles( $wp_styles ); |
|---|
| 38 | |
|---|
| 39 | if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) && stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) === $wp_version ) { |
|---|
| 40 | $protocol = $_SERVER['SERVER_PROTOCOL']; |
|---|
| 41 | if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0' ) ) ) { |
|---|
| 42 | $protocol = 'HTTP/1.0'; |
|---|
| 43 | } |
|---|
| 44 | header( "$protocol 304 Not Modified" ); |
|---|
| 45 | exit(); |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | header( "Etag: $wp_version" ); |
|---|
| 49 | header( 'Content-Type: text/css; charset=UTF-8' ); |
|---|
| 50 | header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + $expires_offset ) . ' GMT' ); |
|---|
| 51 | header( "Cache-Control: public, max-age=$expires_offset" ); |
|---|
| 52 | |
|---|
| 53 | foreach ( $load as $handle ) { |
|---|
| 54 | if ( ! array_key_exists( $handle, $wp_styles->registered ) ) { |
|---|
| 55 | continue; |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | $style = $wp_styles->registered[ $handle ]; |
|---|
| 59 | |
|---|
| 60 | if ( empty( $style->src ) ) { |
|---|
| 61 | continue; |
|---|
| 62 | } |
|---|
| 63 | |
|---|
| 64 | $path = ABSPATH . $style->src; |
|---|
| 65 | |
|---|
| 66 | if ( $rtl && ! empty( $style->extra['rtl'] ) ) { |
|---|
| 67 | // All default styles have fully independent RTL files. |
|---|
| 68 | $path = str_replace( '.min.css', '-rtl.min.css', $path ); |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | $content = get_file( $path ) . "\r\n"; |
|---|
| 72 | |
|---|
| 73 | if ( strpos( $style->src, '/' . WPINC . '/css/' ) === 0 ) { |
|---|
| 74 | $content = str_replace( '../images/', '../' . WPINC . '/images/', $content ); |
|---|
| 75 | $content = str_replace( '../js/tinymce/', '../' . WPINC . '/js/tinymce/', $content ); |
|---|
| 76 | $content = str_replace( '../fonts/', '../' . WPINC . '/fonts/', $content ); |
|---|
| 77 | echo $content; |
|---|
| 78 | } else { |
|---|
| 79 | echo str_replace( '../images/', 'images/', $content ); |
|---|
| 80 | } |
|---|
| 81 | } |
|---|
| 82 | |
|---|
| 83 | exit; |
|---|