You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

96 lines
2.8 KiB

  1. <?php
  2. /**
  3. * Disable error reporting
  4. *
  5. * Set this to error_reporting( -1 ) for debugging
  6. */
  7. error_reporting(0);
  8. /** Set ABSPATH for execution */
  9. if ( ! defined( 'ABSPATH' ) ) {
  10. define( 'ABSPATH', dirname( dirname( __FILE__ ) ) . '/' );
  11. }
  12. define( 'WPINC', 'wp-includes' );
  13. require( ABSPATH . 'wp-admin/includes/noop.php' );
  14. require( ABSPATH . WPINC . '/script-loader.php' );
  15. require( ABSPATH . WPINC . '/version.php' );
  16. $load = $_GET['load'];
  17. if ( is_array( $load ) ) {
  18. $load = implode( '', $load );
  19. }
  20. $load = preg_replace( '/[^a-z0-9,_-]+/i', '', $load );
  21. $load = array_unique( explode( ',', $load ) );
  22. if ( empty($load) )
  23. exit;
  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. $wp_styles = new WP_Styles();
  30. wp_default_styles($wp_styles);
  31. if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) && stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) === $wp_version ) {
  32. $protocol = $_SERVER['SERVER_PROTOCOL'];
  33. if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0' ) ) ) {
  34. $protocol = 'HTTP/1.0';
  35. }
  36. header( "$protocol 304 Not Modified" );
  37. exit();
  38. }
  39. foreach ( $load as $handle ) {
  40. if ( !array_key_exists($handle, $wp_styles->registered) )
  41. continue;
  42. $style = $wp_styles->registered[$handle];
  43. if ( empty( $style->src ) ) {
  44. continue;
  45. }
  46. $path = ABSPATH . $style->src;
  47. if ( $rtl && ! empty( $style->extra['rtl'] ) ) {
  48. // All default styles have fully independent RTL files.
  49. $path = str_replace( '.min.css', '-rtl.min.css', $path );
  50. }
  51. $content = get_file( $path ) . "\n";
  52. if ( strpos( $style->src, '/' . WPINC . '/css/' ) === 0 ) {
  53. $content = str_replace( '../images/', '../' . WPINC . '/images/', $content );
  54. $content = str_replace( '../js/tinymce/', '../' . WPINC . '/js/tinymce/', $content );
  55. $content = str_replace( '../fonts/', '../' . WPINC . '/fonts/', $content );
  56. $out .= $content;
  57. } else {
  58. $out .= str_replace( '../images/', 'images/', $content );
  59. }
  60. }
  61. header("Etag: $wp_version");
  62. header('Content-Type: text/css; charset=UTF-8');
  63. header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT');
  64. header("Cache-Control: public, max-age=$expires_offset");
  65. if ( $compress && ! ini_get('zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) {
  66. header('Vary: Accept-Encoding'); // Handle proxies
  67. if ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) {
  68. header('Content-Encoding: deflate');
  69. $out = gzdeflate( $out, 3 );
  70. } elseif ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode') ) {
  71. header('Content-Encoding: gzip');
  72. $out = gzencode( $out, 3 );
  73. }
  74. }
  75. echo $out;
  76. exit;