Make WordPress Core


Ignore:
Timestamp:
02/27/2010 10:01:22 PM (15 years ago)
Author:
nacin
Message:

When deleting plugins, check for uninstall hooks and warn of data deletion. Props cyberhobo. Pluralize some string(s). fixes #11850

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/plugins.php

    r13452 r13470  
    223223                ?>
    224224            <div class="wrap">
    225                 <h2><?php _e('Delete Plugin(s)'); ?></h2>
    226225                <?php
    227226                    $files_to_delete = $plugin_info = array();
     
    229228                        if ( '.' == dirname($plugin) ) {
    230229                            $files_to_delete[] = WP_PLUGIN_DIR . '/' . $plugin;
    231                             if ( $data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin) )
     230                            if( $data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin) ) {
    232231                                $plugin_info[ $plugin ] = $data;
     232                                $plugin_info[ $plugin ]['is_uninstallable'] = is_uninstallable_plugin( $plugin );
     233                            }
    233234                        } else {
    234235                            //Locate all the files in that folder:
     
    238239                            }
    239240                            //Get plugins list from that folder
    240                             if ( $folder_plugins = get_plugins( '/' . dirname($plugin)) )
    241                                 $plugin_info = array_merge($plugin_info, $folder_plugins);
     241                            if ( $folder_plugins = get_plugins( '/' . dirname($plugin)) ) {
     242                                foreach( $folder_plugins as $plugin_file => $data ) {
     243                                    $plugin_info[ $plugin_file ] = $data;
     244                                    $plugin_info[ $plugin_file ]['is_uninstallable'] = is_uninstallable_plugin( $plugin );
     245                                }
     246                            }
    242247                        }
    243248                    }
     249                    screen_icon();
     250                    $plugins_to_delete = count( $plugin_info );
     251                    echo '<h2>' . _n( 'Delete Plugin', 'Delete Plugins', $plugins_to_delete ) . '</h2>';
    244252                ?>
    245                 <p><?php _e('Deleting the selected plugins will remove the following plugin(s) and their files:'); ?></p>
     253                <p><?php echo _n( 'Deleting the selected plugin will remove the following plugin and its files:', 'Deleting the selected plugins will remove the following plugins and their files:', $plugins_to_delete ); ?></p>
    246254                    <ul class="ul-disc">
    247255                        <?php
    248                         foreach ( $plugin_info as $plugin )
    249                             /* translators: 1: plugin name, 2: plugin author */
    250                             echo '<li>', sprintf(__('<strong>%1$s</strong> by <em>%2$s</em>'), $plugin['Name'], $plugin['Author']), '</li>';
     256                        $data_to_delete = false;
     257                        foreach ( $plugin_info as $plugin ) {
     258                            if ( $plugin['is_uninstallable'] ) {
     259                                /* translators: 1: plugin name, 2: plugin author */
     260                                echo '<li>', sprintf( __( '<strong>%1$s</strong> by <em>%2$s</em> (will also <strong>delete its data</strong>)' ), $plugin['Name'], $plugin['Author'] ), '</li>';
     261                                $data_to_delete = true;
     262                            } else {
     263                                /* translators: 1: plugin name, 2: plugin author */
     264                                echo '<li>', sprintf( __('<strong>%1$s</strong> by <em>%2$s</em>' ), $plugin['Name'], $plugin['Author'] ), '</li>';
     265                            }
     266                        }
    251267                        ?>
    252268                    </ul>
    253                 <p><?php _e('Are you sure you wish to delete these files?') ?></p>
     269                <p><?php
     270                if ( $data_to_delete )
     271                    _e('Are you sure you wish to delete these files and data?');
     272                else
     273                    _e('Are you sure you wish to delete these files?');
     274                ?></p>
    254275                <form method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>" style="display:inline;">
    255276                    <input type="hidden" name="verify-delete" value="1" />
     
    260281                    ?>
    261282                    <?php wp_nonce_field('bulk-manage-plugins') ?>
    262                     <input type="submit" name="submit" value="<?php esc_attr_e('Yes, Delete these files') ?>" class="button" />
     283                    <input type="submit" name="submit" value="<?php $data_to_delete ? esc_attr_e('Yes, Delete these files and data') : esc_attr_e('Yes, Delete these files') ?>" class="button" />
    263284                </form>
    264285                <form method="post" action="<?php echo esc_url(wp_get_referer()); ?>" style="display:inline;">
Note: See TracChangeset for help on using the changeset viewer.