WordPress.org

Make WordPress Core

Ticket #42061: 42061.diff

File 42061.diff, 3.1 KB (added by flixos90, 2 years ago)
  • src/wp-admin/includes/ms.php

     
    4545                $file['error'] = __( 'You have used your space quota. Please delete files before uploading.' );
    4646        }
    4747
    48         if ( $file['error'] != '0' && ! isset( $_POST['html-upload'] ) && ! wp_doing_ajax() ) {
     48        if ( '0' != $file['error'] && ! isset( $_POST['html-upload'] ) && ! wp_doing_ajax() && ! wp_is_rest_request() ) {
    4949                wp_die( $file['error'] . ' <a href="javascript:history.go(-1)">' . __( 'Back' ) . '</a>' );
    5050        }
    5151
  • src/wp-includes/class-wp-query.php

     
    946946                        $this->is_comment_feed = true;
    947947                }
    948948
    949                 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 ) ) {
     949                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 ) ) {
    950950                        $this->is_home = true;
    951951                }
    952952
  • src/wp-includes/functions.php

     
    64386438                }
    64396439        }
    64406440}
     6441
     6442/**
     6443 * Determines whether the current request is a WordPress REST API request.
     6444 *
     6445 * This function must not be called until the {@see 'parse_request'} action.
     6446 *
     6447 * @since 5.0.0
     6448 *
     6449 * @return bool True if it's a WordPress REST API request, false otherwise.
     6450 */
     6451function wp_is_rest_request() {
     6452        if ( ! defined( 'REST_REQUEST' ) && ! did_action( 'parse_request' ) ) {
     6453                _doing_it_wrong(
     6454                        __FUNCTION__,
     6455                        sprintf(
     6456                                /* translators: %s: parse_request */
     6457                                __( 'Detecting whether the current request is a REST API request is not possible until the %s hook.' ),
     6458                                '<code>parse_request</code>'
     6459                        ),
     6460                        '5.0.0'
     6461                );
     6462        }
     6463
     6464        /**
     6465         * Filters whether the current request is a WordPress REST API request.
     6466         *
     6467         * @since 5.0.0
     6468         *
     6469         * @param bool $wp_is_rest_request Whether the current request is a WordPress REST API request.
     6470         */
     6471        return apply_filters( 'wp_is_rest_request', defined( 'REST_REQUEST' ) && REST_REQUEST );
     6472}
  • src/wp-includes/load.php

     
    349349                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 );
    350350        }
    351351
    352         if ( defined( 'XMLRPC_REQUEST' ) || defined( 'REST_REQUEST' ) || ( defined( 'WP_INSTALLING' ) && WP_INSTALLING ) || wp_doing_ajax() ) {
     352        if ( defined( 'XMLRPC_REQUEST' ) || wp_installing() || wp_doing_ajax() ) {
    353353                @ini_set( 'display_errors', 0 );
    354354        }
    355355}