wp_untrash_comment

Removes a comment from the Trash.

Description

wp_untrash_comment( (int|WP_Comment) $comment_id ); 

Parameters (1)

0. $comment_id (int|WP_Comment)
Comment ID or WP_Comment object.

Usage

  1. if ( !function_exists( 'wp_untrash_comment' ) ) { 
  2. require_once ABSPATH . WPINC . '/comment.php'; 
  3.  
  4. // Comment ID or WP_Comment object. 
  5. $comment_id = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wp_untrash_comment($comment_id); 
  9.  

Defined (1)

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

/wp-includes/comment.php  
  1. function wp_untrash_comment($comment_id) { 
  2. $comment = get_comment( $comment_id ); 
  3. if ( ! $comment ) { 
  4. return false; 
  5.  
  6. /** 
  7. * Fires immediately before a comment is restored from the Trash. 
  8. * @since 2.9.0 
  9. * @param int $comment_id The comment ID. 
  10. */ 
  11. do_action( 'untrash_comment', $comment->comment_ID ); 
  12.  
  13. $status = (string) get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ); 
  14. if ( empty($status) ) 
  15. $status = '0'; 
  16.  
  17. if ( wp_set_comment_status( $comment, $status ) ) { 
  18. delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_time' ); 
  19. delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_status' ); 
  20. /** 
  21. * Fires immediately after a comment is restored from the Trash. 
  22. * @since 2.9.0 
  23. * @param int $comment_id The comment ID. 
  24. */ 
  25. do_action( 'untrashed_comment', $comment->comment_ID ); 
  26. return true; 
  27.  
  28. return false;