wp_ajax_edit_comment

Ajax handler for editing a comment.

Description

wp_ajax_edit_comment(); 

Usage

  1. if ( !function_exists( 'wp_ajax_edit_comment' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/ajax-actions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wp_ajax_edit_comment(); 
  7.  

Defined (1)

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

/wp-admin/includes/ajax-actions.php  
  1. function wp_ajax_edit_comment() { 
  2. check_ajax_referer( 'replyto-comment', '_ajax_nonce-replyto-comment' ); 
  3.  
  4. $comment_id = (int) $_POST['comment_ID']; 
  5. if ( ! current_user_can( 'edit_comment', $comment_id ) ) 
  6. wp_die( -1 ); 
  7.  
  8. if ( '' == $_POST['content'] ) 
  9. wp_die( __( ERROR please type a comment.' ) ); 
  10.  
  11. if ( isset( $_POST['status'] ) ) 
  12. $_POST['comment_status'] = $_POST['status']; 
  13.  
  14. $position = ( isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1'; 
  15. $checkbox = ( isset($_POST['checkbox']) && true == $_POST['checkbox'] ) ? 1 : 0; 
  16. $wp_list_table = _get_list_table( $checkbox ? 'WP_Comments_List_Table' : 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) ); 
  17.  
  18. $comment = get_comment( $comment_id ); 
  19. if ( empty( $comment->comment_ID ) ) 
  20. wp_die( -1 ); 
  21.  
  22. ob_start(); 
  23. $wp_list_table->single_row( $comment ); 
  24. $comment_list_item = ob_get_clean(); 
  25.  
  26. $x = new WP_Ajax_Response(); 
  27.  
  28. $x->add( array( 
  29. 'what' => 'edit_comment',  
  30. 'id' => $comment->comment_ID,  
  31. 'data' => $comment_list_item,  
  32. 'position' => $position 
  33. )); 
  34.  
  35. $x->send();