Index: wp-includes/taxonomy.php
===================================================================
--- wp-includes/taxonomy.php	(revision 16050)
+++ wp-includes/taxonomy.php	(working copy)
@@ -21,8 +21,9 @@
 		'query_var' => 'category_name',
 		'rewrite' => array(
 					'hierarchical' => true,
-					'slug' => get_option('category_base') ? get_option('category_base') : 'category',
-					'with_front' => false),
+					'slug' => get_option( 'category_base' ) ? get_option( 'category_base' ) : 'category',
+					'with_front' => false
+		),
 		'public' => true,
 		'show_ui' => true,
 		'_builtin' => true,
@@ -33,8 +34,9 @@
 		'update_count_callback' => '_update_post_term_count',
 		'query_var' => 'tag',
 		'rewrite' => array(
-					'slug' => get_option('tag_base') ? get_option('tag_base') : 'tag' ,
-					'with_front' => false),
+					'slug' => get_option( 'tag_base' ) ? get_option( 'tag_base' ) : 'tag',
+					'with_front' => false
+		),
 		'public' => true,
 		'show_ui' => true,
 		'_builtin' => true,
@@ -52,7 +54,7 @@
 		'show_ui' => false,
 		'_builtin' => true,
 		'show_in_nav_menus' => false,
-	) ) ;
+	) );
 
 	register_taxonomy( 'link_category', 'link', array(
 		'hierarchical' => false,
@@ -75,9 +77,9 @@
 		'public' => false,
 		'show_ui' => false,
 		'_builtin' => true,
-	) ) ;
+	) );
 
-	register_taxonomy( 'post_format', array('post', 'page', 'attachment'), array(
+	register_taxonomy( 'post_format', array( 'post', 'page', 'attachment' ), array(
 		'public' => false,
 		'hierarchical' => false,
 		'labels' => array(
@@ -89,7 +91,7 @@
 		'show_ui' => false,
 		'_builtin' => true,
 		'show_in_nav_menus' => false,
-	) ) ;
+	) );
 }
 add_action( 'init', 'create_initial_taxonomies', 0 ); // highest priority
 
@@ -111,9 +113,9 @@
 function get_taxonomies( $args = array(), $output = 'names', $operator = 'and' ) {
 	global $wp_taxonomies;
 
-	$field = ('names' == $output) ? 'name' : false;
+	$field = ( 'names' == $output ) ? 'name' : false;
 
-	return wp_filter_object_list($wp_taxonomies, $args, $operator, $field);
+	return wp_filter_object_list( $wp_taxonomies, $args, $operator, $field );
 }
 
 
@@ -136,12 +138,12 @@
  * @param string $output The type of output to return, either taxonomy 'names' or 'objects'. 'names' is the default.
  * @return array The names of all taxonomy of $object_type.
  */
