Index: wp-includes/taxonomy.php
===================================================================
--- wp-includes/taxonomy.php	(revision 16050)
+++ wp-includes/taxonomy.php	(working copy)
@@ -1056,7 +1059,7 @@
 		$where .= ' AND tt.count > 0';
 
 	// don't limit the query results when we have to descend the family tree
-	if ( ! empty($number) && ! $hierarchical && empty( $child_of ) && '' === $parent ) {
+	if ( ! empty( $number ) && ! $hierarchical && empty( $child_of ) && '' === $parent ) {
 		if ( $offset )
 			$limit = 'LIMIT ' . $offset . ',' . $number;
 		else
@@ -1136,26 +1139,26 @@
 
 	$_terms = array();
 	if ( 'id=>parent' == $fields ) {
-		while ( $term = array_shift($terms) )
+		while ( $term = array_shift( $terms ) )
 			$_terms[$term->term_id] = $term->parent;
 		$terms = $_terms;
 	} elseif ( 'ids' == $fields ) {
-		while ( $term = array_shift($terms) )
+		while ( $term = array_shift( $terms ) )
 			$_terms[] = $term->term_id;
 		$terms = $_terms;
 	} elseif ( 'names' == $fields ) {
-		while ( $term = array_shift($terms) )
+		while ( $term = array_shift( $terms ) )
 			$_terms[] = $term->name;
 		$terms = $_terms;
 	}
 
-	if ( 0 < $number && intval(@count($terms)) > $number ) {
-		$terms = array_slice($terms, $offset, $number);
+	if ( 0 < $number && intval( @count( $terms ) ) > $number ) {
+		$terms = array_slice( $terms, $offset, $number );
 	}
 
 	wp_cache_add( $cache_key, $terms, 'terms', 86400 ); // one day
 
-	$terms = apply_filters('get_terms', $terms, $taxonomies, $args);
+	$terms = apply_filters( 'get_terms', $terms, $taxonomies, $args );
 	return $terms;
 }
 
@@ -1177,17 +1180,17 @@
  * @param int $parent ID of parent term under which to confine the exists search.
  * @return mixed Get the term id or Term Object, if exists.
  */
-function term_exists($term, $taxonomy = '', $parent = 0) {
+function term_exists( $term, $taxonomy = '', $parent = 0 ) {
 	global $wpdb;
 
 	$select = "SELECT term_id FROM $wpdb->terms as t WHERE ";
 	$tax_select = "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 ";
 
-	if ( is_int($term) ) {
+	if ( is_int( $term ) ) {
 		if ( 0 == $term )
 			return 0;
 		$where = 't.term_id = %d';
-		if ( !empty($taxonomy) )
+		if ( !empty( $taxonomy ) )
 			return $wpdb->get_row( $wpdb->prepare( $tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy ), ARRAY_A );
 		else
 			return $wpdb->get_var( $wpdb->prepare( $select . $where, $term ) );
@@ -1195,14 +1198,14 @@
 
 	$term = trim( stripslashes( $term ) );
 
-	if ( '' === $slug = sanitize_title($term) )
+	if ( '' === $slug = sanitize_title( $term ) )
 		return 0;
 
 	$where = 't.slug = %s';
 	$else_where = 't.name = %s';
-	$where_fields = array($slug);
-	$else_where_fields = array($term);
-	if ( !empty($taxonomy) ) {
+	$where_fields = array( $slug );
+	$else_where_fields = array( $term );
+	if ( !empty( $taxonomy ) ) {
 		$parent = (int) $parent;
 		if ( $parent > 0 ) {
 			$where_fields[] = $parent;
@@ -1214,16 +1217,16 @@
 		$where_fields[] = $taxonomy;
 		$else_where_fields[] = $taxonomy;
 
-		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", $where_fields), ARRAY_A) )
+		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", $where_fields ), ARRAY_A ) )
 			return $result;
 
-		return $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 $else_where AND tt.taxonomy = %s", $else_where_fields), ARRAY_A);
+		return $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 $else_where AND tt.taxonomy = %s", $else_where_fields ), ARRAY_A );
 	}
 
-	if ( $result = $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields) ) )
+	if ( $result = $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields ) ) )
 		return $result;
 
-	return $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $else_where", $else_where_fields) );
+	return $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM $wpdb->terms as t WHERE $else_where", $else_where_fields ) );
 }
 
 /**
@@ -1246,26 +1249,26 @@
  * @param string $context Default is 'display'.
  * @return array|object Term with all fields sanitized
  */
-function sanitize_term($term, $taxonomy, $context = 'display') {
+function sanitize_term( $term, $taxonomy, $context = 'display' ) {
 
 	if ( 'raw' == $context )
 		return $term;
 
-	$fields = array('term_id', 'name', 'description', 'slug', 'count', 'parent', 'term_group');
+	$fields = array( 'term_id', 'name', 'description', 'slug', 'count', 'parent', 'term_group' );
 
 	$do_object = false;
-	if ( is_object($term) )
+	if ( is_object( $term ) )
 		$do_object = true;
 
-	$term_id = $do_object ? $term->term_id : (isset($term['term_id']) ? $term['term_id'] : 0);
+	$term_id = $do_object ? $term->term_id : ( isset( $term['term_id'] ) ? $term['term_id'] : 0 );
 
 	foreach ( (array) $fields as $field ) {
 		if ( $do_object ) {
-			if ( isset($term->$field) )
-				$term->$field = sanitize_term_field($field, $term->$field, $term_id, $taxonomy, $context);
+			if ( isset( $term->$field ) )
+				$term->$field = sanitize_term_field( $field, $term->$field, $term_id, $taxonomy, $context );
 		} else {
-			if ( isset($term[$field]) )
-				$term[$field] = sanitize_term_field($field, $term[$field], $term_id, $taxonomy, $context);
+			if ( isset( $term[$field] ) )
+				$term[$field] = sanitize_term_field( $field, $term[$field], $term_id, $taxonomy, $context );
 		}
 	}
 
@@ -1303,7 +1306,7 @@
  * @param string $context Either edit, db, display, attribute, or js.
  * @return mixed sanitized field
  */
-function sanitize_term_field($field, $value, $term_id, $taxonomy, $context) {
+function sanitize_term_field( $field, $value, $term_id, $taxonomy, $context ) {
 	if ( 'parent' == $field  || 'term_id' == $field || 'count' == $field || 'term_group' == $field ) {
 		$value = (int) $value;
 		if ( $value < 0 )
@@ -1314,32 +1317,32 @@
 		return $value;
 
 	if ( 'edit' == $context ) {
-		$value = apply_filters("edit_term_$field", $value, $term_id, $taxonomy);
-		$value = apply_filters("edit_${taxonomy}_$field", $value, $term_id);
+		$value = apply_filters( "edit_term_$field", $value, $term_id, $taxonomy );
+		$value = apply_filters( "edit_${taxonomy}_$field", $value, $term_id );
 		if ( 'description' == $field )
-			$value = format_to_edit($value);
+			$value = format_to_edit( $value );
 		else
-			$value = esc_attr($value);
+			$value = esc_attr( $value );
 	} else if ( 'db' == $context ) {
-		$value = apply_filters("pre_term_$field", $value, $taxonomy);
-		$value = apply_filters("pre_${taxonomy}_$field", $value);
+		$value = apply_filters( "pre_term_$field", $value, $taxonomy );
+		$value = apply_filters( "pre_${taxonomy}_$field", $value );
 		// Back compat filters
 		if ( 'slug' == $field )
-			$value = apply_filters('pre_category_nicename', $value);
+			$value = apply_filters( 'pre_category_nicename', $value );
 
 	} else if ( 'rss' == $context ) {
-		$value = apply_filters("term_${field}_rss", $value, $taxonomy);
-		$value = apply_filters("${taxonomy}_${field}_rss", $value);
+		$value = apply_filters( "term_${field}_rss", $value, $taxonomy );
+		$value = apply_filters( "${taxonomy}_${field}_rss", $value );
 	} else {
 		// Use display filters by default.
-		$value = apply_filters("term_$field", $value, $term_id, $taxonomy, $context);
-		$value = apply_filters("${taxonomy}_$field", $value, $term_id, $context);
+		$value = apply_filters( "term_$field", $value, $term_id, $taxonomy, $context );
+		$value = apply_filters( "${taxonomy}_$field", $value, $term_id, $context );
 	}
 
 	if ( 'attribute' == $context )
-		$value = esc_attr($value);
+		$value = esc_attr( $value );
 	else if ( 'js' == $context )
-		$value = esc_js($value);
+		$value = esc_js( $value );
 
 	return $value;
 }
@@ -1361,18 +1364,18 @@
  * @return int How many terms are in $taxonomy
  */
 function wp_count_terms( $taxonomy, $args = array() ) {
-	$defaults = array('hide_empty' => false);
-	$args = wp_parse_args($args, $defaults);
+	$defaults = array( 'hide_empty' => false );
+	$args = wp_parse_args( $args, $defaults );
 
 	// backwards compatibility
-	if ( isset($args['ignore_empty']) ) {
+	if ( isset( $args['ignore_empty'] ) ) {
 		$args['hide_empty'] = $args['ignore_empty'];
-		unset($args['ignore_empty']);
+		unset( $args['ignore_empty'] );
 	}
 
 	$args['fields'] = 'count';
 
-	return get_terms($taxonomy, $args);
+	return get_terms( $taxonomy, $args );
 }
 
 /**
@@ -1395,16 +1398,16 @@
 
 	$object_id = (int) $object_id;
 
-	if ( !is_array($taxonomies) )
-		$taxonomies = array($taxonomies);
+	if ( !is_array( $taxonomies ) )
+		$taxonomies = array( $taxonomies );
 
 	foreach ( (array) $taxonomies as $taxonomy ) {
-		$tt_ids = wp_get_object_terms($object_id, $taxonomy, array('fields' => 'tt_ids'));
-		$in_tt_ids = "'" . implode("', '", $tt_ids) . "'";
+		$tt_ids = wp_get_object_terms( $object_id, $taxonomy, array( 'fields' => 'tt_ids' ) );
+		$in_tt_ids = "'" . implode( "', '", $tt_ids ) . "'";
 		do_action( 'delete_term_relationships', $object_id, $tt_ids );
-		$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id IN ($in_tt_ids)", $object_id) );
+		$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id IN ($in_tt_ids)", $object_id ) );
 		do_action( 'deleted_term_relationships', $object_id, $tt_ids );
-		wp_update_term_count($tt_ids, $taxonomy);
+		wp_update_term_count( $tt_ids, $taxonomy );
 	}
 }
 
@@ -1438,7 +1441,7 @@
 
 	$term = (int) $term;
 
-	if ( ! $ids = term_exists($term, $taxonomy) )
+	if ( ! $ids = term_exists( $term, $taxonomy ) )
 		return false;
 	if ( is_wp_error( $ids ) )
 		return $ids;
@@ -1453,41 +1456,41 @@
 			return 0; // Don't delete the default category
 	}
 
-	$args = wp_parse_args($args, $defaults);
-	extract($args, EXTR_SKIP);
+	$args = wp_parse_args( $args, $defaults );
+	extract( $args, EXTR_SKIP );
 
 	if ( isset( $default ) ) {
 		$default = (int) $default;
-		if ( ! term_exists($default, $taxonomy) )
-			unset($default);
+		if ( ! term_exists( $default, $taxonomy ) )
+			unset( $default );
 	}
 
 	// Update children to point to new parent
-	if ( is_taxonomy_hierarchical($taxonomy) ) {
-		$term_obj = get_term($term, $taxonomy);
+	if ( is_taxonomy_hierarchical( $taxonomy ) ) {
+		$term_obj = get_term( $term, $taxonomy );
 		if ( is_wp_error( $term_obj ) )
 			return $term_obj;
 		$parent = $term_obj->parent;
 
 		$edit_tt_ids = $wpdb->get_col( "SELECT `term_taxonomy_id` FROM $wpdb->term_taxonomy WHERE `parent` = " . (int)$term_obj->term_id );
 		do_action( 'edit_term_taxonomies', $edit_tt_ids );
-		$wpdb->update( $wpdb->term_taxonomy, compact( 'parent' ), array( 'parent' => $term_obj->term_id) + compact( 'taxonomy' ) );
+		$wpdb->update( $wpdb->term_taxonomy, compact( 'parent' ), array( 'parent' => $term_obj->term_id ) + compact( 'taxonomy' ) );
 		do_action( 'edited_term_taxonomies', $edit_tt_ids );
 	}
 
 	$objects = $wpdb->get_col( $wpdb->prepare( "SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $tt_id ) );
 
 	foreach ( (array) $objects as $object ) {
-		$terms = wp_get_object_terms($object, $taxonomy, array('fields' => 'ids', 'orderby' => 'none'));
-		if ( 1 == count($terms) && isset($default) ) {
-			$terms = array($default);
+		$terms = wp_get_object_terms( $object, $taxonomy, array( 'fields' => 'ids', 'orderby' => 'none' ) );
+		if ( 1 == count( $terms ) && isset( $default ) ) {
+			$terms = array( $default );
 		} else {
-			$terms = array_diff($terms, array($term));
-			if (isset($default) && isset($force_default) && $force_default)
-				$terms = array_merge($terms, array($default));
+			$terms = array_diff( $terms, array( $term ) );
+			if ( isset( $default ) && isset( $force_default ) && $force_default )
+				$terms = array_merge( $terms, array( $default ) );
 		}
-		$terms = array_map('intval', $terms);
-		wp_set_object_terms($object, $terms, $taxonomy);
+		$terms = array_map( 'intval', $terms );
+		wp_set_object_terms( $object, $terms, $taxonomy );
 	}
 
 	do_action( 'delete_term_taxonomy', $tt_id );
@@ -1495,13 +1498,13 @@
 	do_action( 'deleted_term_taxonomy', $tt_id );
 
 	// Delete the term if no taxonomies use it.
-	if ( !$wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE term_id = %d", $term) ) )
-		$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->terms WHERE term_id = %d", $term) );
+	if ( !$wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE term_id = %d", $term ) ) )
+		$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->terms WHERE term_id = %d", $term ) );
 
-	clean_term_cache($term, $taxonomy);
+	clean_term_cache( $term, $taxonomy );
 
-	do_action('delete_term', $term, $tt_id, $taxonomy);
-	do_action("delete_$taxonomy", $term, $tt_id);
+	do_action( 'delete_term', $term, $tt_id, $taxonomy );
+	do_action( "delete_$taxonomy", $term, $tt_id );
 
 	return true;
 }
@@ -1552,40 +1555,40 @@
  * @param array|string $args Change what is returned
  * @return array|WP_Error The requested term data or empty array if no terms found. WP_Error if $taxonomy does not exist.
  */
-function wp_get_object_terms($object_ids, $taxonomies, $args = array()) {
+function wp_get_object_terms( $object_ids, $taxonomies, $args = array() ) {
 	global $wpdb;
 
-	if ( !is_array($taxonomies) )
-		$taxonomies = array($taxonomies);
+	if ( !is_array( $taxonomies ) )
+		$taxonomies = array( $taxonomies );
 
 	foreach ( (array) $taxonomies as $taxonomy ) {
-		if ( ! taxonomy_exists($taxonomy) )
-			return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy'));
+		if ( ! taxonomy_exists( $taxonomy ) )
+			return new WP_Error( 'invalid_taxonomy', __( 'Invalid Taxonomy' ) );
 	}
 
-	if ( !is_array($object_ids) )
-		$object_ids = array($object_ids);
-	$object_ids = array_map('intval', $object_ids);
+	if ( !is_array( $object_ids ) )
+		$object_ids = array( $object_ids );
+	$object_ids = array_map( 'intval', $object_ids );
 
-	$defaults = array('orderby' => 'name', 'order' => 'ASC', 'fields' => 'all');
+	$defaults = array( 'orderby' => 'name', 'order' => 'ASC', 'fields' => 'all' );
 	$args = wp_parse_args( $args, $defaults );
 
 	$terms = array();
-	if ( count($taxonomies) > 1 ) {
+	if ( count( $taxonomies ) > 1 ) {
 		foreach ( $taxonomies as $index => $taxonomy ) {
-			$t = get_taxonomy($taxonomy);
-			if ( isset($t->args) && is_array($t->args) && $args != array_merge($args, $t->args) ) {
-				unset($taxonomies[$index]);
-				$terms = array_merge($terms, wp_get_object_terms($object_ids, $taxonomy, array_merge($args, $t->args)));
+			$t = get_taxonomy( $taxonomy );
+			if ( isset( $t->args ) && is_array( $t->args ) && $args != array_merge( $args, $t->args ) ) {
+				unset( $taxonomies[$index] );
+				$terms = array_merge( $terms, wp_get_object_terms( $object_ids, $taxonomy, array_merge( $args, $t->args ) ) );
 			}
 		}
 	} else {
-		$t = get_taxonomy($taxonomies[0]);
-		if ( isset($t->args) && is_array($t->args) )
-			$args = array_merge($args, $t->args);
+		$t = get_taxonomy( $taxonomies[0] );
+		if ( isset( $t->args ) && is_array( $t->args ) )
+			$args = array_merge( $args, $t->args );
 	}
 
-	extract($args, EXTR_SKIP);
+	extract( $args, EXTR_SKIP );
 
 	if ( 'count' == $orderby )
 		$orderby = 'tt.count';
@@ -1605,14 +1608,14 @@
 	}
 
 	// tt_ids queries can only be none or tr.term_taxonomy_id
-	if ( ('tt_ids' == $fields) && !empty($orderby) )
+	if ( ( 'tt_ids' == $fields ) && !empty( $orderby ) )
 		$orderby = 'tr.term_taxonomy_id';
 
-	if ( !empty($orderby) )
+	if ( !empty( $orderby ) )
 		$orderby = "ORDER BY $orderby";
 
-	$taxonomies = "'" . implode("', '", $taxonomies) . "'";
-	$object_ids = implode(', ', $object_ids);
+	$taxonomies = "'" . implode( "', '", $taxonomies ) . "'";
+	$object_ids = implode( ', ', $object_ids );
 
 	$select_this = '';
 	if ( 'all' == $fields )
@@ -1627,18 +1630,18 @@
 	$query = "SELECT $select_this FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN $wpdb->term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ($taxonomies) AND tr.object_id IN ($object_ids) $orderby $order";
 
 	if ( 'all' == $fields || 'all_with_object_id' == $fields ) {
-		$terms = array_merge($terms, $wpdb->get_results($query));
-		update_term_cache($terms);
+		$terms = array_merge( $terms, $wpdb->get_results( $query ) );
+		update_term_cache( $terms );
 	} else if ( 'ids' == $fields || 'names' == $fields ) {
-		$terms = array_merge($terms, $wpdb->get_col($query));
+		$terms = array_merge( $terms, $wpdb->get_col( $query ) );
 	} else if ( 'tt_ids' == $fields ) {
-		$terms = $wpdb->get_col("SELECT tr.term_taxonomy_id FROM $wpdb->term_relationships AS tr INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tr.object_id IN ($object_ids) AND tt.taxonomy IN ($taxonomies) $orderby $order");
+		$terms = $wpdb->get_col( "SELECT tr.term_taxonomy_id FROM $wpdb->term_relationships AS tr INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tr.object_id IN ($object_ids) AND tt.taxonomy IN ($taxonomies) $orderby $order" );
 	}
 
 	if ( ! $terms )
 		$terms = array();
 
-	return apply_filters('wp_get_object_terms', $terms, $object_ids, $taxonomies, $args);
+	return apply_filters( 'wp_get_object_terms', $terms, $object_ids, $taxonomies, $args );
 }
 
 /**
@@ -1697,83 +1700,83 @@
 function wp_insert_term( $term, $taxonomy, $args = array() ) {
 	global $wpdb;
 
-	if ( ! taxonomy_exists($taxonomy) )
-		return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
+	if ( ! taxonomy_exists( $taxonomy ) )
+		return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy' ) );
 
 	$term = apply_filters( 'pre_insert_term', $term, $taxonomy );
 		if ( is_wp_error( $term ) )
 			return $term;
 
-	if ( is_int($term) && 0 == $term )
-		return new WP_Error('invalid_term_id', __('Invalid term ID'));
+	if ( is_int( $term ) && 0 == $term )
+		return new WP_Error( 'invalid_term_id', __( 'Invalid term ID' ) );
 
-	if ( '' == trim($term) )
-		return new WP_Error('empty_term_name', __('A name is required for this term'));
+	if ( '' == trim( $term ) )
+		return new WP_Error( 'empty_term_name', __( 'A name is required for this term' ) );
 
-	$defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
-	$args = wp_parse_args($args, $defaults);
+	$defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '' );
+	$args = wp_parse_args( $args, $defaults );
 	$args['name'] = $term;
 	$args['taxonomy'] = $taxonomy;
-	$args = sanitize_term($args, $taxonomy, 'db');
-	extract($args, EXTR_SKIP);
+	$args = sanitize_term( $args, $taxonomy, 'db' );
+	extract( $args, EXTR_SKIP );
 
 	// expected_slashed ($name)
-	$name = stripslashes($name);
-	$description = stripslashes($description);
+	$name = stripslashes( $name );
+	$description = stripslashes( $description );
 
-	if ( empty($slug) )
-		$slug = sanitize_title($name);
+	if ( empty( $slug ) )
+		$slug = sanitize_title( $name );
 
 	$term_group = 0;
 	if ( $alias_of ) {
-		$alias = $wpdb->get_row( $wpdb->prepare( "SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $alias_of) );
+		$alias = $wpdb->get_row( $wpdb->prepare( "SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $alias_of ) );
 		if ( $alias->term_group ) {
 			// The alias we want is already in a group, so let's use that one.
 			$term_group = $alias->term_group;
 		} else {
 			// The alias isn't in a group, so let's create a new one and firstly add the alias term to it.
-			$term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms") + 1;
+			$term_group = $wpdb->get_var( "SELECT MAX(term_group) FROM $wpdb->terms" ) + 1;
 			do_action( 'edit_terms', $alias->term_id );
-			$wpdb->update($wpdb->terms, compact('term_group'), array('term_id' => $alias->term_id) );
+			$wpdb->update( $wpdb->terms, compact( 'term_group' ), array( 'term_id' => $alias->term_id ) );
 			do_action( 'edited_terms', $alias->term_id );
 		}
 	}
 
-	if ( $term_id = term_exists($slug) ) {
-		$existing_term = $wpdb->get_row( $wpdb->prepare( "SELECT name FROM $wpdb->terms WHERE term_id = %d", $term_id), ARRAY_A );
+	if ( $term_id = term_exists( $slug ) ) {
+		$existing_term = $wpdb->get_row( $wpdb->prepare( "SELECT name FROM $wpdb->terms WHERE term_id = %d", $term_id ), ARRAY_A );
 		// We've got an existing term in the same taxonomy, which matches the name of the new term:
-		if ( is_taxonomy_hierarchical($taxonomy) && $existing_term['name'] == $name && $exists = term_exists( (int) $term_id, $taxonomy ) ) {
+		if ( is_taxonomy_hierarchical( $taxonomy ) && $existing_term['name'] == $name && $exists = term_exists( (int) $term_id, $taxonomy ) ) {
 			// Hierarchical, and it matches an existing term, Do not allow same "name" in the same level.
-			$siblings = get_terms($taxonomy, array('fields' => 'names', 'get' => 'all', 'parent' => (int)$parent) );
-			if ( in_array($name, $siblings) ) {
-				return new WP_Error('term_exists', __('A term with the name provided already exists with this parent.'), $exists['term_id']);
+			$siblings = get_terms( $taxonomy, array( 'fields' => 'names', 'get' => 'all', 'parent' => (int)$parent ) );
+			if ( in_array( $name, $siblings ) ) {
+				return new WP_Error( 'term_exists', __( 'A term with the name provided already exists with this parent.' ), $exists['term_id'] );
 			} else {
-				$slug = wp_unique_term_slug($slug, (object) $args);
+				$slug = wp_unique_term_slug( $slug, (object) $args );
 				if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) )
-					return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error);
+					return new WP_Error( 'db_insert_error', __( 'Could not insert term into the database' ), $wpdb->last_error );
 				$term_id = (int) $wpdb->insert_id;
 			}
 		} elseif ( $existing_term['name'] != $name ) {
 			// We've got an existing term, with a different name, Create the new term.
-			$slug = wp_unique_term_slug($slug, (object) $args);
+			$slug = wp_unique_term_slug( $slug, (object) $args );
 			if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) )
-				return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error);
+				return new WP_Error( 'db_insert_error', __( 'Could not insert term into the database' ), $wpdb->last_error );
 			$term_id = (int) $wpdb->insert_id;
 		} elseif ( $exists = term_exists( (int) $term_id, $taxonomy ) )  {
 			// Same name, same slug.
-			return new WP_Error('term_exists', __('A term with the name provided already exists.'), $exists['term_id']);
+			return new WP_Error( 'term_exists', __( 'A term with the name provided already exists.' ), $exists['term_id'] );
 		}
 	} else {
 		// This term does not exist at all in the database, Create it.
-		$slug = wp_unique_term_slug($slug, (object) $args);
+		$slug = wp_unique_term_slug( $slug, (object) $args );
 		if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) )
-			return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error);
+			return new WP_Error( 'db_insert_error', __( 'Could not insert term into the database' ), $wpdb->last_error );
 		$term_id = (int) $wpdb->insert_id;
 	}
 
 	// Seems unreachable, However, Is used in the case that a term name is provided, which sanitizes to an empty string.
-	if ( empty($slug) ) {
-		$slug = sanitize_title($slug, $term_id);
+	if ( empty( $slug ) ) {
+		$slug = sanitize_title( $slug, $term_id );
 		do_action( 'edit_terms', $term_id );
 		$wpdb->update( $wpdb->terms, compact( 'slug' ), compact( 'term_id' ) );
 		do_action( 'edited_terms', $term_id );
@@ -1781,23 +1784,23 @@
 
 	$tt_id = $wpdb->get_var( $wpdb->prepare( "SELECT tt.term_taxonomy_id FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = %s AND t.term_id = %d", $taxonomy, $term_id ) );
 
-	if ( !empty($tt_id) )
-		return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
+	if ( !empty( $tt_id ) )
+		return array( 'term_id' => $term_id, 'term_taxonomy_id' => $tt_id );
 
 	$wpdb->insert( $wpdb->term_taxonomy, compact( 'term_id', 'taxonomy', 'description', 'parent') + array( 'count' => 0 ) );
 	$tt_id = (int) $wpdb->insert_id;
 
-	do_action("create_term", $term_id, $tt_id, $taxonomy);
-	do_action("create_$taxonomy", $term_id, $tt_id);
+	do_action( "create_term", $term_id, $tt_id, $taxonomy );
+	do_action( "create_$taxonomy", $term_id, $tt_id );
 
-	$term_id = apply_filters('term_id_filter', $term_id, $tt_id);
+	$term_id = apply_filters( 'term_id_filter', $term_id, $tt_id );
 
-	clean_term_cache($term_id, $taxonomy);
+	clean_term_cache( $term_id, $taxonomy );
 
-	do_action("created_term", $term_id, $tt_id, $taxonomy);
-	do_action("created_$taxonomy", $term_id, $tt_id);
+	do_action( "created_term", $term_id, $tt_id, $taxonomy );
+	do_action( "created_$taxonomy", $term_id, $tt_id );
 
-	return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
+	return array( 'term_id' => $term_id, 'term_taxonomy_id' => $tt_id );
 }
 
 /**
