| @@ 161-169 (lines=9) @@ | ||
| 158 | $term_info = wp_insert_term( $term, $taxonomy ); |
|
| 159 | } |
|
| 160 | ||
| 161 | if ( ! is_wp_error( $term_info ) ) { |
|
| 162 | if ( $is_hierarchical ) { |
|
| 163 | // Categories must be added by ID |
|
| 164 | $tax_input[$taxonomy][] = (int) $term_info['term_id']; |
|
| 165 | } else { |
|
| 166 | // Tags must be added by name |
|
| 167 | $tax_input[$taxonomy][] = $term; |
|
| 168 | } |
|
| 169 | } |
|
| 170 | } |
|
| 171 | } |
|
| 172 | ||
| @@ 200-208 (lines=9) @@ | ||
| 197 | $term = (int) $term; |
|
| 198 | $term_info = get_term_by( 'id', $term, $taxonomy, ARRAY_A ); |
|
| 199 | ||
| 200 | if ( $term_info && ! is_wp_error( $term_info ) ) { |
|
| 201 | if ( $is_hierarchical ) { |
|
| 202 | // Categories must be added by ID |
|
| 203 | $tax_input[$taxonomy][] = $term; |
|
| 204 | } else { |
|
| 205 | // Tags must be added by name |
|
| 206 | $tax_input[$taxonomy][] = $term_info['name']; |
|
| 207 | } |
|
| 208 | } |
|
| 209 | } |
|
| 210 | } |
|
| 211 | ||