Make WordPress Core


Ignore:
Timestamp:
12/07/2021 06:36:29 PM (22 months ago)
Author:
spacedmonkey
Message:

REST API: Ensure that the export template endpoint returns a valid WP_Error object.

Ensure that the export template endpoint returns a WP_Error object, including code and message, so that the site editor can display an error message.
Add some basic unit tests to ensure that permission checks are working as expected.

Follow-up to [52286].

Props Spacedmonkey, dlh, hellofromTonya , Mamaduka, TimothyBlynJacobs.
Fixes #54448.

File:
1 edited

Legend:

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

    r52286 r52340  
    5555    public function permissions_check() {
    5656        if ( ! current_user_can( 'edit_theme_options' ) ) {
    57             new WP_Error(
    58                 'rest_cannot_view_url_details',
     57            return new WP_Error(
     58                'rest_cannot_export_templates',
    5959                __( 'Sorry, you are not allowed to export templates and template parts.' ),
    6060                array( 'status' => rest_authorization_required_code() )
Note: See TracChangeset for help on using the changeset viewer.