bbp_get_topic_close_link( array $args = array() )
Return the close link of the topic
Description Description
Parameters Parameters
- $args
-
(Optional) This function supports these args: - id: Optional. Topic id - link_before: Before the link - link_after: After the link - close_text: Close text - open_text: Open text
Default value: array()
Return Return
(string) Topic close link
Source Source
File: includes/topics/template.php
function bbp_get_topic_close_link( $args = array() ) {
// Parse arguments against default values
$r = bbp_parse_args( $args, array(
'id' => 0,
'link_before' => '',
'link_after' => '',
'sep' => ' | ',
'close_text' => esc_html_x( 'Close', 'Close the topic', 'bbpress' ),
'open_text' => esc_html_x( 'Open', 'Open the topic', 'bbpress' )
), 'get_topic_close_link' );
// Get topic
$topic = bbp_get_topic( $r['id'] );
// Bail if no topic or current user cannot moderate
if ( empty( $topic ) || ! current_user_can( 'moderate', $topic->ID ) ) {
return;
}
$display = bbp_is_topic_open( $topic->ID ) ? $r['close_text'] : $r['open_text'];
$uri = add_query_arg( array( 'action' => 'bbp_toggle_topic_close', 'topic_id' => $topic->ID ) );
$uri = wp_nonce_url( $uri, 'close-topic_' . $topic->ID );
$retval = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" class="bbp-topic-close-link">' . $display . '</a>' . $r['link_after'];
// Filter & return
return apply_filters( 'bbp_get_topic_close_link', $retval, $r, $args );
}
Changelog Changelog
| Version | Description |
|---|---|
| 2.0.0 | Introduced. |