Make WordPress Core


Ignore:
Timestamp:
03/11/2015 10:54:49 PM (12 years ago)
Author:
pento
Message:

Add emoji URL support, and Twemoji fallback for displaying slugs in wp-admin, when the browser doesn't natively support emoji.

Props pento, SergeyBiryukov and boonebgorges.

Fixes #31328

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/taxonomy.php

    r31652 r31734  
    28802880        $slug_provided = ! empty( $args['slug'] );
    28812881        if ( ! $slug_provided ) {
    2882                 $_name = trim( $name );
    2883                 $existing_term = get_term_by( 'name', $_name, $taxonomy );
    2884                 if ( $existing_term ) {
    2885                         $slug = $existing_term->slug;
    2886                 } else {
    2887                         $slug = sanitize_title( $name );
    2888                 }
     2882                $slug = sanitize_title( $name );
    28892883        } else {
    28902884                $slug = $args['slug'];
     
    29112905
    29122906        // Terms with duplicate names are not allowed at the same level of a taxonomy hierarchy.
    2913         if ( $exists = term_exists( $slug, $taxonomy ) ) {
    2914                 $existing_term = get_term( $exists['term_id'], $taxonomy );
    2915 
    2916                 if ( $name === $existing_term->name ) {
    2917 
    2918                         if ( is_taxonomy_hierarchical( $taxonomy ) ) {
    2919                                 $siblings = get_terms( $taxonomy, array( 'fields' => 'names', 'get' => 'all', 'parent' => $parent ) );
    2920                                 if ( in_array( $name, $siblings ) ) {
    2921                                         return new WP_Error( 'term_exists', __( 'A term with the name and slug already exists with this parent.' ), $exists['term_id'] );
    2922                                 }
    2923 
    2924                         } else {
    2925                                 return new WP_Error( 'term_exists', __( 'A term with the name and slug already exists in this taxonomy.' ), $exists['term_id'] );
     2907        if ( $existing_term = get_term_by( 'name', $name, $taxonomy ) ) {
     2908                if ( is_taxonomy_hierarchical( $taxonomy ) ) {
     2909                        $siblings = get_terms( $taxonomy, array( 'fields' => 'names', 'get' => 'all', 'parent' => $parent ) );
     2910                        if ( in_array( $name, $siblings ) ) {
     2911                                return new WP_Error( 'term_exists', __( 'A term with the name already exists with this parent.' ), $existing_term->term_id );
    29262912                        }
     2913                } else {
     2914                        return new WP_Error( 'term_exists', __( 'A term with the name already exists in this taxonomy.' ), $existing_term->term_id );
    29272915                }
    29282916        }
Note: See TracChangeset for help on using the changeset viewer.