bbp_get_topic_close_link

Return the close link of the topic.

Description

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

Returns (string)

Topic close link

Parameters (1)

0. $args — Optional. (string) => ''
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

Usage

  1. if ( !function_exists( 'bbp_get_topic_close_link' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/topics/template.php'; 
  3. $args = ''; 
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bbp_get_topic_close_link($args); 
  7.  

Defined (1)

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

/includes/topics/template.php  
  1. function bbp_get_topic_close_link( $args = '' ) { 
  2.  
  3. // Parse arguments against default values 
  4. $r = bbp_parse_args( $args, array( 
  5. 'id' => 0,  
  6. 'link_before' => '',  
  7. 'link_after' => '',  
  8. 'sep' => ' | ',  
  9. 'close_text' => _x( 'Close', 'Topic Status', bbpress ),  
  10. 'open_text' => _x( 'Open', 'Topic Status', bbpress ) 
  11. ), 'get_topic_close_link' ); 
  12.  
  13. $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) ); 
  14.  
  15. if ( empty( $topic ) || !current_user_can( 'moderate', $topic->ID ) ) 
  16. return; 
  17.  
  18. $display = bbp_is_topic_open( $topic->ID ) ? $r['close_text'] : $r['open_text']; 
  19. $uri = add_query_arg( array( 'action' => 'bbp_toggle_topic_close', 'topic_id' => $topic->ID ) ); 
  20. $uri = wp_nonce_url( $uri, 'close-topic_' . $topic->ID ); 
  21. $retval = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" class="bbp-topic-close-link">' . $display . '</a>' . $r['link_after']; 
  22.  
  23. return apply_filters( 'bbp_get_topic_close_link', $retval, $r );