Changeset 5229

Show
Ignore:
Timestamp:
02/18/06 05:16:44 (2 years ago)
Author:
GamerZ
Message:

Added Authro Stats

Location:
wp-stats/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • wp-stats/trunk/readme.txt

    r5122 r5229  
    1515- NEW: Slightly Changed The Grouping Of Stats 
    1616- NEW: WP-Stats Now Can Be Found ALso On The Dashboard 
     17- NEW: Added Author Status 
    1718- FIXED: Moved All Stats Functions To stats.php 
    1819 
  • wp-stats/trunk/stats.php

    r5124 r5229  
    4444            <h2>General Stats</h2> 
    4545            <ul> 
     46                  <li><b><?php get_totalauthors(); ?></b> Authors To This Blog.</li> 
    4647                  <li><b><?php get_totalposts(); ?></b> Posts Were Posted.</li> 
    4748                  <li><b><?php get_totalpages(); ?></b> Pages Were Created.</li> 
     
    153154      </div> 
    154155 
     156      <!-- Author Stats --> 
     157      <div class="wrap">             
     158            <h2>Authors Stats</h2> 
     159            <ol> 
     160                  <?php get_authorsstats(); ?> 
     161            </ol> 
     162      </div> 
     163 
    155164      <!-- Comments' Members Stats --> 
    156165      <div class="wrap">             
     
    182191 
    183192 
     193### Function: Get Total Authors 
     194function get_totalauthors() { 
     195      global $wpdb; 
     196      $totalauthors = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->users WHERE user_activation_key = ''"); 
     197      echo $totalauthors; 
     198} 
     199 
     200 
    184201### Function: Get Total Posts 
    185202function get_totalposts() { 
     
    233250                  $where = '(post_status = \'publish\' OR post_status = \'static\')'; 
    234251      } 
    235     $recentposts = $wpdb->get_results("SELECT $wpdb->posts.ID, post_title, post_name, post_status, post_date, user_login FROM $wpdb->posts LEFT JOIN $wpdb->users ON $wpdb->users.ID = $wpdb->posts.post_author WHERE post_date < '".current_time('mysql')."' AND $where AND post_password = '' ORDER  BY post_date DESC LIMIT $limit"); 
     252    $recentposts = $wpdb->get_results("SELECT $wpdb->posts.ID, post_title, post_name, post_status, post_date, user_login, display_name FROM $wpdb->posts LEFT JOIN $wpdb->users ON $wpdb->users.ID = $wpdb->posts.post_author WHERE post_date < '".current_time('mysql')."' AND $where AND post_password = '' ORDER  BY post_date DESC LIMIT $limit"); 
    236253      if($recentposts) { 
    237254            foreach ($recentposts as $post) { 
    238255                        $post_title = htmlspecialchars(stripslashes($post->post_title)); 
    239256                        $post_date = mysql2date('d.m.Y', $post->post_date); 
    240                         $user_nickname = htmlspecialchars(stripslashes($post->user_login)); 
    241                         echo "<li>$post_date - <a href=\"".get_permalink()."\">$post_title</a> ($user_nickname)</li>"; 
     257                        $display_name = htmlspecialchars(stripslashes($post->display_name)); 
     258                        echo "<li>$post_date - <a href=\"".get_permalink()."\">$post_title</a> ($display_name)</li>"; 
    242259            } 
    243260      } else { 
     
    289306                        $comment_total = intval($post->comment_total); 
    290307                        echo "<li><a href=\"".get_permalink()."\">$post_title</a> - $comment_total ".__('comments')."</li>"; 
     308            } 
     309      } else { 
     310            echo '<li>'.__('N/A').'</li>'; 
     311      } 
     312} 
     313 
     314 
     315### Function: Get Author Stats 
     316function  get_authorsstats() { 
     317      global $wpdb, $wp_rewrite; 
     318      $where = ''; 
     319      if($mode == 'post') { 
     320                  $where = 'post_status = \'publish\''; 
     321      } elseif($mode == 'page') { 
     322                  $where = 'post_status = \'static\''; 
     323      } else { 
     324                  $where = '(post_status = \'publish\' OR post_status = \'static\')'; 
     325      } 
     326      $posts = $wpdb->get_results("SELECT COUNT($wpdb->posts.ID) AS 'posts_total', $wpdb->users.display_name,  $wpdb->users.user_nicename FROM $wpdb->posts LEFT JOIN $wpdb->users ON $wpdb->users.ID = $wpdb->posts.post_author AND user_activation_key = '' AND $where GROUP BY $wpdb->posts.post_author"); 
     327      if($posts) { 
     328            $using_permalink = get_settings('permalink_structure'); 
     329            $permalink = $wp_rewrite->get_author_permastruct(); 
     330            foreach ($posts as $post) { 
     331                        $author_link = str_replace('%author%', strip_tags(stripslashes($post->user_nicename)), $permalink); 
     332                        $display_name = urlencode($post->display_name); 
     333                        $posts_total = intval($post->posts_total);                         
     334                        if($using_permalink) { 
     335                              echo "<li><a href=\"".get_settings('siteurl').$author_link."\">$display_name</a> ($posts_total)</li>"; 
     336                        } else { 
     337                              echo "<li><a href=\"".get_settings('siteurl')."/?author_name=$post_author\">$display_name</a> ($posts_total)</li>"; 
     338                        } 
    291339            } 
    292340      } else { 
     
    529577 
    530578 
     579### Function: Display UserOnline 
     580if(!function_exists('get_useronline')) { 
     581      function get_useronline($user = 'User', $users = 'Users', $display = true) { 
     582            global $useronline; 
     583            // Display User Online 
     584            if($display) { 
     585                  if($useronline > 1) { 
     586                        echo "<b>$useronline</b> $users ".__('Online'); 
     587                  } else { 
     588                        echo "<b>$useronline</b> $user ".__('Online'); 
     589                  } 
     590            } else { 
     591                  return $useronline; 
     592            } 
     593      } 
     594} 
     595 
     596 
    531597### Function: Display Max UserOnline 
    532598if(!function_exists('get_most_useronline')) { 
  • wp-stats/trunk/wp-stats.php

    r5124 r5229  
    3434            <h2 class="pagetitle">General Stats</h2> 
    3535            <ul> 
     36                  <li><b><?php get_totalauthors(); ?></b> Authors To This Blog.</li> 
    3637                  <li><b><?php get_totalposts(); ?></b> Posts Were Posted.</li> 
    3738                  <li><b><?php get_totalpages(); ?></b> Pages Were Created.</li> 
     
    138139            </ul> 
    139140 
     141            <!-- Author Stats --> 
     142            <h2 class="pagetitle">Authors Stats</h2> 
     143            <ol> 
     144                  <?php get_authorsstats(); ?> 
     145            </ol> 
     146 
    140147            <!-- Comments' Members Stats --> 
    141148            <h2 class="pagetitle">Comments' Members Stats</h2>