Make WordPress Core

Changeset 26270


Ignore:
Timestamp:
11/19/2013 03:26:56 PM (11 years ago)
Author:
lancewillett
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentyfourteen/inc/featured-content.php

    r26260 r26270  
    449449            $output['tag-id'] = 0;
    450450        } else {
    451             $new_tag = wp_create_tag( $input['tag-name'] );
    452             if ( ! is_wp_error( $new_tag ) && isset( $new_tag['term_id'] ) ) {
    453                 $output['tag-id'] = $new_tag['term_id'];
     451            $term = get_term_by( 'name', $input['tag-name'], 'post_tag' );
     452
     453            if ( $term ) {
     454                $output['tag-id'] = $term->term_id;
    454455            } else {
    455                 $term = get_term_by( 'name', $input['tag-name'], 'post_tag' );
    456                 $output['tag-id'] = $term ? $term->term_id : 0;
     456                $new_tag = wp_create_tag( $input['tag-name'] );
     457
     458                if ( ! is_wp_error( $new_tag ) && isset( $new_tag['term_id'] ) ) {
     459                    $output['tag-id'] = $new_tag['term_id'];
     460                }
    457461            }
     462
    458463            $output['tag-name'] = $input['tag-name'];
    459464        }
Note: See TracChangeset for help on using the changeset viewer.