Update WordPress to 5.2
This commit is contained in:
parent
489b5a5914
commit
e00f87f2f5
599 changed files with 119573 additions and 55990 deletions
|
@ -214,31 +214,16 @@ function wp_maintenance() {
|
|||
die();
|
||||
}
|
||||
|
||||
require_once( ABSPATH . WPINC . '/functions.php' );
|
||||
wp_load_translations_early();
|
||||
|
||||
$protocol = wp_get_server_protocol();
|
||||
header( "$protocol 503 Service Unavailable", true, 503 );
|
||||
header( 'Content-Type: text/html; charset=utf-8' );
|
||||
header( 'Retry-After: 600' );
|
||||
|
||||
$dir_attr = '';
|
||||
if ( is_rtl() ) {
|
||||
$dir_attr = ' dir="rtl"';
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"<?php echo $dir_attr; ?>>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title><?php _e( 'Maintenance' ); ?></title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<h1><?php _e( 'Briefly unavailable for scheduled maintenance. Check back in a minute.' ); ?></h1>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
die();
|
||||
wp_die(
|
||||
__( 'Briefly unavailable for scheduled maintenance. Check back in a minute.' ),
|
||||
__( 'Maintenance' ),
|
||||
503
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -697,6 +682,43 @@ function wp_get_active_and_valid_plugins() {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove plugins from the list of active plugins when we're on an endpoint
|
||||
* that should be protected against WSODs and the plugin is paused.
|
||||
*/
|
||||
if ( wp_is_recovery_mode() ) {
|
||||
$plugins = wp_skip_paused_plugins( $plugins );
|
||||
}
|
||||
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters a given list of plugins, removing any paused plugins from it.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @param array $plugins List of absolute plugin main file paths.
|
||||
* @return array Filtered value of $plugins, without any paused plugins.
|
||||
*/
|
||||
function wp_skip_paused_plugins( array $plugins ) {
|
||||
$paused_plugins = wp_paused_plugins()->get_all();
|
||||
|
||||
if ( empty( $paused_plugins ) ) {
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
foreach ( $plugins as $index => $plugin ) {
|
||||
list( $plugin ) = explode( '/', plugin_basename( $plugin ) );
|
||||
|
||||
if ( array_key_exists( $plugin, $paused_plugins ) ) {
|
||||
unset( $plugins[ $index ] );
|
||||
|
||||
// Store list of paused plugins for displaying an admin notice.
|
||||
$GLOBALS['_paused_plugins'][ $plugin ] = $paused_plugins[ $plugin ];
|
||||
}
|
||||
}
|
||||
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
|
@ -725,9 +747,146 @@ function wp_get_active_and_valid_themes() {
|
|||
|
||||
$themes[] = TEMPLATEPATH;
|
||||
|
||||
/*
|
||||
* Remove themes from the list of active themes when we're on an endpoint
|
||||
* that should be protected against WSODs and the theme is paused.
|
||||
*/
|
||||
if ( wp_is_recovery_mode() ) {
|
||||
$themes = wp_skip_paused_themes( $themes );
|
||||
|
||||
// If no active and valid themes exist, skip loading themes.
|
||||
if ( empty( $themes ) ) {
|
||||
add_filter( 'wp_using_themes', '__return_false' );
|
||||
}
|
||||
}
|
||||
|
||||
return $themes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters a given list of themes, removing any paused themes from it.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @param array $themes List of absolute theme directory paths.
|
||||
* @return array Filtered value of $themes, without any paused themes.
|
||||
*/
|
||||
function wp_skip_paused_themes( array $themes ) {
|
||||
$paused_themes = wp_paused_themes()->get_all();
|
||||
|
||||
if ( empty( $paused_themes ) ) {
|
||||
return $themes;
|
||||
}
|
||||
|
||||
foreach ( $themes as $index => $theme ) {
|
||||
$theme = basename( $theme );
|
||||
|
||||
if ( array_key_exists( $theme, $paused_themes ) ) {
|
||||
unset( $themes[ $index ] );
|
||||
|
||||
// Store list of paused themes for displaying an admin notice.
|
||||
$GLOBALS['_paused_themes'][ $theme ] = $paused_themes[ $theme ];
|
||||
}
|
||||
}
|
||||
|
||||
return $themes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is WordPress in Recovery Mode.
|
||||
*
|
||||
* In this mode, plugins or themes that cause WSODs will be paused.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function wp_is_recovery_mode() {
|
||||
return wp_recovery_mode()->is_active();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether we are currently on an endpoint that should be protected against WSODs.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @return bool True if the current endpoint should be protected.
|
||||
*/
|
||||
function is_protected_endpoint() {
|
||||
// Protect login pages.
|
||||
if ( isset( $GLOBALS['pagenow'] ) && 'wp-login.php' === $GLOBALS['pagenow'] ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Protect the admin backend.
|
||||
if ( is_admin() && ! wp_doing_ajax() ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Protect AJAX actions that could help resolve a fatal error should be available.
|
||||
if ( is_protected_ajax_action() ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters whether the current request is against a protected endpoint.
|
||||
*
|
||||
* This filter is only fired when an endpoint is requested which is not already protected by
|
||||
* WordPress core. As such, it exclusively allows providing further protected endpoints in
|
||||
* addition to the admin backend, login pages and protected AJAX actions.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @param bool $is_protected_endpoint Whether the currently requested endpoint is protected. Default false.
|
||||
*/
|
||||
return (bool) apply_filters( 'is_protected_endpoint', false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether we are currently handling an AJAX action that should be protected against WSODs.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @return bool True if the current AJAX action should be protected.
|
||||
*/
|
||||
function is_protected_ajax_action() {
|
||||
if ( ! wp_doing_ajax() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! isset( $_REQUEST['action'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$actions_to_protect = array(
|
||||
'edit-theme-plugin-file', // Saving changes in the core code editor.
|
||||
'heartbeat', // Keep the heart beating.
|
||||
'install-plugin', // Installing a new plugin.
|
||||
'install-theme', // Installing a new theme.
|
||||
'search-plugins', // Searching in the list of plugins.
|
||||
'search-install-plugins', // Searching for a plugin in the plugin install screen.
|
||||
'update-plugin', // Update an existing plugin.
|
||||
'update-theme', // Update an existing theme.
|
||||
);
|
||||
|
||||
/**
|
||||
* Filters the array of protected AJAX actions.
|
||||
*
|
||||
* This filter is only fired when doing AJAX and the AJAX request has an 'action' property.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @param array $actions_to_protect Array of strings with AJAX actions to protect.
|
||||
*/
|
||||
$actions_to_protect = (array) apply_filters( 'wp_protected_ajax_actions', $actions_to_protect );
|
||||
|
||||
if ( ! in_array( $_REQUEST['action'], $actions_to_protect, true ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set internal encoding.
|
||||
*
|
||||
|
@ -1285,6 +1444,9 @@ function wp_start_scraping_edited_file_errors() {
|
|||
echo "###### wp_scraping_result_end:$key ######";
|
||||
die();
|
||||
}
|
||||
if ( ! defined( 'WP_SANDBOX_SCRAPING' ) ) {
|
||||
define( 'WP_SANDBOX_SCRAPING', true );
|
||||
}
|
||||
register_shutdown_function( 'wp_finalize_scraping_edited_file_errors', $key );
|
||||
}
|
||||
|
||||
|
@ -1327,3 +1489,63 @@ function wp_is_json_request() {
|
|||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether current request is a JSONP request, or is expecting a JSONP response.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @return bool True if JSONP request, false otherwise.
|
||||
*/
|
||||
function wp_is_jsonp_request() {
|
||||
if ( ! isset( $_GET['_jsonp'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'wp_check_jsonp_callback' ) ) {
|
||||
require_once ABSPATH . WPINC . '/functions.php';
|
||||
}
|
||||
|
||||
$jsonp_callback = $_GET['_jsonp'];
|
||||
if ( ! wp_check_jsonp_callback( $jsonp_callback ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** This filter is documented in wp-includes/rest-api/class-wp-rest-server.php */
|
||||
$jsonp_enabled = apply_filters( 'rest_jsonp_enabled', true );
|
||||
|
||||
return $jsonp_enabled;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether current request is an XML request, or is expecting an XML response.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @return bool True if Accepts or Content-Type headers contain xml, false otherwise.
|
||||
*/
|
||||
function wp_is_xml_request() {
|
||||
$accepted = array(
|
||||
'text/xml',
|
||||
'application/rss+xml',
|
||||
'application/atom+xml',
|
||||
'application/rdf+xml',
|
||||
'text/xml+oembed',
|
||||
'application/xml+oembed',
|
||||
);
|
||||
|
||||
if ( isset( $_SERVER['HTTP_ACCEPT'] ) ) {
|
||||
foreach ( $accepted as $type ) {
|
||||
if ( false !== strpos( $_SERVER['HTTP_ACCEPT'], $type ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $_SERVER['CONTENT_TYPE'] ) && in_array( $_SERVER['CONTENT_TYPE'], $accepted, true ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue