Files
wordpress-develop/wp-admin/edit-form-ajax-cat.php
Ryan Boren cfe42dc930 Add category_exists() and wp_create_category().
git-svn-id: https://develop.svn.wordpress.org/trunk@2864 602fd350-edb4-49c9-b593-d223f7449a82
2005-09-10 18:44:05 +00:00

25 lines
561 B
PHP

<?php
require_once('../wp-config.php');
require_once('admin-functions.php');
get_currentuserinfo();
if ( !current_user_can('manage_categories') )
die('-1');
function get_out_now() { exit; }
add_action('shutdown', 'get_out_now', -1);
$cat_name = rawurldecode($_GET['ajaxnewcat']);
if ( !$category_nicename = sanitize_title($cat_name) )
die('0');
if ( $already = category_exists($cat_name) )
die((string) $already);
$cat_name = $wpdb->escape($cat_name);
$new_cat_id = wp_create_category($cat_name);
die((string) $new_cat_id);
?>