prefix.'author_performance ( `id` int(11) NOT NULL AUTO_INCREMENT, `post_title` text NOT NULL, `post_id` int(11) NOT NULL, `post_author_id` int(11) NOT NULL, `word_count` int(11) NOT NULL, `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1;'; $wpdb->query($query); } function author_performance_top_authors_by_word_count ($count,$usermeta='yes') { global $wpdb; $rec1=$wpdb->get_results("select SUM(word_count) as wc,COUNT(id) as tc,post_author_id from $wpdb->prefix"."author_performance group by post_author_id order by wc desc limit $count"); foreach ($rec1 as $rec2) { $a++; $top_authors[$a]['author_id']=$rec2->post_author_id; $top_authors[$a]['word_count']=$rec2->wc; $top_authors[$a]['post_count']=$rec2->tc; if ($usermeta=='yes') { $user_data=$wpdb->get_row("select * from $wpdb->users where ID=$rec2->post_author_id"); $top_authors[$a]['display_name']=$user_data->display_name; $top_authors[$a]['login_name']=$user_data->user_login; } } return $top_authors; } // TOP AUTHORS BY TITLE COUNT function author_performance_top_authors_by_post_count ($count,$usermeta='yes') { global $wpdb; $rec1=$wpdb->get_results("select SUM(word_count) as wc,COUNT(id) as tc,post_author_id from $wpdb->prefix"."author_performance group by post_author_id order by tc desc limit $count"); foreach ($rec1 as $rec2) { $a++; $top_authors[$a]['author_id']=$rec2->post_author_id; $top_authors[$a]['word_count']=$rec2->wc; $top_authors[$a]['post_count']=$rec2->tc; if ($usermeta=='yes') { $user_data=$wpdb->get_row("select * from $wpdb->users where ID=$rec2->post_author_id"); $top_authors[$a]['display_name']=$user_data->display_name; $top_authors[$a]['login_name']=$user_data->user_login; } } return $top_authors; } // LONGEST POSTS function author_performance_longest_posts ($count,$usermeta='yes') { global $wpdb; $rec1=$wpdb->get_results("select * from $wpdb->prefix"."author_performance order by word_count desc limit $count"); foreach ($rec1 as $rec2) { $a++; $top_authors[$a]['post_title']=$rec2->post_title; $top_authors[$a]['word_count']=$rec2->word_count; $top_authors[$a]['link']=$wpdb->get_var("select guid from $wpdb->posts where ID=$rec2->post_id"); if ($usermeta=='yes') { $user_data=$wpdb->get_row("select * from $wpdb->users where ID=$rec2->post_author_id"); $top_authors[$a]['display_name']=$user_data->display_name; $top_authors[$a]['login_name']=$user_data->user_login; } } return $top_authors; } // LONGEST POST BY AUTHOR function author_performance_longest_post_by_author ($authorid,$count) { global $wpdb; $rec1=$wpdb->get_results("select * from $wpdb->prefix"."author_performance where post_author_id=$authorid order by word_count desc limit $count"); foreach ($rec1 as $rec2) { $a++; $top_authors[$a]['post_title']=$rec2->post_title; $top_authors[$a]['word_count']=$rec2->word_count; $top_authors[$a]['link']=$wpdb->get_var("select guid from $wpdb->posts where ID=$rec2->post_id"); } return $top_authors; } function author_performance_update() { global $wpdb; $recs=$wpdb->get_results("SELECT ID, post_title,post_content,post_author FROM $wpdb->prefix"."posts WHERE post_type='post' AND post_status='publish' ORDER BY ID DESC"); foreach ($recs as $record) { $word_count=count(str_word_count($record->post_content,1,'öçÖÇŞİşiIğĞüÜ')); $yaz=$wpdb->query("INSERT INTO $wpdb->prefix"."author_performance (post_title,post_id,post_author_id,word_count) VALUES ('$record->post_title',$record->ID , $record->post_author, $word_count)"); } echo "
Table updated. Click here.
"; } function author_performance_update_table() { // DO I HAVE TO UPDATE? if (get_option("author_performance_count_on_save")=='1'){ global $wpdb; $del=$wpdb->query("TRUNCATE $wpdb->prefix"."author_performance"); //echo "update"; } } function author_performance_options() { global $wpdb; $rec_count=$wpdb->get_var("select count(id) from $wpdb->prefix"."author_performance"); ?>