PHP Cross Reference of WordPress Subversion HEAD

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]

title

Body

[close]

/wp-admin/ -> moderation.php (source)

   1  <?php
   2  
   3  require_once  './admin.php';
   4  
   5  $title = __( 'Moderate Comments' );
   6  $parent_file = 'edit-comments.php';
   7  
   8  wp_enqueue_script( 'admin-comments' );
   9  
  10  wp_reset_vars( array( 'action', 'item_ignored', 'item_deleted', 'item_approved', 'item_spam', 'feelinglucky' ) );
  11  
  12  $comment = array();
  13  
  14  if ( isset( $_POST['comment'] ) && is_array( $_POST['comment'] ) ) {
  15      foreach ( $_POST['comment'] as $k => $v ) {
  16          $comment[intval( $k )] = $v;
  17      }
  18  }
  19  
  20  if ( $action == 'update' ) {
  21      check_admin_referer( 'moderate-comments' );
  22  
  23      if ( !current_user_can( 'moderate_comments' ) ) {
  24          wp_die( __( 'Your level is not high enough to moderate comments.' ) );
  25      }
  26  
  27      $item_ignored = 0;
  28      $item_deleted = 0;
  29      $item_approved = 0;
  30      $item_spam = 0;
  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 );
  57                  }
  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      }
 101  }
 102  
 103  ?>
 104  <div class="wrap">
 105  <?php
 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 = 100;
 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' => '&laquo;',
 133      'next_text' => '&raquo;'
 134  ) );
 135  
 136  $comments = array_slice( $comments, $start, $stop );
 137  
 138  ?>
 139      <h2><?php _e( 'Moderation Queue' ); ?></h2>
 140  
 141      <?php
 142          if ( $page_links ) {
 143              echo '<p class="pagenav">' . $page_links . '</p>';
 144          }
 145      ?>
 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-comment-list" class="list:comment 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              $delete_url  = clean_url( wp_nonce_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) );
 162              $approve_url = clean_url( wp_nonce_url( "comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "approve-comment_$comment->comment_ID" ) );
 163              $spam_url    = clean_url( wp_nonce_url( "comment.php?action=deletecomment&dt=spam&p=$comment->comment_post_ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) );
 164  
 165          ?>
 166              <li id="comment-<?php comment_ID(); ?>" class="<?php echo $class; ?>">
 167                  <p>
 168                      <strong><?php comment_author(); ?></strong>
 169                      <?php if ( !empty( $comment->comment_author_email ) ) { ?>| <?php comment_author_email_link(); ?> <?php } ?>
 170                      <?php if ( !empty( $comment->comment_author_url ) && $comment->comment_author_url != 'http://' ) { ?>| <?php comment_author_url_link(); ?> <?php } ?>
 171                      | <?php _e( 'IP:' ); ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP(); ?>"><?php comment_author_IP(); ?></a>
 172                  </p>
 173  
 174                  <p>
 175                      <?php comment_text(); ?>
 176                  </p>
 177  
 178                  <p>
 179                      <?php comment_date( __( 'M j, g:i A' ) ); ?>
 180                      &#8212;
 181                      [
 182                      <a href="comment.php?action=editcomment&amp;c=<?php comment_ID(); ?>" title="<?php _e( 'Edit this comment' ); ?>"><?php _e( 'Edit' ); ?></a>
 183                      |
 184                      <a href="<?php echo $delete_url; ?>" class="delete:the-comment-list:comment-<?php comment_ID(); ?>" title="<?php _e( 'Delete this comment' ); ?>"><?php _e( 'Delete' ); ?></a>
 185                      |
 186                      <a href="<?php echo $approve_url; ?>" class="delete:the-comment-list:comment-<?php comment_ID(); ?>:33FF33:action=dim-comment" title="<?php _e( 'Approve this comment' ); ?>"><?php _e( 'Approve' ); ?></a>
 187                      |
 188                      <a href="<?php echo $spam_url; ?>" class="delete:the-comment-list:comment-<?php comment_ID(); ?>::spam=1" title="<?php _e( 'Mark this comment as spam' ); ?>"><?php _e( 'Spam' ); ?></a>
 189                      ]
 190                      &#8212;
 191                      <a href="<?php echo get_permalink( $comment->comment_post_ID ); ?>" title="<?php _e( 'View the post' ); ?>"><?php printf( __( 'View post &#8220;%s&#8221;' ), get_the_title( $comment->comment_post_ID ) ); ?></a>
 192                  </p>
 193  
 194                  <p>
 195                      <?php _e( 'Bulk action:' ); ?>
 196                      <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> &nbsp;
 197                      <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> &nbsp;
 198                      <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> &nbsp;
 199                      <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>
 200                  </p>
 201              </li>
 202          <?php
 203          }
 204      ?>
 205          </ol>
 206  
 207          <?php
 208              if ( $page_links ) {
 209                  echo '<p class="pagenav">' . $page_links . '</p>';
 210              }
 211          ?>
 212  
 213          <div id="ajax-response"></div>
 214  
 215          <noscript>
 216              <p class="submit">
 217                  <label for="feelinglucky"><input name="feelinglucky" id="feelinglucky" type="checkbox" value="true" /> <?php _e( 'Delete every comment marked &#8220;defer.&#8221; <strong>Warning: This can&#8217;t be undone.</strong>' ); ?></label>
 218              </p>
 219          </noscript>
 220  
 221          <p class="submit">
 222              <input type="submit" id="submit" name="submit" value="<?php _e( 'Bulk Moderate Comments &raquo;' ); ?>" />
 223          </p>
 224  
 225          <script type="text/javascript">
 226          // <![CDATA[
 227  			function mark_all_as( what ) {
 228                  for ( var i = 0; i < document.approval.length; i++ ) {
 229                      if ( document.approval[i].value == what ) {
 230                          document.approval[i].checked = true;
 231                      }
 232                  }
 233              }
 234  
 235              document.write( '<p><strong><?php _e( 'Mark all:' ); ?></strong> <a href="javascript:mark_all_as(\'approve\')"><?php _e( 'Approved' ); ?></a> &ndash; <a href="javascript:mark_all_as(\'spam\')"><?php _e( 'Spam' ); ?></a> &ndash; <a href="javascript:mark_all_as(\'delete\')"><?php _e( 'Deleted' ); ?></a> &ndash; <a href="javascript:mark_all_as(\'later\')"><?php _e( 'Later' ); ?></a></p>' );
 236          // ]]>
 237          </script>
 238      </form>
 239  </div>
 240  <?php include_once  './admin-footer.php'; ?>


Generated Thu Dec 6 06:47:08 2007 for RedAlt XRefs Cross-referenced by PHPXref 0.6 and RedAlt