Changeset 6849

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

Bulk link category delete

Files:

Legend:

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

    r6805 r6849  
    11<?php 
    22require_once('admin.php'); 
     3 
     4// Handle bulk deletes 
     5if ( isset($_GET['deleteit']) && isset($_GET['delete']) ) { 
     6    check_admin_referer('bulk-link-categories'); 
     7 
     8    if ( !current_user_can('manage_categories') ) 
     9        wp_die(__('Cheatin&#8217; uh?')); 
     10 
     11    foreach( (array) $_GET['delete'] as $cat_ID ) { 
     12        $cat_name = get_term_field('name', $cat_ID, 'link_category'); 
     13 
     14        // Don't delete the default cats. 
     15        if ( $cat_ID == get_option('default_link_category') ) 
     16            wp_die(sprintf(__("Can&#8217;t delete the <strong>%s</strong> category: this is the default one"), $cat_name)); 
     17 
     18        wp_delete_term($cat_ID, 'link_category'); 
     19    } 
     20 
     21    wp_redirect('edit-link-categories.php?message=6'); 
     22    exit(); 
     23} 
    324 
    425$title = __('Link Categories'); 
     
    627 
    728wp_enqueue_script( 'admin-categories' ); 
     29wp_enqueue_script('admin-forms'); 
     30 
    831require_once ('admin-header.php'); 
    932 
     
    1336$messages[4] = __('Category not added.'); 
    1437$messages[5] = __('Category not updated.'); 
     38$messages[6] = __('Categories deleted.'); 
    1539 
    1640if (isset($_GET['message'])) : ?> 
     
    5680 
    5781<div style="float: left"> 
    58 <input type="button" value="<?php _e('Delete'); ?>" name="deleteit" /> 
     82<input type="submit" value="<?php _e('Delete'); ?>" name="deleteit" /> 
     83<?php wp_nonce_field('bulk-link-categories'); ?> 
    5984</div> 
    6085 
    6186<br style="clear:both;" /> 
    6287</div> 
    63 </form> 
    6488 
    6589<br style="clear:both;" /> 
     
    6892    <thead> 
    6993    <tr> 
    70         <th scope="col" style="text-align: center"><input type="checkbox" onclick="checkAll(document.getElementById('deletetags'));" /></th> 
     94        <th scope="col" style="text-align: center"><input type="checkbox" onclick="checkAll(document.getElementById('posts-filter'));" /></th> 
    7195        <th scope="col"><?php _e('Name') ?></th> 
    7296        <th scope="col"><?php _e('Description') ?></th> 
     
    96120    </tbody> 
    97121</table> 
     122</form> 
    98123 
    99124<br style="clear:both;" /> 
  • trunk/wp-admin/includes/template.php

    r6827 r6849  
    8282    $count = ( $category->count > 0 ) ? "<a href='link-manager.php?cat_id=$category->term_id'>$category->count</a>" : $category->count; 
    8383    $output = "<tr id='link-cat-$category->term_id'$class>" . 
    84         '<td style="text-align: center"> <input type="checkbox" name="delete_tags[]" value="' . $category->term_id . '" /></td>' . 
     84        '<td style="text-align: center"> <input type="checkbox" name="delete[]" value="' . $category->term_id . '" /></td>' . 
    8585        "<td>$edit</td> 
    8686        <td>$category->description</td>