Skip to:
Content

bbPress.org


Ignore:
Timestamp:
04/01/2011 03:00:10 AM (15 years ago)
Author:
johnjamesjacoby
Message:

Improve logic behind setting the current_forum/topic/reply_id global variables

File:
1 edited

Legend:

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

    r2970 r2972  
    293293         */
    294294        function bbp_get_topic_id( $topic_id = 0 ) {
    295                 global $bbp, $wp_query, $bbp;
     295                global $bbp, $wp_query;
    296296
    297297                // Easy empty checking
     
    305305                // Currently viewing a topic
    306306                elseif ( ( bbp_is_topic() || bbp_is_topic_edit() ) && isset( $wp_query->post->ID ) )
    307                         $bbp_topic_id = $wp_query->post->ID;
     307                        $bbp_topic_id = $bbp->current_topic_id = $wp_query->post->ID;
     308
     309                // Currently viewing a topic
     310                elseif ( bbp_is_reply() )
     311                        $bbp_topic_id = $bbp->current_topic_id = bbp_get_reply_topic_id();
    308312
    309313                // Fallback
     
    311315                        $bbp_topic_id = 0;
    312316
    313                 $bbp->current_topic_id = $bbp_topic_id;
     317                // Check if current_reply_id is set, and check post_type if so
     318                if ( !empty( $bbp->current_topic_id ) && ( bbp_get_topic_post_type() != get_post_field( 'post_type', $bbp_topic_id ) ) )
     319                        $bbp->current_topic_id = null;
    314320
    315321                return apply_filters( 'bbp_get_topic_id', (int) $bbp_topic_id, $topic_id );
Note: See TracChangeset for help on using the changeset viewer.