WordPress.org

Make WordPress Core

Ticket #17689: 17689-noformatting.diff

File 17689-noformatting.diff, 1.5 KB (added by wonderboymusic, 6 years ago)
  • src/wp-includes/taxonomy.php

    Cannot display: file marked as a binary type.
    svn:mime-type = application/octet-stream
     
    20912091        $name = wp_unslash($name);
    20922092        $description = wp_unslash($description);
    20932093
    2094         if ( empty($slug) )
    2095                 $slug = sanitize_title($name);
     2094        if ( empty( $slug ) ) {
     2095                $name = trim( $name );
     2096                $sanitized_name = sanitize_title( $name );
     2097                $exists = $wpdb->get_row( $wpdb->prepare( "SELECT term_id, slug FROM $wpdb->terms WHERE name = %s ORDER BY term_id ASC LIMIT 1", $name ) );
     2098                if ( ! empty( $exists ) && term_exists( $exists->term_id, $taxonomy ) ) {
     2099                        if ( $sanitized_name === $exists->slug )
     2100                                return new WP_Error( 'term_exists', __( 'A term with the name provided already exists.' ) );
    20962101
     2102                        $slug = $exists->slug;
     2103                } elseif ( ! empty( $exists ) ) {
     2104                        $exists = $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM $wpdb->terms WHERE slug = %s ORDER BY term_id ASC LIMIT 1", $sanitized_name ) );
     2105                        if ( ! empty( $exists ) )
     2106                                return new WP_Error( 'term_exists', __( 'A term with the name provided already exists.' ) );
     2107                } else {
     2108                        $slug = $sanitized_name;
     2109                }
     2110        }
     2111
    20972112        $term_group = 0;
    20982113        if ( $alias_of ) {
    20992114                $alias = $wpdb->get_row( $wpdb->prepare( "SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $alias_of) );