-
+ 5BCB68D3A075D461B9B1EAE9921DF9D6E4BAEC9822C47C88B39845DA08B5E15F2A674851FBD2EFC744F6381BFF89DC9D619FFF0B13773A60396F904600D9DB04
mp-wp/wp-admin/edit-comments.php
(0 . 0)(1 . 388)
9882 <?php
9883 /**
9884 * Edit Comments Administration Panel.
9885 *
9886 * @package WordPress
9887 * @subpackage Administration
9888 */
9889
9890 /** WordPress Administration Bootstrap */
9891 require_once('admin.php');
9892
9893 wp_enqueue_script('admin-comments');
9894 enqueue_comment_hotkeys_js();
9895
9896 $post_id = isset($_REQUEST['p']) ? (int) $_REQUEST['p'] : 0;
9897
9898 if ( ( isset( $_REQUEST['delete_all_spam'] ) || isset( $_REQUEST['delete_all_spam2'] ) ) && !empty( $_REQUEST['pagegen_timestamp'] ) ) {
9899 check_admin_referer('bulk-spam-delete', '_spam_nonce');
9900
9901 $delete_time = $wpdb->escape( $_REQUEST['pagegen_timestamp'] );
9902 $deleted_spam = $wpdb->query( "DELETE FROM $wpdb->comments WHERE comment_approved = 'spam' AND '$delete_time' > comment_date_gmt" );
9903
9904 $redirect_to = 'edit-comments.php?comment_status=spam&deleted=' . (int) $deleted_spam;
9905 if ( $post_id )
9906 $redirect_to = add_query_arg( 'p', absint( $post_id ), $redirect_to );
9907 wp_redirect( $redirect_to );
9908 } elseif ( isset($_REQUEST['delete_comments']) && isset($_REQUEST['action']) && ( -1 != $_REQUEST['action'] || -1 != $_REQUEST['action2'] ) ) {
9909 check_admin_referer('bulk-comments');
9910 $doaction = ( -1 != $_REQUEST['action'] ) ? $_REQUEST['action'] : $_REQUEST['action2'];
9911
9912 $deleted = $approved = $unapproved = $spammed = 0;
9913 foreach ( (array) $_REQUEST['delete_comments'] as $comment_id) : // Check the permissions on each
9914 $comment_id = (int) $comment_id;
9915 $_post_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = %d", $comment_id) );
9916
9917 if ( !current_user_can('edit_post', $_post_id) )
9918 continue;
9919
9920 switch( $doaction ) {
9921 case 'markspam' :
9922 wp_set_comment_status($comment_id, 'spam');
9923 $spammed++;
9924 break;
9925 case 'delete' :
9926 wp_set_comment_status($comment_id, 'delete');
9927 $deleted++;
9928 break;
9929 case 'approve' :
9930 wp_set_comment_status($comment_id, 'approve');
9931 $approved++;
9932 break;
9933 case 'unapprove' :
9934 wp_set_comment_status($comment_id, 'hold');
9935 $unapproved++;
9936 break;
9937 }
9938 endforeach;
9939
9940 $redirect_to = 'edit-comments.php?deleted=' . $deleted . '&approved=' . $approved . '&spam=' . $spammed . '&unapproved=' . $unapproved;
9941 if ( $post_id )
9942 $redirect_to = add_query_arg( 'p', absint( $post_id ), $redirect_to );
9943 if ( isset($_REQUEST['apage']) )
9944 $redirect_to = add_query_arg( 'apage', absint($_REQUEST['apage']), $redirect_to );
9945 if ( !empty($_REQUEST['mode']) )
9946 $redirect_to = add_query_arg('mode', $_REQUEST['mode'], $redirect_to);
9947 if ( !empty($_REQUEST['comment_status']) )
9948 $redirect_to = add_query_arg('comment_status', $_REQUEST['comment_status'], $redirect_to);
9949 if ( !empty($_REQUEST['s']) )
9950 $redirect_to = add_query_arg('s', $_REQUEST['s'], $redirect_to);
9951 wp_redirect( $redirect_to );
9952 } elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
9953 wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
9954 exit;
9955 }
9956
9957 if ( $post_id )
9958 $title = sprintf(__('Edit Comments on “%s”'), wp_html_excerpt(_draft_or_post_title($post_id), 50));
9959 else
9960 $title = __('Edit Comments');
9961
9962 require_once('admin-header.php');
9963
9964 $mode = ( ! isset($_GET['mode']) || empty($_GET['mode']) ) ? 'detail' : attribute_escape($_GET['mode']);
9965
9966 $comment_status = !empty($_GET['comment_status']) ? attribute_escape($_GET['comment_status']) : '';
9967
9968 $comment_type = !empty($_GET['comment_type']) ? attribute_escape($_GET['comment_type']) : '';
9969
9970 $search_dirty = ( isset($_GET['s']) ) ? $_GET['s'] : '';
9971 $search = attribute_escape( $search_dirty ); ?>
9972
9973 <div class="wrap">
9974 <?php screen_icon(); ?>
9975 <h2><?php echo wp_specialchars( $title );
9976 if ( isset($_GET['s']) && $_GET['s'] )
9977 printf( '<span class="subtitle">' . sprintf( __( 'Search results for “%s”' ), wp_html_excerpt( wp_specialchars( stripslashes( $_GET['s'] ) ), 50 ) ) . '</span>' ); ?>
9978 </h2>
9979
9980 <?php
9981 if ( isset( $_GET['approved'] ) || isset( $_GET['deleted'] ) || isset( $_GET['spam'] ) ) {
9982 $approved = isset( $_GET['approved'] ) ? (int) $_GET['approved'] : 0;
9983 $deleted = isset( $_GET['deleted'] ) ? (int) $_GET['deleted'] : 0;
9984 $spam = isset( $_GET['spam'] ) ? (int) $_GET['spam'] : 0;
9985
9986 if ( $approved > 0 || $deleted > 0 || $spam > 0 ) {
9987 echo '<div id="moderated" class="updated fade"><p>';
9988
9989 if ( $approved > 0 ) {
9990 printf( __ngettext( '%s comment approved', '%s comments approved', $approved ), $approved );
9991 echo '<br />';
9992 }
9993
9994 if ( $deleted > 0 ) {
9995 printf( __ngettext( '%s comment deleted', '%s comments deleted', $deleted ), $deleted );
9996 echo '<br />';
9997 }
9998
9999 if ( $spam > 0 ) {
10000 printf( __ngettext( '%s comment marked as spam', '%s comments marked as spam', $spam ), $spam );
10001 echo '<br />';
10002 }
10003
10004 echo '</p></div>';
10005 }
10006 }
10007 ?>
10008
10009 <form id="comments-form" action="" method="get">
10010 <ul class="subsubsub">
10011 <?php
10012 $status_links = array();
10013 $num_comments = ( $post_id ) ? wp_count_comments( $post_id ) : wp_count_comments();
10014 //, number_format_i18n($num_comments->moderated) ), "<span class='comment-count'>" . number_format_i18n($num_comments->moderated) . "</span>"),
10015 //, number_format_i18n($num_comments->spam) ), "<span class='spam-comment-count'>" . number_format_i18n($num_comments->spam) . "</span>")
10016 $stati = array(
10017 'all' => __ngettext_noop('All', 'All'), // singular not used
10018 'moderated' => __ngettext_noop('Pending (<span class="pending-count">%s</span>)', 'Pending (<span class="pending-count">%s</span>)'),
10019 'approved' => __ngettext_noop('Approved', 'Approved'), // singular not used
10020 'spam' => __ngettext_noop('Spam (<span class="spam-count">%s</span>)', 'Spam (<span class="spam-count">%s</span>)')
10021 );
10022 $class = ( '' === $comment_status ) ? ' class="current"' : '';
10023 // $status_links[] = "<li><a href='edit-comments.php'$class>" . __( 'All' ) . '</a>';
10024 $link = 'edit-comments.php';
10025 if ( !empty($comment_type) && 'all' != $comment_type )
10026 $link = add_query_arg( 'comment_type', $comment_type, $link );
10027 foreach ( $stati as $status => $label ) {
10028 $class = '';
10029
10030 if ( str_replace( 'all', '', $status ) == $comment_status )
10031 $class = ' class="current"';
10032 if ( !isset( $num_comments->$status ) )
10033 $num_comments->$status = 10;
10034 if ( 'all' != $status )
10035 $link = add_query_arg( 'comment_status', $status, $link );
10036 if ( $post_id )
10037 $link = add_query_arg( 'p', absint( $post_id ), $link );
10038 /*
10039 // I toyed with this, but decided against it. Leaving it in here in case anyone thinks it is a good idea. ~ Mark
10040 if ( !empty( $_GET['s'] ) )
10041 $link = add_query_arg( 's', attribute_escape( stripslashes( $_GET['s'] ) ), $link );
10042 */
10043 $status_links[] = "<li class='$status'><a href='$link'$class>" . sprintf(
10044 __ngettext( $label[0], $label[1], $num_comments->$status ),
10045 number_format_i18n( $num_comments->$status )
10046 ) . '</a>';
10047 }
10048
10049 $status_links = apply_filters( 'comment_status_links', $status_links );
10050
10051 echo implode( " |</li>\n", $status_links) . '</li>';
10052 unset($status_links);
10053 ?>
10054 </ul>
10055
10056 <p class="search-box">
10057 <label class="hidden" for="comment-search-input"><?php _e( 'Search Comments' ); ?>:</label>
10058 <input type="text" class="search-input" id="comment-search-input" name="s" value="<?php _admin_search_query(); ?>" />
10059 <input type="submit" value="<?php _e( 'Search Comments' ); ?>" class="button" />
10060 </p>
10061
10062 <?php
10063 $comments_per_page = apply_filters('comments_per_page', 20, $comment_status);
10064
10065 if ( isset( $_GET['apage'] ) )
10066 $page = abs( (int) $_GET['apage'] );
10067 else
10068 $page = 1;
10069
10070 $start = $offset = ( $page - 1 ) * $comments_per_page;
10071
10072 list($_comments, $total) = _wp_get_comment_list( $comment_status, $search_dirty, $start, $comments_per_page + 5, $post_id, $comment_type ); // Grab a few extra
10073
10074 $_comment_post_ids = array();
10075 foreach ( $_comments as $_c ) {
10076 $_comment_post_ids[] = $_c->comment_post_ID;
10077 }
10078 $_comment_pending_count_temp = (array) get_pending_comments_num($_comment_post_ids);
10079 foreach ( (array) $_comment_post_ids as $_cpid )
10080 $_comment_pending_count[$_cpid] = isset( $_comment_pending_count_temp[$_cpid] ) ? $_comment_pending_count_temp[$_cpid] : 0;
10081 if ( empty($_comment_pending_count) )
10082 $_comment_pending_count = array();
10083
10084 $comments = array_slice($_comments, 0, $comments_per_page);
10085 $extra_comments = array_slice($_comments, $comments_per_page);
10086
10087 $page_links = paginate_links( array(
10088 'base' => add_query_arg( 'apage', '%#%' ),
10089 'format' => '',
10090 'prev_text' => __('«'),
10091 'next_text' => __('»'),
10092 'total' => ceil($total / $comments_per_page),
10093 'current' => $page
10094 ));
10095
10096 ?>
10097
10098 <input type="hidden" name="mode" value="<?php echo $mode; ?>" />
10099 <?php if ( $post_id ) : ?>
10100 <input type="hidden" name="p" value="<?php echo intval( $post_id ); ?>" />
10101 <?php endif; ?>
10102 <input type="hidden" name="comment_status" value="<?php echo $comment_status; ?>" />
10103 <input type="hidden" name="pagegen_timestamp" value="<?php echo current_time('mysql', 1); ?>" />
10104
10105 <div class="tablenav">
10106
10107 <?php if ( $page_links ) : ?>
10108 <div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s',
10109 number_format_i18n( $start + 1 ),
10110 number_format_i18n( min( $page * $comments_per_page, $total ) ),
10111 number_format_i18n( $total ),
10112 $page_links
10113 ); echo $page_links_text; ?></div>
10114 <?php endif; ?>
10115
10116 <div class="alignleft actions">
10117 <select name="action">
10118 <option value="-1" selected="selected"><?php _e('Bulk Actions') ?></option>
10119 <?php if ( empty($comment_status) || 'approved' == $comment_status ): ?>
10120 <option value="unapprove"><?php _e('Unapprove'); ?></option>
10121 <?php endif; ?>
10122 <?php if ( empty($comment_status) || 'moderated' == $comment_status || 'spam' == $comment_status ): ?>
10123 <option value="approve"><?php _e('Approve'); ?></option>
10124 <?php endif; ?>
10125 <?php if ( 'spam' != $comment_status ): ?>
10126 <option value="markspam"><?php _e('Mark as Spam'); ?></option>
10127 <?php endif; ?>
10128 <option value="delete"><?php _e('Delete'); ?></option>
10129 </select>
10130 <input type="submit" name="doaction" id="doaction" value="<?php _e('Apply'); ?>" class="button-secondary apply" />
10131 <?php wp_nonce_field('bulk-comments'); ?>
10132
10133 <?php if ( $comment_status ) echo "<input type='hidden' name='comment_status' value='$comment_status' />\n"; ?>
10134 <select name="comment_type">
10135 <option value="all"><?php _e('Show all comment types'); ?></option>
10136 <?php
10137 $comment_types = apply_filters( 'admin_comment_types_dropdown', array(
10138 'comment' => __('Comments'),
10139 'pings' => __('Pings'),
10140 ) );
10141
10142 foreach ( $comment_types as $type => $label ) {
10143 echo " <option value='$type'";
10144 selected( $comment_type, $type );
10145 echo ">$label</option>\n";
10146 }
10147 ?>
10148 </select>
10149 <input type="submit" id="post-query-submit" value="<?php _e('Filter'); ?>" class="button-secondary" />
10150
10151 <?php if ( isset($_GET['apage']) ) { ?>
10152 <input type="hidden" name="apage" value="<?php echo absint( $_GET['apage'] ); ?>" />
10153 <?php }
10154
10155 if ( 'spam' == $comment_status ) {
10156 wp_nonce_field('bulk-spam-delete', '_spam_nonce'); ?>
10157 <input type="submit" name="delete_all_spam" value="<?php _e('Delete All Spam'); ?>" class="button-secondary apply" />
10158 <?php } ?>
10159 <?php do_action('manage_comments_nav', $comment_status); ?>
10160 </div>
10161
10162 <br class="clear" />
10163
10164 </div>
10165
10166 <div class="clear"></div>
10167
10168 <?php if ( $comments ) { ?>
10169 <table class="widefat comments fixed" cellspacing="0">
10170 <thead>
10171 <tr>
10172 <?php print_column_headers('edit-comments'); ?>
10173 </tr>
10174 </thead>
10175
10176 <tfoot>
10177 <tr>
10178 <?php print_column_headers('edit-comments', false); ?>
10179 </tr>
10180 </tfoot>
10181
10182 <tbody id="the-comment-list" class="list:comment">
10183 <?php
10184 foreach ($comments as $comment)
10185 _wp_comment_row( $comment->comment_ID, $mode, $comment_status );
10186 ?>
10187 </tbody>
10188 <tbody id="the-extra-comment-list" class="list:comment" style="display: none;">
10189 <?php
10190 foreach ($extra_comments as $comment)
10191 _wp_comment_row( $comment->comment_ID, $mode, $comment_status );
10192 ?>
10193 </tbody>
10194 </table>
10195
10196 <div class="tablenav">
10197 <?php
10198 if ( $page_links )
10199 echo "<div class='tablenav-pages'>$page_links_text</div>";
10200 ?>
10201
10202 <div class="alignleft actions">
10203 <select name="action2">
10204 <option value="-1" selected="selected"><?php _e('Bulk Actions') ?></option>
10205 <?php if ( empty($comment_status) || 'approved' == $comment_status ): ?>
10206 <option value="unapprove"><?php _e('Unapprove'); ?></option>
10207 <?php endif; ?>
10208 <?php if ( empty($comment_status) || 'moderated' == $comment_status ): ?>
10209 <option value="approve"><?php _e('Approve'); ?></option>
10210 <?php endif; ?>
10211 <?php if ( 'spam' != $comment_status ): ?>
10212 <option value="markspam"><?php _e('Mark as Spam'); ?></option>
10213 <?php endif; ?>
10214 <option value="delete"><?php _e('Delete'); ?></option>
10215 </select>
10216 <input type="submit" name="doaction2" id="doaction2" value="<?php _e('Apply'); ?>" class="button-secondary apply" />
10217
10218 <?php if ( 'spam' == $comment_status ) { ?>
10219 <input type="submit" name="delete_all_spam2" value="<?php _e('Delete All Spam'); ?>" class="button-secondary apply" />
10220 <?php } ?>
10221 <?php do_action('manage_comments_nav', $comment_status); ?>
10222 </div>
10223
10224 <br class="clear" />
10225 </div>
10226
10227 </form>
10228
10229 <form id="get-extra-comments" method="post" action="" class="add:the-extra-comment-list:" style="display: none;">
10230 <input type="hidden" name="s" value="<?php echo $search; ?>" />
10231 <input type="hidden" name="mode" value="<?php echo $mode; ?>" />
10232 <input type="hidden" name="comment_status" value="<?php echo $comment_status; ?>" />
10233 <input type="hidden" name="page" value="<?php echo isset($_REQUEST['page']) ? absint( $_REQUEST['page'] ) : 1; ?>" />
10234 <input type="hidden" name="p" value="<?php echo attribute_escape( $post_id ); ?>" />
10235 <input type="hidden" name="comment_type" value="<?php echo attribute_escape( $comment_type ); ?>" />
10236 <?php wp_nonce_field( 'add-comment', '_ajax_nonce', false ); ?>
10237 </form>
10238
10239 <div id="ajax-response"></div>
10240
10241 <?php } elseif ( 'moderated' == $_GET['comment_status'] ) { ?>
10242 <p><?php _e('No comments awaiting moderation… yet.') ?></p>
10243 </form>
10244
10245 <?php } else { ?>
10246 <p><?php _e('No results found.') ?></p>
10247 </form>
10248
10249 <?php } ?>
10250 </div>
10251
10252 <script type="text/javascript">
10253 /* <![CDATA[ */
10254 (function($){
10255 $(document).ready(function(){
10256 $('#doaction, #doaction2').click(function(){
10257 if ( $('select[name^="action"]').val() == 'delete' ) {
10258 var m = '<?php echo js_escape(__("You are about to delete the selected comments.\n 'Cancel' to stop, 'OK' to delete.")); ?>';
10259 return showNotice.warn(m);
10260 }
10261 });
10262 });
10263 })(jQuery);
10264 /* ]]> */
10265 </script>
10266
10267 <?php
10268 wp_comment_reply('-1', true, 'detail');
10269 include('admin-footer.php'); ?>