get_comment_to_edit

Returns a WP_Comment object based on comment ID.

Description

(WP_Comment|false) get_comment_to_edit( (int) $id ); 

Returns (WP_Comment|false)

Comment if found. False on failure.

Parameters (1)

0. $id (int)
ID of comment to retrieve.

Usage

  1. if ( !function_exists( 'get_comment_to_edit' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/comment.php'; 
  3.  
  4. // ID of comment to retrieve. 
  5. $id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = get_comment_to_edit($id); 
  9.  

Defined (1)

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

/wp-admin/includes/comment.php  
  1. function get_comment_to_edit( $id ) { 
  2. if ( !$comment = get_comment($id) ) 
  3. return false; 
  4.  
  5. $comment->comment_ID = (int) $comment->comment_ID; 
  6. $comment->comment_post_ID = (int) $comment->comment_post_ID; 
  7.  
  8. $comment->comment_content = format_to_edit( $comment->comment_content ); 
  9. /** 
  10. * Filters the comment content before editing. 
  11. * @since 2.0.0 
  12. * @param string $comment->comment_content Comment content. 
  13. */ 
  14. $comment->comment_content = apply_filters( 'comment_edit_pre', $comment->comment_content ); 
  15.  
  16. $comment->comment_author = format_to_edit( $comment->comment_author ); 
  17. $comment->comment_author_email = format_to_edit( $comment->comment_author_email ); 
  18. $comment->comment_author_url = format_to_edit( $comment->comment_author_url ); 
  19. $comment->comment_author_url = esc_url($comment->comment_author_url); 
  20.  
  21. return $comment;