Opened 3 years ago

Last modified 8 months ago

#14955 new enhancement

Themes should support uninstall.php or uninstall hook

Reported by: WraithKenny Owned by:
Priority: normal Milestone: Future Release
Component: Themes Version: 3.0.1
Severity: normal Keywords: has-patch early
Cc: Ken@…, chip@…, xoodrew@…, thomas@…

Description (last modified by scribu)

Related tickets on extending Themes to have Plugin features: #7795 and #14849 but those deal primarily with activation and deactivation centering around 'switch_themes' action.

From looking at /wp-admin/includes/plugin.php, adding support for uninstall is a separate concern (and it doesn't have the issue blocking activation/deactivation).

Should is_uninstallable_plugin, register_uninstall_hook and uninstall_plugin be extended to check theme directory or should versions (is_uninstallable_theme, register_uninstall_theme_hook and uninstall_theme) be added to theme.php?

Advantage of the first method is that the register_uninstall_hook could be reused for Themes where in the second, a new, less attractive name would be needed (register_uninstall_theme_hook?) Also, there's no theme_basename as it was reverted/removed.

Attachments (1)

14955.diff (1013 bytes) - added by greuben 23 months ago.

Download all attachments as: .zip

Change History (13)

We shouldn't attempt to reuse register_*_hook() functions because there's only one theme running at a time, so the underlying logic would be very different.

That's why there's no theme_basename() and why the $file parameter wouldn't be needed.

  • Description modified (diff)

Forget what I said, as it doesn't apply to the uninstall process.

  • Keywords needs-patch 3.2-early added
  • Milestone changed from Awaiting Review to Future Release
  • Cc Ken@… added

Related: #7795

Version 0, edited 2 years ago by scribu (next)
  • Cc chip@… added

So, at Scribu's prompting, I'm going to attempt to create a patch for this. I'm thinking of creating analogous functions in themes.php, unless either of you think I should go the route of extending the existing Plugin hooks?

(Should I assign this to myself? I am still mostly unfamiliar with Trac workflow.)

You can assign it to yourself, if you want, but it's not mandatory.

Extending register_uninstall_hook() is not an option.

The available options are:

  • uninstall.php file
  • register_theme_uninstall_hook()
  • Keywords 3.3-early has-patch added; needs-patch 3.2-early removed

Instead of register_theme_uninstall_hook() we can use 'uninstall_theme' hook.

14955.diff makes use of uninstall.php and introduces 'uninstall_theme' hook.

  • Keywords early added; 3.3-early removed
  • Cc xoodrew@… added

#19505 closed as duplicate.

  • Cc thomas@… added

Any progress on this topic?

Note: See TracTickets for help on using tickets.