Twenty Fourteen: avoid premature creation of tags when using the tag suggestion for Featured Content. Props obenland, fixes #26080.

git-svn-id: https://develop.svn.wordpress.org/trunk@26270 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Lance Willett 2013-11-19 15:26:56 +00:00
parent 659b2758ff
commit c6a57c410a
1 changed files with 10 additions and 5 deletions

View File

@ -448,13 +448,18 @@ class Featured_Content {
if ( empty( $input['tag-name'] ) ) {
$output['tag-id'] = 0;
} else {
$new_tag = wp_create_tag( $input['tag-name'] );
if ( ! is_wp_error( $new_tag ) && isset( $new_tag['term_id'] ) ) {
$output['tag-id'] = $new_tag['term_id'];
$term = get_term_by( 'name', $input['tag-name'], 'post_tag' );
if ( $term ) {
$output['tag-id'] = $term->term_id;
} else {
$term = get_term_by( 'name', $input['tag-name'], 'post_tag' );
$output['tag-id'] = $term ? $term->term_id : 0;
$new_tag = wp_create_tag( $input['tag-name'] );
if ( ! is_wp_error( $new_tag ) && isset( $new_tag['term_id'] ) ) {
$output['tag-id'] = $new_tag['term_id'];
}
}
$output['tag-name'] = $input['tag-name'];
}