Index: src/wp-admin/includes/ms.php
===================================================================
--- src/wp-admin/includes/ms.php (revision 43583)
+++ src/wp-admin/includes/ms.php (working copy)
@@ -45,7 +45,7 @@
$file['error'] = __( 'You have used your space quota. Please delete files before uploading.' );
}
- if ( $file['error'] != '0' && ! isset( $_POST['html-upload'] ) && ! wp_doing_ajax() ) {
+ if ( '0' != $file['error'] && ! isset( $_POST['html-upload'] ) && ! wp_doing_ajax() && ! wp_is_rest_request() ) {
wp_die( $file['error'] . ' ' . __( 'Back' ) . '' );
}
Index: src/wp-includes/class-wp-query.php
===================================================================
--- src/wp-includes/class-wp-query.php (revision 43583)
+++ src/wp-includes/class-wp-query.php (working copy)
@@ -946,7 +946,7 @@
$this->is_comment_feed = true;
}
- if ( ! ( $this->is_singular || $this->is_archive || $this->is_search || $this->is_feed || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_robots ) ) {
+ if ( ! ( $this->is_singular || $this->is_archive || $this->is_search || $this->is_feed || wp_is_rest_request() || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_robots ) ) {
$this->is_home = true;
}
Index: src/wp-includes/functions.php
===================================================================
--- src/wp-includes/functions.php (revision 43583)
+++ src/wp-includes/functions.php (working copy)
@@ -6438,3 +6438,35 @@
}
}
}
+
+/**
+ * Determines whether the current request is a WordPress REST API request.
+ *
+ * This function must not be called until the {@see 'parse_request'} action.
+ *
+ * @since 5.0.0
+ *
+ * @return bool True if it's a WordPress REST API request, false otherwise.
+ */
+function wp_is_rest_request() {
+ if ( ! defined( 'REST_REQUEST' ) && ! did_action( 'parse_request' ) ) {
+ _doing_it_wrong(
+ __FUNCTION__,
+ sprintf(
+ /* translators: %s: parse_request */
+ __( 'Detecting whether the current request is a REST API request is not possible until the %s hook.' ),
+ 'parse_request
'
+ ),
+ '5.0.0'
+ );
+ }
+
+ /**
+ * Filters whether the current request is a WordPress REST API request.
+ *
+ * @since 5.0.0
+ *
+ * @param bool $wp_is_rest_request Whether the current request is a WordPress REST API request.
+ */
+ return apply_filters( 'wp_is_rest_request', defined( 'REST_REQUEST' ) && REST_REQUEST );
+}
Index: src/wp-includes/load.php
===================================================================
--- src/wp-includes/load.php (revision 43583)
+++ src/wp-includes/load.php (working copy)
@@ -349,7 +349,7 @@
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 );
}
- if ( defined( 'XMLRPC_REQUEST' ) || defined( 'REST_REQUEST' ) || ( defined( 'WP_INSTALLING' ) && WP_INSTALLING ) || wp_doing_ajax() ) {
+ if ( defined( 'XMLRPC_REQUEST' ) || wp_installing() || wp_doing_ajax() ) {
@ini_set( 'display_errors', 0 );
}
}