author | ymh <ymh.work@gmail.com> |
Fri, 05 Sep 2025 18:52:52 +0200 | |
changeset 22 | 8c2e4d02f4ef |
parent 21 | 48c4eec2b7e6 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
||
19 | 3 |
/* |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
4 |
* The error_reporting() function can be disabled in php.ini. On systems where that is the case, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
5 |
* it's best to add a dummy function to the wp-config.php file, but as this call to the function |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
6 |
* is run prior to wp-config.php loading, it is wrapped in a function_exists() check. |
0 | 7 |
*/ |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
8 |
if ( function_exists( 'error_reporting' ) ) { |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
9 |
/* |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
10 |
* Disable error reporting. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
11 |
* |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
12 |
* Set this to error_reporting( -1 ) for debugging. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
13 |
*/ |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
14 |
error_reporting( 0 ); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
15 |
} |
0 | 16 |
|
19 | 17 |
// Set ABSPATH for execution. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
18 |
if ( ! defined( 'ABSPATH' ) ) { |
16 | 19 |
define( 'ABSPATH', dirname( __DIR__ ) . '/' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
20 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
21 |
|
0 | 22 |
define( 'WPINC', 'wp-includes' ); |
18 | 23 |
define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); |
0 | 24 |
|
16 | 25 |
require ABSPATH . 'wp-admin/includes/noop.php'; |
18 | 26 |
require ABSPATH . WPINC . '/theme.php'; |
27 |
require ABSPATH . WPINC . '/class-wp-theme-json-resolver.php'; |
|
19 | 28 |
require ABSPATH . WPINC . '/global-styles-and-settings.php'; |
16 | 29 |
require ABSPATH . WPINC . '/script-loader.php'; |
30 |
require ABSPATH . WPINC . '/version.php'; |
|
31 |
||
32 |
$protocol = $_SERVER['SERVER_PROTOCOL']; |
|
19 | 33 |
if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0', 'HTTP/3' ), true ) ) { |
16 | 34 |
$protocol = 'HTTP/1.0'; |
35 |
} |
|
0 | 36 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
37 |
$load = $_GET['load']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
38 |
if ( is_array( $load ) ) { |
16 | 39 |
ksort( $load ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
40 |
$load = implode( '', $load ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
41 |
} |
16 | 42 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
43 |
$load = preg_replace( '/[^a-z0-9,_-]+/i', '', $load ); |
0 | 44 |
$load = array_unique( explode( ',', $load ) ); |
45 |
||
9 | 46 |
if ( empty( $load ) ) { |
16 | 47 |
header( "$protocol 400 Bad Request" ); |
0 | 48 |
exit; |
9 | 49 |
} |
0 | 50 |
|
16 | 51 |
$rtl = ( isset( $_GET['dir'] ) && 'rtl' === $_GET['dir'] ); |
52 |
$expires_offset = 31536000; // 1 year. |
|
9 | 53 |
$out = ''; |
0 | 54 |
|
55 |
$wp_styles = new WP_Styles(); |
|
9 | 56 |
wp_default_styles( $wp_styles ); |
0 | 57 |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
58 |
$etag = $wp_styles->get_etag( $load ); |
21
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 |
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
|
61 |
header( "$protocol 304 Not Modified" ); |
16 | 62 |
exit; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
63 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
64 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
65 |
foreach ( $load as $handle ) { |
9 | 66 |
if ( ! array_key_exists( $handle, $wp_styles->registered ) ) { |
0 | 67 |
continue; |
9 | 68 |
} |
0 | 69 |
|
9 | 70 |
$style = $wp_styles->registered[ $handle ]; |
7
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 |
if ( empty( $style->src ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
73 |
continue; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
74 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
75 |
|
0 | 76 |
$path = ABSPATH . $style->src; |
77 |
||
5 | 78 |
if ( $rtl && ! empty( $style->extra['rtl'] ) ) { |
79 |
// All default styles have fully independent RTL files. |
|
80 |
$path = str_replace( '.min.css', '-rtl.min.css', $path ); |
|
0 | 81 |
} |
82 |
||
5 | 83 |
$content = get_file( $path ) . "\n"; |
84 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
85 |
// Note: str_starts_with() is not used here, as wp-includes/compat.php is not loaded in this file. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
86 |
if ( 0 === strpos( $style->src, '/' . WPINC . '/css/' ) ) { |
5 | 87 |
$content = str_replace( '../images/', '../' . WPINC . '/images/', $content ); |
88 |
$content = str_replace( '../js/tinymce/', '../' . WPINC . '/js/tinymce/', $content ); |
|
89 |
$content = str_replace( '../fonts/', '../' . WPINC . '/fonts/', $content ); |
|
9 | 90 |
$out .= $content; |
0 | 91 |
} else { |
92 |
$out .= str_replace( '../images/', 'images/', $content ); |
|
93 |
} |
|
94 |
} |
|
95 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
96 |
header( "Etag: $etag" ); |
9 | 97 |
header( 'Content-Type: text/css; charset=UTF-8' ); |
98 |
header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + $expires_offset ) . ' GMT' ); |
|
99 |
header( "Cache-Control: public, max-age=$expires_offset" ); |
|
0 | 100 |
|
101 |
echo $out; |
|
102 |
exit; |