Making WordPress.org

Changeset 13509


Ignore:
Timestamp:
04/12/2024 04:18:08 AM (2 years ago)
Author:
dd32
Message:

Support Forums: Ratings: Only adjust the Topic queries with the ratings join.

This previously adjusted all WP_Query instances, which caused queries for WordPress core post types to fail on filtered review views.

See [13489].

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-ratings-compat.php

    r13489 r13509  
    4545                        }
    4646                        $this->filter = $filter;
    47                         add_filter( 'posts_clauses', array( $this, 'add_filter_to_posts_clauses' ) );
     47                        add_filter( 'posts_clauses', array( $this, 'add_filter_to_posts_clauses' ), 10, 2 );
    4848                        add_action( 'pre_get_posts', array( $this, 'no_found_rows' ) );
    4949                        add_filter( 'bbp_topic_pagination', array( $this, 'add_filter_topic_pagination' ) );
    5050
    5151                        // <meta robots="noindex,follow"> for filtered views.
    52                         add_filter( 'wp_head', 'wp_no_robots' );
     52                        add_filter( 'wp_robots', 'wp_robots_no_robots' );
    5353                }
    5454
     
    9494         * Allow ratings view to be filtered by star rating.
    9595         */
    96         public function add_filter_to_posts_clauses( $clauses ) {
     96        public function add_filter_to_posts_clauses( $clauses, $query ) {
    9797                global $wpdb;
    9898
    99                 if ( false !== strpos( $clauses['where'], ".post_type = 'wp_navigation' " ) ) {
     99                // Only adjust topic queries.
     100                if ( ! in_array( bbp_get_topic_post_type(), (array) $query->get( 'post_type' ) ) ) {
    100101                        return $clauses;
    101102                }
Note: See TracChangeset for help on using the changeset viewer.