2005-11-12 23:40:18 -05:00
|
|
|
<?php
|
|
|
|
require_once('../wp-config.php');
|
|
|
|
require_once('admin-functions.php');
|
|
|
|
require_once('admin-db.php');
|
|
|
|
|
|
|
|
if ( !current_user_can('manage_categories') )
|
|
|
|
die('-1');
|
2006-04-21 17:18:32 -04:00
|
|
|
if ( !check_ajax_referer() )
|
|
|
|
die('-1');
|
2005-11-12 23:40:18 -05:00
|
|
|
|
|
|
|
function get_out_now() { exit; }
|
|
|
|
|
|
|
|
add_action('shutdown', 'get_out_now', -1);
|
|
|
|
|
2006-04-21 17:18:32 -04:00
|
|
|
$names = explode(',', rawurldecode($_POST['ajaxnewcat']) );
|
2005-11-17 05:23:35 -05:00
|
|
|
$ids = array();
|
2005-11-12 23:40:18 -05:00
|
|
|
|
2005-11-17 05:23:35 -05:00
|
|
|
foreach ($names as $cat_name) {
|
|
|
|
$cat_name = trim( $cat_name );
|
|
|
|
|
|
|
|
if ( !$category_nicename = sanitize_title($cat_name) )
|
|
|
|
continue;
|
|
|
|
if ( $already = category_exists($cat_name) ) {
|
|
|
|
$ids[] = (string) $already;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$new_cat_id = wp_create_category($cat_name);
|
|
|
|
|
|
|
|
$ids[] = (string) $new_cat_id;
|
|
|
|
}
|
2005-11-12 23:40:18 -05:00
|
|
|
|
2005-11-17 05:23:35 -05:00
|
|
|
$return = join(',', $ids);
|
|
|
|
|
|
|
|
die( (string) $return );
|
|
|
|
|
2006-04-21 17:18:32 -04:00
|
|
|
?>
|