bb_get_topic_delete_link

The BuddyPress bb get topic delete link function.

Description

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

Parameters (1)

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

Usage

  1. if ( !function_exists( 'bb_get_topic_delete_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_delete_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_delete_link( $args = '' ) { 
  2. $defaults = array( 'id' => 0, 'before' => '[', 'after' => ']', 'delete_text' => false, 'undelete_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( 'delete_topic', $topic->topic_id ) ) 
  9. return; 
  10.  
  11. if ( 0 == $topic->topic_status ) { 
  12. if ( true === $redirect ) 
  13. $redirect = add_query_arg( bb_is_admin() ? array() : array( 'view' => 'all' ) ); 
  14.  
  15. $query = array( 'id' => $topic->topic_id, '_wp_http_referer' => $redirect ? rawurlencode( $redirect ) : false ); 
  16. $confirm = __('Are you sure you want to delete that?'); 
  17. $display = esc_html( $delete_text ? $delete_text : __('Delete entire topic') ); 
  18. } else { 
  19. if ( true === $redirect ) 
  20. $redirect = remove_query_arg( bb_is_admin() ? array() : 'view' ); 
  21.  
  22. $query = array('id' => $topic->topic_id, 'view' => 'all', '_wp_http_referer' => $redirect ? rawurlencode( $redirect ) : false ); 
  23. $confirm = __('Are you sure you want to undelete that?'); 
  24. $display = esc_html( $undelete_text ? $undelete_text : __('Undelete entire topic') ); 
  25. $uri = bb_get_uri('bb-admin/delete-topic.php', $query, BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN); 
  26. $uri = esc_url( bb_nonce_url( $uri, 'delete-topic_' . $topic->topic_id ) ); 
  27.  
  28. return $before . '<a href="' . $uri . '" onclick="return confirm(\'' . esc_js( $confirm ) . '\');">' . $display . '</a>' . $after;