Make WordPress Core

Ticket #38243: 38243.diff

File 38243.diff, 1.2 KB (added by dd32, 8 years ago)
  • src/wp-includes/taxonomy.php

    function wp_insert_term( $term, $taxonom 
    21002100        }
    21012101
    21022102        $args['name'] = $term;
    21032103        $args['taxonomy'] = $taxonomy;
    21042104
    21052105        // Coerce null description to strings, to avoid database errors.
    21062106        $args['description'] = (string) $args['description'];
    21072107
    21082108        $args = sanitize_term($args, $taxonomy, 'db');
    21092109
    21102110        // expected_slashed ($name)
    21112111        $name = wp_unslash( $args['name'] );
    21122112        $description = wp_unslash( $args['description'] );
    21132113        $parent = (int) $args['parent'];
    21142114
     2115        if ( '' == trim( $name ) ) {
     2116                return new WP_Error( 'empty_term_name', __( 'A name is required for this term.' ) );
     2117        }
     2118
    21152119        $slug_provided = ! empty( $args['slug'] );
    21162120        if ( ! $slug_provided ) {
    21172121                $slug = sanitize_title( $name );
    21182122        } else {
    21192123                $slug = $args['slug'];
    21202124        }
    21212125
    21222126        $term_group = 0;
    21232127        if ( $args['alias_of'] ) {
    21242128                $alias = get_term_by( 'slug', $args['alias_of'], $taxonomy );
    21252129                if ( ! empty( $alias->term_group ) ) {
    21262130                        // The alias we want is already in a group, so let's use that one.
    21272131                        $term_group = $alias->term_group;
    21282132                } elseif ( ! empty( $alias->term_id ) ) {
    21292133                        /*