mirror of
https://github.com/WordPress/five-for-the-future.git
synced 2025-07-06 10:45:44 +03:00
Pledge List: Show hours because it's a more meaningful statistic.
This commit is contained in:
parent
7273057950
commit
33d3bc1933
5 changed files with 28 additions and 18 deletions
|
@ -225,6 +225,7 @@ function filter_query( $query ) {
|
|||
}
|
||||
|
||||
$contributor_count_key = META_PREFIX . 'pledge-confirmed-contributors';
|
||||
$hours_count_key = META_PREFIX . 'pledge-total-hours';
|
||||
|
||||
// Set up meta queries to include the "valid pledge" check, added to both search and pledge archive requests.
|
||||
$meta_queries = (array) $query->get( 'meta_query' );
|
||||
|
@ -246,14 +247,15 @@ function filter_query( $query ) {
|
|||
// Archives should only show pledges with contributors.
|
||||
$query->set( 'meta_query', $meta_queries );
|
||||
$order = isset( $_GET['order'] ) ? $_GET['order'] : '';
|
||||
|
||||
switch ( $order ) {
|
||||
case 'alphabetical':
|
||||
$query->set( 'orderby', 'name' );
|
||||
$query->set( 'order', 'ASC' );
|
||||
break;
|
||||
|
||||
case 'contributors':
|
||||
$query->set( 'meta_key', $contributor_count_key );
|
||||
case 'hours':
|
||||
$query->set( 'meta_key', $hours_count_key );
|
||||
$query->set( 'orderby', 'meta_value_num' );
|
||||
$query->set( 'order', 'DESC' );
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue