bbp_get_reply_edit_link

Return the edit link of the reply.

Description

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

Returns (string)

Reply edit link

Parameters (1)

0. $args — Optional. (string) => ''
This function supports these arguments: - id: Reply id - link_before: HTML before the link - link_after: HTML after the link - edit_text: Edit text. Defaults to Edit

Usage

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

Defined (1)

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

/includes/replies/template.php  
  1. function bbp_get_reply_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_reply_edit_link' ); 
  10.  
  11. $reply = bbp_get_reply( bbp_get_reply_id( (int) $r['id'] ) ); 
  12.  
  13. // Bypass check if user has caps 
  14. if ( !current_user_can( 'edit_others_replies' ) ) { 
  15.  
  16. // User cannot edit or it is past the lock time 
  17. if ( empty( $reply ) || !current_user_can( 'edit_reply', $reply->ID ) || bbp_past_edit_lock( $reply->post_date_gmt ) ) { 
  18. return; 
  19.  
  20. // Get uri 
  21. $uri = bbp_get_reply_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-reply-edit-link">' . $r['edit_text'] . '</a>' . $r['link_after']; 
  28.  
  29. return apply_filters( 'bbp_get_reply_edit_link', $retval, $r );