edit_comment_link

Displays the edit comment link with formatting.

Description

edit_comment_link( (constant) $text = null, (string) $before = '', (string) $after = '' ); 

Parameters (3)

0. $text — Optional. (constant) => null
Anchor text. If null, default is Edit This.. Default null.
1. $before — Optional. (string) => ''
Display before edit link. Default empty.
2. $after — Optional. (string) => ''
Display after edit link. Default empty.

Usage

  1. if ( !function_exists( 'edit_comment_link' ) ) { 
  2. require_once ABSPATH . WPINC . '/link-template.php'; 
  3.  
  4. // Optional. Anchor text. If null, default is 'Edit This'. Default null. 
  5. $text = null; 
  6.  
  7. // Optional. Display before edit link. Default empty. 
  8. $before = ''; 
  9.  
  10. // Optional. Display after edit link. Default empty. 
  11. $after = ''; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = edit_comment_link($text, $before, $after); 
  15.  

Defined (1)

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

/wp-includes/link-template.php  
  1. function edit_comment_link( $text = null, $before = '', $after = '' ) { 
  2. $comment = get_comment(); 
  3.  
  4. if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) { 
  5. return; 
  6.  
  7. if ( null === $text ) { 
  8. $text = __( 'Edit This' ); 
  9.  
  10. $link = '<a class="comment-edit-link" href="' . esc_url( get_edit_comment_link( $comment ) ) . '">' . $text . '</a>'; 
  11.  
  12. /** 
  13. * Filters the comment edit link anchor tag. 
  14. * @since 2.3.0 
  15. * @param string $link Anchor tag for the edit link. 
  16. * @param int $comment_id Comment ID. 
  17. * @param string $text Anchor text. 
  18. */ 
  19. echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID, $text ) . $after;