WP-PostViews - Version 1.30

Version Description

Download this release

Release Info

Developer GamerZ
Plugin Icon WP-PostViews
Version 1.30
Comparing to
See all releases

Code changes from version 1.20 to 1.30

postviews/postviews-options.php → postviews-options.php RENAMED
@@ -2,8 +2,8 @@
2
  /*
3
  +----------------------------------------------------------------+
4
  | |
5
- | WordPress 2.1 Plugin: WP-PostViews 1.20 |
6
- | Copyright (c) 2007 Lester "GaMerZ" Chan |
7
  | |
8
  | File Written By: |
9
  | - Lester "GaMerZ" Chan |
@@ -11,14 +11,14 @@
11
  | |
12
  | File Information: |
13
  | - Post Views Options Page |
14
- | - wp-content/plugins/postviews/postviews-options.php |
15
  | |
16
  +----------------------------------------------------------------+
17
  */
18
 
19
 
20
  ### Variables Variables Variables
21
- $base_name = plugin_basename('postviews/postviews-options.php');
22
  $base_page = 'admin.php?page='.$base_name;
23
  $id = intval($_GET['id']);
24
  $mode = trim($_GET['mode']);
@@ -26,31 +26,34 @@ $views_settings = array('views_options', 'widget_views_most_viewed');
26
  $views_postmetas = array('views');
27
 
28
 
