2010 Summary - whole year of blogging summarized

This plugin generates a brief summary of your blog for year 2010.

See how many posts you wrote durig the ending year, which were the most popular, who was the most active commenter etc.

And then share the stats with your readers - copy the data to a new draft with a single click.

'; if($_POST['y2010summary_generate']==TRUE){ y2010summary_generate(); } elseif($_POST['y2010summary_draft']==TRUE){ $my_post = array( 'post_title' => 'Summary of 2010', 'post_content' => base64_decode($_POST['y2010summary_draftcontent']), 'post_status' => 'draft', 'post_author' => $user_ID, ); // Insert the post into the database $postid=wp_insert_post( $my_post ); echo '

 

A draft of the new post has been created. You can now edit it and then publish.

'; echo'

 

 

'; } else { echo '
'; } echo '

 

 


Questions? Suggestions? Mail me: wpsummary@topa.pl or @tomasztopa. You can also check out my blog at www.tomasz.topa.pl

'; echo ''; } function y2010summary_generate(){ global $wpdb; $y2010summary_noposts = $wpdb->get_row("SELECT count($wpdb->posts.ID) as howmany FROM $wpdb->posts WHERE year(post_date)=2010 and post_type='post' and post_status='publish'"); $y2010summary_nopages = $wpdb->get_row("SELECT count($wpdb->posts.ID) as howmany FROM $wpdb->posts WHERE year(post_date)=2010 and post_type='page' and post_status='publish'"); $y2010summary_noattach = $wpdb->get_row("SELECT count($wpdb->posts.ID) as howmany FROM $wpdb->posts WHERE year(post_date)=2010 and $wpdb->posts.post_type='attachment'"); $y2010summary_noauthors = $wpdb->get_row("SELECT count($wpdb->users.ID) as howmany FROM $wpdb->users"); $y2010summary_nocomm = $wpdb->get_row("SELECT count($wpdb->comments.comment_ID) as howmany FROM $wpdb->comments WHERE year($wpdb->comments.comment_date)=2010 and $wpdb->comments.comment_type!='trackback' and $wpdb->comments.comment_approved=1"); $y2010summary_commbyauthors = $wpdb->get_results("SELECT count($wpdb->comments.comment_ID) as howmany, $wpdb->comments.user_id FROM $wpdb->comments WHERE year($wpdb->comments.comment_date)=2010 and $wpdb->comments.comment_type!='trackback' and $wpdb->comments.comment_approved=1 and $wpdb->comments.user_id>0 group by $wpdb->comments.user_id"); $y2010summary_nocommr = $wpdb->get_row("SELECT count($wpdb->comments.comment_ID) as howmany FROM $wpdb->comments WHERE year($wpdb->comments.comment_date)=2010 and comment_type!='trackback' and $wpdb->comments.user_id>0 and $wpdb->comments.comment_approved=1"); $y2010summary_months = $wpdb->get_results("SELECT count($wpdb->posts.ID) as howmany, month($wpdb->posts.post_date) as postmonth FROM $wpdb->posts WHERE year(post_date)=2010 and $wpdb->posts.post_type='post' group by postmonth order by postmonth asc"); $y2010summary_hours = $wpdb->get_results("SELECT count($wpdb->posts.ID) as howmany, hour($wpdb->posts.post_date) as posthour FROM $wpdb->posts WHERE year(post_date)=2010 and $wpdb->posts.post_type='post' group by posthour order by posthour asc"); $y2010summary_days = $wpdb->get_results("SELECT count($wpdb->posts.ID) as howmany, dayname($wpdb->posts.post_date) as postday, dayofweek($wpdb->posts.post_date) as postday2 FROM $wpdb->posts WHERE year(post_date)=2010 and $wpdb->posts.post_type='post' group by postday order by postday2 asc"); $y2010summary_postsbyauthors = $wpdb->get_results("SELECT count($wpdb->posts.ID) as howmany, $wpdb->posts.post_author FROM $wpdb->posts WHERE year(post_date)=2010 and $wpdb->posts.post_type='post' group by $wpdb->posts.post_author order by howmany desc"); $y2010summary_topcom = $wpdb->get_results("SELECT $wpdb->posts.comment_count, $wpdb->posts.post_title, $wpdb->posts.ID FROM $wpdb->posts WHERE year($wpdb->posts.post_date)=2010 and $wpdb->posts.post_type='post' order by comment_count desc limit 10"); $y2010summary_commenters = $wpdb->get_results("SELECT count($wpdb->comments.comment_ID) as howmany,$wpdb->comments.comment_author FROM $wpdb->comments WHERE year($wpdb->comments.comment_date)=2010 and comment_type!='trackback' and $wpdb->comments.comment_approved=1 and user_id=0 group by $wpdb->comments.comment_author order by howmany desc limit 10"); $y2010summary_commentsday = $wpdb->get_results("SELECT count($wpdb->comments.comment_ID) as howmany, dayname($wpdb->comments.comment_date) as commentday, dayofweek($wpdb->comments.comment_date) as commentday2 FROM $wpdb->comments WHERE year($wpdb->comments.comment_date)=2010 and comment_type!='trackback' and $wpdb->comments.comment_approved=1 group by commentday order by commentday2 asc"); $y2010summary_commentmonths = $wpdb->get_results("SELECT count($wpdb->comments.comment_ID) as howmany, month($wpdb->comments.comment_date) as commentmonth FROM $wpdb->comments WHERE year($wpdb->comments.comment_date)=2010 and comment_type!='trackback' and $wpdb->comments.comment_approved=1 group by commentmonth order by commentmonth asc"); $y2010summary_commenthours = $wpdb->get_results("SELECT count($wpdb->comments.comment_ID) as howmany, hour($wpdb->comments.comment_date) as commenthour FROM $wpdb->comments WHERE year($wpdb->comments.comment_date)=2010 and comment_type!='trackback' and $wpdb->comments.comment_approved=1 group by commenthour order by commenthour asc"); foreach ($y2010summary_commenters as $y2010summary_commenter) { $y2010summary_commentdata.='
  • '.$y2010summary_commenter->comment_author.': '.$y2010summary_commenter->howmany.' comments
  • '; } foreach ($y2010summary_months as $y2010summary_month) { $y2010summary_monthdata.=''.date("F",mktime(0,0,0,$y2010summary_month->postmonth,1,2010)).':
      '.$y2010summary_month->howmany.' ('.round($y2010summary_month->howmany/$y2010summary_noposts->howmany*100,2).'%)'; } foreach ($y2010summary_commentmonths as $y2010summary_commentmonth) { $y2010summary_commentmonthdata.=''.date("F",mktime(0,0,0,$y2010summary_commentmonth->commentmonth,1,2010)).':
      '.$y2010summary_commentmonth->howmany.' ('.round($y2010summary_commentmonth->howmany/$y2010summary_nocomm->howmany*100,2).'%)'; } foreach ($y2010summary_hours as $y2010summary_hour) { $y2010summary_hourdata.=''.$y2010summary_hour->posthour.':
      '.$y2010summary_hour->howmany.' ('.round($y2010summary_hour->howmany/$y2010summary_noposts->howmany*100,2).'%)'; } foreach ($y2010summary_commenthours as $y2010summary_commenthour) { $y2010summary_commenthourdata.=''.$y2010summary_commenthour->commenthour.':
      '.$y2010summary_commenthour->howmany.' ('.round($y2010summary_commenthour->howmany/$y2010summary_nocomm->howmany*100,2).'%)'; } foreach ($y2010summary_days as $y2010summary_day) { $y2010summary_daydata.=''.$y2010summary_day->postday.':
      '.$y2010summary_day->howmany.' ('.round($y2010summary_day->howmany/$y2010summary_noposts->howmany*100,2).'%)'; } foreach ($y2010summary_commentsday as $y2010summary_commentday) { $y2010summary_commentdaydata.=''.$y2010summary_commentday->commentday.':
      '.$y2010summary_commentday->howmany.' ('.round($y2010summary_commentday->howmany/$y2010summary_nocomm->howmany*100,2).'%)'; } foreach ($y2010summary_topcom as $y2010summary_post) { $y2010summary_postdata.='
  • '.$y2010summary_post->post_title.': '.$y2010summary_post->comment_count.' comments
  • '; } foreach ($y2010summary_postsbyauthors as $y2010summary_author) { $y2010summary_authorprofile=get_userdata($y2010summary_author->post_author); $y2010summary_authordata.='
  • '.$y2010summary_authorprofile->display_name.': '.$y2010summary_author->howmany.' posts
  • '; } foreach ($y2010summary_commbyauthors as $y2010summary_commauthor) { $y2010summary_authorprofile2=get_userdata($y2010summary_commauthor->user_id); $y2010summary_commauthordata.='
  • '.$y2010summary_authorprofile2->display_name.': '.$y2010summary_commauthor->howmany.' comments
  • '; } $y2010summary_text.='

    In 2010 you wrote '.$y2010summary_noposts->howmany.' posts and added '.$y2010summary_nopages->howmany.' pages to this blog, with '.$y2010summary_noattach->howmany.' attachments in total.

     

    The number of posts in each month:

    '.$y2010summary_monthdata.'

     

    The number of posts in each day of week:

    '.$y2010summary_daydata.'

    At what hours you publish new posts:

    '.$y2010summary_hourdata.'

     

    In 2010 your posts were commented '.$y2010summary_nocomm->howmany.' times, from which '.$y2010summary_nocommr->howmany.' comments ('.round($y2010summary_nocommr->howmany/$y2010summary_nocomm->howmany*100,2).'%) were written by registered users/authors.

     

    TOP 10 commenters in 2010:

     

    TOP 10 most commented posts in 2010:

     

    The number of comments in each month:

    '.$y2010summary_commentmonthdata.'

     

    On what days people comment:

    '.$y2010summary_commentdaydata.'

    At what hours people comment:

    '.$y2010summary_commenthourdata.'
    '; if($y2010summary_noauthors->howmany>1){ $y2010summary_text.='

    This blog has many authors. Here is the number of posts each one wrote:

     

    And the number of comments each one wrote:

     

    '; } $y2010summary_draft=base64_encode(str_replace(array('your','you','

     

    '), array('the','I',''), $y2010summary_text).'

    Summary generated by 2010 Summary plugin by Tomasz Topa.

    '); echo '

     

     

    2010 Summary

     

    '; echo $y2010summary_text; echo '
    '; echo '

     

    '; } ?>