Skip to:
Content

BuddyPress.org

Changeset 5085


Ignore:
Timestamp:
09/01/2011 03:48:35 AM (13 years ago)
Author:
johnjamesjacoby
Message:

Fix bug where topic permalink would not calculate correctly in single topic view on some installations.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-forums/bp-forums-template.php

    r5083 r5085  
    540540}
    541541    function bp_get_the_topic_object_permalink() {
    542         global $bp, $forum_template;
    543542
    544543        // Currently this will only work with group forums, extended support in the future
    545544        if ( bp_is_active( 'groups' ) )
    546             $permalink = trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . $forum_template->topic->object_slug . '/forum/' );
     545            $permalink = trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . bp_get_the_topic_object_slug() . '/forum' );
    547546        else
    548547            $permalink = '';
     
    703702        global $forum_template, $bp;
    704703
    705         if ( bp_is_active( 'groups' ) && !empty( $forum_template->topic->object_slug ) )
    706             $permalink = trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . $forum_template->topic->object_slug . '/forum' );
    707         else if ( bp_is_single_item() )
     704        // The topic is in a loop where its parent object is loaded
     705        if ( bp_get_the_topic_object_slug() ) {
     706            $permalink = trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . bp_get_the_topic_object_slug() . '/forum' );
     707
     708        // We are viewing a single group topic, so use the current item
     709        } elseif ( bp_is_group_forum_topic() ) {
     710            $permalink = trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . bp_current_item() . '/forum' );
     711
     712        // We are unsure what the context is, so fallback to forum root slug
     713        } elseif ( bp_is_single_item() ) {
    708714            $permalink = trailingslashit( bp_get_root_domain() . '/' . bp_get_forums_root_slug() . '/' . bp_current_item() );
    709         else
     715
     716        // This is some kind of error situation, so use forum root
     717        } else {
    710718            $permalink = trailingslashit( bp_get_root_domain() . '/' . bp_get_forums_root_slug() );
     719        }
    711720
    712721        return apply_filters( 'bp_get_the_topic_permalink', trailingslashit( $permalink . 'topic/' . $forum_template->topic->topic_slug ) );
Note: See TracChangeset for help on using the changeset viewer.