PluginProbe
WP-Stats / 2.50
WP-Stats v2.50
3.0.1 3.0.0 trunk 1.00 2.00 2.01 2.02 2.03 2.04 2.05 2.06 2.10 2.11 2.20 2.30 2.31 2.40 2.50 2.55 2.56 2.56.1
wp-stats / wp-stats.php

wp-stats.php in WP-Stats 2.50, at wp-stats.php

883 lines 41.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: WP-Stats
4 Plugin URI: http://lesterchan.net/portfolio/programming/php/
5 Description: Display your WordPress blog statistics. Ranging from general total statistics, some of my plugins statistics and top 10 statistics.
6 Version: 2.50
7 Author: Lester 'GaMerZ' Chan
8 Author URI: http://lesterchan.net
9 */
10
11
12 /*
13 Copyright 2009 Lester Chan (email : lesterchan@gmail.com)
14
15 This program is free software; you can redistribute it and/or modify
16 it under the terms of the GNU General Public License as published by
17 the Free Software Foundation; either version 2 of the License, or
18 (at your option) any later version.
19
20 This program is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with this program; if not, write to the Free Software
27 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 */
29
30
31 ### Create Text Domain For Translations
32 add_action('init', 'stats_textdomain');
33 function stats_textdomain() {
34 load_plugin_textdomain('wp-stats', false, 'wp-stats');
35 }
36
37
38 ### Function: WP-Stats Menu
39 add_action('admin_menu', 'stats_menu');
40 function stats_menu() {
41 if (function_exists('add_submenu_page')) {
42 add_submenu_page('index.php', __('WP-Stats', 'wp-stats'), __('WP-Stats', 'wp-stats'), 1, 'wp-stats/wp-stats.php', 'display_stats');
43 }
44 if (function_exists('add_options_page')) {
45 add_options_page(__('Stats', 'wp-stats'), __('Stats', 'wp-stats'), 'manage_options', 'wp-stats/stats-options.php');
46 }
47 }
48
49
50 ### Function: Enqueue Stats Stylesheets
51 add_action('wp_print_styles', 'stats_stylesheets');
52 function stats_stylesheets() {
53 if(!function_exists('pagenavi_stylesheets')) {
54 if(@file_exists(TEMPLATEPATH.'/stats-css.css')) {
55 wp_enqueue_style('wp-stats', plugins_url(get_stylesheet_directory_uri().'/stats-css.css'), false, '2.50', 'all');
56 } else {
57 wp_enqueue_style('wp-stats', plugins_url('wp-stats/stats-css.css'), false, '2.50', 'all');
58 }
59 }
60 }
61
62
63 ### Display WP-Stats Admin Page
64 function display_stats() {
65 $stats_page = stats_page();
66 echo '<div class="wrap">';
67 screen_icon();
68 echo $stats_page;
69 echo '</div>';
70 }
71
72
73 ### Function: Get Total Authors
74 function get_totalauthors($display = true) {
75 global $wpdb;
76 $totalauthors = intval($wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->users LEFT JOIN $wpdb->usermeta ON $wpdb->usermeta.user_id = $wpdb->users.ID WHERE $wpdb->users.user_activation_key = '' AND $wpdb->usermeta.meta_key = '".$wpdb->prefix."user_level' AND (meta_value+0.00) > 1"));
77 if($display) {
78 echo $totalauthors;
79 } else {
80 return $totalauthors;
81 }
82 }
83
84
85 ### Function: Get Total Posts
86 function get_totalposts($display = true) {
87 global $wpdb;
88 $totalposts = intval($wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish'"));
89 if($display) {
90 echo $totalposts;
91 } else {
92 return $totalposts;
93 }
94 }
95
96
97 ### Function: Get Total Pages
98 function get_totalpages($display = true) {
99 global $wpdb;
100 $totalpages = intval($wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->posts WHERE post_type = 'page' AND post_status = 'publish'"));
101 if($display) {
102 echo $totalpages;
103 } else {
104 return $totalpages;
105 }
106 }
107
108
109 ### Function: Get Total Comments
110 function get_totalcomments($display = true) {
111 global $wpdb;
112 $totalcomments = intval($wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = '1'"));
113 if($display) {
114 echo $totalcomments;
115 } else {
116 return $totalcomments;
117 }
118 }
119
120
121 ### Function: Get Total Comments Poster
122 function get_totalcommentposters($display = true) {
123 global $wpdb;
124 $totalcommentposters = intval($wpdb->get_var("SELECT COUNT(DISTINCT comment_author) FROM $wpdb->comments WHERE comment_approved = '1' AND comment_type = ''"));
125 if($display) {
126 echo $totalcommentposters;
127 } else {
128 return $totalcommentposters;
129 }
130 }
131
132
133 ### Function: Get Total Links
134 function get_totallinks($display = true) {
135 global $wpdb;
136 $totallinks = intval($wpdb->get_var("SELECT COUNT(link_id) FROM $wpdb->links"));
137 if($display) {
138 echo $totallinks;
139 } else {
140 return $totallinks;
141 }
142 }
143
144
145 ### Function: Get Recent Posts
146 function get_recentposts($mode = '', $limit = 10, $display = true) {
147 global $wpdb, $post;
148 $where = '';
149 $temp = '';
150 if(!empty($mode) && $mode != 'both') {
151 $where = "post_type = '$mode'";
152 } else {
153 $where = '1=1';
154 }
155 $recentposts = $wpdb->get_results("SELECT $wpdb->users.*, $wpdb->posts.* FROM $wpdb->posts LEFT JOIN $wpdb->users ON $wpdb->users.ID = $wpdb->posts.post_author WHERE user_activation_key = '' AND post_date < '".current_time('mysql')."' AND $where AND post_status = 'publish' AND post_password = '' ORDER BY post_date DESC LIMIT $limit");
156 if($recentposts) {
157 foreach ($recentposts as $post) {
158 $post_title = get_the_title();
159 $post_date = get_the_time(sprintf(__('%s @ %s', 'wp-stats'), get_option('date_format'), get_option('time_format')));
160 $display_name = stripslashes($post->display_name);
161 $temp .= "<li>$post_date - <a href=\"".get_permalink()."\" title=\"".sprintf(__('View post %s', 'wp-stats'), $post_title)."\">$post_title</a> ($display_name)</li>\n";
162 }
163 } else {
164 $temp = '<li>'.__('N/A', 'wp-stats').'</li>';
165 }
166 if($display) {
167 echo $temp;
168 } else {
169 return $temp;
170 }
171 }
172
173
174 ### Function: Get Recent Comments
175 function get_recentcomments($mode = '', $limit = 10, $display = true) {
176 global $wpdb, $post;
177 $where = '';
178 $temp = '';
179 if(!empty($mode) && $mode != 'both') {
180 $where = "post_type = '$mode'";
181 } else {
182 $where = '1=1';
183 }
184 $recentcomments = $wpdb->get_results("SELECT * FROM $wpdb->posts INNER JOIN $wpdb->comments ON $wpdb->posts.ID = $wpdb->comments.comment_post_ID WHERE comment_approved = '1' AND comment_type = '' AND post_date < '".current_time('mysql')."' AND $where AND post_status = 'publish' AND post_password = '' ORDER BY comment_date DESC LIMIT $limit");
185 if($recentcomments) {
186 foreach ($recentcomments as $post) {
187 $post_title = get_the_title();
188 $comment_author = htmlspecialchars(stripslashes($post->comment_author));
189 $comment_date = mysql2date(sprintf(__('%s @ %s', 'wp-stats'), get_option('date_format'), get_option('time_format')), $post->comment_date);
190 $temp .= "<li>$comment_date - $comment_author (<a href=\"".get_permalink()."#comment-".$post->comment_ID."\" title=\"".sprintf(__('View comments in post %s', 'wp-stats'), $post_title)."\">$post_title</a>)</li>\n";
191 }
192 } else {
193 $temp = '<li>'.__('N/A', 'wp-stats').'</li>';
194 }
195 if($display) {
196 echo $temp;
197 } else {
198 return $temp;
199 }
200 }
201
202
203 ### Function: Get Top Commented Posts
204 function get_mostcommented($mode = '', $limit = 10, $chars = 0, $display = true) {
205 global $wpdb, $post;
206 $where = '';
207 $temp = '';
208 if(!empty($mode) && $mode != 'both') {
209 $where = "post_type = '$mode'";
210 } else {
211 $where = '1=1';
212 }
213 $mostcommenteds = $wpdb->get_results("SELECT $wpdb->posts.*, COUNT($wpdb->comments.comment_post_ID) AS 'comment_total' FROM $wpdb->posts LEFT JOIN $wpdb->comments ON $wpdb->posts.ID = $wpdb->comments.comment_post_ID WHERE comment_approved = '1' AND post_date < '".current_time('mysql')."' AND $where AND post_status = 'publish' AND post_password = '' GROUP BY $wpdb->comments.comment_post_ID ORDER BY comment_total DESC LIMIT $limit");
214 if($mostcommenteds) {
215 if($chars > 0) {
216 foreach ($mostcommenteds as $post) {
217 $post_title = get_the_title();
218 $comment_total = $post->comment_total;
219 $temp .= "<li><a href=\"".get_permalink()."\" title=\"".sprintf(__('View comments in post %s', 'wp-stats'), $post_title)."\">".snippet_text($post_title, $chars)."</a> - ".sprintf(_n('%s comment', '%s comments', $comment_total, 'wp-stats'), number_format_i18n($comment_total))."</li>";
220 }
221 } else {
222 foreach ($mostcommenteds as $post) {
223 $post_title = get_the_title();
224 $comment_total = $post->comment_total;
225 $temp .= "<li><a href=\"".get_permalink()."\" title=\"".sprintf(__('View comments in post %s', 'wp-stats'), $post_title)."\">$post_title</a> - ".sprintf(_n('%s comment', '%s comments', $comment_total, 'wp-stats'), number_format_i18n($comment_total))."</li>";
226 }
227 }
228 } else {
229 $temp = '<li>'.__('N/A', 'wp-stats').'</li>';
230 }
231 if($display) {
232 echo $temp;
233 } else {
234 return $temp;
235 }
236 }
237
238
239 ### Function: Get Author Stats
240 function get_authorsstats($mode = '', $display = true) {
241 global $wpdb, $wp_rewrite;
242 $where = '';
243 $temp = '';
244 if(!empty($mode) && $mode != 'both') {
245 $where = "post_type = '$mode'";
246 } else {
247 $where = '1=1';
248 }
249 $posts = $wpdb->get_results("SELECT COUNT($wpdb->posts.ID) AS 'posts_total', $wpdb->users.display_name, $wpdb->users.user_nicename FROM $wpdb->posts LEFT JOIN $wpdb->users ON $wpdb->users.ID = $wpdb->posts.post_author WHERE user_activation_key = '' AND $where AND post_status = 'publish' GROUP BY $wpdb->posts.post_author");
250 if($posts) {
251 $using_permalink = get_option('permalink_structure');
252 $permalink = $wp_rewrite->get_author_permastruct();
253 foreach ($posts as $post) {
254 $post_author = strip_tags(stripslashes($post->user_nicename));
255 $author_link = str_replace('%author%', $post_author, $permalink);
256 $display_name = strip_tags(stripslashes($post->display_name));
257 $posts_total = number_format_i18n($post->posts_total);
258 if($using_permalink) {
259 $temp .= "<li><a href=\"".get_option('home').$author_link."\" title=\"".sprintf(__('View posts posted by %s', 'wp-stats'), $display_name)."\">$display_name</a> ($posts_total)</li>\n";
260 } else {
261 $temp .= "<li><a href=\"".get_option('siteurl')."/?author_name=$post_author\" title=\"".sprintf(__('View posts posted by %s', 'wp-stats'), $display_name)."\">$display_name</a> ($posts_total)</li>\n";
262 }
263 }
264 } else {
265 $temp = '<li>'.__('N/A', 'wp-stats').'</li>';
266 }
267 if($display) {
268 echo $temp;
269 } else {
270 return $temp;
271 }
272 }
273
274
275 ### Function: Get Comments' Members Stats
276 // Treshhold = Number Of Posts User Must Have Before It Will Display His Name Out
277 // 5 = Default Treshhold; -1 = Disable Treshhold
278 function get_commentmembersstats($threshhold = -1, $limit = 0, $display = true) {
279 global $wpdb;
280 $temp = '';
281 $limit_sql = '';
282 if($limit > 0) {
283 $limit_sql = "LIMIT $limit";
284 }
285 $comments = $wpdb->get_results("SELECT comment_author, COUNT(comment_ID) AS 'comment_total' FROM $wpdb->comments INNER JOIN $wpdb->posts ON $wpdb->comments.comment_post_ID = $wpdb->posts.ID WHERE comment_approved = '1' AND comment_type = '' AND post_date < '".current_time('mysql')."' AND post_status = 'publish' AND post_password = '' GROUP BY comment_author ORDER BY comment_total DESC $limit_sql");
286 if($comments) {
287 foreach ($comments as $comment) {
288 $comment_total = intval($comment->comment_total);
289 // If Total Comments Is Below Threshold
290 if($comment_total >= $threshhold) {
291 $comment_author = strip_tags(stripslashes($comment->comment_author));
292 $comment_author_link = urlencode($comment_author);
293 $temp .= "<li><a href=\"".stats_page_link($comment_author_link)."\" title=\"".sprintf(__('View all comments posted by %s', 'wp-stats'), $comment_author)."\">$comment_author</a> (".number_format_i18n($comment_total).")</li>\n";
294 }
295 }
296 } else {
297 $temp = '<li>'.__('N/A', 'wp-stats').'</li>';
298 }
299 if($display) {
300 echo $temp;
301 } else {
302 return $temp;
303 }
304 }
305
306
307 ### Function: Get Post Categories Stats
308 function get_postcats($display = true) {
309 global $wpdb;
310 $temp = '';
311 $defaults = array('type' => 'post', 'style' => 'list', 'show_count' => 1);
312 $categories = get_categories($defaults);
313 if (empty($categories)){
314 $temp .= '<li>'.__('No categories', 'wp-stats').'</li>';
315 } else {
316 $temp .= walk_category_tree($categories, 0, $defaults);
317 }
318 if($display) {
319 echo $temp;
320 } else {
321 return $temp;
322 }
323 }
324
325
326 ### Function: Get Links Categories Stats
327 function get_linkcats($display = true) {
328 global $wpdb;
329 $temp = '';
330 $cats = get_categories('type=link');
331 if ($cats) {
332 foreach ($cats as $cat) {
333 $temp .= '<li>'.$cat->cat_name.' ('.number_format_i18n($cat->count).")</li>\n";
334 }
335 }
336 if($display) {
337 echo $temp;
338 } else {
339 return $temp;
340 }
341 }
342
343
344 ### Function: Get Tags List
345 function get_tags_list($display = true) {
346 global $wpdb;
347 $temp = '';
348 $tags = get_tags('orderby=count&order=DESC');
349 if ($tags) {
350 foreach ($tags as $tag) {
351 $temp .= '<li><a href="'.clean_url(get_tag_link($tag->term_id)).'" title="'.sprintf(_n('%s topic', '%s topics', $tag->count, 'wp-stats'), number_format_i18n($tag->count)).'">'.$tag->name.'</a> ('.number_format_i18n($tag->count).")</li>\n";
352 }
353 }
354 if($display) {
355 echo $temp;
356 } else {
357 return $temp;
358 }
359 }
360
361
362 ### Function: Snippet Text
363 if(!function_exists('snippet_text')) {
364 function snippet_text($text, $length = 0) {
365 if (defined('MB_OVERLOAD_STRING')) {
366 $text = @html_entity_decode($text, ENT_QUOTES, get_option('blog_charset'));
367 if (mb_strlen($text) > $length) {
368 return htmlentities(mb_substr($text,0,$length), ENT_COMPAT, get_option('blog_charset')).'...';
369 } else {
370 return htmlentities($text, ENT_COMPAT, get_option('blog_charset'));
371 }
372 } else {
373 $text = @html_entity_decode($text, ENT_QUOTES, get_option('blog_charset'));
374 if (strlen($text) > $length) {
375 return htmlentities(substr($text,0,$length), ENT_COMPAT, get_option('blog_charset')).'...';
376 } else {
377 return htmlentities($text, ENT_COMPAT, get_option('blog_charset'));
378 }
379 }
380 }
381 }
382
383
384 ### Function: Short Code For Inserting Stats Into Page
385 add_shortcode('page_stats', 'stats_page_shortcode');
386 function stats_page_shortcode($atts) {
387 return stats_page();
388 }
389
390
391 ### Function: Stats Page
392 function stats_page_link($author, $page = 0) {
393 $stats_url = get_option('stats_url');
394 if($page > 1) {
395 $page = "&amp;stats_page=$page";
396 } else {
397 $page = '';
398 }
399 if(strpos($stats_url, '?') !== false) {
400 $stats_url = "$stats_url&amp;stats_author=$author$page";
401 } else {
402 $stats_url = "$stats_url?stats_author=$author$page";
403 }
404 return $stats_url;
405 }
406
407
408 ### Function: Statistics Page
409 function stats_page() {
410 global $wpdb, $post;
411 // Variables Variables Variables
412 $comment_author = urldecode(strip_tags(stripslashes(trim($_GET['stats_author']))));
413 $page = intval($_GET['stats_page']);
414 $temp_stats = '';
415 $temp_post = $post;
416 $stats_mostlimit = intval(get_option('stats_mostlimit'));
417 $stats_display = get_option('stats_display');
418
419 // Default wp-stats.php Page
420 if(empty($comment_author)) {
421 // General Stats
422 if($stats_display['total_stats'] == 1) {
423 $temp_stats .= '<h2 id="GeneralStats">'.__('General Stats', 'wp-stats').'</h2>'."\n";
424 $temp_stats .= '<p><strong>'.__('Total Stats', 'wp-stats').'</strong></p>'."\n";
425 $temp_stats .= '<ul>'."\n";
426 $temp_stats .= '<li>'.sprintf(_n('<strong>%s</strong> author to this blog.', '<strong>%s</strong> authors to this blog.', get_totalauthors(false), 'wp-stats'), number_format_i18n(get_totalauthors(false))).'</li>'."\n";
427 $temp_stats .= '<li>'.sprintf(_n('<strong>%s</strong> post was posted.', '<strong>%s</strong> posts were posted.', get_totalposts(false), 'wp-stats'), number_format_i18n(get_totalposts(false))).'</li>'."\n";
428 $temp_stats .= '<li>'.sprintf(_n('<strong>%s</strong> page was created.', '<strong>%s</strong> pages were created.', get_totalpages(false), 'wp-stats'), number_format_i18n(get_totalpages(false))).'</li>'."\n";
429 $temp_stats .= '<li>'.sprintf(_n('<strong>%s</strong> tag was created.', '<strong>%s</strong> tags were created.', wp_count_terms('post_tag'), 'wp-stats'), number_format_i18n(wp_count_terms('post_tag'))).'</li>'."\n";
430
431 $temp_stats .= '<li>'.sprintf(_n('<strong>%s</strong> comment was posted.', '<strong>%s</strong> comments were posted.', get_totalcomments(false), 'wp-stats'), number_format_i18n(get_totalcomments(false))).'</li>'."\n";
432 $temp_stats .= '<li>'.sprintf(_n('<strong>%s</strong> nickname was represented in the comments.', '<strong>%s</strong> different nicknames were represented in the comments.', get_totalcommentposters(false), 'wp-stats'), number_format_i18n(get_totalcommentposters(false))).'</li>'."\n";
433
434 $temp_stats .= '<li>'.sprintf(_n('<strong>%s</strong> link was added.', '<strong>%s</strong> links were added.', get_totallinks(false), 'wp-stats'), number_format_i18n(get_totallinks(false))).'</li>'."\n";
435 $temp_stats .= '<li>'.sprintf(_n('<strong>%s</strong> post category was needed.', '<strong>%s</strong> post categories were needed.', wp_count_terms('category'), 'wp-stats'), number_format_i18n(wp_count_terms('category'))).'</li>'."\n";
436 $temp_stats .= '<li>'.sprintf(_n('<strong>%s</strong> link category was needed.', '<strong>%s</strong> link categories were needed.', wp_count_terms('link_category'), 'wp-stats'), number_format_i18n(wp_count_terms('link_category'))).'</li>'."\n";
437 if(function_exists('akismet_spam_count')) {
438 $temp_stats .= '<li>'.sprintf(_n('<strong>%s</strong> spam blocked.', '<strong>%s</strong> spam blocked.', get_option('akismet_spam_count'), 'wp-stats'), number_format_i18n(get_option('akismet_spam_count'))).'</li>'."\n";
439 }
440 // WP-Stats: General Stats Filter
441 $temp_stats = apply_filters('wp_stats_page_general', $temp_stats);
442 $temp_stats .= '</ul>'."\n";
443 }
444
445 // Plugin Stats
446 $temp_stats .= '<h2 id="PluginsStats">'.__('Plugins Stats', 'wp-stats').'</h2>'."\n";
447
448 // WP-Stats: Plugins Stats Filter
449 $temp_stats = apply_filters('wp_stats_page_plugins', $temp_stats);
450
451 // Top Recent Stats
452 $temp_stats .= '<h2 id="TopRecentStats">'.sprintf(_n('Top %s Recent Stat', 'Top %s Recent Stats', $stats_mostlimit, 'wp-stats'), number_format_i18n($stats_mostlimit)).'</h2>'."\n";
453
454 // Recent Posts
455 if($stats_display['recent_posts'] == 1) {
456 $temp_stats .= '<p><strong>'.sprintf(_n('%s Recent Post', '%s Recent Posts', $stats_mostlimit, 'wp-stats'), number_format_i18n($stats_mostlimit)).'</strong></p>'."\n";
457 $temp_stats .= '<ul>'."\n";
458 $temp_stats .= get_recentposts('post', $stats_mostlimit, false);
459 $temp_stats .= '</ul>'."\n";
460 }
461
462 // Recent Comments
463 if($stats_display['recent_comments'] == 1) {
464 $temp_stats .= '<p><strong>'.sprintf(_n('%s Recent Comment', '%s Recent Comments', $stats_mostlimit, 'wp-stats'), number_format_i18n($stats_mostlimit)).'</strong></p>'."\n";
465 $temp_stats .= '<ul>'."\n";
466 $temp_stats .= get_recentcomments('both', $stats_mostlimit, false);
467 $temp_stats .= '</ul>'."\n";
468 }
469
470 // WP-Stats: Top Recent Stats Filter
471 $temp_stats = apply_filters('wp_stats_page_recent', $temp_stats);
472
473 // Top Most Stats
474 $temp_stats .= '<h2 id="TopMostHighestStats">'.sprintf(_n('%s Most/Highest Stat', '%s Most/Highest Stats', $stats_mostlimit, 'wp-stats'), number_format_i18n($stats_mostlimit)).'</h2>'."\n";
475
476 // Most Commented Posts
477 if($stats_display['commented_post'] == 1) {
478 $temp_stats .= '<p><strong>'.sprintf(_n('%s Most Commented Post', '%s Most Commented Posts', $stats_mostlimit, 'wp-stats'), number_format_i18n($stats_mostlimit)).'</strong></p>'."\n";
479 $temp_stats .= '<ul>'."\n";
480 $temp_stats .= get_mostcommented('post', $stats_mostlimit, 0, false);
481 $temp_stats .= '</ul>'."\n";
482 }
483
484 // Most Commented Pages
485 if($stats_display['commented_page'] == 1) {
486 $temp_stats .= '<p><strong>'.sprintf(_n('%s Most Commented Page', '%s Most Commented Pages', $stats_mostlimit, 'wp-stats'), number_format_i18n($stats_mostlimit)).'</strong></p>'."\n";
487 $temp_stats .= '<ul>'."\n";
488 $temp_stats .= get_mostcommented('page', $stats_mostlimit, 0, false);
489 $temp_stats .= '</ul>'."\n";
490 }
491
492 // WP-Stats: Top Most/Highest Stats Filter
493 $temp_stats = apply_filters('wp_stats_page_most', $temp_stats);
494
495 // Authors Stats
496 $temp_stats .= '<h2 id="AuthorsStats">'.__('Authors Stats', 'wp-stats').'</h2>'."\n";
497
498 // Authors
499 if($stats_display['authors'] == 1) {
500 $temp_stats .= '<p><strong>'.__('Authors', 'wp-stats').'</strong></p>'."\n";
501 $temp_stats .= '<ol>'."\n";
502 $temp_stats .= get_authorsstats('post', false);
503 $temp_stats .= '</ol>'."\n";
504 }
505
506 // WP-Stats: Authors Stats Filter
507 $temp_stats = apply_filters('wp_stats_page_authors', $temp_stats);
508
509 // Comments' Members Stats
510 $temp_stats .= '<h2 id="CommentsMembersStats">'.__('Comments\' Members Stats', 'wp-stats').'</h2>'."\n";
511
512 // Comments' Member
513 if($stats_display['comment_members'] == 1) {
514 $temp_stats .= '<p><strong>'.__('Comment Members', 'wp-stats').'</strong></p>'."\n";
515 $temp_stats .= '<ol>'."\n";
516 $temp_stats .= get_commentmembersstats(5, 0, false);
517 $temp_stats .= '</ol>'."\n";
518 }
519
520 // WP-Stats: Comments' Members Stats Filter
521 $temp_stats = apply_filters('wp_stats_page_comments_members', $temp_stats);
522
523 // Misc Stats
524 $temp_stats .= '<h2 id="MiscStats">'.__('Misc Stats', 'wp-stats').'</h2>'."\n";
525
526 // Post Categories
527 if($stats_display['post_cats'] == 1) {
528 $temp_stats .= '<p><strong>'.__('Post Categories', 'wp-stats').'</strong></p>'."\n";
529 $temp_stats .= '<ul>'."\n";
530 $temp_stats .= get_postcats(false);
531 $temp_stats .= '</ul>'."\n";
532 }
533
534 // Link Categories
535 if($stats_display['link_cats'] == 1) {
536 $temp_stats .= '<p><strong>'.__('Link Categories', 'wp-stats').'</strong></p>'."\n";
537 $temp_stats .= '<ul>'."\n";
538 $temp_stats .= get_linkcats(false);
539 $temp_stats .= '</ul>'."\n";
540 }
541
542 if($stats_display['tags_list'] == 1) {
543 $temp_stats .= '<p><strong>'.__('Tags List', 'wp-stats').'</strong></p>'."\n";
544 $temp_stats .= '<ul>'."\n";
545 $temp_stats .= get_tags_list(false);
546 $temp_stats .= '</ul>'."\n";
547 }
548
549 // WP-Stats: Plugin Misc Filter
550 $temp_stats = apply_filters('wp_stats_page_misc', $temp_stats);
551
552 // Displaying Comments Posted By User
553 } else {
554 // Stats URL
555 $stats_url = get_option('stats_url');
556 // Number Of Comments Per Page
557 $perpage = 10;
558 // Comment Author Link
559 $comment_author_link = urlencode($comment_author);
560 // Comment Author SQL
561 $comment_author_sql = $wpdb->escape($comment_author);
562 // Total Comments Posted By User
563 $totalcomments = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments INNER JOIN $wpdb->posts ON $wpdb->comments.comment_post_ID = $wpdb->posts.ID WHERE comment_author = '$comment_author_sql' AND comment_approved = '1' AND comment_type = '' AND post_date < '".current_time('mysql')."' AND post_status = 'publish' AND post_password = ''");
564 // Calculate Paging
565 $numposts = $totalcomments;
566 $perpage = 30;
567 $max_page = ceil($numposts/$perpage);
568 if(empty($page) || $page == 0) {
569 $page = 1;
570 }
571 $offset = ($page-1) * $perpage;
572 $pages_to_show = 10;
573 $pages_to_show_minus_1 = $pages_to_show-1;
574 $half_page_start = floor($pages_to_show_minus_1/2);
575 $half_page_end = ceil($pages_to_show_minus_1/2);
576 $start_page = $page - $half_page_start;
577 if($start_page <= 0) {
578 $start_page = 1;
579 }
580 $end_page = $page + $half_page_end;
581 if(($end_page - $start_page) != $pages_to_show_minus_1) {
582 $end_page = $start_page + $pages_to_show_minus_1;
583 }
584 if($end_page > $max_page) {
585 $start_page = $max_page - $pages_to_show_minus_1;
586 $end_page = $max_page;
587 }
588 if($start_page <= 0) {
589 $start_page = 1;
590 }
591 if(($offset + $perpage) > $numposts) {
592 $max_on_page = $numposts;
593 } else {
594 $max_on_page = ($offset + $perpage);
595 }
596 if (($offset + 1) > ($numposts)) {
597 $display_on_page = $numposts;
598 } else {
599 $display_on_page = ($offset + 1);
600 }
601
602 // Getting The Comments
603 $gmz_comments = $wpdb->get_results("SELECT $wpdb->posts.*, $wpdb->comments.* FROM $wpdb->comments INNER JOIN $wpdb->posts ON $wpdb->comments.comment_post_ID = $wpdb->posts.ID WHERE comment_author = '$comment_author_sql' AND comment_approved = '1' AND post_date < '".current_time('mysql')."' AND post_status = 'publish' AND post_password = '' ORDER BY comment_post_ID DESC, comment_date DESC LIMIT $offset, $perpage");
604 $temp_stats .= '<h2>'.__('Comments Posted By', 'wp-stats').' '.$comment_author.'</h2>';
605 $temp_stats .= '<p>'.sprintf(__('Displaying <strong>%s</strong> To <strong>%s</strong> Of <strong>%s</strong> Comments', 'wp-stats'), number_format_i18n($display_on_page), number_format_i18n($max_on_page), number_format_i18n($numposts)).'</p>';
606
607
608 // Get Comments
609 if($gmz_comments) {
610 foreach($gmz_comments as $post) {
611 $comment_id = intval($post->comment_ID);
612 $comment_author2 = htmlspecialchars(stripslashes($post->comment_author));
613 $comment_date = mysql2date(sprintf(__('%s @ %s', 'wp-stats'), get_option('date_format'), get_option('time_format')), $post->comment_date);
614 $comment_content = apply_filters('comment_text', $post->comment_content);
615 $post_date = get_the_time(sprintf(__('%s @ %s', 'wp-stats'), get_option('date_format'), get_option('time_format')));
616 $post_title = get_the_title();
617
618 // Check For Password Protected Post
619 if(!empty($post->post_password) && stripslashes($_COOKIE['wp-postpass_'.COOKIEHASH]) != $post->post_password) {
620 // If New Title, Print It Out
621 if($post_title != $cache_post_title) {
622 $temp_stats .= "<p><strong><a href=\"".get_permalink()."\" title=\"".__('Posted On', 'wp-stats')." $post_date\">".__('Protected', 'wp-stats').": $post_title</a></strong></p>";
623 $temp_stats .= '<blockquote>'.__('Comments Protected', 'wp-stats').'</blockquote>';
624 }
625 } else {
626 // If New Title, Print It Out
627 if($post_title != $cache_post_title) {
628 $temp_stats .= "<p><strong><a href=\"".get_permalink()."\" title=\"".__('Posted On', 'wp-stats')." $post_date\">$post_title</a></strong></p>";
629 }
630 $temp_stats .= "<blockquote>$comment_content<p><a href=\"".get_permalink()."#comment-$comment_id\" title=\"".sprintf(__('View the comment posted by %s', 'wp-stats'), $comment_author2)."\">&raquo;</a> ".__('Posted By', 'wp-stats')." <strong>$comment_author2</strong> ".__('On', 'wp-stats')." $comment_date</p></blockquote>";
631 }
632 $cache_post_title = $post_title;
633 }
634 } else {
635 $temp_stats .= "<p>$comment_author ".__('has not made any comments yet.', 'wp-stats')."</p>";
636 }
637
638 // Comments Paging
639 if($max_page > 1) {
640 $temp_stats = apply_filters('wp_stats_paging_start', $temp_stats);
641 $temp_stats .= '<div class="wp-pagenavi">'."\n";
642 $temp_stats .= '<span class="pages">&#8201;'.sprintf(__('Page %s of %s', 'wp-stats'), number_format_i18n($page), number_format_i18n($max_page)).'&#8201;</span>';
643 if ($start_page >= 2 && $pages_to_show < $max_page) {
644 $temp_stats .= '<a href="'.stats_page_link($comment_author_link, 1).'" title="'.__('&laquo; First', 'wp-stats').'">&#8201;'.__('&laquo; First', 'wp-stats').'&#8201;</a>';
645 $temp_stats .= '<span class="extend">...</span>';
646 }
647 if($page > 1) {
648 $temp_stats .= '<a href="'.stats_page_link($comment_author_link, ($page-1)).'" title="'.__('&laquo;', 'wp-stats').'">&#8201;'.__('&laquo;', 'wp-stats').'&#8201;</a>';
649 }
650 for($i = $start_page; $i <= $end_page; $i++) {
651 if($i == $page) {
652 $temp_stats .= '<span class="current">&#8201;'.number_format_i18n($i).'&#8201;</span>';
653 } else {
654 $temp_stats .= '<a href="'.stats_page_link($comment_author_link, $i).'" title="'.number_format_i18n($i).'">&#8201;'.number_format_i18n($i).'&#8201;</a>';
655 }
656 }
657 if(empty($page) || ($page+1) <= $max_page) {
658 $temp_stats .= '<a href="'.stats_page_link($comment_author_link, ($page+1)).'" title="'.__('&raquo;', 'wp-stats').'">&#8201;'.__('&raquo;', 'wp-stats').'&#8201;</a>';
659 }
660 if ($end_page < $max_page) {
661 $temp_stats .= '<span class="extend">...</span>';
662 $temp_stats .= '<a href="'.stats_page_link($comment_author_link, $max_page).'" title="'.__('Last &raquo;', 'wp-stats').'">&#8201;'.__('Last &raquo;', 'wp-stats').'&#8201;</a>';
663 }
664 $temp_stats .= '</div>';
665 $temp_stats = apply_filters('wp_stats_paging_end', $temp_stats);
666 }
667 $temp_stats .= '<strong>&laquo;&laquo;</strong> <a href="'.$stats_url.'">'.__('Back To Stats Page', 'wp-stats').' </a>';
668 } // End If
669
670 // Assign Back $post
671 $post = $temp_post;
672
673 // Output Stats Page
674 return apply_filters('stats_page', $temp_stats);
675 }
676
677
678 ### Class: WP-Stats Widget
679 class WP_Widget_Stats extends WP_Widget {
680 // Constructor
681 function WP_Widget_Stats() {
682 $widget_ops = array('description' => __('WP-Stats statistics', 'wp-stats'));
683 $this->WP_Widget('stats', __('Stats', 'wp-stats'), $widget_ops);
684 }
685
686 // Display Widget
687 function widget($args, $instance) {
688 extract($args);
689 $title = apply_filters('widget_title', esc_attr($instance['title']));
690 $limit = intval($instance['limit']);
691 $chars = intval($instance['chars']);
692 $show_link = intval($instance['show_link']);
693 $stats_total_authors = intval($instance['stats_total_authors']);
694 $stats_total_posts = intval($instance['stats_total_posts']);
695 $stats_total_pages = intval($instance['stats_total_pages']);
696 $stats_total_tags = intval($instance['stats_total_tags']);
697 $stats_total_comments = intval($instance['stats_total_comments']);
698 $stats_total_commenters = intval($instance['stats_total_commenters']);
699 $stats_total_links = intval($instance['stats_total_links']);
700 $stats_total_post_cat = intval($instance['stats_total_post_cat']);
701 $stats_total_link_cat = intval($instance['stats_total_link_cat']);
702 $stats_total_spam = intval($instance['stats_total_spam']);
703 $stats_most_commented_post = intval($instance['stats_most_commented_post']);
704 echo $before_widget.$before_title.$title.$after_title;
705 echo '<ul>'."\n";
706 echo '<li><strong>'.__('Total Stats', 'wp-stats').'</strong>'."\n";
707 echo '<ul>'."\n";
708 // Total Authors
709 if($stats_total_authors) {
710 echo '<li>'.sprintf(_n('<strong>%s</strong> Author', '<strong>%s</strong> Authors', get_totalauthors(false), 'wp-stats'), number_format_i18n(get_totalauthors(false))).'</li>'."\n";
711 }
712 // Total Posts
713 if($stats_total_posts) {
714 echo '<li>'.sprintf(_n('<strong>%s</strong> Post', '<strong>%s</strong> Posts', get_totalposts(false), 'wp-stats'), number_format_i18n(get_totalposts(false))).'</li>'."\n";
715 }
716 // Total Pages
717 if($stats_total_pages) {
718 '<li>'.sprintf(_n('<strong>%s</strong> Page', '<strong>%s</strong> Pages', get_totalpages(false), 'wp-stats'), number_format_i18n(get_totalpages(false))).'</li>'."\n";
719 }
720 // Total Tags
721 if($stats_total_tags) {
722 echo '<li>'.sprintf(_n('<strong>%s</strong> Tag', '<strong>%s</strong> Tags', wp_count_terms('post_tag'), 'wp-stats'), number_format_i18n(wp_count_terms('post_tag'))).'</li>'."\n";
723 }
724 // Total Comments
725 if($stats_total_comments) {
726 echo '<li>'.sprintf(_n('<strong>%s</strong> Comment', '<strong>%s</strong> Comments', get_totalcomments(false), 'wp-stats'), number_format_i18n(get_totalcomments(false))).'</li>'."\n";
727 }
728 // Total Comment Posters
729 if($stats_total_commenters) {
730 echo '<li>'.sprintf(_n('<strong>%s</strong> Comment Poster', '<strong>%s</strong> Comment Posters', get_totalcommentposters(false), 'wp-stats'), number_format_i18n(get_totalcommentposters(false))).'</li>'."\n";
731 }
732 // Total Links
733 if($stats_total_links) {
734 echo '<li>'.sprintf(_n('<strong>%s</strong> Link', '<strong>%s</strong> Links', get_totallinks(false), 'wp-stats'), number_format_i18n(get_totallinks(false))).'</li>'."\n";
735 }
736 // Total Post Categories
737 if($stats_total_post_cat) {
738 echo '<li>'.sprintf(_n('<strong>%s</strong> Post Category', '<strong>%s</strong> Post Categories', wp_count_terms('category'), 'wp-stats'), number_format_i18n(wp_count_terms('category'))).'</li>'."\n";
739 }
740 // Total Link Categories
741 if($stats_total_link_cat) {
742 echo '<li>'.sprintf(_n('<strong>%s</strong> Link Category', '<strong>%s</strong> Link Categories', wp_count_terms('link_category'), 'wp-stats'), number_format_i18n(wp_count_terms('link_category'))).'</li>'."\n";
743 }
744 // Total Spam
745 if($stats_total_spam && function_exists('akismet_spam_count')) {
746 echo '<li>'.sprintf(_n('<strong>%s</strong> Spam Blocked', '<strong>%s</strong> Spam Blockeds', akismet_spam_count(), 'wp-stats'), number_format_i18n(akismet_spam_count())).'</li>'."\n";
747 }
748 echo '</ul>'."\n";
749 echo '</li>'."\n";
750 echo '</ul>'."\n";
751 // Most Commented
752 if($stats_most_commented_post) {
753 echo '<ul>'."\n";
754 echo '<li><strong>'.number_format_i18n($limit).' '.__('Most Commented Posts', 'wp-stats').'</strong>'."\n";
755 echo '<ul>'."\n";
756 get_mostcommented('post', $limit, $chars);
757 echo '</ul>'."\n";
758 echo '</li>'."\n";
759 echo '</ul>'."\n";
760 }
761 if($show_link) {
762 echo '<ul>'."\n";
763 echo '<li><a href="'.stripslashes(get_option('stats_url')).'">'.__('My Blog Statistics', 'wp-stats').'</a></li>'."\n";
764 echo '</ul>'."\n";
765 }
766 echo $after_widget;
767 }
768
769 // When Widget Control Form Is Posted
770 function update($new_instance, $old_instance) {
771 if (!isset($new_instance['submit'])) {
772 return false;
773 }
774 $instance = $old_instance;
775 $instance['title'] = strip_tags($new_instance['title']);;
776 $instance['limit'] = intval($new_instance['limit']);
777 $instance['chars'] = intval($new_instance['chars']);
778 $instance['show_link'] = intval($new_instance['show_link']);
779 $instance['stats_total_authors'] = intval($new_instance['stats_total_authors']);
780 $instance['stats_total_posts'] = intval($new_instance['stats_total_posts']);
781 $instance['stats_total_pages'] = intval($new_instance['stats_total_pages']);
782 $instance['stats_total_tags'] = intval($new_instance['stats_total_tags']);
783 $instance['stats_total_comments'] = intval($new_instance['stats_total_comments']);
784 $instance['stats_total_commenters'] = intval($new_instance['stats_total_commenters']);
785 $instance['stats_total_links'] = intval($new_instance['stats_total_links']);
786 $instance['stats_total_post_cat'] = intval($new_instance['stats_total_post_cat']);
787 $instance['stats_total_link_cat'] = intval($new_instance['stats_total_link_cat']);
788 $instance['stats_total_spam'] = intval($new_instance['stats_total_spam']);
789 $instance['stats_most_commented_post'] = intval($new_instance['stats_most_commented_post']);
790 return $instance;
791 }
792
793 // DIsplay Widget Control Form
794 function form($instance) {
795 global $wpdb;
796 $instance = wp_parse_args((array) $instance, array('title' => __('Stats', 'wp-stats'), 'limit' => 10, 'chars' => 200, 'show_link' => 1, 'stats_total_authors' => 1, 'stats_total_posts' => 1, 'stats_total_pages' => 1, 'stats_total_tags' => 1, 'stats_total_comments' => 1, 'stats_total_commenters' => 1, 'stats_total_links' => 1, 'stats_total_post_cat' => 1, 'stats_total_link_cat' => 1, 'stats_total_spam' => 1, 'stats_most_commented_post' => 1));
797 $title = esc_attr($instance['title']);
798 $limit = intval($instance['limit']);
799 $chars = intval($instance['chars']);
800 $show_link = intval($instance['show_link']);
801 $stats_total_authors = intval($instance['stats_total_authors']);
802 $stats_total_posts = intval($instance['stats_total_posts']);
803 $stats_total_pages = intval($instance['stats_total_pages']);
804 $stats_total_tags = intval($instance['stats_total_tags']);
805 $stats_total_comments = intval($instance['stats_total_comments']);
806 $stats_total_commenters = intval($instance['stats_total_commenters']);
807 $stats_total_links = intval($instance['stats_total_links']);
808 $stats_total_post_cat = intval($instance['stats_total_post_cat']);
809 $stats_total_link_cat = intval($instance['stats_total_link_cat']);
810 $stats_total_spam = intval($instance['stats_total_spam']);
811 $stats_most_commented_post = intval($instance['stats_most_commented_post']);
812 ?>
813 <p>
814 <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'wp-stats'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></label>
815 </p>
816 <p>
817 <?php _e('Statistics To Display:', 'wp-postviews'); ?><br />
818 <input type="checkbox" id="<?php echo $this->get_field_id('stats_total_authors'); ?>" name="<?php echo $this->get_field_name('stats_total_authors'); ?>" value="1" <?php checked(1, $instance['stats_total_authors']); ?> />&nbsp;&nbsp;<label for="<?php echo $this->get_field_id('stats_total_authors'); ?>"><?php _e('Total Authors', 'wp-stats'); ?></label>
819 <br />
820 <input type="checkbox" id="<?php echo $this->get_field_id('stats_total_posts'); ?>" name="<?php echo $this->get_field_name('stats_total_posts'); ?>" value="1" <?php checked(1, $instance['stats_total_posts']); ?> />&nbsp;&nbsp;<label for="<?php echo $this->get_field_id('stats_total_posts'); ?>"><?php _e('Total Posts', 'wp-stats'); ?></label>
821 <br />
822 <input type="checkbox" id="<?php echo $this->get_field_id('stats_total_pages'); ?>" name="<?php echo $this->get_field_name('stats_total_pages'); ?>" value="1" <?php checked(1, $instance['stats_total_pages']); ?> />&nbsp;&nbsp;<label for="<?php echo $this->get_field_id('stats_total_pages'); ?>"><?php _e('Total Pages', 'wp-stats'); ?></label>
823 <br />
824 <input type="checkbox" id="<?php echo $this->get_field_id('stats_total_tags'); ?>" name="<?php echo $this->get_field_name('stats_total_tags'); ?>" value="1" <?php checked(1, $instance['stats_total_tags']); ?> />&nbsp;&nbsp;<label for="<?php echo $this->get_field_id('stats_total_tags'); ?>"><?php _e('Total Tags', 'wp-stats'); ?></label>
825 <br />
826 <input type="checkbox" id="<?php echo $this->get_field_id('stats_total_comments'); ?>" name="<?php echo $this->get_field_name('stats_total_comments'); ?>" value="1" <?php checked(1, $instance['stats_total_comments']); ?> />&nbsp;&nbsp;<label for="<?php echo $this->get_field_id('stats_total_comments'); ?>"><?php _e('Total Comments', 'wp-stats'); ?></label>
827 <br />
828 <input type="checkbox" id="<?php echo $this->get_field_id('stats_total_commenters'); ?>" name="<?php echo $this->get_field_name('stats_total_commenters'); ?>" value="1" <?php checked(1, $instance['stats_total_commenters']); ?> />&nbsp;&nbsp;<label for="<?php echo $this->get_field_id('stats_total_commenters'); ?>"><?php _e('Total Comment Posters', 'wp-stats'); ?></label>
829 <br />
830 <input type="checkbox" id="<?php echo $this->get_field_id('stats_total_links'); ?>" name="<?php echo $this->get_field_name('stats_total_links'); ?>" value="1" <?php checked(1, $instance['stats_total_links']); ?> />&nbsp;&nbsp;<label for="<?php echo $this->get_field_id('stats_total_links'); ?>"><?php _e('Total Links', 'wp-stats'); ?></label>
831 <br />
832 <input type="checkbox" id="<?php echo $this->get_field_id('stats_total_post_cat'); ?>" name="<?php echo $this->get_field_name('stats_total_post_cat'); ?>" value="1" <?php checked(1, $instance['stats_total_post_cat']); ?> />&nbsp;&nbsp;<label for="<?php echo $this->get_field_id('stats_total_post_cat'); ?>"><?php _e('Total Post Categories', 'wp-stats'); ?></label>
833 <br />
834 <input type="checkbox" id="<?php echo $this->get_field_id('stats_total_link_cat'); ?>" name="<?php echo $this->get_field_name('stats_total_link_cat'); ?>" value="1" <?php checked(1, $instance['stats_total_link_cat']); ?> />&nbsp;&nbsp;<label for="<?php echo $this->get_field_id('stats_total_link_cat'); ?>"><?php _e('Total Link Categories', 'wp-stats'); ?></label>
835 <br />
836 <?php if(function_exists('akismet_spam_count')): ?>
837 <input type="checkbox" id="<?php echo $this->get_field_id('stats_total_spam'); ?>" name="<?php echo $this->get_field_name('stats_total_spam'); ?>" value="1" <?php checked(1, $instance['stats_total_spam']); ?> />&nbsp;&nbsp;<label for="<?php echo $this->get_field_id('stats_total_spam'); ?>"><?php _e('Total Spam Blocked', 'wp-stats'); ?></label>
838 <br />
839 <?php endif; ?>
840 <br />
841 <input type="checkbox" id="<?php echo $this->get_field_id('stats_most_commented_post'); ?>" name="<?php echo $this->get_field_name('stats_most_commented_post'); ?>" value="1" <?php checked(1, $instance['stats_most_commented_post']); ?> />&nbsp;&nbsp;<label for="<?php echo $this->get_field_id('stats_most_commented_post'); ?>"><?php printf(_n('%s Most Commented Post', '%s Most Commented Posts', $options['most_limit'], 'wp-stats'), $options['most_limit']); ?></label>
842 </p>
843 <p>
844 <label for="<?php echo $this->get_field_id('limit'); ?>"><?php _e('No. Of Records To Show:', 'wp-stats'); ?> <span style="color: red;">*</span> <input class="widefat" id="<?php echo $this->get_field_id('limit'); ?>" name="<?php echo $this->get_field_name('limit'); ?>" type="text" value="<?php echo $limit; ?>" /></label>
845 </p>
846 <p>
847 <label for="<?php echo $this->get_field_id('chars'); ?>"><?php _e('Maximum Post Title Length (Characters):', 'wp-stats'); ?> <span style="color: red;">*</span> <input class="widefat" id="<?php echo $this->get_field_id('chars'); ?>" name="<?php echo $this->get_field_name('chars'); ?>" type="text" value="<?php echo $chars; ?>" /></label><br />
848 <small><?php _e('<strong>0</strong> to disable.', 'wp-stats'); ?></small>
849 </p>
850 <p>
851 <label for="<?php echo $this->get_field_id('show_link'); ?>"><?php _e('Show Link To Statistics Page?', 'wp-stats'); ?>
852 <select name="<?php echo $this->get_field_name('show_link'); ?>" id="<?php echo $this->get_field_id('show_link'); ?>" class="widefat">
853 <option value="0"<?php selected('0', $show_link); ?>><?php _e('No', 'wp-stats'); ?></option>
854 <option value="1"<?php selected('1', $show_link); ?>><?php _e('Yes', 'wp-stats'); ?></option>
855 </select>
856 </label>
857 </p>
858 <p style="color: red;">
859 <small><?php _e('* Used only in most commented post.', 'wp-stats'); ?></small>
860 <p>
861 <input type="hidden" id="<?php echo $this->get_field_id('submit'); ?>" name="<?php echo $this->get_field_name('submit'); ?>" value="1" />
862 <?php
863 }
864 }
865
866
867 ### Function: Init WP-Stats Widget
868 add_action('widgets_init', 'widget_stats_init');
869 function widget_stats_init() {
870 register_widget('WP_Widget_Stats');
871 }
872
873
874 ### Function: Stats Option
875 add_action('activate_wp-stats/wp-stats.php', 'stats_init');
876 function stats_init() {
877 global $wpdb;
878 $stats_display = array('total_stats' => 1, 'email' => 1, 'polls' => 1, 'ratings' => 1, 'views' => 1, 'useronline' => 1, 'recent_posts' => 1, 'recent_comments' => 1, 'commented_post' => 1, 'commented_page' => 0, 'emailed_most_post' => 1, 'emailed_most_page' => 0, 'rated_highest_post' => 1, 'rated_highest_page' => 0, 'rated_most_post' => 1, 'rated_most_page' => 0, 'viewed_most_post' => 1, 'viewed_most_page' => 0, 'authors' => 1, 'comment_members' => 1, 'post_cats' => 1, 'link_cats' => 1);
879 add_option('stats_mostlimit', '10', 'Stats Most Limit');
880 add_option('stats_display', $stats_display, 'Stats To Display');
881 add_option('stats_url', get_option('siteurl').'/stats/', 'Stats URL');
882 }
883 ?>