bbp_get_reply_admin_links( array $args = array() )

Return admin links for reply

Description

Parameters

$args

(Optional) This function supports these arguments: - id: Optional. Reply id - before: HTML before the links. Defaults to <span class="bbp-admin-links"> - after: HTML after the links. Defaults to </span> - sep: Separator. Defaults to ' | ' - links: Array of the links to display. By default, edit, trash, spam, reply move, and topic split links are displayed

Default value: array()

Return

(string) Reply admin links

Source

File: bp-forums/replies/template.php

1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
function bbp_get_reply_admin_links( $args = array() ) {
 
    // Parse arguments against default values
    $r = bbp_parse_args( $args, array(
        'id'     => 0,
        'before' => '<span class="bbp-admin-links">',
        'after'  => '</span>',
        'sep'    => ' | ',
        'links'  => array()
    ), 'get_reply_admin_links' );
 
    $r['id'] = bbp_get_reply_id( (int) $r['id'] );
 
    // If post is a topic, return the topic admin links instead
    if ( bbp_is_topic( $r['id'] ) ) {
        return bbp_get_topic_admin_links( $args );
    }
 
    // If post is not a reply, return
    if ( !bbp_is_reply( $r['id'] ) ) {
        return;
    }
 
    // If topic is trashed, do not show admin links
    if ( bbp_is_topic_trash( bbp_get_reply_topic_id( $r['id'] ) ) ) {
        return;
    }
 
    // If no links were passed, default to the standard
    if ( empty( $r['links'] ) ) {
        $r['links'] = apply_filters( 'bbp_reply_admin_links', array(
            'edit'  => bbp_get_reply_edit_link ( $r ),
            'move'  => bbp_get_reply_move_link ( $r ),
            'split' => bbp_get_topic_split_link( $r ),
            'trash' => bbp_get_reply_trash_link( $r ),
            'spam'  => bbp_get_reply_spam_link ( $r ),
            'reply' => bbp_get_reply_to_link   ( $r )
        ), $r['id'] );
    }
 
    // See if links need to be unset
    $reply_status = bbp_get_reply_status( $r['id'] );
    if ( in_array( $reply_status, array( bbp_get_spam_status_id(), bbp_get_trash_status_id() ) ) ) {
 
        // Spam link shouldn't be visible on trashed topics
        if ( bbp_get_trash_status_id() === $reply_status ) {
            unset( $r['links']['spam'] );
 
        // Trash link shouldn't be visible on spam topics
        } elseif ( bbp_get_spam_status_id() === $reply_status ) {
            unset( $r['links']['trash'] );
        }
    }
 
    // Process the admin links
    $links  = implode( $r['sep'], array_filter( $r['links'] ) );
    $retval = $r['before'] . $links . $r['after'];
 
    return apply_filters( 'bbp_get_reply_admin_links', $retval, $r, $args );
}

Changelog

Changelog
Version Description
bbPress (r2667) 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.