Skip to:
Content

bbPress.org

Ticket #2931: 2931.diff

File 2931.diff, 3.9 KB (added by thebrandonallen, 4 years ago)
  • src/includes/forums/template.php

    diff --git a/src/includes/forums/template.php b/src/includes/forums/template.php
    index 9dc6b378..12374fa1 100644
    a b function bbp_forum_visibility( $forum_id = 0 ) { 
    15341534         * @uses get_post_status() To get the forum's status
    15351535         * @uses apply_filters() Calls 'bbp_get_forum_visibility' with the visibility
    15361536         *                        and forum id
    1537          * @return string Status of forum
     1537         * @return string Status of forum. Defaults to empty string.
    15381538         */
    15391539        function bbp_get_forum_visibility( $forum_id = 0 ) {
    15401540                $forum_id   = bbp_get_forum_id( $forum_id );
    1541                 $visibility = get_post_status( $forum_id );
     1541                $visibility = empty( $forum_id ) ? '' : get_post_status( $forum_id );
    15421542
    15431543                return apply_filters( 'bbp_get_forum_visibility', $visibility, $forum_id );
    15441544        }
    function bbp_is_forum_category( $forum_id = 0 ) { 
    16031603 * @return bool Whether the forum is open or not
    16041604 */
    16051605function bbp_is_forum_open( $forum_id = 0, $check_ancestors = true ) {
    1606         return ! bbp_is_forum_closed( $forum_id, $check_ancestors );
     1606        $forum_id = bbp_get_forum_id( $forum_id );
     1607        $open     = empty( $forum_id ) ? false : ( ! bbp_is_forum_closed( $forum_id, $check_ancestors ) );
     1608        return $open;
    16071609}
    16081610
    16091611/**
  • src/includes/replies/template.php

    diff --git a/src/includes/replies/template.php b/src/includes/replies/template.php
    index edb7b37e..7748a801 100644
    a b function bbp_reply_status( $reply_id = 0 ) { 
    903903         * @uses bbp_get_reply_id() To get the reply id
    904904         * @uses get_post_status() To get the reply status
    905905         * @uses apply_filters() Calls 'bbp_get_reply_status' with the reply id
    906          * @return string Status of reply
     906         * @return string Status of reply. Defaults to empty string.
    907907         */
    908908        function bbp_get_reply_status( $reply_id = 0 ) {
    909909                $reply_id = bbp_get_reply_id( $reply_id );
    910                 return apply_filters( 'bbp_get_reply_status', get_post_status( $reply_id ), $reply_id );
     910                $status   = empty( $reply_id ) ? '' : get_post_status( $reply_id );
     911
     912                return apply_filters( 'bbp_get_reply_status', $status, $reply_id );
    911913        }
    912914
    913915/**
    function bbp_is_reply_anonymous( $reply_id = 0 ) { 
    10021004        $reply_id = bbp_get_reply_id( $reply_id );
    10031005        $retval   = false;
    10041006
     1007        // Bail early if no reply id.
     1008        if ( empty( $reply_id ) ) {
     1009                return false;
     1010        }
     1011
    10051012        if ( ! bbp_get_reply_author_id( $reply_id ) ) {
    10061013                $retval = true;
    10071014
  • src/includes/topics/template.php

    diff --git a/src/includes/topics/template.php b/src/includes/topics/template.php
    index efe36e41..5ec2de87 100644
    a b function bbp_topic_status( $topic_id = 0 ) { 
    11431143         * @uses get_post_status() To get the topic status
    11441144         * @uses apply_filters() Calls 'bbp_get_topic_status' with the status
    11451145         *                        and topic id
    1146          * @return string Status of topic
     1146         * @return string Status of topic. Defaults to empty string.
    11471147         */
    11481148        function bbp_get_topic_status( $topic_id = 0 ) {
    11491149                $topic_id = bbp_get_topic_id( $topic_id );
     1150                $status   = empty( $topic_id ) ? '' : get_post_status( $topic_id );
    11501151
    1151                 return apply_filters( 'bbp_get_topic_status', get_post_status( $topic_id ), $topic_id );
     1152                return apply_filters( 'bbp_get_topic_status', $status, $topic_id );
    11521153        }
    11531154
    11541155/**
    function bbp_is_topic_closed( $topic_id = 0 ) { 
    11821183 * @return bool True if open, false if closed.
    11831184 */
    11841185function bbp_is_topic_open( $topic_id = 0 ) {
    1185         return ! bbp_is_topic_closed( $topic_id );
     1186        $topic_id = bbp_get_topic_id( $topic_id );
     1187        $closed   = empty( $topic_id ) ? false : ( ! bbp_is_topic_closed( $topic_id ) );
     1188        return $closed;
    11861189}
    11871190
    11881191/**
    function bbp_is_topic_anonymous( $topic_id = 0 ) { 
    12961299        $topic_id = bbp_get_topic_id( $topic_id );
    12971300        $retval   = false;
    12981301
     1302        // Bail early if no topic id.
     1303        if ( empty( $topic_id ) ) {
     1304                return false;
     1305        }
     1306
    12991307        if ( ! bbp_get_topic_author_id( $topic_id ) ) {
    13001308                $retval = true;
    13011309