Make WordPress Core


Ignore:
Timestamp:
04/11/2022 10:36:02 AM (2 years ago)
Author:
gziolo
Message:

Editor: Add functionality required for theme export in the site editor

This bring across changes to theme export functionality, and related code, and tests. Relates issue in Gutenberg: https://github.com/WordPress/gutenberg/issues/39889.

Props scruffian, timothyblynjacobs, oandregal, ajlende, zieleadam.
See #55505.

File:
1 edited

Legend:

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

    r52340 r53129  
    5454     */
    5555    public function permissions_check() {
    56         if ( ! current_user_can( 'edit_theme_options' ) ) {
    57             return new WP_Error(
    58                 'rest_cannot_export_templates',
    59                 __( 'Sorry, you are not allowed to export templates and template parts.' ),
    60                 array( 'status' => rest_authorization_required_code() )
    61             );
     56        if ( current_user_can( 'edit_theme_options' ) ) {
     57            return true;
    6258        }
    6359
    64         return true;
     60        return new WP_Error(
     61            'rest_cannot_export_templates',
     62            __( 'Sorry, you are not allowed to export templates and template parts.' ),
     63            array( 'status' => rest_authorization_required_code() )
     64        );
    6565    }
    6666
     
    8383        }
    8484
     85        $theme_name = wp_get_theme()->get( 'TextDomain' );
    8586        header( 'Content-Type: application/zip' );
    86         header( 'Content-Disposition: attachment; filename=edit-site-export.zip' );
     87        header( 'Content-Disposition: attachment; filename=' . $theme_name . '.zip' );
    8788        header( 'Content-Length: ' . filesize( $filename ) );
    8889        flush();
Note: See TracChangeset for help on using the changeset viewer.