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 |
/** |
|
3 |
* These functions are needed to load WordPress. |
|
4 |
* |
|
5 |
* @package WordPress |
|
6 |
*/ |
|
7 |
||
8 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
9 |
* Returns the HTTP protocol sent by the server. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
10 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
11 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
12 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
13 |
* @return string The HTTP protocol. Default: HTTP/1.0. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
14 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
15 |
function wp_get_server_protocol() { |
16 | 16 |
$protocol = isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : ''; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
17 |
|
19 | 18 |
if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0', 'HTTP/3' ), true ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
19 |
$protocol = 'HTTP/1.0'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
20 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
21 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
22 |
return $protocol; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
23 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
24 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
25 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
26 |
* Fixes `$_SERVER` variables for various setups. |
0 | 27 |
* |
5 | 28 |
* @since 3.0.0 |
0 | 29 |
* @access private |
5 | 30 |
* |
31 |
* @global string $PHP_SELF The filename of the currently executing script, |
|
32 |
* relative to the document root. |
|
0 | 33 |
*/ |
34 |
function wp_fix_server_vars() { |
|
35 |
global $PHP_SELF; |
|
36 |
||
37 |
$default_server_values = array( |
|
38 |
'SERVER_SOFTWARE' => '', |
|
9 | 39 |
'REQUEST_URI' => '', |
0 | 40 |
); |
41 |
||
42 |
$_SERVER = array_merge( $default_server_values, $_SERVER ); |
|
43 |
||
16 | 44 |
// Fix for IIS when running with PHP ISAPI. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
45 |
if ( empty( $_SERVER['REQUEST_URI'] ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
46 |
|| ( 'cgi-fcgi' !== PHP_SAPI && preg_match( '/^Microsoft-IIS\//', $_SERVER['SERVER_SOFTWARE'] ) ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
47 |
) { |
0 | 48 |
|
49 |
if ( isset( $_SERVER['HTTP_X_ORIGINAL_URL'] ) ) { |
|
16 | 50 |
// IIS Mod-Rewrite. |
0 | 51 |
$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL']; |
9 | 52 |
} elseif ( isset( $_SERVER['HTTP_X_REWRITE_URL'] ) ) { |
16 | 53 |
// IIS Isapi_Rewrite. |
0 | 54 |
$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL']; |
55 |
} else { |
|
16 | 56 |
// Use ORIG_PATH_INFO if there is no PATH_INFO. |
9 | 57 |
if ( ! isset( $_SERVER['PATH_INFO'] ) && isset( $_SERVER['ORIG_PATH_INFO'] ) ) { |
0 | 58 |
$_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO']; |
9 | 59 |
} |
0 | 60 |
|
16 | 61 |
// Some IIS + PHP configurations put the script-name in the path-info (no need to append it twice). |
0 | 62 |
if ( isset( $_SERVER['PATH_INFO'] ) ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
63 |
if ( $_SERVER['PATH_INFO'] === $_SERVER['SCRIPT_NAME'] ) { |
0 | 64 |
$_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO']; |
9 | 65 |
} else { |
0 | 66 |
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO']; |
9 | 67 |
} |
0 | 68 |
} |
69 |
||
16 | 70 |
// Append the query string if it exists and isn't null. |
0 | 71 |
if ( ! empty( $_SERVER['QUERY_STRING'] ) ) { |
72 |
$_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
73 |
} |
|
74 |
} |
|
75 |
} |
|
76 |
||
16 | 77 |
// Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
78 |
if ( isset( $_SERVER['SCRIPT_FILENAME'] ) && str_ends_with( $_SERVER['SCRIPT_FILENAME'], 'php.cgi' ) ) { |
0 | 79 |
$_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED']; |
9 | 80 |
} |
0 | 81 |
|
16 | 82 |
// Fix for Dreamhost and other PHP as CGI hosts. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
83 |
if ( isset( $_SERVER['SCRIPT_NAME'] ) && str_contains( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) ) { |
0 | 84 |
unset( $_SERVER['PATH_INFO'] ); |
9 | 85 |
} |
0 | 86 |
|
16 | 87 |
// Fix empty PHP_SELF. |
0 | 88 |
$PHP_SELF = $_SERVER['PHP_SELF']; |
9 | 89 |
if ( empty( $PHP_SELF ) ) { |
16 | 90 |
$_SERVER['PHP_SELF'] = preg_replace( '/(\?.*)?$/', '', $_SERVER['REQUEST_URI'] ); |
91 |
$PHP_SELF = $_SERVER['PHP_SELF']; |
|
9 | 92 |
} |
18 | 93 |
|
94 |
wp_populate_basic_auth_from_authorization_header(); |
|
95 |
} |
|
96 |
||
97 |
/** |
|
98 |
* Populates the Basic Auth server details from the Authorization header. |
|
99 |
* |
|
100 |
* Some servers running in CGI or FastCGI mode don't pass the Authorization |
|
101 |
* header on to WordPress. If it's been rewritten to the `HTTP_AUTHORIZATION` header, |
|
102 |
* fill in the proper $_SERVER variables instead. |
|
103 |
* |
|
104 |
* @since 5.6.0 |
|
105 |
*/ |
|
106 |
function wp_populate_basic_auth_from_authorization_header() { |
|
107 |
// If we don't have anything to pull from, return early. |
|
108 |
if ( ! isset( $_SERVER['HTTP_AUTHORIZATION'] ) && ! isset( $_SERVER['REDIRECT_HTTP_AUTHORIZATION'] ) ) { |
|
109 |
return; |
|
110 |
} |
|
111 |
||
112 |
// If either PHP_AUTH key is already set, do nothing. |
|
113 |
if ( isset( $_SERVER['PHP_AUTH_USER'] ) || isset( $_SERVER['PHP_AUTH_PW'] ) ) { |
|
114 |
return; |
|
115 |
} |
|
116 |
||
117 |
// From our prior conditional, one of these must be set. |
|
118 |
$header = isset( $_SERVER['HTTP_AUTHORIZATION'] ) ? $_SERVER['HTTP_AUTHORIZATION'] : $_SERVER['REDIRECT_HTTP_AUTHORIZATION']; |
|
119 |
||
120 |
// Test to make sure the pattern matches expected. |
|
121 |
if ( ! preg_match( '%^Basic [a-z\d/+]*={0,2}$%i', $header ) ) { |
|
122 |
return; |
|
123 |
} |
|
124 |
||
125 |
// Removing `Basic ` the token would start six characters in. |
|
126 |
$token = substr( $header, 6 ); |
|
127 |
$userpass = base64_decode( $token ); |
|
128 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
129 |
// There must be at least one colon in the string. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
130 |
if ( ! str_contains( $userpass, ':' ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
131 |
return; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
132 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
133 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
134 |
list( $user, $pass ) = explode( ':', $userpass, 2 ); |
18 | 135 |
|
136 |
// Now shove them in the proper keys where we're expecting later on. |
|
137 |
$_SERVER['PHP_AUTH_USER'] = $user; |
|
138 |
$_SERVER['PHP_AUTH_PW'] = $pass; |
|
0 | 139 |
} |
140 |
||
141 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
142 |
* Checks for the required PHP version, and the mysqli extension or |
5 | 143 |
* a database drop-in. |
0 | 144 |
* |
145 |
* Dies if requirements are not met. |
|
146 |
* |
|
5 | 147 |
* @since 3.0.0 |
0 | 148 |
* @access private |
5 | 149 |
* |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
150 |
* @global string $required_php_version The required PHP version string. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
151 |
* @global string[] $required_php_extensions The names of required PHP extensions. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
152 |
* @global string $wp_version The WordPress version string. |
0 | 153 |
*/ |
154 |
function wp_check_php_mysql_versions() { |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
155 |
global $required_php_version, $required_php_extensions, $wp_version; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
156 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
157 |
$php_version = PHP_VERSION; |
5 | 158 |
|
0 | 159 |
if ( version_compare( $required_php_version, $php_version, '>' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
160 |
$protocol = wp_get_server_protocol(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
161 |
header( sprintf( '%s 500 Internal Server Error', $protocol ), true, 500 ); |
5 | 162 |
header( 'Content-Type: text/html; charset=utf-8' ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
163 |
printf( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
164 |
'Your server is running PHP version %1$s but WordPress %2$s requires at least %3$s.', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
165 |
$php_version, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
166 |
$wp_version, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
167 |
$required_php_version |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
168 |
); |
9 | 169 |
exit( 1 ); |
0 | 170 |
} |
171 |
||
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
172 |
$missing_extensions = array(); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
173 |
|
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
174 |
if ( isset( $required_php_extensions ) && is_array( $required_php_extensions ) ) { |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
175 |
foreach ( $required_php_extensions as $extension ) { |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
176 |
if ( extension_loaded( $extension ) ) { |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
177 |
continue; |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
178 |
} |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
179 |
|
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
180 |
$missing_extensions[] = sprintf( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
181 |
'WordPress %1$s requires the <code>%2$s</code> PHP extension.', |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
182 |
$wp_version, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
183 |
$extension |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
184 |
); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
185 |
} |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
186 |
} |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
187 |
|
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
188 |
if ( count( $missing_extensions ) > 0 ) { |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
189 |
$protocol = wp_get_server_protocol(); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
190 |
header( sprintf( '%s 500 Internal Server Error', $protocol ), true, 500 ); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
191 |
header( 'Content-Type: text/html; charset=utf-8' ); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
192 |
echo implode( '<br>', $missing_extensions ); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
193 |
exit( 1 ); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
194 |
} |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
195 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
196 |
// This runs before default constants are defined, so we can't assume WP_CONTENT_DIR is set yet. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
197 |
$wp_content_dir = defined( 'WP_CONTENT_DIR' ) ? WP_CONTENT_DIR : ABSPATH . 'wp-content'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
198 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
199 |
if ( ! function_exists( 'mysqli_connect' ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
200 |
&& ! file_exists( $wp_content_dir . '/db.php' ) |
18 | 201 |
) { |
16 | 202 |
require_once ABSPATH . WPINC . '/functions.php'; |
0 | 203 |
wp_load_translations_early(); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
204 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
205 |
$message = '<p>' . __( 'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.' ) . "</p>\n"; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
206 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
207 |
$message .= '<p>' . sprintf( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
208 |
/* translators: %s: mysqli. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
209 |
__( 'Please check that the %s PHP extension is installed and enabled.' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
210 |
'<code>mysqli</code>' |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
211 |
) . "</p>\n"; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
212 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
213 |
$message .= '<p>' . sprintf( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
214 |
/* translators: %s: Support forums URL. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
215 |
__( 'If you are unsure what these terms mean you should probably contact your host. If you still need help you can always visit the <a href="%s">WordPress support forums</a>.' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
216 |
__( 'https://wordpress.org/support/forums/' ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
217 |
) . "</p>\n"; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
218 |
|
9 | 219 |
$args = array( |
220 |
'exit' => false, |
|
221 |
'code' => 'mysql_not_found', |
|
222 |
); |
|
223 |
wp_die( |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
224 |
$message, |
16 | 225 |
__( 'Requirements Not Met' ), |
9 | 226 |
$args |
227 |
); |
|
228 |
exit( 1 ); |
|
0 | 229 |
} |
230 |
} |
|
231 |
||
232 |
/** |
|
16 | 233 |
* Retrieves the current environment type. |
234 |
* |
|
235 |
* The type can be set via the `WP_ENVIRONMENT_TYPE` global system variable, |
|
236 |
* or a constant of the same name. |
|
237 |
* |
|
18 | 238 |
* Possible values are 'local', 'development', 'staging', and 'production'. |
16 | 239 |
* If not set, the type defaults to 'production'. |
240 |
* |
|
241 |
* @since 5.5.0 |
|
242 |
* @since 5.5.1 Added the 'local' type. |
|
243 |
* @since 5.5.1 Removed the ability to alter the list of types. |
|
244 |
* |
|
245 |
* @return string The current environment type. |
|
246 |
*/ |
|
247 |
function wp_get_environment_type() { |
|
248 |
static $current_env = ''; |
|
249 |
||
19 | 250 |
if ( ! defined( 'WP_RUN_CORE_TESTS' ) && $current_env ) { |
16 | 251 |
return $current_env; |
252 |
} |
|
253 |
||
254 |
$wp_environments = array( |
|
255 |
'local', |
|
256 |
'development', |
|
257 |
'staging', |
|
258 |
'production', |
|
259 |
); |
|
260 |
||
261 |
// Add a note about the deprecated WP_ENVIRONMENT_TYPES constant. |
|
262 |
if ( defined( 'WP_ENVIRONMENT_TYPES' ) && function_exists( '_deprecated_argument' ) ) { |
|
263 |
if ( function_exists( '__' ) ) { |
|
264 |
/* translators: %s: WP_ENVIRONMENT_TYPES */ |
|
265 |
$message = sprintf( __( 'The %s constant is no longer supported.' ), 'WP_ENVIRONMENT_TYPES' ); |
|
266 |
} else { |
|
267 |
$message = sprintf( 'The %s constant is no longer supported.', 'WP_ENVIRONMENT_TYPES' ); |
|
268 |
} |
|
269 |
||
270 |
_deprecated_argument( |
|
271 |
'define()', |
|
272 |
'5.5.1', |
|
273 |
$message |
|
274 |
); |
|
275 |
} |
|
276 |
||
277 |
// Check if the environment variable has been set, if `getenv` is available on the system. |
|
278 |
if ( function_exists( 'getenv' ) ) { |
|
279 |
$has_env = getenv( 'WP_ENVIRONMENT_TYPE' ); |
|
280 |
if ( false !== $has_env ) { |
|
281 |
$current_env = $has_env; |
|
282 |
} |
|
283 |
} |
|
284 |
||
285 |
// Fetch the environment from a constant, this overrides the global system variable. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
286 |
if ( defined( 'WP_ENVIRONMENT_TYPE' ) && WP_ENVIRONMENT_TYPE ) { |
16 | 287 |
$current_env = WP_ENVIRONMENT_TYPE; |
288 |
} |
|
289 |
||
290 |
// Make sure the environment is an allowed one, and not accidentally set to an invalid value. |
|
291 |
if ( ! in_array( $current_env, $wp_environments, true ) ) { |
|
292 |
$current_env = 'production'; |
|
293 |
} |
|
294 |
||
295 |
return $current_env; |
|
296 |
} |
|
297 |
||
298 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
299 |
* Retrieves the current development mode. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
300 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
301 |
* The development mode affects how certain parts of the WordPress application behave, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
302 |
* which is relevant when developing for WordPress. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
303 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
304 |
* Development mode can be set via the `WP_DEVELOPMENT_MODE` constant in `wp-config.php`. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
305 |
* Possible values are 'core', 'plugin', 'theme', 'all', or an empty string to disable |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
306 |
* development mode. 'all' is a special value to signify that all three development modes |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
307 |
* ('core', 'plugin', and 'theme') are enabled. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
308 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
309 |
* Development mode is considered separately from `WP_DEBUG` and wp_get_environment_type(). |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
310 |
* It does not affect debugging output, but rather functional nuances in WordPress. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
311 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
312 |
* This function retrieves the currently set development mode value. To check whether |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
313 |
* a specific development mode is enabled, use wp_is_development_mode(). |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
314 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
315 |
* @since 6.3.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
316 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
317 |
* @return string The current development mode. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
318 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
319 |
function wp_get_development_mode() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
320 |
static $current_mode = null; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
321 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
322 |
if ( ! defined( 'WP_RUN_CORE_TESTS' ) && null !== $current_mode ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
323 |
return $current_mode; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
324 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
325 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
326 |
$development_mode = WP_DEVELOPMENT_MODE; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
327 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
328 |
// Exclusively for core tests, rely on the `$_wp_tests_development_mode` global. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
329 |
if ( defined( 'WP_RUN_CORE_TESTS' ) && isset( $GLOBALS['_wp_tests_development_mode'] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
330 |
$development_mode = $GLOBALS['_wp_tests_development_mode']; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
331 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
332 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
333 |
$valid_modes = array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
334 |
'core', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
335 |
'plugin', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
336 |
'theme', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
337 |
'all', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
338 |
'', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
339 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
340 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
341 |
if ( ! in_array( $development_mode, $valid_modes, true ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
342 |
$development_mode = ''; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
343 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
344 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
345 |
$current_mode = $development_mode; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
346 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
347 |
return $current_mode; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
348 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
349 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
350 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
351 |
* Checks whether the site is in the given development mode. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
352 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
353 |
* @since 6.3.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
354 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
355 |
* @param string $mode Development mode to check for. Either 'core', 'plugin', 'theme', or 'all'. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
356 |
* @return bool True if the given mode is covered by the current development mode, false otherwise. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
357 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
358 |
function wp_is_development_mode( $mode ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
359 |
$current_mode = wp_get_development_mode(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
360 |
if ( empty( $current_mode ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
361 |
return false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
362 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
363 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
364 |
// Return true if the current mode encompasses all modes. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
365 |
if ( 'all' === $current_mode ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
366 |
return true; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
367 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
368 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
369 |
// Return true if the current mode is the given mode. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
370 |
return $mode === $current_mode; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
371 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
372 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
373 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
374 |
* Ensures all of WordPress is not loaded when handling a favicon.ico request. |
5 | 375 |
* |
0 | 376 |
* Instead, send the headers for a zero-length favicon and bail. |
377 |
* |
|
378 |
* @since 3.0.0 |
|
16 | 379 |
* @deprecated 5.4.0 Deprecated in favor of do_favicon(). |
0 | 380 |
*/ |
381 |
function wp_favicon_request() { |
|
16 | 382 |
if ( '/favicon.ico' === $_SERVER['REQUEST_URI'] ) { |
9 | 383 |
header( 'Content-Type: image/vnd.microsoft.icon' ); |
0 | 384 |
exit; |
385 |
} |
|
386 |
} |
|
387 |
||
388 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
389 |
* Dies with a maintenance message when conditions are met. |
0 | 390 |
* |
391 |
* The default message can be replaced by using a drop-in (maintenance.php in |
|
392 |
* the wp-content directory). |
|
393 |
* |
|
5 | 394 |
* @since 3.0.0 |
0 | 395 |
* @access private |
396 |
*/ |
|
397 |
function wp_maintenance() { |
|
16 | 398 |
// Return if maintenance mode is disabled. |
399 |
if ( ! wp_is_maintenance_mode() ) { |
|
0 | 400 |
return; |
9 | 401 |
} |
0 | 402 |
|
16 | 403 |
if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) { |
404 |
require_once WP_CONTENT_DIR . '/maintenance.php'; |
|
405 |
die(); |
|
406 |
} |
|
407 |
||
408 |
require_once ABSPATH . WPINC . '/functions.php'; |
|
409 |
wp_load_translations_early(); |
|
410 |
||
411 |
header( 'Retry-After: 600' ); |
|
412 |
||
413 |
wp_die( |
|
414 |
__( 'Briefly unavailable for scheduled maintenance. Check back in a minute.' ), |
|
415 |
__( 'Maintenance' ), |
|
416 |
503 |
|
417 |
); |
|
418 |
} |
|
419 |
||
420 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
421 |
* Checks if maintenance mode is enabled. |
16 | 422 |
* |
423 |
* Checks for a file in the WordPress root directory named ".maintenance". |
|
424 |
* This file will contain the variable $upgrading, set to the time the file |
|
425 |
* was created. If the file was created less than 10 minutes ago, WordPress |
|
426 |
* is in maintenance mode. |
|
427 |
* |
|
428 |
* @since 5.5.0 |
|
429 |
* |
|
430 |
* @global int $upgrading The Unix timestamp marking when upgrading WordPress began. |
|
431 |
* |
|
432 |
* @return bool True if maintenance mode is enabled, false otherwise. |
|
433 |
*/ |
|
434 |
function wp_is_maintenance_mode() { |
|
0 | 435 |
global $upgrading; |
436 |
||
16 | 437 |
if ( ! file_exists( ABSPATH . '.maintenance' ) || wp_installing() ) { |
438 |
return false; |
|
439 |
} |
|
440 |
||
441 |
require ABSPATH . '.maintenance'; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
442 |
|
16 | 443 |
// If the $upgrading timestamp is older than 10 minutes, consider maintenance over. |
444 |
if ( ( time() - $upgrading ) >= 10 * MINUTE_IN_SECONDS ) { |
|
445 |
return false; |
|
9 | 446 |
} |
0 | 447 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
448 |
// Don't enable maintenance mode while scraping for fatal errors. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
449 |
if ( is_int( $upgrading ) && isset( $_REQUEST['wp_scrape_key'], $_REQUEST['wp_scrape_nonce'] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
450 |
$key = stripslashes( $_REQUEST['wp_scrape_key'] ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
451 |
$nonce = stripslashes( $_REQUEST['wp_scrape_nonce'] ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
452 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
453 |
if ( md5( $upgrading ) === $key && (int) $nonce === $upgrading ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
454 |
return false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
455 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
456 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
457 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
458 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
459 |
* Filters whether to enable maintenance mode. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
460 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
461 |
* This filter runs before it can be used by plugins. It is designed for |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
462 |
* non-web runtimes. If this filter returns true, maintenance mode will be |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
463 |
* active and the request will end. If false, the request will be allowed to |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
464 |
* continue processing even if maintenance mode should be active. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
465 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
466 |
* @since 4.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
467 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
468 |
* @param bool $enable_checks Whether to enable maintenance mode. Default true. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
469 |
* @param int $upgrading The timestamp set in the .maintenance file. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
470 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
471 |
if ( ! apply_filters( 'enable_maintenance_mode', true, $upgrading ) ) { |
16 | 472 |
return false; |
0 | 473 |
} |
474 |
||
16 | 475 |
return true; |
0 | 476 |
} |
477 |
||
478 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
479 |
* Gets the time elapsed so far during this PHP script. |
18 | 480 |
* |
481 |
* @since 5.8.0 |
|
482 |
* |
|
483 |
* @return float Seconds since the PHP script started. |
|
484 |
*/ |
|
485 |
function timer_float() { |
|
486 |
return microtime( true ) - $_SERVER['REQUEST_TIME_FLOAT']; |
|
487 |
} |
|
488 |
||
489 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
490 |
* Starts the WordPress micro-timer. |
0 | 491 |
* |
5 | 492 |
* @since 0.71 |
0 | 493 |
* @access private |
5 | 494 |
* |
495 |
* @global float $timestart Unix timestamp set at the beginning of the page load. |
|
496 |
* @see timer_stop() |
|
497 |
* |
|
0 | 498 |
* @return bool Always returns true. |
499 |
*/ |
|
500 |
function timer_start() { |
|
501 |
global $timestart; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
502 |
|
0 | 503 |
$timestart = microtime( true ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
504 |
|
0 | 505 |
return true; |
506 |
} |
|
507 |
||
508 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
509 |
* Retrieves or displays the time from the page start to when function is called. |
0 | 510 |
* |
511 |
* @since 0.71 |
|
5 | 512 |
* |
513 |
* @global float $timestart Seconds from when timer_start() is called. |
|
514 |
* @global float $timeend Seconds from when function is called. |
|
0 | 515 |
* |
5 | 516 |
* @param int|bool $display Whether to echo or return the results. Accepts 0|false for return, |
517 |
* 1|true for echo. Default 0|false. |
|
518 |
* @param int $precision The number of digits from the right of the decimal to display. |
|
519 |
* Default 3. |
|
520 |
* @return string The "second.microsecond" finished time calculation. The number is formatted |
|
521 |
* for human consumption, both localized and rounded. |
|
0 | 522 |
*/ |
5 | 523 |
function timer_stop( $display = 0, $precision = 3 ) { |
0 | 524 |
global $timestart, $timeend; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
525 |
|
9 | 526 |
$timeend = microtime( true ); |
0 | 527 |
$timetotal = $timeend - $timestart; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
528 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
529 |
if ( function_exists( 'number_format_i18n' ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
530 |
$r = number_format_i18n( $timetotal, $precision ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
531 |
} else { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
532 |
$r = number_format( $timetotal, $precision ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
533 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
534 |
|
9 | 535 |
if ( $display ) { |
0 | 536 |
echo $r; |
9 | 537 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
538 |
|
0 | 539 |
return $r; |
540 |
} |
|
541 |
||
542 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
543 |
* Sets PHP error reporting based on WordPress debug settings. |
5 | 544 |
* |
545 |
* Uses three constants: `WP_DEBUG`, `WP_DEBUG_DISPLAY`, and `WP_DEBUG_LOG`. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
546 |
* All three can be defined in wp-config.php. By default, `WP_DEBUG` and |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
547 |
* `WP_DEBUG_LOG` are set to false, and `WP_DEBUG_DISPLAY` is set to true. |
0 | 548 |
* |
5 | 549 |
* When `WP_DEBUG` is true, all PHP notices are reported. WordPress will also |
550 |
* display internal notices: when a deprecated WordPress function, function |
|
551 |
* argument, or file is used. Deprecated code may be removed from a later |
|
552 |
* version. |
|
0 | 553 |
* |
5 | 554 |
* It is strongly recommended that plugin and theme developers use `WP_DEBUG` |
555 |
* in their development environments. |
|
0 | 556 |
* |
5 | 557 |
* `WP_DEBUG_DISPLAY` and `WP_DEBUG_LOG` perform no function unless `WP_DEBUG` |
558 |
* is true. |
|
0 | 559 |
* |
5 | 560 |
* When `WP_DEBUG_DISPLAY` is true, WordPress will force errors to be displayed. |
561 |
* `WP_DEBUG_DISPLAY` defaults to true. Defining it as null prevents WordPress |
|
562 |
* from changing the global configuration setting. Defining `WP_DEBUG_DISPLAY` |
|
563 |
* as false will force errors to be hidden. |
|
0 | 564 |
* |
9 | 565 |
* When `WP_DEBUG_LOG` is true, errors will be logged to `wp-content/debug.log`. |
566 |
* When `WP_DEBUG_LOG` is a valid path, errors will be logged to the specified file. |
|
0 | 567 |
* |
19 | 568 |
* Errors are never displayed for XML-RPC, REST, `ms-files.php`, and Ajax requests. |
0 | 569 |
* |
5 | 570 |
* @since 3.0.0 |
9 | 571 |
* @since 5.1.0 `WP_DEBUG_LOG` can be a file path. |
0 | 572 |
* @access private |
573 |
*/ |
|
574 |
function wp_debug_mode() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
575 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
576 |
* Filters whether to allow the debug mode check to occur. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
577 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
578 |
* This filter runs before it can be used by plugins. It is designed for |
19 | 579 |
* non-web runtimes. Returning false causes the `WP_DEBUG` and related |
16 | 580 |
* constants to not be checked and the default PHP values for errors |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
581 |
* will be used unless you take care to update them yourself. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
582 |
* |
18 | 583 |
* To use this filter you must define a `$wp_filter` global before |
584 |
* WordPress loads, usually in `wp-config.php`. |
|
585 |
* |
|
586 |
* Example: |
|
587 |
* |
|
588 |
* $GLOBALS['wp_filter'] = array( |
|
589 |
* 'enable_wp_debug_mode_checks' => array( |
|
590 |
* 10 => array( |
|
591 |
* array( |
|
592 |
* 'accepted_args' => 0, |
|
593 |
* 'function' => function() { |
|
594 |
* return false; |
|
595 |
* }, |
|
596 |
* ), |
|
597 |
* ), |
|
598 |
* ), |
|
599 |
* ); |
|
600 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
601 |
* @since 4.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
602 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
603 |
* @param bool $enable_debug_mode Whether to enable debug mode checks to occur. Default true. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
604 |
*/ |
9 | 605 |
if ( ! apply_filters( 'enable_wp_debug_mode_checks', true ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
606 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
607 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
608 |
|
0 | 609 |
if ( WP_DEBUG ) { |
610 |
error_reporting( E_ALL ); |
|
611 |
||
9 | 612 |
if ( WP_DEBUG_DISPLAY ) { |
0 | 613 |
ini_set( 'display_errors', 1 ); |
9 | 614 |
} elseif ( null !== WP_DEBUG_DISPLAY ) { |
0 | 615 |
ini_set( 'display_errors', 0 ); |
9 | 616 |
} |
0 | 617 |
|
9 | 618 |
if ( in_array( strtolower( (string) WP_DEBUG_LOG ), array( 'true', '1' ), true ) ) { |
619 |
$log_path = WP_CONTENT_DIR . '/debug.log'; |
|
620 |
} elseif ( is_string( WP_DEBUG_LOG ) ) { |
|
621 |
$log_path = WP_DEBUG_LOG; |
|
622 |
} else { |
|
623 |
$log_path = false; |
|
624 |
} |
|
625 |
||
626 |
if ( $log_path ) { |
|
0 | 627 |
ini_set( 'log_errors', 1 ); |
9 | 628 |
ini_set( 'error_log', $log_path ); |
0 | 629 |
} |
630 |
} else { |
|
631 |
error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR ); |
|
632 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
633 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
634 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
635 |
* The 'REST_REQUEST' check here is optimistic as the constant is most |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
636 |
* likely not set at this point even if it is in fact a REST request. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
637 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
638 |
if ( defined( 'XMLRPC_REQUEST' ) || defined( 'REST_REQUEST' ) || defined( 'MS_FILES_REQUEST' ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
639 |
|| ( defined( 'WP_INSTALLING' ) && WP_INSTALLING ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
640 |
|| wp_doing_ajax() || wp_is_json_request() |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
641 |
) { |
16 | 642 |
ini_set( 'display_errors', 0 ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
643 |
} |
0 | 644 |
} |
645 |
||
646 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
647 |
* Sets the location of the language directory. |
0 | 648 |
* |
5 | 649 |
* To set directory manually, define the `WP_LANG_DIR` constant |
650 |
* in wp-config.php. |
|
0 | 651 |
* |
5 | 652 |
* If the language directory exists within `WP_CONTENT_DIR`, it |
653 |
* is used. Otherwise the language directory is assumed to live |
|
654 |
* in `WPINC`. |
|
0 | 655 |
* |
5 | 656 |
* @since 3.0.0 |
0 | 657 |
* @access private |
658 |
*/ |
|
659 |
function wp_set_lang_dir() { |
|
9 | 660 |
if ( ! defined( 'WP_LANG_DIR' ) ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
661 |
if ( file_exists( WP_CONTENT_DIR . '/languages' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
662 |
|| ! @is_dir( ABSPATH . WPINC . '/languages' ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
663 |
) { |
5 | 664 |
/** |
665 |
* Server path of the language directory. |
|
666 |
* |
|
667 |
* No leading slash, no trailing slash, full path, not relative to ABSPATH |
|
668 |
* |
|
669 |
* @since 2.1.0 |
|
670 |
*/ |
|
671 |
define( 'WP_LANG_DIR', WP_CONTENT_DIR . '/languages' ); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
672 |
|
9 | 673 |
if ( ! defined( 'LANGDIR' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
674 |
// Old static relative path maintained for limited backward compatibility - won't work in some cases. |
0 | 675 |
define( 'LANGDIR', 'wp-content/languages' ); |
676 |
} |
|
677 |
} else { |
|
5 | 678 |
/** |
679 |
* Server path of the language directory. |
|
680 |
* |
|
681 |
* No leading slash, no trailing slash, full path, not relative to `ABSPATH`. |
|
682 |
* |
|
683 |
* @since 2.1.0 |
|
684 |
*/ |
|
685 |
define( 'WP_LANG_DIR', ABSPATH . WPINC . '/languages' ); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
686 |
|
9 | 687 |
if ( ! defined( 'LANGDIR' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
688 |
// Old relative path maintained for backward compatibility. |
0 | 689 |
define( 'LANGDIR', WPINC . '/languages' ); |
690 |
} |
|
691 |
} |
|
692 |
} |
|
693 |
} |
|
694 |
||
695 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
696 |
* Loads the database class file and instantiates the `$wpdb` global. |
0 | 697 |
* |
698 |
* @since 2.5.0 |
|
5 | 699 |
* |
16 | 700 |
* @global wpdb $wpdb WordPress database abstraction object. |
0 | 701 |
*/ |
702 |
function require_wp_db() { |
|
703 |
global $wpdb; |
|
704 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
705 |
require_once ABSPATH . WPINC . '/class-wpdb.php'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
706 |
|
9 | 707 |
if ( file_exists( WP_CONTENT_DIR . '/db.php' ) ) { |
16 | 708 |
require_once WP_CONTENT_DIR . '/db.php'; |
9 | 709 |
} |
0 | 710 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
711 |
if ( isset( $wpdb ) ) { |
0 | 712 |
return; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
713 |
} |
0 | 714 |
|
9 | 715 |
$dbuser = defined( 'DB_USER' ) ? DB_USER : ''; |
716 |
$dbpassword = defined( 'DB_PASSWORD' ) ? DB_PASSWORD : ''; |
|
717 |
$dbname = defined( 'DB_NAME' ) ? DB_NAME : ''; |
|
718 |
$dbhost = defined( 'DB_HOST' ) ? DB_HOST : ''; |
|
719 |
||
720 |
$wpdb = new wpdb( $dbuser, $dbpassword, $dbname, $dbhost ); |
|
0 | 721 |
} |
722 |
||
723 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
724 |
* Sets the database table prefix and the format specifiers for database |
5 | 725 |
* table columns. |
0 | 726 |
* |
5 | 727 |
* Columns not listed here default to `%s`. |
0 | 728 |
* |
5 | 729 |
* @since 3.0.0 |
730 |
* @access private |
|
0 | 731 |
* |
16 | 732 |
* @global wpdb $wpdb WordPress database abstraction object. |
5 | 733 |
* @global string $table_prefix The database table prefix. |
0 | 734 |
*/ |
735 |
function wp_set_wpdb_vars() { |
|
736 |
global $wpdb, $table_prefix; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
737 |
|
9 | 738 |
if ( ! empty( $wpdb->error ) ) { |
0 | 739 |
dead_db(); |
9 | 740 |
} |
0 | 741 |
|
9 | 742 |
$wpdb->field_types = array( |
743 |
'post_author' => '%d', |
|
744 |
'post_parent' => '%d', |
|
745 |
'menu_order' => '%d', |
|
746 |
'term_id' => '%d', |
|
747 |
'term_group' => '%d', |
|
748 |
'term_taxonomy_id' => '%d', |
|
749 |
'parent' => '%d', |
|
750 |
'count' => '%d', |
|
751 |
'object_id' => '%d', |
|
752 |
'term_order' => '%d', |
|
753 |
'ID' => '%d', |
|
754 |
'comment_ID' => '%d', |
|
755 |
'comment_post_ID' => '%d', |
|
756 |
'comment_parent' => '%d', |
|
757 |
'user_id' => '%d', |
|
758 |
'link_id' => '%d', |
|
759 |
'link_owner' => '%d', |
|
760 |
'link_rating' => '%d', |
|
761 |
'option_id' => '%d', |
|
762 |
'blog_id' => '%d', |
|
763 |
'meta_id' => '%d', |
|
764 |
'post_id' => '%d', |
|
765 |
'user_status' => '%d', |
|
766 |
'umeta_id' => '%d', |
|
767 |
'comment_karma' => '%d', |
|
768 |
'comment_count' => '%d', |
|
16 | 769 |
// Multisite: |
9 | 770 |
'active' => '%d', |
771 |
'cat_id' => '%d', |
|
772 |
'deleted' => '%d', |
|
773 |
'lang_id' => '%d', |
|
774 |
'mature' => '%d', |
|
775 |
'public' => '%d', |
|
776 |
'site_id' => '%d', |
|
777 |
'spam' => '%d', |
|
0 | 778 |
); |
779 |
||
780 |
$prefix = $wpdb->set_prefix( $table_prefix ); |
|
781 |
||
782 |
if ( is_wp_error( $prefix ) ) { |
|
783 |
wp_load_translations_early(); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
784 |
wp_die( |
9 | 785 |
sprintf( |
16 | 786 |
/* translators: 1: $table_prefix, 2: wp-config.php */ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
787 |
__( '<strong>Error:</strong> %1$s in %2$s can only contain numbers, letters, and underscores.' ), |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
788 |
'<code>$table_prefix</code>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
789 |
'<code>wp-config.php</code>' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
790 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
791 |
); |
0 | 792 |
} |
793 |
} |
|
794 |
||
795 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
796 |
* Toggles `$_wp_using_ext_object_cache` on and off without directly |
5 | 797 |
* touching global. |
0 | 798 |
* |
799 |
* @since 3.7.0 |
|
800 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
801 |
* @global bool $_wp_using_ext_object_cache |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
802 |
* |
5 | 803 |
* @param bool $using Whether external object cache is being used. |
804 |
* @return bool The current 'using' setting. |
|
0 | 805 |
*/ |
806 |
function wp_using_ext_object_cache( $using = null ) { |
|
807 |
global $_wp_using_ext_object_cache; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
808 |
|
0 | 809 |
$current_using = $_wp_using_ext_object_cache; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
810 |
|
9 | 811 |
if ( null !== $using ) { |
0 | 812 |
$_wp_using_ext_object_cache = $using; |
9 | 813 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
814 |
|
0 | 815 |
return $current_using; |
816 |
} |
|
817 |
||
818 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
819 |
* Starts the WordPress object cache. |
0 | 820 |
* |
821 |
* If an object-cache.php file exists in the wp-content directory, |
|
822 |
* it uses that drop-in as an external object cache. |
|
823 |
* |
|
5 | 824 |
* @since 3.0.0 |
0 | 825 |
* @access private |
5 | 826 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
827 |
* @global array $wp_filter Stores all of the filters. |
0 | 828 |
*/ |
829 |
function wp_start_object_cache() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
830 |
global $wp_filter; |
9 | 831 |
static $first_init = true; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
832 |
|
9 | 833 |
// Only perform the following checks once. |
18 | 834 |
|
835 |
/** |
|
836 |
* Filters whether to enable loading of the object-cache.php drop-in. |
|
837 |
* |
|
838 |
* This filter runs before it can be used by plugins. It is designed for non-web |
|
19 | 839 |
* runtimes. If false is returned, object-cache.php will never be loaded. |
18 | 840 |
* |
841 |
* @since 5.8.0 |
|
842 |
* |
|
843 |
* @param bool $enable_object_cache Whether to enable loading object-cache.php (if present). |
|
19 | 844 |
* Default true. |
18 | 845 |
*/ |
846 |
if ( $first_init && apply_filters( 'enable_loading_object_cache_dropin', true ) ) { |
|
9 | 847 |
if ( ! function_exists( 'wp_cache_init' ) ) { |
848 |
/* |
|
849 |
* This is the normal situation. First-run of this function. No |
|
850 |
* caching backend has been loaded. |
|
851 |
* |
|
852 |
* We try to load a custom caching backend, and then, if it |
|
853 |
* results in a wp_cache_init() function existing, we note |
|
854 |
* that an external object cache is being used. |
|
855 |
*/ |
|
856 |
if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { |
|
16 | 857 |
require_once WP_CONTENT_DIR . '/object-cache.php'; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
858 |
|
9 | 859 |
if ( function_exists( 'wp_cache_init' ) ) { |
860 |
wp_using_ext_object_cache( true ); |
|
861 |
} |
|
0 | 862 |
|
16 | 863 |
// Re-initialize any hooks added manually by object-cache.php. |
9 | 864 |
if ( $wp_filter ) { |
865 |
$wp_filter = WP_Hook::build_preinitialized_hooks( $wp_filter ); |
|
866 |
} |
|
867 |
} |
|
868 |
} elseif ( ! wp_using_ext_object_cache() && file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { |
|
869 |
/* |
|
870 |
* Sometimes advanced-cache.php can load object-cache.php before |
|
871 |
* this function is run. This breaks the function_exists() check |
|
872 |
* above and can result in wp_using_ext_object_cache() returning |
|
873 |
* false when actually an external cache is in use. |
|
874 |
*/ |
|
875 |
wp_using_ext_object_cache( true ); |
|
876 |
} |
|
0 | 877 |
} |
878 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
879 |
if ( ! wp_using_ext_object_cache() ) { |
16 | 880 |
require_once ABSPATH . WPINC . '/cache.php'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
881 |
} |
0 | 882 |
|
16 | 883 |
require_once ABSPATH . WPINC . '/cache-compat.php'; |
884 |
||
5 | 885 |
/* |
886 |
* If cache supports reset, reset instead of init if already |
|
887 |
* initialized. Reset signals to the cache that global IDs |
|
888 |
* have changed and it may need to update keys and cleanup caches. |
|
889 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
890 |
if ( ! $first_init && function_exists( 'wp_cache_switch_to_blog' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
891 |
wp_cache_switch_to_blog( get_current_blog_id() ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
892 |
} elseif ( function_exists( 'wp_cache_init' ) ) { |
0 | 893 |
wp_cache_init(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
894 |
} |
0 | 895 |
|
896 |
if ( function_exists( 'wp_cache_add_global_groups' ) ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
897 |
wp_cache_add_global_groups( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
898 |
array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
899 |
'blog-details', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
900 |
'blog-id-cache', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
901 |
'blog-lookup', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
902 |
'blog_meta', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
903 |
'global-posts', |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
904 |
'image_editor', |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
905 |
'networks', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
906 |
'network-queries', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
907 |
'sites', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
908 |
'site-details', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
909 |
'site-options', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
910 |
'site-queries', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
911 |
'site-transient', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
912 |
'theme_files', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
913 |
'translation_files', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
914 |
'rss', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
915 |
'users', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
916 |
'user-queries', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
917 |
'user_meta', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
918 |
'useremail', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
919 |
'userlogins', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
920 |
'userslugs', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
921 |
) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
922 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
923 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
924 |
wp_cache_add_non_persistent_groups( array( 'counts', 'plugins', 'theme_json' ) ); |
0 | 925 |
} |
9 | 926 |
|
927 |
$first_init = false; |
|
0 | 928 |
} |
929 |
||
930 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
931 |
* Redirects to the installer if WordPress is not installed. |
0 | 932 |
* |
5 | 933 |
* Dies with an error message when Multisite is enabled. |
0 | 934 |
* |
5 | 935 |
* @since 3.0.0 |
0 | 936 |
* @access private |
937 |
*/ |
|
938 |
function wp_not_installed() { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
939 |
if ( is_blog_installed() || wp_installing() ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
940 |
return; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
941 |
} |
5 | 942 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
943 |
nocache_headers(); |
5 | 944 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
945 |
if ( is_multisite() ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
946 |
wp_die( __( 'The site you have requested is not installed properly. Please contact the system administrator.' ) ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
947 |
} |
0 | 948 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
949 |
require ABSPATH . WPINC . '/kses.php'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
950 |
require ABSPATH . WPINC . '/pluggable.php'; |
0 | 951 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
952 |
$link = wp_guess_url() . '/wp-admin/install.php'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
953 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
954 |
wp_redirect( $link ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
955 |
die(); |
0 | 956 |
} |
957 |
||
958 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
959 |
* Retrieves an array of must-use plugin files. |
0 | 960 |
* |
5 | 961 |
* The default directory is wp-content/mu-plugins. To change the default |
962 |
* directory manually, define `WPMU_PLUGIN_DIR` and `WPMU_PLUGIN_URL` |
|
0 | 963 |
* in wp-config.php. |
964 |
* |
|
5 | 965 |
* @since 3.0.0 |
0 | 966 |
* @access private |
5 | 967 |
* |
16 | 968 |
* @return string[] Array of absolute paths of files to include. |
0 | 969 |
*/ |
970 |
function wp_get_mu_plugins() { |
|
971 |
$mu_plugins = array(); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
972 |
|
9 | 973 |
if ( ! is_dir( WPMU_PLUGIN_DIR ) ) { |
0 | 974 |
return $mu_plugins; |
9 | 975 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
976 |
|
16 | 977 |
$dh = opendir( WPMU_PLUGIN_DIR ); |
978 |
if ( ! $dh ) { |
|
0 | 979 |
return $mu_plugins; |
9 | 980 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
981 |
|
0 | 982 |
while ( ( $plugin = readdir( $dh ) ) !== false ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
983 |
if ( str_ends_with( $plugin, '.php' ) ) { |
0 | 984 |
$mu_plugins[] = WPMU_PLUGIN_DIR . '/' . $plugin; |
9 | 985 |
} |
0 | 986 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
987 |
|
0 | 988 |
closedir( $dh ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
989 |
|
0 | 990 |
sort( $mu_plugins ); |
991 |
||
992 |
return $mu_plugins; |
|
993 |
} |
|
994 |
||
995 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
996 |
* Retrieves an array of active and valid plugin files. |
0 | 997 |
* |
5 | 998 |
* While upgrading or installing WordPress, no plugins are returned. |
999 |
* |
|
9 | 1000 |
* The default directory is `wp-content/plugins`. To change the default |
5 | 1001 |
* directory manually, define `WP_PLUGIN_DIR` and `WP_PLUGIN_URL` |
9 | 1002 |
* in `wp-config.php`. |
0 | 1003 |
* |
5 | 1004 |
* @since 3.0.0 |
0 | 1005 |
* @access private |
5 | 1006 |
* |
16 | 1007 |
* @return string[] Array of paths to plugin files relative to the plugins directory. |
0 | 1008 |
*/ |
1009 |
function wp_get_active_and_valid_plugins() { |
|
9 | 1010 |
$plugins = array(); |
0 | 1011 |
$active_plugins = (array) get_option( 'active_plugins', array() ); |
1012 |
||
16 | 1013 |
// Check for hacks file if the option is enabled. |
0 | 1014 |
if ( get_option( 'hack_file' ) && file_exists( ABSPATH . 'my-hacks.php' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1015 |
_deprecated_file( 'my-hacks.php', '1.5.0' ); |
0 | 1016 |
array_unshift( $plugins, ABSPATH . 'my-hacks.php' ); |
1017 |
} |
|
1018 |
||
9 | 1019 |
if ( empty( $active_plugins ) || wp_installing() ) { |
0 | 1020 |
return $plugins; |
9 | 1021 |
} |
0 | 1022 |
|
1023 |
$network_plugins = is_multisite() ? wp_get_active_network_plugins() : false; |
|
1024 |
||
1025 |
foreach ( $active_plugins as $plugin ) { |
|
16 | 1026 |
if ( ! validate_file( $plugin ) // $plugin must validate as file. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1027 |
&& str_ends_with( $plugin, '.php' ) // $plugin must end with '.php'. |
16 | 1028 |
&& file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist. |
1029 |
// Not already included as a network plugin. |
|
1030 |
&& ( ! $network_plugins || ! in_array( WP_PLUGIN_DIR . '/' . $plugin, $network_plugins, true ) ) |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1031 |
) { |
9 | 1032 |
$plugins[] = WP_PLUGIN_DIR . '/' . $plugin; |
1033 |
} |
|
1034 |
} |
|
1035 |
||
1036 |
/* |
|
1037 |
* Remove plugins from the list of active plugins when we're on an endpoint |
|
1038 |
* that should be protected against WSODs and the plugin is paused. |
|
1039 |
*/ |
|
1040 |
if ( wp_is_recovery_mode() ) { |
|
1041 |
$plugins = wp_skip_paused_plugins( $plugins ); |
|
1042 |
} |
|
1043 |
||
1044 |
return $plugins; |
|
1045 |
} |
|
1046 |
||
1047 |
/** |
|
1048 |
* Filters a given list of plugins, removing any paused plugins from it. |
|
1049 |
* |
|
1050 |
* @since 5.2.0 |
|
1051 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1052 |
* @global WP_Paused_Extensions_Storage $_paused_plugins |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1053 |
* |
16 | 1054 |
* @param string[] $plugins Array of absolute plugin main file paths. |
1055 |
* @return string[] Filtered array of plugins, without any paused plugins. |
|
9 | 1056 |
*/ |
1057 |
function wp_skip_paused_plugins( array $plugins ) { |
|
1058 |
$paused_plugins = wp_paused_plugins()->get_all(); |
|
1059 |
||
1060 |
if ( empty( $paused_plugins ) ) { |
|
1061 |
return $plugins; |
|
1062 |
} |
|
1063 |
||
1064 |
foreach ( $plugins as $index => $plugin ) { |
|
1065 |
list( $plugin ) = explode( '/', plugin_basename( $plugin ) ); |
|
1066 |
||
1067 |
if ( array_key_exists( $plugin, $paused_plugins ) ) { |
|
1068 |
unset( $plugins[ $index ] ); |
|
1069 |
||
1070 |
// Store list of paused plugins for displaying an admin notice. |
|
1071 |
$GLOBALS['_paused_plugins'][ $plugin ] = $paused_plugins[ $plugin ]; |
|
1072 |
} |
|
1073 |
} |
|
1074 |
||
1075 |
return $plugins; |
|
1076 |
} |
|
1077 |
||
1078 |
/** |
|
1079 |
* Retrieves an array of active and valid themes. |
|
1080 |
* |
|
1081 |
* While upgrading or installing WordPress, no themes are returned. |
|
1082 |
* |
|
1083 |
* @since 5.1.0 |
|
1084 |
* @access private |
|
1085 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1086 |
* @global string $pagenow The filename of the current screen. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1087 |
* @global string $wp_stylesheet_path Path to current theme's stylesheet directory. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1088 |
* @global string $wp_template_path Path to current theme's template directory. |
19 | 1089 |
* |
16 | 1090 |
* @return string[] Array of absolute paths to theme directories. |
9 | 1091 |
*/ |
1092 |
function wp_get_active_and_valid_themes() { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1093 |
global $pagenow, $wp_stylesheet_path, $wp_template_path; |
9 | 1094 |
|
1095 |
$themes = array(); |
|
1096 |
||
1097 |
if ( wp_installing() && 'wp-activate.php' !== $pagenow ) { |
|
1098 |
return $themes; |
|
1099 |
} |
|
1100 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1101 |
if ( is_child_theme() ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1102 |
$themes[] = $wp_stylesheet_path; |
9 | 1103 |
} |
1104 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1105 |
$themes[] = $wp_template_path; |
9 | 1106 |
|
1107 |
/* |
|
1108 |
* Remove themes from the list of active themes when we're on an endpoint |
|
1109 |
* that should be protected against WSODs and the theme is paused. |
|
1110 |
*/ |
|
1111 |
if ( wp_is_recovery_mode() ) { |
|
1112 |
$themes = wp_skip_paused_themes( $themes ); |
|
1113 |
||
1114 |
// If no active and valid themes exist, skip loading themes. |
|
1115 |
if ( empty( $themes ) ) { |
|
1116 |
add_filter( 'wp_using_themes', '__return_false' ); |
|
1117 |
} |
|
1118 |
} |
|
1119 |
||
1120 |
return $themes; |
|
1121 |
} |
|
1122 |
||
1123 |
/** |
|
1124 |
* Filters a given list of themes, removing any paused themes from it. |
|
1125 |
* |
|
1126 |
* @since 5.2.0 |
|
1127 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1128 |
* @global WP_Paused_Extensions_Storage $_paused_themes |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1129 |
* |
16 | 1130 |
* @param string[] $themes Array of absolute theme directory paths. |
1131 |
* @return string[] Filtered array of absolute paths to themes, without any paused themes. |
|
9 | 1132 |
*/ |
1133 |
function wp_skip_paused_themes( array $themes ) { |
|
1134 |
$paused_themes = wp_paused_themes()->get_all(); |
|
1135 |
||
1136 |
if ( empty( $paused_themes ) ) { |
|
1137 |
return $themes; |
|
0 | 1138 |
} |
9 | 1139 |
|
1140 |
foreach ( $themes as $index => $theme ) { |
|
1141 |
$theme = basename( $theme ); |
|
1142 |
||
1143 |
if ( array_key_exists( $theme, $paused_themes ) ) { |
|
1144 |
unset( $themes[ $index ] ); |
|
1145 |
||
1146 |
// Store list of paused themes for displaying an admin notice. |
|
1147 |
$GLOBALS['_paused_themes'][ $theme ] = $paused_themes[ $theme ]; |
|
1148 |
} |
|
1149 |
} |
|
1150 |
||
1151 |
return $themes; |
|
1152 |
} |
|
1153 |
||
1154 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1155 |
* Determines whether WordPress is in Recovery Mode. |
9 | 1156 |
* |
1157 |
* In this mode, plugins or themes that cause WSODs will be paused. |
|
1158 |
* |
|
1159 |
* @since 5.2.0 |
|
1160 |
* |
|
1161 |
* @return bool |
|
1162 |
*/ |
|
1163 |
function wp_is_recovery_mode() { |
|
1164 |
return wp_recovery_mode()->is_active(); |
|
1165 |
} |
|
1166 |
||
1167 |
/** |
|
1168 |
* Determines whether we are currently on an endpoint that should be protected against WSODs. |
|
1169 |
* |
|
1170 |
* @since 5.2.0 |
|
1171 |
* |
|
19 | 1172 |
* @global string $pagenow The filename of the current screen. |
18 | 1173 |
* |
9 | 1174 |
* @return bool True if the current endpoint should be protected. |
1175 |
*/ |
|
1176 |
function is_protected_endpoint() { |
|
1177 |
// Protect login pages. |
|
1178 |
if ( isset( $GLOBALS['pagenow'] ) && 'wp-login.php' === $GLOBALS['pagenow'] ) { |
|
1179 |
return true; |
|
1180 |
} |
|
1181 |
||
1182 |
// Protect the admin backend. |
|
1183 |
if ( is_admin() && ! wp_doing_ajax() ) { |
|
1184 |
return true; |
|
1185 |
} |
|
1186 |
||
16 | 1187 |
// Protect Ajax actions that could help resolve a fatal error should be available. |
9 | 1188 |
if ( is_protected_ajax_action() ) { |
1189 |
return true; |
|
1190 |
} |
|
1191 |
||
1192 |
/** |
|
1193 |
* Filters whether the current request is against a protected endpoint. |
|
1194 |
* |
|
1195 |
* This filter is only fired when an endpoint is requested which is not already protected by |
|
1196 |
* WordPress core. As such, it exclusively allows providing further protected endpoints in |
|
16 | 1197 |
* addition to the admin backend, login pages and protected Ajax actions. |
9 | 1198 |
* |
1199 |
* @since 5.2.0 |
|
1200 |
* |
|
16 | 1201 |
* @param bool $is_protected_endpoint Whether the currently requested endpoint is protected. |
1202 |
* Default false. |
|
9 | 1203 |
*/ |
1204 |
return (bool) apply_filters( 'is_protected_endpoint', false ); |
|
1205 |
} |
|
1206 |
||
1207 |
/** |
|
16 | 1208 |
* Determines whether we are currently handling an Ajax action that should be protected against WSODs. |
9 | 1209 |
* |
1210 |
* @since 5.2.0 |
|
1211 |
* |
|
16 | 1212 |
* @return bool True if the current Ajax action should be protected. |
9 | 1213 |
*/ |
1214 |
function is_protected_ajax_action() { |
|
1215 |
if ( ! wp_doing_ajax() ) { |
|
1216 |
return false; |
|
1217 |
} |
|
1218 |
||
1219 |
if ( ! isset( $_REQUEST['action'] ) ) { |
|
1220 |
return false; |
|
1221 |
} |
|
1222 |
||
1223 |
$actions_to_protect = array( |
|
1224 |
'edit-theme-plugin-file', // Saving changes in the core code editor. |
|
1225 |
'heartbeat', // Keep the heart beating. |
|
1226 |
'install-plugin', // Installing a new plugin. |
|
1227 |
'install-theme', // Installing a new theme. |
|
1228 |
'search-plugins', // Searching in the list of plugins. |
|
1229 |
'search-install-plugins', // Searching for a plugin in the plugin install screen. |
|
1230 |
'update-plugin', // Update an existing plugin. |
|
1231 |
'update-theme', // Update an existing theme. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1232 |
'activate-plugin', // Activating an existing plugin. |
9 | 1233 |
); |
1234 |
||
1235 |
/** |
|
16 | 1236 |
* Filters the array of protected Ajax actions. |
9 | 1237 |
* |
16 | 1238 |
* This filter is only fired when doing Ajax and the Ajax request has an 'action' property. |
9 | 1239 |
* |
1240 |
* @since 5.2.0 |
|
1241 |
* |
|
16 | 1242 |
* @param string[] $actions_to_protect Array of strings with Ajax actions to protect. |
9 | 1243 |
*/ |
1244 |
$actions_to_protect = (array) apply_filters( 'wp_protected_ajax_actions', $actions_to_protect ); |
|
1245 |
||
1246 |
if ( ! in_array( $_REQUEST['action'], $actions_to_protect, true ) ) { |
|
1247 |
return false; |
|
1248 |
} |
|
1249 |
||
1250 |
return true; |
|
0 | 1251 |
} |
1252 |
||
1253 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1254 |
* Sets internal encoding. |
0 | 1255 |
* |
5 | 1256 |
* In most cases the default internal encoding is latin1, which is |
1257 |
* of no use, since we want to use the `mb_` functions for `utf-8` strings. |
|
0 | 1258 |
* |
5 | 1259 |
* @since 3.0.0 |
0 | 1260 |
* @access private |
1261 |
*/ |
|
1262 |
function wp_set_internal_encoding() { |
|
1263 |
if ( function_exists( 'mb_internal_encoding' ) ) { |
|
1264 |
$charset = get_option( 'blog_charset' ); |
|
16 | 1265 |
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged |
9 | 1266 |
if ( ! $charset || ! @mb_internal_encoding( $charset ) ) { |
0 | 1267 |
mb_internal_encoding( 'UTF-8' ); |
9 | 1268 |
} |
0 | 1269 |
} |
1270 |
} |
|
1271 |
||
1272 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1273 |
* Adds magic quotes to `$_GET`, `$_POST`, `$_COOKIE`, and `$_SERVER`. |
0 | 1274 |
* |
5 | 1275 |
* Also forces `$_REQUEST` to be `$_GET + $_POST`. If `$_SERVER`, |
1276 |
* `$_COOKIE`, or `$_ENV` are needed, use those superglobals directly. |
|
0 | 1277 |
* |
5 | 1278 |
* @since 3.0.0 |
0 | 1279 |
* @access private |
1280 |
*/ |
|
1281 |
function wp_magic_quotes() { |
|
1282 |
// Escape with wpdb. |
|
9 | 1283 |
$_GET = add_magic_quotes( $_GET ); |
1284 |
$_POST = add_magic_quotes( $_POST ); |
|
0 | 1285 |
$_COOKIE = add_magic_quotes( $_COOKIE ); |
1286 |
$_SERVER = add_magic_quotes( $_SERVER ); |
|
1287 |
||
1288 |
// Force REQUEST to be GET + POST. |
|
1289 |
$_REQUEST = array_merge( $_GET, $_POST ); |
|
1290 |
} |
|
1291 |
||
1292 |
/** |
|
1293 |
* Runs just before PHP shuts down execution. |
|
1294 |
* |
|
5 | 1295 |
* @since 1.2.0 |
0 | 1296 |
* @access private |
1297 |
*/ |
|
1298 |
function shutdown_action_hook() { |
|
1299 |
/** |
|
1300 |
* Fires just before PHP shuts down execution. |
|
1301 |
* |
|
1302 |
* @since 1.2.0 |
|
1303 |
*/ |
|
1304 |
do_action( 'shutdown' ); |
|
5 | 1305 |
|
0 | 1306 |
wp_cache_close(); |
1307 |
} |
|
1308 |
||
1309 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1310 |
* Clones an object. |
0 | 1311 |
* |
1312 |
* @since 2.7.0 |
|
5 | 1313 |
* @deprecated 3.2.0 |
0 | 1314 |
* |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1315 |
* @param object $input_object The object to clone. |
5 | 1316 |
* @return object The cloned object. |
0 | 1317 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1318 |
function wp_clone( $input_object ) { |
16 | 1319 |
// Use parens for clone to accommodate PHP 4. See #17880. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1320 |
return clone( $input_object ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1321 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1322 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1323 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1324 |
* Determines whether the current request is for the login screen. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1325 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1326 |
* @since 6.1.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1327 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1328 |
* @see wp_login_url() |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1329 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1330 |
* @return bool True if inside WordPress login screen, false otherwise. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1331 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1332 |
function is_login() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1333 |
return false !== stripos( wp_login_url(), $_SERVER['SCRIPT_NAME'] ); |
0 | 1334 |
} |
1335 |
||
1336 |
/** |
|
9 | 1337 |
* Determines whether the current request is for an administrative interface page. |
0 | 1338 |
* |
9 | 1339 |
* Does not check if the user is an administrator; use current_user_can() |
5 | 1340 |
* for checking roles and capabilities. |
0 | 1341 |
* |
9 | 1342 |
* For more information on this and similar theme functions, check out |
1343 |
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ |
|
1344 |
* Conditional Tags} article in the Theme Developer Handbook. |
|
1345 |
* |
|
0 | 1346 |
* @since 1.5.1 |
1347 |
* |
|
16 | 1348 |
* @global WP_Screen $current_screen WordPress current screen object. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1349 |
* |
5 | 1350 |
* @return bool True if inside WordPress administration interface, false otherwise. |
0 | 1351 |
*/ |
1352 |
function is_admin() { |
|
9 | 1353 |
if ( isset( $GLOBALS['current_screen'] ) ) { |
0 | 1354 |
return $GLOBALS['current_screen']->in_admin(); |
9 | 1355 |
} elseif ( defined( 'WP_ADMIN' ) ) { |
0 | 1356 |
return WP_ADMIN; |
9 | 1357 |
} |
0 | 1358 |
|
1359 |
return false; |
|
1360 |
} |
|
1361 |
||
1362 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1363 |
* Determines whether the current request is for a site's administrative interface. |
0 | 1364 |
* |
5 | 1365 |
* e.g. `/wp-admin/` |
1366 |
* |
|
9 | 1367 |
* Does not check if the user is an administrator; use current_user_can() |
5 | 1368 |
* for checking roles and capabilities. |
0 | 1369 |
* |
1370 |
* @since 3.1.0 |
|
1371 |
* |
|
16 | 1372 |
* @global WP_Screen $current_screen WordPress current screen object. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1373 |
* |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1374 |
* @return bool True if inside WordPress site administration pages. |
0 | 1375 |
*/ |
1376 |
function is_blog_admin() { |
|
9 | 1377 |
if ( isset( $GLOBALS['current_screen'] ) ) { |
0 | 1378 |
return $GLOBALS['current_screen']->in_admin( 'site' ); |
9 | 1379 |
} elseif ( defined( 'WP_BLOG_ADMIN' ) ) { |
0 | 1380 |
return WP_BLOG_ADMIN; |
9 | 1381 |
} |
0 | 1382 |
|
1383 |
return false; |
|
1384 |
} |
|
1385 |
||
1386 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1387 |
* Determines whether the current request is for the network administrative interface. |
0 | 1388 |
* |
5 | 1389 |
* e.g. `/wp-admin/network/` |
1390 |
* |
|
9 | 1391 |
* Does not check if the user is an administrator; use current_user_can() |
5 | 1392 |
* for checking roles and capabilities. |
0 | 1393 |
* |
16 | 1394 |
* Does not check if the site is a Multisite network; use is_multisite() |
1395 |
* for checking if Multisite is enabled. |
|
1396 |
* |
|
0 | 1397 |
* @since 3.1.0 |
1398 |
* |
|
16 | 1399 |
* @global WP_Screen $current_screen WordPress current screen object. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1400 |
* |
0 | 1401 |
* @return bool True if inside WordPress network administration pages. |
1402 |
*/ |
|
1403 |
function is_network_admin() { |
|
9 | 1404 |
if ( isset( $GLOBALS['current_screen'] ) ) { |
0 | 1405 |
return $GLOBALS['current_screen']->in_admin( 'network' ); |
9 | 1406 |
} elseif ( defined( 'WP_NETWORK_ADMIN' ) ) { |
0 | 1407 |
return WP_NETWORK_ADMIN; |
9 | 1408 |
} |
0 | 1409 |
|
1410 |
return false; |
|
1411 |
} |
|
1412 |
||
1413 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1414 |
* Determines whether the current request is for a user admin screen. |
5 | 1415 |
* |
1416 |
* e.g. `/wp-admin/user/` |
|
0 | 1417 |
* |
9 | 1418 |
* Does not check if the user is an administrator; use current_user_can() |
1419 |
* for checking roles and capabilities. |
|
0 | 1420 |
* |
1421 |
* @since 3.1.0 |
|
1422 |
* |
|
16 | 1423 |
* @global WP_Screen $current_screen WordPress current screen object. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1424 |
* |
0 | 1425 |
* @return bool True if inside WordPress user administration pages. |
1426 |
*/ |
|
1427 |
function is_user_admin() { |
|
9 | 1428 |
if ( isset( $GLOBALS['current_screen'] ) ) { |
0 | 1429 |
return $GLOBALS['current_screen']->in_admin( 'user' ); |
9 | 1430 |
} elseif ( defined( 'WP_USER_ADMIN' ) ) { |
0 | 1431 |
return WP_USER_ADMIN; |
9 | 1432 |
} |
0 | 1433 |
|
1434 |
return false; |
|
1435 |
} |
|
1436 |
||
1437 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1438 |
* Determines whether Multisite is enabled. |
0 | 1439 |
* |
1440 |
* @since 3.0.0 |
|
1441 |
* |
|
5 | 1442 |
* @return bool True if Multisite is enabled, false otherwise. |
0 | 1443 |
*/ |
1444 |
function is_multisite() { |
|
9 | 1445 |
if ( defined( 'MULTISITE' ) ) { |
0 | 1446 |
return MULTISITE; |
9 | 1447 |
} |
0 | 1448 |
|
9 | 1449 |
if ( defined( 'SUBDOMAIN_INSTALL' ) || defined( 'VHOST' ) || defined( 'SUNRISE' ) ) { |
0 | 1450 |
return true; |
9 | 1451 |
} |
0 | 1452 |
|
1453 |
return false; |
|
1454 |
} |
|
1455 |
||
1456 |
/** |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
1457 |
* Converts a value to non-negative integer. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
1458 |
* |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
1459 |
* @since 2.5.0 |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
1460 |
* |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
1461 |
* @param mixed $maybeint Data you wish to have converted to a non-negative integer. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
1462 |
* @return int A non-negative integer. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
1463 |
*/ |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
1464 |
function absint( $maybeint ) { |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
1465 |
return abs( (int) $maybeint ); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
1466 |
} |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
1467 |
|
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
1468 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1469 |
* Retrieves the current site ID. |
0 | 1470 |
* |
1471 |
* @since 3.1.0 |
|
1472 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1473 |
* @global int $blog_id |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1474 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1475 |
* @return int Site ID. |
0 | 1476 |
*/ |
1477 |
function get_current_blog_id() { |
|
1478 |
global $blog_id; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1479 |
|
9 | 1480 |
return absint( $blog_id ); |
0 | 1481 |
} |
1482 |
||
1483 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1484 |
* Retrieves the current network ID. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1485 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1486 |
* @since 4.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1487 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1488 |
* @return int The ID of the current network. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1489 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1490 |
function get_current_network_id() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1491 |
if ( ! is_multisite() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1492 |
return 1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1493 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1494 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1495 |
$current_network = get_network(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1496 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1497 |
if ( ! isset( $current_network->id ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1498 |
return get_main_network_id(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1499 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1500 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1501 |
return absint( $current_network->id ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1502 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1503 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1504 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1505 |
* Attempts an early load of translations. |
0 | 1506 |
* |
5 | 1507 |
* Used for errors encountered during the initial loading process, before |
1508 |
* the locale has been properly detected and loaded. |
|
0 | 1509 |
* |
5 | 1510 |
* Designed for unusual load sequences (like setup-config.php) or for when |
1511 |
* the script will then terminate with an error, otherwise there is a risk |
|
1512 |
* that a file can be double-included. |
|
0 | 1513 |
* |
1514 |
* @since 3.4.0 |
|
1515 |
* @access private |
|
5 | 1516 |
* |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1517 |
* @global WP_Textdomain_Registry $wp_textdomain_registry WordPress Textdomain Registry. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1518 |
* @global WP_Locale $wp_locale WordPress date and time locale object. |
0 | 1519 |
*/ |
1520 |
function wp_load_translations_early() { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1521 |
global $wp_textdomain_registry, $wp_locale; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1522 |
static $loaded = false; |
0 | 1523 |
|
9 | 1524 |
if ( $loaded ) { |
0 | 1525 |
return; |
9 | 1526 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1527 |
|
0 | 1528 |
$loaded = true; |
1529 |
||
9 | 1530 |
if ( function_exists( 'did_action' ) && did_action( 'init' ) ) { |
0 | 1531 |
return; |
9 | 1532 |
} |
0 | 1533 |
|
16 | 1534 |
// We need $wp_local_package. |
0 | 1535 |
require ABSPATH . WPINC . '/version.php'; |
1536 |
||
16 | 1537 |
// Translation and localization. |
0 | 1538 |
require_once ABSPATH . WPINC . '/pomo/mo.php'; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1539 |
require_once ABSPATH . WPINC . '/l10n/class-wp-translation-controller.php'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1540 |
require_once ABSPATH . WPINC . '/l10n/class-wp-translations.php'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1541 |
require_once ABSPATH . WPINC . '/l10n/class-wp-translation-file.php'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1542 |
require_once ABSPATH . WPINC . '/l10n/class-wp-translation-file-mo.php'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1543 |
require_once ABSPATH . WPINC . '/l10n/class-wp-translation-file-php.php'; |
0 | 1544 |
require_once ABSPATH . WPINC . '/l10n.php'; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1545 |
require_once ABSPATH . WPINC . '/class-wp-textdomain-registry.php'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1546 |
require_once ABSPATH . WPINC . '/class-wp-locale.php'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1547 |
require_once ABSPATH . WPINC . '/class-wp-locale-switcher.php'; |
0 | 1548 |
|
16 | 1549 |
// General libraries. |
0 | 1550 |
require_once ABSPATH . WPINC . '/plugin.php'; |
1551 |
||
16 | 1552 |
$locales = array(); |
1553 |
$locations = array(); |
|
0 | 1554 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1555 |
if ( ! $wp_textdomain_registry instanceof WP_Textdomain_Registry ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1556 |
$wp_textdomain_registry = new WP_Textdomain_Registry(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1557 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1558 |
|
0 | 1559 |
while ( true ) { |
1560 |
if ( defined( 'WPLANG' ) ) { |
|
16 | 1561 |
if ( '' === WPLANG ) { |
0 | 1562 |
break; |
9 | 1563 |
} |
0 | 1564 |
$locales[] = WPLANG; |
1565 |
} |
|
1566 |
||
9 | 1567 |
if ( isset( $wp_local_package ) ) { |
0 | 1568 |
$locales[] = $wp_local_package; |
9 | 1569 |
} |
0 | 1570 |
|
9 | 1571 |
if ( ! $locales ) { |
0 | 1572 |
break; |
9 | 1573 |
} |
0 | 1574 |
|
9 | 1575 |
if ( defined( 'WP_LANG_DIR' ) && @is_dir( WP_LANG_DIR ) ) { |
0 | 1576 |
$locations[] = WP_LANG_DIR; |
9 | 1577 |
} |
0 | 1578 |
|
9 | 1579 |
if ( defined( 'WP_CONTENT_DIR' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) ) { |
0 | 1580 |
$locations[] = WP_CONTENT_DIR . '/languages'; |
9 | 1581 |
} |
0 | 1582 |
|
9 | 1583 |
if ( @is_dir( ABSPATH . 'wp-content/languages' ) ) { |
0 | 1584 |
$locations[] = ABSPATH . 'wp-content/languages'; |
9 | 1585 |
} |
0 | 1586 |
|
9 | 1587 |
if ( @is_dir( ABSPATH . WPINC . '/languages' ) ) { |
0 | 1588 |
$locations[] = ABSPATH . WPINC . '/languages'; |
9 | 1589 |
} |
0 | 1590 |
|
9 | 1591 |
if ( ! $locations ) { |
0 | 1592 |
break; |
9 | 1593 |
} |
0 | 1594 |
|
1595 |
$locations = array_unique( $locations ); |
|
1596 |
||
1597 |
foreach ( $locales as $locale ) { |
|
1598 |
foreach ( $locations as $location ) { |
|
1599 |
if ( file_exists( $location . '/' . $locale . '.mo' ) ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1600 |
load_textdomain( 'default', $location . '/' . $locale . '.mo', $locale ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1601 |
|
9 | 1602 |
if ( defined( 'WP_SETUP_CONFIG' ) && file_exists( $location . '/admin-' . $locale . '.mo' ) ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1603 |
load_textdomain( 'default', $location . '/admin-' . $locale . '.mo', $locale ); |
9 | 1604 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1605 |
|
0 | 1606 |
break 2; |
1607 |
} |
|
1608 |
} |
|
1609 |
} |
|
1610 |
||
1611 |
break; |
|
1612 |
} |
|
1613 |
||
1614 |
$wp_locale = new WP_Locale(); |
|
1615 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1616 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1617 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1618 |
* Checks or sets whether WordPress is in "installation" mode. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1619 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1620 |
* If the `WP_INSTALLING` constant is defined during the bootstrap, `wp_installing()` will default to `true`. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1621 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1622 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1623 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1624 |
* @param bool $is_installing Optional. True to set WP into Installing mode, false to turn Installing mode off. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1625 |
* Omit this parameter if you only want to fetch the current status. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1626 |
* @return bool True if WP is installing, otherwise false. When a `$is_installing` is passed, the function will |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1627 |
* report whether WP was in installing mode prior to the change to `$is_installing`. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1628 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1629 |
function wp_installing( $is_installing = null ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1630 |
static $installing = null; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1631 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1632 |
// Support for the `WP_INSTALLING` constant, defined before WP is loaded. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1633 |
if ( is_null( $installing ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1634 |
$installing = defined( 'WP_INSTALLING' ) && WP_INSTALLING; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1635 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1636 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1637 |
if ( ! is_null( $is_installing ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1638 |
$old_installing = $installing; |
9 | 1639 |
$installing = $is_installing; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1640 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1641 |
return (bool) $old_installing; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1642 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1643 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1644 |
return (bool) $installing; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1645 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1646 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1647 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1648 |
* Determines if SSL is used. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1649 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1650 |
* @since 2.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1651 |
* @since 4.6.0 Moved from functions.php to load.php. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1652 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1653 |
* @return bool True if SSL, otherwise false. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1654 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1655 |
function is_ssl() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1656 |
if ( isset( $_SERVER['HTTPS'] ) ) { |
16 | 1657 |
if ( 'on' === strtolower( $_SERVER['HTTPS'] ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1658 |
return true; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1659 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1660 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1661 |
if ( '1' === (string) $_SERVER['HTTPS'] ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1662 |
return true; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1663 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1664 |
} elseif ( isset( $_SERVER['SERVER_PORT'] ) && ( '443' === (string) $_SERVER['SERVER_PORT'] ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1665 |
return true; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1666 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1667 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1668 |
return false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1669 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1670 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1671 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1672 |
* Converts a shorthand byte value to an integer byte value. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1673 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1674 |
* @since 2.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1675 |
* @since 4.6.0 Moved from media.php to load.php. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1676 |
* |
16 | 1677 |
* @link https://www.php.net/manual/en/function.ini-get.php |
1678 |
* @link https://www.php.net/manual/en/faq.using.php#faq.using.shorthandbytes |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1679 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1680 |
* @param string $value A (PHP ini) byte value, either shorthand or ordinary. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1681 |
* @return int An integer byte value. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1682 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1683 |
function wp_convert_hr_to_bytes( $value ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1684 |
$value = strtolower( trim( $value ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1685 |
$bytes = (int) $value; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1686 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1687 |
if ( str_contains( $value, 'g' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1688 |
$bytes *= GB_IN_BYTES; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1689 |
} elseif ( str_contains( $value, 'm' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1690 |
$bytes *= MB_IN_BYTES; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1691 |
} elseif ( str_contains( $value, 'k' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1692 |
$bytes *= KB_IN_BYTES; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1693 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1694 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1695 |
// Deal with large (float) values which run into the maximum integer size. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1696 |
return min( $bytes, PHP_INT_MAX ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1697 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1698 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1699 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1700 |
* Determines whether a PHP ini value is changeable at runtime. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1701 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1702 |
* @since 4.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1703 |
* |
16 | 1704 |
* @link https://www.php.net/manual/en/function.ini-get-all.php |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1705 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1706 |
* @param string $setting The name of the ini setting to check. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1707 |
* @return bool True if the value is changeable at runtime. False otherwise. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1708 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1709 |
function wp_is_ini_value_changeable( $setting ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1710 |
static $ini_all; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1711 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1712 |
if ( ! isset( $ini_all ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1713 |
$ini_all = false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1714 |
// Sometimes `ini_get_all()` is disabled via the `disable_functions` option for "security purposes". |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1715 |
if ( function_exists( 'ini_get_all' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1716 |
$ini_all = ini_get_all(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1717 |
} |
9 | 1718 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1719 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1720 |
if ( isset( $ini_all[ $setting ]['access'] ) |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
1721 |
&& ( INI_ALL === $ini_all[ $setting ]['access'] || INI_USER === $ini_all[ $setting ]['access'] ) |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1722 |
) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1723 |
return true; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1724 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1725 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1726 |
// If we were unable to retrieve the details, fail gracefully to assume it's changeable. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1727 |
if ( ! is_array( $ini_all ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1728 |
return true; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1729 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1730 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1731 |
return false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1732 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1733 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1734 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1735 |
* Determines whether the current request is a WordPress Ajax request. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1736 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1737 |
* @since 4.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1738 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1739 |
* @return bool True if it's a WordPress Ajax request, false otherwise. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1740 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1741 |
function wp_doing_ajax() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1742 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1743 |
* Filters whether the current request is a WordPress Ajax request. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1744 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1745 |
* @since 4.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1746 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1747 |
* @param bool $wp_doing_ajax Whether the current request is a WordPress Ajax request. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1748 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1749 |
return apply_filters( 'wp_doing_ajax', defined( 'DOING_AJAX' ) && DOING_AJAX ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1750 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1751 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1752 |
/** |
9 | 1753 |
* Determines whether the current request should use themes. |
1754 |
* |
|
1755 |
* @since 5.1.0 |
|
1756 |
* |
|
1757 |
* @return bool True if themes should be used, false otherwise. |
|
1758 |
*/ |
|
1759 |
function wp_using_themes() { |
|
1760 |
/** |
|
1761 |
* Filters whether the current request should use themes. |
|
1762 |
* |
|
1763 |
* @since 5.1.0 |
|
1764 |
* |
|
1765 |
* @param bool $wp_using_themes Whether the current request should use themes. |
|
1766 |
*/ |
|
1767 |
return apply_filters( 'wp_using_themes', defined( 'WP_USE_THEMES' ) && WP_USE_THEMES ); |
|
1768 |
} |
|
1769 |
||
1770 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1771 |
* Determines whether the current request is a WordPress cron request. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1772 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1773 |
* @since 4.8.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1774 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1775 |
* @return bool True if it's a WordPress cron request, false otherwise. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1776 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1777 |
function wp_doing_cron() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1778 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1779 |
* Filters whether the current request is a WordPress cron request. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1780 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1781 |
* @since 4.8.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1782 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1783 |
* @param bool $wp_doing_cron Whether the current request is a WordPress cron request. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1784 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1785 |
return apply_filters( 'wp_doing_cron', defined( 'DOING_CRON' ) && DOING_CRON ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1786 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1787 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1788 |
/** |
18 | 1789 |
* Checks whether the given variable is a WordPress Error. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1790 |
* |
18 | 1791 |
* Returns whether `$thing` is an instance of the `WP_Error` class. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1792 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1793 |
* @since 2.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1794 |
* |
18 | 1795 |
* @param mixed $thing The variable to check. |
1796 |
* @return bool Whether the variable is an instance of WP_Error. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1797 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1798 |
function is_wp_error( $thing ) { |
18 | 1799 |
$is_wp_error = ( $thing instanceof WP_Error ); |
1800 |
||
1801 |
if ( $is_wp_error ) { |
|
1802 |
/** |
|
1803 |
* Fires when `is_wp_error()` is called and its parameter is an instance of `WP_Error`. |
|
1804 |
* |
|
1805 |
* @since 5.6.0 |
|
1806 |
* |
|
1807 |
* @param WP_Error $thing The error object passed to `is_wp_error()`. |
|
1808 |
*/ |
|
1809 |
do_action( 'is_wp_error_instance', $thing ); |
|
1810 |
} |
|
1811 |
||
1812 |
return $is_wp_error; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1813 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1814 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1815 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1816 |
* Determines whether file modifications are allowed. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1817 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1818 |
* @since 4.8.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1819 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1820 |
* @param string $context The usage context. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1821 |
* @return bool True if file modification is allowed, false otherwise. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1822 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1823 |
function wp_is_file_mod_allowed( $context ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1824 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1825 |
* Filters whether file modifications are allowed. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1826 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1827 |
* @since 4.8.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1828 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1829 |
* @param bool $file_mod_allowed Whether file modifications are allowed. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1830 |
* @param string $context The usage context. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1831 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1832 |
return apply_filters( 'file_mod_allowed', ! defined( 'DISALLOW_FILE_MODS' ) || ! DISALLOW_FILE_MODS, $context ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1833 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1834 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1835 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1836 |
* Starts scraping edited file errors. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1837 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1838 |
* @since 4.9.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1839 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1840 |
function wp_start_scraping_edited_file_errors() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1841 |
if ( ! isset( $_REQUEST['wp_scrape_key'] ) || ! isset( $_REQUEST['wp_scrape_nonce'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1842 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1843 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1844 |
|
9 | 1845 |
$key = substr( sanitize_key( wp_unslash( $_REQUEST['wp_scrape_key'] ) ), 0, 32 ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1846 |
$nonce = wp_unslash( $_REQUEST['wp_scrape_nonce'] ); |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
1847 |
if ( empty( $key ) || empty( $nonce ) ) { |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
1848 |
return; |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
1849 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1850 |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
1851 |
$transient = get_transient( 'scrape_key_' . $key ); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
1852 |
if ( false === $transient ) { |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
1853 |
return; |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
1854 |
} |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
1855 |
|
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
1856 |
if ( $transient !== $nonce ) { |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
1857 |
if ( ! headers_sent() ) { |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
1858 |
header( 'X-Robots-Tag: noindex' ); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
1859 |
nocache_headers(); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
1860 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1861 |
echo "###### wp_scraping_result_start:$key ######"; |
9 | 1862 |
echo wp_json_encode( |
1863 |
array( |
|
1864 |
'code' => 'scrape_nonce_failure', |
|
18 | 1865 |
'message' => __( 'Scrape key check failed. Please try again.' ), |
9 | 1866 |
) |
1867 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1868 |
echo "###### wp_scraping_result_end:$key ######"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1869 |
die(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1870 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1871 |
|
9 | 1872 |
if ( ! defined( 'WP_SANDBOX_SCRAPING' ) ) { |
1873 |
define( 'WP_SANDBOX_SCRAPING', true ); |
|
1874 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1875 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1876 |
register_shutdown_function( 'wp_finalize_scraping_edited_file_errors', $key ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1877 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1878 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1879 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1880 |
* Finalizes scraping for edited file errors. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1881 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1882 |
* @since 4.9.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1883 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1884 |
* @param string $scrape_key Scrape key. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1885 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1886 |
function wp_finalize_scraping_edited_file_errors( $scrape_key ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1887 |
$error = error_get_last(); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1888 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1889 |
echo "\n###### wp_scraping_result_start:$scrape_key ######\n"; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1890 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1891 |
if ( ! empty( $error ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1892 |
&& in_array( $error['type'], array( E_CORE_ERROR, E_COMPILE_ERROR, E_ERROR, E_PARSE, E_USER_ERROR, E_RECOVERABLE_ERROR ), true ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1893 |
) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1894 |
$error = str_replace( ABSPATH, '', $error ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1895 |
echo wp_json_encode( $error ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1896 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1897 |
echo wp_json_encode( true ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1898 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1899 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1900 |
echo "\n###### wp_scraping_result_end:$scrape_key ######\n"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1901 |
} |
9 | 1902 |
|
1903 |
/** |
|
1904 |
* Checks whether current request is a JSON request, or is expecting a JSON response. |
|
1905 |
* |
|
1906 |
* @since 5.0.0 |
|
1907 |
* |
|
16 | 1908 |
* @return bool True if `Accepts` or `Content-Type` headers contain `application/json`. |
1909 |
* False otherwise. |
|
9 | 1910 |
*/ |
1911 |
function wp_is_json_request() { |
|
18 | 1912 |
if ( isset( $_SERVER['HTTP_ACCEPT'] ) && wp_is_json_media_type( $_SERVER['HTTP_ACCEPT'] ) ) { |
9 | 1913 |
return true; |
1914 |
} |
|
1915 |
||
18 | 1916 |
if ( isset( $_SERVER['CONTENT_TYPE'] ) && wp_is_json_media_type( $_SERVER['CONTENT_TYPE'] ) ) { |
9 | 1917 |
return true; |
1918 |
} |
|
1919 |
||
1920 |
return false; |
|
1921 |
} |
|
1922 |
||
1923 |
/** |
|
1924 |
* Checks whether current request is a JSONP request, or is expecting a JSONP response. |
|
1925 |
* |
|
1926 |
* @since 5.2.0 |
|
1927 |
* |
|
1928 |
* @return bool True if JSONP request, false otherwise. |
|
1929 |
*/ |
|
1930 |
function wp_is_jsonp_request() { |
|
1931 |
if ( ! isset( $_GET['_jsonp'] ) ) { |
|
1932 |
return false; |
|
1933 |
} |
|
1934 |
||
1935 |
if ( ! function_exists( 'wp_check_jsonp_callback' ) ) { |
|
1936 |
require_once ABSPATH . WPINC . '/functions.php'; |
|
1937 |
} |
|
1938 |
||
1939 |
$jsonp_callback = $_GET['_jsonp']; |
|
1940 |
if ( ! wp_check_jsonp_callback( $jsonp_callback ) ) { |
|
1941 |
return false; |
|
1942 |
} |
|
1943 |
||
1944 |
/** This filter is documented in wp-includes/rest-api/class-wp-rest-server.php */ |
|
1945 |
$jsonp_enabled = apply_filters( 'rest_jsonp_enabled', true ); |
|
1946 |
||
1947 |
return $jsonp_enabled; |
|
1948 |
} |
|
1949 |
||
1950 |
/** |
|
18 | 1951 |
* Checks whether a string is a valid JSON Media Type. |
1952 |
* |
|
1953 |
* @since 5.6.0 |
|
1954 |
* |
|
1955 |
* @param string $media_type A Media Type string to check. |
|
1956 |
* @return bool True if string is a valid JSON Media Type. |
|
1957 |
*/ |
|
1958 |
function wp_is_json_media_type( $media_type ) { |
|
1959 |
static $cache = array(); |
|
1960 |
||
1961 |
if ( ! isset( $cache[ $media_type ] ) ) { |
|
1962 |
$cache[ $media_type ] = (bool) preg_match( '/(^|\s|,)application\/([\w!#\$&-\^\.\+]+\+)?json(\+oembed)?($|\s|;|,)/i', $media_type ); |
|
1963 |
} |
|
1964 |
||
1965 |
return $cache[ $media_type ]; |
|
1966 |
} |
|
1967 |
||
1968 |
/** |
|
9 | 1969 |
* Checks whether current request is an XML request, or is expecting an XML response. |
1970 |
* |
|
1971 |
* @since 5.2.0 |
|
1972 |
* |
|
16 | 1973 |
* @return bool True if `Accepts` or `Content-Type` headers contain `text/xml` |
1974 |
* or one of the related MIME types. False otherwise. |
|
9 | 1975 |
*/ |
1976 |
function wp_is_xml_request() { |
|
1977 |
$accepted = array( |
|
1978 |
'text/xml', |
|
1979 |
'application/rss+xml', |
|
1980 |
'application/atom+xml', |
|
1981 |
'application/rdf+xml', |
|
1982 |
'text/xml+oembed', |
|
1983 |
'application/xml+oembed', |
|
1984 |
); |
|
1985 |
||
1986 |
if ( isset( $_SERVER['HTTP_ACCEPT'] ) ) { |
|
1987 |
foreach ( $accepted as $type ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1988 |
if ( str_contains( $_SERVER['HTTP_ACCEPT'], $type ) ) { |
9 | 1989 |
return true; |
1990 |
} |
|
1991 |
} |
|
1992 |
} |
|
1993 |
||
1994 |
if ( isset( $_SERVER['CONTENT_TYPE'] ) && in_array( $_SERVER['CONTENT_TYPE'], $accepted, true ) ) { |
|
1995 |
return true; |
|
1996 |
} |
|
1997 |
||
1998 |
return false; |
|
1999 |
} |
|
18 | 2000 |
|
2001 |
/** |
|
2002 |
* Checks if this site is protected by HTTP Basic Auth. |
|
2003 |
* |
|
2004 |
* At the moment, this merely checks for the present of Basic Auth credentials. Therefore, calling |
|
2005 |
* this function with a context different from the current context may give inaccurate results. |
|
2006 |
* In a future release, this evaluation may be made more robust. |
|
2007 |
* |
|
2008 |
* Currently, this is only used by Application Passwords to prevent a conflict since it also utilizes |
|
2009 |
* Basic Auth. |
|
2010 |
* |
|
2011 |
* @since 5.6.1 |
|
2012 |
* |
|
19 | 2013 |
* @global string $pagenow The filename of the current screen. |
18 | 2014 |
* |
2015 |
* @param string $context The context to check for protection. Accepts 'login', 'admin', and 'front'. |
|
2016 |
* Defaults to the current context. |
|
2017 |
* @return bool Whether the site is protected by Basic Auth. |
|
2018 |
*/ |
|
2019 |
function wp_is_site_protected_by_basic_auth( $context = '' ) { |
|
2020 |
global $pagenow; |
|
2021 |
||
2022 |
if ( ! $context ) { |
|
2023 |
if ( 'wp-login.php' === $pagenow ) { |
|
2024 |
$context = 'login'; |
|
2025 |
} elseif ( is_admin() ) { |
|
2026 |
$context = 'admin'; |
|
2027 |
} else { |
|
2028 |
$context = 'front'; |
|
2029 |
} |
|
2030 |
} |
|
2031 |
||
2032 |
$is_protected = ! empty( $_SERVER['PHP_AUTH_USER'] ) || ! empty( $_SERVER['PHP_AUTH_PW'] ); |
|
2033 |
||
2034 |
/** |
|
2035 |
* Filters whether a site is protected by HTTP Basic Auth. |
|
2036 |
* |
|
2037 |
* @since 5.6.1 |
|
2038 |
* |
|
2039 |
* @param bool $is_protected Whether the site is protected by Basic Auth. |
|
2040 |
* @param string $context The context to check for protection. One of 'login', 'admin', or 'front'. |
|
2041 |
*/ |
|
2042 |
return apply_filters( 'wp_is_site_protected_by_basic_auth', $is_protected, $context ); |
|
2043 |
} |