kk Star Ratings - Version 1.5

Version Description

  • Fixed: Some users complained about a fault: "An error occured" being displayed when someone rates a post. This was due to the charset of the returned response via ajax (Mentioned by jamk). Has been fixed as the ajax response is now retrieved as an xml dom instead of plain text.
  • Fixed: Regardless of unique voting set or not, a user could click on a star multiple times simultaneously and the post would be rated that much time. Has been fixed.
  • Added: Filter by category in the widget as well as the custom template tag/function.

=

Download this release

Release Info

Developer bhittani
Plugin Icon 128x128 kk Star Ratings
Version 1.5
Comparing to
See all releases

Code changes from version 1.4 to 1.5

Files changed (4) hide show
  1. admin/options.php +0 -10
  2. kk-ratings.php +15 -6
  3. readme.txt +16 -4
  4. widget.php +18 -3
admin/options.php CHANGED
@@ -12,16 +12,6 @@
12
  <form action="options.php" method="post" id=<?php echo $this->plugin_id; ?>"_options_form" name=<?php echo $this->plugin_id; ?>"_options_form">
13
  <?php settings_fields($this->plugin_id.'_options'); ?>
14
  <h2>kk Star Ratings &raquo; Settings</h2>
15
- <p>Donations to this plugin will always be appreciated. It is a way of saying thanks!</p>
16
- <p>
17
-
18
- <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
19
- <input type="hidden" name="cmd" value="_s-xclick">
20
- <input type="hidden" name="hosted_button_id" value="EHPTKTC2TT4QC">
21
- <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
22
- <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
23
- </form>
24
- </p>
25
  <table width="697" class="widefat" style="width:600px;">
26
  <thead>
27
     <tr>
12
  <form action="options.php" method="post" id=<?php echo $this->plugin_id; ?>"_options_form" name=<?php echo $this->plugin_id; ?>"_options_form">
13
  <?php settings_fields($this->plugin_id.'_options'); ?>
14
  <h2>kk Star Ratings &raquo; Settings</h2>
 
 
 
 
 
 
 
 
 
 
15
  <table width="697" class="widefat" style="width:600px;">
16
  <thead>
17
     <tr>
kk-ratings.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin Name: kk Star Ratings
5
  Plugin URI: http://wakeusup.com/2011/05/kk-star-ratings/
6
  Description: A clean, animated and sweat ratings feature for your blog <strong>With kk Star Ratings, you can allow your blog posts to be rated by your blog visitors</strong>. <strong>It also includes a widget</strong> which you can add to your sidebar to show the top rated post. There are some useful options you can set to customize this plugin. You can do all that after installing and activating the plugin and then visiting the <a href="options-general.php?page=kk-ratings_options">Plugin Settings</a>.
7
- Version: 1.4
8
  Author: Kamal Khan
9
  Author URI: http://bhittani.com
10
  License: GPLv2 or later
@@ -294,12 +294,21 @@ if(!class_exists('kk_Ratings') && !isset($kkratings) && !function_exists('kk_sta
294
  return $this->markup($pid);
295
  return '';
296
  }
297
- public function kk_star_ratings_get($total=5)
298
  {
299
  global $wpdb;
300
  $table = $wpdb->prefix . 'postmeta';
301
- $rated_posts = $wpdb->get_results("SELECT a.ID, b.meta_value AS 'ratings' FROM " . $wpdb->posts . " a, $table b WHERE a.post_status='publish' AND a.ID=b.post_id AND b.meta_key='_kk_ratings_avg' ORDER BY b.meta_value DESC LIMIT $total");
302
- return $rated_posts;
 
 
 
 
 
 
 
 
 
303
  }
304
  }
305
 
