[wp-trac] [WordPress Trac] #3799: improvements for submitting new categories via wp-admin/categories.php

WordPress Trac wp-trac at lists.automattic.com
Fri Feb 16 17:57:01 GMT 2007


#3799: improvements for submitting new categories via wp-admin/categories.php
----------------------------+-----------------------------------------------
 Reporter:  prokurator      |       Owner:  anonymous
     Type:  enhancement     |      Status:  new      
 Priority:  normal          |   Milestone:  2.3      
Component:  Administration  |     Version:           
 Severity:  normal          |    Keywords:  category 
----------------------------+-----------------------------------------------
 There are 2 things I would like to improve wile submitting new category
 into WP.
 1. If user by accident chose category name which is already exists in the
 system
 2. If user by accident hit submit without entering any category name
 (category name is empty).

 In order to fix this problems 3 files need to be updated.

 1. wp-admin/admin-ajax.php
 add after line 132 (case 'add-cat')
 following code:
 ##################
     $cat = wp_insert_category($_POST);
     if ( !$cat ) #= wp_insert_category( $_POST ) )
         die('4');
     $rr = $cat;
     if (is_string($rr) && preg_match('/same/',$rr))
         die('5');

 #   if ( !$cat = wp_insert_category( $_POST ) )
 #       die('0');
 ##################

 2. wp-admin/admin-db.php
 add in the function wp_insert_category($catarr)
 after line 85
 following code:
 #############
     $ccat = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->categories WHERE
 cat_name = '$cat_name'");
     if ($ccat)
         return 'same';
 #############

 3. /wp-includes/js/wp-ajax-js.php
 add after line 61 (in ParseAjaxResponse)
 following code or make adjustment to existing error definition:
 else if ( 4 == r ) {
             Element.update(this.myResponseElement,"<div
 class='error'><p><?php _e("Something strange happened.  Category field is
 empty."); ?></p></div>");
             return false;
         } else if ( 5 == r ) {
             Element.update(this.myResponseElement,"<div
 class='error'><p><?php _e("Something strange happened.  The same category
 name already exists."); ?></p></div>");
             return false;
         }

-- 
Ticket URL: <http://trac.wordpress.org/ticket/3799>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list