Changeset 31734 for trunk/src/wp-includes/taxonomy.php
- Timestamp:
- 03/11/2015 10:54:49 PM (11 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/taxonomy.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/taxonomy.php
r31652 r31734 2880 2880 $slug_provided = ! empty( $args['slug'] ); 2881 2881 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 ); 2889 2883 } else { 2890 2884 $slug = $args['slug']; … … 2911 2905 2912 2906 // 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 ); 2926 2912 } 2913 } else { 2914 return new WP_Error( 'term_exists', __( 'A term with the name already exists in this taxonomy.' ), $existing_term->term_id ); 2927 2915 } 2928 2916 }
Note: See TracChangeset
for help on using the changeset viewer.