Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Theme Export: Add index.php and style.css #39173

Merged
merged 3 commits into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/compat/wordpress-6.0/block-template-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ function gutenberg_generate_block_templates_export_file() {
wp_json_encode( $tree->get_data(), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE )
);

$zip->addFromString(
'theme/index.php',
'<?php // This file is needed to make the theme work, but it doesn\'t do anything.'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we go with "Silence is golden"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if the best thing to do is the same as for the style.css - just copy the index.php

);

$zip->addFromString(
'theme/style.css',
file_get_contents( get_stylesheet_directory() . '/style.css' )
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can use ZipArchive::addFile here. It is what core uses in privacy tools export.


// Save changes to the zip file.
$zip->close();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public function permissions_check() {

/**
* Output a ZIP file with an export of the current templates
* and template parts from the site editor, and close the connection.
* template parts, theme.json and index.php from the site editor,
* and close the connection.
*
* @return WP_Error|void
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default function SiteExport() {
role="menuitem"
icon={ download }
onClick={ handleExport }
info={ __( 'Download your templates and styles.' ) }
info={ __( 'Download your templates and styles as a theme.' ) }
>
{ _x( 'Export', 'site exporter menu item' ) }
</MenuItem>
Expand Down