wordpress-develop icon indicating copy to clipboard operation
wordpress-develop copied to clipboard

Trac 64439: Add theme download capability to Theme Editor

Open noruzzamans opened this issue 1 week ago • 4 comments

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_theme action.
  • Added logic to generate a ZIP archive of the theme using ZipArchive (with a fallback to PclZip for compatibility).
  • Ensures proper permission checks (edit_themes) and nonce verification before processing the download.

Testing Instructions

  1. Navigate to Appearance > Theme File Editor.
  2. Select any theme from the dropdown menu (if multiple themes are installed).
  3. Scroll down to the bottom of the editor area.
  4. Click the newly added Download Theme button.
  5. Verify that a .zip file containing the full theme directory is downloaded successfully.
  6. Extract the ZIP file and confirm that all theme files are present and strictly correspond to the selected theme.

noruzzamans avatar Jan 14 '26 05:01 noruzzamans