From c6a57c410a764c7ae6d6edd253db6eb15e4ba5a4 Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Tue, 19 Nov 2013 15:26:56 +0000 Subject: [PATCH] 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 --- .../twentyfourteen/inc/featured-content.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/wp-content/themes/twentyfourteen/inc/featured-content.php b/src/wp-content/themes/twentyfourteen/inc/featured-content.php index a85b66ff17..7ac0249602 100644 --- a/src/wp-content/themes/twentyfourteen/inc/featured-content.php +++ b/src/wp-content/themes/twentyfourteen/inc/featured-content.php @@ -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']; }