[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-admin/ -> load-scripts.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( __DIR__ ) . '/' );
  13  }
  14  
  15  define( 'WPINC', 'wp-includes' );
  16  
  17  $protocol = $_SERVER['SERVER_PROTOCOL'];
  18  if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0', 'HTTP/3' ), true ) ) {
  19      $protocol = 'HTTP/1.0';
  20  }
  21  
  22  $load = $_GET['load'];
  23  if ( is_array( $load ) ) {
  24      ksort( $load );
  25      $load = implode( '', $load );
  26  }
  27  
  28  $load = preg_replace( '/[^a-z0-9,_-]+/i', '', $load );
  29  $load = array_unique( explode( ',', $load ) );
  30  
  31  if ( empty( $load ) ) {
  32      header( "$protocol 400 Bad Request" );
  33      exit;
  34  }
  35  
  36  require ABSPATH . 'wp-admin/includes/noop.php';
  37  require ABSPATH . WPINC . '/script-loader.php';
  38  require  ABSPATH . WPINC . '/version.php';
  39  
  40  $expires_offset = 31536000; // 1 year.
  41  $out            = '';
  42  
  43  $wp_scripts = new WP_Scripts();
  44  wp_default_scripts( $wp_scripts );
  45  wp_default_packages_vendor( $wp_scripts );
  46  wp_default_packages_scripts( $wp_scripts );
  47  
  48  if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) && stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) === $wp_version ) {
  49      header( "$protocol 304 Not Modified" );
  50      exit;
  51  }
  52  
  53  foreach ( $load as $handle ) {
  54      if ( ! array_key_exists( $handle, $wp_scripts->registered ) ) {
  55          continue;
  56      }
  57  
  58      $path = ABSPATH . $wp_scripts->registered[ $handle ]->src;
  59      $out .= get_file( $path ) . "\n";
  60  }
  61  
  62  header( "Etag: $wp_version" );
  63  header( 'Content-Type: application/javascript; charset=UTF-8' );
  64  header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + $expires_offset ) . ' GMT' );
  65  header( "Cache-Control: public, max-age=$expires_offset" );
  66  
  67  echo $out;
  68  exit;


Generated: Thu Nov 21 01:00:03 2024 Cross-referenced by PHPXref 0.7.1