Make WordPress Core


Ignore:
Timestamp:
11/17/2005 10:23:35 AM (19 years ago)
Author:
matt
Message:

Slicker category adding, fixes #1882

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-form-ajax-cat.php

    r3061 r3135  
    1313add_action('shutdown', 'get_out_now', -1);
    1414
    15 $cat_name = rawurldecode($_GET['ajaxnewcat']);
     15$names = explode(',', rawurldecode($_GET['ajaxnewcat']) );
     16$ids   = array();
    1617
    17 if ( !$category_nicename = sanitize_title($cat_name) )
    18     die('0');
    19 if ( $already = category_exists($cat_name) )
    20     die((string) $already);
     18foreach ($names as $cat_name) {
     19    $cat_name = trim( $cat_name );
     20   
     21    if ( !$category_nicename = sanitize_title($cat_name) )
     22        continue;
     23    if ( $already = category_exists($cat_name) ) {
     24        $ids[] = (string) $already;
     25        continue;
     26    }
     27   
     28    $new_cat_id = wp_create_category($cat_name);
     29   
     30    $ids[] = (string) $new_cat_id;
     31}
    2132
    22 $new_cat_id = wp_create_category($cat_name);
    23 die((string) $new_cat_id);
     33$return = join(',', $ids);
     34
     35die( (string) $return );
     36
    2437?>
Note: See TracChangeset for help on using the changeset viewer.