Ticket #20578: 20578.3.diff
File 20578.3.diff, 8.6 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 25f6828..70989b0 100644
function activate_plugins( $plugins, $redirect = '', $network_wide = false, $sil 760 760 * Remove directory and files of a plugin for a list of plugins. 761 761 * 762 762 * @since 2.6.0 763 * @since 4.6.0 Added the `$uninstall` parameter. 763 764 * 764 765 * @global WP_Filesystem_Base $wp_filesystem 765 766 * 766 767 * @param array $plugins List of plugins to delete. 767 768 * @param string $deprecated Deprecated. 769 * @param bool $uninstall Optional. Whether the plugin install routine should be run. Default true. 768 770 * @return bool|null|WP_Error True on success, false is $plugins is empty, WP_Error on failure. 769 771 * Null if filesystem credentials are required to proceed. 770 772 */ 771 function delete_plugins( $plugins, $deprecated = '' ) {773 function delete_plugins( $plugins, $deprecated = '', $uninstall = true ) { 772 774 global $wp_filesystem; 773 775 774 776 if ( empty($plugins) ) … … function delete_plugins( $plugins, $deprecated = '' ) { 825 827 826 828 foreach ( $plugins as $plugin_file ) { 827 829 // Run Uninstall hook. 828 if ( is_uninstallable_plugin( $plugin_file ) ) {830 if ( is_uninstallable_plugin( $plugin_file ) && $uninstall ) { 829 831 uninstall_plugin($plugin_file); 830 832 } 831 833 … … function delete_plugins( $plugins, $deprecated = '' ) { 833 835 * Fires immediately before a plugin deletion attempt. 834 836 * 835 837 * @since 4.4.0 838 * @since 4.6.0 Added the `$uninstall` parameter. 836 839 * 837 840 * @param string $plugin_file Plugin file name. 841 * @param bool $uninstall Whether the plugin uninstall routine was run. 838 842 */ 839 do_action( 'delete_plugin', $plugin_file );843 do_action( 'delete_plugin', $plugin_file, $uninstall ); 840 844 841 845 $this_plugin_dir = trailingslashit( dirname( $plugins_dir . $plugin_file ) ); 842 846 … … function delete_plugins( $plugins, $deprecated = '' ) { 851 855 * Fires immediately after a plugin deletion attempt. 852 856 * 853 857 * @since 4.4.0 858 * @since 4.6.0 Added the `$uninstall` parameter. 854 859 * 855 860 * @param string $plugin_file Plugin file name. 856 861 * @param bool $deleted Whether the plugin deletion was successful. 862 * @param bool $uninstall Whether the plugin uninstall routine was run. 857 863 */ 858 do_action( 'deleted_plugin', $plugin_file, $deleted );864 do_action( 'deleted_plugin', $plugin_file, $deleted, $uninstall ); 859 865 860 866 if ( ! $deleted ) { 861 867 $errors[] = $plugin_file; -
src/wp-admin/plugins.php
diff --git src/wp-admin/plugins.php src/wp-admin/plugins.php index 3b9d334..03e38d2 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( __( '%1$s by %2$s (will also <strong>delete its data</strong>)' ), '<strong>' . $plugin['Name'] . '</strong>', '<em>' . $plugin['AuthorName'] . '</em>' ), '</li>';307 306 $data_to_delete = true; 308 } else {309 /* translators: 1: plugin name, 2: plugin author */310 echo '<li>', sprintf( _x('%1$s by %2$s', 'plugin' ), '<strong>' . $plugin['Name'] . '</strong>', '<em>' . $plugin['AuthorName'] ) . '</em>', '</li>';311 307 } 308 309 /* translators: 1: plugin name, 2: plugin author */ 310 echo '<li>', sprintf( _x('%1$s by %2$s', 'plugin' ), '<strong>' . $plugin['Name'] . '</strong>', '<em>' . $plugin['AuthorName'] ) . '</em>', '</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") );