2005-08-09 10:16:29 +02:00
|
|
|
<?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);
|
|
|
|
}
|
|
|
|
|
2005-08-30 02:57:34 +02:00
|
|
|
function get_out_now() { exit; }
|
|
|
|
|
|
|
|
|
2005-08-09 10:16:29 +02:00
|
|
|
add_action('edit_category', 'grab_id');
|
|
|
|
add_action('create_category', 'grab_id');
|
2005-08-30 02:57:34 +02:00
|
|
|
add_action('shutdown', 'get_out_now', -1);
|
2005-08-09 10:16:29 +02:00
|
|
|
|
2005-08-30 02:57:34 +02:00
|
|
|
$cat_name = rawurldecode($_GET['ajaxnewcat']);
|
2005-08-09 10:16:29 +02:00
|
|
|
|
|
|
|
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'") )
|
2005-09-02 19:17:36 +02:00
|
|
|
die((string) $already);
|
2005-08-09 10:16:29 +02:00
|
|
|
|
|
|
|
$cat_name = $wpdb->escape($cat_name);
|
|
|
|
$cat_array = compact('cat_name', 'category_nicename');
|
|
|
|
wp_insert_category($cat_array);
|
2005-09-02 19:17:36 +02:00
|
|
|
die((string) $new_cat_id);
|
|
|
|
?>
|