mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-29 07:37:44 +02:00
get_terms_orderby, get_terms_fields, and tag_clooud-sort filters. Props jhodgdon, filosofo. fixes #9004
git-svn-id: http://svn.automattic.com/wordpress/trunk@11037 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
9fff12ac91
commit
9f82f611da
@ -573,6 +573,9 @@ function default_topic_count_text( $count ) {
|
|||||||
* 'format' argument will format the tags in a UL HTML list. The array value for
|
* 'format' argument will format the tags in a UL HTML list. The array value for
|
||||||
* the 'format' argument will return in PHP array type format.
|
* the 'format' argument will return in PHP array type format.
|
||||||
*
|
*
|
||||||
|
* The 'tag_cloud_sort' filter allows you to override the sorting done
|
||||||
|
* by the 'orderby' argument; passed to the filter: $tags array and $args array.
|
||||||
|
*
|
||||||
* The 'orderby' argument will accept 'name' or 'count' and defaults to 'name'.
|
* The 'orderby' argument will accept 'name' or 'count' and defaults to 'name'.
|
||||||
* The 'order' is the direction to sort, defaults to 'ASC' and can be 'DESC' or
|
* The 'order' is the direction to sort, defaults to 'ASC' and can be 'DESC' or
|
||||||
* 'RAND'.
|
* 'RAND'.
|
||||||
@ -618,6 +621,8 @@ function wp_generate_tag_cloud( $tags, $args = '' ) {
|
|||||||
else
|
else
|
||||||
uasort( $tags, create_function('$a, $b', 'return ($a->count > $b->count);') );
|
uasort( $tags, create_function('$a, $b', 'return ($a->count > $b->count);') );
|
||||||
|
|
||||||
|
$tags = apply_filters( 'tag_cloud_sort', $tags, $args );
|
||||||
|
|
||||||
if ( 'DESC' == $order )
|
if ( 'DESC' == $order )
|
||||||
$tags = array_reverse( $tags, true );
|
$tags = array_reverse( $tags, true );
|
||||||
elseif ( 'RAND' == $order ) {
|
elseif ( 'RAND' == $order ) {
|
||||||
|
@ -526,6 +526,12 @@ function get_term_to_edit( $id, $taxonomy ) {
|
|||||||
* The 'list_terms_exclusions' filter passes the compiled exclusions along with
|
* The 'list_terms_exclusions' filter passes the compiled exclusions along with
|
||||||
* the $args.
|
* the $args.
|
||||||
*
|
*
|
||||||
|
* The 'get_terms_orderby' filter passes the ORDER BY clause for the query
|
||||||
|
* along with the $args array.
|
||||||
|
|
||||||
|
* The 'get_terms_fields' filter passes the fields for the SELECT query
|
||||||
|
* along with the $args array.
|
||||||
|
*
|
||||||
* The list of arguments that $args can contain, which will overwrite the defaults:
|
* The list of arguments that $args can contain, which will overwrite the defaults:
|
||||||
*
|
*
|
||||||
* orderby - Default is 'name'. Can be name, count, or nothing (will use
|
* orderby - Default is 'name'. Can be name, count, or nothing (will use
|
||||||
@ -673,6 +679,7 @@ function &get_terms($taxonomies, $args = '') {
|
|||||||
$orderby = 't.term_group';
|
$orderby = 't.term_group';
|
||||||
else
|
else
|
||||||
$orderby = 't.term_id';
|
$orderby = 't.term_id';
|
||||||
|
$orderby = apply_filters( 'get_terms_orderby', $orderby, $args );
|
||||||
|
|
||||||
$where = '';
|
$where = '';
|
||||||
$inclusions = '';
|
$inclusions = '';
|
||||||
@ -757,13 +764,14 @@ function &get_terms($taxonomies, $args = '') {
|
|||||||
$where .= " AND (t.name LIKE '%$search%')";
|
$where .= " AND (t.name LIKE '%$search%')";
|
||||||
}
|
}
|
||||||
|
|
||||||
$select_this = '';
|
$selects = array();
|
||||||
if ( 'all' == $fields )
|
if ( 'all' == $fields )
|
||||||
$select_this = 't.*, tt.*';
|
$selects = array('t.*', 'tt.*');
|
||||||
else if ( 'ids' == $fields )
|
else if ( 'ids' == $fields )
|
||||||
$select_this = 't.term_id, tt.parent, tt.count';
|
$selects = array('t.term_id', 'tt.parent', 'tt.count');
|
||||||
else if ( 'names' == $fields )
|
else if ( 'names' == $fields )
|
||||||
$select_this = 't.term_id, tt.parent, tt.count, t.name';
|
$selects = array('t.term_id', 'tt.parent', 'tt.count', 't.name');
|
||||||
|
$select_this = implode(', ', apply_filters( 'get_terms_fields', $selects, $args ));
|
||||||
|
|
||||||
$query = "SELECT $select_this FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ($in_taxonomies) $where ORDER BY $orderby $order $limit";
|
$query = "SELECT $select_this FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ($in_taxonomies) $where ORDER BY $orderby $order $limit";
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user