Make WordPress Core

Opened 5 years ago

Last modified 4 weeks ago

#14955 new enhancement

Themes should support uninstall.php or uninstall hook

Reported by: WraithKenny Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Themes Keywords: has-patch dev-feedback
Focuses: Cc:

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 (2)

14955.diff (1013 bytes) - added by greuben 4 years ago.
14955.1.diff (1.2 KB) - added by obenland 2 years ago.
Refreshed patch

Download all attachments as: .zip

Change History (27)

comment:1 @scribu5 years ago

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.

comment:2 @scribu5 years ago

  • Description modified (diff)

comment:3 @scribu5 years ago

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

comment:4 @scribu5 years ago

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

comment:5 @WraithKenny5 years ago

  • Cc Ken@… added

comment:6 @scribu5 years ago

Related: #7795

(duh, it's in the ticket description)

Last edited 5 years ago by scribu (previous) (diff)

comment:7 @chipbennett5 years ago

  • 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.)

comment:8 @scribu5 years ago

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()

@greuben4 years ago

comment:9 @greuben4 years ago

  • 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.

comment:10 @scribu4 years ago

  • Keywords early added; 3.3-early removed

comment:11 @DrewAPicture4 years ago

  • Cc xoodrew@… added

#19505 closed as duplicate.

comment:12 @oncletom3 years ago

  • Cc thomas@… added

Any progress on this topic?

comment:13 @DeanMarkTaylor2 years ago

  • Cc DeanMarkTaylor added

@obenland2 years ago

Refreshed patch

comment:14 @obenland2 years ago

  • Keywords early removed
  • Milestone changed from Future Release to 3.7

comment:16 follow-up: @nacin2 years ago

This doesn't seem like functionality I'd want themes to have.

comment:17 @WraithKenny2 years ago

@nacin Theme's can add options, create tables, and do all sorts of things that plugins can do, but has little opportunity to clean up after themselves. Shouldn't themes clean up like plugins are expected to?

comment:18 in reply to: ↑ 16 @helen2 years ago

  • Milestone changed from 3.7 to Awaiting Review

Replying to nacin:

This doesn't seem like functionality I'd want themes to have.

comment:19 @Apiweb21 months ago

  • Version 3.0.1 deleted

As the WraithKenny said, has many themes that add tables, alter the structure of WordPress, and with all the powerful API of WordPress they can do a lot more, I believe this would be an interesting option to be implemented.

comment:20 @slackbot7 months ago

This ticket was mentioned in Slack in #meta by sterlo. View the logs.

comment:21 @slackbot7 months ago

This ticket was mentioned in Slack in #cli by sterlo. View the logs.

comment:22 @chriscct75 weeks ago

#16401 was marked as a duplicate.

comment:23 @kjodle5 weeks ago

Some themes are doing this already. It would be beneficial to keep the database clean, and to ensure that all themes are doing this in a uniform way. Perhaps as all themes migrate to using the customizer, this can be implemented.

comment:24 @chriscct75 weeks ago

  • Keywords dev-feedback added

comment:25 @muxahuk12144 weeks ago

Any progress on this topic? May be you could implement only do_action for now ?

Last edited 4 weeks ago by muxahuk1214 (previous) (diff)
Note: See TracTickets for help on using tickets.