author | ymh <ymh.work@gmail.com> |
Tue, 22 Oct 2019 16:11:46 +0200 | |
changeset 15 | 3d4e9c994f10 |
parent 9 | 177826044cd9 |
child 16 | a86126ab1dd4 |
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 |
*/ |
9 | 8 |
error_reporting( 0 ); |
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']; |
|
9 | 18 |
if ( is_array( $load ) ) { |
0 | 19 |
$load = implode( '', $load ); |
9 | 20 |
} |
0 | 21 |
|
22 |
$load = preg_replace( '/[^a-z0-9,_-]+/i', '', $load ); |
|
23 |
$load = array_unique( explode( ',', $load ) ); |
|
24 |
||
9 | 25 |
if ( empty( $load ) ) { |
0 | 26 |
exit; |
9 | 27 |
} |
0 | 28 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
29 |
require( ABSPATH . 'wp-admin/includes/noop.php' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
30 |
require( ABSPATH . WPINC . '/script-loader.php' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
31 |
require( ABSPATH . WPINC . '/version.php' ); |
0 | 32 |
|
33 |
$expires_offset = 31536000; // 1 year |
|
9 | 34 |
$out = ''; |
0 | 35 |
|
36 |
$wp_scripts = new WP_Scripts(); |
|
9 | 37 |
wp_default_scripts( $wp_scripts ); |
38 |
wp_default_packages_vendor( $wp_scripts ); |
|
39 |
wp_default_packages_scripts( $wp_scripts ); |
|
0 | 40 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
41 |
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
|
42 |
$protocol = $_SERVER['SERVER_PROTOCOL']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
43 |
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
|
44 |
$protocol = 'HTTP/1.0'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
45 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
46 |
header( "$protocol 304 Not Modified" ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
47 |
exit(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
48 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
49 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
50 |
foreach ( $load as $handle ) { |
9 | 51 |
if ( ! array_key_exists( $handle, $wp_scripts->registered ) ) { |
0 | 52 |
continue; |
9 | 53 |
} |
0 | 54 |
|
9 | 55 |
$path = ABSPATH . $wp_scripts->registered[ $handle ]->src; |
56 |
$out .= get_file( $path ) . "\n"; |
|
0 | 57 |
} |
58 |
||
9 | 59 |
header( "Etag: $wp_version" ); |
60 |
header( 'Content-Type: application/javascript; charset=UTF-8' ); |
|
61 |
header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + $expires_offset ) . ' GMT' ); |
|
62 |
header( "Cache-Control: public, max-age=$expires_offset" ); |
|
0 | 63 |
|
64 |
echo $out; |
|
65 |
exit; |