Changeset 3851 for sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-performance-optimizations.php
- Timestamp:
- 08/24/2016 01:15:18 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-performance-optimizations.php
r3846 r3851 22 22 if ( ! in_array( $view, array( 'plugin', 'theme', 'review' ) ) ) { 23 23 $r['date_query'] = array( 'after' => '19 months ago' ); 24 } else { 25 $term = self::get_term(); 26 27 // If there are a lot of results for a single plugin or theme, 28 // order by ID to avoid an INNER JOIN ON. 29 if ( $term && ! is_wp_error( $term ) && property_exists( $term, 'count' ) ) { 30 if ( $term->count > 10000 ) { 31 unset( $r['meta_key'] ); 32 unset( $r['meta_type'] ); 33 34 $r['orderby'] = 'ID'; 35 } 36 } 24 37 } 25 38 … … 35 48 unset( $r['meta_type'] ); 36 49 37 $r['orderby'] = 'post_date'; 50 // This only works because we don't edit dates on forum topics. 51 $r['orderby'] = 'ID'; 38 52 add_action( 'pre_get_posts', array( __CLASS__, 'pre_get_posts' ) ); 39 53 } … … 71 85 return $r; 72 86 } 87 88 /** 89 * Get the term for a plugin or theme view from query_var. 90 */ 91 public static function get_term() { 92 if ( ! empty( get_query_var( Plugin::get_instance()->plugins->query_var() ) ) ) { 93 $slug = Plugin::get_instance()->plugins->slug(); 94 $tax = Plugin::get_instance()->plugins->taxonomy(); 95 } elseif ( ! empty( get_query_var( Plugin::get_instance()->themes->query_var() ) ) ) { 96 $slug = Plugin::get_instance()->themes->slug(); 97 $tax = Plugin::get_instance()->themes->taxonomy(); 98 } 99 $term = get_term( $slug, $tax ); 100 return $term; 101 } 73 102 }
Note: See TracChangeset
for help on using the changeset viewer.