Thanks luna, After looking into it, wp_sitecategories does only seem to serve the purpose of goofing stuff up for no reason, i really have no idea why it is being used in that function.
For me the solution was as follows:
non-working original function referencing wp_sitecategories:(giving me 3 db errors)
function global_terms( $term_id, $tt_id ) {
global $wpdb;
$term_id = intval( $term_id );
$c = $wpdb->get_row( "SELECT * FROM $wpdb->terms WHERE term_id = '$term_id'" );
$global_id = $wpdb->get_var( "SELECT cat_ID FROM $wpdb->sitecategories WHERE category_nicename = '" . $wpdb->escape( $c->slug ) . "'" );
if ( $global_id == null ) {
$wpdb->query( "INSERT INTO $wpdb->sitecategories ( cat_name, category_nicename ) VALUES ( '" . $wpdb->escape( $c->name ) . "', '" . $wpdb->escape( $c->slug ) . "' )" );
$global_id = $wpdb->insert_id;
}
if ( $global_id == $term_id )
return $global_id;
$wpdb->query( "UPDATE $wpdb->terms SET term_id = '$global_id' WHERE term_id = '$term_id'" );
$wpdb->query( "UPDATE $wpdb->term_taxonomy SET term_id = '$global_id' WHERE term_id = '$term_id'" );
$wpdb->query( "UPDATE $wpdb->term_taxonomy SET parent = '$global_id' WHERE parent = '$term_id'" );
$wpdb->query( "UPDATE $wpdb->categories SET cat_ID = '$global_id' WHERE cat_ID = '$term_id'" );
$wpdb->query( "UPDATE $wpdb->categories SET category_parent = '$global_id' WHERE category_parent = '$term_id'" );
clean_term_cache($global_id, 'category');
clean_term_cache($global_id, 'post_tag');
return $global_id;
}
working function i am currently using:(no errors)
function global_terms( $term_id ) {
global $wpdb;
$term_id = intval( $term_id );
$wpdb->query( "UPDATE $wpdb->terms SET term_id = '$term_id' WHERE term_id = '$term_id'" );
$wpdb->query( "UPDATE $wpdb->term_taxonomy SET term_id = '$term_id' WHERE term_id = '$term_id'" );
$wpdb->query( "UPDATE $wpdb->term_taxonomy SET parent = '$term_id' WHERE parent = '$term_id'" );
clean_term_cache($term_id, 'category');
clean_term_cache($term_id, 'post_tag');
return $term_id;
}
I also removed the $tt_id from the arguments because the function doesn't do anything with it :p