WordPress / create-block-theme

A WordPress plugin to create block themes
https://wordpress.org/plugins/create-block-theme/
GNU General Public License v2.0
310 stars 44 forks source link

Check ZipArchive class before zip export #609

Closed t-hamano closed 2 months ago

t-hamano commented 2 months ago

Fixes #492

This PR displays an appropriate error message when a process that creates a zip file requires the ZipArchive class and the class does not exist.

Suggestions for displayed text are also welcome!

image

image

Testing Instructions

To test this PR, you need to disable the zip extension locally. For wp-env, please follow the steps below.

After that, confirm that an error message is displayed when you perform the following operations:

P.S. Restart wp-env and the zip extension will be automatically enabled again.

Supplement

In addition to the REST API endpoint that this PR changes, the ZipArchive class is also used in the callback functions of the following two endpoints. However, these two endpoints currently don't seem to be called from anywhere.

Endpoint Callback function
create-block-theme/v1/export-clone/ rest_export_cloned_theme
create-block-theme/v1/export-child-clone/ rest_export_child_cloned_theme