[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

title

Body

[close]

/wp-admin/ -> load-styles.php (source)

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


Generated: Sat Nov 23 20:47:33 2019 Cross-referenced by PHPXref 0.7