mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-05 10:22:23 +01:00
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;
|
||
|
?>
|