3 function comment_exists($comment_author, $comment_date) {
6 return $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments
7 WHERE comment_author = '$comment_author' AND comment_date = '$comment_date'");
10 function edit_comment() {
13 $comment_ID = (int) $_POST['comment_ID'];
14 $comment_post_ID = (int) $_POST['comment_post_ID'];
16 if (!current_user_can( 'edit_post', $comment_post_ID ))
17 wp_die( __('You are not allowed to edit comments on this post, so you cannot edit this comment.' ));
19 $_POST['comment_author'] = $_POST['newcomment_author'];
20 $_POST['comment_author_email'] = $_POST['newcomment_author_email'];
21 $_POST['comment_author_url'] = $_POST['newcomment_author_url'];
22 $_POST['comment_approved'] = $_POST['comment_status'];
23 $_POST['comment_content'] = $_POST['content'];
24 $_POST['comment_ID'] = (int) $_POST['comment_ID'];
26 if (!empty ( $_POST['edit_date'] ) ) {
33 $jj = ($jj > 31 ) ? 31 : $jj;
34 $hh = ($hh > 23 ) ? $hh -24 : $hh;
35 $mn = ($mn > 59 ) ? $mn -60 : $mn;
36 $ss = ($ss > 59 ) ? $ss -60 : $ss;
37 $_POST['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss";
40 wp_update_comment( $_POST);
43 function get_comment_to_edit( $id ) {
44 if ( !$comment = get_comment($id) )
47 $comment->comment_ID = (int) $comment->comment_ID;
48 $comment->comment_post_ID = (int) $comment->comment_post_ID;
50 $comment->comment_content = format_to_edit( $comment->comment_content );
51 $comment->comment_content = apply_filters( 'comment_edit_pre', $comment->comment_content);
53 $comment->comment_author = format_to_edit( $comment->comment_author );
54 $comment->comment_author_email = format_to_edit( $comment->comment_author_email );
55 $comment->comment_author_url = clean_url($comment->comment_author_url);
56 $comment->comment_author_url = format_to_edit( $comment->comment_author_url );
61 function get_pending_comments_num( $post_id ) {
63 $post_id = (int) $post_id;
64 $pending = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = $post_id AND comment_approved = '0'" );