Hi!
bbP has bbp_get_topic_close_link
function (defined in bbpress/includes/topics/template.php file) that outputs an anchor tag (<a>
). However customizing the anchor tag proved difficult so we ended up using a bit of custom code to output the link:
<?php if( is_singular( 'topic' ) && current_user_can( 'moderate' ) ) : ?>
<div class="post-note">
<?php
$topic = bbp_get_topic( bbp_get_topic_id() );
if( bbp_is_topic_open( $topic->ID ) ) {
$uri = add_query_arg( array( 'action' => 'bbp_toggle_topic_close', 'topic_id' => $topic->ID ) );
$uri = wp_nonce_url( $uri, 'close-topic_' . $topic->ID );
echo '<a href="' . esc_url( $uri ) . '" class="bbp-topic-close-link button green">Close Thread</a>';
}
?>
</div>
<?php endif; ?>