mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-15 14:20:24 +00:00
In wp_insert_term(), when no slug is provided, check for an existing term by name. If it exists, use that slug instead of calling sanitize_title( $name ).
Prevents creating an endless number of terms like `A+` or `$$$$` in any given taxonomy. Props wonderboymusic, SergeyBiryukov, aaroncampbell. Fixes #17689. git-svn-id: https://develop.svn.wordpress.org/trunk@28733 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -2436,7 +2436,13 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) {
|
||||
|
||||
$slug_provided = ! empty( $args['slug'] );
|
||||
if ( ! $slug_provided ) {
|
||||
$slug = sanitize_title($name);
|
||||
$_name = trim( $name );
|
||||
$existing_term = get_term_by( 'name', $_name, $taxonomy );
|
||||
if ( $existing_term ) {
|
||||
$slug = $existing_term->slug;
|
||||
} else {
|
||||
$slug = sanitize_title( $name );
|
||||
}
|
||||
} else {
|
||||
$slug = $args['slug'];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user