Make WordPress Core

Ticket #50346: 50346.2.diff

File 50346.2.diff, 3.0 KB (added by samful, 5 years ago)

fixed issue where plugin only worked on multisites and changed message to "If the plugin has data, this will not be deleted."

  • src/js/_enqueues/wp/updates.js

    diff --git src/js/_enqueues/wp/updates.js src/js/_enqueues/wp/updates.js
    index dc342f2..7243f0e 100644
     
    21372137                 * @param {Event} event Event interface.
    21382138                 */
    21392139                $bulkActionForm.on( 'click', '[data-plugin] a.delete', function( event ) {
    2140                         var $pluginRow = $( event.target ).parents( 'tr' ),
    2141                                 confirmMessage = sprintf(
     2140                        var $pluginRow = $( event.target ).parents( 'tr' );
     2141               
     2142                        if($(event.target).hasClass('no-plugin-data')){
     2143                                var confirmMessage = sprintf(
     2144                                        /* translators: %s: Plugin name. */
     2145                                        __( 'Are you sure you want to delete %s? If the plugin has data, this will not be deleted.' ),
     2146                                        $pluginRow.find( '.plugin-title strong' ).text()
     2147                                );
     2148                        } else {
     2149                                var confirmMessage = sprintf(
    21422150                                        /* translators: %s: Plugin name. */
    21432151                                        __( 'Are you sure you want to delete %s and its data?' ),
    21442152                                        $pluginRow.find( '.plugin-title strong' ).text()
    21452153                                );
    2146 
     2154                        }
    21472155                        event.preventDefault();
    21482156
    21492157                        if ( ! window.confirm( confirmMessage ) ) {
  • src/wp-admin/includes/class-wp-plugins-list-table.php

    diff --git src/wp-admin/includes/class-wp-plugins-list-table.php src/wp-admin/includes/class-wp-plugins-list-table.php
    index f257354..3e4b8e0 100644
    class WP_Plugins_List_Table extends WP_List_Table { 
    758758                                        }
    759759
    760760                                        if ( current_user_can( 'delete_plugins' ) && ! is_plugin_active( $plugin_file ) ) {
     761
     762                                                $has_plugin_data = is_uninstallable_plugin($plugin_file) ? "has-plugin-data" : "no-plugin-data";
     763
    761764                                                $actions['delete'] = sprintf(
    762                                                         '<a href="%s" id="delete-%s" class="delete" aria-label="%s">%s</a>',
     765                                                        '<a href="%s" id="delete-%s" class="delete%s" aria-label="%s">%s</a>',
    763766                                                        wp_nonce_url( 'plugins.php?action=delete-selected&amp;checked[]=' . urlencode( $plugin_file ) . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'bulk-plugins' ),
    764767                                                        esc_attr( $plugin_slug ),
     768                                                        " $has_plugin_data",
    765769                                                        /* translators: %s: Plugin name. */
    766770                                                        esc_attr( sprintf( _x( 'Delete %s', 'plugin' ), $plugin_data['Name'] ) ),
    767771                                                        __( 'Delete' )
    class WP_Plugins_List_Table extends WP_List_Table { 
    812816                                        }
    813817
    814818                                        if ( ! is_multisite() && current_user_can( 'delete_plugins' ) ) {
     819                                               
     820                                                $has_plugin_data = is_uninstallable_plugin($plugin_file) ? "has-plugin-data" : "no-plugin-data";
     821
    815822                                                $actions['delete'] = sprintf(
    816                                                         '<a href="%s" id="delete-%s" class="delete" aria-label="%s">%s</a>',
     823                                                        '<a href="%s" id="delete-%s" class="delete%s" aria-label="%s">%s</a>',
    817824                                                        wp_nonce_url( 'plugins.php?action=delete-selected&amp;checked[]=' . urlencode( $plugin_file ) . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'bulk-plugins' ),
    818825                                                        esc_attr( $plugin_slug ),
     826                                                        " $has_plugin_data",
    819827                                                        /* translators: %s: Plugin name. */
    820828                                                        esc_attr( sprintf( _x( 'Delete %s', 'plugin' ), $plugin_data['Name'] ) ),
    821829                                                        __( 'Delete' )