2 require_once('../wp-config.php');
3 require_once('admin-functions.php');
4 require_once('admin-db.php');
6 if ( !current_user_can('manage_categories') )
8 if ( !check_ajax_referer() )
11 function get_out_now() { exit; }
13 add_action('shutdown', 'get_out_now', -1);
15 $names = explode(',', rawurldecode($_POST['ajaxnewcat']) );
18 foreach ($names as $cat_name) {
19 $cat_name = trim( $cat_name );
21 if ( !$category_nicename = sanitize_title($cat_name) )
23 if ( $already = category_exists($cat_name) ) {
24 $ids[] = (string) $already;
28 $new_cat_id = wp_create_category($cat_name);
30 $ids[] = (string) $new_cat_id;
33 $return = join(',', $ids);
35 die( (string) $return );