kk Star Ratings - Version 1.4

Version Description

  • Added: ability to retrieve top rated posts in the template/theme.

=

Download this release

Release Info

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

Code changes from version 1.3.1 to 1.4

Files changed (3) hide show
  1. admin/options.php +31 -6
  2. kk-ratings.php +14 -2
  3. readme.txt +4 -1
admin/options.php CHANGED
@@ -12,12 +12,22 @@
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 class="widefat" style="width:600px;">
 
 
 
 
 
 
 
 
 
 
16
  <thead>
17
     <tr>
18
-      <th>#</th>
19
- <th>Label</th>
20
- <th>Value</th>
21
  </tr>
22
  </thead>
23
  <tfoot>
@@ -51,10 +61,25 @@
51
  <strong>NOTE</strong> : For manual, please use shortcode <span style="color:#06F;">[kkratings]</span>
52
  <br />in any post or page you need the ratings.
53
  <br /><br />
54
- For use in theme files:
55
  <br /> <span style="color:#F60;">&lt;?php if(function_exists('kk_star_ratings')) : echo kk_star_ratings($pid); endif; ?&gt;</span>
56
  <br />Where $pid is the post of the id
57
- <br />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  </p>
59
  </td>
60
  </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
+ <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>
28
+      <th width="8">#</th>
29
+ <th width="69">Label</th>
30
+ <th width="604">Value</th>
31
  </tr>
32
  </thead>
33
  <tfoot>
61
  <strong>NOTE</strong> : For manual, please use shortcode <span style="color:#06F;">[kkratings]</span>
62
  <br />in any post or page you need the ratings.
63
  <br /><br />
64
+ <strong>For use in theme files:</strong>
65
  <br /> <span style="color:#F60;">&lt;?php if(function_exists('kk_star_ratings')) : echo kk_star_ratings($pid); endif; ?&gt;</span>
66
  <br />Where $pid is the post of the id
67
+ <br /><br />
68
+ <strong>Get top rated posts as array of objects:</strong>
69
+ <br /> <span style="color:#F60;">&lt;?php if(function_exists('kk_star_ratings_get')) : $top_rated_posts = kk_star_ratings_get($total); endif; ?&gt;</span>
70
+ <br />Where $total is the limit (int)
71
+ <br />$top_rated_posts will contain an array of objects, each containing an ID and ratings.
72
+ <br />
73
+ <strong>Example Usage:</strong>
74
+ <pre>
75
+ foreach($top_rated_posts as $post)
76
+ {
77
+ // you get $post->ID and $post->ratings
78
+ // Do anything with it like get_post($post->ID)
79
+ // ...
80
+ }
81
+ </pre>
82
+ <br />
83
  </p>
84
  </td>
85
  </tr>
kk-ratings.php CHANGED
@@ -4,14 +4,14 @@
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.3.1
8
  Author: Kamal Khan
9
  Author URI: http://bhittani.com
10
  License: GPLv2 or later
11
  */
12
 
13
  // Make sure class does not already exist (Playing safe).
14
- if(!class_exists('kk_Ratings') && !isset($kkratings) && !function_exists('kk_star_ratings')) :
15
 
16
  // Declare and define the plugin class.
17
  class kk_Ratings
@@ -294,6 +294,13 @@ if(!class_exists('kk_Ratings') && !isset($kkratings) && !function_exists('kk_sta
294
  return $this->markup($pid);
295
  return '';
296
  }
 
 
 
 
 
 
 
297
  }
298
 
299
  // Instantiate the plugin
@@ -312,6 +319,11 @@ if(!class_exists('kk_Ratings') && !isset($kkratings) && !function_exists('kk_sta
312
  global $kkratings;
313
  return $kkratings->kk_star_rating($pid);
314
  }
 
 
 
 
 
315
 
316
  require_once('widget.php');
317
 
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
11
  */
12
 
13
  // Make sure class does not already exist (Playing safe).
14
+ if(!class_exists('kk_Ratings') && !isset($kkratings) && !function_exists('kk_star_ratings') && !function_exists('kk_star_ratings_get')) :
15
 
16
  // Declare and define the plugin class.
17
  class kk_Ratings
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
 
306
  // Instantiate the plugin
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');
329
 
readme.txt CHANGED
@@ -11,7 +11,7 @@ Requires at least: 3.0
11
 
12
  Tested up to: 3.2.1
13
 
14
- Stable tag: 1.3.1
15
 
16
 
17
  kk Star Ratings allows blog visitors to involve and interact more effectively with your website by rating posts.
@@ -98,5 +98,8 @@ First of all make sure you have selected where to display the ratings in the set
98
  = 1.3.1 =
99
  * Fixed: flushing/removing of ratings for widget included. Thanks to feedback from glyn.
100
 
 
 
 
101
 
102
  == Upgrade Notice ==
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.
98
  = 1.3.1 =
99
  * Fixed: flushing/removing of ratings for widget included. Thanks to feedback from glyn.
100
 
101
+ = 1.4 =
102
+ * Added: ability to retrieve top rated posts in the template/theme.
103
+
104
 
105
  == Upgrade Notice ==