29
- ### Form Processing
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  if(!empty($_POST['do'])) {
31
- // Decide What To Do
32
- switch($_POST['do']) {
33
- case __('Update Options', 'wp-postviews'):
34
- $views_options = array();
35
- $views_options['count'] = intval($_POST['views_count']);
36
- $views_options['template'] = addslashes(trim($_POST['views_template_template']));
37
- $update_views_queries = array();
38
- $update_views_text = array();
39
- $update_views_queries[] = update_option('views_options', $views_options);
40
- $update_views_text[] = __('Post Views Options', 'wp-postviews');
41
- $i=0;
42
- $text = '';
43
- foreach($update_views_queries as $update_views_query) {
44
- if($update_views_query) {
45
- $text .= '<font color="green">'.$update_views_text[$i].' '.__('Updated', 'wp-postviews').'</font><br />';
46
- }
47
- $i++;
48
- }
49
- if(empty($text)) {
50
- $text = '<font color="red">'.__('No Post Views Option Updated', 'wp-postviews').'</font>';
51
- }
52
- break;
53
- // Uninstall WP-PostViews
54
  case __('UNINSTALL WP-PostViews', 'wp-postviews') :
55
  if(trim($_POST['uninstall_views_yes']) == 'yes') {
56
  echo '<div id="message" class="updated fade">';
@@ -94,9 +97,9 @@ if(!empty($_POST['do'])) {
94
  switch($mode) {
95
  // Deactivating WP-PostViews
96
  case 'end-UNINSTALL':
97
- $deactivate_url = 'plugins.php?action=deactivate&amp;plugin=postviews/postviews.php';
98
  if(function_exists('wp_nonce_url')) {
99
- $deactivate_url = wp_nonce_url($deactivate_url, 'deactivate-plugin_postviews/postviews.php');
100
  }
101
  echo '<div class="wrap">';
102
  echo '<h2>'.__('Uninstall WP-PostViews', 'wp-postviews').'</h2>';
@@ -115,6 +118,9 @@ switch($mode) {
115
  case 'template':
116
  default_template = "<?php _e('%VIEW_COUNT% views', 'wp-postviews'); ?>";
117
  break;
 
 
 
118
  }
119
  document.getElementById("views_template_" + template).value = default_template;
120
  }
@@ -123,36 +129,60 @@ switch($mode) {
123
  <?php if(!empty($text)) { echo '<!-- Last Action --><div id="message" class="updated fade"><p>'.$text.'</p></div>'; } ?>
124
  <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
125
  <div class="wrap">
126
- <h2><?php _e('Post Views Options', 'wp-postviews'); ?></h2>
127
- <fieldset class="options">
128
- <legend><?php _e('Post Views Options', 'wp-postviews'); ?></legend>
129
- <table width="100%" border="0" cellspacing="3" cellpadding="3">
130
- <tr valign="top">
131
- <th align="left" width="30%"><?php _e('Count Views From:', 'wp-postviews'); ?></th>
132
- <td align="left">
133
- <select name="views_count" size="1">
134
- <option value="0"<?php selected('0', $views_options['count']); ?>><?php _e('Everyone', 'wp-postviews'); ?></option>
135
- <option value="1"<?php selected('1', $views_options['count']); ?>><?php _e('Guests Only', 'wp-postviews'); ?></option>
136
- <option value="2"<?php selected('2', $views_options['count']); ?>><?php _e('Registered Users Only', 'wp-postviews'); ?></option>
137
- </select>
138
- </td>
139
- </tr>
140
- <tr valign="top">
141
- <th align="left" width="30%"><?php _e('Views Template:', 'wp-postviews'); ?></th>
142
- <td align="left">
143
- <input type="text" id="views_template_template" name="views_template_template" size="70" value="<?php echo htmlspecialchars(stripslashes($views_options['template'])); ?>" /><br />
144
- <?php _e('HTML is allowed.', 'wp-postviews'); ?><br />
145
- %VIEW_COUNT% - <?php _e('The number of views.', 'wp-postviews'); ?><br />
146
- <input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template', 'wp-postviews'); ?>" onclick="views_default_templates('template');" class="button" />
147
- </td>
148
- </tr>
149
- </table>
150
- </fieldset>
151
- <div align="center">
152
- <input type="submit" name="do" class="button" value="<?php _e('Update Options', 'wp-postviews'); ?>" />&nbsp;&nbsp;<input type="button" name="cancel" value="<?php _e('Cancel', 'wp-postviews'); ?>" class="button" onclick="javascript:history.go(-1)" />
153
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
  </div>
155
  </form>
 
156
 
157
  <!-- Uninstall WP-PostViews -->
158
  <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
@@ -168,13 +198,15 @@ switch($mode) {
168
  <p style="text-align: left; color: red">
169
  <strong><?php _e('The following WordPress Options/PostMetas will be DELETED:', 'wp-postviews'); ?></strong><br />
170
  </p>
171
- <table width="70%" border="0" cellspacing="3" cellpadding="3">
172
- <tr class="thead">
173
- <td align="center"><strong><?php _e('WordPress Options', 'wp-postviews'); ?></strong></td>
174
- <td align="center"><strong><?php _e('WordPress PostMetas', 'wp-postviews'); ?></strong></td>
175
- </tr>
 
 
176
  <tr>
177
- <td valign="top" style="background-color: #eee;">
178
  <ol>
179
  <?php
180
  foreach($views_settings as $settings) {
@@ -183,7 +215,7 @@ switch($mode) {
183
  ?>
184
  </ol>
185
  </td>
186
- <td valign="top" style="background-color: #eee;">
187
  <ol>
188
  <?php
189
  foreach($views_postmetas as $postmeta) {
2
  /*
3
  +----------------------------------------------------------------+
4
  | |
5
+ | WordPress 2.5 Plugin: WP-PostViews 1.30 |
6
+ | Copyright (c) 2008 Lester "GaMerZ" Chan |
7
  | |
8
  | File Written By: |
9
  | - Lester "GaMerZ" Chan |
11
  | |
12
  | File Information: |
13
  | - Post Views Options Page |
14
+ | - wp-content/plugins/wp-postviews/postviews-options.php |
15
  | |
16
  +----------------------------------------------------------------+
17
  */
18
 
19
 
20
  ### Variables Variables Variables
21
+ $base_name = plugin_basename('wp-postviews/postviews-options.php');
22
  $base_page = 'admin.php?page='.$base_name;
23
  $id = intval($_GET['id']);
24
  $mode = trim($_GET['mode']);
26
  $views_postmetas = array('views');
27
 
28
 
29
+ ### Form Processing
30
+ // Update Options
31
+ if(!empty($_POST['Submit'])) {
32
+ $views_options = array();
33
+ $views_options['count'] = intval($_POST['views_count']);
34
+ $views_options['exclude_bots'] = intval($_POST['views_exclude_bots']);
35
+ $views_options['template'] = trim($_POST['views_template_template']);
36
+ $views_options['most_viewed_template'] = trim($_POST['views_template_most_viewed']);
37
+ $update_views_queries = array();
38
+ $update_views_text = array();
39
+ $update_views_queries[] = update_option('views_options', $views_options);
40
+ $update_views_text[] = __('Post Views Options', 'wp-postviews');
41
+ $i=0;
42
+ $text = '';
43
+ foreach($update_views_queries as $update_views_query) {
44
+ if($update_views_query) {
45
+ $text .= '<font color="green">'.$update_views_text[$i].' '.__('Updated', 'wp-postviews').'</font><br />';
46
+ }
47
+ $i++;
48
+ }
49
+ if(empty($text)) {
50
+ $text = '<font color="red">'.__('No Post Views Option Updated', 'wp-postviews').'</font>';
51
+ }
52
+ }
53
+ // Decide What To Do
54
  if(!empty($_POST['do'])) {
55
+ // Uninstall WP-PostViews
56
+ switch($_POST['do']) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  case __('UNINSTALL WP-PostViews', 'wp-postviews') :
58
  if(trim($_POST['uninstall_views_yes']) == 'yes') {
59
  echo '<div id="message" class="updated fade">';
97
  switch($mode) {
98
  // Deactivating WP-PostViews
99
  case 'end-UNINSTALL':
100
+ $deactivate_url = 'plugins.php?action=deactivate&amp;plugin=wp-postviews/wp-postviews.php';
101
  if(function_exists('wp_nonce_url')) {
102
+ $deactivate_url = wp_nonce_url($deactivate_url, 'deactivate-plugin_wp-postviews/wp-postviews.php');
103
  }
104
  echo '<div class="wrap">';
105
  echo '<h2>'.__('Uninstall WP-PostViews', 'wp-postviews').'</h2>';
118
  case 'template':
119
  default_template = "<?php _e('%VIEW_COUNT% views', 'wp-postviews'); ?>";
120
  break;
121
+ case 'most_viewed':
122
+ default_template = "<li><a href=\"%POST_URL%\" title=\"%POST_TITLE%\">%POST_TITLE%</a> - %VIEW_COUNT% <?php _e('views', 'wp-postviews'); ?></li>";
123
+ break;
124
  }
125
  document.getElementById("views_template_" + template).value = default_template;
126
  }
129
  <?php if(!empty($text)) { echo '<!-- Last Action --><div id="message" class="updated fade"><p>'.$text.'</p></div>'; } ?>
130
  <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
131
  <div class="wrap">
132
+ <h2><?php _e('Post Views Options', 'wp-postviews'); ?></h2>
133
+ <table class="form-table">
134
+ <tr>
135
+ <td valign="top" width="30%"><strong><?php _e('Count Views From:', 'wp-postviews'); ?></strong></td>
136
+ <td valign="top">
137
+ <select name="views_count" size="1">
138
+ <option value="0"<?php selected('0', $views_options['count']); ?>><?php _e('Everyone', 'wp-postviews'); ?></option>
139
+ <option value="1"<?php selected('1', $views_options['count']); ?>><?php _e('Guests Only', 'wp-postviews'); ?></option>
140
+ <option value="2"<?php selected('2', $views_options['count']); ?>><?php _e('Registered Users Only', 'wp-postviews'); ?></option>
141
+ </select>
142
+ </td>
143
+ </tr>
144
+ <tr>
145
+ <td valign="top" width="30%"><strong><?php _e('Exclude Bot Views:', 'wp-postviews'); ?></strong></td>
146
+ <td valign="top">
147
+ <select name="views_exclude_bots" size="1">
148
+ <option value="0"<?php selected('0', $views_options['exclude_bots']); ?>><?php _e('No', 'wp-postviews'); ?></option>
149
+ <option value="1"<?php selected('1', $views_options['exclude_bots']); ?>><?php _e('Yes', 'wp-postviews'); ?></option>
150
+ </select>
151
+ </td>
152
+ </tr>
153
+ <tr>
154
+ <td valign="top">
155
+ <strong><?php _e('Views Template:', 'wp-postviews'); ?></strong><br /><br />
156
+ <?php _e('Allowed Variables:', 'wp-postviews'); ?><br />
157
+ - %VIEW_COUNT%<br /><br />
158
+ <input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template', 'wp-postviews'); ?>" onclick="views_default_templates('template');" class="button" />
159
+ </td>
160
+ <td valign="top">
161
+ <input type="text" id="views_template_template" name="views_template_template" size="70" value="<?php echo htmlspecialchars(stripslashes($views_options['template'])); ?>" />
162
+ </td>
163
+ </tr>
164
+ <tr>
165
+ <td valign="top">
166
+ <strong><?php _e('Most Viewed Template:', 'wp-postviews'); ?></strong><br /><br />
167
+ <?php _e('Allowed Variables:', 'wp-postviews'); ?><br />
168
+ - %VIEW_COUNT%<br />
169
+ - %POST_TITLE%<br />
170
+ - %POST_EXCERPT%<br />
171
+ - %POST_CONTENT%<br />
172
+ - %POST_URL%<br /><br />
173
+ <input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template', 'wp-postviews'); ?>" onclick="views_default_templates('most_viewed');" class="button" />
174
+ </td>
175
+ <td valign="top">
176
+ <textarea cols="80" rows="15" id="views_template_most_viewed" name="views_template_most_viewed"><?php echo htmlspecialchars(stripslashes($views_options['most_viewed_template'])); ?></textarea>
177
+ </td>
178
+ </tr>
179
+ </table>
180
+ <p class="submit">
181
+ <input type="submit" name="Submit" class="button" value="<?php _e('Save Changes', 'wp-postviews'); ?>" />
182
+ </p>
183
  </div>
184
  </form>
185
+ <p>&nbsp;</p>
186
 
187
  <!-- Uninstall WP-PostViews -->
188
  <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
198
  <p style="text-align: left; color: red">
199
  <strong><?php _e('The following WordPress Options/PostMetas will be DELETED:', 'wp-postviews'); ?></strong><br />
200
  </p>
201
+ <table class="widefat">
202
+ <thead>
203
+ <tr>
204
+ <th><?php _e('WordPress Options', 'wp-postviews'); ?></th>
205
+ <th><?php _e('WordPress PostMetas', 'wp-postviews'); ?></th>
206
+ </tr>
207
+ </thead>
208
  <tr>
209
+ <td valign="top">
210
  <ol>
211
  <?php
212
  foreach($views_settings as $settings) {
215
  ?>
216
  </ol>
217
  </td>
218
+ <td valign="top" class="alternate">
219
  <ol>
220
  <?php
221
  foreach($views_postmetas as $postmeta) {
postviews/postviews.php DELETED
@@ -1,388 +0,0 @@
1
- <?php
2
- /*
3
- Plugin Name: WP-PostViews
4
- Plugin URI: http://lesterchan.net/portfolio/programming.php
5
- Description: Enables you to display how many times a post/page had been viewed. It will not count registered member views, but that can be changed easily.
6
- Version: 1.20
7
- Author: Lester 'GaMerZ' Chan
8
- Author URI: http://lesterchan.net
9
- */
10
-
11
-
12
- /*
13
- Copyright 2007 Lester Chan (email : gamerz84@hotmail.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', 'postviews_textdomain');
33
- function postviews_textdomain() {
34
- load_plugin_textdomain('wp-postviews', 'wp-content/plugins/postviews');
35
- }
36
-
37
-
38
- ### Function: Post Views Option Menu
39
- add_action('admin_menu', 'postviews_menu');
40
- function postviews_menu() {
41
- if (function_exists('add_options_page')) {
42
- add_options_page(__('Post Views', 'wp-postviews'), __('Post Views', 'wp-postviews'), 'manage_options', 'postviews/postviews-options.php') ;
43
- }
44
- }
45
-
46
-
47
- ### Function: Calculate Post Views
48
- add_action('loop_start', 'process_postviews');
49
- function process_postviews() {
50
- global $id, $user_ID;
51
- $views_options = get_option('views_options');
52
- $post_views = get_post_custom($post_id);
53
- $post_views = intval($post_views['views'][0]);
54
- $should_count = false;
55
- switch(intval($views_options['count'])) {
56
- case 0:
57
- $should_count = true;
58
- break;
59
- case 1:
60
- if(empty($_COOKIE[USER_COOKIE])) {
61
- $should_count = true;
62
- }
63
- break;
64
- case 2:
65
- if(intval($user_ID) > 0) {
66
- $should_count = true;
67
- }
68
- break;
69
- }
70
- if($should_count) {
71
- if(is_single() || is_page()) {
72
- if(!update_post_meta($id, 'views', ($post_views+1))) {
73
- add_post_meta($id, 'views', 1, true);
74
- }
75
- remove_action('loop_start', 'process_postviews');
76
- }
77
- }
78
- }
79
-
80
-
81
- ### Function: Display The Post Views
82
- function the_views($display = true) {
83
- $post_views = intval(post_custom('views'));
84
- $views_options = get_option('views_options');
85
- $output = str_replace('%VIEW_COUNT%', number_format($post_views), $views_options['template']);
86
- if($display) {
87
- echo $output;
88
- } else {
89
- return $output;
90
- }
91
- }
92
-
93
-
94
- ### Function: Display Most Viewed Page/Post
95
- if(!function_exists('get_most_viewed')) {
96
- function get_most_viewed($mode = '', $limit = 10, $chars = 0, $display = true) {
97
- global $wpdb, $post;
98
- $where = '';
99
- $temp = '';
100
- if(!empty($mode) && $mode != 'both') {
101
- $where = "post_type = '$mode'";
102
- } else {
103
- $where = '1=1';
104
- }
105
- $most_viewed = $wpdb->get_results("SELECT DISTINCT $wpdb->posts.*, (meta_value+0) AS views FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON $wpdb->postmeta.post_id = $wpdb->posts.ID WHERE post_date < '".current_time('mysql')."' AND $where AND post_status = 'publish' AND meta_key = 'views' AND post_password = '' ORDER BY views DESC LIMIT $limit");
106
- if($most_viewed) {
107
- if($chars > 0) {
108
- foreach ($most_viewed as $post) {
109
- $post_title = get_the_title();
110
- $post_views = intval($post->views);
111
- $post_views = number_format($post_views);
112
- $temp .= "<li><a href=\"".get_permalink()."\">".snippet_chars($post_title, $chars)."</a> - $post_views ".__('views', 'wp-postviews')."</li>\n";
113
- }
114
- } else {
115
- foreach ($most_viewed as $post) {
116
- $post_title = get_the_title();
117
- $post_views = intval($post->views);
118
- $post_views = number_format($post_views);
119
- $temp .= "<li><a href=\"".get_permalink()."\">$post_title</a> - $post_views ".__('views', 'wp-postviews')."</li>\n";
120
- }
121
- }
122
- } else {
123
- $temp = '<li>'.__('N/A', 'wp-postviews').'</li>'."\n";
124
- }
125
- if($display) {
126
- echo $temp;
127
- } else {
128
- return $temp;
129
- }
130
- }
131
- }
132
-
133
-
134
- ### Function: Display Most Viewed Page/Post By Category ID
135
- if(!function_exists('get_most_viewed_category')) {
136
- function get_most_viewed_category($category_id = 0, $mode = '', $limit = 10, $chars = 0, $display = true) {
137
- global $wpdb, $post;
138
- $where = '';
139
- $temp = '';
140
- if(is_array($category_id)) {
141
- $category_sql = "$wpdb->term_relationships.term_taxonomy_id IN (".join(',', $category_id).')';
142
- } else {
143
- $category_sql = "$wpdb->term_relationships.term_taxonomy_id = $category_id";
144
- }
145
- if(!empty($mode) && $mode != 'both') {
146
- $where = "post_type = '$mode'";
147
- } else {
148
- $where = '1=1';
149
- }
150
- $most_viewed = $wpdb->get_results("SELECT DISTINCT $wpdb->posts.*, (meta_value+0) AS views FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON $wpdb->postmeta.post_id = $wpdb->posts.ID LEFT JOIN $wpdb->term_relationships ON $wpdb->term_relationships.object_id = $wpdb->posts.ID WHERE post_date < '".current_time('mysql')."' AND $category_sql AND $where AND post_status = 'publish' AND meta_key = 'views' AND post_password = '' ORDER BY views DESC LIMIT $limit");
151
- if($most_viewed) {
152
- if($chars > 0) {
153
- foreach ($most_viewed as $post) {
154
- $post_title = htmlspecialchars(stripslashes($post->post_title));
155
- $post_views = intval($post->views);
156
- $post_views = number_format($post_views);
157
- $temp .= "<li><a href=\"".get_permalink()."\">".snippet_chars($post_title, $chars)."</a> - $post_views ".__('views', 'wp-postviews')."</li>\n";
158
- }
159
- } else {
160
- foreach ($most_viewed as $post) {
161
- $post_title = htmlspecialchars(stripslashes($post->post_title));
162
- $post_views = intval($post->views);
163
- $post_views = number_format($post_views);
164
- $temp .= "<li><a href=\"".get_permalink()."\">$post_title</a> - $post_views ".__('views', 'wp-postviews')."</li>\n";
165
- }
166
- }
167
- } else {
168
- $temp = '<li>'.__('N/A', 'wp-postviews').'</li>'."\n";
169
- }
170
- if($display) {
171
- echo $temp;
172
- } else {
173
- return $temp;
174
- }
175
- }
176
- }
177
-
178
-
179
- ### Function: Get TimeSpan Most Viewed - Added by Paolo Tagliaferri (http://www.vortexmind.net - webmaster@vortexmind.net)
180
- function get_timespan_most_viewed($mode = '', $limit = 10, $days = 7, $display = true) {
181
- global $wpdb, $post;
182
- $limit_date = current_time('timestamp') - ($days*86400);
183
- $limit_date = date("Y-m-d H:i:s",$limit_date);
184
- $where = '';
185
- $temp = '';
186
- if(!empty($mode) && $mode != 'both') {
187
- $where = "post_type = '$mode'";
188
- } else {
189
- $where = '1=1';
190
- }
191
- $most_viewed = $wpdb->get_results("SELECT DISTINCT $wpdb->posts.*, (meta_value+0) AS views FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON $wpdb->postmeta.post_id = $wpdb->posts.ID WHERE post_date < '".current_time('mysql')."' AND post_date > '".$limit_date."' AND $where AND post_status = 'publish' AND meta_key = 'views' AND post_password = '' ORDER BY views DESC LIMIT $limit");
192
- if($most_viewed) {
193
- foreach ($most_viewed as $post) {
194
- $post_title = get_the_title();
195
- $post_views = intval($post->views);
196
- $post_views = number_format($post_views);
197
- $temp .= "<li><a href=\"".get_permalink()."\">$post_title</a> - $post_views ".__('views', 'wp-postviews')."</li>";
198
- }
199
- } else {
200
- $temp = '<li>'.__('N/A', 'wp-postviews').'</li>'."\n";
201
- }
202
- if($display) {
203
- echo $temp;
204
- } else {
205
- return $temp;
206
- }
207
- }
208
-
209
-
210
- ### Function: Get TimeSpan Most Viewed By Category
211
- function get_timespan_most_viewed_cat($category_id = 0, $mode = '', $limit = 10, $days = 7, $display = true) {
212
- global $wpdb, $post;
213
- $limit_date = current_time('timestamp') - ($days*86400);
214
- $limit_date = date("Y-m-d H:i:s",$limit_date);
215
- $where = '';
216
- $temp = '';
217
- if(is_array($category_id)) {
218
- $category_sql = "$wpdb->term_relationships.term_taxonomy_id IN (".join(',', $category_id).')';
219
- } else {
220
- $category_sql = "$wpdb->term_relationships.term_taxonomy_id = $category_id";
221
- }
222
- if(!empty($mode) && $mode != 'both') {
223
- $where = "post_type = '$mode'";
224
- } else {
225
- $where = '1=1';
226
- }
227
- $most_viewed = $wpdb->get_results("SELECT DISTINCT $wpdb->posts.*, (meta_value+0) AS views FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON $wpdb->postmeta.post_id = $wpdb->posts.ID LEFT JOIN $wpdb->term_relationships ON $wpdb->term_relationships.object_id = $wpdb->posts.ID WHERE post_date < '".current_time('mysql')."' AND $category_sql AND post_date > '".$limit_date."' AND $where AND post_status = 'publish' AND meta_key = 'views' AND post_password = '' ORDER BY views DESC LIMIT $limit");
228
- if($most_viewed) {
229
- foreach ($most_viewed as $post) {
230
- $post_title = get_the_title();
231
- $post_views = intval($post->views);
232
- $post_views = number_format($post_views);
233
- $temp .= "<li><a href=\"".get_permalink()."\">$post_title</a> - $post_views ".__('views', 'wp-postviews')."</li>";
234
- }
235
- } else {
236
- $temp = '<li>'.__('N/A', 'wp-postviews').'</li>'."\n";
237
- }
238
- if($display) {
239
- echo $temp;
240
- } else {
241
- return $temp;
242
- }
243
- }
244
-
245
-
246
- ### Function: Display Total Views
247
- if(!function_exists('get_totalviews')) {
248
- function get_totalviews($display = true) {
249
- global $wpdb;
250
- $total_views = $wpdb->get_var("SELECT SUM(meta_value+0) FROM $wpdb->postmeta WHERE meta_key = 'views'");
251
- if($display) {
252
- echo number_format($total_views);
253
- } else {
254
- return number_format($total_views);
255
- }
256
- }
257
- }
258
-
259
-
260
- ### Function: Snippet Text
261
- if(!function_exists('snippet_chars')) {
262
- function snippet_chars($text, $length = 0) {
263
- $text = htmlspecialchars_decode($text);
264
- if (strlen($text) > $length){
265
- return htmlspecialchars(substr($text,0,$length)).'...';
266
- } else {
267
- return htmlspecialchars($text);
268
- }
269
- }
270
- }
271
-
272
-
273
- ### Function: HTML Special Chars Decode
274
- if (!function_exists('htmlspecialchars_decode')) {
275
- function htmlspecialchars_decode($text) {
276
- return strtr($text, array_flip(get_html_translation_table(HTML_SPECIALCHARS)));
277
- }
278
- }
279
-
280
-
281
- ### Function: Modify Default WordPress Listing To Make It Sorted By Post Views
282
- function views_fields($content) {
283
- global $wpdb;
284
- $content .= ", ($wpdb->postmeta.meta_value+0) AS views";
285
- return $content;
286
- }
287
- function views_join($content) {
288
- global $wpdb;
289
- $content .= " LEFT JOIN $wpdb->postmeta ON $wpdb->postmeta.post_id = $wpdb->posts.ID";
290
- return $content;
291
- }
292
- function views_where($content) {
293
- global $wpdb;
294
- $content .= " AND $wpdb->postmeta.meta_key = 'views'";
295
- return $content;
296
- }
297
- function views_orderby($content) {
298
- $orderby = trim(addslashes($_GET['orderby']));
299
- if(empty($orderby) || ($orderby != 'asc' && $orderby != 'desc')) {
300
- $orderby = 'desc';
301
- }
302
- $content = " views $orderby";
303
- return $content;
304
- }
305
-
306
-
307
- ### Process The Sorting
308
- /*
309
- if($_GET['sortby'] == 'views') {
310
- add_filter('posts_fields', 'views_fields');
311
- add_filter('posts_join', 'views_join');
312
- add_filter('posts_where', 'views_where');
313
- add_filter('posts_orderby', 'views_orderby');
314
- }
315
- */
316
-
317
-
318
- ### Function: Plug Into WP-Stats
319
- if(strpos(get_option('stats_url'), $_SERVER['REQUEST_URI']) || strpos($_SERVER['REQUEST_URI'], 'stats-options.php') || strpos($_SERVER['REQUEST_URI'], 'stats/stats.php')) {
320
- add_filter('wp_stats_page_admin_plugins', 'postviews_page_admin_general_stats');
321
- add_filter('wp_stats_page_admin_most', 'postviews_page_admin_most_stats');
322
- add_filter('wp_stats_page_plugins', 'postviews_page_general_stats');
323
- add_filter('wp_stats_page_most', 'postviews_page_most_stats');
324
- }
325
-
326
-
327
- ### Function: Add WP-PostViews General Stats To WP-Stats Page Options
328
- function postviews_page_admin_general_stats($content) {
329
- $stats_display = get_option('stats_display');
330
- if($stats_display['views'] == 1) {
331
- $content .= '<input type="checkbox" name="stats_display[]" id="wpstats_views" value="views" checked="checked" />&nbsp;&nbsp;<label for="wpstats_views">'.__('WP-PostViews', 'wp-postviews').'</label><br />'."\n";
332
- } else {
333
- $content .= '<input type="checkbox" name="stats_display[]" id="wpstats_views" value="views" />&nbsp;&nbsp;<label for="wpstats_views">'.__('WP-PostViews', 'wp-postviews').'</label><br />'."\n";
334
- }
335
- return $content;
336
- }
337
-
338
-
339
- ### Function: Add WP-PostViews Top Most/Highest Stats To WP-Stats Page Options
340
- function postviews_page_admin_most_stats($content) {
341
- $stats_display = get_option('stats_display');
342
- $stats_mostlimit = intval(get_option('stats_mostlimit'));
343
- if($stats_display['viewed_most'] == 1) {
344
- $content .= '<input type="checkbox" name="stats_display[]" id="wpstats_viewed_most" value="viewed_most" checked="checked" />&nbsp;&nbsp;<label for="wpstats_viewed_most">'.$stats_mostlimit.' '.__('Most Viewed Posts', 'wp-postviews').'</label><br />'."\n";
345
- } else {
346
- $content .= '<input type="checkbox" name="stats_display[]" id="wpstats_viewed_most" value="viewed_most" />&nbsp;&nbsp;<label for="wpstats_viewed_most">'.$stats_mostlimit.' '.__('Most Viewed Posts', 'wp-postviews').'</label><br />'."\n";
347
- }
348
- return $content;
349
- }
350
-
351
-
352
- ### Function: Add WP-PostViews General Stats To WP-Stats Page
353
- function postviews_page_general_stats($content) {
354
- $stats_display = get_option('stats_display');
355
- if($stats_display['views'] == 1) {
356
- $content .= '<p><strong>'.__('WP-PostViews', 'wp-postviews').'</strong></p>'."\n";
357
- $content .= '<ul>'."\n";
358
- $content .= '<li><strong>'.get_totalviews(false).'</strong> '.__('views were generated.', 'wp-postviews').'</li>'."\n";
359
- $content .= '</ul>'."\n";
360
- }
361
- return $content;
362
- }
363
-
364
-
365
- ### Function: Add WP-PostViews Top Most/Highest Stats To WP-Stats Page
366
- function postviews_page_most_stats($content) {
367
- $stats_display = get_option('stats_display');
368
- $stats_mostlimit = intval(get_option('stats_mostlimit'));
369
- if($stats_display['viewed_most'] == 1) {
370
- $content .= '<p><strong>'.$stats_mostlimit.' '.__('Most Viewed Post', 'wp-postviews').'</strong></p>'."\n";
371
- $content .= '<ul>'."\n";
372
- $content .= get_most_viewed('post', $stats_mostlimit, 0, false);
373
- $content .= '</ul>'."\n";
374
- }
375
- return $content;
376
- }
377
-
378
-
379
- ### Function: Post Views Options
380
- add_action('activate_postviews/postviews.php', 'views_init');
381
- function views_init() {
382
- // Add Options
383
- $views_options = array();
384
- $views_options['count'] = 1;
385
- $views_options['template'] = __('%VIEW_COUNT% views', 'wp-postviews');
386
- add_option('views_options', $views_options, 'Post Views Options');
387
- }
388
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
postviews/wp-postviews.mo DELETED
Binary file
readme.html CHANGED
@@ -2,7 +2,7 @@
2
  <html>
3
  <head>
4
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
5
- <title>WP-PostViews 1.20 Readme</title>
6
  <style type="text/css" media="screen">
7
  /* Default Style */
8
  BODY {
@@ -203,7 +203,7 @@
203
  <body>
204
  <div id="Container">
205
  <!-- Title -->
206
- <div id="Title">WP-PostViews 1.20&nbsp;&nbsp;&nbsp;<span style="color: #aaaaaa;">Readme</span></div>
207
 
208
  <!-- Tabs -->
209
  <ul id="Tabs">
@@ -224,28 +224,19 @@
224
  <strong>Author:</strong><br />
225
  <strong>&raquo;</strong> Lester 'GaMerZ' Chan
226
  </p>
227
- <p>
228
- <strong>EMail:</strong><br />
229
- <strong>&raquo;</strong>
230
- <script type="text/javascript">
231
- /* <![CDATA[*/
232
- document.write(' <a href="mailto:gamerz84@hotmail.com?Subject=WP-PostViews%201.20%20Support" title="EMail To gamerz84@hotmail.com">gamerz84@hotmail.com</a>');
233
- /* ]]> */
234
- </script>
235
- </p>
236
  <p>
237
  <strong>Website:</strong><br />
238
  <strong>&raquo;</strong> <a href="http://lesterchan.net/" title="http://lesterchan.net/">http://lesterchan.net/</a>
239
  </p>
240
  <p>
241
  <strong>Features:</strong><br />
242
- <strong>&raquo;</strong> Enables you to display how many times a post/page had been viewed. It will not count registered member views, but that can be changed easily.
243
  </p>
244
  <p>
245
  <strong>Download:</strong><br />
246
- <strong>&raquo;</strong> <a href="http://lesterchan.net/others/downloads.php?id=19" title="http://lesterchan.net/others/downloads.php?id=19">WP-PostViews 1.20 For WordPress 2.3.x</a><br />
247
- <strong>&raquo;</strong> <a href="http://lesterchan.net/others/downloads/wp-postviews111.zip" title="http://lesterchan.net/others/downloads/wp-postviews111.zip">WP-PostViews 1.11 For WordPress 2.1.x And 2.2.x</a><br />
248
- <strong>&raquo;</strong> <a href="http://lesterchan.net/others/downloads/wp-postviews102.zip" title="http://lesterchan.net/others/downloads/wp-postviews102.zip">WP-PostViews 1.02 For WordPress 2.0.x</a><br />
249
  </p>
250
  <p>
251
  <strong>Screenshots:</strong><br />
@@ -267,8 +258,8 @@
267
  <strong>&raquo;</strong> <a href="http://forums.lesterchan.net/index.php?board=16.0" title="http://forums.lesterchan.net/index.php?board=16.0">http://forums.lesterchan.net/index.php?board=16.0</a>
268
  </p>
269
  <p>
270
- <strong>Updated:</strong><br />
271
- <strong>&raquo;</strong> 1st October 2007
272
  </p>
273
  <p>
274
  <strong>Note:</strong><br />
@@ -279,7 +270,7 @@
279
  <strong>&raquo;</strong> I spent most of my free time creating, updating, maintaining and supporting these plugins, if you really love my plugins and could spare me a couple of bucks as my school allowance, I will really appericiate it. If not feel free to use it without any obligations. Thank You. My Paypal account is
280
  <script type="text/javascript">
281
  /* <![CDATA[*/
282
- document.write(' <strong>gamerz84@hotmail.com</strong>.');
283
  /* ]]> */
284
  </script>
285
  </p>
@@ -289,6 +280,19 @@
289
  <div id="Changelog" style="display: none;">
290
  <div class="SubTitle">&raquo; Changelog</div>
291
  <ul>
 
 
 
 
 
 
 
 
 
 
 
 
 
292
  <li>
293
  <strong>Version 1.20 (01-10-2007)</strong>
294
  <ul>
@@ -344,7 +348,7 @@
344
  </li>
345
  <li>
346
  Put:
347
- <blockquote>Folder: postviews</blockquote>
348
  </li>
349
  <li>
350
  <strong>Activate</strong> WP-PostViews Plugin
@@ -358,7 +362,7 @@
358
  <!-- Upgrade Instructions -->
359
  <div id="Upgrade" style="display: none;">
360
  <div class="SubTitle">&raquo; Upgrade Instructions</div>
361
- <div class="SubSubTitle">From v1.0x To v1.20</div>
362
  <ol>
363
  <li>
364
  <strong>Deactivate</strong> WP-PostViews Plugin
@@ -368,11 +372,13 @@
368
  </li>
369
  <li>
370
  Put/Overwrite:
371
- <blockquote>Folder: postviews</blockquote>
372
  </li>
373
  <li>
374
- Delete:
375
- <blockquote>File: postviews.php</blockquote>
 
 
376
  </li>
377
  <li>
378
  <strong>Activate</strong> WP-PostViews Plugin
@@ -405,7 +411,7 @@
405
  </blockquote>
406
  </li>
407
  <li>
408
- Go to <strong>'WP-Admin -> Options -> Post Views'</strong> to configure the plugin.
409
  </li>
410
  </ol>
411
  <div class="SubSubTitle">View Stats (With Widgets)</div>
@@ -414,19 +420,19 @@
414
  <strong>Activate</strong> WP-PostViews Widget Plugin
415
  </li>
416
  <li>
417
- Go to '<strong>WP-Admin -> Presentation -> Widgets</strong>'
418
  </li>
419
  <li>
420
  To Display <strong>Most Viewed Post</strong>
421
  </li>
422
  <li>
423
- <strong>Drag</strong> the Most Viewed Widget to your sidebar
424
  </li>
425
  <li>
426
- You can <strong>configure</strong> the Most Viewed Widget by clicking on the configure icon
427
  </li>
428
  <li>
429
- Click 'Save changes'
430
  </li>
431
  </ol>
432
  <div class="SubSubTitle">View Stats (Outside WP Loop)</div>
@@ -438,7 +444,9 @@
438
  Use:
439
  <blockquote>
440
  &lt;?php if (function_exists('get_most_viewed')): ?&gt;<br />
441
- &nbsp;&nbsp;&nbsp;&lt;?php get_most_viewed(); ?&gt;<br />
 
 
442
  &lt;?php endif; ?&gt;
443
  </blockquote>
444
  <p>
@@ -454,7 +462,9 @@
454
  Use:
455
  <blockquote>
456
  &lt;?php if (function_exists('get_most_viewed_category')): ?&gt;<br />
457
- &nbsp;&nbsp;&nbsp;&lt;?php get_most_viewed_category(); ?&gt;<br />
 
 
458
  &lt;?php endif; ?&gt;
459
  </blockquote>
460
  <p>
@@ -467,6 +477,6 @@
467
  </div>
468
  </div>
469
  </div>
470
- <p id="Copyright">WP-PostViews 1.20<br />Copyright &copy; 2007 Lester 'GaMerZ' Chan. All Rights Reserved.</p>
471
  </body>
472
  </html>
2
  <html>
3
  <head>
4
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
5
+ <title>WP-PostViews 1.30 Readme</title>
6
  <style type="text/css" media="screen">
7
  /* Default Style */
8
  BODY {
203
  <body>
204
  <div id="Container">
205
  <!-- Title -->
206
+ <div id="Title">WP-PostViews 1.30&nbsp;&nbsp;&nbsp;<span style="color: #aaaaaa;">Readme</span></div>
207
 
208
  <!-- Tabs -->
209
  <ul id="Tabs">
224
  <strong>Author:</strong><br />
225
  <strong>&raquo;</strong> Lester 'GaMerZ' Chan
226
  </p>
 
 
 
 
 
 
 
 
 
227
  <p>
228
  <strong>Website:</strong><br />
229
  <strong>&raquo;</strong> <a href="http://lesterchan.net/" title="http://lesterchan.net/">http://lesterchan.net/</a>
230
  </p>
231
  <p>
232
  <strong>Features:</strong><br />
233
+ <strong>&raquo;</strong> Enables you to display how many times a post/page had been viewed.
234
  </p>
235
  <p>
236
  <strong>Download:</strong><br />
237
+ <strong>&raquo;</strong> <a href="http://downloads.wordpress.org/plugin/wp-postviews.1.30.zip" title="http://downloads.wordpress.org/plugin/wp-postviews.1.30.zip">WP-PostViews 1.30 For WordPress 2.3.x And 2.5.x</a><br />
238
+ <strong>&raquo;</strong> <a href="http://downloads.wordpress.org/plugin/wp-postviews.1.11.zip" title="http://downloads.wordpress.org/plugin/wp-postviews.1.11.zip">WP-PostViews 1.11 For WordPress 2.1.x And 2.2.x</a><br />
239
+ <strong>&raquo;</strong> <a href="http://downloads.wordpress.org/plugin/wp-postviews.1.02.zip" title="http://downloads.wordpress.org/plugin/wp-postviews.1.02.zip">WP-PostViews 1.02 For WordPress 2.0.x</a><br />
240
  </p>
241
  <p>
242
  <strong>Screenshots:</strong><br />
258
  <strong>&raquo;</strong> <a href="http://forums.lesterchan.net/index.php?board=16.0" title="http://forums.lesterchan.net/index.php?board=16.0">http://forums.lesterchan.net/index.php?board=16.0</a>
259
  </p>
260
  <p>
261
+ <strong>Credits:</strong><br />
262
+ <strong>&raquo;</strong> WP-Cache/WP-SuperCache Compatibility By <a href="http://omninoggin.com/">Thaya Kareeson</a>.
263
  </p>
264
  <p>
265
  <strong>Note:</strong><br />
270
  <strong>&raquo;</strong> I spent most of my free time creating, updating, maintaining and supporting these plugins, if you really love my plugins and could spare me a couple of bucks as my school allowance, I will really appericiate it. If not feel free to use it without any obligations. Thank You. My Paypal account is
271
  <script type="text/javascript">
272
  /* <![CDATA[*/
273
+ document.write(' <strong>lesterchan@gmail.com</strong>.');
274
  /* ]]> */
275
  </script>
276
  </p>
280
  <div id="Changelog" style="display: none;">
281
  <div class="SubTitle">&raquo; Changelog</div>
282
  <ul>
283
+ <li>
284
+ <strong>Version 1.30 (01-06-2008)</strong>
285
+ <ul>
286
+ <li>NEW: Uses /wp-postviews/ Folder Instead Of /postviews/</li>
287
+ <li>NEW: Uses wp-postviews.php Instead Of postviews.php</li>
288
+ <li>NEW: Uses wp-postviews-widget.php Instead Of postviews-widget.php</li>
289
+ <li>NEW: Uses number_format_i18n() Instead Of number_format()</li>
290
+ <li>NEW: Option To Exclude Bots Views In 'WP-Admin -> Settings -> Post Views'</li>
291
+ <li>NEW: Added Most Viewed Template</li>
292
+ <li>NEW: Change The Way WP-PostViews Count Views</li>
293
+ <li>NEW: Should Work With WP-Cache Or WP-SuperCache</li>
294
+ </ul>
295
+ </li>
296
  <li>
297
  <strong>Version 1.20 (01-10-2007)</strong>
298
  <ul>
348
  </li>
349
  <li>
350
  Put:
351
+ <blockquote>Folder: wp-postviews</blockquote>
352
  </li>
353
  <li>
354
  <strong>Activate</strong> WP-PostViews Plugin
362
  <!-- Upgrade Instructions -->
363
  <div id="Upgrade" style="display: none;">
364
  <div class="SubTitle">&raquo; Upgrade Instructions</div>
365
+ <div class="SubSubTitle">From v1.0x To v1.30</div>
366
  <ol>
367
  <li>
368
  <strong>Deactivate</strong> WP-PostViews Plugin
372
  </li>
373
  <li>
374
  Put/Overwrite:
375
+ <blockquote>Folder: wp-postviews</blockquote>
376
  </li>
377
  <li>
378
+ Delete this folder if exists:
379
+ <blockquote>
380
+ Folder: postviews
381
+ </blockquote>
382
  </li>
383
  <li>
384
  <strong>Activate</strong> WP-PostViews Plugin
411
  </blockquote>
412
  </li>
413
  <li>
414
+ Go to <strong>'WP-Admin -> Settings -> Post Views'</strong> to configure the plugin.
415
  </li>
416
  </ol>
417
  <div class="SubSubTitle">View Stats (With Widgets)</div>
420
  <strong>Activate</strong> WP-PostViews Widget Plugin
421
  </li>
422
  <li>
423
+ Go to '<strong>WP-Admin -> Design -> Widgets</strong>'
424
  </li>
425
  <li>
426
  To Display <strong>Most Viewed Post</strong>
427
  </li>
428
  <li>
429
+ You can <strong>add</strong> the Most Viewed Widget by clicking on the 'Add' link besides it.
430
  </li>
431
  <li>
432
+ After adding, you can <strong>configure</strong> the Most Viewed Widget by clicking on the 'Edit' link besides it.
433
  </li>
434
  <li>
435
+ Click 'Save Changes'
436
  </li>
437
  </ol>
438
  <div class="SubSubTitle">View Stats (Outside WP Loop)</div>
444
  Use:
445
  <blockquote>
446
  &lt;?php if (function_exists('get_most_viewed')): ?&gt;<br />
447
+ &nbsp;&nbsp;&nbsp;&lt;ul&gt;<br />
448
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php get_most_viewed(); ?&gt;<br />
449
+ &nbsp;&nbsp;&nbsp;&lt;/ul&gt;<br />
450
  &lt;?php endif; ?&gt;
451
  </blockquote>
452
  <p>
462
  Use:
463
  <blockquote>
464
  &lt;?php if (function_exists('get_most_viewed_category')): ?&gt;<br />
465
+ &nbsp;&nbsp;&nbsp;&lt;ul&gt;<br />
466
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php get_most_viewed_category(); ?&gt;<br />
467
+ &nbsp;&nbsp;&nbsp;&lt;/ul&gt;<br />
468
  &lt;?php endif; ?&gt;
469
  </blockquote>
470
  <p>
477
  </div>
478
  </div>
479
  </div>
480
+ <p id="Copyright">WP-PostViews 1.30<br />Copyright &copy; 2008 Lester 'GaMerZ' Chan. All Rights Reserved.</p>
481
  </body>
482
  </html>
readme.txt CHANGED
@@ -2,15 +2,13 @@
2
  Contributors: GamerZ
3
  Donate link: http://lesterchan.net/wordpress
4
  Tags: views, hits, counter, postviews
5
- Requires at least: 2.3.0
6
- Stable tag: 1.20
7
 
8
  Enables you to display how many times a post/page had been viewed.
9
 
10
  == Description ==
11
 
12
- It will not count registered member views, but that can be changed easily.
13
-
14
  All the information (general, changelog, installation, upgrade, usage) you need about this plugin can be found here: [WP-PostViews Readme](http://lesterchan.net/wordpress/readme/wp-postviews.html "WP-PostViews Readme").
15
  It is the exact same readme.html is included in the zip package.
16
 
2
  Contributors: GamerZ
3
  Donate link: http://lesterchan.net/wordpress
4
  Tags: views, hits, counter, postviews
5
+ Requires at least: 2.5.0
6
+ Stable tag: 1.30
7
 
8
  Enables you to display how many times a post/page had been viewed.
9
 
10
  == Description ==
11
 
 
 
12
  All the information (general, changelog, installation, upgrade, usage) you need about this plugin can be found here: [WP-PostViews Readme](http://lesterchan.net/wordpress/readme/wp-postviews.html "WP-PostViews Readme").
13
  It is the exact same readme.html is included in the zip package.
14
 
postviews/postviews-widget.php → wp-postviews-widget.php RENAMED
@@ -1,16 +1,16 @@
1
  <?php
2
  /*
3
  Plugin Name: WP-PostViews Widget
4
- Plugin URI: http://lesterchan.net/portfolio/programming.php
5
  Description: Adds a PostViews Widget to display most viewed posts and/or pages on your sidebar. You will need to activate WP-PostViews first.
6
- Version: 1.20
7
  Author: Lester 'GaMerZ' Chan
8
  Author URI: http://lesterchan.net
9
  */
10
 
11
 
12
  /*
13
- Copyright 2007 Lester Chan (email : gamerz84@hotmail.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
@@ -38,7 +38,7 @@ function widget_views_init() {
38
  function widget_views_most_viewed($args) {
39
  extract($args);
40
  $options = get_option('widget_views_most_viewed');
41
- $title = htmlspecialchars($options['title']);
42
  if (function_exists('get_most_viewed')) {
43
  echo $before_widget.$before_title.$title.$after_title;
44
  echo '<ul>'."\n";
@@ -52,11 +52,11 @@ function widget_views_init() {
52
  function widget_views_most_viewed_options() {
53
  $options = get_option('widget_views_most_viewed');
54
  if (!is_array($options)) {
55
- $options = array('title' => __('Most Viewed', 'wp-postviews'), 'mode' => 'post', 'limit' => 10, 'chars' => 200);
56
  }
57
  if ($_POST['most_viewed-submit']) {
58
- $options['title'] = strip_tags(addslashes($_POST['most_viewed-title']));
59
- $options['mode'] = strip_tags(addslashes($_POST['most_viewed-mode']));
60
  $options['limit'] = intval($_POST['most_viewed-limit']);
61
  $options['chars'] = intval($_POST['most_viewed-chars']);
62
  update_option('widget_views_most_viewed', $options);
1
  <?php
2
  /*
3
  Plugin Name: WP-PostViews Widget
4
+ Plugin URI: http://lesterchan.net/portfolio/programming/php/
5
  Description: Adds a PostViews Widget to display most viewed posts and/or pages on your sidebar. You will need to activate WP-PostViews first.
6
+ Version: 1.30
7
  Author: Lester 'GaMerZ' Chan
8
  Author URI: http://lesterchan.net
9
  */
10
 
11
 
12
  /*
13
+ Copyright 2008 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
38
  function widget_views_most_viewed($args) {
39
  extract($args);
40
  $options = get_option('widget_views_most_viewed');
41
+ $title = htmlspecialchars(stripslashes($options['title']));
42
  if (function_exists('get_most_viewed')) {
43
  echo $before_widget.$before_title.$title.$after_title;
44
  echo '<ul>'."\n";
52
  function widget_views_most_viewed_options() {
53
  $options = get_option('widget_views_most_viewed');
54
  if (!is_array($options)) {
55
+ $options = array('title' => __('Most Viewed', 'wp-postviews'), 'mode' => 'post', 'limit' => 10, 'chars' => 0);
56
  }
57
  if ($_POST['most_viewed-submit']) {
58
+ $options['title'] = strip_tags($_POST['most_viewed-title']);
59
+ $options['mode'] = strip_tags($_POST['most_viewed-mode']);
60
  $options['limit'] = intval($_POST['most_viewed-limit']);
61
  $options['chars'] = intval($_POST['most_viewed-chars']);
62
  update_option('widget_views_most_viewed', $options);
wp-postviews.mo ADDED
Binary file
wp-postviews.php ADDED
@@ -0,0 +1,383 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: WP-PostViews
4
+ Plugin URI: http://lesterchan.net/portfolio/programming/php/
5
+ Description: Enables you to display how many times a post/page had been viewed.
6
+ Version: 1.30
7
+ Author: Lester 'GaMerZ' Chan
8
+ Author URI: http://lesterchan.net
9
+ */
10
+
11
+
12
+ /*
13
+ Copyright 2008 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
+ ### Load WP-Config File If This File Is Called Directly
32
+ if (!function_exists('add_action')) {
33
+ require_once('../../../wp-config.php');
34
+ }
35
+
36
+
37
+ ### Create Text Domain For Translations
38
+ add_action('init', 'postviews_textdomain');
39
+ function postviews_textdomain() {
40
+ load_plugin_textdomain('wp-postviews', 'wp-content/plugins/wp-postviews');
41
+ }
42
+
43
+
44
+ ### Function: Post Views Option Menu
45
+ add_action('admin_menu', 'postviews_menu');
46
+ function postviews_menu() {
47
+ if (function_exists('add_options_page')) {
48
+ add_options_page(__('Post Views', 'wp-postviews'), __('Post Views', 'wp-postviews'), 'manage_options', 'wp-postviews/postviews-options.php') ;
49
+ }
50
+ }
51
+
52
+
53
+ ### Function: Calculate Post Views
54
+ add_action('wp_head', 'process_postviews');
55
+ function process_postviews() {
56
+ global $user_ID, $post;
57
+ if(is_single() || is_page()) {
58
+ $id = intval($post->ID);
59
+ $views_options = get_option('views_options');
60
+ $post_views = get_post_custom($id);
61
+ $post_views = intval($post_views['views'][0]);
62
+ $should_count = false;
63
+ switch(intval($views_options['count'])) {
64
+ case 0:
65
+ $should_count = true;
66
+ break;
67
+ case 1:
68
+ if(empty($_COOKIE[USER_COOKIE]) && intval($user_ID) == 0) {
69
+ $should_count = true;
70
+ }
71
+ break;
72
+ case 2:
73
+ if(intval($user_ID) > 0) {
74
+ $should_count = true;
75
+ }
76
+ break;
77
+ }
78
+ if(intval($views_options['exclude_bots']) == 1) {
79
+ $bots = array('Google Bot' => 'googlebot', 'Google Bot' => 'google', 'MSN' => 'msnbot', 'Alex' => 'ia_archiver', 'Lycos' => 'lycos', 'Ask Jeeves' => 'jeeves', 'Altavista' => 'scooter', 'AllTheWeb' => 'fast-webcrawler', 'Inktomi' => 'slurp@inktomi', 'Turnitin.com' => 'turnitinbot', 'Technorati' => 'technorati', 'Yahoo' => 'yahoo', 'Findexa' => 'findexa', 'NextLinks' => 'findlinks', 'Gais' => 'gaisbo', 'WiseNut' => 'zyborg', 'WhoisSource' => 'surveybot', 'Bloglines' => 'bloglines', 'BlogSearch' => 'blogsearch', 'PubSub' => 'pubsub', 'Syndic8' => 'syndic8', 'RadioUserland' => 'userland', 'Gigabot' => 'gigabot', 'Become.com' => 'become.com');
80
+ $useragent = $_SERVER['HTTP_USER_AGENT'];
81
+ foreach ($bots as $name => $lookfor) {
82
+ if (stristr($useragent, $lookfor) !== false) {
83
+ $should_count = false;
84
+ break;
85
+ }
86
+ }
87
+ }
88
+ if($should_count) {
89
+ if(defined('WP_CACHE') && WP_CACHE) {
90
+ echo "\n".'<!-- Start Of Script Generated By WP-PostViews 1.30 -->'."\n";
91
+ wp_print_scripts(array('sack'));
92
+ echo '<script type="text/javascript">'."\n";
93
+ echo '/* <![CDATA[ */'."\n";
94
+ echo "\t".'var postviews_ajax_url = \''.get_option('siteurl').'/wp-content/plugins/wp-postviews/wp-postviews.php'."';\n";
95
+ echo "\t".'postviews_count = new sack(postviews_ajax_url);'."\n";
96
+ echo "\t".'postviews_count.setVar("postviews_id", '.$id.');'."\n";
97
+ echo "\t".'postviews_count.method = \'GET\';'."\n";
98
+ echo "\t".'postviews_count.runAJAX();'."\n";
99
+ echo "\t".'postviews_count = null;'."\n";
100
+ echo '/* ]]> */'."\n";
101
+ echo '</script>'."\n";
102
+ echo '<!-- End Of Script Generated By WP-PostViews 1.30 -->'."\n";
103
+ } else {
104
+ if(!update_post_meta($id, 'views', ($post_views+1))) {
105
+ add_post_meta($id, 'views', 1, true);
106
+ }
107
+ }
108
+ }
109
+ }
110
+ }
111
+
112
+
113
+ ### Function: Display The Post Views
114
+ function the_views($display = true) {
115
+ $post_views = intval(post_custom('views'));
116
+ $views_options = get_option('views_options');
117
+ $output = str_replace('%VIEW_COUNT%', number_format_i18n($post_views), $views_options['template']);
118
+ if($display) {
119
+ echo $output;
120
+ } else {
121
+ return $output;
122
+ }
123
+ }
124
+
125
+
126
+ ### Function: Display Most Viewed Page/Post
127
+ if(!function_exists('get_most_viewed')) {
128
+ function get_most_viewed($mode = '', $limit = 10, $chars = 0, $display = true) {
129
+ global $wpdb, $post;
130
+ $views_options = get_option('views_options');
131
+ $where = '';
132
+ $temp = '';
133
+ $output = '';
134
+ if(!empty($mode) && $mode != 'both') {
135
+ $where = "post_type = '$mode'";
136
+ } else {
137
+ $where = '1=1';
138
+ }
139
+ $most_viewed = $wpdb->get_results("SELECT DISTINCT $wpdb->posts.*, (meta_value+0) AS views FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON $wpdb->postmeta.post_id = $wpdb->posts.ID WHERE post_date < '".current_time('mysql')."' AND $where AND post_status = 'publish' AND meta_key = 'views' AND post_password = '' ORDER BY views DESC LIMIT $limit");
140
+ if($most_viewed) {
141
+ foreach ($most_viewed as $post) {
142
+ $post_views = number_format_i18n(intval($post->views));
143
+ $post_title = get_the_title();
144
+ $post_excerpt = views_post_excerpt($post->post_excerpt, $post->post_content, $post->post_password);
145
+ $post_content = get_the_content();
146
+ if($chars > 0) {
147
+ $temp = "<li><a href=\"".get_permalink()."\">".snippet_text($post_title, $chars)."</a> - $post_views ".__('views', 'wp-postviews')."</li>\n";
148
+ } else {
149
+ $temp = stripslashes($views_options['most_viewed_template']);
150
+ $temp = str_replace("%VIEW_COUNT%", $post_views, $temp);
151
+ $temp = str_replace("%POST_TITLE%", $post_title, $temp);
152
+ $temp = str_replace("%POST_EXCERPT%", $post_excerpt, $temp);
153
+ $temp = str_replace("%POST_CONTENT%", $post_content, $temp);
154
+ $temp = str_replace("%POST_URL%", get_permalink(), $temp);
155
+ }
156
+ $output .= $temp;
157
+ }
158
+ } else {
159
+ $output = '<li>'.__('N/A', 'wp-postviews').'</li>'."\n";
160
+ }
161
+ if($display) {
162
+ echo $output;
163
+ } else {
164
+ return $output;
165
+ }
166
+ }
167
+ }
168
+
169
+
170
+ ### Function: Display Most Viewed Page/Post By Category ID
171
+ if(!function_exists('get_most_viewed_category')) {
172
+ function get_most_viewed_category($category_id = 0, $mode = '', $limit = 10, $chars = 0, $display = true) {
173
+ global $wpdb, $post;
174
+ $views_options = get_option('views_options');
175
+ $where = '';
176
+ $temp = '';
177
+ $output = '';
178
+ if(is_array($category_id)) {
179
+ $category_sql = "$wpdb->term_taxonomy.term_id IN (".join(',', $category_id).')';
180
+ } else {
181
+ $category_sql = "$wpdb->term_taxonomy.term_id = $category_id";
182
+ }
183
+ if(!empty($mode) && $mode != 'both') {
184
+ $where = "post_type = '$mode'";
185
+ } else {
186
+ $where = '1=1';
187
+ }
188
+ $most_viewed = $wpdb->get_results("SELECT DISTINCT $wpdb->posts.*, (meta_value+0) AS views FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON $wpdb->postmeta.post_id = $wpdb->posts.ID INNER JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) INNER JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id) WHERE post_date < '".current_time('mysql')."' AND $wpdb->term_taxonomy.taxonomy = 'category' AND $category_sql AND $where AND post_status = 'publish' AND meta_key = 'views' AND post_password = '' ORDER BY views DESC LIMIT $limit");
189
+ if($most_viewed) {
190
+ foreach ($most_viewed as $post) {
191
+ $post_views = number_format_i18n(intval($post->views));
192
+ $post_title = get_the_title();
193
+ $post_excerpt = views_post_excerpt($post->post_excerpt, $post->post_content, $post->post_password);
194
+ $post_content = get_the_content();
195
+ if($chars > 0) {
196
+ $temp = "<li><a href=\"".get_permalink()."\">".snippet_text($post_title, $chars)."</a> - $post_views ".__('views', 'wp-postviews')."</li>\n";
197
+ } else {
198
+ $temp = stripslashes($views_options['most_viewed_template']);
199
+ $temp = str_replace("%VIEW_COUNT%", $post_views, $temp);
200
+ $temp = str_replace("%POST_TITLE%", $post_title, $temp);
201
+ $temp = str_replace("%POST_EXCERPT%", $post_excerpt, $temp);
202
+ $temp = str_replace("%POST_CONTENT%", $post_content, $temp);
203
+ $temp = str_replace("%POST_URL%", get_permalink(), $temp);
204
+ }
205
+ $output .= $temp;
206
+ }
207
+ } else {
208
+ $output = '<li>'.__('N/A', 'wp-postviews').'</li>'."\n";
209
+ }
210
+ if($display) {
211
+ echo $output;
212
+ } else {
213
+ return $output;
214
+ }
215
+ }
216
+ }
217
+
218
+
219
+ ### Function: Display Total Views
220
+ if(!function_exists('get_totalviews')) {
221
+ function get_totalviews($display = true) {
222
+ global $wpdb;
223
+ $total_views = $wpdb->get_var("SELECT SUM(meta_value+0) FROM $wpdb->postmeta WHERE meta_key = 'views'");
224
+ if($display) {
225
+ echo number_format_i18n($total_views);
226
+ } else {
227
+ return number_format_i18n($total_views);
228
+ }
229
+ }
230
+ }
231
+
232
+
233
+ ### Function: Snippet Text
234
+ if(!function_exists('snippet_text')) {
235
+ function snippet_text($text, $length = 0) {
236
+ $text = html_entity_decode($text, ENT_QUOTES, get_option('blog_charset'));
237
+ if (strlen($text) > $length) {
238
+ return htmlentities(substr($text,0,$length), ENT_COMPAT, get_option('blog_charset')).'...';
239
+ } else {
240
+ return htmlentities($text, ENT_COMPAT, get_option('blog_charset'));
241
+ }
242
+ }
243
+ }
244
+
245
+
246
+ ### Function: Process Post Excerpt, For Some Reasons, The Default get_post_excerpt() Does Not Work As Expected
247
+ function views_post_excerpt($post_excerpt, $post_content, $post_password) {
248
+ if(!empty($post_password)) {
249
+ if(!isset($_COOKIE['wp-postpass_'.COOKIEHASH]) || $_COOKIE['wp-postpass_'.COOKIEHASH] != $post_password) {
250
+ return __('There is no excerpt because this is a protected post.', 'wp-postviews');
251
+ }
252
+ }
253
+ if(empty($post_excerpt)) {
254
+ return snippet_text($post_content, 200);
255
+ } else {
256
+ return $post_excerpt;
257
+ }
258
+ }
259
+
260
+
261
+ ### Function: Modify Default WordPress Listing To Make It Sorted By Post Views
262
+ function views_fields($content) {
263
+ global $wpdb;
264
+ $content .= ", ($wpdb->postmeta.meta_value+0) AS views";
265
+ return $content;
266
+ }
267
+ function views_join($content) {
268
+ global $wpdb;
269
+ $content .= " LEFT JOIN $wpdb->postmeta ON $wpdb->postmeta.post_id = $wpdb->posts.ID";
270
+ return $content;
271
+ }
272
+ function views_where($content) {
273
+ global $wpdb;
274
+ $content .= " AND $wpdb->postmeta.meta_key = 'views'";
275
+ return $content;
276
+ }
277
+ function views_orderby($content) {
278
+ $orderby = trim(addslashes($_GET['orderby']));
279
+ if(empty($orderby) || ($orderby != 'asc' && $orderby != 'desc')) {
280
+ $orderby = 'desc';
281
+ }
282
+ $content = " views $orderby";
283
+ return $content;
284
+ }
285
+
286
+
287
+ ### Process The Sorting
288
+ if($_GET['sortby'] == 'views') {
289
+ add_filter('posts_fields', 'views_fields');
290
+ add_filter('posts_join', 'views_join');
291
+ add_filter('posts_where', 'views_where');
292
+ add_filter('posts_orderby', 'views_orderby');
293
+ }
294
+
295
+
296
+ ### Function: Plug Into WP-Stats
297
+ if(strpos(get_option('stats_url'), $_SERVER['REQUEST_URI']) || strpos($_SERVER['REQUEST_URI'], 'stats-options.php') || strpos($_SERVER['REQUEST_URI'], 'wp-stats/wp-stats.php')) {
298
+ add_filter('wp_stats_page_admin_plugins', 'postviews_page_admin_general_stats');
299
+ add_filter('wp_stats_page_admin_most', 'postviews_page_admin_most_stats');
300
+ add_filter('wp_stats_page_plugins', 'postviews_page_general_stats');
301
+ add_filter('wp_stats_page_most', 'postviews_page_most_stats');
302
+ }
303
+
304
+
305
+ ### Function: Add WP-PostViews General Stats To WP-Stats Page Options
306
+ function postviews_page_admin_general_stats($content) {
307
+ $stats_display = get_option('stats_display');
308
+ if($stats_display['views'] == 1) {
309
+ $content .= '<input type="checkbox" name="stats_display[]" id="wpstats_views" value="views" checked="checked" />&nbsp;&nbsp;<label for="wpstats_views">'.__('WP-PostViews', 'wp-postviews').'</label><br />'."\n";
310
+ } else {
311
+ $content .= '<input type="checkbox" name="stats_display[]" id="wpstats_views" value="views" />&nbsp;&nbsp;<label for="wpstats_views">'.__('WP-PostViews', 'wp-postviews').'</label><br />'."\n";
312
+ }
313
+ return $content;
314
+ }
315
+
316
+
317
+ ### Function: Add WP-PostViews Top Most/Highest Stats To WP-Stats Page Options
318
+ function postviews_page_admin_most_stats($content) {
319
+ $stats_display = get_option('stats_display');
320
+ $stats_mostlimit = intval(get_option('stats_mostlimit'));
321
+ if($stats_display['viewed_most'] == 1) {
322
+ $content .= '<input type="checkbox" name="stats_display[]" id="wpstats_viewed_most" value="viewed_most" checked="checked" />&nbsp;&nbsp;<label for="wpstats_viewed_most">'.$stats_mostlimit.' '.__('Most Viewed Posts', 'wp-postviews').'</label><br />'."\n";
323
+ } else {
324
+ $content .= '<input type="checkbox" name="stats_display[]" id="wpstats_viewed_most" value="viewed_most" />&nbsp;&nbsp;<label for="wpstats_viewed_most">'.$stats_mostlimit.' '.__('Most Viewed Posts', 'wp-postviews').'</label><br />'."\n";
325
+ }
326
+ return $content;
327
+ }
328
+
329
+
330
+ ### Function: Add WP-PostViews General Stats To WP-Stats Page
331
+ function postviews_page_general_stats($content) {
332
+ $stats_display = get_option('stats_display');
333
+ if($stats_display['views'] == 1) {
334
+ $content .= '<p><strong>'.__('WP-PostViews', 'wp-postviews').'</strong></p>'."\n";
335
+ $content .= '<ul>'."\n";
336
+ $content .= '<li><strong>'.get_totalviews(false).'</strong> '.__('views were generated.', 'wp-postviews').'</li>'."\n";
337
+ $content .= '</ul>'."\n";
338
+ }
339
+ return $content;
340
+ }
341
+
342
+
343
+ ### Function: Add WP-PostViews Top Most/Highest Stats To WP-Stats Page
344
+ function postviews_page_most_stats($content) {
345
+ $stats_display = get_option('stats_display');
346
+ $stats_mostlimit = intval(get_option('stats_mostlimit'));
347
+ if($stats_display['viewed_most'] == 1) {
348
+ $content .= '<p><strong>'.$stats_mostlimit.' '.__('Most Viewed Post', 'wp-postviews').'</strong></p>'."\n";
349
+ $content .= '<ul>'."\n";
350
+ $content .= get_most_viewed('post', $stats_mostlimit, 0, false);
351
+ $content .= '</ul>'."\n";
352
+ }
353
+ return $content;
354
+ }
355
+
356
+
357
+ ### Function: Increment Post Views
358
+ increment_views();
359
+ function increment_views() {
360
+ global $wpdb;
361
+ $post_id = intval($_GET['postviews_id']);
362
+ if($post_id > 0) {
363
+ $post_views = get_post_custom($post_id);
364
+ $post_views = intval($post_views['views'][0]);
365
+ if(!update_post_meta($post_id, 'views', ($post_views+1))) {
366
+ add_post_meta($post_id, 'views', 1, true);
367
+ }
368
+ }
369
+ }
370
+
371
+
372
+ ### Function: Post Views Options
373
+ add_action('activate_wp-postviews/wp-postviews.php', 'views_init');
374
+ function views_init() {
375
+ // Add Options
376
+ $views_options = array();
377
+ $views_options['count'] = 1;
378
+ $views_options['exclude_bots'] = 0;
379
+ $views_options['template'] = __('%VIEW_COUNT% views', 'wp-postviews');
380
+ $views_options['most_viewed_template'] = '<li><a href="%POST_URL%" title="%POST_TITLE%">%POST_TITLE%</a> - %VIEW_COUNT% '.__('views', 'wp-postviews').'</li>';
381
+ add_option('views_options', $views_options, 'Post Views Options');
382
+ }
383
+ ?>
postviews/wp-postviews.pot → wp-postviews.pot RENAMED
@@ -1,12 +1,13 @@
1
  msgid ""
2
  msgstr ""
3
- "Project-Id-Version: WP-PostViews 1.11\n"
4
- "POT-Creation-Date: \n"
5
- "PO-Revision-Date: 2007-09-30 16:06+0800\n"
6
- "Last-Translator: Lester 'GaMerZ' Chan <gamerz84@hotmail.com>\n"
7
- "Language-Team: Lester Chan <gamerz84@hotmail.com>\n"
 
8
  "MIME-Version: 1.0\n"
9
- "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
11
  "X-Poedit-Language: English\n"
12
  "X-Poedit-Country: SINGAPORE\n"
@@ -14,14 +15,8 @@ msgstr ""
14
  "X-Poedit-Basepath: .\n"
15
  "X-Poedit-SearchPath-0: .\n"
16
 
17
- #: postviews-options.php:33
18
- #: postviews-options.php:152
19
- msgid "Update Options"
20
- msgstr ""
21
-
22
  #: postviews-options.php:40
23
- #: postviews-options.php:126
24
- #: postviews-options.php:128
25
  msgid "Post Views Options"
26
  msgstr ""
27
 
@@ -33,111 +28,129 @@ msgstr ""
33
  msgid "No Post Views Option Updated"
34
  msgstr ""
35
 
36
- #: postviews-options.php:54
37
- #: postviews-options.php:200
38
  msgid "UNINSTALL WP-PostViews"
39
  msgstr ""
40
 
41
- #: postviews-options.php:62
42
  #, php-format
43
  msgid "Setting Key '%s' has been deleted."
44
  msgstr ""
45
 
46
- #: postviews-options.php:66
47
  #, php-format
48
  msgid "Error deleting Setting Key '%s'."
49
  msgstr ""
50
 
51
- #: postviews-options.php:76
52
  #, php-format
53
  msgid "Post Meta Key '%s' has been deleted."
54
  msgstr ""
55
 
56
- #: postviews-options.php:80
57
  #, php-format
58
  msgid "Error deleting Post Meta Key '%s'."
59
  msgstr ""
60
 
61
- #: postviews-options.php:102
62
- #: postviews-options.php:160
63
  msgid "Uninstall WP-PostViews"
64
  msgstr ""
65
 
66
- #: postviews-options.php:103
67
  #, php-format
68
  msgid "<a href=\"%s\">Click Here</a> To Finish The Uninstallation And WP-PostViews Will Be Deactivated Automatically."
69
  msgstr ""
70
 
71
- #: postviews-options.php:116
72
- #: postviews.php:385
73
  msgid "%VIEW_COUNT% views"
74
  msgstr ""
75
 
76
- #: postviews-options.php:131
 
 
 
 
 
 
 
77
  msgid "Count Views From:"
78
  msgstr ""
79
 
80
- #: postviews-options.php:134
81
  msgid "Everyone"
82
  msgstr ""
83
 
84
- #: postviews-options.php:135
85
  msgid "Guests Only"
86
  msgstr ""
87
 
88
- #: postviews-options.php:136
89
  msgid "Registered Users Only"
90
  msgstr ""
91
 
92
- #: postviews-options.php:141
93
- msgid "Views Template:"
94
  msgstr ""
95
 
96
- #: postviews-options.php:144
97
- msgid "HTML is allowed."
98
  msgstr ""
99
 
100
- #: postviews-options.php:145
101
- msgid "The number of views."
 
 
 
 
 
 
 
 
 
 
102
  msgstr ""
103
 
104
- #: postviews-options.php:146
 
105
  msgid "Restore Default Template"
106
  msgstr ""
107
 
108
- #: postviews-options.php:152
109
- msgid "Cancel"
 
 
 
 
110
  msgstr ""
111
 
112
- #: postviews-options.php:162
113
  msgid "Deactivating WP-PostViews plugin does not remove any data that may have been created, such as the views data. To completely remove this plugin, you can uninstall it here."
114
  msgstr ""
115
 
116
- #: postviews-options.php:165
117
  msgid "WARNING:"
118
  msgstr ""
119
 
120
- #: postviews-options.php:166
121
  msgid "Once uninstalled, this cannot be undone. You should use a Database Backup plugin of WordPress to back up all the data first."
122
  msgstr ""
123
 
124
- #: postviews-options.php:169
125
  msgid "The following WordPress Options/PostMetas will be DELETED:"
126
  msgstr ""
127
 
128
- #: postviews-options.php:173
129
  msgid "WordPress Options"
130
  msgstr ""
131
 
132
- #: postviews-options.php:174
133
  msgid "WordPress PostMetas"
134
  msgstr ""
135
 
136
- #: postviews-options.php:199
137
- msgid "Yes"
138
- msgstr ""
139
-
140
- #: postviews-options.php:200
141
  msgid ""
142
  "You Are About To Uninstall WP-PostViews From WordPress.\\n"
143
  "This Action Is Not Reversible.\\n"
@@ -145,82 +158,75 @@ msgid ""
145
  " Choose [Cancel] To Stop, [OK] To Uninstall."
146
  msgstr ""
147
 
148
- #: postviews-widget.php:55
149
  msgid "Most Viewed"
150
  msgstr ""
151
 
152
- #: postviews-widget.php:65
153
  msgid "Title"
154
  msgstr ""
155
 
156
- #: postviews-widget.php:68
157
  msgid "Show Views For: "
158
  msgstr ""
159
 
160
- #: postviews-widget.php:74
161
  msgid "Post &amp Page"
162
  msgstr ""
163
 
164
- #: postviews-widget.php:79
165
  msgid "Post"
166
  msgstr ""
167
 
168
- #: postviews-widget.php:84
169
  msgid "Page"
170
  msgstr ""
171
 
172
- #: postviews-widget.php:87
173
  msgid "Only"
174
  msgstr ""
175
 
176
- #: postviews-widget.php:90
177
  msgid "Limit"
178
  msgstr ""
179
 
180
- #: postviews-widget.php:93
181
  msgid "Post Title Length (Characters)"
182
  msgstr ""
183
 
184
- #: postviews-widget.php:95
185
  msgid "(<strong>0</strong> to disable)"
186
  msgstr ""
187
 
188
- #: postviews.php:42
189
  msgid "Post Views"
190
  msgstr ""
191
 
192
- #: postviews.php:112
193
- #: postviews.php:119
194
- #: postviews.php:157
195
- #: postviews.php:164
196
- #: postviews.php:197
197
- #: postviews.php:233
198
- msgid "views"
199
  msgstr ""
200
 
201
- #: postviews.php:123
202
- #: postviews.php:168
203
- #: postviews.php:200
204
- #: postviews.php:236
205
- msgid "N/A"
206
  msgstr ""
207
 
208
- #: postviews.php:331
209
- #: postviews.php:333
210
- #: postviews.php:356
211
  msgid "WP-PostViews"
212
  msgstr ""
213
 
214
- #: postviews.php:344
215
- #: postviews.php:346
216
  msgid "Most Viewed Posts"
217
  msgstr ""
218
 
219
- #: postviews.php:358
220
  msgid "views were generated."
221
  msgstr ""
222
 
223
- #: postviews.php:370
224
  msgid "Most Viewed Post"
225
  msgstr ""
226
 
1
  msgid ""
2
  msgstr ""
3
+ "Project-Id-Version: WP-PostViews 1.30\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2008-06-09 19:47+0800\n"
6
+ "PO-Revision-Date: 2008-06-09 19:47+0800\n"
7
+ "Last-Translator: Lester Chan <lesterchan@gmail.com>\n"
8
+ "Language-Team: Lester Chan <lesterchan@gmail.com>\n"
9
  "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
  "X-Poedit-Language: English\n"
13
  "X-Poedit-Country: SINGAPORE\n"
15
  "X-Poedit-Basepath: .\n"
16
  "X-Poedit-SearchPath-0: .\n"
17
 
 
 
 
 
 
18
  #: postviews-options.php:40
19
+ #: postviews-options.php:132
 
20
  msgid "Post Views Options"
21
  msgstr ""
22
 
28
  msgid "No Post Views Option Updated"
29
  msgstr ""
30
 
31
+ #: postviews-options.php:57
32
+ #: postviews-options.php:232
33
  msgid "UNINSTALL WP-PostViews"
34
  msgstr ""
35
 
36
+ #: postviews-options.php:65
37
  #, php-format
38
  msgid "Setting Key '%s' has been deleted."
39
  msgstr ""
40
 
41
+ #: postviews-options.php:69
42
  #, php-format
43
  msgid "Error deleting Setting Key '%s'."
44
  msgstr ""
45
 
46
+ #: postviews-options.php:79
47
  #, php-format
48
  msgid "Post Meta Key '%s' has been deleted."
49
  msgstr ""
50
 
51
+ #: postviews-options.php:83
52
  #, php-format
53
  msgid "Error deleting Post Meta Key '%s'."
54
  msgstr ""
55
 
56
+ #: postviews-options.php:105
57
+ #: postviews-options.php:190
58
  msgid "Uninstall WP-PostViews"
59
  msgstr ""
60
 
61
+ #: postviews-options.php:106
62
  #, php-format
63
  msgid "<a href=\"%s\">Click Here</a> To Finish The Uninstallation And WP-PostViews Will Be Deactivated Automatically."
64
  msgstr ""
65
 
66
+ #: postviews-options.php:119
67
+ #: wp-postviews.php:379
68
  msgid "%VIEW_COUNT% views"
69
  msgstr ""
70
 
71
+ #: postviews-options.php:122
72
+ #: wp-postviews.php:147
73
+ #: wp-postviews.php:196
74
+ #: wp-postviews.php:380
75
+ msgid "views"
76
+ msgstr ""
77
+
78
+ #: postviews-options.php:135
79
  msgid "Count Views From:"
80
  msgstr ""
81
 
82
+ #: postviews-options.php:138
83
  msgid "Everyone"
84
  msgstr ""
85
 
86
+ #: postviews-options.php:139
87
  msgid "Guests Only"
88
  msgstr ""
89
 
90
+ #: postviews-options.php:140
91
  msgid "Registered Users Only"
92
  msgstr ""
93
 
94
+ #: postviews-options.php:145
95
+ msgid "Exclude Bot Views:"
96
  msgstr ""
97
 
98
+ #: postviews-options.php:148
99
+ msgid "No"
100
  msgstr ""
101
 
102
+ #: postviews-options.php:149
103
+ #: postviews-options.php:231
104
+ msgid "Yes"
105
+ msgstr ""
106
+
107
+ #: postviews-options.php:155
108
+ msgid "Views Template:"
109
+ msgstr ""
110
+
111
+ #: postviews-options.php:156
112
+ #: postviews-options.php:167
113
+ msgid "Allowed Variables:"
114
  msgstr ""
115
 
116
+ #: postviews-options.php:158
117
+ #: postviews-options.php:173
118
  msgid "Restore Default Template"
119
  msgstr ""
120
 
121
+ #: postviews-options.php:166
122
+ msgid "Most Viewed Template:"
123
+ msgstr ""
124
+
125
+ #: postviews-options.php:181
126
+ msgid "Save Changes"
127
  msgstr ""
128
 
129
+ #: postviews-options.php:192
130
  msgid "Deactivating WP-PostViews plugin does not remove any data that may have been created, such as the views data. To completely remove this plugin, you can uninstall it here."
131
  msgstr ""
132
 
133
+ #: postviews-options.php:195
134
  msgid "WARNING:"
135
  msgstr ""
136
 
137
+ #: postviews-options.php:196
138
  msgid "Once uninstalled, this cannot be undone. You should use a Database Backup plugin of WordPress to back up all the data first."
139
  msgstr ""
140
 
141
+ #: postviews-options.php:199
142
  msgid "The following WordPress Options/PostMetas will be DELETED:"
143
  msgstr ""
144
 
145
+ #: postviews-options.php:204
146
  msgid "WordPress Options"
147
  msgstr ""
148
 
149
+ #: postviews-options.php:205
150
  msgid "WordPress PostMetas"
151
  msgstr ""
152
 
153
+ #: postviews-options.php:232
 
 
 
 
154
  msgid ""
155
  "You Are About To Uninstall WP-PostViews From WordPress.\\n"
156
  "This Action Is Not Reversible.\\n"
158
  " Choose [Cancel] To Stop, [OK] To Uninstall."
159
  msgstr ""
160
 
161
+ #: wp-postviews-widget.php:55
162
  msgid "Most Viewed"
163
  msgstr ""
164
 
165
+ #: wp-postviews-widget.php:65
166
  msgid "Title"
167
  msgstr ""
168
 
169
+ #: wp-postviews-widget.php:68
170
  msgid "Show Views For: "
171
  msgstr ""
172
 
173
+ #: wp-postviews-widget.php:74
174
  msgid "Post &amp Page"
175
  msgstr ""
176
 
177
+ #: wp-postviews-widget.php:79
178
  msgid "Post"
179
  msgstr ""
180
 
181
+ #: wp-postviews-widget.php:84
182
  msgid "Page"
183
  msgstr ""
184
 
185
+ #: wp-postviews-widget.php:87
186
  msgid "Only"
187
  msgstr ""
188
 
189
+ #: wp-postviews-widget.php:90
190
  msgid "Limit"
191
  msgstr ""
192
 
193
+ #: wp-postviews-widget.php:93
194
  msgid "Post Title Length (Characters)"
195
  msgstr ""
196
 
197
+ #: wp-postviews-widget.php:95
198
  msgid "(<strong>0</strong> to disable)"
199
  msgstr ""
200
 
201
+ #: wp-postviews.php:48
202
  msgid "Post Views"
203
  msgstr ""
204
 
205
+ #: wp-postviews.php:159
206
+ #: wp-postviews.php:208
207
+ msgid "N/A"
 
 
 
 
208
  msgstr ""
209
 
210
+ #: wp-postviews.php:250
211
+ msgid "There is no excerpt because this is a protected post."
 
 
 
212
  msgstr ""
213
 
214
+ #: wp-postviews.php:309
215
+ #: wp-postviews.php:311
216
+ #: wp-postviews.php:334
217
  msgid "WP-PostViews"
218
  msgstr ""
219
 
220
+ #: wp-postviews.php:322
221
+ #: wp-postviews.php:324
222
  msgid "Most Viewed Posts"
223
  msgstr ""
224
 
225
+ #: wp-postviews.php:336
226
  msgid "views were generated."
227
  msgstr ""
228
 
229
+ #: wp-postviews.php:348
230
  msgid "Most Viewed Post"
231
  msgstr ""
232