bbp_get_topic_edit_link

Return the edit link of the topic.

Description

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

Returns (string)

Topic edit 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 - edit_text: Edit text

Usage

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

Defined (1)

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

/includes/topics/template.php  
  1. function bbp_get_topic_edit_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. 'edit_text' => esc_html__( 'Edit', bbpress ) 
  9. ), 'get_topic_edit_link' ); 
  10.  
  11. $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) ); 
  12.  
  13. // Bypass check if user has caps 
  14. if ( !current_user_can( 'edit_others_topics' ) ) { 
  15.  
  16. // User cannot edit or it is past the lock time 
  17. if ( empty( $topic ) || !current_user_can( 'edit_topic', $topic->ID ) || bbp_past_edit_lock( $topic->post_date_gmt ) ) { 
  18. return; 
  19.  
  20. // Get uri 
  21. $uri = bbp_get_topic_edit_url( $r['id'] ); 
  22.  
  23. // Bail if no uri 
  24. if ( empty( $uri ) ) 
  25. return; 
  26.  
  27. $retval = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" class="bbp-topic-edit-link">' . $r['edit_text'] . '</a>' . $r['link_after']; 
  28.  
  29. return apply_filters( 'bbp_get_topic_edit_link', $retval, $r );