Make WordPress Core

Opened 3 years ago

Last modified 2 years ago

#53351 new enhancement

Delete Theme Files in Database When Using Delete Option

Reported by: deborah86's profile deborah86 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.7.2
Component: Themes Keywords: 2nd-opinion
Focuses: Cc:


Right now, when a user deletes a theme, the theme files still remain in the database. This can cause future security issues as well as slowdown a site in the future as the database of the website grows.

This also makes it difficult for end-users to troubleshoot issues with a theme because it is impossible to install a brand new version of the theme without deleting multiple files the database.

When deleting plugins, the plugin data is automatically removed from the database if the plugin developers follow the plugin development standards. The same standard should be applicable to themes downloaded through the theme repository.

Users expect a theme to be fully deleted when using the delete option.

Change History (3)

#1 in reply to: ↑ description @SergeyBiryukov
3 years ago

  • Component changed from Database to Themes
  • Keywords reporter-feedback added

Hi there, welcome back to WordPress Trac! Thanks for the ticket.

Replying to deborah86:

Right now, when a user deletes a theme, the theme files still remain in the database.

  1. Could you clarify which files exactly you mean here? Generally, any theme files are stored in a directory under wp-content/themes/theme-name and are removed when the theme is deleted, so the ticket description is a bit confusing for me.
  2. Could you provide the steps to reproduce the issue on a clean install?
Last edited 3 years ago by SergeyBiryukov (previous) (diff)

#2 @deborah86
3 years ago


I am referring to the entries stored in the database.

Steps to Replicate

  1. Install a brand new version of WordPress
  2. Activate the Twenty Twenty theme
  3. Make changes to the theme in the customizer such as the color
  4. Activate the Twenty Twenty One Theme
  5. Delete the Twenty Twenty theme
  6. Reinstall the Twenty Twenty theme

If you reinstall the theme, you will notice the settings you edited are present. The theme is not freshly installed without the saved settings. According to the theme team, this is working as intended.

In order to get a fresh install of the theme, a plugin has to be installed to delete the theme_modes_twentytwenty option in the site's database.

See the response here:

I am requesting the entire theme deletes without the use of a third-party plugin.

#3 @andraganescu
2 years ago

  • Keywords 2nd-opinion added; reporter-feedback removed

Another option would be to have a "reset theme to defaults" button in the Appearance > Themes > [Theme] card that opens when you click a theme, or even in the Customizer itself. I believe the preservation of user settings is a feature, removing theme customisations would be a poor experience for when you try out a theme and then you go back.

Note: See TracTickets for help on using tickets.