@@ -319,10 +328,10 @@ if(!class_exists('kk_Ratings') && !isset($kkratings) && !function_exists('kk_sta
319
  global $kkratings;
320
  return $kkratings->kk_star_rating($pid);
321
  }
322
- function kk_star_ratings_get($lim=5)
323
  {
324
  global $kkratings;
325
- return $kkratings->kk_star_ratings_get($lim);
326
  }
327
 
328
  require_once('widget.php');
4
  Plugin Name: kk Star Ratings
5
  Plugin URI: http://wakeusup.com/2011/05/kk-star-ratings/
6
  Description: A clean, animated and sweat ratings feature for your blog <strong>With kk Star Ratings, you can allow your blog posts to be rated by your blog visitors</strong>. <strong>It also includes a widget</strong> which you can add to your sidebar to show the top rated post. There are some useful options you can set to customize this plugin. You can do all that after installing and activating the plugin and then visiting the <a href="options-general.php?page=kk-ratings_options">Plugin Settings</a>.
7
+ Version: 1.5
8
  Author: Kamal Khan
9
  Author URI: http://bhittani.com
10
  License: GPLv2 or later
294
  return $this->markup($pid);
295
  return '';
296
  }
297
+ public function kk_star_ratings_get($total=5, $cat=false)
298
  {
299
  global $wpdb;
300
  $table = $wpdb->prefix . 'postmeta';
301
+ if(!$cat)
302
+ $rated_posts = $wpdb->get_results("SELECT a.ID, a.post_title, b.meta_value AS 'ratings' FROM " . $wpdb->posts . " a, $table b WHERE a.post_status='publish' AND a.ID=b.post_id AND b.meta_key='_kk_ratings_avg' ORDER BY b.meta_value DESC LIMIT $total");
303
+ else
304
+ {
305
+ $table2 = $wpdb->prefix . 'term_taxonomy';
306
+ $table3 = $wpdb->prefix . 'term_relationships';
307
+ $rated_posts = $wpdb->get_results("SELECT a.ID, a.post_title, b.meta_value AS 'ratings' FROM " . $wpdb->posts . " a, $table b, $table2 c, $table3 d WHERE c.term_taxonomy_id=d.term_taxonomy_id AND c.term_id=$cat AND d.object_id=a.ID AND a.post_status='publish' AND a.ID=b.post_id AND b.meta_key='_kk_ratings_avg' ORDER BY b.meta_value DESC LIMIT $total");
308
+ }
309
+
310
+ return $rated_posts;
311
+
312
  }
313
  }
314
 
328
  global $kkratings;
329
  return $kkratings->kk_star_rating($pid);
330
  }
331
+ function kk_star_ratings_get($lim=5, $cat=false)
332
  {
333
  global $kkratings;
334
+ return $kkratings->kk_star_ratings_get($lim, $cat);
335
  }
336
 
337
  require_once('widget.php');
readme.txt CHANGED
@@ -9,9 +9,9 @@ Tags: star ratings, votings, rate posts, ajax ratings
9
 
10
  Requires at least: 3.0
11
 
12
- Tested up to: 3.2.1
13
 
14
- Stable tag: 1.4
15
 
16
 
17
  kk Star Ratings allows blog visitors to involve and interact more effectively with your website by rating posts.
@@ -29,6 +29,10 @@ It has quite cool hover fade effects and animations.
29
 
30
  Version 1.3+ also inludes a widget so you can show top rated posts in your sidebar as well.
31
 
 
 
 
 
32
  A settings page is also available where you can adjust the settings. You can:
33
 
34
 
@@ -63,11 +67,11 @@ A settings page is also available where you can adjust the settings. You can:
63
 
64
  =
65
 
66
- I have installed the plugin, but the ratings are not showing up anywhere
67
 
68
  =
69
 
70
- First of all make sure you have selected where to display the ratings in the settings page. NOTE: unfortunately, some themes are poorly developed, so keep that in mind.
71
 
72
 
73
 
@@ -101,5 +105,13 @@ First of all make sure you have selected where to display the ratings in the set
101
  = 1.4 =
102
  * Added: ability to retrieve top rated posts in the template/theme.
103
 
 
 
 
 
 
 
 
 
104
 
105
  == Upgrade Notice ==
9
 
10
  Requires at least: 3.0
11
 
12
+ Tested up to: 3.3.1
13
 
14
+ Stable tag: 1.5
15
 
16
 
17
  kk Star Ratings allows blog visitors to involve and interact more effectively with your website by rating posts.
