wordpress-develop
wordpress-develop copied to clipboard
Trac 64439: Add theme download capability to Theme Editor
Description
This Pull Request introduces the ability to download the currently selected theme as a ZIP file directly from the Appearance > Theme File Editor screen. This feature allows users to easily create a backup or copy of the theme they are editing without needing FTP or file manager access.
Ticket
https://core.trac.wordpress.org/ticket/64439
Acknowledgements
Props to @solankisoftware for the initial patch.
Thanks for the contribution! I noticed the file path in the original patch was slightly incorrect for the development environment (it was missing src/), so I have corrected the path to ensure it applies cleanly to the wordpress-develop repository.
Changes
- Added a "Download Theme" button below the theme editor form in [src/wp-admin/theme-editor.php]
- Implemented a secure handler for the
download_themeaction. - Added logic to generate a ZIP archive of the theme using
ZipArchive(with a fallback toPclZipfor compatibility). - Ensures proper permission checks (
edit_themes) and nonce verification before processing the download.
Testing Instructions
- Navigate to Appearance > Theme File Editor.
- Select any theme from the dropdown menu (if multiple themes are installed).
- Scroll down to the bottom of the editor area.
- Click the newly added Download Theme button.
- Verify that a
.zipfile containing the full theme directory is downloaded successfully. - Extract the ZIP file and confirm that all theme files are present and strictly correspond to the selected theme.