| 30 | | |
|---|
| 31 | | foreach($comment as $key => $value) { |
|---|
| 32 | | if ($feelinglucky && 'later' == $value) |
|---|
| 33 | | $value = 'delete'; |
|---|
| 34 | | switch($value) { |
|---|
| 35 | | case 'later': |
|---|
| 36 | | // do nothing with that comment |
|---|
| 37 | | // wp_set_comment_status($key, "hold"); |
|---|
| 38 | | ++$item_ignored; |
|---|
| 39 | | break; |
|---|
| 40 | | case 'delete': |
|---|
| 41 | | wp_set_comment_status($key, 'delete'); |
|---|
| 42 | | ++$item_deleted; |
|---|
| 43 | | break; |
|---|
| 44 | | case 'spam': |
|---|
| 45 | | wp_set_comment_status($key, 'spam'); |
|---|
| 46 | | ++$item_spam; |
|---|
| 47 | | break; |
|---|
| 48 | | case 'approve': |
|---|
| 49 | | wp_set_comment_status($key, 'approve'); |
|---|
| 50 | | if ( get_option('comments_notify') == true ) { |
|---|
| 51 | | wp_notify_postauthor($key); |
|---|
| | 31 | |
|---|
| | 32 | foreach ( $comment as $k => $v ) { |
|---|
| | 33 | if ( $feelinglucky && $v == 'later' ) { |
|---|
| | 34 | $v = 'delete'; |
|---|
| | 35 | } |
|---|
| | 36 | |
|---|
| | 37 | switch ( $v ) { |
|---|
| | 38 | case 'later' : |
|---|
| | 39 | $item_ignored++; |
|---|
| | 40 | break; |
|---|
| | 41 | |
|---|
| | 42 | case 'delete' : |
|---|
| | 43 | wp_set_comment_status( $k, 'delete' ); |
|---|
| | 44 | $item_deleted++; |
|---|
| | 45 | break; |
|---|
| | 46 | |
|---|
| | 47 | case 'spam' : |
|---|
| | 48 | wp_set_comment_status( $k, 'spam' ); |
|---|
| | 49 | $item_spam++; |
|---|
| | 50 | break; |
|---|
| | 51 | |
|---|
| | 52 | case 'approve' : |
|---|
| | 53 | wp_set_comment_status( $k, 'approve' ); |
|---|
| | 54 | |
|---|
| | 55 | if ( get_option( 'comments_notify' ) == true ) { |
|---|
| | 56 | wp_notify_postauthor( $k ); |
|---|
| 53 | | ++$item_approved; |
|---|
| 54 | | break; |
|---|
| 55 | | } |
|---|
| 56 | | } |
|---|
| 57 | | |
|---|
| 58 | | $file = basename(__FILE__); |
|---|
| 59 | | wp_redirect("$file?ignored=$item_ignored&deleted=$item_deleted&approved=$item_approved&spam=$item_spam"); |
|---|
| 60 | | exit(); |
|---|
| 61 | | |
|---|
| 62 | | break; |
|---|
| 63 | | |
|---|
| 64 | | default: |
|---|
| 65 | | |
|---|
| 66 | | require_once('admin-header.php'); |
|---|
| 67 | | |
|---|
| 68 | | if ( isset($_GET['deleted']) || isset($_GET['approved']) || isset($_GET['ignored']) ) { |
|---|
| 69 | | echo "<div id='moderated' class='updated fade'>\n<p>"; |
|---|
| 70 | | $approved = (int) $_GET['approved']; |
|---|
| 71 | | $deleted = (int) $_GET['deleted']; |
|---|
| 72 | | $ignored = (int) $_GET['ignored']; |
|---|
| 73 | | $spam = (int) $_GET['spam']; |
|---|
| 74 | | if ($approved) { |
|---|
| 75 | | printf(__ngettext('%s comment approved', '%s comments approved', $approved), $approved); |
|---|
| 76 | | echo "<br/>\n"; |
|---|
| 77 | | } |
|---|
| 78 | | if ($deleted) { |
|---|
| 79 | | printf(__ngettext('%s comment deleted', '%s comments deleted', $deleted), $deleted); |
|---|
| 80 | | echo "<br/>\n"; |
|---|
| 81 | | } |
|---|
| 82 | | if ($spam) { |
|---|
| 83 | | printf(__ngettext('%s comment marked as spam', '%s comments marked as spam', $spam), $spam); |
|---|
| 84 | | echo "<br/>\n"; |
|---|
| 85 | | } |
|---|
| 86 | | if ($ignored) { |
|---|
| 87 | | printf(__ngettext('%s comment unchanged', '%s comments unchanged', $ignored), $ignored); |
|---|
| 88 | | echo "<br/>\n"; |
|---|
| 89 | | } |
|---|
| 90 | | echo "</p></div>\n"; |
|---|
| | 58 | |
|---|
| | 59 | $item_approved++; |
|---|
| | 60 | break; |
|---|
| | 61 | } |
|---|
| | 62 | } |
|---|
| | 63 | |
|---|
| | 64 | wp_redirect( basename( __FILE__ ) . '?ignored=' . $item_ignored . '&deleted=' . $item_deleted . '&approved=' . $item_approved . '&spam=' . $item_spam ); |
|---|
| | 65 | exit; |
|---|
| | 66 | } |
|---|
| | 67 | |
|---|
| | 68 | require_once './admin-header.php'; |
|---|
| | 69 | |
|---|
| | 70 | if ( !current_user_can( 'moderate_comments' ) ) { |
|---|
| | 71 | echo '<div class="wrap"><p>' . __( 'Your level is not high enough to moderate comments.' ) . '</p></div>'; |
|---|
| | 72 | include_once './admin-footer.php'; |
|---|
| | 73 | exit; |
|---|
| | 74 | } |
|---|
| | 75 | |
|---|
| | 76 | if ( isset( $_GET['approved'] ) || isset( $_GET['deleted'] ) || isset( $_GET['spam'] ) ) { |
|---|
| | 77 | $approved = isset( $_GET['approved'] ) ? (int) $_GET['approved'] : 0; |
|---|
| | 78 | $deleted = isset( $_GET['deleted'] ) ? (int) $_GET['deleted'] : 0; |
|---|
| | 79 | $spam = isset( $_GET['ignored'] ) ? (int) $_GET['spam'] : 0; |
|---|
| | 80 | |
|---|
| | 81 | if ( $approved > 0 || $deleted > 0 || $spam > 0 ) { |
|---|
| | 82 | echo '<div id="moderated" class="updated fade"><p>'; |
|---|
| | 83 | |
|---|
| | 84 | if ( $approved > 0 ) { |
|---|
| | 85 | printf( __ngettext( '%s comment approved.', '%s comments approved.', $approved ), $approved ); |
|---|
| | 86 | echo '<br />'; |
|---|
| | 87 | } |
|---|
| | 88 | |
|---|
| | 89 | if ( $deleted > 0 ) { |
|---|
| | 90 | printf( __ngettext( '%s comment deleted', '%s comments deleted.', $deleted ), $deleted ); |
|---|
| | 91 | echo '<br />'; |
|---|
| | 92 | } |
|---|
| | 93 | |
|---|
| | 94 | if ( $spam > 0 ) { |
|---|
| | 95 | printf( __ngettext( '%s comment marked as spam', '%s comments marked as spam', $spam ), $spam ); |
|---|
| | 96 | echo '<br />'; |
|---|
| | 97 | } |
|---|
| | 98 | |
|---|
| | 99 | echo '</p></div>'; |
|---|
| | 100 | } |
|---|
| 98 | | if ( current_user_can('moderate_comments') ) |
|---|
| 99 | | $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '0'"); |
|---|
| 100 | | else |
|---|
| 101 | | $comments = ''; |
|---|
| 102 | | |
|---|
| 103 | | if ($comments) { |
|---|
| 104 | | // list all comments that are waiting for approval |
|---|
| 105 | | $file = basename(__FILE__); |
|---|
| | 106 | |
|---|
| | 107 | $comments = $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = '0'" ); |
|---|
| | 108 | |
|---|
| | 109 | if ( !$comments ) { |
|---|
| | 110 | echo '<p>' . __( 'Currently there are no comments for you to moderate.' ) . '</p></div>'; |
|---|
| | 111 | include_once './admin-footer.php'; |
|---|
| | 112 | exit; |
|---|
| | 113 | } |
|---|
| | 114 | |
|---|
| | 115 | $total = count( $comments ); |
|---|
| | 116 | $per = 20; |
|---|
| | 117 | |
|---|
| | 118 | if ( isset( $_GET['paged'] ) ) { |
|---|
| | 119 | $page = (int) $_GET['paged']; |
|---|
| | 120 | } else { |
|---|
| | 121 | $page = 1; |
|---|
| | 122 | } |
|---|
| | 123 | |
|---|
| | 124 | $start = ( $page * $per ) - $per; |
|---|
| | 125 | $stop = $start + $per; |
|---|
| | 126 | |
|---|
| | 127 | $page_links = paginate_links( array( |
|---|
| | 128 | 'base' => add_query_arg( 'paged', '%#%' ), |
|---|
| | 129 | 'format' => '', |
|---|
| | 130 | 'total' => ceil( $total / $per ), |
|---|
| | 131 | 'current' => $page, |
|---|
| | 132 | 'prev_text' => '«', |
|---|
| | 133 | 'next_text' => '»' |
|---|
| | 134 | ) ); |
|---|
| | 135 | |
|---|
| | 136 | $comments = array_slice( $comments, $start, $stop ); |
|---|
| | 137 | |
|---|
| 122 | | <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> |
|---|
| 123 | | <?php comment_text() ?> |
|---|
| 124 | | <p><?php comment_date(__('M j, g:i A')); ?> — [ <?php |
|---|
| 125 | | echo '<a href="comment.php?action=editcomment&c='.$comment->comment_ID.'">' . __('Edit') . '</a> | '; |
|---|
| 126 | | echo " <a href=\"post.php?action=deletecomment&p=".$comment->comment_post_ID."&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> "; ?> ] — |
|---|
| 127 | | <?php |
|---|
| 128 | | $post = get_post($comment->comment_post_ID); |
|---|
| 129 | | $post_title = wp_specialchars( $post->post_title, 'double' ); |
|---|
| 130 | | $post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title; |
|---|
| 131 | | ?> |
|---|
| 132 | | <a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php echo $post_title; ?></a></p> |
|---|
| 133 | | <p><?php _e('Bulk action:') ?> |
|---|
| 134 | | <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment-<?php echo $comment->comment_ID; ?>-approve" value="approve" /> <label for="comment-<?php echo $comment->comment_ID; ?>-approve"><?php _e('Approve') ?></label> |
|---|
| 135 | | <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment-<?php echo $comment->comment_ID; ?>-spam" value="spam" /> <label for="comment-<?php echo $comment->comment_ID; ?>-spam"><?php _e('Spam') ?></label> |
|---|
| 136 | | <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment-<?php echo $comment->comment_ID; ?>-delete" value="delete" /> <label for="comment-<?php echo $comment->comment_ID; ?>-delete"><?php _e('Delete') ?></label> |
|---|
| 137 | | <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment-<?php echo $comment->comment_ID; ?>-nothing" value="later" checked="checked" /> <label for="comment-<?php echo $comment->comment_ID; ?>-nothing"><?php _e('Defer until later') ?></label> |
|---|
| 138 | | </p> |
|---|
| 139 | | |
|---|
| 140 | | </li> |
|---|
| 141 | | <?php |
|---|
| 142 | | } |
|---|
| 143 | | ?> |
|---|
| 144 | | </ol> |
|---|
| 145 | | |
|---|
| 146 | | <div id="ajax-response"></div> |
|---|
| 147 | | |
|---|
| 148 | | <p class="submit"><input type="submit" name="submit" value="<?php _e('Bulk Moderate Comments »') ?>" /></p> |
|---|
| 149 | | <script type="text/javascript"> |
|---|
| 150 | | // <![CDATA[ |
|---|
| 151 | | function markAllForDelete() { |
|---|
| 152 | | for (var i=0; i< document.approval.length; i++) { |
|---|
| 153 | | if (document.approval[i].value == "delete") { |
|---|
| 154 | | document.approval[i].checked = true; |
|---|
| 155 | | } |
|---|
| 156 | | } |
|---|
| 157 | | } |
|---|
| 158 | | function markAllForApprove() { |
|---|
| 159 | | for (var i=0; i< document.approval.length; i++) { |
|---|
| 160 | | if (document.approval[i].value == "approve") { |
|---|
| 161 | | document.approval[i].checked = true; |
|---|
| 162 | | } |
|---|
| 163 | | } |
|---|
| 164 | | } |
|---|
| 165 | | function markAllForDefer() { |
|---|
| 166 | | for (var i=0; i< document.approval.length; i++) { |
|---|
| 167 | | if (document.approval[i].value == "later") { |
|---|
| 168 | | document.approval[i].checked = true; |
|---|
| 169 | | } |
|---|
| 170 | | } |
|---|
| 171 | | } |
|---|
| 172 | | function markAllAsSpam() { |
|---|
| 173 | | for (var i=0; i< document.approval.length; i++) { |
|---|
| 174 | | if (document.approval[i].value == "spam") { |
|---|
| 175 | | document.approval[i].checked = true; |
|---|
| 176 | | } |
|---|
| 177 | | } |
|---|
| 178 | | } |
|---|
| 179 | | document.write('<ul><li><a href="javascript:markAllForApprove()"><?php _e('Mark all for approval'); ?></a></li><li><a href="javascript:markAllAsSpam()"><?php _e('Mark all as spam'); ?></a></li><li><a href="javascript:markAllForDelete()"><?php _e('Mark all for deletion'); ?></a></li><li><a href="javascript:markAllForDefer()"><?php _e('Mark all for later'); ?></a></li></ul>'); |
|---|
| 180 | | // ]]> |
|---|
| 181 | | </script> |
|---|
| 182 | | |
|---|
| 183 | | <noscript> |
|---|
| 184 | | <p> |
|---|
| 185 | | <input name="feelinglucky" type="checkbox" id="feelinglucky" value="true" /> <label for="feelinglucky"><?php _e('Delete every comment marked “defer.” <strong>Warning: This can’t be undone.</strong>'); ?></label> |
|---|
| 186 | | </p> |
|---|
| 187 | | </noscript> |
|---|
| 188 | | </form> |
|---|
| 189 | | <?php |
|---|
| 190 | | } else { |
|---|
| 191 | | // nothing to approve |
|---|
| 192 | | echo '<p>'.__("Currently there are no comments for you to moderate.") . "</p>\n"; |
|---|
| 193 | | } |
|---|
| 194 | | ?> |
|---|
| 195 | | |
|---|
| | 146 | |
|---|
| | 147 | <form name="approval" id="approval" action="<?php echo basename( __FILE__ ); ?>" method="post"> |
|---|
| | 148 | <?php wp_nonce_field( 'moderate-comments' ); ?> |
|---|
| | 149 | <input type="hidden" name="action" value="update" /> |
|---|
| | 150 | <ol id="the-comments-list" class="commentlist"> |
|---|
| | 151 | <?php |
|---|
| | 152 | $i = 0; |
|---|
| | 153 | |
|---|
| | 154 | foreach ( $comments as $comment ) { |
|---|
| | 155 | $class = 'js-unapproved'; |
|---|
| | 156 | |
|---|
| | 157 | if ( $i++ % 2 ) { |
|---|
| | 158 | $class .= ' alternate'; |
|---|
| | 159 | } |
|---|
| | 160 | ?> |
|---|
| | 161 | <li id="comment-<?php comment_ID(); ?>" class="<?php echo $class; ?>"> |
|---|
| | 162 | <p> |
|---|
| | 163 | <strong><?php comment_author(); ?></strong> |
|---|
| | 164 | <?php if ( !empty( $comment->comment_author_email ) ) { ?>| <?php comment_author_email_link(); ?> <?php } ?> |
|---|
| | 165 | <?php if ( !empty( $comment->comment_author_url ) && $comment->comment_author_url != 'http://' ) { ?>| <?php comment_author_url_link(); ?> <?php } ?> |
|---|
| | 166 | | <?php _e( 'IP:' ); ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP(); ?>"><?php comment_author_IP(); ?></a> |
|---|
| | 167 | </p> |
|---|
| | 168 | |
|---|
| | 169 | <p><small> |
|---|
| | 170 | <?php comment_date( __( 'M j, g:i A' ) ); ?> — |
|---|
| | 171 | [ <a href="comment.php?action=editcomment&c=<?php comment_ID(); ?>" title="<?php _e( 'Edit this comment' ); ?>"><?php _e( 'Edit' ); ?></a> | |
|---|
| | 172 | <a href="post.php?action=deletecomment&p=<?php echo $comment->comment_post_ID; ?>" title="<?php _e( 'Delete this comment' ); ?>" onclick="return deleteSomething( 'comment', <?php comment_ID(); ?>, '<?php echo js_escape( sprintf( __( 'You are about to delete this comment by \'%s\'.\n\'OK\' to delete, \'Cancel\' to stop.' ), get_comment_author() ) ); ?>', theCommentList );"><?php _e( 'Delete' ); ?></a> ] — |
|---|
| | 173 | <a href="<?php echo get_permalink( $comment->comment_post_ID ); ?>" title="<?php _e( 'View the post' ); ?>"><?php printf( __( 'View post “%s”' ), get_the_title( $comment->comment_post_ID ) ); ?></a> |
|---|
| | 174 | </small></p> |
|---|
| | 175 | |
|---|
| | 176 | <p> |
|---|
| | 177 | <?php comment_text(); ?> |
|---|
| | 178 | </p> |
|---|
| | 179 | |
|---|
| | 180 | <p><small> |
|---|
| | 181 | <?php _e( 'Bulk action:' ); ?> |
|---|
| | 182 | <label for="comment-<?php comment_ID(); ?>-approve"><input type="radio" name="comment[<?php comment_ID(); ?>]" id="comment-<?php comment_ID(); ?>-approve" value="approve" /> <?php _e( 'Approve' ); ?></label> |
|---|
| | 183 | <label for="comment-<?php comment_ID(); ?>-spam"><input type="radio" name="comment[<?php comment_ID(); ?>]" id="comment-<?php comment_ID(); ?>-spam" value="spam" /> <?php _e( 'Spam' ); ?></label> |
|---|
| | 184 | <label for="comment-<?php comment_ID(); ?>-delete"><input type="radio" name="comment[<?php comment_ID(); ?>]" id="comment-<?php comment_ID(); ?>-delete" value="delete" /> <?php _e( 'Delete' ); ?></label> |
|---|
| | 185 | <label for="comment-<?php comment_ID(); ?>-nothing"><input type="radio" name="comment[<?php comment_ID(); ?>]" id="comment-<?php comment_ID(); ?>-nothing" value="later" checked="checked" /> <?php _e( 'No action' ); ?></label> |
|---|
| | 186 | </small></p> |
|---|
| | 187 | </li> |
|---|
| | 188 | <?php |
|---|
| | 189 | } |
|---|
| | 190 | ?> |
|---|
| | 191 | </ol> |
|---|
| | 192 | |
|---|
| | 193 | <?php |
|---|
| | 194 | if ( $page_links ) { |
|---|
| | 195 | echo '<p class="pagenav">' . $page_links . '</p>'; |
|---|
| | 196 | } |
|---|
| | 197 | ?> |
|---|
| | 198 | |
|---|
| | 199 | <div id="ajax-response"></div> |
|---|
| | 200 | |
|---|
| | 201 | <noscript> |
|---|
| | 202 | <p class="submit"> |
|---|
| | 203 | <label for="feelinglucky"><input name="feelinglucky" id="feelinglucky" type="checkbox" value="true" /> <?php _e( 'Delete every comment marked “defer.” <strong>Warning: This can’t be undone.</strong>' ); ?></label> |
|---|
| | 204 | </p> |
|---|
| | 205 | </noscript> |
|---|
| | 206 | |
|---|
| | 207 | <p class="submit"> |
|---|
| | 208 | <input type="submit" id="submit" name="submit" value="<?php _e( 'Bulk Moderate Comments »' ); ?>" /> |
|---|
| | 209 | </p> |
|---|
| | 210 | |
|---|
| | 211 | <script type="text/javascript"> |
|---|
| | 212 | // <![CDATA[ |
|---|
| | 213 | function mark_all_as( what ) { |
|---|
| | 214 | for ( var i = 0; i < document.approval.length; i++ ) { |
|---|
| | 215 | if ( document.approval[i].value == what ) { |
|---|
| | 216 | document.approval[i].checked = true; |
|---|
| | 217 | } |
|---|
| | 218 | } |
|---|
| | 219 | } |
|---|
| | 220 | |
|---|
| | 221 | document.write( '<p style="text-align:center;"><strong><?php _e( 'Mark all:' ); ?></strong> <a href="javascript:mark_all_as(\'approve\')"><?php _e( 'Approved' ); ?></a> – <a href="javascript:mark_all_as(\'spam\')"><?php _e( 'Spam' ); ?></a> – <a href="javascript:mark_all_as(\'delete\')"><?php _e( 'Deleted' ); ?></a> – <a href="javascript:mark_all_as(\'later\')"><?php _e( 'Later' ); ?></a></p>' ); |
|---|
| | 222 | // ]]> |
|---|
| | 223 | </script> |
|---|
| | 224 | </form> |
|---|