kk Star Ratings - Version 1.4.1

Version Description

  • Fixed: Settings are now able to be saved. Was not being saved in v1.4.

=

Download this release

Release Info

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

Code changes from version 1.7 to 1.4.1

Files changed (6) hide show
  1. admin/options.php +19 -5
  2. ajax/kk-ratings-ajax.php +16 -3
  3. js/kk-ratings.js +17 -17
  4. kk-ratings.php +9 -50
  5. readme.txt +4 -18
  6. widget.php +3 -18
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>
ajax/kk-ratings-ajax.php CHANGED
@@ -1,6 +1,8 @@
1
  <?php
 
 
2
 
3
- $path_to_root = urldecode($_POST['root']);
4
  require_once($path_to_root."wp-config.php");
5
 
6
  // check security
@@ -53,11 +55,22 @@ if(isset($_POST['id']) && ((!strcmp($_POST['op'], 'get') && $Ratings['ratings'])
53
  $Ratings['legend'] = str_replace('[avg]',$Ratings['avg'], $Ratings['legend']);
54
  $Ratings['legend'] = str_replace('[per]',$Ratings['per'].'%', $Ratings['legend']);
55
 
56
- echo "SUCCESS|||".$Ratings['per'].'|||'.$Ratings['legend'].'|||'.$Ratings['open'];
 
 
 
 
 
 
 
57
  }
58
  else
59
  {
60
- echo "FAIL|||";
 
 
 
 
61
  }
62
 
63
  ?>
1
  <?php
2
+ session_start();
3
+ header("Content-type: text/xml");
4
 
5
+ $path_to_root = urldecode($_SESSION['kksr_root']); // v 1.7.1
6
  require_once($path_to_root."wp-config.php");
7
 
8
  // check security
55
  $Ratings['legend'] = str_replace('[avg]',$Ratings['avg'], $Ratings['legend']);
56
  $Ratings['legend'] = str_replace('[per]',$Ratings['per'].'%', $Ratings['legend']);
57
 
58
+ echo "<?xml version='1.0' encoding='ISO-8859-1'?>";
59
+ echo "<response>";
60
+ echo "<success>1</success>";
61
+ echo "<percentage>".$Ratings['per']."</percentage>";
62
+ echo "<legend>".$Ratings['legend']."</legend>";
63
+ echo "<open>".$Ratings['open']."</open>";
64
+ echo "</response>";
65
+ exit;
66
  }
67
  else
68
  {
69
+ echo "<?xml version='1.0' encoding='ISO-8859-1'?>";
70
+ echo "<response>";
71
+ echo "<error>Invalid error occurred</error>";
72
+ echo "</response>";
73
+ exit;
74
  }
75
 
76
  ?>
js/kk-ratings.js CHANGED
@@ -5,7 +5,6 @@
5
  jQuery(document).ready( function($){
6
  $('.kk-ratings').kkratings({
7
  'path' : kk_ratings_settings.path,
8
- 'root' : kk_ratings_settings.root,
9
  'nonce' : kk_ratings_settings.nonce,
10
  'position' : kk_ratings_settings.pos
11
  });
@@ -88,16 +87,14 @@ jQuery(document).ready( function($){
88
  $.ajax({
89
  type: "POST",
90
  url: settings.path+"ajax/kk-ratings-ajax.php",
91
- data: '_ajax_nonce='+settings.nonce+'&root='+settings.root+"&op=get&id="+id,
 
92
  success: function(msg){
93
-
94
- msg = msg.replace(/^\s+|\s+$/g,"");
95
- var response = msg.split('|||');
96
- if(response[0]=='SUCCESS')
97
  {
98
- var per = response[1];
99
- var legend = response[2];
100
- var open = response[3];
101
 
102
  if($.browser.opera)
103
  $('.stars-turned-on',obj).css({'width':per+'%'});
@@ -133,6 +130,7 @@ jQuery(document).ready( function($){
133
  }
134
  });
135
 
 
136
  $(".hover-panel > a", obj).click( function() {
137
  var obj = $(this).parent().parent();
138
  var percentage = 0;
@@ -144,23 +142,24 @@ jQuery(document).ready( function($){
144
  var starsTT = starsT.split('-');
145
  var stars = parseInt(starsTT[1]);
146
  var id = $("span:eq(0)",obj).text();
147
-
 
 
148
  $.ajax({
149
  type: "POST",
150
  url: settings.path+"ajax/kk-ratings-ajax.php",
151
- data: '_ajax_nonce='+settings.nonce+'&root='+settings.root+"&op=put&id="+id+'&stars='+stars,
 
152
  beforeSend: function(){
153
  obj.fadeTo('slow',0.3);
154
  $('.casting-desc',obj).fadeOut('fast');
155
  },
156
  success: function(msg){
157
- msg = msg.replace(/^\s+|\s+$/g,"");
158
- var response = msg.split('|||');
159
- if(response[0]=='SUCCESS')
160
  {
161
- var per = response[1];
162
- var legend = response[2];
163
- var open = response[3];
164
 
165
  percentage = per;
166
 
@@ -216,6 +215,7 @@ jQuery(document).ready( function($){
216
  }
217
  }
218
  });
 
219
  }
220
  return false;
221
  });
5
  jQuery(document).ready( function($){
6
  $('.kk-ratings').kkratings({
7
  'path' : kk_ratings_settings.path,
 
8
  'nonce' : kk_ratings_settings.nonce,
9
  'position' : kk_ratings_settings.pos
10
  });
87
  $.ajax({
88
  type: "POST",
89
  url: settings.path+"ajax/kk-ratings-ajax.php",
90
+ data: '_ajax_nonce='+settings.nonce+"&op=get&id="+id,
91
+ dataType: "xml",
92
  success: function(msg){
93
+ if($(msg).find('success').text())
 
 
 
94
  {
95
+ var per = $(msg).find('percentage').text();
96
+ var legend = $(msg).find('legend').text();
97
+ var open = $(msg).find('open').text();
98
 
99
  if($.browser.opera)
100
  $('.stars-turned-on',obj).css({'width':per+'%'});
130
  }
131
  });
132
 
133
+ var busy = false;
134
  $(".hover-panel > a", obj).click( function() {
135
  var obj = $(this).parent().parent();
136
  var percentage = 0;
142
  var starsTT = starsT.split('-');
143
  var stars = parseInt(starsTT[1]);
144
  var id = $("span:eq(0)",obj).text();
145
+ if(!busy)
146
+ {
147
+ busy = true;
148
  $.ajax({
149
  type: "POST",
150
  url: settings.path+"ajax/kk-ratings-ajax.php",
151
+ data: '_ajax_nonce='+settings.nonce+"&op=put&id="+id+'&stars='+stars,
152
+ dataType: "xml",
153
  beforeSend: function(){
154
  obj.fadeTo('slow',0.3);
155
  $('.casting-desc',obj).fadeOut('fast');
156
  },
157
  success: function(msg){
158
+ if($(msg).find('success').text())
 
 
159
  {
160
+ var per = $(msg).find('percentage').text();
161
+ var legend = $(msg).find('legend').text();
162
+ var open = $(msg).find('open').text();
163
 
164
  percentage = per;
165
 
215
  }
216
  }
217
  });
218
+ }
219
  }
220
  return false;
221
  });
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.7
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, [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
@@ -116,18 +116,11 @@ if(!class_exists('kk_Ratings') && !isset($kkratings) && !function_exists('kk_sta
116
  $this->options['show_in_pages'] = 0; // 1, 0
117
  $this->options['unique'] = 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, [avg]=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,46 +288,18 @@ if(!class_exists('kk_Ratings') && !isset($kkratings) && !function_exists('kk_sta
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'])
321
  return $this->markup($pid);
322
  return '';
323
  }
324
- public function kk_star_ratings_get($total=5, $cat=false)
325
  {
326
  global $wpdb;
327
  $table = $wpdb->prefix . 'postmeta';
328
- if(!$cat)
329
- $rated_posts = $wpdb->get_results("SELECT a.ID, a.post_title, b.meta_value AS 'ratings' FROM " . $wpdb->posts . " a, $table b, $table c WHERE a.post_status='publish' AND a.ID=b.post_id AND a.ID=c.post_id AND b.meta_key='_kk_ratings_avg' AND c.meta_key='_kk_ratings_casts' ORDER BY b.meta_value DESC, c.meta_value DESC LIMIT $total");
330
- else
331
- {
332
- $table2 = $wpdb->prefix . 'term_taxonomy';
333
- $table3 = $wpdb->prefix . 'term_relationships';
334
- $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, $table e 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 a.ID=e.post_id AND b.meta_key='_kk_ratings_avg' AND e.meta_key='_kk_ratings_casts' ORDER BY b.meta_value DESC, e.meta_value DESC LIMIT $total");
335
- }
336
-
337
- return $rated_posts;
338
  }
339
  }
340
 
@@ -349,21 +314,15 @@ if(!class_exists('kk_Ratings') && !isset($kkratings) && !function_exists('kk_sta
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;
361
  return $kkratings->kk_star_rating($pid);
362
  }
363
- function kk_star_ratings_get($lim=5, $cat=false)
364
  {
365
  global $kkratings;
366
- return $kkratings->kk_star_ratings_get($lim, $cat);
367
  }
368
 
369
  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.4.1
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, [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
116
  $this->options['show_in_pages'] = 0; // 1, 0
117
  $this->options['unique'] = 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->update_options();
122
  endif;
123
 
 
 
 
 
 
 
124
  // add meta_key for avg. Required for backward compatibility
125
  global $wpdb;
126
  $table = $wpdb->prefix . 'postmeta';
288
  endif;
289
  return $content;
290
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
291
  public function kk_star_rating($pid=false)
292
  {
293
  if($this->options['enable'])
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
 
314
  // add shortcode handler
315
  add_shortcode('kkratings', array($kkratings, 'do_it_manually'));
316
 
 
 
 
 
 
 
317
  function kk_star_ratings($pid=false)
318
  {
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');
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.3.2
13
 
14
- Stable tag: 1.7
15
 
16
 
17
  kk Star Ratings allows blog visitors to involve and interact more effectively with your website by rating posts.
@@ -29,10 +29,6 @@ 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
- 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,11 +63,11 @@ A settings page is also available where you can adjust the settings. You can:
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
 
@@ -108,15 +104,5 @@ This may have occured to some users with previous versions of the plugin. It has
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
- = 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
- = 1.7 =
120
- * Update: The top rated posts now considers the vote count as well. This is a recommended update for all users.
121
 
122
  == Upgrade Notice ==
9
 
10
  Requires at least: 3.0
11
 
12
+ Tested up to: 3.2.1
13
 
14
+ Stable tag: 1.4.1
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
  A settings page is also available where you can adjust the settings. You can:
33
 
34
 
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
 
104
  = 1.4.1 =
105
  * Fixed: Settings are now able to be saved. Was not being saved in v1.4.
106
 
 
 
 
 
 
 
 
 
 
 
107
 
108
  == Upgrade Notice ==
widget.php CHANGED
@@ -20,14 +20,15 @@ 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
- $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,22 +71,6 @@ class kk_Ratings_Widget extends WP_Widget
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
  }
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
  </select>
72
  </label>
73
  </p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  <?php
75
  }
76
  }