Twenty Fourteen: avoid premature creation of tags when using the tag suggestion for Featured Content. Props obenland, fixes #26080.
Built from https://develop.svn.wordpress.org/trunk@26270 git-svn-id: http://core.svn.wordpress.org/trunk@26175 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
3a0a3bb775
commit
8321cdd567
|
@ -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'];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue