Making WordPress.org

Changeset 8433


Ignore:
Timestamp:
03/09/2019 07:55:46 PM (6 years ago)
Author:
Otto42
Message:

Add a filter to undo topic title changes for replies to reviews. Fixes #4254

File:
1 edited

Legend:

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

    r8216 r8433  
    1111
    1212    var $filter = false;
     13
     14    var $old_title = null;
    1315
    1416    public function __construct( $args ) {
     
    150152     */
    151153    public function get_topic_title( $title, $topic_id ) {
     154
     155        // save the title
     156        $this->old_title = $title;
     157
    152158        if ( bbp_is_single_view() && 'reviews' == bbp_get_view_id() ) {
    153159            $user_id = bbp_get_topic_author_id( $topic_id );
     
    160166    }
    161167
     168    /**
     169     * Undo the above topic title change for specific cases
     170     *
     171     * @param string $title The topic title
     172     */
     173    public function undo_topic_title( $title ) {
     174        if ( !empty( $this->old_title ) ) {
     175            return $this->old_title;
     176        }
     177        return $title;
     178    }
     179
    162180    public function do_view_header() {
    163181        if ( ! bbp_is_single_view() || 'reviews' != bbp_get_view_id() ) {
     
    167185        // Add the filter for topic titles here.
    168186        add_filter( 'bbp_get_topic_title', array( $this, 'get_topic_title' ), 10, 2 );
    169         ?>
     187
     188        // Undo the above filter, for titles of replies to reviews. See #meta4254
     189        add_filter( 'bbp_get_topic_last_topic_title', array( $this, 'undo_topic_title' ), 10, 1 );
     190?>
    170191<link itemprop="applicationCategory" href="http://schema.org/OtherApplication" />
    171192<span itemprop="offers" itemscope itemtype="http://schema.org/Offer">
Note: See TracChangeset for help on using the changeset viewer.