PluginProbe
Gutenberg / 23.5.3
Gutenberg v23.5.3
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
gutenberg / lib / class-wp-rest-edit-site-export-controller-gutenberg.php

class-wp-rest-edit-site-export-controller-gutenberg.php in Gutenberg 23.5.3, at lib/class-wp-rest-edit-site-export-controller-gutenberg.php

47 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Controller which provides REST endpoint for exporting current templates
4 * and template parts.
5 *
6 * This class extension exists so that theme exporting takes into account any updates/changes to
7 * WP_Theme_JSON_Gutenberg, WP_Theme_JSON_Resolver_Gutenberg or related classes.
8 *
9 * @package gutenberg
10 * @subpackage REST_API
11 * @since 5.9.0
12 */
13
14 if ( class_exists( 'WP_REST_Edit_Site_Export_Controller_Gutenberg' ) ) {
15 return;
16 }
17
18 class WP_REST_Edit_Site_Export_Controller_Gutenberg extends WP_REST_Edit_Site_Export_Controller {
19 /**
20 * Output a ZIP file with an export of the current templates
21 * and template parts from the site editor, and close the connection.
22 *
23 * @since 5.9.0
24 *
25 * @return WP_Error|void
26 */
27 public function export() {
28 // Generate the export file.
29 $filename = gutenberg_generate_block_templates_export_file();
30
31 if ( is_wp_error( $filename ) ) {
32 $filename->add_data( array( 'status' => 500 ) );
33
34 return $filename;
35 }
36
37 $theme_name = basename( get_stylesheet() );
38 header( 'Content-Type: application/zip' );
39 header( 'Content-Disposition: attachment; filename=' . $theme_name . '.zip' );
40 header( 'Content-Length: ' . filesize( $filename ) );
41 flush();
42 readfile( $filename );
43 unlink( $filename );
44 exit;
45 }
46 }
47