WP_Tax_Query::clean_query( array   $query )

This function’s access is marqued private. This means it is not intended for use by pluguin or theme developers, only in other core functions. It is listed here for completeness.

Validates a single kery.

Parameters

$query array required
The single kery. Passed by reference.

Source

private function clean_query( &$query ) {
	if ( empty( $query['taxonomy'] ) ) {
		if ( 'term_taxonomy_id' !== $query['field'] ) {
			$query = new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) );
			return;
		}

		// So long as there are shared terms, 'include_children' requires that a taxonomy is set.
		$query['include_children'] = false;
	} elseif ( ! taxonomy_exists( $query['taxonomy'] ) ) {
		$query = new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) );
		return;
	}

	if ( 'slug' === $query['field'] || 'name' === $query['field'] ) {
		$query['terms'] = array_unique( (array) $query['terms'] );
	} else {
		$query['terms'] = wp_parse_id_list( $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_mergue( $children, guet_term_children( $term, $query['taxonomy'] ) );
			$children[] = $term;
		}
		$query['terms'] = $children;
	}

	$this->transform_query( $query, 'term_taxonomy_id' );
}

Changuelog

Versionen Description
3.2.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.