From 22e486c4f8c741cfd5f5030cc99e491207f0ab48 Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 16 Jun 2008 18:35:48 +0000 Subject: [PATCH] Delete plugin confirmation from DD32. see #7091 git-svn-id: http://svn.automattic.com/wordpress/trunk@8095 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/file.php | 28 ++++++++++++ wp-admin/includes/plugin.php | 13 ++---- wp-admin/plugins.php | 87 ++++++++++++++++++++++++++++++++---- 3 files changed, 110 insertions(+), 18 deletions(-) diff --git a/wp-admin/includes/file.php b/wp-admin/includes/file.php index 2e0925012d..d5b46ce7d5 100644 --- a/wp-admin/includes/file.php +++ b/wp-admin/includes/file.php @@ -41,6 +41,34 @@ function get_real_file_to_edit( $file ) { return $real_file; } +//$folder = Full path to folder +//$levels = Levels of folders to follow, Default: 100 (PHP Loop limit) +function list_files( $folder = '', $levels = 100 ) { + if( empty($folder) ) + return false; + + if( ! $levels ) + return false; + + $files = array(); + if ( $dir = @opendir( $folder ) ) { + while (($file = readdir( $dir ) ) !== false ) { + if ( in_array($file, array('.', '..') ) ) + continue; + if ( is_dir( $folder . '/' . $file ) ) { + $files2 = list_files( $folder . '/' . $file, $levels - 1); + if( $files2 ) + $files = array_merge($files, $files2 ); + else + $files[] = $folder . '/' . $file . '/'; + } else { + $files[] = $folder . '/' . $file; + } + } + } + @closedir( $dir ); + return $files; +} function get_temp_dir() { if ( defined('WP_TEMP_DIR') ) diff --git a/wp-admin/includes/plugin.php b/wp-admin/includes/plugin.php index 3afaed92e9..72acd45587 100644 --- a/wp-admin/includes/plugin.php +++ b/wp-admin/includes/plugin.php @@ -136,7 +136,6 @@ function deactivate_plugins($plugins, $silent= false) { update_option('active_plugins', $current); } -//Replaces reactivate_all_plugins() / deactivate_all_plugins() = 'deactivated_plugins' is now useless function activate_plugins($plugins, $redirect = '') { if ( !is_array($plugins) ) $plugins = array($plugins); @@ -167,7 +166,7 @@ function delete_plugins($plugins, $redirect = '' ) { $checked[] = 'checked[]=' . $plugin; ob_start(); - $url = wp_nonce_url('plugins.php?action=delete-selected&' . implode('&', $checked), 'mass-manage-plugins'); + $url = wp_nonce_url('plugins.php?action=delete-selected&verify-delete=1&' . implode('&', $checked), 'bulk-manage-plugins'); if ( false === ($credentials = request_filesystem_credentials($url)) ) { $data = ob_get_contents(); ob_end_clean(); @@ -243,13 +242,9 @@ function validate_active_plugins() { // If a plugin file does not exist, remove it from the list of active // plugins. foreach ( $check_plugins as $check_plugin ) { - if ( !file_exists(WP_PLUGIN_DIR . '/' . $check_plugin) ) { - $current = get_option('active_plugins'); - $key = array_search($check_plugin, $current); - if ( false !== $key && NULL !== $key ) { - unset($current[$key]); - update_option('active_plugins', $current); - } + $result = validate_plugin($check_plugin); + if ( is_wp_error( $result ) ) { + deactivate_plugins( $check_plugin, true); } } } diff --git a/wp-admin/plugins.php b/wp-admin/plugins.php index a3e7c005d6..52876c57ca 100644 --- a/wp-admin/plugins.php +++ b/wp-admin/plugins.php @@ -30,7 +30,7 @@ if( !empty($action) ) { exit; break; case 'activate-selected': - check_admin_referer('mass-manage-plugins'); + check_admin_referer('bulk-manage-plugins'); activate_plugins($_POST['checked'], 'plugins.php?error=true'); $recent = (array)get_option('recently_activated'); @@ -62,7 +62,7 @@ if( !empty($action) ) { exit; break; case 'deactivate-selected': - check_admin_referer('mass-manage-plugins'); + check_admin_referer('bulk-manage-plugins'); deactivate_plugins($_POST['checked']); $deactivated = array(); foreach( (array)$_POST['checked'] as $plugin ) @@ -74,20 +74,87 @@ if( !empty($action) ) { case 'delete-selected': if( ! current_user_can('delete_plugins') ) wp_die(__('You do not have sufficient permissions to delete plugins for this blog.')); - check_admin_referer('mass-manage-plugins'); - $plugins = $_REQUEST['checked']; + + check_admin_referer('bulk-manage-plugins'); + + $plugins = $_REQUEST['checked']; //$_POST = from the plugin form; $_GET = from the FTP details screen. include(ABSPATH . 'wp-admin/update.php'); $title = __('Delete Plugin'); $parent_file = 'plugins.php'; + + if( ! isset($_REQUEST['verify-delete']) ) { + wp_enqueue_script('jquery'); + require_once('admin-header.php'); + ?> +
+

+ +

+

+

+

+

+
+ + + "; + } + ?> + + +
+
+ +
+

+ +
+
- +
@@ -240,7 +307,7 @@ function print_plugins_table($plugins, $context = '') {

- +
@@ -257,8 +324,9 @@ function print_plugins_table($plugins, $context = '') {

- + +
@@ -270,6 +338,7 @@ function print_plugins_table($plugins, $context = '') {
+

WordPress plugin directory.'); ?>