bbp_get_topic_trash_link

Return the trash link of the topic.

Description

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

Returns (string)

Topic trash 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 - sep: Links separator - trash_text: Trash text - restore_text: Restore text - delete_text: Delete text

Usage

  1. if ( !function_exists( 'bbp_get_topic_trash_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_trash_link($args); 
  7.  

Defined (1)

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

/includes/topics/template.php  
  1. function bbp_get_topic_trash_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. 'trash_text' => esc_html__( 'Trash', bbpress ),  
  10. 'restore_text' => esc_html__( 'Restore', bbpress ),  
  11. 'delete_text' => esc_html__( 'Delete', bbpress ) 
  12. ), 'get_topic_trash_link' ); 
  13.  
  14. $actions = array(); 
  15. $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) ); 
  16.  
  17. if ( empty( $topic ) || !current_user_can( 'delete_topic', $topic->ID ) ) { 
  18. return; 
  19.  
  20. if ( bbp_is_topic_trash( $topic->ID ) ) { 
  21. $actions['untrash'] = '<a title="' . esc_attr__( 'Restore this item from the Trash', bbpress ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_topic_trash', 'sub_action' => 'untrash', 'topic_id' => $topic->ID ) ), 'untrash-' . $topic->post_type . '_' . $topic->ID ) ) . '" class="bbp-topic-restore-link">' . $r['restore_text'] . '</a>'; 
  22. } elseif ( EMPTY_TRASH_DAYS ) { 
  23. $actions['trash'] = '<a title="' . esc_attr__( 'Move this item to the Trash', bbpress ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_topic_trash', 'sub_action' => 'trash', 'topic_id' => $topic->ID ) ), 'trash-' . $topic->post_type . '_' . $topic->ID ) ) . '" class="bbp-topic-trash-link">' . $r['trash_text'] . '</a>'; 
  24.  
  25. if ( bbp_is_topic_trash( $topic->ID ) || !EMPTY_TRASH_DAYS ) { 
  26. $actions['delete'] = '<a title="' . esc_attr__( 'Delete this item permanently', bbpress ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_topic_trash', 'sub_action' => 'delete', 'topic_id' => $topic->ID ) ), 'delete-' . $topic->post_type . '_' . $topic->ID ) ) . '" onclick="return confirm(\'' . esc_js( __( 'Are you sure you want to delete that permanently?', bbpress ) ) . '\' );" class="bbp-topic-delete-link">' . $r['delete_text'] . '</a>'; 
  27.  
  28. // Process the admin links 
  29. $retval = $r['link_before'] . implode( $r['sep'], $actions ) . $r['link_after']; 
  30.  
  31. return apply_filters( 'bbp_get_topic_trash_link', $retval, $r );