2003-10-27 08:09:25 +01:00
< ? php
2004-10-19 05:03:06 +02:00
require_once ( 'admin.php' );
2004-04-23 05:23:05 +02:00
2006-11-18 08:31:29 +01:00
$title = __ ( 'Edit Comments' );
$parent_file = 'edit-comments.php' ;
2006-05-22 19:16:05 +02:00
wp_enqueue_script ( 'admin-comments' );
2004-08-23 01:24:50 +02:00
2003-12-11 01:22:36 +01:00
require_once ( 'admin-header.php' );
2004-02-17 09:35:04 +01:00
if ( empty ( $_GET [ 'mode' ])) $mode = 'view' ;
2006-12-21 11:10:04 +01:00
else $mode = attribute_escape ( $_GET [ 'mode' ]);
2003-10-27 08:09:25 +01:00
?>
2004-08-23 01:24:50 +02:00
2004-02-17 09:35:04 +01:00
< script type = " text/javascript " >
<!--
function checkAll ( form )
{
for ( i = 0 , n = form . elements . length ; i < n ; i ++ ) {
if ( form . elements [ i ] . type == " checkbox " ) {
if ( form . elements [ i ] . checked == true )
form . elements [ i ] . checked = false ;
else
form . elements [ i ] . checked = true ;
}
}
}
2006-03-21 01:33:36 +01:00
function getNumChecked ( form )
{
var num = 0 ;
for ( i = 0 , n = form . elements . length ; i < n ; i ++ ) {
if ( form . elements [ i ] . type == " checkbox " ) {
if ( form . elements [ i ] . checked == true )
num ++ ;
}
}
return num ;
}
2004-02-17 09:35:04 +01:00
//-->
</ script >
2003-10-27 08:09:25 +01:00
< div class = " wrap " >
2004-10-05 09:13:51 +02:00
< h2 >< ? php _e ( 'Comments' ); ?> </h2>
2006-05-10 22:35:10 +02:00
< form name = " searchform " action = " " method = " get " id = " editcomments " >
2004-02-13 16:36:28 +01:00
< fieldset >
2004-04-23 05:23:05 +02:00
< legend >< ? php _e ( 'Show Comments That Contain...' ) ?> </legend>
2006-12-21 11:10:04 +01:00
< input type = " text " name = " s " value = " <?php if (isset( $_GET['s'] )) echo attribute_escape( $_GET['s'] ); ?> " size = " 17 " />
2004-04-23 05:23:05 +02:00
< input type = " submit " name = " submit " value = " <?php _e('Search') ?> " />
2004-02-17 09:35:04 +01:00
< input type = " hidden " name = " mode " value = " <?php echo $mode ; ?> " />
2006-08-30 18:40:17 +02:00
< ? php _e ( '(Searches within comment text, e-mail, URL, and IP address.)' ) ?>
2004-02-13 16:36:28 +01:00
</ fieldset >
</ form >
2004-04-23 05:23:05 +02:00
< p >< a href = " ?mode=view " >< ? php _e ( 'View Mode' ) ?> </a> | <a href="?mode=edit"><?php _e('Mass Edit Mode') ?></a></p>
2003-10-27 08:09:25 +01:00
< ? php
2004-07-08 03:10:50 +02:00
if ( ! empty ( $_POST [ 'delete_comments' ] ) ) :
2006-05-03 00:36:06 +02:00
check_admin_referer ( 'bulk-comments' );
2006-03-31 01:12:54 +02:00
2004-07-08 03:10:50 +02:00
$i = 0 ;
2004-09-18 07:56:28 +02:00
foreach ( $_POST [ 'delete_comments' ] as $comment ) : // Check the permissions on each
2004-07-08 03:10:50 +02:00
$comment = ( int ) $comment ;
2007-03-23 01:59:21 +01:00
$post_id = ( int ) $wpdb -> get_var ( " SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment " );
2006-02-14 21:09:13 +01:00
// $authordata = get_userdata( $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $post_id") );
if ( current_user_can ( 'edit_post' , $post_id ) ) {
if ( ! empty ( $_POST [ 'spam_button' ] ) )
wp_set_comment_status ( $comment , 'spam' );
else
wp_set_comment_status ( $comment , 'delete' );
2004-02-17 11:50:33 +01:00
++ $i ;
2006-02-14 21:09:13 +01:00
}
2004-07-08 03:10:50 +02:00
endforeach ;
2006-02-14 21:09:13 +01:00
echo '<div style="background-color: rgb(207, 235, 247);" id="message" class="updated fade"><p>' ;
2006-12-22 00:06:18 +01:00
if ( ! empty ( $_POST [ 'spam_button' ] ) ) {
printf ( __ngettext ( '%s comment marked as spam' , '%s comments marked as spam.' , $i ), $i );
} else {
printf ( __ngettext ( '%s comment deleted.' , '%s comments deleted.' , $i ), $i );
}
2006-02-14 21:09:13 +01:00
echo '</p></div>' ;
2004-07-08 03:10:50 +02:00
endif ;
2004-02-17 11:50:33 +01:00
2004-05-09 07:47:02 +02:00
if ( isset ( $_GET [ 's' ])) {
$s = $wpdb -> escape ( $_GET [ 's' ]);
2004-05-24 10:22:18 +02:00
$comments = $wpdb -> get_results ( " SELECT * FROM $wpdb->comments WHERE
2005-01-18 00:32:20 +01:00
( comment_author LIKE '%$s%' OR
2004-02-13 16:36:28 +01:00
comment_author_email LIKE '%$s%' OR
comment_author_url LIKE ( '%$s%' ) OR
comment_author_IP LIKE ( '%$s%' ) OR
2005-01-18 00:32:20 +01:00
comment_content LIKE ( '%$s%' ) ) AND
comment_approved != 'spam'
2004-02-17 09:35:04 +01:00
ORDER BY comment_date DESC " );
2004-02-13 16:36:28 +01:00
} else {
2006-11-18 07:52:01 +01:00
if ( isset ( $_GET [ 'apage' ] ) )
$page = ( int ) $_GET [ 'apage' ];
2004-10-05 09:25:21 +02:00
else
2006-11-18 07:52:01 +01:00
$page = 1 ;
$start = $offset = ( $page - 1 ) * 20 ;
2004-10-05 09:25:21 +02:00
2006-12-18 01:13:16 +01:00
$comments = $wpdb -> get_results ( " SELECT * FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1' ORDER BY comment_date DESC LIMIT $start , 20 " );
2006-11-18 07:52:01 +01:00
$total = $wpdb -> get_var ( " SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1' " );
2003-10-27 08:09:25 +01:00
}
2006-11-18 07:52:01 +01:00
?>
< ? php if ( $total > 20 ) {
$total_pages = ceil ( $total / 20 );
$r = '' ;
if ( 1 < $page ) {
$args [ 'apage' ] = ( 1 == $page - 1 ) ? FALSE : $page - 1 ;
2007-03-17 09:46:59 +01:00
$r .= '<a class="prev" href="' . clean_url ( add_query_arg ( $args )) . '">« ' . __ ( 'Previous Page' ) . '</a>' . " \n " ;
2006-11-18 07:52:01 +01:00
}
if ( ( $total_pages = ceil ( $total / 20 ) ) > 1 ) {
for ( $page_num = 1 ; $page_num <= $total_pages ; $page_num ++ ) :
if ( $page == $page_num ) :
$r .= " <span> $page_num </span> \n " ;
else :
$p = false ;
if ( $page_num < 3 || ( $page_num >= $page - 3 && $page_num <= $page + 3 ) || $page_num > $total_pages - 3 ) :
$args [ 'apage' ] = ( 1 == $page_num ) ? FALSE : $page_num ;
2007-03-17 09:46:59 +01:00
$r .= '<a class="page-numbers" href="' . clean_url ( add_query_arg ( $args )) . '">' . ( $page_num ) . " </a> \n " ;
2006-11-18 07:52:01 +01:00
$in = true ;
elseif ( $in == true ) :
$r .= " ... \n " ;
$in = false ;
endif ;
endif ;
endfor ;
}
if ( ( $page ) * 20 < $total || - 1 == $total ) {
$args [ 'apage' ] = $page + 1 ;
2007-03-17 09:46:59 +01:00
$r .= '<a class="next" href="' . clean_url ( add_query_arg ( $args )) . '">' . __ ( 'Next Page' ) . ' »</a>' . " \n " ;
2006-11-18 07:52:01 +01:00
}
2007-01-22 20:26:20 +01:00
echo " <p class='pagenav'> $r </p> " ;
2006-11-18 07:52:01 +01:00
?>
< ? php } ?>
< ? php
2004-02-17 09:35:04 +01:00
if ( 'view' == $mode ) {
2003-10-27 08:09:25 +01:00
if ( $comments ) {
2006-11-18 07:52:01 +01:00
?>
< ? php
$offset = $offset + 1 ;
$start = " start=' $offset ' " ;
2004-10-05 09:25:21 +02:00
2006-06-06 06:14:04 +02:00
echo " <ol id='the-comment-list' class='commentlist' $start > " ;
2004-10-05 09:13:51 +02:00
$i = 0 ;
2003-10-27 08:09:25 +01:00
foreach ( $comments as $comment ) {
2004-10-05 09:13:51 +02:00
++ $i ; $class = '' ;
2004-05-24 10:22:18 +02:00
$authordata = get_userdata ( $wpdb -> get_var ( " SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID " ));
2003-11-12 16:22:47 +01:00
$comment_status = wp_get_comment_status ( $comment -> comment_ID );
2006-11-19 08:56:05 +01:00
if ( 'unapproved' == $comment_status )
2004-10-05 09:13:51 +02:00
$class .= ' unapproved' ;
if ( $i % 2 )
$class .= ' alternate' ;
2005-08-31 04:39:17 +02:00
echo " <li id='comment- $comment->comment_ID ' class=' $class '> " ;
2006-02-12 08:53:23 +01:00
?>
2006-04-19 10:30:56 +02:00
< p >< strong >< ? php comment_author () ?> </strong> <?php if ($comment->comment_author_email) { ?>| <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <?php comment_author_url_link() ?> <?php } ?>| <?php _e('IP:') ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p>
< ? php comment_text () ?>
2007-03-07 02:25:17 +01:00
< p >< ? php comment_date ( __ ( 'M j, g:i A' )); ?> — [
2006-04-19 10:30:56 +02:00
< ? php
if ( current_user_can ( 'edit_post' , $comment -> comment_post_ID ) ) {
2006-10-31 07:50:38 +01:00
echo " <a href='comment.php?action=editcomment&c= " . $comment -> comment_ID . " '> " . __ ( 'Edit' ) . '</a>' ;
2007-01-08 04:02:33 +01:00
echo ' | <a href="' . wp_nonce_url ( 'comment.php?action=deletecomment&p=' . $comment -> comment_post_ID . '&c=' . $comment -> comment_ID , 'delete-comment_' . $comment -> comment_ID ) . '" onclick="return deleteSomething( \'comment\', ' . $comment -> comment_ID . ', \'' . js_escape ( sprintf ( __ ( " You are about to delete this comment by '%s'. \n 'Cancel' to stop, 'OK' to delete. " ), $comment -> comment_author )) . " ', theCommentList ); \" > " . __ ( 'Delete' ) . '</a> ' ;
2006-04-19 10:30:56 +02:00
if ( ( 'none' != $comment_status ) && ( current_user_can ( 'moderate_comments' ) ) ) {
2006-10-31 07:50:38 +01:00
echo '<span class="unapprove"> | <a href="' . wp_nonce_url ( 'comment.php?action=unapprovecomment&p=' . $comment -> comment_post_ID . '&c=' . $comment -> comment_ID , 'unapprove-comment_' . $comment -> comment_ID ) . '" onclick="return dimSomething( \'comment\', ' . $comment -> comment_ID . ', \'unapproved\', theCommentList );">' . __ ( 'Unapprove' ) . '</a> </span>' ;
echo '<span class="approve"> | <a href="' . wp_nonce_url ( 'comment.php?action=approvecomment&p=' . $comment -> comment_post_ID . '&c=' . $comment -> comment_ID , 'approve-comment_' . $comment -> comment_ID ) . '" onclick="return dimSomething( \'comment\', ' . $comment -> comment_ID . ', \'unapproved\', theCommentList );">' . __ ( 'Approve' ) . '</a> </span>' ;
2006-04-19 10:30:56 +02:00
}
2007-01-08 04:02:33 +01:00
echo " | <a href= \" " . wp_nonce_url ( " comment.php?action=deletecomment&dt=spam&p= " . $comment -> comment_post_ID . " &c= " . $comment -> comment_ID , 'delete-comment_' . $comment -> comment_ID ) . " \" onclick= \" return deleteSomething( 'comment-as-spam', $comment->comment_ID , ' " . js_escape ( sprintf ( __ ( " You are about to mark as spam this comment by '%s'. \n 'Cancel' to stop, 'OK' to mark as spam. " ), $comment -> comment_author )) . " ', theCommentList ); \" > " . __ ( 'Spam' ) . " </a> " ;
2006-04-19 10:30:56 +02:00
}
$post = get_post ( $comment -> comment_post_ID );
$post_title = wp_specialchars ( $post -> post_title , 'double' );
$post_title = ( '' == $post_title ) ? " # $comment->comment_post_ID " : $post_title ;
?>
2007-03-11 23:46:25 +01:00
] & #8212; <a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php echo $post_title; ?></a></p>
2003-10-27 08:40:15 +01:00
</ li >
2003-10-27 08:09:25 +01:00
2006-03-29 03:51:55 +02:00
< ? php } // end foreach($comment) ?>
2004-10-05 09:25:21 +02:00
</ ol >
2005-08-31 04:39:17 +02:00
< div id = " ajax-response " ></ div >
2004-10-05 09:25:21 +02:00
< ? php
2006-03-29 03:51:55 +02:00
} else { //no comments to show
2004-02-17 09:35:04 +01:00
?>
< p >
2006-11-19 08:56:05 +01:00
< strong >< ? php _e ( 'No comments found.' ) ?> </strong></p>
2006-02-12 08:53:23 +01:00
2004-02-17 09:35:04 +01:00
< ? php
} // end if ($comments)
} elseif ( 'edit' == $mode ) {
2004-02-17 11:50:33 +01:00
2004-02-17 09:35:04 +01:00
if ( $comments ) {
2006-05-03 00:36:06 +02:00
echo '<form name="deletecomments" id="deletecomments" action="" method="post"> ' ;
wp_nonce_field ( 'bulk-comments' );
2006-05-10 22:35:10 +02:00
echo ' < table class = " widefat " >
< thead >
2004-02-17 09:35:04 +01:00
< tr >
2006-09-27 02:51:17 +02:00
< th scope = " col " style = " text-align: center " >< input type = " checkbox " onclick = " checkAll(document.getElementById( \ 'deletecomments \ ')); " /></ th >
< th scope = " col " > ' . __(' Name ') . ' </ th >
< th scope = " col " > ' . __(' E - mail ') . ' </ th >
< th scope = " col " > ' . __(' IP ') . ' </ th >
< th scope = " col " > ' . __(' Comment Excerpt ') . ' </ th >
< th scope = " col " colspan = " 3 " style = " text-align: center " > ' . __(' Actions ') . ' </ th >
2006-05-10 22:35:10 +02:00
</ tr >
</ thead > ' ;
2004-02-17 09:35:04 +01:00
foreach ( $comments as $comment ) {
2004-05-24 10:22:18 +02:00
$authordata = get_userdata ( $wpdb -> get_var ( " SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID " ));
2006-03-29 03:51:55 +02:00
$comment_status = wp_get_comment_status ( $comment -> comment_ID );
2004-07-06 20:14:42 +02:00
$class = ( 'alternate' == $class ) ? '' : 'alternate' ;
2006-03-29 03:51:55 +02:00
$class .= ( 'unapproved' == $comment_status ) ? ' unapproved' : '' ;
2004-02-17 09:35:04 +01:00
?>
2006-03-29 03:51:55 +02:00
< tr id = " comment-<?php echo $comment->comment_ID ; ?> " class = '<?php echo $class; ?>' >
2005-07-17 23:21:50 +02:00
< td >< ? php if ( current_user_can ( 'edit_post' , $comment -> comment_post_ID ) ) { ?> <input type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" /><?php } ?></td>
2004-04-19 10:09:27 +02:00
< td >< ? php comment_author_link () ?> </td>
2004-02-17 09:35:04 +01:00
< td >< ? php comment_author_email_link () ?> </td>
< td >< a href = " http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?> " >< ? php comment_author_IP () ?> </a></td>
< td >< ? php comment_excerpt (); ?> </td>
2006-03-29 03:51:55 +02:00
< td >
< ? php if ( 'unapproved' == $comment_status ) { ?>
( Unapproved )
< ? php } else { ?>
< a href = " <?php echo get_permalink( $comment->comment_post_ID ); ?>#comment-<?php comment_ID() ?> " class = " edit " >< ? php _e ( 'View' ) ?> </a>
< ? php } ?>
</ td >
2005-07-17 23:21:50 +02:00
< td >< ? php if ( current_user_can ( 'edit_post' , $comment -> comment_post_ID ) ) {
2006-10-31 07:50:38 +01:00
echo " <a href='comment.php?action=editcomment&c= $comment->comment_ID ' class='edit'> " . __ ( 'Edit' ) . " </a> " ; } ?> </td>
2005-07-17 23:21:50 +02:00
< td >< ? php if ( current_user_can ( 'edit_post' , $comment -> comment_post_ID ) ) {
2006-12-06 12:26:27 +01:00
echo " <a href= \" comment.php?action=deletecomment&p= " . $comment -> comment_post_ID . " &c= " . $comment -> comment_ID . " \" onclick= \" return deleteSomething( 'comment', $comment->comment_ID , ' " . js_escape ( sprintf ( __ ( " You are about to delete this comment by '%s'. \n 'Cancel' to stop, 'OK' to delete. " ), $comment -> comment_author )) . " ', theCommentList ); \" class='delete'> " . __ ( 'Delete' ) . " </a> " ;
2006-03-29 03:51:55 +02:00
} ?> </td>
2004-02-17 09:35:04 +01:00
</ tr >
< ? php
} // end foreach
?> </table>
2006-12-06 12:26:27 +01:00
< p class = " submit " >< input type = " submit " name = " delete_button " class = " delete " value = " <?php _e('Delete Checked Comments »') ?> " onclick = " var numchecked = getNumChecked(document.getElementById('deletecomments')); if(numchecked < 1) { alert('<?php echo js_escape(__( " Please select some comments to delete " )); ?>'); return false } return confirm('<?php echo sprintf(js_escape(__( " You are about to delete % s comments permanently \n 'Cancel' to stop , 'OK' to delete . " )), " ' + numchecked + ' " ); ?>') " />
< input type = " submit " name = " spam_button " value = " <?php _e('Mark Checked Comments as Spam »') ?> " onclick = " var numchecked = getNumChecked(document.getElementById('deletecomments')); if(numchecked < 1) { alert('<?php echo js_escape(__( " Please select some comments to mark as spam " )); ?>'); return false } return confirm('<?php echo sprintf(js_escape(__( " You are about to mark % s comments as spam \n 'Cancel' to stop , 'OK' to mark as spam . " )), " ' + numchecked + ' " ); ?>') " /></ p >
2004-02-17 09:35:04 +01:00
</ form >
2006-03-29 03:51:55 +02:00
< div id = " ajax-response " ></ div >
2004-02-17 09:35:04 +01:00
< ? php
2003-10-27 08:09:25 +01:00
} else {
2004-02-17 11:50:33 +01:00
?>
< p >
2004-04-23 05:23:05 +02:00
< strong >< ? php _e ( 'No results found.' ) ?> </strong>
2004-02-17 11:50:33 +01:00
</ p >
< ? php
2003-10-27 08:09:25 +01:00
} // end if ($comments)
2004-02-17 09:35:04 +01:00
}
2003-10-27 08:09:25 +01:00
?>
2006-11-18 07:52:01 +01:00
< ? php if ( $total > 20 ) {
$total_pages = ceil ( $total / 20 );
$r = '' ;
if ( 1 < $page ) {
$args [ 'apage' ] = ( 1 == $page - 1 ) ? FALSE : $page - 1 ;
2007-03-17 09:46:59 +01:00
$r .= '<a class="prev" href="' . clean_url ( add_query_arg ( $args )) . '">« ' . __ ( 'Previous Page' ) . '</a>' . " \n " ;
2006-11-18 07:52:01 +01:00
}
if ( ( $total_pages = ceil ( $total / 20 ) ) > 1 ) {
for ( $page_num = 1 ; $page_num <= $total_pages ; $page_num ++ ) :
if ( $page == $page_num ) :
$r .= " <span> $page_num </span> \n " ;
else :
$p = false ;
if ( $page_num < 3 || ( $page_num >= $page - 3 && $page_num <= $page + 3 ) || $page_num > $total_pages - 3 ) :
$args [ 'apage' ] = ( 1 == $page_num ) ? FALSE : $page_num ;
2007-03-17 09:46:59 +01:00
$r .= '<a class="page-numbers" href="' . clean_url ( add_query_arg ( $args )) . '">' . ( $page_num ) . " </a> \n " ;
2006-11-18 07:52:01 +01:00
$in = true ;
elseif ( $in == true ) :
$r .= " ... \n " ;
$in = false ;
endif ;
endif ;
endfor ;
}
if ( ( $page ) * 20 < $total || - 1 == $total ) {
$args [ 'apage' ] = $page + 1 ;
2007-03-17 09:46:59 +01:00
$r .= '<a class="next" href="' . clean_url ( add_query_arg ( $args )) . '">' . __ ( 'Next Page' ) . ' »</a>' . " \n " ;
2006-11-18 07:52:01 +01:00
}
2007-01-22 20:26:20 +01:00
echo " <p class='pagenav'> $r </p> " ;
2006-11-18 07:52:01 +01:00
?>
< ? php } ?>
2003-10-27 08:09:25 +01:00
</ div >
2005-08-31 04:39:17 +02:00
< ? php include ( 'admin-footer.php' ); ?>