mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-28 15:17:42 +02:00
Introduce term_taxonomy_id
parameter for WP_Term_Query
.
Allows the fetching of terms based on `term_taxonomy_id`, or an array of `term_taxonomy_ids`. Props spacedmonkey. Fixes #37074. Built from https://develop.svn.wordpress.org/trunk@37683 git-svn-id: http://core.svn.wordpress.org/trunk@37649 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
cbf8baa301
commit
defe5e371b
@ -92,6 +92,7 @@ class WP_Term_Query {
|
|||||||
* Sets up the term query, based on the query vars passed.
|
* Sets up the term query, based on the query vars passed.
|
||||||
*
|
*
|
||||||
* @since 4.6.0
|
* @since 4.6.0
|
||||||
|
* @since 4.6.0 Introduced 'term_taxonomy_id' parameter.
|
||||||
* @access public
|
* @access public
|
||||||
*
|
*
|
||||||
* @param string|array $query {
|
* @param string|array $query {
|
||||||
@ -136,6 +137,8 @@ class WP_Term_Query {
|
|||||||
* Default empty.
|
* Default empty.
|
||||||
* @type string|array $slug Optional. Slug or array of slugs to return term(s) for.
|
* @type string|array $slug Optional. Slug or array of slugs to return term(s) for.
|
||||||
* Default empty.
|
* Default empty.
|
||||||
|
* @type int|array $term_taxonomy_id Optional. Term taxonomy ID, or array of term taxonomy IDs,
|
||||||
|
* to match when querying terms.
|
||||||
* @type bool $hierarchical Whether to include terms that have non-empty descendants (even
|
* @type bool $hierarchical Whether to include terms that have non-empty descendants (even
|
||||||
* if $hide_empty is set to true). Default true.
|
* if $hide_empty is set to true). Default true.
|
||||||
* @type string $search Search criteria to match terms. Will be SQL-formatted with
|
* @type string $search Search criteria to match terms. Will be SQL-formatted with
|
||||||
@ -183,6 +186,7 @@ class WP_Term_Query {
|
|||||||
'count' => false,
|
'count' => false,
|
||||||
'name' => '',
|
'name' => '',
|
||||||
'slug' => '',
|
'slug' => '',
|
||||||
|
'term_taxonomy_id' => '',
|
||||||
'hierarchical' => true,
|
'hierarchical' => true,
|
||||||
'search' => '',
|
'search' => '',
|
||||||
'name__like' => '',
|
'name__like' => '',
|
||||||
@ -473,6 +477,15 @@ class WP_Term_Query {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( ! empty( $args['term_taxonomy_id'] ) ) {
|
||||||
|
if ( is_array( $args['term_taxonomy_id'] ) ) {
|
||||||
|
$tt_ids = implode( ',', array_map( 'intval', $args['term_taxonomy_id'] ) );
|
||||||
|
$this->sql_clauses['where']['term_taxonomy_id'] = "tt.term_taxonomy_id IN ({$tt_ids})";
|
||||||
|
} else {
|
||||||
|
$this->sql_clauses['where']['term_taxonomy_id'] = $wpdb->prepare( "tt.term_taxonomy_id = %d", $args['term_taxonomy_id'] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! empty( $args['name__like'] ) ) {
|
if ( ! empty( $args['name__like'] ) ) {
|
||||||
$this->sql_clauses['where']['name__like'] = $wpdb->prepare( "t.name LIKE %s", '%' . $wpdb->esc_like( $args['name__like'] ) . '%' );
|
$this->sql_clauses['where']['name__like'] = $wpdb->prepare( "t.name LIKE %s", '%' . $wpdb->esc_like( $args['name__like'] ) . '%' );
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.6-alpha-37682';
|
$wp_version = '4.6-alpha-37683';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user