800 | | if ( $result = $wpdb->get_row( $wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $slug, $taxonomy), ARRAY_A) ) |
801 | | return $result; |
| 800 | if ( $result = $wpdb->get_row( $wpdb->prepare("SELECT t.name, tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $slug, $taxonomy), ARRAY_A) ) { |
| 801 | // slug == name = A slug was passed in, return straight up |
| 802 | //If it was a Name that was passed however, Check that the name on the slug returned is the same as the name passed in. |
| 803 | if ( ($slug == $term) || 0 == strcmp($result['name'], $term) ) |
| 804 | return $result; |
| 805 | } |
1269 | | if ( ! $term_id = is_term($slug) ) { |
1270 | | if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) ) |
1271 | | return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error); |
1272 | | $term_id = (int) $wpdb->insert_id; |
1273 | | } else if ( is_taxonomy_hierarchical($taxonomy) && !empty($parent) ) { |
1274 | | // If the taxonomy supports hierarchy and the term has a parent, make the slug unique |
1275 | | // by incorporating parent slugs. |
1276 | | $slug = wp_unique_term_slug($slug, (object) $args); |
1277 | | if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) ) |
1278 | | return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error); |
1279 | | $term_id = (int) $wpdb->insert_id; |
1280 | | } |
| 1276 | $slug = wp_unique_term_slug($slug, (object) $args); |
| 1277 | if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) ) |
| 1278 | return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error); |
| 1279 | $term_id = (int) $wpdb->insert_id; |