Ticket #20578: 20578.diff
File 20578.diff, 7.1 KB (added by , 9 years ago) |
---|
-
src/wp-admin/includes/plugin.php
diff --git src/wp-admin/includes/plugin.php src/wp-admin/includes/plugin.php index fbb1dc4..f7e9be6 100644
function activate_plugins( $plugins, $redirect = '', $network_wide = false, $sil 752 752 * 753 753 * @param array $plugins List of plugins to delete. 754 754 * @param string $deprecated Deprecated. 755 * @param bool $uninstall Optional. Whether the plugin install routine should be run. Default true. 755 756 * @return bool|null|WP_Error True on success, false is $plugins is empty, WP_Error on failure. 756 757 * Null if filesystem credentials are required to proceed. 757 758 */ 758 function delete_plugins( $plugins, $deprecated = '' ) {759 function delete_plugins( $plugins, $deprecated = '', $uninstall = true ) { 759 760 global $wp_filesystem; 760 761 761 762 if ( empty($plugins) ) … … function delete_plugins( $plugins, $deprecated = '' ) { 812 813 813 814 foreach ( $plugins as $plugin_file ) { 814 815 // Run Uninstall hook. 815 if ( is_uninstallable_plugin( $plugin_file ) ) {816 if ( is_uninstallable_plugin( $plugin_file ) && $uninstall ) { 816 817 uninstall_plugin($plugin_file); 817 818 } 818 819 … … function delete_plugins( $plugins, $deprecated = '' ) { 820 821 * Fires immediately before a plugin deletion attempt. 821 822 * 822 823 * @since 4.4.0 824 * @since 4.5.0 Added the `$uninstall` parameter. 823 825 * 824 826 * @param string $plugin_file Plugin file name. 827 * @param bool $uninstall Whether the plugin uninstall routine was run. 825 828 */ 826 do_action( 'delete_plugin', $plugin_file );829 do_action( 'delete_plugin', $plugin_file, $uninstall ); 827 830 828 831 $this_plugin_dir = trailingslashit( dirname( $plugins_dir . $plugin_file ) ); 829 832 … … function delete_plugins( $plugins, $deprecated = '' ) { 838 841 * Fires immediately after a plugin deletion attempt. 839 842 * 840 843 * @since 4.4.0 844 * @since 4.5.0 Added the `$uninstall` parameter. 841 845 * 842 846 * @param string $plugin_file Plugin file name. 843 847 * @param bool $deleted Whether the plugin deletion was successful. 848 * @param bool $uninstall Whether the plugin uninstall routine was run. 844 849 */ 845 do_action( 'deleted_plugin', $plugin_file, $deleted );850 do_action( 'deleted_plugin', $plugin_file, $deleted, $uninstall ); 846 851 847 852 if ( ! $deleted ) { 848 853 $errors[] = $plugin_file; -
src/wp-admin/plugins.php
diff --git src/wp-admin/plugins.php src/wp-admin/plugins.php index 93aec79..bfe59eb 100644
if ( $action ) { 227 227 exit; 228 228 229 229 case 'delete-selected': 230 case 'delete-selected-no-uninstall': 230 231 if ( ! current_user_can('delete_plugins') ) { 231 232 wp_die(__('You do not have sufficient permissions to delete plugins for this site.')); 232 233 } … … if ( $action ) { 320 321 $data_to_delete = false; 321 322 foreach ( $plugin_info as $plugin ) { 322 323 if ( $plugin['is_uninstallable'] ) { 323 /* translators: 1: plugin name, 2: plugin author */324 echo '<li>', sprintf( __( '<strong>%1$s</strong> by <em>%2$s</em> (will also <strong>delete its data</strong>)' ), $plugin['Name'], $plugin['AuthorName'] ), '</li>';325 324 $data_to_delete = true; 326 } else {327 /* translators: 1: plugin name, 2: plugin author */328 echo '<li>', sprintf( __('<strong>%1$s</strong> by <em>%2$s</em>' ), $plugin['Name'], $plugin['AuthorName'] ), '</li>';329 325 } 326 327 /* translators: 1: plugin name, 2: plugin author */ 328 echo '<li>', sprintf( __( '<strong>%1$s</strong> by <em>%2$s</em>' ), $plugin['Name'], $plugin['AuthorName'] ), '</li>'; 330 329 } 331 330 ?> 332 331 </ul> … … if ( $action ) { 336 335 else 337 336 _e('Are you sure you wish to delete these files?'); 338 337 ?></p> 339 <form method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>" style="display:inline;"> 340 <input type="hidden" name="verify-delete" value="1" /> 341 <input type="hidden" name="action" value="delete-selected" /> 342 <?php 338 <?php if ( $data_to_delete ) : ?> 339 <form method="post" action="<?php echo esc_url( $_SERVER['REQUEST_URI'] ); ?>" style="display:inline;"> 340 <input type="hidden" name="verify-delete" value="1"/> 341 <input type="hidden" name="action" value="delete-selected"/> 342 <?php 343 343 foreach ( (array) $plugins as $plugin ) { 344 344 echo '<input type="hidden" name="checked[]" value="' . esc_attr( $plugin ) . '" />'; 345 345 } 346 ?> 347 <?php wp_nonce_field('bulk-plugins') ?> 348 <?php submit_button( $data_to_delete ? __( 'Yes, delete these files and data' ) : __( 'Yes, delete these files' ), 'button', 'submit', false ); ?> 349 </form> 346 ?> 347 <?php wp_nonce_field( 'bulk-plugins' ) ?> 348 <?php submit_button( __( 'Yes, delete these files and data' ), 'primary', 'submit', false ); ?> 349 </form> 350 <form method="post" action="<?php echo esc_url( $_SERVER['REQUEST_URI'] ); ?>" style="display:inline;"> 351 <input type="hidden" name="verify-delete" value="1"/> 352 <input type="hidden" name="action" value="delete-selected-no-uninstall"/> 353 <?php 354 foreach ( (array) $plugins as $plugin ) { 355 echo '<input type="hidden" name="checked[]" value="' . esc_attr( $plugin ) . '" />'; 356 } 357 ?> 358 <?php wp_nonce_field( 'bulk-plugins' ) ?> 359 <?php submit_button( __( 'Delete files only' ), 'secondary', 'submit', false ); ?> 360 </form> 361 <?php else : ?> 362 <form method="post" action="<?php echo esc_url( $_SERVER['REQUEST_URI'] ); ?>" style="display:inline;"> 363 <input type="hidden" name="verify-delete" value="1"/> 364 <input type="hidden" name="action" value="delete-selected"/> 365 <?php 366 foreach ( (array) $plugins as $plugin ) { 367 echo '<input type="hidden" name="checked[]" value="' . esc_attr( $plugin ) . '" />'; 368 } 369 ?> 370 <?php wp_nonce_field( 'bulk-plugins' ) ?> 371 <?php submit_button( __( 'Yes, delete these files' ), 'primary', 'submit', false ); ?> 372 </form> 373 <?php endif; ?> 350 374 <?php 351 $referer = wp_get_referer(); 375 $referer = wp_get_referer(); 376 $return_url = $referer ? esc_url( $referer ) : esc_url( self_admin_url( 'plugins.php' ) ); 352 377 ?> 353 <form method="post" action="<?php echo $referer ? esc_url( $referer ) : ''; ?>" style="display:inline;"> 354 <?php submit_button( __( 'No, return me to the plugin list' ), 'button', 'submit', false ); ?> 355 </form> 378 <p><a href="<?php echo $return_url; ?>"><?php _e( 'Return to Plugins page' ); ?></a></p> 356 379 357 380 <p><a href="#" onclick="jQuery('#files-list').toggle(); return false;"><?php _e('Click to view entire list of files which will be deleted'); ?></a></p> 358 381 <div id="files-list" style="display:none;"> … … if ( $action ) { 372 395 $plugins_to_delete = count( $plugins ); 373 396 } // endif verify-delete 374 397 375 $delete_result = delete_plugins( $plugins );398 $delete_result = delete_plugins( $plugins, '', 'delete-selected' === $action ); 376 399 377 400 set_transient('plugins_delete_result_' . $user_ID, $delete_result); //Store the result in a cache rather than a URL param due to object type & length 378 401 wp_redirect( self_admin_url("plugins.php?deleted=$plugins_to_delete&plugin_status=$status&paged=$page&s=$s") );