Don't create '0' categories. fixes #4413

git-svn-id: http://svn.automattic.com/wordpress/trunk@5739 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2007-06-20 22:06:29 +00:00
parent 9d84bef608
commit 21e8f43f8c
2 changed files with 7 additions and 0 deletions

View File

@ -796,6 +796,8 @@ function wp_set_post_categories($post_ID = 0, $post_categories = array()) {
// If $post_categories isn't already an array, make it one:
if (!is_array($post_categories) || 0 == count($post_categories) || empty($post_categories))
$post_categories = array(get_option('default_category'));
else if ( 1 == count($post_categories) && '' == $post_categories[0] )
return true;
$post_categories = array_map('intval', $post_categories);
$post_categories = array_unique($post_categories);

View File

@ -381,6 +381,8 @@ function is_term($term, $taxonomy = '') {
global $wpdb;
if ( is_int($term) ) {
if ( 0 == $term )
return 0;
$where = "t.term_id = '$term'";
} else {
if ( ! $term = sanitize_title($term) )
@ -600,6 +602,9 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) {
if ( ! is_taxonomy($taxonomy) )
return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
if ( is_int($term) && 0 == $term )
return new WP_Error('invalid_term_id', __('Invalid term ID'));
$defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
$args = wp_parse_args($args, $defaults);
$args['name'] = $term;