bbp_get_forum_topics_link( int $forum_id )

Return the topics link of the forum

Description

Parameters

$forum_id

(Optional) Topic id

Source

File: bp-forums/forums/template.php

1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
function bbp_get_forum_topics_link( $forum_id = 0 ) {
    $forum    = bbp_get_forum( $forum_id );
    $forum_id = $forum->ID;
    $topics   = sprintf( _n( '%s discussion', '%s discussions', bbp_get_forum_topic_count( $forum_id, true, false ), 'buddyboss' ), bbp_get_forum_topic_count( $forum_id ) );
    $retval   = '';
 
    // First link never has view=all
    if ( bbp_get_view_all( 'edit_others_topics' ) )
        $retval .= "<a href='" . esc_url( bbp_remove_view_all( bbp_get_forum_permalink( $forum_id ) ) ) . "'>" . esc_html( $topics ) . "</a>";
    else
        $retval .= esc_html( $topics );
 
    // Get deleted topics
    $deleted = bbp_get_forum_topic_count_hidden( $forum_id );
 
    // This forum has hidden topics
    if ( !empty( $deleted ) && current_user_can( 'edit_others_topics' ) ) {
 
        // Extra text
        $extra = sprintf( __( ' (+ %d hidden)', 'buddyboss' ), $deleted );
 
        // No link
        if ( bbp_get_view_all() ) {
            $retval .= " $extra";
 
        // Link
        } else {
            $retval .= " <a href='" . esc_url( bbp_add_view_all( bbp_get_forum_permalink( $forum_id ), true ) ) . "'>" . esc_html( $extra ) . "</a>";
        }
    }
 
    return apply_filters( 'bbp_get_forum_topics_link', $retval, $forum_id );
}

Changelog

Changelog
Version Description
bbPress (r2883) Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.