diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php
|
a
|
b
|
|
| 1234 | 1234 | */ |
| 1235 | 1235 | function term_exists( $term, $taxonomy = '', $parent = 0 ) { |
| 1236 | 1236 | global $wpdb; |
| 1237 | | |
| 1238 | | if ( is_int( $term ) ) { |
| 1239 | | $where = 't.term_id = %d'; |
| 1240 | | $else_where = 't.term_id = %d'; |
| | 1237 | |
| | 1238 | // Ensure parent is an integer for proper comparison. |
| | 1239 | $parent = (int) $parent; |
| | 1240 | |
| | 1241 | if ( is_int( $term ) ) { |
| | 1242 | $where = 't.term_id = %d'; |
| | 1243 | $else_where = 't.term_id = %d'; |
| 1241 | 1244 | } else { |
| 1242 | 1245 | $term = trim( wp_unslash( $term ) ); |
| 1243 | 1246 | $slug = sanitize_title( $term ); |
| 1244 | 1247 | $where = 't.slug = %s'; |
| 1245 | 1248 | $else_where = 't.name = %s'; |
| 1246 | 1249 | } |
| 1247 | 1250 | |
| 1248 | | $query = "SELECT t.term_id FROM $wpdb->terms AS t"; |
| | 1251 | $query = "SELECT t.term_id FROM $wpdb->terms AS t"; |
| | 1252 | |
| | 1253 | // Only join term_taxonomy if taxonomy or parent is being checked. |