2005-11-13 05:40:18 +01: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');
|
|
|
|
|
|
|
|
function get_out_now() { exit; }
|
|
|
|
|
|
|
|
add_action('shutdown', 'get_out_now', -1);
|
|
|
|
|
2005-11-17 11:23:35 +01:00
|
|
|
$names = explode(',', rawurldecode($_GET['ajaxnewcat']) );
|
|
|
|
$ids = array();
|
2005-11-13 05:40:18 +01:00
|
|
|
|
2005-11-17 11:23:35 +01:00
|
|
|
foreach ($names as $cat_name) {
|
|
|
|
$cat_name = trim( $cat_name );
|
2006-02-12 08:53:23 +01:00
|
|
|
|
2005-11-17 11:23:35 +01:00
|
|
|
if ( !$category_nicename = sanitize_title($cat_name) )
|
|
|
|
continue;
|
|
|
|
if ( $already = category_exists($cat_name) ) {
|
|
|
|
$ids[] = (string) $already;
|
|
|
|
continue;
|
|
|
|
}
|
2006-02-12 08:53:23 +01:00
|
|
|
|
2005-11-17 11:23:35 +01:00
|
|
|
$new_cat_id = wp_create_category($cat_name);
|
2006-02-12 08:53:23 +01:00
|
|
|
|
2005-11-17 11:23:35 +01:00
|
|
|
$ids[] = (string) $new_cat_id;
|
|
|
|
}
|
2005-11-13 05:40:18 +01:00
|
|
|
|
2005-11-17 11:23:35 +01:00
|
|
|
$return = join(',', $ids);
|
|
|
|
|
|
|
|
die( (string) $return );
|
|
|
|
|
|
|
|
?>
|