Make WordPress Core

Ticket #25549: 25549.bug1.patch

File 25549.bug1.patch, 1.5 KB (added by rachelbaker, 11 years ago)
  • src/wp-content/themes/twentyfourteen/inc/featured-content.php

     
    429429        public static function validate_settings( $input ) {
    430430                $output = array();
    431431
    432                 if ( isset( $input['tag-id'] ) )
    433                         $output['tag-id'] = absint( $input['tag-id'] );
     432                if ( empty( $input['tag-name'] ) ) {
     433                        $output['tag-id'] = 0;
     434                } else {
     435                        $new_tag = wp_create_tag( sanitize_text_field( $input['tag-name'] ) );
    434436
    435                 if ( isset( $input['tag-name'] ) ) {
    436                         if ( empty( $input['tag-name'] ) ) {
    437                                 $output['tag-id'] = 0;
    438                         } else {
    439                                 $new_tag = wp_create_tag( $input['tag-name'] );
    440                                 if ( ! is_wp_error( $new_tag ) && isset( $new_tag['term_id'] ) )
    441                                         $tag = get_term( $new_tag['term_id'], 'post_tag' );
     437                        if ( is_int( $new_tag ) ) {
     438                                $output['tag-id'] = absint( $new_tag );
     439                        } elseif ( ! is_wp_error( $new_tag ) && isset( $new_tag['term_id'] ) ) {
     440                                $tag = get_term( $new_tag['term_id'], 'post_tag' );
    442441                                if ( isset( $tag->term_id ) )
    443442                                        $output['tag-id'] = $tag->term_id;
    444                                 if ( is_int( $new_tag ) )
    445                                         $output['tag-id'] = $new_tag;
    446                                 $output['tag-name'] = get_term( $output['tag-id'], 'post_tag' )->name;
    447443                        }
     444
     445                        $output['tag-name'] = get_term( $output['tag-id'], 'post_tag' )->name;
    448446                }
    449447
    450448                if ( isset( $input['quantity'] ) )