Author Stats


get_author_select(); ?>
'adminsistrator', 'fields' => array('ID','display_name')); $admins = get_users($args); $args = array('role' => 'editor', 'fields' => array('ID','display_name')); $editors = get_users($args); $args = array('role' => 'author', 'fields' => array('ID','display_name')); $authors = get_users($args); $args = array('role' => 'contributor', 'fields' => array('ID','display_name')); $contributors = get_users($args); $text = ''; return $text; } function get_post_stats($author, $status, $time) { global $wpdb; $sql = "SELECT count(ID) as c FROM ". $wpdb->posts . " WHERE post_author=". $author; $sql .= " and post_status='" . $status . "'"; if ($time) { $sql .= " and post_date BETWEEN DATE_SUB(NOW(), INTERVAL ". $time ." DAY) AND NOW();"; } return $wpdb->get_row($sql); } function get_comment_stats($author, $time) { global $wpdb; $sql = "SELECT ID, post_title, comment_count as c FROM " . $wpdb->posts . " WHERE post_author=" . $author; $sql .= " and post_status='publish'"; $sql .= " AND comment_count > 0"; if ($time) { $sql .= " and post_date BETWEEN DATE_SUB(NOW(), INTERVAL ". $time . " DAY) AND NOW() "; $sql .= "ORDER BY comment_count DESC LIMIT 1;"; } return $wpdb->get_row($sql); } function get_comment_avg($author, $time) { global $wpdb; $sql = "SELECT format(avg(comment_count), 1) as c FROM " . $wpdb->posts . " WHERE post_author=" . $author; $sql .= " and post_status='publish'"; if ($time) { $sql .= " and post_date BETWEEN DATE_SUB(NOW(), INTERVAL " . $time . " DAY) AND NOW()"; } return $wpdb->get_row($sql); } function get_word_count_avg($author, $time) { global $wpdb; $sql = "SELECT ID, post_content FROM " . $wpdb->posts . " WHERE post_author=" . $author; $sql .= " and post_status='publish'"; if ($time) { $sql .= " and post_date BETWEEN DATE_SUB(NOW(), INTERVAL " . $time . " DAY) AND NOW()"; } $rows = $wpdb->get_results($sql); $c = array(); $d = array(); foreach ($rows as $row) { $result = preg_split('/((^\p{P}+)|(\p{P}*\s+\p{P}*)|(\p{P}+$))/', strip_tags($row->post_content), -1, PREG_SPLIT_NO_EMPTY); array_push($c, count($result)); array_push($d, array('id' => $row->ID, 'c' => count($result))); } return intval(array_sum($c)/count($c)); } function get_inch_count_avg($author, $time) { global $wpdb; $sql = "SELECT post_content as c FROM " . $wpdb->posts . " WHERE post_author=" . $author; $sql .= " and post_status='publish'"; if ($time) { $sql .= " and post_date BETWEEN DATE_SUB(NOW(), INTERVAL " . $time . " DAY) AND NOW()"; } $r = $wpdb->get_results($sql); $options = get_option( COLUMN_INCHES_OPTION ); $column_inches = $options['words_inch']; $words = $r->c; $num_counts = count($column_inches); $v = array(); $c = 0; foreach ($r as $row) { $c++; $post_plaintext = strip_tags( $row->c ); $words = str_word_count( $post_plaintext ); // Display column inches for ($i = 0; $i < $num_counts; $i++) { $column_inch = $column_inches[$i]; $name = $column_inch['name']; $inches = ceil( $words / $column_inch['count'] ); $v[$name] += $inches; } } $rv = array(); foreach (array_keys($v) as $r) { $v[$r] = intval($v[$r]/$c); array_push($rv, $v[$r]); } return implode(" / ", $rv); } } ?>