| @@ 166-174 (lines=9) @@ | ||
| 163 | $term_info = wp_insert_term( $term, $taxonomy ); |
|
| 164 | } |
|
| 165 | ||
| 166 | if ( ! is_wp_error( $term_info ) ) { |
|
| 167 | if ( $is_hierarchical ) { |
|
| 168 | // Categories must be added by ID |
|
| 169 | $tax_input[$taxonomy][] = (int) $term_info['term_id']; |
|
| 170 | } else { |
|
| 171 | // Tags must be added by name |
|
| 172 | $tax_input[$taxonomy][] = $term; |
|
| 173 | } |
|
| 174 | } |
|
| 175 | } |
|
| 176 | } |
|
| 177 | ||
| @@ 206-214 (lines=9) @@ | ||
| 203 | $term = (int) $term; |
|
| 204 | $term_info = get_term_by( 'id', $term, $taxonomy, ARRAY_A ); |
|
| 205 | ||
| 206 | if ( $term_info && ! is_wp_error( $term_info ) ) { |
|
| 207 | if ( $is_hierarchical ) { |
|
| 208 | // Categories must be added by ID |
|
| 209 | $tax_input[$taxonomy][] = $term; |
|
| 210 | } else { |
|
| 211 | // Tags must be added by name |
|
| 212 | $tax_input[$taxonomy][] = $term_info['name']; |
|
| 213 | } |
|
| 214 | } |
|
| 215 | } |
|
| 216 | } |
|
| 217 | ||