Plugins: Make delete plugin message less scary.

This adds a check if the plugin actually has an uninstall routine before saying that its data will be deleted too.

Props samful, joostdevalk, joyously, Chouby, SergeyBiryukov.
Fixes #50346.

git-svn-id: https://develop.svn.wordpress.org/trunk@48451 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2020-07-12 13:20:58 +00:00
parent cece47bd39
commit 26c296c397
2 changed files with 14 additions and 0 deletions

View File

@ -2138,11 +2138,21 @@
*/
$bulkActionForm.on( 'click', '[data-plugin] a.delete', function( event ) {
var $pluginRow = $( event.target ).parents( 'tr' ),
confirmMessage;
if ( $pluginRow.hasClass( 'is-uninstallable' ) ) {
confirmMessage = sprintf(
/* translators: %s: Plugin name. */
__( 'Are you sure you want to delete %s and its data?' ),
$pluginRow.find( '.plugin-title strong' ).text()
);
} else {
confirmMessage = sprintf(
/* translators: %s: Plugin name. */
__( 'Are you sure you want to delete %s?' ),
$pluginRow.find( '.plugin-title strong' ).text()
);
}
event.preventDefault();

View File

@ -942,6 +942,10 @@ class WP_Plugins_List_Table extends WP_List_Table {
$class .= ' paused';
}
if ( is_uninstallable_plugin( $plugin_file ) ) {
$class .= ' is-uninstallable';
}
printf(
'<tr class="%s" data-slug="%s" data-plugin="%s">',
esc_attr( $class ),