root/tags/1_0-rc2/wp-admin/edit-form-ajax-cat.php

Revision 524, 0.7 kB (checked in by donncha, 3 years ago)

WP Merge - requires upgrading of db through wp-admin/upgrade.php!

Line 
1 <?php
2 require_once('../wp-config.php');
3 require_once('admin-functions.php');
4 require_once('admin-db.php');
5
6 get_currentuserinfo();
7
8 if ( !current_user_can('manage_categories') )
9     die('-1');
10
11 function get_out_now() { exit; }
12
13 add_action('shutdown', 'get_out_now', -1);
14
15 $names = explode(',', rawurldecode($_GET['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 ?>
38
Note: See TracBrowser for help on using the browser.