+ * @since 3.2.0
+ * @access private
+ *
+ * @param array &$query The single query
+ */
+ private function clean_query( &$query ) {
+ if ( ! taxonomy_exists( $query['taxonomy'] ) ) {
+ $query = new WP_Error( 'Invalid taxonomy' );
+ return;
+ }
+
+ $query['terms'] = array_unique( (array) $query['terms'] );
+
+ if ( is_taxonomy_hierarchical( $query['taxonomy'] ) && $query['include_children'] ) {
+ $this->transform_query( $query, 'term_id' );
+
+ if ( is_wp_error( $query ) )
+ return;
+
+ $children = array();
+ foreach ( $query['terms'] as $term ) {
+ $children = array_merge( $children, get_term_children( $term, $query['taxonomy'] ) );
+ $children[] = $term;
+ }
+ $query['terms'] = $children;
+ }
+
+ $this->transform_query( $query, 'term_taxonomy_id' );
+ }
+
+ /**
+ * Transforms a single query, from one field to another.
+ *
+ * @since 3.2.0