author | ymh <ymh.work@gmail.com> |
Thu, 29 Sep 2022 08:06:27 +0200 | |
changeset 20 | 7b1b88e27a20 |
parent 19 | 3d72ae0968f4 |
child 21 | 48c4eec2b7e6 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
||
19 | 3 |
/* |
4 |
* Disable error reporting. |
|
0 | 5 |
* |
5 | 6 |
* Set this to error_reporting( -1 ) for debugging. |
0 | 7 |
*/ |
9 | 8 |
error_reporting( 0 ); |
0 | 9 |
|
19 | 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' ) ) { |
16 | 12 |
define( 'ABSPATH', dirname( __DIR__ ) . '/' ); |
7
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 |
|
16 | 17 |
$protocol = $_SERVER['SERVER_PROTOCOL']; |
19 | 18 |
if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0', 'HTTP/3' ), true ) ) { |
16 | 19 |
$protocol = 'HTTP/1.0'; |
20 |
} |
|
21 |
||
0 | 22 |
$load = $_GET['load']; |
9 | 23 |
if ( is_array( $load ) ) { |
16 | 24 |
ksort( $load ); |
0 | 25 |
$load = implode( '', $load ); |
9 | 26 |
} |
0 | 27 |
|
28 |
$load = preg_replace( '/[^a-z0-9,_-]+/i', '', $load ); |
|
29 |
$load = array_unique( explode( ',', $load ) ); |
|
30 |
||
9 | 31 |
if ( empty( $load ) ) { |
16 | 32 |
header( "$protocol 400 Bad Request" ); |
0 | 33 |
exit; |
9 | 34 |
} |
0 | 35 |
|
16 | 36 |
require ABSPATH . 'wp-admin/includes/noop.php'; |
37 |
require ABSPATH . WPINC . '/script-loader.php'; |
|
38 |
require ABSPATH . WPINC . '/version.php'; |
|
0 | 39 |
|
16 | 40 |
$expires_offset = 31536000; // 1 year. |
9 | 41 |
$out = ''; |
0 | 42 |
|
43 |
$wp_scripts = new WP_Scripts(); |
|
9 | 44 |
wp_default_scripts( $wp_scripts ); |
45 |
wp_default_packages_vendor( $wp_scripts ); |
|
46 |
wp_default_packages_scripts( $wp_scripts ); |
|
0 | 47 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
48 |
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
|
49 |
header( "$protocol 304 Not Modified" ); |
16 | 50 |
exit; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
51 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
52 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
53 |
foreach ( $load as $handle ) { |
9 | 54 |
if ( ! array_key_exists( $handle, $wp_scripts->registered ) ) { |
0 | 55 |
continue; |
9 | 56 |
} |
0 | 57 |
|
9 | 58 |
$path = ABSPATH . $wp_scripts->registered[ $handle ]->src; |
59 |
$out .= get_file( $path ) . "\n"; |
|
0 | 60 |
} |
61 |
||
9 | 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" ); |
|
0 | 66 |
|
67 |
echo $out; |
|
68 |
exit; |