Wordpress 2.0.4
[autoinstalls/wordpress.git] / wp-admin / edit-form-ajax-cat.php
1 <?php
2 require_once('../wp-config.php');
3 require_once('admin-functions.php');
4 require_once('admin-db.php');
5
6 if ( !current_user_can('manage_categories') )
7         die('-1');
8 if ( !check_ajax_referer() )
9         die('-1');
10
11 function get_out_now() { exit; }
12
13 add_action('shutdown', 'get_out_now', -1);
14
15 $names = explode(',', rawurldecode($_POST['ajaxnewcat']) );
16 $ids   = array();
17
18 foreach ($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 }
32
33 $return = join(',', $ids);
34
35 die( (string) $return );
36
37 ?>