Make WordPress Core


Ignore:
Timestamp:
06/30/2021 12:33:43 PM (5 years ago)
Author:
SergeyBiryukov
Message:

Docs: Document the globals used in some REST API methods.

See #53399.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php

    r49955 r51278  
    266266         * @since 5.5.0
    267267         *
     268         * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
     269         *
    268270         * @param WP_REST_Request $request Full details about the request.
    269271         * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
    270272         */
    271273        public function create_item( $request ) {
     274                global $wp_filesystem;
     275
    272276                require_once ABSPATH . 'wp-admin/includes/file.php';
    273277                require_once ABSPATH . 'wp-admin/includes/plugin.php';
    … …  
    330334
    331335                if ( is_null( $result ) ) {
    332                         global $wp_filesystem;
    333336                        // Pass through the error from WP_Filesystem if one was raised.
    334                         if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) {
    335                                 return new WP_Error( 'unable_to_connect_to_filesystem', $wp_filesystem->errors->get_error_message(), array( 'status' => 500 ) );
    336                         }
    337 
    338                         return new WP_Error( 'unable_to_connect_to_filesystem', __( 'Unable to connect to the filesystem. Please confirm your credentials.' ), array( 'status' => 500 ) );
     337                        if ( $wp_filesystem instanceof WP_Filesystem_Base
     338                                && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors()
     339                        ) {
     340                                return new WP_Error(
     341                                        'unable_to_connect_to_filesystem',
     342                                        $wp_filesystem->errors->get_error_message(),
     343                                        array( 'status' => 500 )
     344                                );
     345                        }
     346
     347                        return new WP_Error(
     348                                'unable_to_connect_to_filesystem',
     349                                __( 'Unable to connect to the filesystem. Please confirm your credentials.' ),
     350                                array( 'status' => 500 )
     351                        );
    339352                }
    340353
    … …  
    342355
    343356                if ( ! $file ) {
    344                         return new WP_Error( 'unable_to_determine_installed_plugin', __( 'Unable to determine what plugin was installed.' ), array( 'status' => 500 ) );
     357                        return new WP_Error(
     358                                'unable_to_determine_installed_plugin',
     359                                __( 'Unable to determine what plugin was installed.' ),
     360                                array( 'status' => 500 )
     361                        );
    345362                }
    346363
Note: See TracChangeset for help on using the changeset viewer.