Changeset 1286
- Timestamp:
- 02/20/2015 02:29:04 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/theme-directory.php
r1274 r1286 104 104 $wp_query->set( 'paged', 1 ); 105 105 $wp_query->set( 'posts_per_page', 15 ); 106 $wp_query->set( 'date_query', array( 107 array( 108 'column' => 'post_modified_gmt', 109 'after' => '-1 year', 110 ), 111 ) ); 112 $wp_query->set( 'orderby', 'rand' ); 106 $wp_query->set( 'post__in', (array) wp_cache_get( 'browse-popular', 'theme-info' ) ); 113 107 break; 114 108 115 109 case 'popular': 116 //TODO: Sort by popularity.110 add_filter( 'posts_clauses', 'wporg_themes_popular_posts_clauses' ); 117 111 break; 118 112 119 113 case 'new': 114 // Nothing to do here. 120 115 break; 121 116 } … … 141 136 } 142 137 add_filter( 'found_posts', 'wporg_themes_found_posts', 10, 2 ); 138 139 /** 140 * Filters SQL clauses, to set up a query for the most popular themes based on downloads. 141 * 142 * @param array $clauses 143 * @return array 144 */ 145 function wporg_themes_popular_posts_clauses( $clauses ) { 146 global $wpdb; 147 148 $week = gmdate( 'Y-m-d', strtotime( 'last week' ) ); 149 $clauses['where'] .= " AND s.stamp >= '{$week}'"; 150 $clauses['groupby'] = "{$wpdb->posts}.ID"; 151 $clauses['join'] = "JOIN bb_themes_stats AS s ON ( {$wpdb->posts}.post_name = s.slug )"; 152 $clauses['orderby'] = 'week_downloads DESC'; 153 $clauses['fields'] .= ', SUM(s.downloads) AS week_downloads'; 154 155 return $clauses; 156 } 143 157 144 158 /**
Note: See TracChangeset
for help on using the changeset viewer.