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.
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'"); $y2010summary_nopages = $wpdb->get_row("SELECT count($wpdb->posts.ID) as howmany FROM $wpdb->posts WHERE year(post_date)=2010 and post_type='page'"); $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_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"); echo mysql_error(); $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"); foreach ($y2010summary_commenters as $y2010summary_commenter) { $y2010summary_commentdata.='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:
The number of posts in each day of week:
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:
'; if($y2010summary_noauthors->howmany>1){ $y2010summary_text.='
This blog has many authors. Below you can find 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 '
'; echo $y2010summary_text; echo '
'; } ?>