function bbppt_get_forum_parent_id($forum_id = 0)
{
    if (function_exists('bbp_get_forum_parent_id')) {
        return bbp_get_forum_parent_id($forum_id);
    }
    return bbp_get_forum_parent($forum_id);
}
/**
 * Gets the items for the breadcrumb trail if bbPress is installed.
 *
 * @since 0.5.0
 * @access private
 * @param array $args Mixed arguments for the menu.
 * @return array List of items to be shown in the trail.
 */
function breadcrumb_trail_get_bbpress_items($args = array())
{
    /* Set up a new trail items array. */
    $trail = array();
    /* Get the forum post type object. */
    $post_type_object = get_post_type_object(bbp_get_forum_post_type());
    /* If not viewing the forum root/archive page and a forum archive exists, add it. */
    if (!empty($post_type_object->has_archive) && !bbp_is_forum_archive()) {
        $trail[] = '<a href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '">' . bbp_get_forum_archive_title() . '</a>';
    }
    /* If viewing the forum root/archive. */
    if (bbp_is_forum_archive()) {
        $trail[] = bbp_get_forum_archive_title();
    } elseif (bbp_is_topic_archive()) {
        $trail[] = bbp_get_topic_archive_title();
    } elseif (bbp_is_topic_tag()) {
        $trail[] = bbp_get_topic_tag_name();
    } elseif (bbp_is_topic_tag_edit()) {
        $trail[] = '<a href="' . bbp_get_topic_tag_link() . '">' . bbp_get_topic_tag_name() . '</a>';
        $trail[] = __('Edit', 'breadcrumb-trail');
    } elseif (bbp_is_single_view()) {
        $trail[] = bbp_get_view_title();
    } elseif (bbp_is_single_topic()) {
        /* Get the queried topic. */
        $topic_id = get_queried_object_id();
        /* Get the parent items for the topic, which would be its forum (and possibly forum grandparents). */
        $trail = array_merge($trail, breadcrumb_trail_get_parents(bbp_get_topic_forum_id($topic_id)));
        /* If viewing a split, merge, or edit topic page, show the link back to the topic.  Else, display topic title. */
        if (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) {
            $trail[] = '<a href="' . bbp_get_topic_permalink($topic_id) . '">' . bbp_get_topic_title($topic_id) . '</a>';
        } else {
            $trail[] = bbp_get_topic_title($topic_id);
        }
        /* If viewing a topic split page. */
        if (bbp_is_topic_split()) {
            $trail[] = __('Split', 'breadcrumb-trail');
        } elseif (bbp_is_topic_merge()) {
            $trail[] = __('Merge', 'breadcrumb-trail');
        } elseif (bbp_is_topic_edit()) {
            $trail[] = __('Edit', 'breadcrumb-trail');
        }
    } elseif (bbp_is_single_reply()) {
        /* Get the queried reply object ID. */
        $reply_id = get_queried_object_id();
        /* Get the parent items for the reply, which should be its topic. */
        $trail = array_merge($trail, breadcrumb_trail_get_parents(bbp_get_reply_topic_id($reply_id)));
        /* If viewing a reply edit page, link back to the reply. Else, display the reply title. */
        if (bbp_is_reply_edit()) {
            $trail[] = '<a href="' . bbp_get_reply_url($reply_id) . '">' . bbp_get_reply_title($reply_id) . '</a>';
            $trail[] = __('Edit', 'breadcrumb-trail');
        } else {
            $trail[] = bbp_get_reply_title($reply_id);
        }
    } elseif (bbp_is_single_forum()) {
        /* Get the queried forum ID and its parent forum ID. */
        $forum_id = get_queried_object_id();
        $forum_parent_id = bbp_get_forum_parent($forum_id);
        /* If the forum has a parent forum, get its parent(s). */
        if (0 !== $forum_parent_id) {
            $trail = array_merge($trail, breadcrumb_trail_get_parents($forum_parent_id));
        }
        /* Add the forum title to the end of the trail. */
        $trail[] = bbp_get_forum_title($forum_id);
    } elseif (bbp_is_single_user() || bbp_is_single_user_edit()) {
        if (bbp_is_single_user_edit()) {
            $trail[] = '<a href="' . bbp_get_user_profile_url() . '">' . bbp_get_displayed_user_field('display_name') . '</a>';
            $trail[] = __('Edit', 'breadcrumb-trail');
        } else {
            $trail[] = bbp_get_displayed_user_field('display_name');
        }
    }
    /* Return the bbPress breadcrumb trail items. */
    return apply_filters('breadcrumb_trail_get_bbpress_items', $trail, $args);
}
/**
 * Gets the items for the breadcrumb item if bbPress is installed.
 *
 * @since 0.4
 *
 * @param array $args Mixed arguments for the menu.
 * @return array List of items to be shown in the item.
 */
function breadcrumbs_plus_get_bbpress_items($args = array())
{
    $item = array();
    $post_type_object = get_post_type_object(bbp_get_forum_post_type());
    if (!empty($post_type_object->has_archive) && !bbp_is_forum_archive()) {
        $item[] = '<a href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '">' . bbp_get_forum_archive_title() . '</a>';
    }
    if (bbp_is_forum_archive()) {
        $item[] = bbp_get_forum_archive_title();
    } elseif (bbp_is_topic_archive()) {
        $item[] = bbp_get_topic_archive_title();
    } elseif (bbp_is_single_view()) {
        $item[] = bbp_get_view_title();
    } elseif (bbp_is_single_topic()) {
        $topic_id = get_queried_object_id();
        $item = array_merge($item, breadcrumbs_plus_get_parents(bbp_get_topic_forum_id($topic_id)));
        if (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) {
            $item[] = '<a href="' . bbp_get_topic_permalink($topic_id) . '">' . bbp_get_topic_title($topic_id) . '</a>';
        } else {
            $item[] = bbp_get_topic_title($topic_id);
        }
        if (bbp_is_topic_split()) {
            $item[] = __('Split', 'theme_front');
        } elseif (bbp_is_topic_merge()) {
            $item[] = __('Merge', 'theme_front');
        } elseif (bbp_is_topic_edit()) {
            $item[] = __('Edit', 'theme_front');
        }
    } elseif (bbp_is_single_reply()) {
        $reply_id = get_queried_object_id();
        $item = array_merge($item, breadcrumbs_plus_get_parents(bbp_get_reply_topic_id($reply_id)));
        if (!bbp_is_reply_edit()) {
            $item[] = bbp_get_reply_title($reply_id);
        } else {
            $item[] = '<a href="' . bbp_get_reply_url($reply_id) . '">' . bbp_get_reply_title($reply_id) . '</a>';
            $item[] = __('Edit', 'theme_front');
        }
    } elseif (bbp_is_single_forum()) {
        $forum_id = get_queried_object_id();
        $forum_parent_id = bbp_get_forum_parent($forum_id);
        if (0 !== $forum_parent_id) {
            $item = array_merge($item, breadcrumbs_plus_get_parents($forum_parent_id));
        }
        $item[] = bbp_get_forum_title($forum_id);
    } elseif (bbp_is_single_user() || bbp_is_single_user_edit()) {
        if (bbp_is_single_user_edit()) {
            $item[] = '<a href="' . bbp_get_user_profile_url() . '">' . bbp_get_displayed_user_field('display_name') . '</a>';
            $item[] = __('Edit');
        } else {
            $item[] = bbp_get_displayed_user_field('display_name');
        }
    }
    return apply_filters('breadcrumbs_plus_get_bbpress_items', $item, $args);
}