bb_get_topic_close_link

The BuddyPress bb get topic close link function.

Description

bb_get_topic_close_link( (string) $args = '' ); 

Parameters (1)

0. $args — Optional. (string) => ''
The args.

Usage

  1. if ( !function_exists( 'bb_get_topic_close_link' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/functions.bb-template.php'; 
  3.  
  4. // The args. 
  5. $args = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bb_get_topic_close_link($args); 
  9.  

Defined (1)

The function is defined in the following location(s).

/bp-forums/bbpress/bb-includes/functions.bb-template.php  
  1. function bb_get_topic_close_link( $args = '' ) { 
  2. $defaults = array( 'id' => 0, 'before' => '[', 'after' => ']', 'close_text' => false, 'open_text' => false, 'redirect' => true ); 
  3. extract(wp_parse_args( $args, $defaults ), EXTR_SKIP); 
  4. $id = (int) $id; 
  5.  
  6. $topic = get_topic( get_topic_id( $id ) ); 
  7.  
  8. if ( !$topic || !bb_current_user_can( 'close_topic', $topic->topic_id ) ) 
  9. return; 
  10.  
  11. if ( topic_is_open( $topic->topic_id ) ) 
  12. $display = esc_html( $close_text ? $close_text : __( 'Close topic' ) ); 
  13. else 
  14. $display = esc_html( $open_text ? $open_text : __( 'Open topic' ) ); 
  15.  
  16. if ( true === $redirect ) 
  17. $redirect = $_SERVER['REQUEST_URI']; 
  18.  
  19. $uri = bb_get_uri('bb-admin/topic-toggle.php', array( 'id' => $topic->topic_id, '_wp_http_referer' => $redirect ? rawurlencode( $redirect ) : false ), BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN); 
  20. $uri = esc_url( bb_nonce_url( $uri, 'close-topic_' . $topic->topic_id ) ); 
  21.  
  22. return $before . '<a href="' . $uri . '">' . $display . '</a>' . $after;