Make WordPress Core


Ignore:
Timestamp:
12/03/2009 01:43:49 AM (17 years ago)
Author:
azaozz
Message:

Fix errors when bulk actions executed on empty list, props nacin, see #11184

File:
1 edited

Legend:

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

    r12228 r12317  
    3535
    3636case 'delete':
     37        if ( !isset( $_GET['cat_ID'] ) ) {
     38                wp_redirect('categories.php');
     39                exit;
     40        }
     41
    3742        $cat_ID = (int) $_GET['cat_ID'];
    3843        check_admin_referer('delete-category_' .  $cat_ID);
    … …  
    4146                wp_die(__('Cheatin’ uh?'));
    4247
    43         $cat_name = get_cat_name($cat_ID);
    44 
    4548        // Don't delete the default cats.
    4649        if ( $cat_ID == get_option('default_category') )
    47                 wp_die(sprintf(__("Can&#8217;t delete the <strong>%s</strong> category: this is the default one"), $cat_name));
     50                wp_die( sprintf( __("Can&#8217;t delete the <strong>%s</strong> category: this is the default one"), get_cat_name($cat_ID) ) );
    4851
    4952        wp_delete_category($cat_ID);
    … …  
    6063                wp_die( __('You are not allowed to delete categories.') );
    6164
    62         foreach ( (array) $_GET['delete'] as $cat_ID ) {
    63                 $cat_name = get_cat_name($cat_ID);
    64 
    65                 // Don't delete the default cats.
    66                 if ( $cat_ID == get_option('default_category') )
    67                         wp_die(sprintf(__("Can&#8217;t delete the <strong>%s</strong> category: this is the default one"), $cat_name));
     65        $cats = (array) $_GET['delete'];
     66        $default_cat = get_option('default_category');
     67        foreach ( $cats as $cat_ID ) {
     68                $cat_ID = (int) $cat_ID;
     69
     70                // Don't delete the default cat.
     71                if ( $cat_ID == $default_cat )
     72                        wp_die( sprintf( __("Can&#8217;t delete the <strong>%s</strong> category: this is the default one"), get_cat_name($cat_ID) ) );
    6873
    6974                wp_delete_category($cat_ID);
    … …  
    7176
    7277        wp_safe_redirect( wp_get_referer() );
    73         exit();
     78        exit;
    7479
    7580break;
Note: See TracChangeset for help on using the changeset viewer.