Skip to:
Content

bbPress.org

Changeset 3543


Ignore:
Timestamp:
10/10/2011 05:39:14 AM (15 years ago)
Author:
johnjamesjacoby
Message:

Use get_post_class() to fix premature echo of forum/topic/reply post classes. Fixes #1650.

Location:
branches/2.0/bbp-includes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0/bbp-includes/bbp-forum-template.php

    r3505 r3543  
    15801580 * @since bbPress (r2667)
    15811581 *
     1582 * @param int $forum_id Optional. Forum ID.
    15821583 * @uses bbp_get_forum_class() To get the row class of the forum
    15831584 */
    1584 function bbp_forum_class() {
    1585         echo bbp_get_forum_class();
     1585function bbp_forum_class( $forum_id = 0 ) {
     1586        echo bbp_get_forum_class( $forum_id );
    15861587}
    15871588        /**
     
    15901591         * @since bbPress (r2667)
    15911592         *
    1592          * @uses post_class() To get all the classes including ours
     1593         * @param int $forum_id Optional. Forum ID
     1594         * @uses get_post_class() To get all the classes including ours
    15931595         * @uses apply_filters() Calls 'bbp_get_forum_class' with the classes
    15941596         * @return string Row class of the forum
    15951597         */
    1596         function bbp_get_forum_class() {
     1598        function bbp_get_forum_class( $forum_id = 0 ) {
    15971599                global $bbp;
    15981600
     1601                $forum_id  = bbp_get_forum_id( $forum_id );
     1602                $count     = isset( $bbp->forum_query->current_post ) ? $bbp->forum_query->current_post : 1;
    15991603                $classes   = array();
    1600                 $classes[] = $bbp->forum_query->current_post % 2 ? 'even' : 'odd';
    1601                 $classes[] = bbp_is_forum_category() ? 'status-category' : '';
    1602                 $classes[] = bbp_is_forum_private()  ? 'status-private'  : '';
     1604                $classes[] = ( (int) $count % 2 )               ? 'even'            : 'odd';
     1605                $classes[] = bbp_is_forum_category( $forum_id ) ? 'status-category' : '';
     1606                $classes[] = bbp_is_forum_private( $forum_id )  ? 'status-private'  : '';
    16031607                $classes   = array_filter( $classes );
    1604 
    1605                 $post      = post_class( $classes );
    1606 
    1607                 return apply_filters( 'bbp_get_forum_class', $post );
     1608                $retval    = get_post_class( $classes, $forum_id );
     1609                $retval    = 'class="' . join( ' ', $retval ) . '"';
     1610
     1611                return apply_filters( 'bbp_get_forum_class', $retval, $forum_id );
    16081612        }
    16091613
  • branches/2.0/bbp-includes/bbp-reply-template.php

    r3540 r3543  
    17051705 *
    17061706 * @since bbPress (r2678)
    1707  */
    1708 function bbp_reply_class() {
    1709         echo bbp_get_reply_class();
     1707 *
     1708 * @param int $reply_id Optional. Reply ID
     1709 * @uses bbp_get_reply_class() To get the reply class
     1710 */
     1711function bbp_reply_class( $reply_id = 0 ) {
     1712        echo bbp_get_reply_class( $reply_id );
    17101713}
    17111714        /**
     
    17141717         * @since bbPress (r2678)
    17151718         *
    1716          * @uses post_class() To get all the classes including ours
     1719         * @param int $reply_id Optional. Reply ID
     1720         * @uses get_post_class() To get all the classes including ours
    17171721         * @uses apply_filters() Calls 'bbp_get_reply_class' with the classes
    17181722         * @return string Row class of the reply
    17191723         */
    1720         function bbp_get_reply_class() {
     1724        function bbp_get_reply_class( $reply_id = 0 ) {
    17211725                global $bbp;
    17221726
     1727                $reply_id  = bbp_get_reply_id( $reply_id );
    17231728                $count     = isset( $bbp->reply_query->current_post ) ? $bbp->reply_query->current_post : 1;
    1724                 $alternate = (int) $count % 2 ? 'even' : 'odd';
    1725                 $post      = post_class( array( $alternate ) );
    1726 
    1727                 return apply_filters( 'bbp_reply_class', $post );
     1729                $classes   = array();
     1730                $classes[] = ( (int) $count % 2 ) ? 'even' : 'odd';
     1731                $retval    = get_post_class( $classes, $reply_id );
     1732                $retval    = 'class="' . join( ' ', $retval ) . '"';
     1733
     1734                return apply_filters( 'bbp_get_reply_class', $retval, $reply_id );
    17281735        }
    17291736
  • branches/2.0/bbp-includes/bbp-topic-template.php

    r3540 r3543  
    19241924         * @uses bbp_is_topic_super_sticky() To check if the topic is a super
    19251925         *                                    sticky
    1926          * @uses post_class() To get the topic classes
     1926         * @uses get_post_class() To get the topic classes
    19271927         * @uses apply_filters() Calls 'bbp_get_topic_class' with the classes
    19281928         *                        and topic id
     
    19321932                global $bbp;
    19331933
     1934                $topic_id  = bbp_get_topic_id( $topic_id );
     1935                $count     = isset( $bbp->topic_query->current_post ) ? $bbp->topic_query->current_post : 1;
    19341936                $classes   = array();
    1935                 $classes[] = $bbp->topic_query->current_post % 2     ? 'even'         : 'odd';
     1937                $classes[] = ( (int) $count % 2 )                    ? 'even'         : 'odd';
    19361938                $classes[] = bbp_is_topic_sticky( $topic_id, false ) ? 'sticky'       : '';
    19371939                $classes[] = bbp_is_topic_super_sticky( $topic_id  ) ? 'super-sticky' : '';
    19381940                $classes   = array_filter( $classes );
    1939                 $post      = post_class( $classes, $topic_id );
    1940 
    1941                 return apply_filters( 'bbp_get_topic_class', $post, $topic_id );
     1941                $retval    = get_post_class( $classes, $topic_id );
     1942                $retval    = 'class="' . join( ' ', $retval ) . '"';
     1943
     1944                return apply_filters( 'bbp_get_topic_class', $retval, $topic_id );
    19421945        }
    19431946
Note: See TracChangeset for help on using the changeset viewer.