Count per Day - Version 3.2.2

Version Description

  • New: counter column in custom post lists
  • Bugfix: errors in search words
  • Bugfix: wrong counts in posts lists
Download this release

Release Info

Developer Tom Braider
Plugin Icon 128x128 Count per Day
Version 3.2.2
Comparing to
See all releases

Code changes from version 3.2.1 to 3.2.2

Files changed (3) hide show
  1. counter-core.php +35 -11
  2. counter.php +18 -12
  3. readme.txt +8 -3
counter-core.php CHANGED
@@ -83,15 +83,25 @@ function init()
83
add_filter('screen_layout_columns', array(&$this,'screenLayoutColumns'), 10, 2);
84
// CpD dashboard
85
add_action('admin_menu', array(&$this,'setAdminMenu'));
86
- // column page list
87
- add_action('manage_pages_custom_column', array(&$this,'cpdColumnContent'), 10, 2);
88
- add_filter('manage_edit-page_columns', array(&$this,'cpdColumn'));
89
- // column post list
90
- add_action('manage_posts_custom_column', array(&$this,'cpdColumnContent'), 10, 2);
91
- // add_filter('manage_posts_columns', array(&$this,'cpdColumn'));
92
- add_filter('manage_edit-post_columns', array(&$this,'cpdColumn'));
93
- // add_filter('manage_edit-post_sortable_columns', array(&$this,'cpdSortableColumns'));
94
- // add_filter('request', array(&$this,'cpdReadsOrderby'));
95
96
// adds javascript
97
add_action('admin_head', array(&$this,'addJS'));
@@ -143,6 +153,20 @@ function init()
143
$this->ntoa = 'INET_NTOA';
144
}
145
146
function addJquery()
147
{
148
wp_enqueue_script('jquery');
@@ -705,8 +729,8 @@ function cpdColumnContent($column_name, $id = 0)
705
{
706
$c = $this->mysqlQuery('count', "SELECT 1 FROM $wpdb->cpd_counter WHERE page='$id'", 'cpdColumn_'.$id.'_'.__LINE__);
707
$coll = get_option('count_per_day_posts');
708
- if ( $coll && isset($coll['p-'.$id]) )
709
- $c += $coll['p-'.$id];
710
echo $c;
711
}
712
}
83
add_filter('screen_layout_columns', array(&$this,'screenLayoutColumns'), 10, 2);
84
// CpD dashboard
85
add_action('admin_menu', array(&$this,'setAdminMenu'));
86
+ // counter column posts lists
87
+ add_action('admin_head', array(&$this,'addPostTypesColumns'));
88
+
89
+ // column page list
90
+ // add_action('manage_pages_custom_column', array(&$this,'cpdColumnContent'), 10, 2);
91
+ // add_filter('manage_edit-page_columns', array(&$this,'cpdColumn'));
92
+
93
+ // add_action('manage_posts_custom_column', array(&$this,'cpdColumnContent'), 10, 2);
94
+
95
+ // add_filter('manage_posts_columns', array(&$this,'cpdColumn'));
96
+
97
+ // add_filter('manage_edit-post_columns', array(&$this,'cpdColumn'));
98
+
99
+ // add_filter('manage_edit-post_sortable_columns', array(&$this,'cpdSortableColumns'));
100
+ // add_filter('request', array(&$this,'cpdReadsOrderby'));
101
+
102
+
103
+
104
+
105
106
// adds javascript
107
add_action('admin_head', array(&$this,'addJS'));
153
$this->ntoa = 'INET_NTOA';
154
}
155
156
+ /**
157
+ * adds counter columns to posts list
158
+ */
159
+ function addPostTypesColumns()
160
+ {
161
+ $post_types = get_post_types(array('public'=>true),'objects');
162
+ foreach ($post_types as $post_type )
163
+ {
164
+ $name = trim($post_type->name);
165
+ add_action('manage_'.trim($name).'s_custom_column', array(&$this,'cpdColumnContent'), 10, 2);
166
+ add_filter('manage_edit-'.trim($name).'_columns', array(&$this,'cpdColumn'));
167
+ }
168
+ }
169
+
170
function addJquery()
171
{
172
wp_enqueue_script('jquery');
729
{
730
$c = $this->mysqlQuery('count', "SELECT 1 FROM $wpdb->cpd_counter WHERE page='$id'", 'cpdColumn_'.$id.'_'.__LINE__);
731
$coll = get_option('count_per_day_posts');
732
+ if ( $coll && isset($coll['p'.$id]) )
733
+ $c += $coll['p'.$id];
734
echo $c;
735
}
736
}
counter.php CHANGED
@@ -3,14 +3,14 @@
3
Plugin Name: Count Per Day
4
Plugin URI: http://www.tomsdimension.de/wp-plugins/count-per-day
5
Description: Counter, shows reads and visitors per page; today, yesterday, last week, last months ... on dashboard, per shortcode or in widget.
6
- Version: 3.2.1
7
License: Postcardware
8
Author: Tom Braider
9
Author URI: http://www.tomsdimension.de
10
*/
11
12
$cpd_dir_name = 'count-per-day';
13
- $cpd_version = '3.2.1';
14
15
$cpd_path = str_replace('/', DIRECTORY_SEPARATOR, ABSPATH.PLUGINDIR.'/'.$cpd_dir_name.'/');
16
include_once($cpd_path.'counter-core.php');
@@ -87,6 +87,8 @@ function count( $x, $page = 'x' )
87
else if (current_user_can('subscriber')) $userlevel = 0;
88
else $userlevel = -1;
89
90
// count visitor?
91
$countUser = 1;
92
if (!$this->options['user'] && is_user_logged_in() ) $countUser = 0; // don't count loged user
@@ -118,7 +120,6 @@ function count( $x, $page = 'x' )
118
$referer = ($this->options['referers'] && isset($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : '';
119
if ($this->options['referers_cut'])
120
$referer = substr( $referer, 0, strpos($referer,'?') );
121
- $date = date_i18n('Y-m-d');
122
123
// new visitor on page?
124
$count = $this->mysqlQuery('var', $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->cpd_counter WHERE ip=$this->aton(%s) AND date=%s AND page=%d", $userip, $date, $page), 'count check '.__LINE__);
@@ -148,7 +149,10 @@ function count( $x, $page = 'x' )
148
$s = $this->getSearchString();
149
if ($s)
150
{
151
- $search = (array) get_option('count_per_day_search');
152
if (isset($search[$date]) && is_array($search[$date]))
153
{
154
if (!in_array($s, $search[$date]))
@@ -1077,13 +1081,14 @@ function getSearches( $limit = 0, $days = 0, $return = false )
1077
$c = array();
1078
foreach ( $search as $day => $strings )
1079
{
1080
- foreach ( $strings as $s )
1081
- {
1082
- if (isset($c[$s]))
1083
- $c[$s]++;
1084
- else
1085
- $c[$s] = 1;
1086
- }
1087
}
1088
arsort($c);
1089
$c = array_slice($c, 0, $limit);
@@ -1099,7 +1104,8 @@ function getSearches( $limit = 0, $days = 0, $return = false )
1099
$r .= '<small>'.sprintf(__('The search strings of the last %s days:', 'cpd'), $days).'</small>';
1100
$r .= '<ul class="cpd_front_list">';
1101
foreach ( $search as $day => $s )
1102
- $r .= '<li><div style="font-weight:bold">'.$day.'</div> '.implode(', ', $s).'</li>'."\n";
1103
$r .= '</ul>';
1104
if ($return) return $r; else echo $r;
1105
}
3
Plugin Name: Count Per Day
4
Plugin URI: http://www.tomsdimension.de/wp-plugins/count-per-day
5
Description: Counter, shows reads and visitors per page; today, yesterday, last week, last months ... on dashboard, per shortcode or in widget.
6
+ Version: 3.2.2
7
License: Postcardware
8
Author: Tom Braider
9
Author URI: http://www.tomsdimension.de
10
*/
11
12
$cpd_dir_name = 'count-per-day';
13
+ $cpd_version = '3.2.2';
14
15
$cpd_path = str_replace('/', DIRECTORY_SEPARATOR, ABSPATH.PLUGINDIR.'/'.$cpd_dir_name.'/');
16
include_once($cpd_path.'counter-core.php');
87
else if (current_user_can('subscriber')) $userlevel = 0;
88
else $userlevel = -1;
89
90
+ $date = date_i18n('Y-m-d');
91
+
92
// count visitor?
93
$countUser = 1;
94
if (!$this->options['user'] && is_user_logged_in() ) $countUser = 0; // don't count loged user
120
$referer = ($this->options['referers'] && isset($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : '';
121
if ($this->options['referers_cut'])
122
$referer = substr( $referer, 0, strpos($referer,'?') );
123
124
// new visitor on page?
125
$count = $this->mysqlQuery('var', $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->cpd_counter WHERE ip=$this->aton(%s) AND date=%s AND page=%d", $userip, $date, $page), 'count check '.__LINE__);
149
$s = $this->getSearchString();
150
if ($s)
151
{
152
+ $search = get_option('count_per_day_search');
153
+ // reset if array is corrupt
154
+ if (!is_array($search))
155
+ $search = array($date=>'');
156
if (isset($search[$date]) && is_array($search[$date]))
157
{
158
if (!in_array($s, $search[$date]))
1081
$c = array();
1082
foreach ( $search as $day => $strings )
1083
{
1084
+ if (is_array($strings))
1085
+ foreach ( $strings as $s )
1086
+ {
1087
+ if (isset($c[$s]))
1088
+ $c[$s]++;
1089
+ else
1090
+ $c[$s] = 1;
1091
+ }
1092
}
1093
arsort($c);
1094
$c = array_slice($c, 0, $limit);
1104
$r .= '<small>'.sprintf(__('The search strings of the last %s days:', 'cpd'), $days).'</small>';
1105
$r .= '<ul class="cpd_front_list">';
1106
foreach ( $search as $day => $s )
1107
+ if (is_array($s))
1108
+ $r .= '<li><div style="font-weight:bold">'.$day.'</div> '.implode(', ', $s).'</li>'."\n";
1109
$r .= '</ul>';
1110
if ($return) return $r; else echo $r;
1111
}
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: Tom Braider
3
Tags: counter, count, posts, visits, reads, dashboard, widget, shortcode
4
Requires at least: 3.0
5
Tested up to: 3.4.1
6
- Stable tag: 3.2.1
7
License: Postcardware :)
8
Donate link: http://www.tomsdimension.de/postcards
9
@@ -82,7 +82,7 @@ read and write comments on http://www.tomsdimension.de/wp-plugins/count-per-day
82
83
You can use these shortcodes in the content of your posts to show a number or list
84
or in your theme files while adding e.g. '&lt;?php echo do_shortcode("[THE_SHORTCODE]"); ?>'.
85
- To use the shortcodes within a textwidget you have to add 'add_filter("widget_text", "do_shortcode");' to the 'functions.php' of your theme.
86
87
[CPD_READS_THIS]
88
[CPD_READS_TOTAL]
@@ -292,10 +292,15 @@ to check if plugin is activated.
292
293
== Changelog ==
294
295
= 3.2.1 =
296
+ Bugfix: massbot delete error
297
+ Bugfix: search words array sometimes corrupt
298
- + Bugfix: add collected data to reads per post, thanks to http://is.gd/VWNyLq http://yumeneko.pmfan.jp
299
+ Language update: Japanese, thanks to Juno Hayami
300
+ Language update: Portuguese, thanks to Beto Ribeiro
301
+ Language update: Russian, thanks to Ilya Pshenichny
3
Tags: counter, count, posts, visits, reads, dashboard, widget, shortcode
4
Requires at least: 3.0
5
Tested up to: 3.4.1
6
+ Stable tag: 3.2.2
7
License: Postcardware :)
8
Donate link: http://www.tomsdimension.de/postcards
9
82
83
You can use these shortcodes in the content of your posts to show a number or list
84
or in your theme files while adding e.g. '&lt;?php echo do_shortcode("[THE_SHORTCODE]"); ?>'.
85
+ To use the shortcodes within a text widget you have to add 'add_filter("widget_text", "do_shortcode");' to the 'functions.php' of your theme.
86
87
[CPD_READS_THIS]
88
[CPD_READS_TOTAL]
292
293
== Changelog ==
294
295
+ = 3.2.2 =
296
+ + New: counter column in custom post lists
297
+ + Bugfix: errors in search words
298
+ + Bugfix: wrong counts in posts lists
299
+
300
= 3.2.1 =
301
+ Bugfix: massbot delete error
302
+ Bugfix: search words array sometimes corrupt
303
+ + Bugfix: add collected data to reads per post, thanks to Suzakura Karin http://yumeneko.pmfan.jp / http://is.gd/VWNyLq
304
+ Language update: Japanese, thanks to Juno Hayami
305
+ Language update: Portuguese, thanks to Beto Ribeiro
306
+ Language update: Russian, thanks to Ilya Pshenichny