Changeset 29728

Show
Ignore:
Timestamp:
01/21/08 23:00:41 (6 months ago)
Author:
MtDewVirus
Message:

Add option to count for single post

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • post-word-count/trunk/post-word-count.php

    r900 r29728  
    33Plugin Name: Post Word Count 
    44Plugin URI: http://mtdewvirus.com/code/wordpress-plugins/ 
    5 Description: Outputs the total number of words in all posts. 
    6 Version: 1.02 
     5Description: Outputs the total number of words in all posts or the number of words in a single post. 
     6Version: 1.1 
    77Author: Nick Momrik 
    88Author URI: http://mtdewvirus.com/ 
    99*/ 
    1010 
    11 function mdv_post_word_count() { 
    12     global $wpdb; 
     11function mdv_post_word_count($single = false) { 
     12    global $wpdb, $id; 
    1313      $now = gmdate("Y-m-d H:i:s",time()); 
    14       $words = $wpdb->get_results("SELECT post_content FROM $wpdb->posts WHERE post_status = 'publish' AND post_date < '$now'"); 
     14 
     15    if ($single) $query = "SELECT post_content FROM $wpdb->posts WHERE ID = '$id'"; 
     16      else $query = "SELECT post_content FROM $wpdb->posts WHERE post_status = 'publish' AND post_date < '$now'"; 
     17       
     18      $words = $wpdb->get_results($query); 
    1519      if ($words) { 
    1620            foreach ($words as $word) {