-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This ensures that any theme exports get the benefit of the latest cha…
…nges to theme json and resolver.
- Loading branch information
Showing
4 changed files
with
173 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
lib/compat/wordpress-6.6/class-gutenberg-rest-edit-site-export-controller-6-6.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
/** | ||
* REST API: WP_REST_Edit_Site_Export_Controller class | ||
* | ||
* @package WordPress | ||
* @subpackage REST_API | ||
*/ | ||
|
||
/** | ||
* Controller which provides REST endpoint for exporting current templates | ||
* and template parts. | ||
* | ||
* @since 5.9.0 | ||
* | ||
* @see WP_REST_Controller | ||
*/ | ||
|
||
if ( class_exists( 'Gutenberg_REST_Edit_Site_Export_Controller_6_6' ) ) { | ||
return; | ||
} | ||
|
||
class Gutenberg_REST_Edit_Site_Export_Controller_6_6 extends WP_REST_Edit_Site_Export_Controller { | ||
/** | ||
* Output a ZIP file with an export of the current templates | ||
* and template parts from the site editor, and close the connection. | ||
* | ||
* @since 5.9.0 | ||
* | ||
* @return WP_Error|void | ||
*/ | ||
public function export() { | ||
// Generate the export file. | ||
$filename = gutenberg_generate_block_templates_export_file(); | ||
|
||
if ( is_wp_error( $filename ) ) { | ||
$filename->add_data( array( 'status' => 500 ) ); | ||
|
||
return $filename; | ||
} | ||
|
||
$theme_name = basename( get_stylesheet() ); | ||
header( 'Content-Type: application/zip' ); | ||
header( 'Content-Disposition: attachment; filename=' . $theme_name . '.zip' ); | ||
header( 'Content-Length: ' . filesize( $filename ) ); | ||
flush(); | ||
readfile( $filename ); | ||
unlink( $filename ); | ||
exit; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters