kk Star Ratings - Version 1.6

Version Description

  • Added: Now you can see a column in the admin screen of posts and pages stating the ratings of each.

=

Download this release

Release Info

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

Code changes from version 1.5 to 1.6

Files changed (3) hide show
  1. admin/options.php +19 -5
  2. kk-ratings.php +36 -4
  3. readme.txt +4 -1
admin/options.php CHANGED
@@ -11,7 +11,9 @@
11
  <?php screen_icon(); ?>
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>
@@ -28,6 +30,11 @@
28
  </tr>
29
  </tfoot>
30
  <tbody>
 
 
 
 
 
31
  <tr>
32
  <td>1</td>
33
  <td><label for="<?php echo $this->plugin_id; ?>[enable]">Enable</label></td>
@@ -56,17 +63,19 @@
56
  <br />Where $pid is the post of the id
57
  <br /><br />
58
  <strong>Get top rated posts as array of objects:</strong>
59
- <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>
60
- <br />Where $total is the limit (int)
61
- <br />$top_rated_posts will contain an array of objects, each containing an ID and ratings.
62
  <br />
63
  <strong>Example Usage:</strong>
64
  <pre>
65
  foreach($top_rated_posts as $post)
66
  {
67
- // you get $post->ID and $post->ratings
68
  // Do anything with it like get_post($post->ID)
69
  // ...
 
 
70
  }
71
  </pre>
72
  <br />
@@ -118,6 +127,11 @@
118
  <input type="checkbox" name="<?php echo $this->plugin_id; ?>[clear]" value="1" <?php echo $this->options['clear'] ? "checked='checked'" : ""; ?> />
119
  </td>
120
  </tr>
 
 
 
 
 
121
  </tbody>
122
  </table>
123
  <p><input type="submit" name="submit" value="Save Settings" class="button" /></p>
11
  <?php screen_icon(); ?>
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
15
+ <script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like send="false" layout="button_count" width="450" show_faces="true" href="http://wakeusup.com"></fb:like>
16
+ </h2>
17
  <table width="697" class="widefat" style="width:600px;">
18
  <thead>
19
     <tr>
30
  </tr>
31
  </tfoot>
32
  <tbody>
33
+ <tr>
34
+ <td></td>
35
+ <td><a href="http://wakeusup.com/2011/05/kk-star-ratings/" target="_blank" title="View Changelog">Changelog</a></td>
36
+ <td></td>
37
+ </tr>
38
  <tr>
39
  <td>1</td>
40
  <td><label for="<?php echo $this->plugin_id; ?>[enable]">Enable</label></td>
63
  <br />Where $pid is the post of the id
64
  <br /><br />
65
  <strong>Get top rated posts as array of objects:</strong>
66
+ <br /> <span style="color:#F60;">&lt;?php if(function_exists('kk_star_ratings_get')) : $top_rated_posts = kk_star_ratings_get($total,$cat_id); endif; ?&gt;</span>
67
+ <br />Where $total is the limit (int) and $cat_id is the id of the category which is optional
68
+ <br />$top_rated_posts will contain an array of objects, each containing an ID, title and ratings.
69
  <br />
70
  <strong>Example Usage:</strong>
71
  <pre>
72
  foreach($top_rated_posts as $post)
73
  {
74
+ // You get $post->ID, $post->ratings and $post->post_title
75
  // Do anything with it like get_post($post->ID)
76
  // ...
77
+ // The following will display the Post ID, Title and Ratings for each.
78
+ echo "Post ID: ".$post->ID." | Title: ".$post->post_title." | Ratings: ".$post->ratings.'&lt;br /&gt;';
79
  }
80
  </pre>
81
  <br />
127
  <input type="checkbox" name="<?php echo $this->plugin_id; ?>[clear]" value="1" <?php echo $this->options['clear'] ? "checked='checked'" : ""; ?> />
128
  </td>
129
  </tr>
130
+ <tr>
131
+ <td>8</td>
132
+ <td><label for="<?php echo $this->plugin_id; ?>[column]">Show rating column in the posts/pages admin screen</label></td>
133
+ <td><input type="checkbox" name="<?php echo $this->plugin_id; ?>[column]" value="1" <?php echo $this->options['column'] ? "checked='checked'" : ""; ?> /></td>
134
+ </tr>
135
  </tbody>
136
  </table>
137
  <p><input type="submit" name="submit" value="Save Settings" class="button" /></p>
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.5
8
  Author: Kamal Khan
9
  Author URI: http://bhittani.com
10
  License: GPLv2 or later
@@ -105,8 +105,8 @@ if(!class_exists('kk_Ratings') && !isset($kkratings) && !function_exists('kk_sta
105
  }
106
  public function activate()
107
  {
108
- $this->options['legend'] = '[avg]([per]) [total] votes'; // [total]=total ratings, [rating]=average, [per]=percentage
109
- $this->update_options();
110
  if(!count($this->options)) :
111
  $this->options['enable'] = 1; // 1, 0
112
  $this->options['clear'] = 0; // 1, 0
@@ -118,9 +118,16 @@ if(!class_exists('kk_Ratings') && !isset($kkratings) && !function_exists('kk_sta
118
  $this->options['position'] = 'top-left'; // 'top-left', 'top-right', 'bottom-left', 'bottom-right'
119
  $this->options['legend'] = '[avg]([per]) [total] votes'; // [total]=total ratings, [rating]=average, [per]=percentage
120
  $this->options['init_msg'] = 'Be the first to rate it!'; // string
 
121
  $this->update_options();
122
  endif;
123
 
 
 
 
 
 
 
124
  // add meta_key for avg. Required for backward compatibility
125
  global $wpdb;
126
  $table = $wpdb->prefix . 'postmeta';
@@ -288,6 +295,26 @@ if(!class_exists('kk_Ratings') && !isset($kkratings) && !function_exists('kk_sta
288
  endif;
289
  return $content;
290
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
291
  public function kk_star_rating($pid=false)
292
  {
293
  if($this->options['enable'])
@@ -308,7 +335,6 @@ if(!class_exists('kk_Ratings') && !isset($kkratings) && !function_exists('kk_sta
308
  }
309
 
310
  return $rated_posts;
311
-
312
  }
313
  }
314
 
@@ -323,6 +349,12 @@ if(!class_exists('kk_Ratings') && !isset($kkratings) && !function_exists('kk_sta
323
  // add shortcode handler
324
  add_shortcode('kkratings', array($kkratings, 'do_it_manually'));
325
 
 
 
 
 
 
 
326
  function kk_star_ratings($pid=false)
327
  {
328
  global $kkratings;
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.6
8
  Author: Kamal Khan
9
  Author URI: http://bhittani.com
10
  License: GPLv2 or later
105
  }
106
  public function activate()
107
  {
108
+ //$this->options['legend'] = '[avg]([per]) [total] votes'; // [total]=total ratings, [avg]=average, [per]=percentage
109
+ //$this->update_options();
110
  if(!count($this->options)) :
111
  $this->options['enable'] = 1; // 1, 0
112
  $this->options['clear'] = 0; // 1, 0
118
  $this->options['position'] = 'top-left'; // 'top-left', 'top-right', 'bottom-left', 'bottom-right'
119
  $this->options['legend'] = '[avg]([per]) [total] votes'; // [total]=total ratings, [rating]=average, [per]=percentage
120
  $this->options['init_msg'] = 'Be the first to rate it!'; // string
121
+ $this->options['column'] = 1; // 1, 0
122
  $this->update_options();
123
  endif;
124
 
125
+ if(!isset($this->options['column']))
126
+ {
127
+ $this->options['column'] = 1;
128
+ $this->update_options();
129
+ }
130
+
131
  // add meta_key for avg. Required for backward compatibility
132
  global $wpdb;
133
  $table = $wpdb->prefix . 'postmeta';
295
  endif;
296
  return $content;
297
  }
298
+ public function add_column($Columns)
299
+ {
300
+ if($this->options['column'])
301
+ $Columns['kk_star_ratings'] = 'Ratings';
302
+ return $Columns;
303
+ }
304
+ function add_row($Columns, $id)
305
+ {
306
+ if($this->options['column']) :
307
+ $raw = (get_post_meta($id, '_kk_ratings_ratings', true)?get_post_meta($id, '_kk_ratings_ratings', true):0);
308
+ $avg = '<strong>'.(get_post_meta($id, '_kk_ratings_avg', true)?get_post_meta($id, '_kk_ratings_avg', true):'0').'/5</strong>';
309
+ $cast = (get_post_meta($id, '_kk_ratings_casts', true)?get_post_meta($id, '_kk_ratings_casts', true):'0').' votes';
310
+ $per = ($raw>0?ceil((($raw/$cast)/5)*100):0).'%';
311
+ $row = $avg . ' (' . $per . ') ' . $cast;
312
+ switch($Columns)
313
+ {
314
+ case 'kk_star_ratings' : echo $row; break;
315
+ }
316
+ endif;
317
+ }
318
  public function kk_star_rating($pid=false)
319
  {
320
  if($this->options['enable'])
335
  }
336
 
337
  return $rated_posts;
 
338
  }
339
  }
340
 
349
  // add shortcode handler
350
  add_shortcode('kkratings', array($kkratings, 'do_it_manually'));
351
 
352
+ // ADD COLUMNS TO POST AND PAGE TABLES IN ADMIN (as of 1.6)
353
+ add_filter( 'manage_posts_columns', array($kkratings, 'add_column') );
354
+ add_filter( 'manage_pages_columns', array($kkratings, 'add_column') );
355
+ add_filter( 'manage_posts_custom_column', array($kkratings, 'add_row'), 10, 2 );
356
+ add_filter( 'manage_pages_custom_column', array($kkratings, 'add_row'), 10, 2 );
357
+
358
  function kk_star_ratings($pid=false)
359
  {
360
  global $kkratings;
readme.txt CHANGED
@@ -11,7 +11,7 @@ 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.
@@ -113,5 +113,8 @@ This may have occured to some users with previous versions of the plugin. It has
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 ==
11
 
12
  Tested up to: 3.3.1
13
 
14
+ Stable tag: 1.6
15
 
16
 
17
  kk Star Ratings allows blog visitors to involve and interact more effectively with your website by rating posts.
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
+ = 1.6 =
117
+ * Added: Now you can see a column in the admin screen of posts and pages stating the ratings of each.
118
+
119
 
120
  == Upgrade Notice ==