author | ymh <ymh.work@gmail.com> |
Mon, 14 Oct 2019 17:39:30 +0200 | |
changeset 7 | cf61fcea0001 |
parent 5 | 5e2f62d02dcd |
child 9 | 177826044cd9 |
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() { |
|
30 |
if ( !ini_get( 'register_globals' ) ) |
|
31 |
return; |
|
32 |
||
33 |
if ( isset( $_REQUEST['GLOBALS'] ) ) |
|
34 |
die( 'GLOBALS overwrite attempt detected' ); |
|
35 |
||
36 |
// Variables that shouldn't be unset |
|
37 |
$no_unset = array( 'GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix' ); |
|
38 |
||
39 |
$input = array_merge( $_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset( $_SESSION ) && is_array( $_SESSION ) ? $_SESSION : array() ); |
|
40 |
foreach ( $input as $k => $v ) |
|
41 |
if ( !in_array( $k, $no_unset ) && isset( $GLOBALS[$k] ) ) { |
|
42 |
unset( $GLOBALS[$k] ); |
|
43 |
} |
|
44 |
} |
|
45 |
||
46 |
/** |
|
5 | 47 |
* Fix `$_SERVER` variables for various setups. |
0 | 48 |
* |
5 | 49 |
* @since 3.0.0 |
0 | 50 |
* @access private |
5 | 51 |
* |
52 |
* @global string $PHP_SELF The filename of the currently executing script, |
|
53 |
* relative to the document root. |
|
0 | 54 |
*/ |
55 |
function wp_fix_server_vars() { |
|
56 |
global $PHP_SELF; |
|
57 |
||
58 |
$default_server_values = array( |
|
59 |
'SERVER_SOFTWARE' => '', |
|
60 |
'REQUEST_URI' => '', |
|
61 |
); |
|
62 |
||
63 |
$_SERVER = array_merge( $default_server_values, $_SERVER ); |
|
64 |
||
65 |
// Fix for IIS when running with PHP ISAPI |
|
5 | 66 |
if ( empty( $_SERVER['REQUEST_URI'] ) || ( PHP_SAPI != 'cgi-fcgi' && preg_match( '/^Microsoft-IIS\//', $_SERVER['SERVER_SOFTWARE'] ) ) ) { |
0 | 67 |
|
68 |
// IIS Mod-Rewrite |
|
69 |
if ( isset( $_SERVER['HTTP_X_ORIGINAL_URL'] ) ) { |
|
70 |
$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL']; |
|
71 |
} |
|
72 |
// IIS Isapi_Rewrite |
|
5 | 73 |
elseif ( isset( $_SERVER['HTTP_X_REWRITE_URL'] ) ) { |
0 | 74 |
$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL']; |
75 |
} else { |
|
76 |
// Use ORIG_PATH_INFO if there is no PATH_INFO |
|
77 |
if ( !isset( $_SERVER['PATH_INFO'] ) && isset( $_SERVER['ORIG_PATH_INFO'] ) ) |
|
78 |
$_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO']; |
|
79 |
||
80 |
// Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice) |
|
81 |
if ( isset( $_SERVER['PATH_INFO'] ) ) { |
|
82 |
if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] ) |
|
83 |
$_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO']; |
|
84 |
else |
|
85 |
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO']; |
|
86 |
} |
|
87 |
||
88 |
// Append the query string if it exists and isn't null |
|
89 |
if ( ! empty( $_SERVER['QUERY_STRING'] ) ) { |
|
90 |
$_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
91 |
} |
|
92 |
} |
|
93 |
} |
|
94 |
||
95 |
// Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests |
|
96 |
if ( isset( $_SERVER['SCRIPT_FILENAME'] ) && ( strpos( $_SERVER['SCRIPT_FILENAME'], 'php.cgi' ) == strlen( $_SERVER['SCRIPT_FILENAME'] ) - 7 ) ) |
|
97 |
$_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED']; |
|
98 |
||
99 |
// Fix for Dreamhost and other PHP as CGI hosts |
|
100 |
if ( strpos( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) !== false ) |
|
101 |
unset( $_SERVER['PATH_INFO'] ); |
|
102 |
||
103 |
// Fix empty PHP_SELF |
|
104 |
$PHP_SELF = $_SERVER['PHP_SELF']; |
|
105 |
if ( empty( $PHP_SELF ) ) |
|
106 |
$_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace( '/(\?.*)?$/', '', $_SERVER["REQUEST_URI"] ); |
|
107 |
} |
|
108 |
||
109 |
/** |
|
5 | 110 |
* Check for the required PHP version, and the MySQL extension or |
111 |
* a database drop-in. |
|
0 | 112 |
* |
113 |
* Dies if requirements are not met. |
|
114 |
* |
|
5 | 115 |
* @since 3.0.0 |
0 | 116 |
* @access private |
5 | 117 |
* |
118 |
* @global string $required_php_version The required PHP version string. |
|
119 |
* @global string $wp_version The WordPress version string. |
|
0 | 120 |
*/ |
121 |
function wp_check_php_mysql_versions() { |
|
122 |
global $required_php_version, $wp_version; |
|
123 |
$php_version = phpversion(); |
|
5 | 124 |
|
0 | 125 |
if ( version_compare( $required_php_version, $php_version, '>' ) ) { |
126 |
wp_load_translations_early(); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
127 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
128 |
$protocol = wp_get_server_protocol(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
129 |
header( sprintf( '%s 500 Internal Server Error', $protocol ), true, 500 ); |
5 | 130 |
header( 'Content-Type: text/html; charset=utf-8' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
131 |
/* translators: 1: Current PHP version number, 2: WordPress version number, 3: Minimum required PHP version number */ |
0 | 132 |
die( sprintf( __( 'Your server is running PHP version %1$s but WordPress %2$s requires at least %3$s.' ), $php_version, $wp_version, $required_php_version ) ); |
133 |
} |
|
134 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
135 |
if ( ! extension_loaded( 'mysql' ) && ! extension_loaded( 'mysqli' ) && ! extension_loaded( 'mysqlnd' ) && ! file_exists( WP_CONTENT_DIR . '/db.php' ) ) { |
0 | 136 |
wp_load_translations_early(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
137 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
138 |
$protocol = wp_get_server_protocol(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
139 |
header( sprintf( '%s 500 Internal Server Error', $protocol ), true, 500 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
140 |
header( 'Content-Type: text/html; charset=utf-8' ); |
0 | 141 |
die( __( 'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.' ) ); |
142 |
} |
|
143 |
} |
|
144 |
||
145 |
/** |
|
146 |
* Don't load all of WordPress when handling a favicon.ico request. |
|
5 | 147 |
* |
0 | 148 |
* Instead, send the headers for a zero-length favicon and bail. |
149 |
* |
|
150 |
* @since 3.0.0 |
|
151 |
*/ |
|
152 |
function wp_favicon_request() { |
|
153 |
if ( '/favicon.ico' == $_SERVER['REQUEST_URI'] ) { |
|
154 |
header('Content-Type: image/vnd.microsoft.icon'); |
|
155 |
exit; |
|
156 |
} |
|
157 |
} |
|
158 |
||
159 |
/** |
|
5 | 160 |
* Die with a maintenance message when conditions are met. |
0 | 161 |
* |
162 |
* Checks for a file in the WordPress root directory named ".maintenance". |
|
163 |
* This file will contain the variable $upgrading, set to the time the file |
|
164 |
* was created. If the file was created less than 10 minutes ago, WordPress |
|
165 |
* enters maintenance mode and displays a message. |
|
166 |
* |
|
167 |
* The default message can be replaced by using a drop-in (maintenance.php in |
|
168 |
* the wp-content directory). |
|
169 |
* |
|
5 | 170 |
* @since 3.0.0 |
0 | 171 |
* @access private |
5 | 172 |
* |
173 |
* @global int $upgrading the unix timestamp marking when upgrading WordPress began. |
|
0 | 174 |
*/ |
175 |
function wp_maintenance() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
176 |
if ( ! file_exists( ABSPATH . '.maintenance' ) || wp_installing() ) |
0 | 177 |
return; |
178 |
||
179 |
global $upgrading; |
|
180 |
||
181 |
include( ABSPATH . '.maintenance' ); |
|
182 |
// If the $upgrading timestamp is older than 10 minutes, don't die. |
|
183 |
if ( ( time() - $upgrading ) >= 600 ) |
|
184 |
return; |
|
185 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
186 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
187 |
* Filters whether to enable maintenance mode. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
188 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
189 |
* 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
|
190 |
* 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
|
191 |
* 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
|
192 |
* continue processing even if maintenance mode should be active. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
193 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
194 |
* @since 4.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
195 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
196 |
* @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
|
197 |
* @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
|
198 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
199 |
if ( ! apply_filters( 'enable_maintenance_mode', true, $upgrading ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
200 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
201 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
202 |
|
0 | 203 |
if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) { |
204 |
require_once( WP_CONTENT_DIR . '/maintenance.php' ); |
|
205 |
die(); |
|
206 |
} |
|
207 |
||
208 |
wp_load_translations_early(); |
|
209 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
210 |
$protocol = wp_get_server_protocol(); |
0 | 211 |
header( "$protocol 503 Service Unavailable", true, 503 ); |
212 |
header( 'Content-Type: text/html; charset=utf-8' ); |
|
213 |
header( 'Retry-After: 600' ); |
|
214 |
?> |
|
215 |
<!DOCTYPE html> |
|
216 |
<html xmlns="http://www.w3.org/1999/xhtml"<?php if ( is_rtl() ) echo ' dir="rtl"'; ?>> |
|
217 |
<head> |
|
218 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
|
219 |
<title><?php _e( 'Maintenance' ); ?></title> |
|
220 |
||
221 |
</head> |
|
222 |
<body> |
|
223 |
<h1><?php _e( 'Briefly unavailable for scheduled maintenance. Check back in a minute.' ); ?></h1> |
|
224 |
</body> |
|
225 |
</html> |
|
226 |
<?php |
|
227 |
die(); |
|
228 |
} |
|
229 |
||
230 |
/** |
|
5 | 231 |
* Start the WordPress micro-timer. |
0 | 232 |
* |
5 | 233 |
* @since 0.71 |
0 | 234 |
* @access private |
5 | 235 |
* |
236 |
* @global float $timestart Unix timestamp set at the beginning of the page load. |
|
237 |
* @see timer_stop() |
|
238 |
* |
|
0 | 239 |
* @return bool Always returns true. |
240 |
*/ |
|
241 |
function timer_start() { |
|
242 |
global $timestart; |
|
243 |
$timestart = microtime( true ); |
|
244 |
return true; |
|
245 |
} |
|
246 |
||
247 |
/** |
|
5 | 248 |
* Retrieve or display the time from the page start to when function is called. |
0 | 249 |
* |
250 |
* @since 0.71 |
|
5 | 251 |
* |
252 |
* @global float $timestart Seconds from when timer_start() is called. |
|
253 |
* @global float $timeend Seconds from when function is called. |
|
0 | 254 |
* |
5 | 255 |
* @param int|bool $display Whether to echo or return the results. Accepts 0|false for return, |
256 |
* 1|true for echo. Default 0|false. |
|
257 |
* @param int $precision The number of digits from the right of the decimal to display. |
|
258 |
* Default 3. |
|
259 |
* @return string The "second.microsecond" finished time calculation. The number is formatted |
|
260 |
* for human consumption, both localized and rounded. |
|
0 | 261 |
*/ |
5 | 262 |
function timer_stop( $display = 0, $precision = 3 ) { |
0 | 263 |
global $timestart, $timeend; |
264 |
$timeend = microtime( true ); |
|
265 |
$timetotal = $timeend - $timestart; |
|
266 |
$r = ( function_exists( 'number_format_i18n' ) ) ? number_format_i18n( $timetotal, $precision ) : number_format( $timetotal, $precision ); |
|
267 |
if ( $display ) |
|
268 |
echo $r; |
|
269 |
return $r; |
|
270 |
} |
|
271 |
||
272 |
/** |
|
5 | 273 |
* Set PHP error reporting based on WordPress debug settings. |
274 |
* |
|
275 |
* 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
|
276 |
* 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
|
277 |
* `WP_DEBUG_LOG` are set to false, and `WP_DEBUG_DISPLAY` is set to true. |
0 | 278 |
* |
5 | 279 |
* When `WP_DEBUG` is true, all PHP notices are reported. WordPress will also |
280 |
* display internal notices: when a deprecated WordPress function, function |
|
281 |
* argument, or file is used. Deprecated code may be removed from a later |
|
282 |
* version. |
|
0 | 283 |
* |
5 | 284 |
* It is strongly recommended that plugin and theme developers use `WP_DEBUG` |
285 |
* in their development environments. |
|
0 | 286 |
* |
5 | 287 |
* `WP_DEBUG_DISPLAY` and `WP_DEBUG_LOG` perform no function unless `WP_DEBUG` |
288 |
* is true. |
|
0 | 289 |
* |
5 | 290 |
* When `WP_DEBUG_DISPLAY` is true, WordPress will force errors to be displayed. |
291 |
* `WP_DEBUG_DISPLAY` defaults to true. Defining it as null prevents WordPress |
|
292 |
* from changing the global configuration setting. Defining `WP_DEBUG_DISPLAY` |
|
293 |
* as false will force errors to be hidden. |
|
0 | 294 |
* |
5 | 295 |
* When `WP_DEBUG_LOG` is true, errors will be logged to debug.log in the content |
296 |
* directory. |
|
0 | 297 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
298 |
* Errors are never displayed for XML-RPC, REST, and Ajax requests. |
0 | 299 |
* |
5 | 300 |
* @since 3.0.0 |
0 | 301 |
* @access private |
302 |
*/ |
|
303 |
function wp_debug_mode() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
304 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
305 |
* 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
|
306 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
307 |
* 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
|
308 |
* 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
|
309 |
* 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
|
310 |
* 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
|
311 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
312 |
* @since 4.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
313 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
314 |
* @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
|
315 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
316 |
if ( ! apply_filters( 'enable_wp_debug_mode_checks', true ) ){ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
317 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
318 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
319 |
|
0 | 320 |
if ( WP_DEBUG ) { |
321 |
error_reporting( E_ALL ); |
|
322 |
||
323 |
if ( WP_DEBUG_DISPLAY ) |
|
324 |
ini_set( 'display_errors', 1 ); |
|
325 |
elseif ( null !== WP_DEBUG_DISPLAY ) |
|
326 |
ini_set( 'display_errors', 0 ); |
|
327 |
||
328 |
if ( WP_DEBUG_LOG ) { |
|
329 |
ini_set( 'log_errors', 1 ); |
|
330 |
ini_set( 'error_log', WP_CONTENT_DIR . '/debug.log' ); |
|
331 |
} |
|
332 |
} else { |
|
333 |
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 ); |
|
334 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
335 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
336 |
if ( defined( 'XMLRPC_REQUEST' ) || defined( 'REST_REQUEST' ) || ( defined( 'WP_INSTALLING' ) && WP_INSTALLING ) || wp_doing_ajax() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
337 |
@ini_set( 'display_errors', 0 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
338 |
} |
0 | 339 |
} |
340 |
||
341 |
/** |
|
5 | 342 |
* Set the location of the language directory. |
0 | 343 |
* |
5 | 344 |
* To set directory manually, define the `WP_LANG_DIR` constant |
345 |
* in wp-config.php. |
|
0 | 346 |
* |
5 | 347 |
* If the language directory exists within `WP_CONTENT_DIR`, it |
348 |
* is used. Otherwise the language directory is assumed to live |
|
349 |
* in `WPINC`. |
|
0 | 350 |
* |
5 | 351 |
* @since 3.0.0 |
0 | 352 |
* @access private |
353 |
*/ |
|
354 |
function wp_set_lang_dir() { |
|
355 |
if ( !defined( 'WP_LANG_DIR' ) ) { |
|
356 |
if ( file_exists( WP_CONTENT_DIR . '/languages' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) || !@is_dir(ABSPATH . WPINC . '/languages') ) { |
|
5 | 357 |
/** |
358 |
* Server path of the language directory. |
|
359 |
* |
|
360 |
* No leading slash, no trailing slash, full path, not relative to ABSPATH |
|
361 |
* |
|
362 |
* @since 2.1.0 |
|
363 |
*/ |
|
364 |
define( 'WP_LANG_DIR', WP_CONTENT_DIR . '/languages' ); |
|
0 | 365 |
if ( !defined( 'LANGDIR' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
366 |
// Old static relative path maintained for limited backward compatibility - won't work in some cases. |
0 | 367 |
define( 'LANGDIR', 'wp-content/languages' ); |
368 |
} |
|
369 |
} else { |
|
5 | 370 |
/** |
371 |
* Server path of the language directory. |
|
372 |
* |
|
373 |
* No leading slash, no trailing slash, full path, not relative to `ABSPATH`. |
|
374 |
* |
|
375 |
* @since 2.1.0 |
|
376 |
*/ |
|
377 |
define( 'WP_LANG_DIR', ABSPATH . WPINC . '/languages' ); |
|
0 | 378 |
if ( !defined( 'LANGDIR' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
379 |
// Old relative path maintained for backward compatibility. |
0 | 380 |
define( 'LANGDIR', WPINC . '/languages' ); |
381 |
} |
|
382 |
} |
|
383 |
} |
|
384 |
} |
|
385 |
||
386 |
/** |
|
5 | 387 |
* Load the database class file and instantiate the `$wpdb` global. |
0 | 388 |
* |
389 |
* @since 2.5.0 |
|
5 | 390 |
* |
391 |
* @global wpdb $wpdb The WordPress database class. |
|
0 | 392 |
*/ |
393 |
function require_wp_db() { |
|
394 |
global $wpdb; |
|
395 |
||
396 |
require_once( ABSPATH . WPINC . '/wp-db.php' ); |
|
397 |
if ( file_exists( WP_CONTENT_DIR . '/db.php' ) ) |
|
398 |
require_once( WP_CONTENT_DIR . '/db.php' ); |
|
399 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
400 |
if ( isset( $wpdb ) ) { |
0 | 401 |
return; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
402 |
} |
0 | 403 |
|
404 |
$wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST ); |
|
405 |
} |
|
406 |
||
407 |
/** |
|
5 | 408 |
* Set the database table prefix and the format specifiers for database |
409 |
* table columns. |
|
0 | 410 |
* |
5 | 411 |
* Columns not listed here default to `%s`. |
0 | 412 |
* |
5 | 413 |
* @since 3.0.0 |
414 |
* @access private |
|
0 | 415 |
* |
5 | 416 |
* @global wpdb $wpdb The WordPress database class. |
417 |
* @global string $table_prefix The database table prefix. |
|
0 | 418 |
*/ |
419 |
function wp_set_wpdb_vars() { |
|
420 |
global $wpdb, $table_prefix; |
|
421 |
if ( !empty( $wpdb->error ) ) |
|
422 |
dead_db(); |
|
423 |
||
424 |
$wpdb->field_types = array( 'post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d', |
|
425 |
'parent' => '%d', 'count' => '%d','object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'comment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d', |
|
426 |
'user_id' => '%d', 'link_id' => '%d', 'link_owner' => '%d', 'link_rating' => '%d', 'option_id' => '%d', 'blog_id' => '%d', 'meta_id' => '%d', 'post_id' => '%d', |
|
427 |
'user_status' => '%d', 'umeta_id' => '%d', 'comment_karma' => '%d', 'comment_count' => '%d', |
|
428 |
// multisite: |
|
429 |
'active' => '%d', 'cat_id' => '%d', 'deleted' => '%d', 'lang_id' => '%d', 'mature' => '%d', 'public' => '%d', 'site_id' => '%d', 'spam' => '%d', |
|
430 |
); |
|
431 |
||
432 |
$prefix = $wpdb->set_prefix( $table_prefix ); |
|
433 |
||
434 |
if ( is_wp_error( $prefix ) ) { |
|
435 |
wp_load_translations_early(); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
436 |
wp_die( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
437 |
/* translators: 1: $table_prefix 2: wp-config.php */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
438 |
sprintf( __( '<strong>ERROR</strong>: %1$s in %2$s can only contain numbers, letters, and underscores.' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
439 |
'<code>$table_prefix</code>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
440 |
'<code>wp-config.php</code>' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
441 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
442 |
); |
0 | 443 |
} |
444 |
} |
|
445 |
||
446 |
/** |
|
5 | 447 |
* Toggle `$_wp_using_ext_object_cache` on and off without directly |
448 |
* touching global. |
|
0 | 449 |
* |
450 |
* @since 3.7.0 |
|
451 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
452 |
* @global bool $_wp_using_ext_object_cache |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
453 |
* |
5 | 454 |
* @param bool $using Whether external object cache is being used. |
455 |
* @return bool The current 'using' setting. |
|
0 | 456 |
*/ |
457 |
function wp_using_ext_object_cache( $using = null ) { |
|
458 |
global $_wp_using_ext_object_cache; |
|
459 |
$current_using = $_wp_using_ext_object_cache; |
|
460 |
if ( null !== $using ) |
|
461 |
$_wp_using_ext_object_cache = $using; |
|
462 |
return $current_using; |
|
463 |
} |
|
464 |
||
465 |
/** |
|
5 | 466 |
* Start the WordPress object cache. |
0 | 467 |
* |
468 |
* If an object-cache.php file exists in the wp-content directory, |
|
469 |
* it uses that drop-in as an external object cache. |
|
470 |
* |
|
5 | 471 |
* @since 3.0.0 |
0 | 472 |
* @access private |
5 | 473 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
474 |
* @global array $wp_filter Stores all of the filters. |
0 | 475 |
*/ |
476 |
function wp_start_object_cache() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
477 |
global $wp_filter; |
0 | 478 |
|
479 |
$first_init = false; |
|
480 |
if ( ! function_exists( 'wp_cache_init' ) ) { |
|
481 |
if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { |
|
482 |
require_once ( WP_CONTENT_DIR . '/object-cache.php' ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
483 |
if ( function_exists( 'wp_cache_init' ) ) { |
0 | 484 |
wp_using_ext_object_cache( true ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
485 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
486 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
487 |
// Re-initialize any hooks added manually by object-cache.php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
488 |
if ( $wp_filter ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
489 |
$wp_filter = WP_Hook::build_preinitialized_hooks( $wp_filter ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
490 |
} |
0 | 491 |
} |
492 |
||
493 |
$first_init = true; |
|
5 | 494 |
} elseif ( ! wp_using_ext_object_cache() && file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { |
495 |
/* |
|
496 |
* Sometimes advanced-cache.php can load object-cache.php before |
|
497 |
* it is loaded here. This breaks the function_exists check above |
|
498 |
* and can result in `$_wp_using_ext_object_cache` being set |
|
499 |
* incorrectly. Double check if an external cache exists. |
|
500 |
*/ |
|
0 | 501 |
wp_using_ext_object_cache( true ); |
502 |
} |
|
503 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
504 |
if ( ! wp_using_ext_object_cache() ) { |
0 | 505 |
require_once ( ABSPATH . WPINC . '/cache.php' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
506 |
} |
0 | 507 |
|
5 | 508 |
/* |
509 |
* If cache supports reset, reset instead of init if already |
|
510 |
* initialized. Reset signals to the cache that global IDs |
|
511 |
* have changed and it may need to update keys and cleanup caches. |
|
512 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
513 |
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
|
514 |
wp_cache_switch_to_blog( get_current_blog_id() ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
515 |
} elseif ( function_exists( 'wp_cache_init' ) ) { |
0 | 516 |
wp_cache_init(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
517 |
} |
0 | 518 |
|
519 |
if ( function_exists( 'wp_cache_add_global_groups' ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
520 |
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' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
521 |
wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) ); |
0 | 522 |
} |
523 |
} |
|
524 |
||
525 |
/** |
|
5 | 526 |
* Redirect to the installer if WordPress is not installed. |
0 | 527 |
* |
5 | 528 |
* Dies with an error message when Multisite is enabled. |
0 | 529 |
* |
5 | 530 |
* @since 3.0.0 |
0 | 531 |
* @access private |
532 |
*/ |
|
533 |
function wp_not_installed() { |
|
534 |
if ( is_multisite() ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
535 |
if ( ! is_blog_installed() && ! wp_installing() ) { |
5 | 536 |
nocache_headers(); |
537 |
||
0 | 538 |
wp_die( __( 'The site you have requested is not installed properly. Please contact the system administrator.' ) ); |
5 | 539 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
540 |
} elseif ( ! is_blog_installed() && ! wp_installing() ) { |
5 | 541 |
nocache_headers(); |
542 |
||
0 | 543 |
require( ABSPATH . WPINC . '/kses.php' ); |
544 |
require( ABSPATH . WPINC . '/pluggable.php' ); |
|
545 |
require( ABSPATH . WPINC . '/formatting.php' ); |
|
546 |
||
547 |
$link = wp_guess_url() . '/wp-admin/install.php'; |
|
548 |
||
549 |
wp_redirect( $link ); |
|
550 |
die(); |
|
551 |
} |
|
552 |
} |
|
553 |
||
554 |
/** |
|
5 | 555 |
* Retrieve an array of must-use plugin files. |
0 | 556 |
* |
5 | 557 |
* The default directory is wp-content/mu-plugins. To change the default |
558 |
* directory manually, define `WPMU_PLUGIN_DIR` and `WPMU_PLUGIN_URL` |
|
0 | 559 |
* in wp-config.php. |
560 |
* |
|
5 | 561 |
* @since 3.0.0 |
0 | 562 |
* @access private |
5 | 563 |
* |
564 |
* @return array Files to include. |
|
0 | 565 |
*/ |
566 |
function wp_get_mu_plugins() { |
|
567 |
$mu_plugins = array(); |
|
568 |
if ( !is_dir( WPMU_PLUGIN_DIR ) ) |
|
569 |
return $mu_plugins; |
|
570 |
if ( ! $dh = opendir( WPMU_PLUGIN_DIR ) ) |
|
571 |
return $mu_plugins; |
|
572 |
while ( ( $plugin = readdir( $dh ) ) !== false ) { |
|
573 |
if ( substr( $plugin, -4 ) == '.php' ) |
|
574 |
$mu_plugins[] = WPMU_PLUGIN_DIR . '/' . $plugin; |
|
575 |
} |
|
576 |
closedir( $dh ); |
|
577 |
sort( $mu_plugins ); |
|
578 |
||
579 |
return $mu_plugins; |
|
580 |
} |
|
581 |
||
582 |
/** |
|
5 | 583 |
* Retrieve an array of active and valid plugin files. |
0 | 584 |
* |
5 | 585 |
* While upgrading or installing WordPress, no plugins are returned. |
586 |
* |
|
587 |
* The default directory is wp-content/plugins. To change the default |
|
588 |
* directory manually, define `WP_PLUGIN_DIR` and `WP_PLUGIN_URL` |
|
0 | 589 |
* in wp-config.php. |
590 |
* |
|
5 | 591 |
* @since 3.0.0 |
0 | 592 |
* @access private |
5 | 593 |
* |
594 |
* @return array Files. |
|
0 | 595 |
*/ |
596 |
function wp_get_active_and_valid_plugins() { |
|
597 |
$plugins = array(); |
|
598 |
$active_plugins = (array) get_option( 'active_plugins', array() ); |
|
599 |
||
600 |
// Check for hacks file if the option is enabled |
|
601 |
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
|
602 |
_deprecated_file( 'my-hacks.php', '1.5.0' ); |
0 | 603 |
array_unshift( $plugins, ABSPATH . 'my-hacks.php' ); |
604 |
} |
|
605 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
606 |
if ( empty( $active_plugins ) || wp_installing() ) |
0 | 607 |
return $plugins; |
608 |
||
609 |
$network_plugins = is_multisite() ? wp_get_active_network_plugins() : false; |
|
610 |
||
611 |
foreach ( $active_plugins as $plugin ) { |
|
612 |
if ( ! validate_file( $plugin ) // $plugin must validate as file |
|
613 |
&& '.php' == substr( $plugin, -4 ) // $plugin must end with '.php' |
|
614 |
&& file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist |
|
615 |
// not already included as a network plugin |
|
616 |
&& ( ! $network_plugins || ! in_array( WP_PLUGIN_DIR . '/' . $plugin, $network_plugins ) ) |
|
617 |
) |
|
618 |
$plugins[] = WP_PLUGIN_DIR . '/' . $plugin; |
|
619 |
} |
|
620 |
return $plugins; |
|
621 |
} |
|
622 |
||
623 |
/** |
|
5 | 624 |
* Set internal encoding. |
0 | 625 |
* |
5 | 626 |
* In most cases the default internal encoding is latin1, which is |
627 |
* of no use, since we want to use the `mb_` functions for `utf-8` strings. |
|
0 | 628 |
* |
5 | 629 |
* @since 3.0.0 |
0 | 630 |
* @access private |
631 |
*/ |
|
632 |
function wp_set_internal_encoding() { |
|
633 |
if ( function_exists( 'mb_internal_encoding' ) ) { |
|
634 |
$charset = get_option( 'blog_charset' ); |
|
635 |
if ( ! $charset || ! @mb_internal_encoding( $charset ) ) |
|
636 |
mb_internal_encoding( 'UTF-8' ); |
|
637 |
} |
|
638 |
} |
|
639 |
||
640 |
/** |
|
5 | 641 |
* Add magic quotes to `$_GET`, `$_POST`, `$_COOKIE`, and `$_SERVER`. |
0 | 642 |
* |
5 | 643 |
* Also forces `$_REQUEST` to be `$_GET + $_POST`. If `$_SERVER`, |
644 |
* `$_COOKIE`, or `$_ENV` are needed, use those superglobals directly. |
|
0 | 645 |
* |
5 | 646 |
* @since 3.0.0 |
0 | 647 |
* @access private |
648 |
*/ |
|
649 |
function wp_magic_quotes() { |
|
650 |
// If already slashed, strip. |
|
651 |
if ( get_magic_quotes_gpc() ) { |
|
652 |
$_GET = stripslashes_deep( $_GET ); |
|
653 |
$_POST = stripslashes_deep( $_POST ); |
|
654 |
$_COOKIE = stripslashes_deep( $_COOKIE ); |
|
655 |
} |
|
656 |
||
657 |
// Escape with wpdb. |
|
658 |
$_GET = add_magic_quotes( $_GET ); |
|
659 |
$_POST = add_magic_quotes( $_POST ); |
|
660 |
$_COOKIE = add_magic_quotes( $_COOKIE ); |
|
661 |
$_SERVER = add_magic_quotes( $_SERVER ); |
|
662 |
||
663 |
// Force REQUEST to be GET + POST. |
|
664 |
$_REQUEST = array_merge( $_GET, $_POST ); |
|
665 |
} |
|
666 |
||
667 |
/** |
|
668 |
* Runs just before PHP shuts down execution. |
|
669 |
* |
|
5 | 670 |
* @since 1.2.0 |
0 | 671 |
* @access private |
672 |
*/ |
|
673 |
function shutdown_action_hook() { |
|
674 |
/** |
|
675 |
* Fires just before PHP shuts down execution. |
|
676 |
* |
|
677 |
* @since 1.2.0 |
|
678 |
*/ |
|
679 |
do_action( 'shutdown' ); |
|
5 | 680 |
|
0 | 681 |
wp_cache_close(); |
682 |
} |
|
683 |
||
684 |
/** |
|
685 |
* Copy an object. |
|
686 |
* |
|
687 |
* @since 2.7.0 |
|
5 | 688 |
* @deprecated 3.2.0 |
0 | 689 |
* |
5 | 690 |
* @param object $object The object to clone. |
691 |
* @return object The cloned object. |
|
0 | 692 |
*/ |
693 |
function wp_clone( $object ) { |
|
694 |
// Use parens for clone to accommodate PHP 4. See #17880 |
|
695 |
return clone( $object ); |
|
696 |
} |
|
697 |
||
698 |
/** |
|
5 | 699 |
* Whether the current request is for an administrative interface page. |
0 | 700 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
701 |
* Does not check if the user is an administrator; current_user_can() |
5 | 702 |
* for checking roles and capabilities. |
0 | 703 |
* |
704 |
* @since 1.5.1 |
|
705 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
706 |
* @global WP_Screen $current_screen |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
707 |
* |
5 | 708 |
* @return bool True if inside WordPress administration interface, false otherwise. |
0 | 709 |
*/ |
710 |
function is_admin() { |
|
711 |
if ( isset( $GLOBALS['current_screen'] ) ) |
|
712 |
return $GLOBALS['current_screen']->in_admin(); |
|
713 |
elseif ( defined( 'WP_ADMIN' ) ) |
|
714 |
return WP_ADMIN; |
|
715 |
||
716 |
return false; |
|
717 |
} |
|
718 |
||
719 |
/** |
|
5 | 720 |
* Whether the current request is for a site's admininstrative interface. |
0 | 721 |
* |
5 | 722 |
* e.g. `/wp-admin/` |
723 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
724 |
* Does not check if the user is an administrator; current_user_can() |
5 | 725 |
* for checking roles and capabilities. |
0 | 726 |
* |
727 |
* @since 3.1.0 |
|
728 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
729 |
* @global WP_Screen $current_screen |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
730 |
* |
5 | 731 |
* @return bool True if inside WordPress blog administration pages. |
0 | 732 |
*/ |
733 |
function is_blog_admin() { |
|
734 |
if ( isset( $GLOBALS['current_screen'] ) ) |
|
735 |
return $GLOBALS['current_screen']->in_admin( 'site' ); |
|
736 |
elseif ( defined( 'WP_BLOG_ADMIN' ) ) |
|
737 |
return WP_BLOG_ADMIN; |
|
738 |
||
739 |
return false; |
|
740 |
} |
|
741 |
||
742 |
/** |
|
5 | 743 |
* Whether the current request is for the network administrative interface. |
0 | 744 |
* |
5 | 745 |
* e.g. `/wp-admin/network/` |
746 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
747 |
* Does not check if the user is an administrator; current_user_can() |
5 | 748 |
* for checking roles and capabilities. |
0 | 749 |
* |
750 |
* @since 3.1.0 |
|
751 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
752 |
* @global WP_Screen $current_screen |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
753 |
* |
0 | 754 |
* @return bool True if inside WordPress network administration pages. |
755 |
*/ |
|
756 |
function is_network_admin() { |
|
757 |
if ( isset( $GLOBALS['current_screen'] ) ) |
|
758 |
return $GLOBALS['current_screen']->in_admin( 'network' ); |
|
759 |
elseif ( defined( 'WP_NETWORK_ADMIN' ) ) |
|
760 |
return WP_NETWORK_ADMIN; |
|
761 |
||
762 |
return false; |
|
763 |
} |
|
764 |
||
765 |
/** |
|
5 | 766 |
* Whether the current request is for a user admin screen. |
767 |
* |
|
768 |
* e.g. `/wp-admin/user/` |
|
0 | 769 |
* |
5 | 770 |
* Does not inform on whether the user is an admin! Use capability |
771 |
* checks to tell if the user should be accessing a section or not |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
772 |
* current_user_can(). |
0 | 773 |
* |
774 |
* @since 3.1.0 |
|
775 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
776 |
* @global WP_Screen $current_screen |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
777 |
* |
0 | 778 |
* @return bool True if inside WordPress user administration pages. |
779 |
*/ |
|
780 |
function is_user_admin() { |
|
781 |
if ( isset( $GLOBALS['current_screen'] ) ) |
|
782 |
return $GLOBALS['current_screen']->in_admin( 'user' ); |
|
783 |
elseif ( defined( 'WP_USER_ADMIN' ) ) |
|
784 |
return WP_USER_ADMIN; |
|
785 |
||
786 |
return false; |
|
787 |
} |
|
788 |
||
789 |
/** |
|
5 | 790 |
* If Multisite is enabled. |
0 | 791 |
* |
792 |
* @since 3.0.0 |
|
793 |
* |
|
5 | 794 |
* @return bool True if Multisite is enabled, false otherwise. |
0 | 795 |
*/ |
796 |
function is_multisite() { |
|
797 |
if ( defined( 'MULTISITE' ) ) |
|
798 |
return MULTISITE; |
|
799 |
||
800 |
if ( defined( 'SUBDOMAIN_INSTALL' ) || defined( 'VHOST' ) || defined( 'SUNRISE' ) ) |
|
801 |
return true; |
|
802 |
||
803 |
return false; |
|
804 |
} |
|
805 |
||
806 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
807 |
* Retrieve the current site ID. |
0 | 808 |
* |
809 |
* @since 3.1.0 |
|
810 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
811 |
* @global int $blog_id |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
812 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
813 |
* @return int Site ID. |
0 | 814 |
*/ |
815 |
function get_current_blog_id() { |
|
816 |
global $blog_id; |
|
817 |
return absint($blog_id); |
|
818 |
} |
|
819 |
||
820 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
821 |
* Retrieves the current network ID. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
822 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
823 |
* @since 4.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
824 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
825 |
* @return int The ID of the current network. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
826 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
827 |
function get_current_network_id() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
828 |
if ( ! is_multisite() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
829 |
return 1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
830 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
831 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
832 |
$current_network = get_network(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
833 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
834 |
if ( ! isset( $current_network->id ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
835 |
return get_main_network_id(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
836 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
837 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
838 |
return absint( $current_network->id ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
839 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
840 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
841 |
/** |
5 | 842 |
* Attempt an early load of translations. |
0 | 843 |
* |
5 | 844 |
* Used for errors encountered during the initial loading process, before |
845 |
* the locale has been properly detected and loaded. |
|
0 | 846 |
* |
5 | 847 |
* Designed for unusual load sequences (like setup-config.php) or for when |
848 |
* the script will then terminate with an error, otherwise there is a risk |
|
849 |
* that a file can be double-included. |
|
0 | 850 |
* |
851 |
* @since 3.4.0 |
|
852 |
* @access private |
|
5 | 853 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
854 |
* @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
|
855 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
856 |
* @staticvar bool $loaded |
0 | 857 |
*/ |
858 |
function wp_load_translations_early() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
859 |
global $wp_locale; |
0 | 860 |
|
861 |
static $loaded = false; |
|
862 |
if ( $loaded ) |
|
863 |
return; |
|
864 |
$loaded = true; |
|
865 |
||
866 |
if ( function_exists( 'did_action' ) && did_action( 'init' ) ) |
|
867 |
return; |
|
868 |
||
869 |
// We need $wp_local_package |
|
870 |
require ABSPATH . WPINC . '/version.php'; |
|
871 |
||
872 |
// Translation and localization |
|
873 |
require_once ABSPATH . WPINC . '/pomo/mo.php'; |
|
874 |
require_once ABSPATH . WPINC . '/l10n.php'; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
875 |
require_once ABSPATH . WPINC . '/class-wp-locale.php'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
876 |
require_once ABSPATH . WPINC . '/class-wp-locale-switcher.php'; |
0 | 877 |
|
878 |
// General libraries |
|
879 |
require_once ABSPATH . WPINC . '/plugin.php'; |
|
880 |
||
881 |
$locales = $locations = array(); |
|
882 |
||
883 |
while ( true ) { |
|
884 |
if ( defined( 'WPLANG' ) ) { |
|
885 |
if ( '' == WPLANG ) |
|
886 |
break; |
|
887 |
$locales[] = WPLANG; |
|
888 |
} |
|
889 |
||
890 |
if ( isset( $wp_local_package ) ) |
|
891 |
$locales[] = $wp_local_package; |
|
892 |
||
893 |
if ( ! $locales ) |
|
894 |
break; |
|
895 |
||
896 |
if ( defined( 'WP_LANG_DIR' ) && @is_dir( WP_LANG_DIR ) ) |
|
897 |
$locations[] = WP_LANG_DIR; |
|
898 |
||
899 |
if ( defined( 'WP_CONTENT_DIR' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) ) |
|
900 |
$locations[] = WP_CONTENT_DIR . '/languages'; |
|
901 |
||
902 |
if ( @is_dir( ABSPATH . 'wp-content/languages' ) ) |
|
903 |
$locations[] = ABSPATH . 'wp-content/languages'; |
|
904 |
||
905 |
if ( @is_dir( ABSPATH . WPINC . '/languages' ) ) |
|
906 |
$locations[] = ABSPATH . WPINC . '/languages'; |
|
907 |
||
908 |
if ( ! $locations ) |
|
909 |
break; |
|
910 |
||
911 |
$locations = array_unique( $locations ); |
|
912 |
||
913 |
foreach ( $locales as $locale ) { |
|
914 |
foreach ( $locations as $location ) { |
|
915 |
if ( file_exists( $location . '/' . $locale . '.mo' ) ) { |
|
916 |
load_textdomain( 'default', $location . '/' . $locale . '.mo' ); |
|
917 |
if ( defined( 'WP_SETUP_CONFIG' ) && file_exists( $location . '/admin-' . $locale . '.mo' ) ) |
|
918 |
load_textdomain( 'default', $location . '/admin-' . $locale . '.mo' ); |
|
919 |
break 2; |
|
920 |
} |
|
921 |
} |
|
922 |
} |
|
923 |
||
924 |
break; |
|
925 |
} |
|
926 |
||
927 |
$wp_locale = new WP_Locale(); |
|
928 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
929 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
930 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
931 |
* Check or set whether WordPress is in "installation" mode. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
932 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
933 |
* 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
|
934 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
935 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
936 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
937 |
* @staticvar bool $installing |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
938 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
939 |
* @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
|
940 |
* 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
|
941 |
* @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
|
942 |
* 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
|
943 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
944 |
function wp_installing( $is_installing = null ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
945 |
static $installing = null; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
946 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
947 |
// 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
|
948 |
if ( is_null( $installing ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
949 |
$installing = defined( 'WP_INSTALLING' ) && WP_INSTALLING; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
950 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
951 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
952 |
if ( ! is_null( $is_installing ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
953 |
$old_installing = $installing; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
954 |
$installing = $is_installing; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
955 |
return (bool) $old_installing; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
956 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
957 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
958 |
return (bool) $installing; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
959 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
960 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
961 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
962 |
* Determines if SSL is used. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
963 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
964 |
* @since 2.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
965 |
* @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
|
966 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
967 |
* @return bool True if SSL, otherwise false. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
968 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
969 |
function is_ssl() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
970 |
if ( isset( $_SERVER['HTTPS'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
971 |
if ( 'on' == strtolower( $_SERVER['HTTPS'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
972 |
return true; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
973 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
974 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
975 |
if ( '1' == $_SERVER['HTTPS'] ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
976 |
return true; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
977 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
978 |
} elseif ( isset($_SERVER['SERVER_PORT'] ) && ( '443' == $_SERVER['SERVER_PORT'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
979 |
return true; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
980 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
981 |
return false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
982 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
983 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
984 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
985 |
* 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
|
986 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
987 |
* @since 2.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
988 |
* @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
|
989 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
990 |
* @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
|
991 |
* @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
|
992 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
993 |
* @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
|
994 |
* @return int An integer byte value. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
995 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
996 |
function wp_convert_hr_to_bytes( $value ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
997 |
$value = strtolower( trim( $value ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
998 |
$bytes = (int) $value; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
999 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1000 |
if ( false !== strpos( $value, 'g' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1001 |
$bytes *= GB_IN_BYTES; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1002 |
} elseif ( false !== strpos( $value, 'm' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1003 |
$bytes *= MB_IN_BYTES; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1004 |
} elseif ( false !== strpos( $value, 'k' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1005 |
$bytes *= KB_IN_BYTES; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1006 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1007 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1008 |
// 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
|
1009 |
return min( $bytes, PHP_INT_MAX ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1010 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1011 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1012 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1013 |
* 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
|
1014 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1015 |
* @since 4.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1016 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1017 |
* @staticvar array $ini_all |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1018 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1019 |
* @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
|
1020 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1021 |
* @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
|
1022 |
* @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
|
1023 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1024 |
function wp_is_ini_value_changeable( $setting ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1025 |
static $ini_all; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1026 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1027 |
if ( ! isset( $ini_all ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1028 |
$ini_all = false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1029 |
// 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
|
1030 |
if ( function_exists( 'ini_get_all' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1031 |
$ini_all = ini_get_all(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1032 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1033 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1034 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1035 |
// 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
|
1036 |
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
|
1037 |
return true; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1038 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1039 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1040 |
// 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
|
1041 |
if ( ! is_array( $ini_all ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1042 |
return true; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1043 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1044 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1045 |
return false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1046 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1047 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1048 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1049 |
* 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
|
1050 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1051 |
* @since 4.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1052 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1053 |
* @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
|
1054 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1055 |
function wp_doing_ajax() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1056 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1057 |
* 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
|
1058 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1059 |
* @since 4.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1060 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1061 |
* @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
|
1062 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1063 |
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
|
1064 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1065 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1066 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1067 |
* 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
|
1068 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1069 |
* @since 4.8.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1070 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1071 |
* @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
|
1072 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1073 |
function wp_doing_cron() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1074 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1075 |
* 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
|
1076 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1077 |
* @since 4.8.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1078 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1079 |
* @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
|
1080 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1081 |
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
|
1082 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1083 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1084 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1085 |
* Check whether variable is a WordPress Error. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1086 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1087 |
* 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
|
1088 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1089 |
* @since 2.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1090 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1091 |
* @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
|
1092 |
* @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
|
1093 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1094 |
function is_wp_error( $thing ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1095 |
return ( $thing instanceof WP_Error ); |
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 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1098 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1099 |
* Determines whether file modifications are allowed. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1100 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1101 |
* @since 4.8.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1102 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1103 |
* @param string $context The usage context. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1104 |
* @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
|
1105 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1106 |
function wp_is_file_mod_allowed( $context ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1107 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1108 |
* Filters whether file modifications are allowed. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1109 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1110 |
* @since 4.8.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1111 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1112 |
* @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
|
1113 |
* @param string $context The usage context. |
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 |
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
|
1116 |
} |
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 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1119 |
* Start scraping edited file errors. |
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 |
* @since 4.9.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1122 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1123 |
function wp_start_scraping_edited_file_errors() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1124 |
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
|
1125 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1126 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1127 |
$key = substr( sanitize_key( wp_unslash( $_REQUEST['wp_scrape_key'] ) ), 0, 32 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1128 |
$nonce = wp_unslash( $_REQUEST['wp_scrape_nonce'] ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1129 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1130 |
if ( get_transient( 'scrape_key_' . $key ) !== $nonce ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1131 |
echo "###### wp_scraping_result_start:$key ######"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1132 |
echo wp_json_encode( array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1133 |
'code' => 'scrape_nonce_failure', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1134 |
'message' => __( 'Scrape nonce check failed. Please try again.' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1135 |
) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1136 |
echo "###### wp_scraping_result_end:$key ######"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1137 |
die(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1138 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1139 |
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
|
1140 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1141 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1142 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1143 |
* Finalize scraping for edited file errors. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1144 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1145 |
* @since 4.9.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1146 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1147 |
* @param string $scrape_key Scrape key. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1148 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1149 |
function wp_finalize_scraping_edited_file_errors( $scrape_key ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1150 |
$error = error_get_last(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1151 |
echo "\n###### wp_scraping_result_start:$scrape_key ######\n"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1152 |
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
|
1153 |
$error = str_replace( ABSPATH, '', $error ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1154 |
echo wp_json_encode( $error ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1155 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1156 |
echo wp_json_encode( true ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1157 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1158 |
echo "\n###### wp_scraping_result_end:$scrape_key ######\n"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1159 |
} |