29
 
30
  Version 1.3+ also inludes a widget so you can show top rated posts in your sidebar as well.
31
 
32
+ Now you can also filter the top rated posts widget by category
33
+
34
+ Custom template tag/function available
35
+
36
  A settings page is also available where you can adjust the settings. You can:
37
 
38
 
67
 
68
  =
69
 
70
+ Whenever I click on a star, it states "An error occured".
71
 
72
  =
73
 
74
+ This may have occured to some users with previous versions of the plugin. It has been fixed in version 1.5.
75
 
76
 
77
 
105
  = 1.4 =
106
  * Added: ability to retrieve top rated posts in the template/theme.
107
 
108
+ = 1.4.1 =
109
+ * Fixed: Settings are now able to be saved. Was not being saved in v1.4.
110
+
111
+ = 1.5 =
112
+ * Fixed: Some users complained about a fault: "An error occured" being displayed when someone rates a post. This was due to the charset of the returned response via ajax (Mentioned by jamk). Has been fixed as the ajax response is now retrieved as an xml dom instead of plain text.
113
+ * Fixed: Regardless of unique voting set or not, a user could click on a star multiple times simultaneously and the post would be rated that much time. Has been fixed.
114
+ * Added: Filter by category in the widget as well as the custom template tag/function.
115
+
116
 
117
  == Upgrade Notice ==
widget.php CHANGED
@@ -20,15 +20,14 @@ class kk_Ratings_Widget extends WP_Widget
20
  extract( $args, EXTR_SKIP );
21
  $title = ( !empty($instance['title']) ) ? $instance['title'] : 'Top Posts';
22
  $total = ( !empty($instance['noofposts']) ) ? $instance['noofposts'] : '5';
 
23
  $sr = ($instance['showrating']) ? true : false;
24
 
25
  echo $before_widget;
26
  echo $before_title . $title . $after_title;
27
 
28
  // OUTPUT starts
29
- global $wpdb;
30
- $table = $wpdb->prefix . 'postmeta';
31
- $posts = $wpdb->get_results("SELECT a.ID, a.post_title, b.meta_value AS 'ratings' FROM " . $wpdb->posts . " a, $table b WHERE a.post_status='publish' AND a.ID=b.post_id AND b.meta_key='_kk_ratings_avg' ORDER BY b.meta_value DESC LIMIT $total");
32
  echo '<ul>';
33
  foreach ($posts as $post)
34
  {
@@ -71,6 +70,22 @@ class kk_Ratings_Widget extends WP_Widget
71
  </select>
72
  </label>
73
  </p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  <?php
75
  }
76
  }
20
  extract( $args, EXTR_SKIP );
21
  $title = ( !empty($instance['title']) ) ? $instance['title'] : 'Top Posts';
22
  $total = ( !empty($instance['noofposts']) ) ? $instance['noofposts'] : '5';
23
+ $category = ( $instance['category'] ) ? $instance['category'] : false;
24
  $sr = ($instance['showrating']) ? true : false;
25
 
26
  echo $before_widget;
27
  echo $before_title . $title . $after_title;
28
 
29
  // OUTPUT starts
30
+ $posts = kk_star_ratings_get($total, $category);
 
 
31
  echo '<ul>';
32
  foreach ($posts as $post)
33
  {
70
  </select>
71
  </label>
72
  </p>
73
+ <p>
74
+ <label for="<?php echo $this->get_field_id('category'); ?>">Filter by Category:
75
+ <select id="<?php echo $this->get_field_id('category'); ?>" name="<?php echo $this->get_field_name('category'); ?>">
76
+ <option value="0">Select</option>
77
+ <?php
78
+ foreach(get_categories(array()) as $category)
79
+ {
80
+ echo '<option value="'.$category->term_id.'"';
81
+ if(esc_attr($instance['category'])==$category->term_id)
82
+ echo ' selected="selected"';
83
+ echo '>'.$category->name.'</option>';
84
+ }
85
+ ?>
86
+ </select>
87
+ </label>
88
+ </p>
89
  <?php
90
  }
91
  }