Changeset 6847

Show
Ignore:
Timestamp:
02/14/08 09:17:00 (9 months ago)
Author:
ryan
Message:

Bulk delete for categories

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-admin/categories.php

    r6804 r6847  
    66 
    77wp_reset_vars(array('action', 'cat')); 
     8 
     9if ( isset($_GET['deleteit']) && isset($_GET['delete']) ) 
     10    $action = 'bulk-delete'; 
    811 
    912switch($action) { 
     
    4447break; 
    4548 
     49case 'bulk-delete': 
     50    check_admin_referer('bulk-categories'); 
     51 
     52    if ( !current_user_can('manage_categories') ) 
     53        wp_die( __('You are not allowed to delete categories.') ); 
     54 
     55    foreach ( (array) $_GET['delete'] as $cat_ID ) { 
     56        $cat_name = get_catname($cat_ID); 
     57 
     58        // Don't delete the default cats. 
     59        if ( $cat_ID == get_option('default_category') ) 
     60            wp_die(sprintf(__("Can&#8217;t delete the <strong>%s</strong> category: this is the default one"), $cat_name)); 
     61 
     62        wp_delete_category($cat_ID); 
     63    } 
     64 
     65    $sendback = wp_get_referer(); 
     66    $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback); 
     67 
     68    wp_redirect($sendback); 
     69    exit(); 
     70 
     71break; 
    4672case 'edit': 
    4773 
     
    7197 
    7298wp_enqueue_script( 'admin-categories' ); 
     99wp_enqueue_script('admin-forms'); 
     100 
    73101require_once ('admin-header.php'); 
    74102 
     
    102130 
    103131<div style="float: left"> 
    104 <input type="button" value="<?php _e('Delete'); ?>" name="deleteit" /> 
     132<input type="submit" value="<?php _e('Delete'); ?>" name="deleteit" /> 
     133<?php wp_nonce_field('bulk-categories'); ?> 
    105134</div> 
    106135 
    107136<br style="clear:both;" /> 
    108137</div> 
    109 </form> 
    110138 
    111139<br style="clear:both;" /> 
     
    114142    <thead> 
    115143    <tr> 
    116         <th scope="col"><div style="text-align: center"><input type="checkbox" name="TODO" /></div></th> 
     144        <th scope="col"><div style="text-align: center"><input type="checkbox" onclick="checkAll(document.getElementById('posts-filter'));" /></div></th> 
    117145        <th scope="col"><?php _e('Name') ?></th> 
    118146        <th scope="col"><?php _e('Description') ?></th> 
    119         <th scope="col" width="90" style="text-align: center"><?php _e('Posts') ?></th> 
     147        <th scope="col" style="text-align: center"><?php _e('Posts') ?></th> 
    120148    </tr> 
    121149    </thead> 
     
    126154    </tbody> 
    127155</table> 
     156</form> 
    128157 
    129158<br style="clear:both;" />