Ticket #20578: 20578.2.diff
File 20578.2.diff, 8.3 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 0b504b5..c5e5624 100644
function activate_plugins( $plugins, $redirect = '', $network_wide = false, $sil 755 755 * 756 756 * @param array $plugins List of plugins to delete. 757 757 * @param string $deprecated Deprecated. 758 * @param bool $uninstall Optional. Whether the plugin install routine should be run. Default true. 758 759 * @return bool|null|WP_Error True on success, false is $plugins is empty, WP_Error on failure. 759 760 * Null if filesystem credentials are required to proceed. 760 761 */ 761 function delete_plugins( $plugins, $deprecated = '' ) {762 function delete_plugins( $plugins, $deprecated = '', $uninstall = true ) { 762 763 global $wp_filesystem; 763 764 764 765 if ( empty($plugins) ) … … function delete_plugins( $plugins, $deprecated = '' ) { 815 816 816 817 foreach ( $plugins as $plugin_file ) { 817 818 // Run Uninstall hook. 818 if ( is_uninstallable_plugin( $plugin_file ) ) {819 if ( is_uninstallable_plugin( $plugin_file ) && $uninstall ) { 819 820 uninstall_plugin($plugin_file); 820 821 } 821 822 … … function delete_plugins( $plugins, $deprecated = '' ) { 823 824 * Fires immediately before a plugin deletion attempt. 824 825 * 825 826 * @since 4.4.0 827 * @since 4.5.0 Added the `$uninstall` parameter. 826 828 * 827 829 * @param string $plugin_file Plugin file name. 830 * @param bool $uninstall Whether the plugin uninstall routine was run. 828 831 */ 829 do_action( 'delete_plugin', $plugin_file );832 do_action( 'delete_plugin', $plugin_file, $uninstall ); 830 833 831 834 $this_plugin_dir = trailingslashit( dirname( $plugins_dir . $plugin_file ) ); 832 835 … … function delete_plugins( $plugins, $deprecated = '' ) { 841 844 * Fires immediately after a plugin deletion attempt. 842 845 * 843 846 * @since 4.4.0 847 * @since 4.5.0 Added the `$uninstall` parameter. 844 848 * 845 849 * @param string $plugin_file Plugin file name. 846 850 * @param bool $deleted Whether the plugin deletion was successful. 851 * @param bool $uninstall Whether the plugin uninstall routine was run. 847 852 */ 848 do_action( 'deleted_plugin', $plugin_file, $deleted );853 do_action( 'deleted_plugin', $plugin_file, $deleted, $uninstall ); 849 854 850 855 if ( ! $deleted ) { 851 856 $errors[] = $plugin_file; -
src/wp-admin/plugins.php
diff --git src/wp-admin/plugins.php src/wp-admin/plugins.php index a55001e..dd8297f 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 ) { 284 285 } 285 286 $plugins_to_delete = count( $plugin_info ); 286 287 ?> 287 <?php if ( 1 == $plugins_to_delete ) : ?>288 <?php if ( 1 === $plugins_to_delete ) : ?> 288 289 <h1><?php _e( 'Delete Plugin' ); ?></h1> 289 290 <?php if ( $have_non_network_plugins && is_network_admin() ) : ?> 290 291 <div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php _e( 'This plugin may be active on other sites in the network.' ); ?></p></div> … … if ( $action ) { 302 303 $data_to_delete = false; 303 304 foreach ( $plugin_info as $plugin ) { 304 305 if ( $plugin['is_uninstallable'] ) { 305 /* translators: 1: plugin name, 2: plugin author */306 echo '<li>', sprintf( __( '<strong>%1$s</strong> by <em>%2$s</em> (will also <strong>delete its data</strong>)' ), $plugin['Name'], $plugin['AuthorName'] ), '</li>';307 306 $data_to_delete = true; 308 } else {309 /* translators: 1: plugin name, 2: plugin author */310 echo '<li>', sprintf( __('<strong>%1$s</strong> by <em>%2$s</em>' ), $plugin['Name'], $plugin['AuthorName'] ), '</li>';311 307 } 308 309 /* translators: 1: plugin name, 2: plugin author */ 310 echo '<li>', sprintf( __( '<strong>%1$s</strong> by <em>%2$s</em>' ), $plugin['Name'], $plugin['AuthorName'] ), '</li>'; 312 311 } 313 312 ?> 314 313 </ul> 315 <p><?php 316 if ( $data_to_delete ) 317 _e('Are you sure you wish to delete these files and data?'); 318 else 319 _e('Are you sure you wish to delete these files?'); 320 ?></p> 321 <form method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>" style="display:inline;"> 322 <input type="hidden" name="verify-delete" value="1" /> 323 <input type="hidden" name="action" value="delete-selected" /> 314 <p> 324 315 <?php 316 if ( 1 === $plugins_to_delete ) { 317 if ( $data_to_delete ) { 318 _e( 'Are you sure you wish to delete this plugin and all of its data?' ); 319 } else { 320 _e( 'Are you sure you wish to delete this plugin?' ); 321 } 322 } else { 323 if ( $data_to_delete ) { 324 _e( 'Are you sure you wish to delete these plugins and all of their data?' ); 325 } else { 326 _e( 'Are you sure you wish to delete these plugins?' ); 327 } 328 } 329 ?> 330 </p> 331 <?php if ( $data_to_delete ) : ?> 332 <form method="post" action="<?php echo esc_url( $_SERVER['REQUEST_URI'] ); ?>" style="display:inline;"> 333 <input type="hidden" name="verify-delete" value="1"/> 334 <input type="hidden" name="action" value="delete-selected"/> 335 <?php 325 336 foreach ( (array) $plugins as $plugin ) { 326 337 echo '<input type="hidden" name="checked[]" value="' . esc_attr( $plugin ) . '" />'; 327 338 } 328 ?> 329 <?php wp_nonce_field('bulk-plugins') ?> 330 <?php submit_button( $data_to_delete ? __( 'Yes, delete these files and data' ) : __( 'Yes, delete these files' ), 'button', 'submit', false ); ?> 331 </form> 339 ?> 340 <?php wp_nonce_field( 'bulk-plugins' ) ?> 341 <?php 342 if ( 1 === $plugins_to_delete ) { 343 submit_button( __( 'Yes, completely uninstall this plugin' ), 'primary', 'submit', false ); 344 } else { 345 submit_button( __( 'Yes, completely uninstall these plugins' ), 'primary', 'submit', false ); 346 } 347 ?> 348 </form> 349 <form method="post" action="<?php echo esc_url( $_SERVER['REQUEST_URI'] ); ?>" style="display:inline;"> 350 <input type="hidden" name="verify-delete" value="1"/> 351 <input type="hidden" name="action" value="delete-selected-no-uninstall"/> 352 <?php 353 foreach ( (array) $plugins as $plugin ) { 354 echo '<input type="hidden" name="checked[]" value="' . esc_attr( $plugin ) . '" />'; 355 } 356 ?> 357 <?php wp_nonce_field( 'bulk-plugins' ) ?> 358 <?php submit_button( __( 'Delete files only' ), 'secondary', 'submit', false ); ?> 359 </form> 360 <?php else : ?> 361 <form method="post" action="<?php echo esc_url( $_SERVER['REQUEST_URI'] ); ?>" style="display:inline;"> 362 <input type="hidden" name="verify-delete" value="1"/> 363 <input type="hidden" name="action" value="delete-selected"/> 364 <?php 365 foreach ( (array) $plugins as $plugin ) { 366 echo '<input type="hidden" name="checked[]" value="' . esc_attr( $plugin ) . '" />'; 367 } 368 ?> 369 <?php wp_nonce_field( 'bulk-plugins' ) ?> 370 <?php 371 if ( 1 === $plugins_to_delete ) { 372 submit_button( __( 'Yes, delete this plugin' ), 'primary', 'submit', false ); 373 } else { 374 submit_button( __( 'Yes, delete these plugins' ), 'primary', 'submit', false ); 375 } 376 ?> 377 </form> 378 <?php endif; ?> 332 379 <?php 333 $referer = wp_get_referer(); 380 $referer = wp_get_referer(); 381 $return_url = $referer ? esc_url( $referer ) : esc_url( self_admin_url( 'plugins.php' ) ); 334 382 ?> 335 <form method="post" action="<?php echo $referer ? esc_url( $referer ) : ''; ?>" style="display:inline;"> 336 <?php submit_button( __( 'No, return me to the plugin list' ), 'button', 'submit', false ); ?> 337 </form> 383 <p><a href="<?php echo $return_url; ?>"><?php _e( 'Return to Plugins page' ); ?></a></p> 338 384 </div> 339 385 <?php 340 386 require_once(ABSPATH . 'wp-admin/admin-footer.php'); … … if ( $action ) { 343 389 $plugins_to_delete = count( $plugins ); 344 390 } // endif verify-delete 345 391 346 $delete_result = delete_plugins( $plugins );392 $delete_result = delete_plugins( $plugins, '', 'delete-selected' === $action ); 347 393 348 394 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 349 395 wp_redirect( self_admin_url("plugins.php?deleted=$plugins_to_delete&plugin_status=$status&paged=$page&s=$s") );