Skip to:
Content

bbPress.org


Ignore:
Timestamp:
07/02/2024 04:11:29 PM (23 months ago)
Author:
johnjamesjacoby
Message:

Posts: strip "Protected/Private" for bbPress post types

This change prevents post title hints from being prepended to titles of Forums, Topics, or Replies, which was happening as a consequence of calling get_the_title() which assumes every protected/private post title needs it.

It does this by including the following code changes:

  • introduce the bbp_no_title_status_hints() filter function, which hooks into 2 WordPress filters and maybe overrides the return value
  • replace a few get_the_title() calls with get_post_field( 'post_title' ) to bypass the above filters when they would never be desirable

Committer note: this could be considered a small back-compat break (because it alters long-standing theme-side output) but ultimately it is a design decision to output all of the forum content as it was saved by the community members. Forums that prefer the old behavior can unhook bbp_no_title_status_hints and continue to customize child template parts to insert custom forum status hints.

Fixes #3602.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/replies/template.php

    r7268 r7276  
    524524    function bbp_get_reply_title( $reply_id = 0 ) {
    525525        $reply_id = bbp_get_reply_id( $reply_id );
    526         $title    = get_the_title( $reply_id );
     526        $title    = get_post_field( 'post_title', $reply_id );
     527        $title    = apply_filters( 'the_title', $title, $reply_id );
    527528
    528529        // Filter & return
     
    14011402        $reply_id = bbp_get_reply_id( $reply_id );
    14021403        $topic_id = bbp_get_reply_topic_id( $reply_id );
    1403 
    1404         // Filter & return
    1405         return apply_filters( 'bbp_get_reply_topic_title', bbp_get_topic_title( $topic_id ), $reply_id );
     1404        $title    = bbp_get_topic_title( $topic_id );
     1405
     1406        // Filter & return
     1407        return apply_filters( 'bbp_get_reply_topic_title', $title, $reply_id );
    14061408    }
    14071409
Note: See TracChangeset for help on using the changeset viewer.