author | ymh <ymh.work@gmail.com> |
Mon, 14 Oct 2019 18:28:13 +0200 | |
changeset 9 | 177826044cd9 |
parent 7 | cf61fcea0001 |
child 16 | a86126ab1dd4 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
3 |
* These functions are needed to load WordPress. |
|
4 |
* |
|
5 |
* @package WordPress |
|
6 |
*/ |
|
7 |
||
8 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
9 |
* Return the HTTP protocol sent by the server. |
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() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
16 |
$protocol = $_SERVER['SERVER_PROTOCOL']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
17 |
if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0' ) ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
18 |
$protocol = 'HTTP/1.0'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
19 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
20 |
return $protocol; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
21 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
22 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
23 |
/** |
0 | 24 |
* Turn register globals off. |
25 |
* |
|
5 | 26 |
* @since 2.1.0 |
0 | 27 |
* @access private |
28 |
*/ |
|
29 |
function wp_unregister_GLOBALS() { |
|
9 | 30 |
if ( ! ini_get( 'register_globals' ) ) { |
0 | 31 |
return; |
9 | 32 |
} |
0 | 33 |
|
9 | 34 |
if ( isset( $_REQUEST['GLOBALS'] ) ) { |
0 | 35 |
die( 'GLOBALS overwrite attempt detected' ); |
9 | 36 |
} |
0 | 37 |
|
38 |
// Variables that shouldn't be unset |
|
39 |
$no_unset = array( 'GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix' ); |
|
40 |
||
41 |
$input = array_merge( $_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset( $_SESSION ) && is_array( $_SESSION ) ? $_SESSION : array() ); |
|
9 | 42 |
foreach ( $input as $k => $v ) { |
43 |
if ( ! in_array( $k, $no_unset ) && isset( $GLOBALS[ $k ] ) ) { |
|
44 |
unset( $GLOBALS[ $k ] ); |
|
0 | 45 |
} |
9 | 46 |
} |
0 | 47 |
} |
48 |
||
49 |
/** |
|
5 | 50 |
* Fix `$_SERVER` variables for various setups. |
0 | 51 |
* |
5 | 52 |
* @since 3.0.0 |
0 | 53 |
* @access private |
5 | 54 |
* |
55 |
* @global string $PHP_SELF The filename of the currently executing script, |
|
56 |
* relative to the document root. |
|
0 | 57 |
*/ |
58 |
function wp_fix_server_vars() { |
|
59 |
global $PHP_SELF; |
|
60 |
||
61 |
$default_server_values = array( |
|
62 |
'SERVER_SOFTWARE' => '', |
|
9 | 63 |
'REQUEST_URI' => '', |
0 | 64 |
); |
65 |
||
66 |
$_SERVER = array_merge( $default_server_values, $_SERVER ); |
|
67 |
||
68 |
// Fix for IIS when running with PHP ISAPI |
|
5 | 69 |
if ( empty( $_SERVER['REQUEST_URI'] ) || ( PHP_SAPI != 'cgi-fcgi' && preg_match( '/^Microsoft-IIS\//', $_SERVER['SERVER_SOFTWARE'] ) ) ) { |
0 | 70 |
|
71 |
if ( isset( $_SERVER['HTTP_X_ORIGINAL_URL'] ) ) { |
|
9 | 72 |
// IIS Mod-Rewrite |
0 | 73 |
$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL']; |
9 | 74 |
} elseif ( isset( $_SERVER['HTTP_X_REWRITE_URL'] ) ) { |
75 |
// IIS Isapi_Rewrite |
|
0 | 76 |
$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL']; |
77 |
} else { |
|
78 |
// Use ORIG_PATH_INFO if there is no PATH_INFO |
|
9 | 79 |
if ( ! isset( $_SERVER['PATH_INFO'] ) && isset( $_SERVER['ORIG_PATH_INFO'] ) ) { |
0 | 80 |
$_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO']; |
9 | 81 |
} |
0 | 82 |
|
83 |
// Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice) |
|
84 |
if ( isset( $_SERVER['PATH_INFO'] ) ) { |
|
9 | 85 |
if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] ) { |
0 | 86 |
$_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO']; |
9 | 87 |
} else { |
0 | 88 |
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO']; |
9 | 89 |
} |
0 | 90 |
} |
91 |
||
92 |
// Append the query string if it exists and isn't null |
|
93 |
if ( ! empty( $_SERVER['QUERY_STRING'] ) ) { |
|
94 |
$_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
95 |
} |
|
96 |
} |
|
97 |
} |
|
98 |
||
99 |
// Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests |
|
9 | 100 |
if ( isset( $_SERVER['SCRIPT_FILENAME'] ) && ( strpos( $_SERVER['SCRIPT_FILENAME'], 'php.cgi' ) == strlen( $_SERVER['SCRIPT_FILENAME'] ) - 7 ) ) { |
0 | 101 |
$_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED']; |
9 | 102 |
} |
0 | 103 |
|
104 |
// Fix for Dreamhost and other PHP as CGI hosts |
|
9 | 105 |
if ( strpos( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) !== false ) { |
0 | 106 |
unset( $_SERVER['PATH_INFO'] ); |
9 | 107 |
} |
0 | 108 |
|
109 |
// Fix empty PHP_SELF |
|
110 |
$PHP_SELF = $_SERVER['PHP_SELF']; |
|
9 | 111 |
if ( empty( $PHP_SELF ) ) { |
112 |
$_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace( '/(\?.*)?$/', '', $_SERVER['REQUEST_URI'] ); |
|
113 |
} |
|
0 | 114 |
} |
115 |
||
116 |
/** |
|
5 | 117 |
* Check for the required PHP version, and the MySQL extension or |
118 |
* a database drop-in. |
|
0 | 119 |
* |
120 |
* Dies if requirements are not met. |
|
121 |
* |
|
5 | 122 |
* @since 3.0.0 |
0 | 123 |
* @access private |
5 | 124 |
* |
125 |
* @global string $required_php_version The required PHP version string. |
|
126 |
* @global string $wp_version The WordPress version string. |
|
0 | 127 |
*/ |
128 |
function wp_check_php_mysql_versions() { |
|
129 |
global $required_php_version, $wp_version; |
|
130 |
$php_version = phpversion(); |
|
5 | 131 |
|
0 | 132 |
if ( version_compare( $required_php_version, $php_version, '>' ) ) { |
133 |
wp_load_translations_early(); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
134 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
135 |
$protocol = wp_get_server_protocol(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
136 |
header( sprintf( '%s 500 Internal Server Error', $protocol ), true, 500 ); |
5 | 137 |
header( 'Content-Type: text/html; charset=utf-8' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
138 |
/* translators: 1: Current PHP version number, 2: WordPress version number, 3: Minimum required PHP version number */ |
9 | 139 |
printf( __( 'Your server is running PHP version %1$s but WordPress %2$s requires at least %3$s.' ), $php_version, $wp_version, $required_php_version ); |
140 |
exit( 1 ); |
|
0 | 141 |
} |
142 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
143 |
if ( ! extension_loaded( 'mysql' ) && ! extension_loaded( 'mysqli' ) && ! extension_loaded( 'mysqlnd' ) && ! file_exists( WP_CONTENT_DIR . '/db.php' ) ) { |
9 | 144 |
require_once( ABSPATH . WPINC . '/functions.php' ); |
0 | 145 |
wp_load_translations_early(); |
9 | 146 |
$args = array( |
147 |
'exit' => false, |
|
148 |
'code' => 'mysql_not_found', |
|
149 |
); |
|
150 |
wp_die( |
|
151 |
__( 'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.' ), |
|
152 |
__( 'Insufficient Requirements' ), |
|
153 |
$args |
|
154 |
); |
|
155 |
exit( 1 ); |
|
0 | 156 |
} |
157 |
} |
|
158 |
||
159 |
/** |
|
160 |
* Don't load all of WordPress when handling a favicon.ico request. |
|
5 | 161 |
* |
0 | 162 |
* Instead, send the headers for a zero-length favicon and bail. |
163 |
* |
|
164 |
* @since 3.0.0 |
|
165 |
*/ |
|
166 |
function wp_favicon_request() { |
|
167 |
if ( '/favicon.ico' == $_SERVER['REQUEST_URI'] ) { |
|
9 | 168 |
header( 'Content-Type: image/vnd.microsoft.icon' ); |
0 | 169 |
exit; |
170 |
} |
|
171 |
} |
|
172 |
||
173 |
/** |
|
5 | 174 |
* Die with a maintenance message when conditions are met. |
0 | 175 |
* |
176 |
* Checks for a file in the WordPress root directory named ".maintenance". |
|
177 |
* This file will contain the variable $upgrading, set to the time the file |
|
178 |
* was created. If the file was created less than 10 minutes ago, WordPress |
|
179 |
* enters maintenance mode and displays a message. |
|
180 |
* |
|
181 |
* The default message can be replaced by using a drop-in (maintenance.php in |
|
182 |
* the wp-content directory). |
|
183 |
* |
|
5 | 184 |
* @since 3.0.0 |
0 | 185 |
* @access private |
5 | 186 |
* |
187 |
* @global int $upgrading the unix timestamp marking when upgrading WordPress began. |
|
0 | 188 |
*/ |
189 |
function wp_maintenance() { |
|
9 | 190 |
if ( ! file_exists( ABSPATH . '.maintenance' ) || wp_installing() ) { |
0 | 191 |
return; |
9 | 192 |
} |
0 | 193 |
|
194 |
global $upgrading; |
|
195 |
||
196 |
include( ABSPATH . '.maintenance' ); |
|
197 |
// If the $upgrading timestamp is older than 10 minutes, don't die. |
|
9 | 198 |
if ( ( time() - $upgrading ) >= 600 ) { |
0 | 199 |
return; |
9 | 200 |
} |
0 | 201 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
202 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
203 |
* Filters whether to enable maintenance mode. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
204 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
205 |
* 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
|
206 |
* 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
|
207 |
* 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
|
208 |
* continue processing even if maintenance mode should be active. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
209 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
210 |
* @since 4.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
211 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
212 |
* @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
|
213 |
* @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
|
214 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
215 |
if ( ! apply_filters( 'enable_maintenance_mode', true, $upgrading ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
216 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
217 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
218 |
|
0 | 219 |
if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) { |
220 |
require_once( WP_CONTENT_DIR . '/maintenance.php' ); |
|
221 |
die(); |
|
222 |
} |
|
223 |
||
9 | 224 |
require_once( ABSPATH . WPINC . '/functions.php' ); |
0 | 225 |
wp_load_translations_early(); |
226 |
||
227 |
header( 'Retry-After: 600' ); |
|
228 |
||
9 | 229 |
wp_die( |
230 |
__( 'Briefly unavailable for scheduled maintenance. Check back in a minute.' ), |
|
231 |
__( 'Maintenance' ), |
|
232 |
503 |
|
233 |
); |
|
0 | 234 |
} |
235 |
||
236 |
/** |
|
5 | 237 |
* Start the WordPress micro-timer. |
0 | 238 |
* |
5 | 239 |
* @since 0.71 |
0 | 240 |
* @access private |
5 | 241 |
* |
242 |
* @global float $timestart Unix timestamp set at the beginning of the page load. |
|
243 |
* @see timer_stop() |
|
244 |
* |
|
0 | 245 |
* @return bool Always returns true. |
246 |
*/ |
|
247 |
function timer_start() { |
|
248 |
global $timestart; |
|
249 |
$timestart = microtime( true ); |
|
250 |
return true; |
|
251 |
} |
|
252 |
||
253 |
/** |
|
5 | 254 |
* Retrieve or display the time from the page start to when function is called. |
0 | 255 |
* |
256 |
* @since 0.71 |
|
5 | 257 |
* |
258 |
* @global float $timestart Seconds from when timer_start() is called. |
|
259 |
* @global float $timeend Seconds from when function is called. |
|
0 | 260 |
* |
5 | 261 |
* @param int|bool $display Whether to echo or return the results. Accepts 0|false for return, |
262 |
* 1|true for echo. Default 0|false. |
|
263 |
* @param int $precision The number of digits from the right of the decimal to display. |
|
264 |
* Default 3. |
|
265 |
* @return string The "second.microsecond" finished time calculation. The number is formatted |
|
266 |
* for human consumption, both localized and rounded. |
|
0 | 267 |
*/ |
5 | 268 |
function timer_stop( $display = 0, $precision = 3 ) { |
0 | 269 |
global $timestart, $timeend; |
9 | 270 |
$timeend = microtime( true ); |
0 | 271 |
$timetotal = $timeend - $timestart; |
9 | 272 |
$r = ( function_exists( 'number_format_i18n' ) ) ? number_format_i18n( $timetotal, $precision ) : number_format( $timetotal, $precision ); |
273 |
if ( $display ) { |
|
0 | 274 |
echo $r; |
9 | 275 |
} |
0 | 276 |
return $r; |
277 |
} |
|
278 |
||
279 |
/** |
|
5 | 280 |
* Set PHP error reporting based on WordPress debug settings. |
281 |
* |
|
282 |
* 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
|
283 |
* 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
|
284 |
* `WP_DEBUG_LOG` are set to false, and `WP_DEBUG_DISPLAY` is set to true. |
0 | 285 |
* |
5 | 286 |
* When `WP_DEBUG` is true, all PHP notices are reported. WordPress will also |
287 |
* display internal notices: when a deprecated WordPress function, function |
|
288 |
* argument, or file is used. Deprecated code may be removed from a later |
|
289 |
* version. |
|
0 | 290 |
* |
5 | 291 |
* It is strongly recommended that plugin and theme developers use `WP_DEBUG` |
292 |
* in their development environments. |
|
0 | 293 |
* |
5 | 294 |
* `WP_DEBUG_DISPLAY` and `WP_DEBUG_LOG` perform no function unless `WP_DEBUG` |
295 |
* is true. |
|
0 | 296 |
* |
5 | 297 |
* When `WP_DEBUG_DISPLAY` is true, WordPress will force errors to be displayed. |
298 |
* `WP_DEBUG_DISPLAY` defaults to true. Defining it as null prevents WordPress |
|
299 |
* from changing the global configuration setting. Defining `WP_DEBUG_DISPLAY` |
|
300 |
* as false will force errors to be hidden. |
|
0 | 301 |
* |
9 | 302 |
* When `WP_DEBUG_LOG` is true, errors will be logged to `wp-content/debug.log`. |
303 |
* When `WP_DEBUG_LOG` is a valid path, errors will be logged to the specified file. |
|
0 | 304 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
305 |
* Errors are never displayed for XML-RPC, REST, and Ajax requests. |
0 | 306 |
* |
5 | 307 |
* @since 3.0.0 |
9 | 308 |
* @since 5.1.0 `WP_DEBUG_LOG` can be a file path. |
0 | 309 |
* @access private |
310 |
*/ |
|
311 |
function wp_debug_mode() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
312 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
313 |
* 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
|
314 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
315 |
* 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
|
316 |
* non-web run-times. Returning false causes the `WP_DEBUG` and related |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
317 |
* constants to not be checked and the default php values for errors |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
318 |
* 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
|
319 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
320 |
* @since 4.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
321 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
322 |
* @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
|
323 |
*/ |
9 | 324 |
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
|
325 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
326 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
327 |
|
0 | 328 |
if ( WP_DEBUG ) { |
329 |
error_reporting( E_ALL ); |
|
330 |
||
9 | 331 |
if ( WP_DEBUG_DISPLAY ) { |
0 | 332 |
ini_set( 'display_errors', 1 ); |
9 | 333 |
} elseif ( null !== WP_DEBUG_DISPLAY ) { |
0 | 334 |
ini_set( 'display_errors', 0 ); |
9 | 335 |
} |
0 | 336 |
|
9 | 337 |
if ( in_array( strtolower( (string) WP_DEBUG_LOG ), array( 'true', '1' ), true ) ) { |
338 |
$log_path = WP_CONTENT_DIR . '/debug.log'; |
|
339 |
} elseif ( is_string( WP_DEBUG_LOG ) ) { |
|
340 |
$log_path = WP_DEBUG_LOG; |
|
341 |
} else { |
|
342 |
$log_path = false; |
|
343 |
} |
|
344 |
||
345 |
if ( $log_path ) { |
|
0 | 346 |
ini_set( 'log_errors', 1 ); |
9 | 347 |
ini_set( 'error_log', $log_path ); |
0 | 348 |
} |
349 |
} else { |
|
350 |
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 ); |
|
351 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
352 |
|
9 | 353 |
if ( defined( 'XMLRPC_REQUEST' ) || defined( 'REST_REQUEST' ) || ( defined( 'WP_INSTALLING' ) && WP_INSTALLING ) || wp_doing_ajax() || wp_is_json_request() ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
354 |
@ini_set( 'display_errors', 0 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
355 |
} |
0 | 356 |
} |
357 |
||
358 |
/** |
|
5 | 359 |
* Set the location of the language directory. |
0 | 360 |
* |
5 | 361 |
* To set directory manually, define the `WP_LANG_DIR` constant |
362 |
* in wp-config.php. |
|
0 | 363 |
* |
5 | 364 |
* If the language directory exists within `WP_CONTENT_DIR`, it |
365 |
* is used. Otherwise the language directory is assumed to live |
|
366 |
* in `WPINC`. |
|
0 | 367 |
* |
5 | 368 |
* @since 3.0.0 |
0 | 369 |
* @access private |
370 |
*/ |
|
371 |
function wp_set_lang_dir() { |
|
9 | 372 |
if ( ! defined( 'WP_LANG_DIR' ) ) { |
373 |
if ( file_exists( WP_CONTENT_DIR . '/languages' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) || ! @is_dir( ABSPATH . WPINC . '/languages' ) ) { |
|
5 | 374 |
/** |
375 |
* Server path of the language directory. |
|
376 |
* |
|
377 |
* No leading slash, no trailing slash, full path, not relative to ABSPATH |
|
378 |
* |
|
379 |
* @since 2.1.0 |
|
380 |
*/ |
|
381 |
define( 'WP_LANG_DIR', WP_CONTENT_DIR . '/languages' ); |
|
9 | 382 |
if ( ! defined( 'LANGDIR' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
383 |
// Old static relative path maintained for limited backward compatibility - won't work in some cases. |
0 | 384 |
define( 'LANGDIR', 'wp-content/languages' ); |
385 |
} |
|
386 |
} else { |
|
5 | 387 |
/** |
388 |
* Server path of the language directory. |
|
389 |
* |
|
390 |
* No leading slash, no trailing slash, full path, not relative to `ABSPATH`. |
|
391 |
* |
|
392 |
* @since 2.1.0 |
|
393 |
*/ |
|
394 |
define( 'WP_LANG_DIR', ABSPATH . WPINC . '/languages' ); |
|
9 | 395 |
if ( ! defined( 'LANGDIR' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
396 |
// Old relative path maintained for backward compatibility. |
0 | 397 |
define( 'LANGDIR', WPINC . '/languages' ); |
398 |
} |
|
399 |
} |
|
400 |
} |
|
401 |
} |
|
402 |
||
403 |
/** |
|
5 | 404 |
* Load the database class file and instantiate the `$wpdb` global. |
0 | 405 |
* |
406 |
* @since 2.5.0 |
|
5 | 407 |
* |
408 |
* @global wpdb $wpdb The WordPress database class. |
|
0 | 409 |
*/ |
410 |
function require_wp_db() { |
|
411 |
global $wpdb; |
|
412 |
||
413 |
require_once( ABSPATH . WPINC . '/wp-db.php' ); |
|
9 | 414 |
if ( file_exists( WP_CONTENT_DIR . '/db.php' ) ) { |
0 | 415 |
require_once( WP_CONTENT_DIR . '/db.php' ); |
9 | 416 |
} |
0 | 417 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
418 |
if ( isset( $wpdb ) ) { |
0 | 419 |
return; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
420 |
} |
0 | 421 |
|
9 | 422 |
$dbuser = defined( 'DB_USER' ) ? DB_USER : ''; |
423 |
$dbpassword = defined( 'DB_PASSWORD' ) ? DB_PASSWORD : ''; |
|
424 |
$dbname = defined( 'DB_NAME' ) ? DB_NAME : ''; |
|
425 |
$dbhost = defined( 'DB_HOST' ) ? DB_HOST : ''; |
|
426 |
||
427 |
$wpdb = new wpdb( $dbuser, $dbpassword, $dbname, $dbhost ); |
|
0 | 428 |
} |
429 |
||
430 |
/** |
|
5 | 431 |
* Set the database table prefix and the format specifiers for database |
432 |
* table columns. |
|
0 | 433 |
* |
5 | 434 |
* Columns not listed here default to `%s`. |
0 | 435 |
* |
5 | 436 |
* @since 3.0.0 |
437 |
* @access private |
|
0 | 438 |
* |
5 | 439 |
* @global wpdb $wpdb The WordPress database class. |
440 |
* @global string $table_prefix The database table prefix. |
|
0 | 441 |
*/ |
442 |
function wp_set_wpdb_vars() { |
|
443 |
global $wpdb, $table_prefix; |
|
9 | 444 |
if ( ! empty( $wpdb->error ) ) { |
0 | 445 |
dead_db(); |
9 | 446 |
} |
0 | 447 |
|
9 | 448 |
$wpdb->field_types = array( |
449 |
'post_author' => '%d', |
|
450 |
'post_parent' => '%d', |
|
451 |
'menu_order' => '%d', |
|
452 |
'term_id' => '%d', |
|
453 |
'term_group' => '%d', |
|
454 |
'term_taxonomy_id' => '%d', |
|
455 |
'parent' => '%d', |
|
456 |
'count' => '%d', |
|
457 |
'object_id' => '%d', |
|
458 |
'term_order' => '%d', |
|
459 |
'ID' => '%d', |
|
460 |
'comment_ID' => '%d', |
|
461 |
'comment_post_ID' => '%d', |
|
462 |
'comment_parent' => '%d', |
|
463 |
'user_id' => '%d', |
|
464 |
'link_id' => '%d', |
|
465 |
'link_owner' => '%d', |
|
466 |
'link_rating' => '%d', |
|
467 |
'option_id' => '%d', |
|
468 |
'blog_id' => '%d', |
|
469 |
'meta_id' => '%d', |
|
470 |
'post_id' => '%d', |
|
471 |
'user_status' => '%d', |
|
472 |
'umeta_id' => '%d', |
|
473 |
'comment_karma' => '%d', |
|
474 |
'comment_count' => '%d', |
|
0 | 475 |
// multisite: |
9 | 476 |
'active' => '%d', |
477 |
'cat_id' => '%d', |
|
478 |
'deleted' => '%d', |
|
479 |
'lang_id' => '%d', |
|
480 |
'mature' => '%d', |
|
481 |
'public' => '%d', |
|
482 |
'site_id' => '%d', |
|
483 |
'spam' => '%d', |
|
0 | 484 |
); |
485 |
||
486 |
$prefix = $wpdb->set_prefix( $table_prefix ); |
|
487 |
||
488 |
if ( is_wp_error( $prefix ) ) { |
|
489 |
wp_load_translations_early(); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
490 |
wp_die( |
9 | 491 |
/* translators: 1: $table_prefix, 2: wp-config.php */ |
492 |
sprintf( |
|
493 |
__( '<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
|
494 |
'<code>$table_prefix</code>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
495 |
'<code>wp-config.php</code>' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
496 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
497 |
); |
0 | 498 |
} |
499 |
} |
|
500 |
||
501 |
/** |
|
5 | 502 |
* Toggle `$_wp_using_ext_object_cache` on and off without directly |
503 |
* touching global. |
|
0 | 504 |
* |
505 |
* @since 3.7.0 |
|
506 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
507 |
* @global bool $_wp_using_ext_object_cache |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
508 |
* |
5 | 509 |
* @param bool $using Whether external object cache is being used. |
510 |
* @return bool The current 'using' setting. |
|
0 | 511 |
*/ |
512 |
function wp_using_ext_object_cache( $using = null ) { |
|
513 |
global $_wp_using_ext_object_cache; |
|
514 |
$current_using = $_wp_using_ext_object_cache; |
|
9 | 515 |
if ( null !== $using ) { |
0 | 516 |
$_wp_using_ext_object_cache = $using; |
9 | 517 |
} |
0 | 518 |
return $current_using; |
519 |
} |
|
520 |
||
521 |
/** |
|
5 | 522 |
* Start the WordPress object cache. |
0 | 523 |
* |
524 |
* If an object-cache.php file exists in the wp-content directory, |
|
525 |
* it uses that drop-in as an external object cache. |
|
526 |
* |
|
5 | 527 |
* @since 3.0.0 |
0 | 528 |
* @access private |
5 | 529 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
530 |
* @global array $wp_filter Stores all of the filters. |
0 | 531 |
*/ |
532 |
function wp_start_object_cache() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
533 |
global $wp_filter; |
9 | 534 |
static $first_init = true; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
535 |
|
9 | 536 |
// Only perform the following checks once. |
537 |
if ( $first_init ) { |
|
538 |
if ( ! function_exists( 'wp_cache_init' ) ) { |
|
539 |
/* |
|
540 |
* This is the normal situation. First-run of this function. No |
|
541 |
* caching backend has been loaded. |
|
542 |
* |
|
543 |
* We try to load a custom caching backend, and then, if it |
|
544 |
* results in a wp_cache_init() function existing, we note |
|
545 |
* that an external object cache is being used. |
|
546 |
*/ |
|
547 |
if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { |
|
548 |
require_once( WP_CONTENT_DIR . '/object-cache.php' ); |
|
549 |
if ( function_exists( 'wp_cache_init' ) ) { |
|
550 |
wp_using_ext_object_cache( true ); |
|
551 |
} |
|
0 | 552 |
|
9 | 553 |
// Re-initialize any hooks added manually by object-cache.php |
554 |
if ( $wp_filter ) { |
|
555 |
$wp_filter = WP_Hook::build_preinitialized_hooks( $wp_filter ); |
|
556 |
} |
|
557 |
} |
|
558 |
} elseif ( ! wp_using_ext_object_cache() && file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { |
|
559 |
/* |
|
560 |
* Sometimes advanced-cache.php can load object-cache.php before |
|
561 |
* this function is run. This breaks the function_exists() check |
|
562 |
* above and can result in wp_using_ext_object_cache() returning |
|
563 |
* false when actually an external cache is in use. |
|
564 |
*/ |
|
565 |
wp_using_ext_object_cache( true ); |
|
566 |
} |
|
0 | 567 |
} |
568 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
569 |
if ( ! wp_using_ext_object_cache() ) { |
9 | 570 |
require_once( ABSPATH . WPINC . '/cache.php' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
571 |
} |
0 | 572 |
|
5 | 573 |
/* |
574 |
* If cache supports reset, reset instead of init if already |
|
575 |
* initialized. Reset signals to the cache that global IDs |
|
576 |
* have changed and it may need to update keys and cleanup caches. |
|
577 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
578 |
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
|
579 |
wp_cache_switch_to_blog( get_current_blog_id() ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
580 |
} elseif ( function_exists( 'wp_cache_init' ) ) { |
0 | 581 |
wp_cache_init(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
582 |
} |
0 | 583 |
|
584 |
if ( function_exists( 'wp_cache_add_global_groups' ) ) { |
|
9 | 585 |
wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'blog-lookup', 'blog-details', 'site-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites', 'blog_meta' ) ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
586 |
wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) ); |
0 | 587 |
} |
9 | 588 |
|
589 |
$first_init = false; |
|
0 | 590 |
} |
591 |
||
592 |
/** |
|
5 | 593 |
* Redirect to the installer if WordPress is not installed. |
0 | 594 |
* |
5 | 595 |
* Dies with an error message when Multisite is enabled. |
0 | 596 |
* |
5 | 597 |
* @since 3.0.0 |
0 | 598 |
* @access private |
599 |
*/ |
|
600 |
function wp_not_installed() { |
|
601 |
if ( is_multisite() ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
602 |
if ( ! is_blog_installed() && ! wp_installing() ) { |
5 | 603 |
nocache_headers(); |
604 |
||
0 | 605 |
wp_die( __( 'The site you have requested is not installed properly. Please contact the system administrator.' ) ); |
5 | 606 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
607 |
} elseif ( ! is_blog_installed() && ! wp_installing() ) { |
5 | 608 |
nocache_headers(); |
609 |
||
0 | 610 |
require( ABSPATH . WPINC . '/kses.php' ); |
611 |
require( ABSPATH . WPINC . '/pluggable.php' ); |
|
612 |
||
613 |
$link = wp_guess_url() . '/wp-admin/install.php'; |
|
614 |
||
615 |
wp_redirect( $link ); |
|
616 |
die(); |
|
617 |
} |
|
618 |
} |
|
619 |
||
620 |
/** |
|
5 | 621 |
* Retrieve an array of must-use plugin files. |
0 | 622 |
* |
5 | 623 |
* The default directory is wp-content/mu-plugins. To change the default |
624 |
* directory manually, define `WPMU_PLUGIN_DIR` and `WPMU_PLUGIN_URL` |
|
0 | 625 |
* in wp-config.php. |
626 |
* |
|
5 | 627 |
* @since 3.0.0 |
0 | 628 |
* @access private |
5 | 629 |
* |
630 |
* @return array Files to include. |
|
0 | 631 |
*/ |
632 |
function wp_get_mu_plugins() { |
|
633 |
$mu_plugins = array(); |
|
9 | 634 |
if ( ! is_dir( WPMU_PLUGIN_DIR ) ) { |
0 | 635 |
return $mu_plugins; |
9 | 636 |
} |
637 |
if ( ! $dh = opendir( WPMU_PLUGIN_DIR ) ) { |
|
0 | 638 |
return $mu_plugins; |
9 | 639 |
} |
0 | 640 |
while ( ( $plugin = readdir( $dh ) ) !== false ) { |
9 | 641 |
if ( substr( $plugin, -4 ) == '.php' ) { |
0 | 642 |
$mu_plugins[] = WPMU_PLUGIN_DIR . '/' . $plugin; |
9 | 643 |
} |
0 | 644 |
} |
645 |
closedir( $dh ); |
|
646 |
sort( $mu_plugins ); |
|
647 |
||
648 |
return $mu_plugins; |
|
649 |
} |
|
650 |
||
651 |
/** |
|
5 | 652 |
* Retrieve an array of active and valid plugin files. |
0 | 653 |
* |
5 | 654 |
* While upgrading or installing WordPress, no plugins are returned. |
655 |
* |
|
9 | 656 |
* The default directory is `wp-content/plugins`. To change the default |
5 | 657 |
* directory manually, define `WP_PLUGIN_DIR` and `WP_PLUGIN_URL` |
9 | 658 |
* in `wp-config.php`. |
0 | 659 |
* |
5 | 660 |
* @since 3.0.0 |
0 | 661 |
* @access private |
5 | 662 |
* |
9 | 663 |
* @return string[] $plugin_file Array of paths to plugin files relative to the plugins directory. |
0 | 664 |
*/ |
665 |
function wp_get_active_and_valid_plugins() { |
|
9 | 666 |
$plugins = array(); |
0 | 667 |
$active_plugins = (array) get_option( 'active_plugins', array() ); |
668 |
||
669 |
// Check for hacks file if the option is enabled |
|
670 |
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
|
671 |
_deprecated_file( 'my-hacks.php', '1.5.0' ); |
0 | 672 |
array_unshift( $plugins, ABSPATH . 'my-hacks.php' ); |
673 |
} |
|
674 |
||
9 | 675 |
if ( empty( $active_plugins ) || wp_installing() ) { |
0 | 676 |
return $plugins; |
9 | 677 |
} |
0 | 678 |
|
679 |
$network_plugins = is_multisite() ? wp_get_active_network_plugins() : false; |
|
680 |
||
681 |
foreach ( $active_plugins as $plugin ) { |
|
682 |
if ( ! validate_file( $plugin ) // $plugin must validate as file |
|
683 |
&& '.php' == substr( $plugin, -4 ) // $plugin must end with '.php' |
|
684 |
&& file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist |
|
685 |
// not already included as a network plugin |
|
686 |
&& ( ! $network_plugins || ! in_array( WP_PLUGIN_DIR . '/' . $plugin, $network_plugins ) ) |
|
9 | 687 |
) { |
688 |
$plugins[] = WP_PLUGIN_DIR . '/' . $plugin; |
|
689 |
} |
|
690 |
} |
|
691 |
||
692 |
/* |
|
693 |
* Remove plugins from the list of active plugins when we're on an endpoint |
|
694 |
* that should be protected against WSODs and the plugin is paused. |
|
695 |
*/ |
|
696 |
if ( wp_is_recovery_mode() ) { |
|
697 |
$plugins = wp_skip_paused_plugins( $plugins ); |
|
698 |
} |
|
699 |
||
700 |
return $plugins; |
|
701 |
} |
|
702 |
||
703 |
/** |
|
704 |
* Filters a given list of plugins, removing any paused plugins from it. |
|
705 |
* |
|
706 |
* @since 5.2.0 |
|
707 |
* |
|
708 |
* @param array $plugins List of absolute plugin main file paths. |
|
709 |
* @return array Filtered value of $plugins, without any paused plugins. |
|
710 |
*/ |
|
711 |
function wp_skip_paused_plugins( array $plugins ) { |
|
712 |
$paused_plugins = wp_paused_plugins()->get_all(); |
|
713 |
||
714 |
if ( empty( $paused_plugins ) ) { |
|
715 |
return $plugins; |
|
716 |
} |
|
717 |
||
718 |
foreach ( $plugins as $index => $plugin ) { |
|
719 |
list( $plugin ) = explode( '/', plugin_basename( $plugin ) ); |
|
720 |
||
721 |
if ( array_key_exists( $plugin, $paused_plugins ) ) { |
|
722 |
unset( $plugins[ $index ] ); |
|
723 |
||
724 |
// Store list of paused plugins for displaying an admin notice. |
|
725 |
$GLOBALS['_paused_plugins'][ $plugin ] = $paused_plugins[ $plugin ]; |
|
726 |
} |
|
727 |
} |
|
728 |
||
729 |
return $plugins; |
|
730 |
} |
|
731 |
||
732 |
/** |
|
733 |
* Retrieves an array of active and valid themes. |
|
734 |
* |
|
735 |
* While upgrading or installing WordPress, no themes are returned. |
|
736 |
* |
|
737 |
* @since 5.1.0 |
|
738 |
* @access private |
|
739 |
* |
|
740 |
* @return array Array of paths to theme directories. |
|
741 |
*/ |
|
742 |
function wp_get_active_and_valid_themes() { |
|
743 |
global $pagenow; |
|
744 |
||
745 |
$themes = array(); |
|
746 |
||
747 |
if ( wp_installing() && 'wp-activate.php' !== $pagenow ) { |
|
748 |
return $themes; |
|
749 |
} |
|
750 |
||
751 |
if ( TEMPLATEPATH !== STYLESHEETPATH ) { |
|
752 |
$themes[] = STYLESHEETPATH; |
|
753 |
} |
|
754 |
||
755 |
$themes[] = TEMPLATEPATH; |
|
756 |
||
757 |
/* |
|
758 |
* Remove themes from the list of active themes when we're on an endpoint |
|
759 |
* that should be protected against WSODs and the theme is paused. |
|
760 |
*/ |
|
761 |
if ( wp_is_recovery_mode() ) { |
|
762 |
$themes = wp_skip_paused_themes( $themes ); |
|
763 |
||
764 |
// If no active and valid themes exist, skip loading themes. |
|
765 |
if ( empty( $themes ) ) { |
|
766 |
add_filter( 'wp_using_themes', '__return_false' ); |
|
767 |
} |
|
768 |
} |
|
769 |
||
770 |
return $themes; |
|
771 |
} |
|
772 |
||
773 |
/** |
|
774 |
* Filters a given list of themes, removing any paused themes from it. |
|
775 |
* |
|
776 |
* @since 5.2.0 |
|
777 |
* |
|
778 |
* @param array $themes List of absolute theme directory paths. |
|
779 |
* @return array Filtered value of $themes, without any paused themes. |
|
780 |
*/ |
|
781 |
function wp_skip_paused_themes( array $themes ) { |
|
782 |
$paused_themes = wp_paused_themes()->get_all(); |
|
783 |
||
784 |
if ( empty( $paused_themes ) ) { |
|
785 |
return $themes; |
|
0 | 786 |
} |
9 | 787 |
|
788 |
foreach ( $themes as $index => $theme ) { |
|
789 |
$theme = basename( $theme ); |
|
790 |
||
791 |
if ( array_key_exists( $theme, $paused_themes ) ) { |
|
792 |
unset( $themes[ $index ] ); |
|
793 |
||
794 |
// Store list of paused themes for displaying an admin notice. |
|
795 |
$GLOBALS['_paused_themes'][ $theme ] = $paused_themes[ $theme ]; |
|
796 |
} |
|
797 |
} |
|
798 |
||
799 |
return $themes; |
|
800 |
} |
|
801 |
||
802 |
/** |
|
803 |
* Is WordPress in Recovery Mode. |
|
804 |
* |
|
805 |
* In this mode, plugins or themes that cause WSODs will be paused. |
|
806 |
* |
|
807 |
* @since 5.2.0 |
|
808 |
* |
|
809 |
* @return bool |
|
810 |
*/ |
|
811 |
function wp_is_recovery_mode() { |
|
812 |
return wp_recovery_mode()->is_active(); |
|
813 |
} |
|
814 |
||
815 |
/** |
|
816 |
* Determines whether we are currently on an endpoint that should be protected against WSODs. |
|
817 |
* |
|
818 |
* @since 5.2.0 |
|
819 |
* |
|
820 |
* @return bool True if the current endpoint should be protected. |
|
821 |
*/ |
|
822 |
function is_protected_endpoint() { |
|
823 |
// Protect login pages. |
|
824 |
if ( isset( $GLOBALS['pagenow'] ) && 'wp-login.php' === $GLOBALS['pagenow'] ) { |
|
825 |
return true; |
|
826 |
} |
|
827 |
||
828 |
// Protect the admin backend. |
|
829 |
if ( is_admin() && ! wp_doing_ajax() ) { |
|
830 |
return true; |
|
831 |
} |
|
832 |
||
833 |
// Protect AJAX actions that could help resolve a fatal error should be available. |
|
834 |
if ( is_protected_ajax_action() ) { |
|
835 |
return true; |
|
836 |
} |
|
837 |
||
838 |
/** |
|
839 |
* Filters whether the current request is against a protected endpoint. |
|
840 |
* |
|
841 |
* This filter is only fired when an endpoint is requested which is not already protected by |
|
842 |
* WordPress core. As such, it exclusively allows providing further protected endpoints in |
|
843 |
* addition to the admin backend, login pages and protected AJAX actions. |
|
844 |
* |
|
845 |
* @since 5.2.0 |
|
846 |
* |
|
847 |
* @param bool $is_protected_endpoint Whether the currently requested endpoint is protected. Default false. |
|
848 |
*/ |
|
849 |
return (bool) apply_filters( 'is_protected_endpoint', false ); |
|
850 |
} |
|
851 |
||
852 |
/** |
|
853 |
* Determines whether we are currently handling an AJAX action that should be protected against WSODs. |
|
854 |
* |
|
855 |
* @since 5.2.0 |
|
856 |
* |
|
857 |
* @return bool True if the current AJAX action should be protected. |
|
858 |
*/ |
|
859 |
function is_protected_ajax_action() { |
|
860 |
if ( ! wp_doing_ajax() ) { |
|
861 |
return false; |
|
862 |
} |
|
863 |
||
864 |
if ( ! isset( $_REQUEST['action'] ) ) { |
|
865 |
return false; |
|
866 |
} |
|
867 |
||
868 |
$actions_to_protect = array( |
|
869 |
'edit-theme-plugin-file', // Saving changes in the core code editor. |
|
870 |
'heartbeat', // Keep the heart beating. |
|
871 |
'install-plugin', // Installing a new plugin. |
|
872 |
'install-theme', // Installing a new theme. |
|
873 |
'search-plugins', // Searching in the list of plugins. |
|
874 |
'search-install-plugins', // Searching for a plugin in the plugin install screen. |
|
875 |
'update-plugin', // Update an existing plugin. |
|
876 |
'update-theme', // Update an existing theme. |
|
877 |
); |
|
878 |
||
879 |
/** |
|
880 |
* Filters the array of protected AJAX actions. |
|
881 |
* |
|
882 |
* This filter is only fired when doing AJAX and the AJAX request has an 'action' property. |
|
883 |
* |
|
884 |
* @since 5.2.0 |
|
885 |
* |
|
886 |
* @param array $actions_to_protect Array of strings with AJAX actions to protect. |
|
887 |
*/ |
|
888 |
$actions_to_protect = (array) apply_filters( 'wp_protected_ajax_actions', $actions_to_protect ); |
|
889 |
||
890 |
if ( ! in_array( $_REQUEST['action'], $actions_to_protect, true ) ) { |
|
891 |
return false; |
|
892 |
} |
|
893 |
||
894 |
return true; |
|
0 | 895 |
} |
896 |
||
897 |
/** |
|
5 | 898 |
* Set internal encoding. |
0 | 899 |
* |
5 | 900 |
* In most cases the default internal encoding is latin1, which is |
901 |
* of no use, since we want to use the `mb_` functions for `utf-8` strings. |
|
0 | 902 |
* |
5 | 903 |
* @since 3.0.0 |
0 | 904 |
* @access private |
905 |
*/ |
|
906 |
function wp_set_internal_encoding() { |
|
907 |
if ( function_exists( 'mb_internal_encoding' ) ) { |
|
908 |
$charset = get_option( 'blog_charset' ); |
|
9 | 909 |
if ( ! $charset || ! @mb_internal_encoding( $charset ) ) { |
0 | 910 |
mb_internal_encoding( 'UTF-8' ); |
9 | 911 |
} |
0 | 912 |
} |
913 |
} |
|
914 |
||
915 |
/** |
|
5 | 916 |
* Add magic quotes to `$_GET`, `$_POST`, `$_COOKIE`, and `$_SERVER`. |
0 | 917 |
* |
5 | 918 |
* Also forces `$_REQUEST` to be `$_GET + $_POST`. If `$_SERVER`, |
919 |
* `$_COOKIE`, or `$_ENV` are needed, use those superglobals directly. |
|
0 | 920 |
* |
5 | 921 |
* @since 3.0.0 |
0 | 922 |
* @access private |
923 |
*/ |
|
924 |
function wp_magic_quotes() { |
|
925 |
// If already slashed, strip. |
|
926 |
if ( get_magic_quotes_gpc() ) { |
|
9 | 927 |
$_GET = stripslashes_deep( $_GET ); |
928 |
$_POST = stripslashes_deep( $_POST ); |
|
0 | 929 |
$_COOKIE = stripslashes_deep( $_COOKIE ); |
930 |
} |
|
931 |
||
932 |
// Escape with wpdb. |
|
9 | 933 |
$_GET = add_magic_quotes( $_GET ); |
934 |
$_POST = add_magic_quotes( $_POST ); |
|
0 | 935 |
$_COOKIE = add_magic_quotes( $_COOKIE ); |
936 |
$_SERVER = add_magic_quotes( $_SERVER ); |
|
937 |
||
938 |
// Force REQUEST to be GET + POST. |
|
939 |
$_REQUEST = array_merge( $_GET, $_POST ); |
|
940 |
} |
|
941 |
||
942 |
/** |
|
943 |
* Runs just before PHP shuts down execution. |
|
944 |
* |
|
5 | 945 |
* @since 1.2.0 |
0 | 946 |
* @access private |
947 |
*/ |
|
948 |
function shutdown_action_hook() { |
|
949 |
/** |
|
950 |
* Fires just before PHP shuts down execution. |
|
951 |
* |
|
952 |
* @since 1.2.0 |
|
953 |
*/ |
|
954 |
do_action( 'shutdown' ); |
|
5 | 955 |
|
0 | 956 |
wp_cache_close(); |
957 |
} |
|
958 |
||
959 |
/** |
|
960 |
* Copy an object. |
|
961 |
* |
|
962 |
* @since 2.7.0 |
|
5 | 963 |
* @deprecated 3.2.0 |
0 | 964 |
* |
5 | 965 |
* @param object $object The object to clone. |
966 |
* @return object The cloned object. |
|
0 | 967 |
*/ |
968 |
function wp_clone( $object ) { |
|
969 |
// Use parens for clone to accommodate PHP 4. See #17880 |
|
970 |
return clone( $object ); |
|
971 |
} |
|
972 |
||
973 |
/** |
|
9 | 974 |
* Determines whether the current request is for an administrative interface page. |
0 | 975 |
* |
9 | 976 |
* Does not check if the user is an administrator; use current_user_can() |
5 | 977 |
* for checking roles and capabilities. |
0 | 978 |
* |
9 | 979 |
* For more information on this and similar theme functions, check out |
980 |
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ |
|
981 |
* Conditional Tags} article in the Theme Developer Handbook. |
|
982 |
* |
|
0 | 983 |
* @since 1.5.1 |
984 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
985 |
* @global WP_Screen $current_screen |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
986 |
* |
5 | 987 |
* @return bool True if inside WordPress administration interface, false otherwise. |
0 | 988 |
*/ |
989 |
function is_admin() { |
|
9 | 990 |
if ( isset( $GLOBALS['current_screen'] ) ) { |
0 | 991 |
return $GLOBALS['current_screen']->in_admin(); |
9 | 992 |
} elseif ( defined( 'WP_ADMIN' ) ) { |
0 | 993 |
return WP_ADMIN; |
9 | 994 |
} |
0 | 995 |
|
996 |
return false; |
|
997 |
} |
|
998 |
||
999 |
/** |
|
5 | 1000 |
* Whether the current request is for a site's admininstrative interface. |
0 | 1001 |
* |
5 | 1002 |
* e.g. `/wp-admin/` |
1003 |
* |
|
9 | 1004 |
* Does not check if the user is an administrator; use current_user_can() |
5 | 1005 |
* for checking roles and capabilities. |
0 | 1006 |
* |
1007 |
* @since 3.1.0 |
|
1008 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1009 |
* @global WP_Screen $current_screen |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1010 |
* |
5 | 1011 |
* @return bool True if inside WordPress blog administration pages. |
0 | 1012 |
*/ |
1013 |
function is_blog_admin() { |
|
9 | 1014 |
if ( isset( $GLOBALS['current_screen'] ) ) { |
0 | 1015 |
return $GLOBALS['current_screen']->in_admin( 'site' ); |
9 | 1016 |
} elseif ( defined( 'WP_BLOG_ADMIN' ) ) { |
0 | 1017 |
return WP_BLOG_ADMIN; |
9 | 1018 |
} |
0 | 1019 |
|
1020 |
return false; |
|
1021 |
} |
|
1022 |
||
1023 |
/** |
|
5 | 1024 |
* Whether the current request is for the network administrative interface. |
0 | 1025 |
* |
5 | 1026 |
* e.g. `/wp-admin/network/` |
1027 |
* |
|
9 | 1028 |
* Does not check if the user is an administrator; use current_user_can() |
5 | 1029 |
* for checking roles and capabilities. |
0 | 1030 |
* |
1031 |
* @since 3.1.0 |
|
1032 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1033 |
* @global WP_Screen $current_screen |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1034 |
* |
0 | 1035 |
* @return bool True if inside WordPress network administration pages. |
1036 |
*/ |
|
1037 |
function is_network_admin() { |
|
9 | 1038 |
if ( isset( $GLOBALS['current_screen'] ) ) { |
0 | 1039 |
return $GLOBALS['current_screen']->in_admin( 'network' ); |
9 | 1040 |
} elseif ( defined( 'WP_NETWORK_ADMIN' ) ) { |
0 | 1041 |
return WP_NETWORK_ADMIN; |
9 | 1042 |
} |
0 | 1043 |
|
1044 |
return false; |
|
1045 |
} |
|
1046 |
||
1047 |
/** |
|
5 | 1048 |
* Whether the current request is for a user admin screen. |
1049 |
* |
|
1050 |
* e.g. `/wp-admin/user/` |
|
0 | 1051 |
* |
9 | 1052 |
* Does not check if the user is an administrator; use current_user_can() |
1053 |
* for checking roles and capabilities. |
|
0 | 1054 |
* |
1055 |
* @since 3.1.0 |
|
1056 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1057 |
* @global WP_Screen $current_screen |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1058 |
* |
0 | 1059 |
* @return bool True if inside WordPress user administration pages. |
1060 |
*/ |
|
1061 |
function is_user_admin() { |
|
9 | 1062 |
if ( isset( $GLOBALS['current_screen'] ) ) { |
0 | 1063 |
return $GLOBALS['current_screen']->in_admin( 'user' ); |
9 | 1064 |
} elseif ( defined( 'WP_USER_ADMIN' ) ) { |
0 | 1065 |
return WP_USER_ADMIN; |
9 | 1066 |
} |
0 | 1067 |
|
1068 |
return false; |
|
1069 |
} |
|
1070 |
||
1071 |
/** |
|
5 | 1072 |
* If Multisite is enabled. |
0 | 1073 |
* |
1074 |
* @since 3.0.0 |
|
1075 |
* |
|
5 | 1076 |
* @return bool True if Multisite is enabled, false otherwise. |
0 | 1077 |
*/ |
1078 |
function is_multisite() { |
|
9 | 1079 |
if ( defined( 'MULTISITE' ) ) { |
0 | 1080 |
return MULTISITE; |
9 | 1081 |
} |
0 | 1082 |
|
9 | 1083 |
if ( defined( 'SUBDOMAIN_INSTALL' ) || defined( 'VHOST' ) || defined( 'SUNRISE' ) ) { |
0 | 1084 |
return true; |
9 | 1085 |
} |
0 | 1086 |
|
1087 |
return false; |
|
1088 |
} |
|
1089 |
||
1090 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1091 |
* Retrieve the current site ID. |
0 | 1092 |
* |
1093 |
* @since 3.1.0 |
|
1094 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1095 |
* @global int $blog_id |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1096 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1097 |
* @return int Site ID. |
0 | 1098 |
*/ |
1099 |
function get_current_blog_id() { |
|
1100 |
global $blog_id; |
|
9 | 1101 |
return absint( $blog_id ); |
0 | 1102 |
} |
1103 |
||
1104 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1105 |
* Retrieves the current network ID. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1106 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1107 |
* @since 4.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1108 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1109 |
* @return int The ID of the current network. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1110 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1111 |
function get_current_network_id() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1112 |
if ( ! is_multisite() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1113 |
return 1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1114 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1115 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1116 |
$current_network = get_network(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1117 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1118 |
if ( ! isset( $current_network->id ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1119 |
return get_main_network_id(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1120 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1121 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1122 |
return absint( $current_network->id ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1123 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1124 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1125 |
/** |
5 | 1126 |
* Attempt an early load of translations. |
0 | 1127 |
* |
5 | 1128 |
* Used for errors encountered during the initial loading process, before |
1129 |
* the locale has been properly detected and loaded. |
|
0 | 1130 |
* |
5 | 1131 |
* Designed for unusual load sequences (like setup-config.php) or for when |
1132 |
* the script will then terminate with an error, otherwise there is a risk |
|
1133 |
* that a file can be double-included. |
|
0 | 1134 |
* |
1135 |
* @since 3.4.0 |
|
1136 |
* @access private |
|
5 | 1137 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1138 |
* @global WP_Locale $wp_locale The WordPress date and time locale object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1139 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1140 |
* @staticvar bool $loaded |
0 | 1141 |
*/ |
1142 |
function wp_load_translations_early() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1143 |
global $wp_locale; |
0 | 1144 |
|
1145 |
static $loaded = false; |
|
9 | 1146 |
if ( $loaded ) { |
0 | 1147 |
return; |
9 | 1148 |
} |
0 | 1149 |
$loaded = true; |
1150 |
||
9 | 1151 |
if ( function_exists( 'did_action' ) && did_action( 'init' ) ) { |
0 | 1152 |
return; |
9 | 1153 |
} |
0 | 1154 |
|
1155 |
// We need $wp_local_package |
|
1156 |
require ABSPATH . WPINC . '/version.php'; |
|
1157 |
||
1158 |
// Translation and localization |
|
1159 |
require_once ABSPATH . WPINC . '/pomo/mo.php'; |
|
1160 |
require_once ABSPATH . WPINC . '/l10n.php'; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1161 |
require_once ABSPATH . WPINC . '/class-wp-locale.php'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1162 |
require_once ABSPATH . WPINC . '/class-wp-locale-switcher.php'; |
0 | 1163 |
|
1164 |
// General libraries |
|
1165 |
require_once ABSPATH . WPINC . '/plugin.php'; |
|
1166 |
||
1167 |
$locales = $locations = array(); |
|
1168 |
||
1169 |
while ( true ) { |
|
1170 |
if ( defined( 'WPLANG' ) ) { |
|
9 | 1171 |
if ( '' == WPLANG ) { |
0 | 1172 |
break; |
9 | 1173 |
} |
0 | 1174 |
$locales[] = WPLANG; |
1175 |
} |
|
1176 |
||
9 | 1177 |
if ( isset( $wp_local_package ) ) { |
0 | 1178 |
$locales[] = $wp_local_package; |
9 | 1179 |
} |
0 | 1180 |
|
9 | 1181 |
if ( ! $locales ) { |
0 | 1182 |
break; |
9 | 1183 |
} |
0 | 1184 |
|
9 | 1185 |
if ( defined( 'WP_LANG_DIR' ) && @is_dir( WP_LANG_DIR ) ) { |
0 | 1186 |
$locations[] = WP_LANG_DIR; |
9 | 1187 |
} |
0 | 1188 |
|
9 | 1189 |
if ( defined( 'WP_CONTENT_DIR' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) ) { |
0 | 1190 |
$locations[] = WP_CONTENT_DIR . '/languages'; |
9 | 1191 |
} |
0 | 1192 |
|
9 | 1193 |
if ( @is_dir( ABSPATH . 'wp-content/languages' ) ) { |
0 | 1194 |
$locations[] = ABSPATH . 'wp-content/languages'; |
9 | 1195 |
} |
0 | 1196 |
|
9 | 1197 |
if ( @is_dir( ABSPATH . WPINC . '/languages' ) ) { |
0 | 1198 |
$locations[] = ABSPATH . WPINC . '/languages'; |
9 | 1199 |
} |
0 | 1200 |
|
9 | 1201 |
if ( ! $locations ) { |
0 | 1202 |
break; |
9 | 1203 |
} |
0 | 1204 |
|
1205 |
$locations = array_unique( $locations ); |
|
1206 |
||
1207 |
foreach ( $locales as $locale ) { |
|
1208 |
foreach ( $locations as $location ) { |
|
1209 |
if ( file_exists( $location . '/' . $locale . '.mo' ) ) { |
|
1210 |
load_textdomain( 'default', $location . '/' . $locale . '.mo' ); |
|
9 | 1211 |
if ( defined( 'WP_SETUP_CONFIG' ) && file_exists( $location . '/admin-' . $locale . '.mo' ) ) { |
0 | 1212 |
load_textdomain( 'default', $location . '/admin-' . $locale . '.mo' ); |
9 | 1213 |
} |
0 | 1214 |
break 2; |
1215 |
} |
|
1216 |
} |
|
1217 |
} |
|
1218 |
||
1219 |
break; |
|
1220 |
} |
|
1221 |
||
1222 |
$wp_locale = new WP_Locale(); |
|
1223 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1224 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1225 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1226 |
* Check or set whether WordPress is in "installation" mode. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1227 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1228 |
* 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
|
1229 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1230 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1231 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1232 |
* @staticvar bool $installing |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1233 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1234 |
* @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
|
1235 |
* 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
|
1236 |
* @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
|
1237 |
* 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
|
1238 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1239 |
function wp_installing( $is_installing = null ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1240 |
static $installing = null; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1241 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1242 |
// 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
|
1243 |
if ( is_null( $installing ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1244 |
$installing = defined( 'WP_INSTALLING' ) && WP_INSTALLING; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1245 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1246 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1247 |
if ( ! is_null( $is_installing ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1248 |
$old_installing = $installing; |
9 | 1249 |
$installing = $is_installing; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1250 |
return (bool) $old_installing; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1251 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1252 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1253 |
return (bool) $installing; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1254 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1255 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1256 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1257 |
* Determines if SSL is used. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1258 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1259 |
* @since 2.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1260 |
* @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
|
1261 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1262 |
* @return bool True if SSL, otherwise false. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1263 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1264 |
function is_ssl() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1265 |
if ( isset( $_SERVER['HTTPS'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1266 |
if ( 'on' == strtolower( $_SERVER['HTTPS'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1267 |
return true; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1268 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1269 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1270 |
if ( '1' == $_SERVER['HTTPS'] ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1271 |
return true; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1272 |
} |
9 | 1273 |
} elseif ( isset( $_SERVER['SERVER_PORT'] ) && ( '443' == $_SERVER['SERVER_PORT'] ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1274 |
return true; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1275 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1276 |
return false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1277 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1278 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1279 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1280 |
* 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
|
1281 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1282 |
* @since 2.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1283 |
* @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
|
1284 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1285 |
* @link https://secure.php.net/manual/en/function.ini-get.php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1286 |
* @link https://secure.php.net/manual/en/faq.using.php#faq.using.shorthandbytes |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1287 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1288 |
* @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
|
1289 |
* @return int An integer byte value. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1290 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1291 |
function wp_convert_hr_to_bytes( $value ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1292 |
$value = strtolower( trim( $value ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1293 |
$bytes = (int) $value; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1294 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1295 |
if ( false !== strpos( $value, 'g' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1296 |
$bytes *= GB_IN_BYTES; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1297 |
} elseif ( false !== strpos( $value, 'm' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1298 |
$bytes *= MB_IN_BYTES; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1299 |
} elseif ( false !== strpos( $value, 'k' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1300 |
$bytes *= KB_IN_BYTES; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1301 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1302 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1303 |
// 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
|
1304 |
return min( $bytes, PHP_INT_MAX ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1305 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1306 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1307 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1308 |
* 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
|
1309 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1310 |
* @since 4.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1311 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1312 |
* @staticvar array $ini_all |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1313 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1314 |
* @link https://secure.php.net/manual/en/function.ini-get-all.php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1315 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1316 |
* @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
|
1317 |
* @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
|
1318 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1319 |
function wp_is_ini_value_changeable( $setting ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1320 |
static $ini_all; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1321 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1322 |
if ( ! isset( $ini_all ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1323 |
$ini_all = false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1324 |
// 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
|
1325 |
if ( function_exists( 'ini_get_all' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1326 |
$ini_all = ini_get_all(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1327 |
} |
9 | 1328 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1329 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1330 |
// Bit operator to workaround https://bugs.php.net/bug.php?id=44936 which changes access level to 63 in PHP 5.2.6 - 5.2.17. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1331 |
if ( isset( $ini_all[ $setting ]['access'] ) && ( INI_ALL === ( $ini_all[ $setting ]['access'] & 7 ) || INI_USER === ( $ini_all[ $setting ]['access'] & 7 ) ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1332 |
return true; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1333 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1334 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1335 |
// 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
|
1336 |
if ( ! is_array( $ini_all ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1337 |
return true; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1338 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1339 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1340 |
return false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1341 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1342 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1343 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1344 |
* 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
|
1345 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1346 |
* @since 4.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1347 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1348 |
* @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
|
1349 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1350 |
function wp_doing_ajax() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1351 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1352 |
* 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
|
1353 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1354 |
* @since 4.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1355 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1356 |
* @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
|
1357 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1358 |
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
|
1359 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1360 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1361 |
/** |
9 | 1362 |
* Determines whether the current request should use themes. |
1363 |
* |
|
1364 |
* @since 5.1.0 |
|
1365 |
* |
|
1366 |
* @return bool True if themes should be used, false otherwise. |
|
1367 |
*/ |
|
1368 |
function wp_using_themes() { |
|
1369 |
/** |
|
1370 |
* Filters whether the current request should use themes. |
|
1371 |
* |
|
1372 |
* @since 5.1.0 |
|
1373 |
* |
|
1374 |
* @param bool $wp_using_themes Whether the current request should use themes. |
|
1375 |
*/ |
|
1376 |
return apply_filters( 'wp_using_themes', defined( 'WP_USE_THEMES' ) && WP_USE_THEMES ); |
|
1377 |
} |
|
1378 |
||
1379 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1380 |
* 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
|
1381 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1382 |
* @since 4.8.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1383 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1384 |
* @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
|
1385 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1386 |
function wp_doing_cron() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1387 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1388 |
* 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
|
1389 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1390 |
* @since 4.8.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1391 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1392 |
* @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
|
1393 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1394 |
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
|
1395 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1396 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1397 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1398 |
* Check whether variable is a WordPress Error. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1399 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1400 |
* Returns true if $thing is an object of the WP_Error class. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1401 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1402 |
* @since 2.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1403 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1404 |
* @param mixed $thing Check if unknown variable is a WP_Error object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1405 |
* @return bool True, if WP_Error. False, if not WP_Error. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1406 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1407 |
function is_wp_error( $thing ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1408 |
return ( $thing instanceof WP_Error ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1409 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1410 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1411 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1412 |
* Determines whether file modifications are allowed. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1413 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1414 |
* @since 4.8.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1415 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1416 |
* @param string $context The usage context. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1417 |
* @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
|
1418 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1419 |
function wp_is_file_mod_allowed( $context ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1420 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1421 |
* Filters whether file modifications are allowed. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1422 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1423 |
* @since 4.8.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1424 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1425 |
* @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
|
1426 |
* @param string $context The usage context. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1427 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1428 |
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
|
1429 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1430 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1431 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1432 |
* Start scraping edited file errors. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1433 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1434 |
* @since 4.9.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1435 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1436 |
function wp_start_scraping_edited_file_errors() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1437 |
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
|
1438 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1439 |
} |
9 | 1440 |
$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
|
1441 |
$nonce = wp_unslash( $_REQUEST['wp_scrape_nonce'] ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1442 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1443 |
if ( get_transient( 'scrape_key_' . $key ) !== $nonce ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1444 |
echo "###### wp_scraping_result_start:$key ######"; |
9 | 1445 |
echo wp_json_encode( |
1446 |
array( |
|
1447 |
'code' => 'scrape_nonce_failure', |
|
1448 |
'message' => __( 'Scrape nonce check failed. Please try again.' ), |
|
1449 |
) |
|
1450 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1451 |
echo "###### wp_scraping_result_end:$key ######"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1452 |
die(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1453 |
} |
9 | 1454 |
if ( ! defined( 'WP_SANDBOX_SCRAPING' ) ) { |
1455 |
define( 'WP_SANDBOX_SCRAPING', true ); |
|
1456 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1457 |
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
|
1458 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1459 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1460 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1461 |
* Finalize scraping for edited file errors. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1462 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1463 |
* @since 4.9.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1464 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1465 |
* @param string $scrape_key Scrape key. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1466 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1467 |
function wp_finalize_scraping_edited_file_errors( $scrape_key ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1468 |
$error = error_get_last(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1469 |
echo "\n###### wp_scraping_result_start:$scrape_key ######\n"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1470 |
if ( ! empty( $error ) && in_array( $error['type'], array( E_CORE_ERROR, E_COMPILE_ERROR, E_ERROR, E_PARSE, E_USER_ERROR, E_RECOVERABLE_ERROR ), true ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1471 |
$error = str_replace( ABSPATH, '', $error ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1472 |
echo wp_json_encode( $error ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1473 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1474 |
echo wp_json_encode( true ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1475 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1476 |
echo "\n###### wp_scraping_result_end:$scrape_key ######\n"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1477 |
} |
9 | 1478 |
|
1479 |
/** |
|
1480 |
* Checks whether current request is a JSON request, or is expecting a JSON response. |
|
1481 |
* |
|
1482 |
* @since 5.0.0 |
|
1483 |
* |
|
1484 |
* @return bool True if Accepts or Content-Type headers contain application/json, false otherwise. |
|
1485 |
*/ |
|
1486 |
function wp_is_json_request() { |
|
1487 |
||
1488 |
if ( isset( $_SERVER['HTTP_ACCEPT'] ) && false !== strpos( $_SERVER['HTTP_ACCEPT'], 'application/json' ) ) { |
|
1489 |
return true; |
|
1490 |
} |
|
1491 |
||
1492 |
if ( isset( $_SERVER['CONTENT_TYPE'] ) && 'application/json' === $_SERVER['CONTENT_TYPE'] ) { |
|
1493 |
return true; |
|
1494 |
} |
|
1495 |
||
1496 |
return false; |
|
1497 |
||
1498 |
} |
|
1499 |
||
1500 |
/** |
|
1501 |
* Checks whether current request is a JSONP request, or is expecting a JSONP response. |
|
1502 |
* |
|
1503 |
* @since 5.2.0 |
|
1504 |
* |
|
1505 |
* @return bool True if JSONP request, false otherwise. |
|
1506 |
*/ |
|
1507 |
function wp_is_jsonp_request() { |
|
1508 |
if ( ! isset( $_GET['_jsonp'] ) ) { |
|
1509 |
return false; |
|
1510 |
} |
|
1511 |
||
1512 |
if ( ! function_exists( 'wp_check_jsonp_callback' ) ) { |
|
1513 |
require_once ABSPATH . WPINC . '/functions.php'; |
|
1514 |
} |
|
1515 |
||
1516 |
$jsonp_callback = $_GET['_jsonp']; |
|
1517 |
if ( ! wp_check_jsonp_callback( $jsonp_callback ) ) { |
|
1518 |
return false; |
|
1519 |
} |
|
1520 |
||
1521 |
/** This filter is documented in wp-includes/rest-api/class-wp-rest-server.php */ |
|
1522 |
$jsonp_enabled = apply_filters( 'rest_jsonp_enabled', true ); |
|
1523 |
||
1524 |
return $jsonp_enabled; |
|
1525 |
||
1526 |
} |
|
1527 |
||
1528 |
/** |
|
1529 |
* Checks whether current request is an XML request, or is expecting an XML response. |
|
1530 |
* |
|
1531 |
* @since 5.2.0 |
|
1532 |
* |
|
1533 |
* @return bool True if Accepts or Content-Type headers contain xml, false otherwise. |
|
1534 |
*/ |
|
1535 |
function wp_is_xml_request() { |
|
1536 |
$accepted = array( |
|
1537 |
'text/xml', |
|
1538 |
'application/rss+xml', |
|
1539 |
'application/atom+xml', |
|
1540 |
'application/rdf+xml', |
|
1541 |
'text/xml+oembed', |
|
1542 |
'application/xml+oembed', |
|
1543 |
); |
|
1544 |
||
1545 |
if ( isset( $_SERVER['HTTP_ACCEPT'] ) ) { |
|
1546 |
foreach ( $accepted as $type ) { |
|
1547 |
if ( false !== strpos( $_SERVER['HTTP_ACCEPT'], $type ) ) { |
|
1548 |
return true; |
|
1549 |
} |
|
1550 |
} |
|
1551 |
} |
|
1552 |
||
1553 |
if ( isset( $_SERVER['CONTENT_TYPE'] ) && in_array( $_SERVER['CONTENT_TYPE'], $accepted, true ) ) { |
|
1554 |
return true; |
|
1555 |
} |
|
1556 |
||
1557 |
return false; |
|
1558 |
} |