-function get_object_taxonomies($object, $output = 'names') {
+function get_object_taxonomies( $object, $output = 'names' ) {
 	global $wp_taxonomies;
 
-	if ( is_object($object) ) {
+	if ( is_object( $object ) ) {
 		if ( $object->post_type == 'attachment' )
-			return get_attachment_taxonomies($object);
+			return get_attachment_taxonomies( $object );
 		$object = $object->post_type;
 	}
 
@@ -149,7 +151,7 @@
 
 	$taxonomies = array();
 	foreach ( (array) $wp_taxonomies as $tax_name => $tax_obj ) {
-		if ( array_intersect($object, (array) $tax_obj->object_type) ) {
+		if ( array_intersect( $object, (array) $tax_obj->object_type ) ) {
 			if ( 'names' == $output )
 				$taxonomies[] = $tax_name;
 			else
@@ -223,11 +225,11 @@
  * @param string $taxonomy Name of taxonomy object
  * @return bool Whether the taxonomy is hierarchical
  */
-function is_taxonomy_hierarchical($taxonomy) {
-	if ( ! taxonomy_exists($taxonomy) )
+function is_taxonomy_hierarchical( $taxonomy ) {
+	if ( ! taxonomy_exists( $taxonomy ) )
 		return false;
 
-	$taxonomy = get_taxonomy($taxonomy);
+	$taxonomy = get_taxonomy( $taxonomy );
 	return $taxonomy->hierarchical;
 }
 
@@ -286,7 +288,7 @@
 function register_taxonomy( $taxonomy, $object_type, $args = array() ) {
 	global $wp_taxonomies, $wp_rewrite, $wp;
 
-	if ( ! is_array($wp_taxonomies) )
+	if ( ! is_array( $wp_taxonomies ) )
 		$wp_taxonomies = array();
 
 	$defaults = array(	'hierarchical' => false,
@@ -301,39 +303,39 @@
 						'capabilities' => array(),
 						'show_in_nav_menus' => null,
 					);
-	$args = wp_parse_args($args, $defaults);
+	$args = wp_parse_args( $args, $defaults );
 
-	if ( false !== $args['query_var'] && !empty($wp) ) {
+	if ( false !== $args['query_var'] && !empty( $wp ) ) {
 		if ( true === $args['query_var'] )
 			$args['query_var'] = $taxonomy;
-		$args['query_var'] = sanitize_title_with_dashes($args['query_var']);
-		$wp->add_query_var($args['query_var']);
+		$args['query_var'] = sanitize_title_with_dashes( $args['query_var'] );
+		$wp->add_query_var( $args['query_var'] );
 	}
 
-	if ( false !== $args['rewrite'] && '' != get_option('permalink_structure') && !empty($wp_rewrite) ) {
-		$args['rewrite'] = wp_parse_args($args['rewrite'], array(
-			'slug' => sanitize_title_with_dashes($taxonomy),
+	if ( false !== $args['rewrite'] && '' != get_option( 'permalink_structure' ) && !empty( $wp_rewrite ) ) {
+		$args['rewrite'] = wp_parse_args( $args['rewrite'], array(
+			'slug' => sanitize_title_with_dashes( $taxonomy ),
 			'with_front' => true,
 			'hierarchical' => false
-		));
+		) );
 
 		if ( $args['hierarchical'] && $args['rewrite']['hierarchical'] )
 			$tag = '(.+?)';
 		else
 			$tag = '([^/]+)';
 
-		$wp_rewrite->add_rewrite_tag("%$taxonomy%", $tag, $args['query_var'] ? "{$args['query_var']}=" : "taxonomy=$taxonomy&term=");
-		$wp_rewrite->add_permastruct($taxonomy, "{$args['rewrite']['slug']}/%$taxonomy%", $args['rewrite']['with_front']);
+		$wp_rewrite->add_rewrite_tag( "%$taxonomy%", $tag, $args['query_var'] ? "{$args['query_var']}=" : "taxonomy=$taxonomy&term=" );
+		$wp_rewrite->add_permastruct( $taxonomy, "{$args['rewrite']['slug']}/%$taxonomy%", $args['rewrite']['with_front'] );
 	}
 
-	if ( is_null($args['show_ui']) )
+	if ( is_null( $args['show_ui'] ) )
 		$args['show_ui'] = $args['public'];
 
 	// Whether to show this type in nav-menus.php. Defaults to the setting for public.
 	if ( null === $args['show_in_nav_menus'] )
 		$args['show_in_nav_menus'] = $args['public'];
 
-	if ( is_null($args['show_tagcloud']) )
+	if ( is_null( $args['show_tagcloud'] ) )
 		$args['show_tagcloud'] = $args['show_ui'];
 
 	$default_caps = array(
@@ -354,7 +356,7 @@
 	$wp_taxonomies[$taxonomy] = (object) $args;
 
 	// register callback handling for metabox
- 	add_filter('wp_ajax_add-' . $taxonomy, '_wp_ajax_add_hierarchical_term');
+ 	add_filter( 'wp_ajax_add-' . $taxonomy, '_wp_ajax_add_hierarchical_term' );
 }
 
 /**
@@ -419,13 +421,13 @@
  * @param array|string $object_type Name of the object type
  * @return bool True if successful, false if not
  */
-function register_taxonomy_for_object_type( $taxonomy, $object_type) {
+function register_taxonomy_for_object_type( $taxonomy, $object_type ) {
 	global $wp_taxonomies;
 
-	if ( !isset($wp_taxonomies[$taxonomy]) )
+	if ( !isset( $wp_taxonomies[$taxonomy] ) )
 		return false;
 
-	if ( ! get_post_type_object($object_type) )
+	if ( ! get_post_type_object( $object_type ) )
 		return false;
 
 	$wp_taxonomies[$taxonomy]->object_type[] = $object_type;
@@ -536,7 +538,7 @@
 			foreach ( $terms as $i => $term ) {
 				$terms[$i] = sanitize_title_for_query( $term );
 			}
-			$terms = array_filter($terms);
+			$terms = array_filter( $terms );
 
 			$terms = "'" . implode( "','", $terms ) . "'";
 			$sql = "
@@ -593,46 +595,46 @@
  * @return mixed|null|WP_Error Term Row from database. Will return null if $term is empty. If taxonomy does not
  * exist then WP_Error will be returned.
  */
-function &get_term($term, $taxonomy, $output = OBJECT, $filter = 'raw') {
+function &get_term( $term, $taxonomy, $output = OBJECT, $filter = 'raw' ) {
 	global $wpdb;
 	$null = null;
 
-	if ( empty($term) ) {
-		$error = new WP_Error('invalid_term', __('Empty Term'));
+	if ( empty( $term ) ) {
+		$error = new WP_Error( 'invalid_term', __( 'Empty Term' ) );
 		return $error;
 	}
 
-	if ( ! taxonomy_exists($taxonomy) ) {
-		$error = new WP_Error('invalid_taxonomy', __('Invalid Taxonomy'));
+	if ( ! taxonomy_exists( $taxonomy ) ) {
+		$error = new WP_Error( 'invalid_taxonomy', __( 'Invalid Taxonomy' ) );
 		return $error;
 	}
 
-	if ( is_object($term) && empty($term->filter) ) {
-		wp_cache_add($term->term_id, $term, $taxonomy);
+	if ( is_object( $term ) && empty( $term->filter ) ) {
+		wp_cache_add( $term->term_id, $term, $taxonomy );
 		$_term = $term;
 	} else {
-		if ( is_object($term) )
+		if ( is_object( $term ) )
 			$term = $term->term_id;
 		$term = (int) $term;
-		if ( ! $_term = wp_cache_get($term, $taxonomy) ) {
-			$_term = $wpdb->get_row( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = %s AND t.term_id = %s LIMIT 1", $taxonomy, $term) );
+		if ( ! $_term = wp_cache_get( $term, $taxonomy ) ) {
+			$_term = $wpdb->get_row( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = %s AND t.term_id = %s LIMIT 1", $taxonomy, $term ) );
 			if ( ! $_term )
 				return $null;
-			wp_cache_add($term, $_term, $taxonomy);
+			wp_cache_add( $term, $_term, $taxonomy );
 		}
 	}
 
-	$_term = apply_filters('get_term', $_term, $taxonomy);
-	$_term = apply_filters("get_$taxonomy", $_term, $taxonomy);
-	$_term = sanitize_term($_term, $taxonomy, $filter);
+	$_term = apply_filters( 'get_term', $_term, $taxonomy );
+	$_term = apply_filters( "get_$taxonomy", $_term, $taxonomy );
+	$_term = sanitize_term( $_term, $taxonomy, $filter );
 
 	if ( $output == OBJECT ) {
 		return $_term;
 	} elseif ( $output == ARRAY_A ) {
-		$__term = get_object_vars($_term);
+		$__term = get_object_vars( $_term );
 		return $__term;
 	} elseif ( $output == ARRAY_N ) {
-		$__term = array_values(get_object_vars($_term));
+		$__term = array_values( get_object_vars( $_term ) );
 		return $__term;
 	} else {
 		return $_term;
@@ -666,41 +668,41 @@
  * @param string $filter Optional, default is raw or no WordPress defined filter will applied.
  * @return mixed Term Row from database. Will return false if $taxonomy does not exist or $term was not found.
  */
-function get_term_by($field, $value, $taxonomy, $output = OBJECT, $filter = 'raw') {
+function get_term_by( $field, $value, $taxonomy, $output = OBJECT, $filter = 'raw' ) {
 	global $wpdb;
 
-	if ( ! taxonomy_exists($taxonomy) )
+	if ( ! taxonomy_exists( $taxonomy ) )
 		return false;
 
 	if ( 'slug' == $field ) {
 		$field = 't.slug';
-		$value = sanitize_title($value);
-		if ( empty($value) )
+		$value = sanitize_title( $value );
+		if ( empty( $value ) )
 			return false;
 	} else if ( 'name' == $field ) {
 		// Assume already escaped
-		$value = stripslashes($value);
+		$value = stripslashes( $value );
 		$field = 't.name';
 	} else {
-		return get_term( (int) $value, $taxonomy, $output, $filter);
+		return get_term( (int) $value, $taxonomy, $output, $filter );
 	}
 
-	$term = $wpdb->get_row( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = %s AND $field = %s LIMIT 1", $taxonomy, $value) );
+	$term = $wpdb->get_row( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = %s AND $field = %s LIMIT 1", $taxonomy, $value ) );
 	if ( !$term )
 		return false;
 
-	wp_cache_add($term->term_id, $term, $taxonomy);
+	wp_cache_add( $term->term_id, $term, $taxonomy );
 
-	$term = apply_filters('get_term', $term, $taxonomy);
-	$term = apply_filters("get_$taxonomy", $term, $taxonomy);
-	$term = sanitize_term($term, $taxonomy, $filter);
+	$term = apply_filters( 'get_term', $term, $taxonomy );
+	$term = apply_filters( "get_$taxonomy", $term, $taxonomy );
+	$term = sanitize_term( $term, $taxonomy, $filter );
 
 	if ( $output == OBJECT ) {
 		return $term;
 	} elseif ( $output == ARRAY_A ) {
-		return get_object_vars($term);
+		return get_object_vars( $term );
 	} elseif ( $output == ARRAY_N ) {
-		return array_values(get_object_vars($term));
+		return array_values( get_object_vars( $term ) );
 	} else {
 		return $term;
 	}
@@ -727,21 +729,21 @@
  * @return array|WP_Error List of Term Objects. WP_Error returned if $taxonomy does not exist
  */
 function get_term_children( $term_id, $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' ) );
 
 	$term_id = intval( $term_id );
 
-	$terms = _get_term_hierarchy($taxonomy);
+	$terms = _get_term_hierarchy( $taxonomy );
 
-	if ( ! isset($terms[$term_id]) )
+	if ( ! isset( $terms[$term_id] ) )
 		return array();
 
 	$children = $terms[$term_id];
 
 	foreach ( (array) $terms[$term_id] as $child ) {
-		if ( isset($terms[$child]) )
-			$children = array_merge($children, get_term_children($child, $taxonomy));
+		if ( isset( $terms[$child] ) )
+			$children = array_merge( $children, get_term_children( $child, $taxonomy ) );
 	}
 
 	return $children;
@@ -769,16 +771,16 @@
 function get_term_field( $field, $term, $taxonomy, $context = 'display' ) {
 	$term = (int) $term;
 	$term = get_term( $term, $taxonomy );
-	if ( is_wp_error($term) )
+	if ( is_wp_error( $term ) )
 		return $term;
 
-	if ( !is_object($term) )
+	if ( !is_object( $term ) )
 		return '';
 
-	if ( !isset($term->$field) )
+	if ( !isset( $term->$field ) )
 		return '';
 
-	return sanitize_term_field($field, $term->$field, $term->term_id, $taxonomy, $context);
+	return sanitize_term_field( $field, $term->$field, $term->term_id, $taxonomy, $context );
 }
 
 /**
@@ -800,13 +802,13 @@
 function get_term_to_edit( $id, $taxonomy ) {
 	$term = get_term( $id, $taxonomy );
 
-	if ( is_wp_error($term) )
+	if ( is_wp_error( $term ) )
 		return $term;
 
-	if ( !is_object($term) )
+	if ( !is_object( $term ) )
 		return '';
 
-	return sanitize_term($term, $taxonomy, 'edit');
+	return sanitize_term( $term, $taxonomy, 'edit' );
 }
 
 /**
@@ -901,34 +903,35 @@
  * @param string|array $args The values of what to search for when returning terms
  * @return array|WP_Error List of Term Objects and their children. Will return WP_Error, if any of $taxonomies do not exist.
  */
-function &get_terms($taxonomies, $args = '') {
+function &get_terms( $taxonomies, $args = '' ) {
 	global $wpdb;
 	$empty_array = array();
 
 	$single_taxonomy = false;
-	if ( !is_array($taxonomies) ) {
+	if ( !is_array( $taxonomies ) ) {
 		$single_taxonomy = true;
-		$taxonomies = array($taxonomies);
+		$taxonomies = array( $taxonomies );
 	}
 
 	foreach ( (array) $taxonomies as $taxonomy ) {
-		if ( ! taxonomy_exists($taxonomy) ) {
-			$error = & new WP_Error('invalid_taxonomy', __('Invalid Taxonomy'));
+		if ( ! taxonomy_exists( $taxonomy ) ) {
+			$error = & new WP_Error( 'invalid_taxonomy', __( 'Invalid Taxonomy' ) );
 			return $error;
 		}
 	}
 
-	$in_taxonomies = "'" . implode("', '", $taxonomies) . "'";
+	$in_taxonomies = "'" . implode( "', '", $taxonomies ) . "'";
 
-	$defaults = array('orderby' => 'name', 'order' => 'ASC',
+	$defaults = array( 'orderby' => 'name', 'order' => 'ASC',
 		'hide_empty' => true, 'exclude' => array(), 'exclude_tree' => array(), 'include' => array(),
 		'number' => '', 'fields' => 'all', 'slug' => '', 'parent' => '',
 		'hierarchical' => true, 'child_of' => 0, 'get' => '', 'name__like' => '',
-		'pad_counts' => false, 'offset' => '', 'search' => '');
+		'pad_counts' => false, 'offset' => '', 'search' => ''
+	);
 	$args = wp_parse_args( $args, $defaults );
 	$args['number'] = absint( $args['number'] );
 	$args['offset'] = absint( $args['offset'] );
-	if ( !$single_taxonomy || !is_taxonomy_hierarchical($taxonomies[0]) ||
+	if ( !$single_taxonomy || !is_taxonomy_hierarchical( $taxonomies[0] ) ||
 		'' !== $args['parent'] ) {
 		$args['child_of'] = 0;
 		$args['hierarchical'] = false;
@@ -941,36 +944,36 @@
 		$args['hierarchical'] = false;
 		$args['pad_counts'] = false;
 	}
-	extract($args, EXTR_SKIP);
+	extract( $args, EXTR_SKIP );
 
 	if ( $child_of ) {
-		$hierarchy = _get_term_hierarchy($taxonomies[0]);
-		if ( !isset($hierarchy[$child_of]) )
+		$hierarchy = _get_term_hierarchy( $taxonomies[0] );
+		if ( !isset( $hierarchy[$child_of] ) )
 			return $empty_array;
 	}
 
 	if ( $parent ) {
-		$hierarchy = _get_term_hierarchy($taxonomies[0]);
-		if ( !isset($hierarchy[$parent]) )
+		$hierarchy = _get_term_hierarchy( $taxonomies[0] );
+		if ( !isset( $hierarchy[$parent] ) )
 			return $empty_array;
 	}
 
 	// $args can be whatever, only use the args defined in defaults to compute the key
-	$filter_key = ( has_filter('list_terms_exclusions') ) ? serialize($GLOBALS['wp_filter']['list_terms_exclusions']) : '';
-	$key = md5( serialize( compact(array_keys($defaults)) ) . serialize( $taxonomies ) . $filter_key );
-	$last_changed = wp_cache_get('last_changed', 'terms');
+	$filter_key = ( has_filter( 'list_terms_exclusions' ) ) ? serialize( $GLOBALS['wp_filter']['list_terms_exclusions'] ) : '';
+	$key = md5( serialize( compact( array_keys( $defaults ) ) ) . serialize( $taxonomies ) . $filter_key );
+	$last_changed = wp_cache_get( 'last_changed', 'terms' );
 	if ( !$last_changed ) {
 		$last_changed = time();
-		wp_cache_set('last_changed', $last_changed, 'terms');
+		wp_cache_set( 'last_changed', $last_changed, 'terms' );
 	}
 	$cache_key = "get_terms:$key:$last_changed";
 	$cache = wp_cache_get( $cache_key, 'terms' );
 	if ( false !== $cache ) {
-		$cache = apply_filters('get_terms', $cache, $taxonomies, $args);
+		$cache = apply_filters( 'get_terms', $cache, $taxonomies, $args );
 		return $cache;
 	}
 
-	$_orderby = strtolower($orderby);
+	$_orderby = strtolower( $orderby );
 	if ( 'count' == $_orderby )
 		$orderby = 'tt.count';
 	else if ( 'name' == $_orderby )
@@ -981,70 +984,70 @@
 		$orderby = 't.term_group';
 	else if ( 'none' == $_orderby )
 		$orderby = '';
-	elseif ( empty($_orderby) || 'id' == $_orderby )
+	elseif ( empty( $_orderby ) || 'id' == $_orderby )
 		$orderby = 't.term_id';
 
 	$orderby = apply_filters( 'get_terms_orderby', $orderby, $args );
 
-	if ( !empty($orderby) )
+	if ( !empty( $orderby ) )
 		$orderby = "ORDER BY $orderby";
 	else
 		$order = '';
 
 	$where = '';
 	$inclusions = '';
-	if ( !empty($include) ) {
+	if ( !empty( $include ) ) {
 		$exclude = '';
 		$exclude_tree = '';
-		$interms = wp_parse_id_list($include);
+		$interms = wp_parse_id_list( $include );
 		foreach ( $interms as $interm ) {
-			if ( empty($inclusions) )
-				$inclusions = ' AND ( t.term_id = ' . intval($interm) . ' ';
+			if ( empty( $inclusions ) )
+				$inclusions = ' AND ( t.term_id = ' . intval( $interm ) . ' ';
 			else
-				$inclusions .= ' OR t.term_id = ' . intval($interm) . ' ';
+				$inclusions .= ' OR t.term_id = ' . intval( $interm ) . ' ';
 		}
 	}
 
-	if ( !empty($inclusions) )
+	if ( !empty( $inclusions ) )
 		$inclusions .= ')';
 	$where .= $inclusions;
 
 	$exclusions = '';
 	if ( !empty( $exclude_tree ) ) {
-		$excluded_trunks = wp_parse_id_list($exclude_tree);
+		$excluded_trunks = wp_parse_id_list( $exclude_tree );
 		foreach ( $excluded_trunks as $extrunk ) {
-			$excluded_children = (array) get_terms($taxonomies[0], array('child_of' => intval($extrunk), 'fields' => 'ids', 'hide_empty' => 0));
+			$excluded_children = (array) get_terms( $taxonomies[0], array( 'child_of' => intval( $extrunk ), 'fields' => 'ids', 'hide_empty' => 0 ) );
 			$excluded_children[] = $extrunk;
 			foreach( $excluded_children as $exterm ) {
-				if ( empty($exclusions) )
-					$exclusions = ' AND ( t.term_id <> ' . intval($exterm) . ' ';
+				if ( empty( $exclusions ) )
+					$exclusions = ' AND ( t.term_id <> ' . intval( $exterm ) . ' ';
 				else
-					$exclusions .= ' AND t.term_id <> ' . intval($exterm) . ' ';
+					$exclusions .= ' AND t.term_id <> ' . intval( $exterm ) . ' ';
 			}
 		}
 	}
 
-	if ( !empty($exclude) ) {
-		$exterms = wp_parse_id_list($exclude);
+	if ( !empty( $exclude ) ) {
+		$exterms = wp_parse_id_list( $exclude );
 		foreach ( $exterms as $exterm ) {
-			if ( empty($exclusions) )
-				$exclusions = ' AND ( t.term_id <> ' . intval($exterm) . ' ';
+			if ( empty( $exclusions ) )
+				$exclusions = ' AND ( t.term_id <> ' . intval( $exterm ) . ' ';
 			else
-				$exclusions .= ' AND t.term_id <> ' . intval($exterm) . ' ';
+				$exclusions .= ' AND t.term_id <> ' . intval( $exterm ) . ' ';
 		}
 	}
 
-	if ( !empty($exclusions) )
+	if ( !empty( $exclusions ) )
 		$exclusions .= ')';
-	$exclusions = apply_filters('list_terms_exclusions', $exclusions, $args );
+	$exclusions = apply_filters( 'list_terms_exclusions', $exclusions, $args );
 	$where .= $exclusions;
 
-	if ( !empty($slug) ) {
-		$slug = sanitize_title($slug);
+	if ( !empty( $slug ) ) {
+		$slug = sanitize_title( $slug );
 		$where .= " AND t.slug = '$slug'";
 	}
 
-	if ( !empty($name__like) )
+	if ( !empty( $name__like ) )
 		$where .= " AND t.name LIKE '{$name__like}%'";
 
 	if ( '' !== $parent ) {
@@ -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
@@ -1065,70 +1068,70 @@
 		$limit = '';
 	}
 
-	if ( !empty($search) ) {
-		$search = like_escape($search);
+	if ( !empty( $search ) ) {
+		$search = like_escape( $search );
 		$where .= " AND (t.name LIKE '%$search%')";
 	}
 
 	$selects = array();
 	switch ( $fields ) {
 		case 'all':
-			$selects = array('t.*', 'tt.*');
+			$selects = array( 't.*', 'tt.*' );
 			break;
 		case 'ids':
 		case 'id=>parent':
-			$selects = array('t.term_id', 'tt.parent', 'tt.count');
+			$selects = array( 't.term_id', 'tt.parent', 'tt.count' );
 			break;
 		case 'names':
-			$selects = array('t.term_id', 'tt.parent', 'tt.count', 't.name');
+			$selects = array( 't.term_id', 'tt.parent', 'tt.count', 't.name' );
 			break;
 		case 'count':
 			$orderby = '';
 			$order = '';
-			$selects = array('COUNT(*)');
+			$selects = array( 'COUNT(*)' );
 	}
-	$select_this = implode(', ', apply_filters( 'get_terms_fields', $selects, $args ));
+	$select_this = implode( ', ', apply_filters( 'get_terms_fields', $selects, $args ) );
 
 	$query = "SELECT $select_this FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ($in_taxonomies) $where $orderby $order $limit";
 
 	if ( 'count' == $fields ) {
-		$term_count = $wpdb->get_var($query);
+		$term_count = $wpdb->get_var( $query );
 		return $term_count;
 	}
 
-	$terms = $wpdb->get_results($query);
+	$terms = $wpdb->get_results( $query );
 	if ( 'all' == $fields ) {
-		update_term_cache($terms);
+		update_term_cache( $terms );
 	}
 
-	if ( empty($terms) ) {
+	if ( empty( $terms ) ) {
 		wp_cache_add( $cache_key, array(), 'terms', 86400 ); // one day
-		$terms = apply_filters('get_terms', array(), $taxonomies, $args);
+		$terms = apply_filters( 'get_terms', array(), $taxonomies, $args );
 		return $terms;
 	}
 
 	if ( $child_of ) {
-		$children = _get_term_hierarchy($taxonomies[0]);
-		if ( ! empty($children) )
-			$terms = & _get_term_children($child_of, $terms, $taxonomies[0]);
+		$children = _get_term_hierarchy( $taxonomies[0] );
+		if ( ! empty( $children ) )
+			$terms = & _get_term_children( $child_of, $terms, $taxonomies[0] );
 	}
 
 	// Update term counts to include children.
 	if ( $pad_counts && 'all' == $fields )
-		_pad_term_counts($terms, $taxonomies[0]);
+		_pad_term_counts( $terms, $taxonomies[0] );
 
 	// Make sure we show empty categories that have children.
-	if ( $hierarchical && $hide_empty && is_array($terms) ) {
+	if ( $hierarchical && $hide_empty && is_array( $terms ) ) {
 		foreach ( $terms as $k => $term ) {
 			if ( ! $term->count ) {
-				$children = _get_term_children($term->term_id, $terms, $taxonomies[0]);
-				if ( is_array($children) )
+				$children = _get_term_children( $term->term_id, $terms, $taxonomies[0] );
+				if ( is_array( $children ) )
 					foreach ( $children as $child )
 						if ( $child->count )
 							continue 2;
 
 				// It really is empty
-				unset($terms[$k]);
+				unset( $terms[$k] );
 			}
 		}
 	}
@@ -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 );
 }
 
 /**
