Making WordPress.org

Changeset 13582


Ignore:
Timestamp:
04/22/2024 04:04:11 AM (7 weeks ago)
Author:
dd32
Message:

Support Forums: Reviews: Track the review rating with the topic, rather than the shared ratings table.

Users can have their reviews moderated / hidden if they violate the forum guidelines, and subsequent reviews will replace the users review for all reviews instead of just the new one.
This allows us to keep a history of the rating for a review, even if a newer review from the user has a different rating.

See #4275, #7064.

File:
1 edited

Legend:

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

    r13580 r13582  
    123123        if ( bbp_is_single_topic() && Plugin::REVIEWS_FORUM_ID == bbp_get_topic_forum_id() ) {
    124124            $user_id = bbp_get_topic_author_id();
    125             $rating = \WPORG_Ratings::get_user_rating( $this->compat, $this->slug, $user_id );
     125            $rating  = get_post_meta( $topic_id, 'rating', true ) ?: \WPORG_Ratings::get_user_rating( $this->compat, $this->slug, $user_id );
    126126            if ( $rating > 0 ) {
    127127                echo \WPORG_Ratings::get_dashicons_stars( $rating );
     
    175175        if ( bbp_is_single_view() && 'reviews' == bbp_get_view_id() ) {
    176176            $user_id = bbp_get_topic_author_id( $topic_id );
    177             $rating = \WPORG_Ratings::get_user_rating( $this->compat, $this->slug, $user_id );
     177            $rating  = get_post_meta( $topic_id, 'rating', true ) ?: \WPORG_Ratings::get_user_rating( $this->compat, $this->slug, $user_id );
    178178            if ( $rating > 0 ) {
    179179                $title .= ' ' . \WPORG_Ratings::get_dashicons_stars( $rating );
     
    349349                $rating
    350350            );
     351
     352            // Store it against the review post for later use.
     353            update_post_meta( $topic_id, 'rating', $rating );
    351354        }
    352355    }
     
    558561        if ( Plugin::REVIEWS_FORUM_ID == bbp_get_topic_forum_id( $topic_id ) ) {
    559562            $user_id = bbp_get_topic_author_id( $topic_id );
    560             $rating = \WPORG_Ratings::get_user_rating( $this->compat, $this->slug, $user_id );
     563            $rating  = get_post_meta( $topic_id, 'rating', true ) ?: \WPORG_Ratings::get_user_rating( $this->compat, $this->slug, $user_id );
    561564
    562565            if ( $rating ) {
     
    584587        if ( Plugin::REVIEWS_FORUM_ID == bbp_get_topic_forum_id( $topic_id ) ) {
    585588            $user_id = bbp_get_topic_author_id( $topic_id );
    586             $rating = \WPORG_Ratings::get_user_rating( $this->compat, $this->slug, $user_id );
     589            $rating  = get_post_meta( $topic_id, 'rating', true ) ?: \WPORG_Ratings::get_user_rating( $this->compat, $this->slug, $user_id );
    587590
    588591            if ( $rating ) {
Note: See TracChangeset for help on using the changeset viewer.