Top 10 – Popular posts plugin for WordPress - Version 1.9.8.1

Version Description

New: Custom post support, options to exclude posts by ID, add nofollow attribute to links, open links in new window, change in thumbnail width and height settings. Check the Changelog for more information

=

Download this release

Release Info

Developer Ajay
Plugin Icon 128x128 Top 10 – Popular posts plugin for WordPress
Version 1.9.8.1
Comparing to
See all releases

Code changes from version 1.9.8 to 1.9.8.1

Files changed (3) hide show
  1. admin.inc.php +36 -8
  2. readme.txt +4 -1
  3. top-10.php +2 -2
admin.inc.php CHANGED
@@ -516,7 +516,6 @@ function tptn_manage($daily = 0) {
516
 
517
  $paged = (isset($_GET['paged']) ? intval($_GET['paged']) : 0);
518
  $limit = (isset($_GET['limit']) ? intval($_GET['limit']) : 0);
519
- $exclude_pages = (isset($_GET['exclude_pages']) ? intval($_GET['exclude_pages']) : 0);
520
  $daily = (isset($_GET['daily']) ? intval($_GET['daily']) : $daily);
521
 
522
  ?>
@@ -532,7 +531,7 @@ function tptn_manage($daily = 0) {
532
  </div>
533
 
534
  <div id="options-div">
535
- <?php echo tptn_pop_display($daily,$paged,$limit,false,$exclude_pages); ?>
536
  </div> <!-- End options-div -->
537
 
538
  </div> <!-- End inside -->
@@ -673,10 +672,9 @@ function tptn_clean_duplicates($daily = false) {
673
  * @param int $page (default: 0) Which page of the lists are we on?
674
  * @param int $limit (default: 10) Maximum number of posts per page
675
  * @param bool $widget (default: false) Is this a WordPress widget?
676
- * @param int $exclude_pages (default: 0) Include / exclude pages
677
  * @return void
678
  */
679
- function tptn_pop_display($daily = false, $page = 0, $limit = 10, $widget = false, $exclude_pages = 0) {
680
  global $wpdb, $siteurl, $tableposts, $id;
681
 
682
  $table_name = $wpdb->prefix . "top_ten";
@@ -685,12 +683,21 @@ function tptn_pop_display($daily = false, $page = 0, $limit = 10, $widget = fals
685
  $tptn_settings = tptn_read_options();
686
  if (!($limit)) $limit = $tptn_settings['limit'];
687
  if (!($page)) $page = 0; // Default page value.
 
 
688
 
689
  if(!$daily) {
690
  $sql = "SELECT postnumber, cntaccess as sumCount, ID, post_type ";
691
  $sql .= "FROM $table_name INNER JOIN ". $wpdb->posts ." ON postnumber=ID " ;
692
- if ($exclude_pages) $sql .= "AND post_type = 'post' ";
693
  $sql .= "AND post_status = 'publish' ";
 
 
 
 
 
 
 
 
694
  $sql .= "ORDER BY sumCount DESC";
695
  } else {
696
  $daily_range = $tptn_settings['daily_range']-1;
@@ -700,8 +707,15 @@ function tptn_pop_display($daily = false, $page = 0, $limit = 10, $widget = fals
700
 
701
  $sql = "SELECT postnumber, SUM(cntaccess) as sumCount, dp_date, ID, post_type, post_status ";
702
  $sql .= "FROM $table_name INNER JOIN ". $wpdb->posts ." ON postnumber=ID " ;
703
- if ($exclude_pages) $sql .= "AND post_type = 'post' ";
704
  $sql .= "AND post_status = 'publish' AND dp_date >= '$current_date' ";
 
 
 
 
 
 
 
 
705
  $sql .= "GROUP BY postnumber ";
706
  $sql .= "ORDER BY sumCount DESC";
707
  }
@@ -733,14 +747,28 @@ function tptn_pop_display($daily = false, $page = 0, $limit = 10, $widget = fals
733
  if(!$daily) {
734
  $sql = "SELECT postnumber, cntaccess as sumCount, ID, post_type ";
735
  $sql .= "FROM $table_name INNER JOIN ". $wpdb->posts ." ON postnumber=ID " ;
736
- if ($exclude_pages) $sql .= "AND post_type = 'post' ";
737
  $sql .= "AND post_status = 'publish' ";
 
 
 
 
 
 
 
 
738
  $sql .= "ORDER BY sumCount DESC LIMIT $page, $limit";
739
  } else {
740
  $sql = "SELECT postnumber, SUM(cntaccess) as sumCount, dp_date, ID, post_type, post_status ";
741
  $sql .= "FROM $table_name INNER JOIN ". $wpdb->posts ." ON postnumber=ID " ;
742
- if ($exclude_pages) $sql .= "AND post_type = 'post' ";
743
  $sql .= "AND post_status = 'publish' AND dp_date >= '$current_date' ";
 
 
 
 
 
 
 
 
744
  $sql .= "GROUP BY postnumber ";
745
  $sql .= "ORDER BY sumCount DESC LIMIT $page, $limit";
746
  }
516
 
517
  $paged = (isset($_GET['paged']) ? intval($_GET['paged']) : 0);
518
  $limit = (isset($_GET['limit']) ? intval($_GET['limit']) : 0);
 
519
  $daily = (isset($_GET['daily']) ? intval($_GET['daily']) : $daily);
520
 
521
  ?>
531
  </div>
532
 
533
  <div id="options-div">
534
+ <?php echo tptn_pop_display($daily,$paged,$limit,false); ?>
535
  </div> <!-- End options-div -->
536
 
537
  </div> <!-- End inside -->
672
  * @param int $page (default: 0) Which page of the lists are we on?
673
  * @param int $limit (default: 10) Maximum number of posts per page
674
  * @param bool $widget (default: false) Is this a WordPress widget?
 
675
  * @return void
676
  */
677
+ function tptn_pop_display($daily = false, $page = 0, $limit = 10, $widget = false) {
678
  global $wpdb, $siteurl, $tableposts, $id;
679
 
680
  $table_name = $wpdb->prefix . "top_ten";
683
  $tptn_settings = tptn_read_options();
684
  if (!($limit)) $limit = $tptn_settings['limit'];
685
  if (!($page)) $page = 0; // Default page value.
686
+ parse_str($tptn_settings['post_types'],$post_types); // Save post types in $post_types variable
687
+
688
 
689
  if(!$daily) {
690
  $sql = "SELECT postnumber, cntaccess as sumCount, ID, post_type ";
691
  $sql .= "FROM $table_name INNER JOIN ". $wpdb->posts ." ON postnumber=ID " ;
 
692
  $sql .= "AND post_status = 'publish' ";
693
+ $sql .= "AND ( ";
694
+ $multiple = false;
695
+ foreach ($post_types as $post_type) {
696
+ if ( $multiple ) $sql .= ' OR ';
697
+ $sql .= " post_type = '".$post_type."' ";
698
+ $multiple = true;
699
+ }
700
+ $sql .=" ) ";
701
  $sql .= "ORDER BY sumCount DESC";
702
  } else {
703
  $daily_range = $tptn_settings['daily_range']-1;
707
 
708
  $sql = "SELECT postnumber, SUM(cntaccess) as sumCount, dp_date, ID, post_type, post_status ";
709
  $sql .= "FROM $table_name INNER JOIN ". $wpdb->posts ." ON postnumber=ID " ;
 
710
  $sql .= "AND post_status = 'publish' AND dp_date >= '$current_date' ";
711
+ $sql .= "AND ( ";
712
+ $multiple = false;
713
+ foreach ($post_types as $post_type) {
714
+ if ( $multiple ) $sql .= ' OR ';
715
+ $sql .= " post_type = '".$post_type."' ";
716
+ $multiple = true;
717
+ }
718
+ $sql .=" ) ";
719
  $sql .= "GROUP BY postnumber ";
720
  $sql .= "ORDER BY sumCount DESC";
721
  }
747
  if(!$daily) {
748
  $sql = "SELECT postnumber, cntaccess as sumCount, ID, post_type ";
749
  $sql .= "FROM $table_name INNER JOIN ". $wpdb->posts ." ON postnumber=ID " ;
 
750
  $sql .= "AND post_status = 'publish' ";
751
+ $sql .= "AND ( ";
752
+ $multiple = false;
753
+ foreach ($post_types as $post_type) {
754
+ if ( $multiple ) $sql .= ' OR ';
755
+ $sql .= " post_type = '".$post_type."' ";
756
+ $multiple = true;
757
+ }
758
+ $sql .=" ) ";
759
  $sql .= "ORDER BY sumCount DESC LIMIT $page, $limit";
760
  } else {
761
  $sql = "SELECT postnumber, SUM(cntaccess) as sumCount, dp_date, ID, post_type, post_status ";
762
  $sql .= "FROM $table_name INNER JOIN ". $wpdb->posts ." ON postnumber=ID " ;
 
763
  $sql .= "AND post_status = 'publish' AND dp_date >= '$current_date' ";
764
+ $sql .= "AND ( ";
765
+ $multiple = false;
766
+ foreach ($post_types as $post_type) {
767
+ if ( $multiple ) $sql .= ' OR ';
768
+ $sql .= " post_type = '".$post_type."' ";
769
+ $multiple = true;
770
+ }
771
+ $sql .=" ) ";
772
  $sql .= "GROUP BY postnumber ";
773
  $sql .= "ORDER BY sumCount DESC LIMIT $page, $limit";
774
  }
readme.txt CHANGED
@@ -45,13 +45,16 @@ Includes a sidebar widget to display the popular posts. And, all settings can be
45
 
46
  == Upgrade Notice ==
47
 
48
- = 1.9.8 =
49
  New: Custom post support, options to exclude posts by ID, add nofollow attribute to links, open links in new window, change in thumbnail width and height settings.
50
  Check the Changelog for more information
51
 
52
 
53
  == Changelog ==
54
 
 
 
 
55
  = 1.9.8 =
56
  * New: Custom post support. Choose which custom post types to display in the top posts
57
  * New: More display options. Select which archives you want to display the post count
45
 
46
  == Upgrade Notice ==
47
 
48
+ = 1.9.8.1 =
49
  New: Custom post support, options to exclude posts by ID, add nofollow attribute to links, open links in new window, change in thumbnail width and height settings.
50
  Check the Changelog for more information
51
 
52
 
53
  == Changelog ==
54
 
55
+ = 1.9.8.1 =
56
+ * Fixed: Correct numbers of posts were not being fetched
57
+
58
  = 1.9.8 =
59
  * New: Custom post support. Choose which custom post types to display in the top posts
60
  * New: More display options. Select which archives you want to display the post count
top-10.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Top 10
4
- Version: 1.9.8
5
  Plugin URI: http://ajaydsouza.com/wordpress/plugins/top-10/
6
  Description: Count daily and total visits per post and display the most popular posts based on the number of views. Based on the plugin by <a href="http://weblogtoolscollection.com">Mark Ghosh</a>
7
  Author: Ajay D'Souza
@@ -286,7 +286,7 @@ function get_tptn_pop_posts( $daily = false , $widget = false, $limit = false, $
286
  global $tptn_settings;
287
 
288
  if (empty($limit)) $limit = stripslashes($tptn_settings['limit']);
289
- $limit = ($strict_limit) ? $limit : ($limit*3);
290
 
291
  $show_excerpt = empty($show_excerpt) ? $tptn_settings['show_excerpt'] : $show_excerpt;
292
  $post_thumb_op = empty($post_thumb_op) ? $tptn_settings['post_thumb_op'] : $post_thumb_op;
1
  <?php
2
  /*
3
  Plugin Name: Top 10
4
+ Version: 1.9.8.1
5
  Plugin URI: http://ajaydsouza.com/wordpress/plugins/top-10/
6
  Description: Count daily and total visits per post and display the most popular posts based on the number of views. Based on the plugin by <a href="http://weblogtoolscollection.com">Mark Ghosh</a>
7
  Author: Ajay D'Souza
286
  global $tptn_settings;
287
 
288
  if (empty($limit)) $limit = stripslashes($tptn_settings['limit']);
289
+ $limit = ($strict_limit) ? $limit : ($limit*5);
290
 
291
  $show_excerpt = empty($show_excerpt) ? $tptn_settings['show_excerpt'] : $show_excerpt;
292
  $post_thumb_op = empty($post_thumb_op) ? $tptn_settings['post_thumb_op'] : $post_thumb_op;