Skip to:
Content

bbPress.org


Ignore:
Timestamp:
03/16/2012 05:26:49 AM (13 years ago)
Author:
johnjamesjacoby
Message:

Add missing filters to some topic template tags.

  • Remove inline logic from within some apply_filters() calls
  • Props MZAWeb for initial patch
  • Fixes #1787
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-topic-template.php

    r3785 r3805  
    924924     * @param int $topic_id Optional. Topic id
    925925     * @uses bbp_get_topic_status() To get the topic status
     926     * @uses apply_filters() Calls 'bbp_is_topic_closed' with the topic id
     927     *
    926928     * @return bool True if closed, false if not.
    927929     */
    928930    function bbp_is_topic_closed( $topic_id = 0 ) {
    929         if ( bbp_get_closed_status_id() == bbp_get_topic_status( $topic_id ) )
    930             return true;
    931 
    932         return false;
     931        $closed = bbp_get_topic_status( $topic_id ) == bbp_get_closed_status_id();
     932        return (bool) apply_filters( 'bbp_is_topic_closed', (bool) $closed, $topic_id );
    933933    }
    934934
     
    984984 * @uses bbp_get_topic_id() To get the topic id
    985985 * @uses bbp_get_topic_status() To get the topic status
     986 * @uses apply_filters() Calls 'bbp_is_topic_published' with the topic id
    986987 * @return bool True if published, false if not.
    987988 */
    988989function bbp_is_topic_published( $topic_id = 0 ) {
    989     $topic_status = bbp_get_topic_status( bbp_get_topic_id( $topic_id ) );
    990     return bbp_get_public_status_id() == $topic_status;
     990    $topic_status = bbp_get_topic_status( bbp_get_topic_id( $topic_id ) ) == bbp_get_public_status_id();
     991    return (bool) apply_filters( 'bbp_is_topic_published', (bool) $topic_status, $topic_id );
    991992}
    992993
     
    9991000 * @uses bbp_get_topic_id() To get the topic id
    10001001 * @uses bbp_get_topic_status() To get the topic status
     1002 * @uses apply_filters() Calls 'bbp_is_topic_spam' with the topic id
    10011003 * @return bool True if spam, false if not.
    10021004 */
    10031005function bbp_is_topic_spam( $topic_id = 0 ) {
    1004     $topic_status = bbp_get_topic_status( bbp_get_topic_id( $topic_id ) );
    1005     return bbp_get_spam_status_id() == $topic_status;
     1006    $topic_status = bbp_get_topic_status( bbp_get_topic_id( $topic_id ) ) == bbp_get_spam_status_id();
     1007    return (bool) apply_filters( 'bbp_is_topic_spam', (bool) $topic_status, $topic_id );
    10061008}
    10071009
     
    10141016 * @uses bbp_get_topic_id() To get the topic id
    10151017 * @uses bbp_get_topic_status() To get the topic status
     1018 * @uses apply_filters() Calls 'bbp_is_topic_trash' with the topic id
    10161019 * @return bool True if trashed, false if not.
    10171020 */
    10181021function bbp_is_topic_trash( $topic_id = 0 ) {
    1019     $topic_status = bbp_get_topic_status( bbp_get_topic_id( $topic_id ) );
    1020     return bbp_get_trash_status_id() == $topic_status;
     1022    $topic_status = bbp_get_topic_status( bbp_get_topic_id( $topic_id ) ) == bbp_get_trash_status_id();
     1023    return (bool) apply_filters( 'bbp_is_topic_trash', (bool) $topic_status, $topic_id );
    10211024}
    10221025
     
    10301033 * @uses bbp_get_topic_author_id() To get the topic author id
    10311034 * @uses get_post_meta() To get the anonymous user name and email meta
     1035 * @uses apply_filters() Calls 'bbp_is_topic_anonymous' with the topic id
    10321036 * @return bool True if the post is by an anonymous user, false if not.
    10331037 */
    10341038function bbp_is_topic_anonymous( $topic_id = 0 ) {
    10351039    $topic_id = bbp_get_topic_id( $topic_id );
    1036 
    1037     if ( 0 != bbp_get_topic_author_id( $topic_id ) )
    1038         return false;
    1039 
    1040     if ( false == get_post_meta( $topic_id, '_bbp_anonymous_name', true ) )
    1041         return false;
    1042 
    1043     if ( false == get_post_meta( $topic_id, '_bbp_anonymous_email', true ) )
    1044         return false;
     1040    $retval   = false;
     1041
     1042    if ( !bbp_get_topic_author_id( $topic_id ) )
     1043        $retval = true;
     1044
     1045    elseif ( get_post_meta( $topic_id, '_bbp_anonymous_name',  true ) )
     1046        $retval = true;
     1047
     1048    elseif ( get_post_meta( $topic_id, '_bbp_anonymous_email', true ) )
     1049        $retval = true;
    10451050
    10461051    // The topic is by an anonymous user
    1047     return true;
     1052    return (bool) apply_filters( 'bbp_is_topic_anonymous', $retval, $topic_id );
    10481053}
    10491054
Note: See TracChangeset for help on using the changeset viewer.