mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-13 02:51:33 +01:00
Additional 'orderby' values for wp_get_object_terms()
.
Adds support for ordering by 'taxonomy', 'term_taxonomy_id', and 'parent'. Props ChriCo. Fixes #28688. Built from https://develop.svn.wordpress.org/trunk@31236 git-svn-id: http://core.svn.wordpress.org/trunk@31217 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
00436f6886
commit
42ec13030c
@ -2562,7 +2562,7 @@ function wp_delete_category( $cat_ID ) {
|
|||||||
* @param array|string $args {
|
* @param array|string $args {
|
||||||
* Array of arguments.
|
* Array of arguments.
|
||||||
* @type string $orderby Field by which results should be sorted. Accepts 'name', 'count', 'slug', 'term_group',
|
* @type string $orderby Field by which results should be sorted. Accepts 'name', 'count', 'slug', 'term_group',
|
||||||
* or 'term_order'. Default 'name'.
|
* 'term_order', 'taxonomy', 'parent', or 'term_taxonomy_id'. Default 'name'.
|
||||||
* @type string $order Sort order. Accepts 'ASC' or 'DESC'. Default 'ASC'.
|
* @type string $order Sort order. Accepts 'ASC' or 'DESC'. Default 'ASC'.
|
||||||
* @type string $fields Fields to return for matched terms. Accepts 'all', 'ids', 'names', and
|
* @type string $fields Fields to return for matched terms. Accepts 'all', 'ids', 'names', and
|
||||||
* 'all_with_object_id'. Note that 'all' or 'all_with_object_id' will result in an array of
|
* 'all_with_object_id'. Note that 'all' or 'all_with_object_id' will result in an array of
|
||||||
@ -2612,17 +2612,13 @@ function wp_get_object_terms($object_ids, $taxonomies, $args = array()) {
|
|||||||
$order = $args['order'];
|
$order = $args['order'];
|
||||||
$fields = $args['fields'];
|
$fields = $args['fields'];
|
||||||
|
|
||||||
if ( 'count' == $orderby ) {
|
if ( in_array( $orderby, array( 'term_id', 'name', 'slug', 'term_group' ) ) ) {
|
||||||
$orderby = 'tt.count';
|
$orderby = "t.$orderby";
|
||||||
} elseif ( 'name' == $orderby ) {
|
} else if ( in_array( $orderby, array( 'count', 'parent', 'taxonomy', 'term_taxonomy_id' ) ) ) {
|
||||||
$orderby = 't.name';
|
$orderby = "tt.$orderby";
|
||||||
} elseif ( 'slug' == $orderby ) {
|
} else if ( 'term_order' === $orderby ) {
|
||||||
$orderby = 't.slug';
|
|
||||||
} elseif ( 'term_group' == $orderby ) {
|
|
||||||
$orderby = 't.term_group';
|
|
||||||
} elseif ( 'term_order' == $orderby ) {
|
|
||||||
$orderby = 'tr.term_order';
|
$orderby = 'tr.term_order';
|
||||||
} elseif ( 'none' == $orderby ) {
|
} else if ( 'none' === $orderby ) {
|
||||||
$orderby = '';
|
$orderby = '';
|
||||||
$order = '';
|
$order = '';
|
||||||
} else {
|
} else {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.2-alpha-31235';
|
$wp_version = '4.2-alpha-31236';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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