author | ymh <ymh.work@gmail.com> |
Fri, 05 Sep 2025 18:40:08 +0200 | |
changeset 21 | 48c4eec2b7e6 |
parent 19 | 3d72ae0968f4 |
child 22 | 8c2e4d02f4ef |
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 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
48 |
$etag = "WP:{$wp_version};"; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
49 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
50 |
foreach ( $load as $handle ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
51 |
if ( ! array_key_exists( $handle, $wp_scripts->registered ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
52 |
continue; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
53 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
54 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
55 |
$ver = $wp_scripts->registered[ $handle ]->ver ? $wp_scripts->registered[ $handle ]->ver : $wp_version; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
56 |
$etag .= "{$handle}:{$ver};"; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
57 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
58 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
59 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
60 |
* This is not intended to be cryptographically secure, just a fast way to get |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
61 |
* a fixed length string based on the script versions. As this file does not |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
62 |
* load the full WordPress environment, it is not possible to use the salted |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
63 |
* wp_hash() function. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
64 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
65 |
$etag = 'W/"' . md5( $etag ) . '"'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
66 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
67 |
if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) && stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) === $etag ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
68 |
header( "$protocol 304 Not Modified" ); |
16 | 69 |
exit; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
70 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
71 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
72 |
foreach ( $load as $handle ) { |
9 | 73 |
if ( ! array_key_exists( $handle, $wp_scripts->registered ) ) { |
0 | 74 |
continue; |
9 | 75 |
} |
0 | 76 |
|
9 | 77 |
$path = ABSPATH . $wp_scripts->registered[ $handle ]->src; |
78 |
$out .= get_file( $path ) . "\n"; |
|
0 | 79 |
} |
80 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
81 |
header( "Etag: $etag" ); |
9 | 82 |
header( 'Content-Type: application/javascript; charset=UTF-8' ); |
83 |
header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + $expires_offset ) . ' GMT' ); |
|
84 |
header( "Cache-Control: public, max-age=$expires_offset" ); |
|
0 | 85 |
|
86 |
echo $out; |
|
87 |
exit; |