[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/ -> class-wp-tax-query.php (summary)

Taxonomy API: WP_Tax_Query class

File Size: 659 lines (20 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

WP_Tax_Query:: (11 methods):
  __construct()
  sanitize_query()
  sanitize_relation()
  is_first_order_clause()
  get_sql()
  get_sql_clauses()
  get_sql_for_query()
  get_sql_for_clause()
  find_compatible_table_alias()
  clean_query()
  transform_query()


Class: WP_Tax_Query  - X-Ref

Core class used to implement taxonomy queries for the Taxonomy API.

Used for generating SQL clauses that filter a primary query according to object
taxonomy terms.

WP_Tax_Query is a helper that allows primary query classes, such as WP_Query, to filter
their results by object metadata, by generating `JOIN` and `WHERE` subclauses to be
attached to the primary SQL query string.

__construct( $tax_query )   X-Ref
Constructor.

param: array $tax_query {

sanitize_query( $queries )   X-Ref
Ensures the 'tax_query' argument passed to the class constructor is well-formed.

Ensures that each query-level clause has a 'relation' key, and that
each first-order clause contains all the necessary keys from `$defaults`.

return: array Sanitized array of query clauses.
param: array $queries Array of queries clauses.

sanitize_relation( $relation )   X-Ref
Sanitizes a 'relation' operator.

return: string Sanitized relation. Either 'AND' or 'OR'.
param: string $relation Raw relation key from the query argument.

is_first_order_clause( $query )   X-Ref
Determines whether a clause is first-order.

A "first-order" clause is one that contains any of the first-order
clause keys ('terms', 'taxonomy', 'include_children', 'field',
'operator'). An empty clause also counts as a first-order clause,
for backward compatibility. Any clause that doesn't meet this is
determined, by process of elimination, to be a higher-order query.

return: bool Whether the query clause is a first-order clause.
param: array $query Tax query arguments.

get_sql( $primary_table, $primary_id_column )   X-Ref
Generates SQL clauses to be appended to a main query.

return: string[] {
param: string $primary_table     Database table where the object being filtered is stored (eg wp_users).
param: string $primary_id_column ID column for the filtered object in $primary_table.

get_sql_clauses()   X-Ref
Generates SQL clauses to be appended to a main query.

Called by the public WP_Tax_Query::get_sql(), this method
is abstracted out to maintain parity with the other Query classes.

return: string[] {

get_sql_for_query( &$query, $depth = 0 )   X-Ref
Generates SQL clauses for a single query array.

If nested subqueries are found, this method recurses the tree to
produce the properly nested SQL.

return: string[] {
param: array $query Query to parse (passed by reference).
param: int   $depth Optional. Number of tree levels deep we currently are.

get_sql_for_clause( &$clause, $parent_query )   X-Ref
Generates SQL JOIN and WHERE clauses for a "first-order" query clause.

return: array {
param: array $clause       Query clause (passed by reference).
param: array $parent_query Parent query array.

find_compatible_table_alias( $clause, $parent_query )   X-Ref
Identifies an existing table alias that is compatible with the current query clause.

We avoid unnecessary table joins by allowing each clause to look for
an existing table alias that is compatible with the query that it
needs to perform.

An existing alias is compatible if (a) it is a sibling of `$clause`
(ie, it's under the scope of the same relation), and (b) the combination
of operator and relation between the clauses allows for a shared table
join. In the case of WP_Tax_Query, this only applies to 'IN'
clauses that are connected by the relation 'OR'.

return: string|false Table alias if found, otherwise false.
param: array $clause       Query clause.
param: array $parent_query Parent query of $clause.

clean_query( &$query )   X-Ref
Validates a single query.

param: array $query The single query. Passed by reference.

transform_query( &$query, $resulting_field )   X-Ref
Transforms a single query, from one field to another.

Operates on the `$query` object by reference. In the case of error,
`$query` is converted to a WP_Error object.

param: array  $query           The single query. Passed by reference.
param: string $resulting_field The resulting field. Accepts 'slug', 'name', 'term_taxonomy_id',



Generated : Sat Dec 21 08:20:01 2024 Cross-referenced by PHPXref