PageRenderTime 41ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/APP/wp-admin/load-styles.php

https://bitbucket.org/AFelipeTrujillo/goblog
PHP | 153 lines | 71 code | 33 blank | 49 comment | 23 complexity | 560660743740b51025692b08e3d8ac42 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. /**
  3. * Disable error reporting
  4. *
  5. * Set this to error_reporting( E_ALL ) or error_reporting( E_ALL | E_STRICT ) for debugging
  6. */
  7. error_reporting(0);
  8. /** Set ABSPATH for execution */
  9. define( 'ABSPATH', dirname(dirname(__FILE__)) . '/' );
  10. define( 'WPINC', 'wp-includes' );
  11. /**
  12. * @ignore
  13. */
  14. function __() {}
  15. /**
  16. * @ignore
  17. */
  18. function _x() {}
  19. /**
  20. * @ignore
  21. */
  22. function add_filter() {}
  23. /**
  24. * @ignore
  25. */
  26. function esc_attr() {}
  27. /**
  28. * @ignore
  29. */
  30. function apply_filters() {}
  31. /**
  32. * @ignore
  33. */
  34. function get_option() {}
  35. /**
  36. * @ignore
  37. */
  38. function is_lighttpd_before_150() {}
  39. /**
  40. * @ignore
  41. */
  42. function add_action() {}
  43. /**
  44. * @ignore
  45. */
  46. function do_action_ref_array() {}
  47. /**
  48. * @ignore
  49. */
  50. function get_bloginfo() {}
  51. /**
  52. * @ignore
  53. */
  54. function is_admin() {return true;}
  55. /**
  56. * @ignore
  57. */
  58. function site_url() {}
  59. /**
  60. * @ignore
  61. */
  62. function admin_url() {}
  63. /**
  64. * @ignore
  65. */
  66. function wp_guess_url() {}
  67. function get_file($path) {
  68. if ( function_exists('realpath') )
  69. $path = realpath($path);
  70. if ( ! $path || ! @is_file($path) )
  71. return '';
  72. return @file_get_contents($path);
  73. }
  74. require(ABSPATH . '/wp-includes/script-loader.php');
  75. require(ABSPATH . '/wp-includes/version.php');
  76. $load = preg_replace( '/[^a-z0-9,_-]+/i', '', $_GET['load'] );
  77. $load = array_unique( explode( ',', $load ) );
  78. if ( empty($load) )
  79. exit;
  80. $compress = ( isset($_GET['c']) && $_GET['c'] );
  81. $force_gzip = ( $compress && 'gzip' == $_GET['c'] );
  82. $rtl = ( isset($_GET['dir']) && 'rtl' == $_GET['dir'] );
  83. $expires_offset = 31536000; // 1 year
  84. $out = '';
  85. $wp_styles = new WP_Styles();
  86. wp_default_styles($wp_styles);
  87. foreach( $load as $handle ) {
  88. if ( !array_key_exists($handle, $wp_styles->registered) )
  89. continue;
  90. $style = $wp_styles->registered[$handle];
  91. $path = ABSPATH . $style->src;
  92. if ( $rtl && ! empty( $style->extra['rtl'] ) ) {
  93. // All default styles have fully independent RTL files.
  94. $path = str_replace( '.min.css', '-rtl.min.css', $path );
  95. }
  96. $content = get_file( $path ) . "\n";
  97. if ( strpos( $style->src, '/wp-includes/css/' ) === 0 ) {
  98. $content = str_replace( '../images/', '../wp-includes/images/', $content );
  99. $content = str_replace( '../js/tinymce/', '../wp-includes/js/tinymce/', $content );
  100. $content = str_replace( '../fonts/', '../wp-includes/fonts/', $content );
  101. $out .= $content;
  102. } else {
  103. $out .= str_replace( '../images/', 'images/', $content );
  104. }
  105. }
  106. header('Content-Type: text/css; charset=UTF-8');
  107. header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT');
  108. header("Cache-Control: public, max-age=$expires_offset");
  109. if ( $compress && ! ini_get('zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) {
  110. header('Vary: Accept-Encoding'); // Handle proxies
  111. if ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) {
  112. header('Content-Encoding: deflate');
  113. $out = gzdeflate( $out, 3 );
  114. } elseif ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode') ) {
  115. header('Content-Encoding: gzip');
  116. $out = gzencode( $out, 3 );
  117. }
  118. }
  119. echo $out;
  120. exit;