Changeset 3499 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php
- Timestamp:
- 06/20/2016 01:04:32 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php
r3498 r3499 416 416 */ 417 417 public function use_plugins_in_query( $wp_query ) { 418 if ( is_admin() || ! $wp_query->is_main_query()) {418 if ( is_admin() ) { 419 419 return; 420 420 } … … 429 429 } 430 430 431 switch ( get_query_var( 'browse' )) {431 switch ( $wp_query->query_vars['browse'] ) { 432 432 case 'favorites': 433 433 $favorites_user = wp_get_current_user(); … … 451 451 } 452 452 453 add_filter( 'posts_where', array( $this, 'pre_get_posts_sql_browse' ) );454 453 break; 455 454 456 455 case 'new': 457 case 'popular': 458 add_filter( 'posts_where', array( $this, 'pre_get_posts_sql_browse' ) ); 456 $wp_query->query_vars['orderby'] = 'post_modified'; 459 457 break; 460 458 } 461 459 462 if ( $wp_query->is_archive() && ! $wp_query->is_tax( 'plugin_section', 'new' ) && empty( $wp_query->query_vars['orderby'] ) ) { 460 if ( isset( $wp_query->query['browse'] ) ) { 461 if ( 'beta' != $wp_query->query['browse'] && 'featured' != $wp_query->query['browse'] ) { 462 unset( $wp_query->query_vars['browse'] ); 463 464 add_filter( 'the_posts', function( $posts, $wp_query ) { 465 // Fix the queried object for the archive view 466 if ( ! $wp_query->queried_object && isset( $wp_query->query['browse'] ) ) { 467 $wp_query->query_vars['browse'] = $wp_query->query['browse']; 468 $wp_query->queried_object = get_term_by( 'slug', $wp_query->query['browse'], 'plugin_section' ); 469 } 470 return $posts; 471 }, 10, 2 ); 472 473 } 474 } 475 476 if ( empty( $wp_query->query_vars['orderby'] ) ) { 463 477 $wp_query->query_vars['orderby'] = 'meta_value_num'; 464 478 $wp_query->query_vars['meta_key'] = '_active_installs'; 465 479 } 466 }467 468 /**469 * Callback to remove the requirement for plugins to be tagged with the requested470 * plugin_section term.471 *472 * Used for archives like `popular` or `favorites`, that all active plugins are a part of.473 *474 * @ignore475 *476 * @param string $where WHERE clause.477 * @return string478 */479 public function pre_get_posts_sql_browse( $where ) {480 global $wpdb;481 482 remove_filter( 'posts_where', array( $this, 'pre_get_posts_sql_browse' ) );483 484 $term = get_term_by( 'slug', get_query_var( 'browse' ), 'plugin_section' );485 486 if ( $term instanceof \WP_Term ) {487 $where = str_replace( " AND ( \n {$wpdb->term_relationships}.term_taxonomy_id IN ({$term->term_id})\n)", '', $where );488 }489 490 return $where;491 480 } 492 481
Note: See TracChangeset
for help on using the changeset viewer.