]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/categories.php
Wordpress 2.9
[autoinstalls/wordpress.git] / wp-admin / categories.php
index 8d26b9e134480d5b861f99c22cfa785d3614753a..9639281f600277f0984578ba7084d3296daec38d 100644 (file)
@@ -34,17 +34,20 @@ case 'addcat':
 break;
 
 case 'delete':
+       if ( !isset( $_GET['cat_ID'] ) ) {
+               wp_redirect('categories.php');
+               exit;
+       }
+
        $cat_ID = (int) $_GET['cat_ID'];
        check_admin_referer('delete-category_' .  $cat_ID);
 
        if ( !current_user_can('manage_categories') )
                wp_die(__('Cheatin’ uh?'));
 
-       $cat_name = get_cat_name($cat_ID);
-
        // Don't delete the default cats.
        if ( $cat_ID == get_option('default_category') )
-               wp_die(sprintf(__("Can&#8217;t delete the <strong>%s</strong> category: this is the default one"), $cat_name));
+               wp_die( sprintf( __("Can&#8217;t delete the <strong>%s</strong> category: this is the default one"), get_cat_name($cat_ID) ) );
 
        wp_delete_category($cat_ID);
 
@@ -59,18 +62,20 @@ case 'bulk-delete':
        if ( !current_user_can('manage_categories') )
                wp_die( __('You are not allowed to delete categories.') );
 
-       foreach ( (array) $_GET['delete'] as $cat_ID ) {
-               $cat_name = get_cat_name($cat_ID);
+       $cats = (array) $_GET['delete'];
+       $default_cat = get_option('default_category');
+       foreach ( $cats as $cat_ID ) {
+               $cat_ID = (int) $cat_ID;
 
-               // Don't delete the default cats.
-               if ( $cat_ID == get_option('default_category') )
-                       wp_die(sprintf(__("Can&#8217;t delete the <strong>%s</strong> category: this is the default one"), $cat_name));
+               // Don't delete the default cat.
+               if ( $cat_ID == $default_cat )
+                       wp_die( sprintf( __("Can&#8217;t delete the <strong>%s</strong> category: this is the default one"), get_cat_name($cat_ID) ) );
 
                wp_delete_category($cat_ID);
        }
 
        wp_safe_redirect( wp_get_referer() );
-       exit();
+       exit;
 
 break;
 case 'edit':
@@ -161,10 +166,10 @@ $pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0;
 if ( empty($pagenum) )
        $pagenum = 1;
 
-$cats_per_page = get_user_option('categories_per_page');
-if ( empty($cats_per_page) )
+$cats_per_page = (int) get_user_option( 'categories_per_page', 0, false );
+if ( empty( $cats_per_page ) || $cats_per_page < 1 )
        $cats_per_page = 20;
-$cats_per_page = apply_filters('edit_categories_per_page', $cats_per_page);
+$cats_per_page = apply_filters( 'edit_categories_per_page', $cats_per_page );
 
 if ( !empty($_GET['s']) )
        $num_cats = count(get_categories(array('hide_empty' => 0, 'search' => $_GET['s'])));
@@ -280,7 +285,7 @@ if ( $page_links )
 <div class="form-field">
        <label for="category_description"><?php _e('Description') ?></label>
        <textarea name="category_description" id="category_description" rows="5" cols="40"></textarea>
-    <p><?php _e('The description is not prominent by default, however some themes may show it.'); ?></p>
+    <p><?php _e('The description is not prominent by default; however, some themes may show it.'); ?></p>
 </div>
 
 <p class="submit"><input type="submit" class="button" name="submit" value="<?php esc_attr_e('Add Category'); ?>" /></p>