67ebbbe5a3
git-svn-id: https://develop.svn.wordpress.org/trunk@2767 602fd350-edb4-49c9-b593-d223f7449a82
29 lines
745 B
PHP
29 lines
745 B
PHP
<?php
|
|
require_once('../wp-config.php');
|
|
require_once('admin-functions.php');
|
|
|
|
get_currentuserinfo();
|
|
|
|
if ( !current_user_can('manage_categories') )
|
|
die('-1');
|
|
|
|
function grab_id() {
|
|
global $new_cat_id;
|
|
$new_cat_id = func_get_arg(0);
|
|
}
|
|
|
|
add_action('edit_category', 'grab_id');
|
|
add_action('create_category', 'grab_id');
|
|
|
|
$cat_name = stripslashes($_GET['ajaxnewcat']);
|
|
|
|
if ( !$category_nicename = sanitize_title($cat_name) )
|
|
die('0');
|
|
if ( $already = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$category_nicename'") )
|
|
die($already);
|
|
|
|
$cat_name = $wpdb->escape($cat_name);
|
|
$cat_array = compact('cat_name', 'category_nicename');
|
|
wp_insert_category($cat_array);
|
|
echo $new_cat_id;
|
|
?>
|