+
+ function process_terms() {
+ global $wpdb, $wp_taxonomies;
+
+ $custom_taxonomies = $wp_taxonomies;
+ // get rid of the standard taxonomies
+ unset( $custom_taxonomies['category'] );
+ unset( $custom_taxonomies['post_tag'] );
+ unset( $custom_taxonomies['link_category'] );
+
+ $custom_taxonomies = array_keys( $custom_taxonomies );
+ $current_terms = (array) get_terms( $custom_taxonomies, 'get=all' );
+ $taxonomies = array();
+ foreach ( $current_terms as $term ) {
+ if ( isset( $_terms[$term->taxonomy] ) ) {
+ $taxonomies[$term->taxonomy] = array_merge( $taxonomies[$term->taxonomy], array($term->name) );
+ } else {
+ $taxonomies[$term->taxonomy] = array($term->name);
+ }
+ }
+
+ while ( $c = array_shift($this->terms) ) {
+ $term_name = trim($this->get_tag( $c, 'wp:term_name' ));
+ $term_taxonomy = trim($this->get_tag( $c, 'wp:term_taxonomy' ));
+
+ // If the term exists in the taxonomy we leave it alone
+ if ( isset($taxonomies[$term_taxonomy] ) && in_array( $term_name, $taxonomies[$term_taxonomy] ) )
+ continue;
+
+ $slug = $this->get_tag( $c, 'wp:term_slug' );
+ $description = $this->get_tag( $c, 'wp:term_description' );
+
+ $termarr = compact('slug', 'description');
+
+ $term_ID = wp_insert_term($term_name, $this->get_tag( $c, 'wp:term_taxonomy' ), $termarr);
+ }
+ }