Ticket #7091: 7091.2.diff
File 7091.2.diff, 8.2 KB (added by , 16 years ago) |
---|
-
wp-admin/includes/file.php
41 41 42 42 return $real_file; 43 43 } 44 //$folder = Full path to folder 45 //$levels = Levels of folders to follow, Default: 100 (PHP Loop limit) 46 function list_files( $folder = '', $levels = 100 ) { 47 if( empty($folder) ) 48 return false; 44 49 50 if( ! $levels ) 51 return false; 52 53 $files = array(); 54 if ( $dir = @opendir( $folder ) ) { 55 while (($file = readdir( $dir ) ) !== false ) { 56 if ( in_array($file, array('.', '..') ) ) 57 continue; 58 if ( is_dir( $folder . '/' . $file ) ) { 59 $files2 = list_files( $folder . '/' . $file, $levels - 1); 60 if( $files2 ) 61 $files = array_merge($files, $files2 ); 62 else 63 $files[] = $folder . '/' . $file . '/'; 64 } else { 65 $files[] = $folder . '/' . $file; 66 } 67 } 68 } 69 @closedir( $dir ); 70 return $files; 71 } 72 45 73 function get_temp_dir() { 46 74 if ( defined('WP_TEMP_DIR') ) 47 75 return trailingslashit(WP_TEMP_DIR); -
wp-admin/includes/plugin.php
136 136 update_option('active_plugins', $current); 137 137 } 138 138 139 //Replaces reactivate_all_plugins() / deactivate_all_plugins() = 'deactivated_plugins' is now useless140 139 function activate_plugins($plugins, $redirect = '') { 141 140 if ( !is_array($plugins) ) 142 141 $plugins = array($plugins); … … 167 166 $checked[] = 'checked[]=' . $plugin; 168 167 169 168 ob_start(); 170 $url = wp_nonce_url('plugins.php?action=delete-selected& ' . implode('&', $checked), 'mass-manage-plugins');169 $url = wp_nonce_url('plugins.php?action=delete-selected&verify-delete=1&' . implode('&', $checked), 'bulk-manage-plugins'); 171 170 if ( false === ($credentials = request_filesystem_credentials($url)) ) { 172 171 $data = ob_get_contents(); 173 172 ob_end_clean(); … … 243 242 // If a plugin file does not exist, remove it from the list of active 244 243 // plugins. 245 244 foreach ( $check_plugins as $check_plugin ) { 246 if ( !file_exists(WP_PLUGIN_DIR . '/' . $check_plugin) ) { 247 $current = get_option('active_plugins'); 248 $key = array_search($check_plugin, $current); 249 if ( false !== $key && NULL !== $key ) { 250 unset($current[$key]); 251 update_option('active_plugins', $current); 252 } 245 $result = validate_plugin($check_plugin); 246 if ( is_wp_error( $result ) ) { 247 deactivate_plugins( $check_plugin, true); 253 248 } 254 249 } 255 250 } -
wp-admin/plugins.php
30 30 exit; 31 31 break; 32 32 case 'activate-selected': 33 check_admin_referer(' mass-manage-plugins');33 check_admin_referer('bulk-manage-plugins'); 34 34 activate_plugins($_POST['checked'], 'plugins.php?error=true'); 35 35 36 36 $recent = (array)get_option('recently_activated'); … … 62 62 exit; 63 63 break; 64 64 case 'deactivate-selected': 65 check_admin_referer(' mass-manage-plugins');65 check_admin_referer('bulk-manage-plugins'); 66 66 deactivate_plugins($_POST['checked']); 67 67 $deactivated = array(); 68 68 foreach( (array)$_POST['checked'] as $plugin ) … … 74 74 case 'delete-selected': 75 75 if( ! current_user_can('delete_plugins') ) 76 76 wp_die(__('You do not have sufficient permissions to delete plugins for this blog.')); 77 check_admin_referer('mass-manage-plugins'); 78 $plugins = $_REQUEST['checked']; 77 78 check_admin_referer('bulk-manage-plugins'); 79 80 $plugins = $_REQUEST['checked']; //$_POST = from the plugin form; $_GET = from the FTP details screen. 79 81 include(ABSPATH . 'wp-admin/update.php'); 80 82 81 83 $title = __('Delete Plugin'); 82 84 $parent_file = 'plugins.php'; 85 86 if( ! isset($_REQUEST['verify-delete']) ) { 87 wp_enqueue_script('jquery'); 88 require_once('admin-header.php'); 89 ?> 90 <div class="wrap"> 91 <h2><?php _e('Delete Plugin(s)'); ?></h2> 92 <?php 93 $files_to_delete = $plugin_info = array(); 94 foreach( (array) $plugins as $plugin ) { 95 if( '.' == dirname($plugin) ) { 96 $files_to_delete[] = WP_PLUGIN_DIR . '/' . $plugin; 97 if( $data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin) ) 98 $plugin_info[ $plugin ] = $data; 99 } else { 100 //Locate all the files in that folder: 101 $files = list_files( WP_PLUGIN_DIR . '/' . dirname($plugin) ); 102 if( $files ) { 103 $files_to_delete = array_merge($files_to_delete, $files); 104 } 105 //Get plugins list from that folder 106 if ( $folder_plugins = get_plugins( '/' . dirname($plugin)) ) 107 $plugin_info = array_merge($plugin_info, $folder_plugins); 108 } 109 } 110 ?> 111 <p><?php _e('Deleting the selected plugins will remove the following plugin(s) and their files:'); ?></p> 112 <p> 113 <ul> 114 <?php 115 foreach( $plugin_info as $plugin ) 116 echo '<li>', $plugin['Title'], ' ', __('By'), ' ', $plugin['Author'], '</li>'; 117 ?> 118 </ul> 119 </p> 120 <p><?php _e('Are you sure you wish to delete these files?') ?></p> 121 <form method="post" action="<?php echo clean_url($_SERVER['REQUEST_URI']); ?>" style="display:inline;"> 122 <input type="hidden" name="verify-delete" value="1" /> 123 <input type="hidden" name="delete-selected" value="1" /> 124 <?php 125 foreach( (array)$plugins as $plugin ) { 126 $plugin = attribute_escape($plugin); 127 echo "<input type='hidden' name='checked[]' value='$plugin' />"; 128 } 129 ?> 130 <?php wp_nonce_field('bulk-manage-plugins') ?> 131 <input type="submit" name="submit" value="<?php _e('Yes, Delete these files') ?>" class="button" /> 132 </form> 133 <form method="post" action="<?php echo clean_url(wp_get_referer()); ?>" style="display:inline;"> 134 <input type="submit" name="submit" value="<?php _e('No, Return me to the plugin list') ?>" class="button" /> 135 </form> 83 136 137 <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> 138 <div id="files-list" style="display:none;"> 139 <ul> 140 <?php 141 foreach( (array)$files_to_delete as $file ) { 142 $file = str_replace(ABSPATH, '', $file); 143 echo "<li>$file</li>"; 144 } 145 ?> 146 </ul> 147 </div> 148 </div> 149 <?php 150 require_once('admin-footer.php'); 151 exit; 152 } 84 153 $delete_result = delete_plugins($plugins); 85 154 86 155 wp_cache_delete('plugins', 'plugins'); 87 156 88 157 break; 89 default:90 var_dump("Unknown Action $action");91 158 } 92 159 } 93 160 … … 224 291 225 292 <h3 id="currently-active"><?php _e('Currently Active Plugins') ?></h3> 226 293 <form method="post" action="<?php echo admin_url('plugins.php') ?>"> 227 <?php wp_nonce_field(' mass-manage-plugins') ?>294 <?php wp_nonce_field('bulk-manage-plugins') ?> 228 295 229 296 <div class="tablenav"> 230 297 <div class="alignleft"> … … 240 307 <?php if ( ! empty($recent_plugins) ) : ?> 241 308 <h3 id="recent-plugins"><?php _e('Recently Active Plugins') ?></h3> 242 309 <form method="post" action="<?php echo admin_url('plugins.php') ?>"> 243 <?php wp_nonce_field(' mass-manage-plugins') ?>310 <?php wp_nonce_field('bulk-manage-plugins') ?> 244 311 245 312 <div class="tablenav"> 246 313 <div class="alignleft"> … … 257 324 258 325 <h3 id="available-plugins"><?php _e('Available Plugins') ?></h3> 259 326 <form method="post" action="<?php echo admin_url('plugins.php') ?>"> 260 <?php wp_nonce_field(' mass-manage-plugins') ?>327 <?php wp_nonce_field('bulk-manage-plugins') ?> 261 328 329 <?php if ( ! empty($available_plugins) ) : ?> 262 330 <div class="tablenav"> 263 331 <div class="alignleft"> 264 332 <input type="submit" name="activate-selected" value="<?php _e('Activate') ?>" class="button-secondary" /> … … 270 338 <br class="clear" /> 271 339 <?php print_plugins_table($available_plugins, 'available') ?> 272 340 </form> 341 <?php endif; ?> 273 342 274 343 <h2><?php _e('Get More Plugins'); ?></h2> 275 344 <p><?php _e('You can find additional plugins for your site in the <a href="http://wordpress.org/extend/plugins/">WordPress plugin directory</a>.'); ?></p>