Make WordPress Core

Opened 9 years ago

Last modified 7 years ago

#31136 new enhancement

Allow plugin authors to register an additional 'Uninstall Notification' plugin header and to display back to the user during plugin uninstall flow

Reported by: cefiar's profile cefiar Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Plugins Keywords: has-patch dev-feedback 2nd-opinion needs-testing needs-unit-tests
Focuses: administration Cc:

Description

In wp-admin/plugins.php wordpress displays to the user information about the plugins you are attempting to uninstall. Currently it only displays the name of the plugin name ($plugin[ 'Name' ]) and the plugin author ($plugin[ 'AuthorName' ]). In V4.1 this output is generated around lines 289-304.

Is it possible to add another field that contains a short piece of information from the plugin author, that can be presented to the user for each plugin? The plugin would need to register this information with wordpress when it was installed or updated.

Specifically, I envisage this being used for details that the user might need to follow to preserve any data that they might have before they actually delete the plugin.

An example string that I can see being used by a plugin:

If you wish to uninstall <b>without losing your data</b>, see the details at <a href="http://example.com/plugin-uninstall">http://example.com/plugin-uninstall</a>.

Notes:

  • Such a string should of course be optional to preserve backward compatibility.
  • Appropriate filtering and length checks should be done on the string to ensure that the uninstall plugin UI isn't easily broken or disturbed. This avoids the plugin author filling the field with a string that stops the user from being unable to uninstall the plugin.

Attachments (1)

31136.patch (2.4 KB) - added by eherman24 9 years ago.
added new plugin header metadata 'Uninstall Notification' , which gets displayed to the user on plugin uninstall if the metadata is set in the plugin header.

Download all attachments as: .zip

Change History (11)

#1 follow-up: @cefiar
9 years ago

Field requested would of course be needed to be added to the plugin header.

eg:

Uninstall Info: If you wish to uninstall <b>without losing your data</b>, see the details at <a href="http://example.com/plugin-uninstall">http://example.com/plugin-uninstall</a>.

#2 @eherman24
9 years ago

Hi @cefiar,

As a plugin developer I can see the benefit of such a feature added to core. Adding a new (and optional) plugin header such as 'Uninstall Notification' would be beneficial in certain circumstances.

I am working on a patch that I think could be incorporated into core which would help add additional information to plugins, and could also potentially be used for themes as well.

@eherman24
9 years ago

added new plugin header metadata 'Uninstall Notification' , which gets displayed to the user on plugin uninstall if the metadata is set in the plugin header.

#3 @eherman24
9 years ago

  • Focuses administration added
  • Keywords has-patch dev-feedback 2nd-opinion needs-testing added; needs-patch removed
  • Summary changed from Allow plugins to register a string to show to user when uninstalling/deleting plugin to Allow plugin authors to register an additional 'Uninstall Notification' plugin header and to display back to the user during plugin uninstall flow

In the patch that I have attached above, I've added one additional plugin header meta data, 'Uninstall Notification'.

This allows the user to display a notice back to the user just before uninstalling a plugin. This could be useful for things such as linking to the support forum in the repository, asking nicely for a review or any other number of use cases.

In the following screenshot you can see that I've tested the 'Uninstall Notification' within the 'Askismet' plugin.

Here is the example plugin header with the patch that I have attached implemented :

/**
 * @package Akismet
 */
/*
Plugin Name: Akismet
Plugin URI: http://akismet.com/
Description: Used by millions, Akismet is quite possibly the best way in the world to <strong>protect your blog from comment and trackback spam</strong>. It keeps your site protected from spam even while you sleep. To get started: 1) Click the "Activate" link to the left of this description, 2) <a href="http://akismet.com/get/">Sign up for an Akismet API key</a>, and 3) Go to your Akismet configuration page, and save your API key.
Version: 3.0.4
Author: Automattic
Author URI: http://automattic.com/wordpress-plugins/
License: GPLv2 or later
Text Domain: akismet
Uninstall Notification: Here we are testing an uninstall notification. This could be anything ranging from asking for a review to a link to the repository support forums. <ul> <li><a href="#">Sample Link</a></li> <li><a href="#">Sample Link #2</a> </li> </ul>
*/

You'll notice the new metadata just below 'Text Domain'.

And here is the notification displayed back to the user during the plugin uninstall work flow :

https://i.cloudup.com/m_JVm1dUoy.png

As validation I've implemented wp_kses with the same html tags allowed within a standard post. This allows for specific html tags to be used such as <a>,<em>,<br /> and <strong> while stripping away anything malicious.

I've added the styles for the notification to wp-admin/css/dashboard.css, which may not be the correct location for it. I'm open to suggestions and alterations, but believe this would be a solid addition to the plugin uninstall flow.

#4 @jdgrimes
9 years ago

Related: #20578

#5 in reply to: ↑ 1 ; follow-up: @lpawlik
9 years ago

Replying to cefiar:

Field requested would of course be needed to be added to the plugin header.

eg:

Uninstall Info: If you wish to uninstall <b>without losing your data</b>, see the details at <a href="http://example.com/plugin-uninstall">http://example.com/plugin-uninstall</a>.

It sounds as an awesome idea. Sometimes people have no idea what are the side effects of uninstalling plugins (like data lost etc). I would love to see one more extension related to uninstalling - uninstalling without launching uninstall.php script. Sometime people need to upgrade plugins manually and "light uninstall" without running uninstall.php script combined with proposed solution could be very useful.

#6 in reply to: ↑ 5 @jdgrimes
9 years ago

Replying to lpawlik:

I would love to see one more extension related to uninstalling - uninstalling without launching uninstall.php script. Sometime people need to upgrade plugins manually and "light uninstall" without running uninstall.php script combined with proposed solution could be very useful.

That's what #20578 is about.

#7 @swissspidy
8 years ago

  • Keywords close added

An extra header for that feels weird. Adding a new param to register_uninstall_hook sounds better, but that means the text would need to be stored in the database.

In both cases, the text wouldn't be translatable because the plugin is already deactivated, basically making this ticket a wontfix — or maybelater, if we can figure out a way to only deactivate the plugin after clicking uninstall.

#8 follow-up: @grapplerulrich
8 years ago

@swissspidy The string is translatable if the the text domain is defined in the header. The theme function that does it can be found here: https://github.com/WordPress/WordPress/blob/master/wp-includes/class-wp-theme.php#L755

#9 in reply to: ↑ 8 @jdgrimes
8 years ago

Replying to grapplerulrich:

@swissspidy The string is translatable if the the text domain is defined in the header. The theme function that does it can be found here: https://github.com/WordPress/WordPress/blob/master/wp-includes/class-wp-theme.php#L755

Yes. Basically, it'd be like what we do to display the plugin information in the plugins list table when the plugin isn't activated.

#10 @swissspidy
7 years ago

  • Keywords needs-unit-tests added; close removed
  • Milestone changed from Awaiting Review to Future Release
Note: See TracTickets for help on using tickets.