Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Template Name: Comments Central Page
- *
- *
- */
- ?>
- <?php get_header(); ?>
- <div id="container">
- <div id="content">
- <?php if (have_posts()) : ?>
- <?php while (have_posts()) : the_post(); ?>
- <div id="comments-central" class="post clearfloat">
- <h2 class="title"><?php the_title(); ?></h2>
- <!-- enough fluff, let's read! -->
- <div class="read page-content">
- <?php the_content('Read the rest of this entry »'); ?>
- <?php global $user_ID;
- if( $user_ID ) :
- if( current_user_can('level_10') ) : ?>
- <?php
- $num_comm = wp_count_comments();
- ?>
- <div id="comments-central-admin">
- <span>Total Comments: <a href="<?php bloginfo('wpurl'); ?>/wp-admin/edit-comments.php?"><? echo $num_comm->total_comments; ?></a></span>
- <span>Approved: <a href="<?php bloginfo('wpurl'); ?>/wp-admin/edit-comments.php?comment_status=approved"><? echo $num_comm->approved; ?></a></span>
- <span>Moderated: <a href="<?php bloginfo('wpurl'); ?>/wp-admin/edit-comments.php?comment_status=moderated"><? echo $num_comm->moderated; ?></a></span>
- <span>Spam: <a href="<?php bloginfo('wpurl'); ?>/wp-admin/edit-comments.php?comment_status=spam"><? echo $num_comm->spam; ?> </a></span>
- </div>
- <?php
- endif;
- endif; ?>
- <?php
- if(function_exists('activitysparks')) {
- ?><h3>Comments Activity in the last 2 years</h3>
- <?php
- activitysparks(array('dataset'=>'legend','height_px'=>100,'width_px'=>500,'period'=>30, 'ticks'=>24));
- } ?>
- <div class="comments-central-section">
- <h3>Recent Comments</h3>
- <ul>
- <?php
- // Recent comments
- $max = 10; // item to get
- global $wpdb;
- $sql = "SELECT c.*, p.post_title FROM $wpdb->comments c INNER JOIN $wpdb->posts p ON (c.comment_post_id=p.ID) WHERE comment_approved = '1' AND comment_type not in ('trackback','pingback')";
- $sql .= " ORDER BY comment_date DESC LIMIT $max";
- $results = $wpdb->get_results($sql);
- $template = '<div class="who">%g <a href="%au">%an</a> on <a href="%pu#comment-%cid">%pt</a></div>';
- $echoed=0;
- foreach ($results as $row) {
- $tags = array('%ct','%cd','%g','%pt','%pu','%au','%an','%cid');
- $replacements = array($row->comment_title,$row->comment_date,get_avatar($row->comment_author_email,'32'),$row->post_title,get_permalink($row->comment_post_ID),$row->comment_author_url,$row->comment_author,$row->comment_ID);
- echo '<li>' . str_replace($tags,$replacements,$template) . '<div class="said">'. $row->comment_content . '</div></li>';
- $echoed=1;
- }
- if ($echoed==0)
- echo '<li>None Found.</li>';
- ?>
- </ul>
- </div>
- <div class="comments-central-section">
- <h3>Recent Trackback / Pingback</h3>
- <ul>
- <?php
- // Recent trackback / pingback
- global $wpdb;
- $sql = "SELECT c.*, p.post_title FROM $wpdb->comments c INNER JOIN $wpdb->posts p ON (c.comment_post_id=p.ID) WHERE comment_approved = '1' AND comment_type in ('trackback','pingback')";
- $sql .= " ORDER BY comment_date DESC LIMIT $max";
- $results = $wpdb->get_results($sql);
- $template = '<a href="%au">%an</a> on <a href="%pu">%pt</a>';
- $echoed=0;
- foreach ($results as $row) {
- $tags = array('%ct','%cd','%g','%pt','%pu','%au','%an','%cid');
- $replacements = array($row->comment_title,$row->comment_date,get_avatar($row->comment_author_email,'32'),$row->post_title,get_permalink($row->comment_post_ID),$row->comment_author_url,$row->comment_author,$row->comment_ID);
- echo '<li>' . str_replace($tags,$replacements,$template) . '</li>';
- $echoed=1;
- }
- if ($echoed==0)
- echo '<li>None Found.</li>';
- ?>
- </ul>
- </div>
- <div class="comments-central-section">
- <h3>Most Active Discussions</h3>
- <ul>
- <?php
- // Most active discussion
- global $wpdb;
- $sql = "SELECT p.*, c.comment_count FROM $wpdb->posts p INNER JOIN (SELECT comment_post_id, count(comment_ID) as comment_count from $wpdb->comments WHERE comment_approved='1'";
- $sql .= " GROUP BY comment_post_id) c ON (c.comment_post_id=p.ID) ORDER BY c.comment_count DESC LIMIT $max";
- $results = $wpdb->get_results($sql);
- $template = '<a href="%pu">%pt</a> (%c comments)';
- $echoed=0;
- foreach ($results as $row) {
- $tags = array('%pd','%pt','%pu','%c');
- $replacements = array($row->post_date,$row->post_title,get_permalink($row->ID),$row->comment_count);
- echo '<li>' . str_replace($tags,$replacements,$template) . '</li>';
- $echoed=1;
- }
- if ($echoed==0)
- echo '<li>None Found.</li>';
- ?>
- </ul>
- </div>
- <div class="comments-central-section">
- <h3>Most Active Commenter</h3>
- <ul>
- <?php
- // Most active commenter
- global $wpdb;
- $sql = "SELECT comment_author, comment_author_url, comment_author_email, count(comment_ID) as comment_count FROM $wpdb->comments WHERE comment_approved = '1' AND comment_type not in ('trackback','pingback')";
- $sql .= " GROUP BY comment_author, comment_author_url, comment_author_email ORDER BY comment_count DESC LIMIT $max";
- $results = $wpdb->get_results($sql);
- $template = '<div class="who"<a href="%au">%g %an</a> (%c comments)</div>';
- $echoed=0;
- foreach ($results as $row) {
- $tags = array('%g','%au','%an','%c');
- $replacements = array(get_avatar($row->comment_author_email,'32'),$row->comment_author_url,$row->comment_author,$row->comment_count);
- echo '<li>' . str_replace($tags,$replacements,$template) . '</li>';
- $echoed=1;
- }
- if ($echoed==0)
- echo '<li>None Found.</li>';
- ?>
- </ul>
- </div>
- </div>
- </div> <!-- .post -->
- <?php endwhile; ?>
- <?php else : ?>
- <h2 class="center">Not Found</h2>
- <p class="center">Sorry, but you are looking for something that isn't here.</p>
- <?php endif; ?>
- </div> <!-- #content -->
- <?php get_sidebar(); ?>
- <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement