140 | | echo "<ol id='the-comment-list' class='commentlist' $start>"; |
141 | | $i = 0; |
142 | | foreach ($comments as $comment) { |
143 | | ++$i; $class = ''; |
144 | | $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID")); |
145 | | $comment_status = wp_get_comment_status($comment->comment_ID); |
146 | | if ('unapproved' == $comment_status) |
147 | | $class .= ' unapproved'; |
148 | | if ($i % 2) |
149 | | $class .= ' alternate'; |
150 | | echo "<li id='comment-$comment->comment_ID' class='$class'>"; |
151 | | ?> |
152 | | <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> |
153 | | |
154 | | <?php comment_text() ?> |
155 | | |
156 | | <p><?php comment_date('M j, g:i A'); ?> — [ |
157 | | <?php |
158 | | if ( current_user_can('edit_post', $comment->comment_post_ID) ) { |
159 | | echo " <a href='comment.php?action=editcomment&c=".$comment->comment_ID."'>" . __('Edit') . '</a>'; |
160 | | 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> '; |
161 | | if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) { |
162 | | 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>'; |
163 | | 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>'; |
164 | | } |
165 | | 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> "; |
166 | | } |
167 | | $post = get_post($comment->comment_post_ID); |
168 | | $post_title = wp_specialchars( $post->post_title, 'double' ); |
169 | | $post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title; |
170 | | ?> |
171 | | | <a href="<?php echo get_permalink($comment->comment_post_ID); ?>" title="<?php echo $post_title; ?>"><?php _e('View Post') ?></a> ]</p> |
172 | | </li> |
173 | | |
174 | | <?php } // end foreach($comment) ?> |
175 | | </ol> |
176 | | |
177 | | <div id="ajax-response"></div> |
178 | | |
179 | | <?php |
180 | | } else { //no comments to show |
181 | | |
182 | | ?> |
183 | | <p> |
184 | | <strong><?php _e('No comments found.') ?></strong></p> |
185 | | |
186 | | <?php |
187 | | } // end if ($comments) |
188 | | } elseif ('edit' == $mode) { |
189 | | |
190 | | if ($comments) { |
191 | | echo '<form name="deletecomments" id="deletecomments" action="" method="post"> '; |
192 | | wp_nonce_field('bulk-comments'); |
193 | | echo '<table class="widefat"> |
194 | | <thead> |
195 | | <tr> |
196 | | <th scope="col" style="text-align: center"><input type="checkbox" onclick="checkAll(document.getElementById(\'deletecomments\'));" /></th> |
197 | | <th scope="col">' . __('Name') . '</th> |
198 | | <th scope="col">' . __('E-mail') . '</th> |
199 | | <th scope="col">' . __('IP') . '</th> |
200 | | <th scope="col">' . __('Comment Excerpt') . '</th> |
201 | | <th scope="col" colspan="3" style="text-align: center">' . __('Actions') . '</th> |
202 | | </tr> |
203 | | </thead>'; |
204 | | foreach ($comments as $comment) { |
205 | | $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID")); |
206 | | $comment_status = wp_get_comment_status($comment->comment_ID); |
207 | | $class = ('alternate' == $class) ? '' : 'alternate'; |
208 | | $class .= ('unapproved' == $comment_status) ? ' unapproved' : ''; |
209 | | ?> |
210 | | <tr id="comment-<?php echo $comment->comment_ID; ?>" class='<?php echo $class; ?>'> |
211 | | <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> |
212 | | <td><?php comment_author_link() ?></td> |
213 | | <td><?php comment_author_email_link() ?></td> |
214 | | <td><a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></td> |
215 | | <td><?php comment_excerpt(); ?></td> |
216 | | <td> |
217 | | <?php if ('unapproved' == $comment_status) { ?> |
218 | | (Unapproved) |
219 | | <?php } else { ?> |
220 | | <a href="<?php echo get_permalink($comment->comment_post_ID); ?>#comment-<?php comment_ID() ?>" class="edit"><?php _e('View') ?></a> |
221 | | <?php } ?> |
222 | | </td> |
223 | | <td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) { |
224 | | echo "<a href='comment.php?action=editcomment&c=$comment->comment_ID' class='edit'>" . __('Edit') . "</a>"; } ?></td> |
225 | | <td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) { |
226 | | 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> "; |
227 | | } ?></td> |
228 | | </tr> |
229 | | <?php |
230 | | } // end foreach |
231 | | ?></table> |
232 | | <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 + '"); ?>')" /> |
233 | | <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> |
234 | | </form> |
235 | | <div id="ajax-response"></div> |
236 | | <?php |
237 | | } else { |
238 | | ?> |
239 | | <p> |
240 | | <strong><?php _e('No results found.') ?></strong> |
241 | | </p> |
242 | | <?php |
243 | | } // end if ($comments) |
244 | | } |
245 | | ?> |
246 | | <?php if ( $total > 20 ) { |
247 | | $total_pages = ceil( $total / 20 ); |
248 | | $r = ''; |
249 | | if ( 1 < $page ) { |
250 | | $args['apage'] = ( 1 == $page - 1 ) ? FALSE : $page - 1; |
251 | | $r .= '<a class="prev" href="' . add_query_arg( $args ) . '">« '. __('Previous Page') .'</a>' . "\n"; |
252 | | } |
253 | | if ( ( $total_pages = ceil( $total / 20 ) ) > 1 ) { |
254 | | for ( $page_num = 1; $page_num <= $total_pages; $page_num++ ) : |
255 | | if ( $page == $page_num ) : |
256 | | $r .= "<span>$page_num</span>\n"; |
257 | | else : |
258 | | $p = false; |
259 | | if ( $page_num < 3 || ( $page_num >= $page - 3 && $page_num <= $page + 3 ) || $page_num > $total_pages - 3 ) : |
260 | | $args['apage'] = ( 1 == $page_num ) ? FALSE : $page_num; |
261 | | $r .= '<a class="page-numbers" href="' . add_query_arg($args) . '">' . ( $page_num ) . "</a>\n"; |
262 | | $in = true; |
263 | | elseif ( $in == true ) : |
264 | | $r .= "...\n"; |
265 | | $in = false; |
266 | | endif; |
267 | | endif; |
268 | | endfor; |
269 | | } |
270 | | if ( ( $page ) * 20 < $total || -1 == $total ) { |
271 | | $args['apage'] = $page + 1; |
272 | | $r .= '<a class="next" href="' . add_query_arg($args) . '">'. __('Next Page') .' »</a>' . "\n"; |
273 | | } |
274 | | echo "<p class='pagenav'>$r</p>"; |
275 | | ?> |
276 | | |
277 | | <?php } ?> |
278 | | |