]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/load-scripts.php
WordPress 4.4
[autoinstalls/wordpress.git] / wp-admin / load-scripts.php
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 define( 'ABSPATH', dirname(dirname(__FILE__)) . '/' );
12 define( 'WPINC', 'wp-includes' );
13
14 $load = $_GET['load'];
15 if ( is_array( $load ) )
16         $load = implode( '', $load );
17
18 $load = preg_replace( '/[^a-z0-9,_-]+/i', '', $load );
19 $load = array_unique( explode( ',', $load ) );
20
21 if ( empty($load) )
22         exit;
23
24 require( ABSPATH . 'wp-admin/includes/noop.php' );
25 require( ABSPATH . WPINC . '/script-loader.php' );
26 require( ABSPATH . WPINC . '/version.php' );
27
28 $compress = ( isset($_GET['c']) && $_GET['c'] );
29 $force_gzip = ( $compress && 'gzip' == $_GET['c'] );
30 $expires_offset = 31536000; // 1 year
31 $out = '';
32
33 $wp_scripts = new WP_Scripts();
34 wp_default_scripts($wp_scripts);
35
36 foreach ( $load as $handle ) {
37         if ( !array_key_exists($handle, $wp_scripts->registered) )
38                 continue;
39
40         $path = ABSPATH . $wp_scripts->registered[$handle]->src;
41         $out .= get_file($path) . "\n";
42 }
43
44 header('Content-Type: application/javascript; charset=UTF-8');
45 header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT');
46 header("Cache-Control: public, max-age=$expires_offset");
47
48 if ( $compress && ! ini_get('zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) {
49         header('Vary: Accept-Encoding'); // Handle proxies
50         if ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) {
51                 header('Content-Encoding: deflate');
52                 $out = gzdeflate( $out, 3 );
53         } elseif ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode') ) {
54                 header('Content-Encoding: gzip');
55                 $out = gzencode( $out, 3 );
56         }
57 }
58
59 echo $out;
60 exit;