author | ymh <ymh.work@gmail.com> |
Mon, 14 Oct 2019 17:39:30 +0200 | |
changeset 7 | cf61fcea0001 |
parent 5 | 5e2f62d02dcd |
child 9 | 177826044cd9 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
||
3 |
/** |
|
4 |
* Disable error reporting |
|
5 |
* |
|
5 | 6 |
* Set this to error_reporting( -1 ) for debugging. |
0 | 7 |
*/ |
8 |
error_reporting(0); |
|
9 |
||
10 |
/** Set ABSPATH for execution */ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
11 |
if ( ! defined( 'ABSPATH' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
12 |
define( 'ABSPATH', dirname( dirname( __FILE__ ) ) . '/' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
13 |
} |
0 | 14 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
15 |
define( 'WPINC', 'wp-includes' ); |
0 | 16 |
|
17 |
$load = $_GET['load']; |
|
18 |
if ( is_array( $load ) ) |
|
19 |
$load = implode( '', $load ); |
|
20 |
||
21 |
$load = preg_replace( '/[^a-z0-9,_-]+/i', '', $load ); |
|
22 |
$load = array_unique( explode( ',', $load ) ); |
|
23 |
||
24 |
if ( empty($load) ) |
|
25 |
exit; |
|
26 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
27 |
require( ABSPATH . 'wp-admin/includes/noop.php' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
28 |
require( ABSPATH . WPINC . '/script-loader.php' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
29 |
require( ABSPATH . WPINC . '/version.php' ); |
0 | 30 |
|
31 |
$compress = ( isset($_GET['c']) && $_GET['c'] ); |
|
32 |
$force_gzip = ( $compress && 'gzip' == $_GET['c'] ); |
|
33 |
$expires_offset = 31536000; // 1 year |
|
34 |
$out = ''; |
|
35 |
||
36 |
$wp_scripts = new WP_Scripts(); |
|
37 |
wp_default_scripts($wp_scripts); |
|
38 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
39 |
if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) && stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) === $wp_version ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
40 |
$protocol = $_SERVER['SERVER_PROTOCOL']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
41 |
if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0' ) ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
42 |
$protocol = 'HTTP/1.0'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
43 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
44 |
header( "$protocol 304 Not Modified" ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
45 |
exit(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
46 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
47 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
48 |
foreach ( $load as $handle ) { |
0 | 49 |
if ( !array_key_exists($handle, $wp_scripts->registered) ) |
50 |
continue; |
|
51 |
||
52 |
$path = ABSPATH . $wp_scripts->registered[$handle]->src; |
|
53 |
$out .= get_file($path) . "\n"; |
|
54 |
} |
|
55 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
56 |
header("Etag: $wp_version"); |
5 | 57 |
header('Content-Type: application/javascript; charset=UTF-8'); |
0 | 58 |
header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT'); |
59 |
header("Cache-Control: public, max-age=$expires_offset"); |
|
60 |
||
61 |
if ( $compress && ! ini_get('zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) { |
|
62 |
header('Vary: Accept-Encoding'); // Handle proxies |
|
63 |
if ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) { |
|
64 |
header('Content-Encoding: deflate'); |
|
65 |
$out = gzdeflate( $out, 3 ); |
|
66 |
} elseif ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode') ) { |
|
67 |
header('Content-Encoding: gzip'); |
|
68 |
$out = gzencode( $out, 3 ); |
|
69 |
} |
|
70 |
} |
|
71 |
||
72 |
echo $out; |
|
73 |
exit; |