Changeset 9857 for sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-ratings-compat.php
- Timestamp:
- 05/13/2020 03:31:34 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-ratings-compat.php
r9600 r9857 73 73 add_action( 'bbp_new_topic_post_extras', array( $this, 'topic_post_extras' ) ); 74 74 add_action( 'bbp_edit_topic_post_extras', array( $this, 'topic_post_extras' ) ); 75 76 // Add the rating to the Feed body/title 77 if ( did_action( 'bbp_feed' ) ) { 78 add_filter( 'bbp_get_topic_content', array( $this, 'feed_prepend_rating' ), 10, 2 ); 79 add_filter( 'bbp_get_topic_title', array( $this, 'feed_append_rating' ), 10, 2 ); 80 } 75 81 } 76 82 … … 440 446 return false; 441 447 } 448 449 /** 450 * Prepend the Rating to the feed content. 451 */ 452 public function feed_prepend_rating( $content, $topic_id ) { 453 if ( Plugin::REVIEWS_FORUM_ID == bbp_get_topic_forum_id( $topic_id ) ) { 454 $user_id = bbp_get_topic_author_id( $topic_id ); 455 $rating = \WPORG_Ratings::get_user_rating( $this->compat, $this->slug, $user_id ); 456 457 if ( $rating ) { 458 $content = sprintf( 459 "<p>%s</p>\n%s", 460 sprintf( 461 __( 'Rating: %s', 'wporg-forums' ), 462 sprintf( 463 _n( '%s star', '%s stars', $rating, 'wporg-forums' ), 464 $rating 465 ) 466 ), 467 $content 468 ); 469 } 470 } 471 472 return $content; 473 } 474 475 /** 476 * Append the Rating to the feed title. 477 */ 478 public function feed_append_rating( $title, $topic_id ) { 479 if ( Plugin::REVIEWS_FORUM_ID == bbp_get_topic_forum_id( $topic_id ) ) { 480 $user_id = bbp_get_topic_author_id( $topic_id ); 481 $rating = \WPORG_Ratings::get_user_rating( $this->compat, $this->slug, $user_id ); 482 483 if ( $rating ) { 484 $title = sprintf( 485 "%s (%s)", 486 $title, 487 sprintf( 488 _n( '%s star', '%s stars', $rating, 'wporg-forums' ), 489 $rating 490 ) 491 ); 492 } 493 } 494 495 return $title; 496 } 442 497 }
Note: See TracChangeset
for help on using the changeset viewer.