Don't create '0' categories. fixes #4413
git-svn-id: https://develop.svn.wordpress.org/trunk@5739 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
d907ae8841
commit
fdb786ba7f
|
@ -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 $post_categories isn't already an array, make it one:
|
||||||
if (!is_array($post_categories) || 0 == count($post_categories) || empty($post_categories))
|
if (!is_array($post_categories) || 0 == count($post_categories) || empty($post_categories))
|
||||||
$post_categories = array(get_option('default_category'));
|
$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_map('intval', $post_categories);
|
||||||
$post_categories = array_unique($post_categories);
|
$post_categories = array_unique($post_categories);
|
||||||
|
|
|
@ -381,6 +381,8 @@ function is_term($term, $taxonomy = '') {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
|
||||||
if ( is_int($term) ) {
|
if ( is_int($term) ) {
|
||||||
|
if ( 0 == $term )
|
||||||
|
return 0;
|
||||||
$where = "t.term_id = '$term'";
|
$where = "t.term_id = '$term'";
|
||||||
} else {
|
} else {
|
||||||
if ( ! $term = sanitize_title($term) )
|
if ( ! $term = sanitize_title($term) )
|
||||||
|
@ -600,6 +602,9 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) {
|
||||||
if ( ! is_taxonomy($taxonomy) )
|
if ( ! is_taxonomy($taxonomy) )
|
||||||
return new WP_Error('invalid_taxonomy', __('Invalid 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' => '');
|
$defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
|
||||||
$args = wp_parse_args($args, $defaults);
|
$args = wp_parse_args($args, $defaults);
|
||||||
$args['name'] = $term;
|
$args['name'] = $term;
|
||||||
|
|
Loading…
Reference in New Issue