kk Star Ratings - Version 2.5

Version Description

  • Fix: Deprecate WP_Widget for __construct. Required for wp 4.3+.
  • Fix google rich snippets by using #Ratings as the vocabulary.
  • Update: social and sponsored links in admin.
  • Add: Css reset for star anchors.
  • Use github for managing the plugin source at https://github.com/kamalkhan/kk-star-ratings.
Download this release

Release Info

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

Code changes from version 2.4.1 to 2.5

Files changed (5) hide show
  1. admin.php +52 -21
  2. css.css +2 -0
  3. index.php +78 -78
  4. readme.txt +20 -5
  5. widget.php +7 -7
admin.php CHANGED
@@ -1,12 +1,34 @@
1
  <div class="bhittani-framework">
2
  <?php if(isset($sidebar)) : ?>
3
  <div class="bf-wrap-small _right">
4
- <h3>Like the plugin</h3>
5
- <p>
6
- <script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
7
- <fb:like send="false" layout="box_count" width="225" show_faces="false" href="http://wakeusup.com/2011/05/kk-star-ratings/"></fb:like>
8
- </p>
9
- <iframe src="http://bhittani.com/wp.php" id="bfa" width="225" height="400" scrolling="no" border="0"></iframe>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  </div>
11
  <!-- bf-wrap-small -->
12
  <?php endif; ?>
@@ -26,7 +48,16 @@
26
  <?php echo $h3; ?>
27
  </h3>
28
  <div class="links">
29
- <?php
 
 
 
 
 
 
 
 
 
30
  if(isset($Url) && is_array($Url))
31
  {
32
  $url_sep = '';
@@ -45,7 +76,7 @@
45
  <form method="post" action="" name="bf_form">
46
  <div class="bf_container __settings <?php echo ($opt=='general')?'__active':''; ?>">
47
  <?php
48
-
49
  BhittaniPlugin_AdminMarkup::checkbox(array(
50
  'title' => 'Enable/Disable',
51
  'description' => 'Choose whether you want to enable or disable the plugin',
@@ -240,7 +271,7 @@
240
  </div>
241
  <!--bf_container __stars-->
242
  <div class="bf_container __tooltips <?php echo ($opt=='tooltips')?'__active':''; ?>">
243
- <?php
244
  BhittaniPlugin_AdminMarkup::checkbox(array(
245
  'title' => 'Tooltips',
246
  'description' => 'Choose whether you want to enable or disable the tooltips',
@@ -273,13 +304,13 @@
273
  </div>
274
  <!--bf_container __tooltips-->
275
  <div class="bf_container __reset <?php echo ($opt=='reset')?'__active':''; ?>">
276
- <?php
277
  global $wpdb;
278
  $table = $wpdb->prefix . 'postmeta';
279
- $Posts = $wpdb->get_results("SELECT a.ID, a.post_title
280
- FROM " . $wpdb->posts . " a, $table b
281
- WHERE a.ID=b.post_id AND
282
- b.meta_key='_kksr_ratings'
283
  ORDER BY a.ID ASC");
284
  if(is_array($Posts))
285
  {
@@ -294,12 +325,12 @@
294
  }
295
  if(count($Obj))
296
  {
297
- BhittaniPlugin_AdminMarkup::html('<p>Select the posts/pages below
298
- and click the reset button to reset
299
  their ratings.</p>
300
  <p>
301
- <a href="#" rel="kksr-reset-all" class="button">Select All</a>
302
- <a href="#" rel="kksr-reset-none" class="button">Select None</a>
303
  <a href="#" rel="kksr-reset" class="button-primary" style="color:white;">Reset</a>
304
  </p>'
305
  );
@@ -312,12 +343,12 @@
312
  }
313
  else
314
  {
315
- BhittaniPlugin_AdminMarkup::html('No ratings have been placed.');
316
  }
317
  }
318
  else
319
  {
320
- BhittaniPlugin_AdminMarkup::html('No ratings have been placed.');
321
  }
322
  ?>
323
  </div>
@@ -389,7 +420,7 @@ function my_super_function2($post_id, $no_of_stars, $ip_address);
389
  </pre>
390
  </code>
391
  </p>'
392
- );
393
  ?>
394
  </div>
395
  <!--bf_container __help-->
1
  <div class="bhittani-framework">
2
  <?php if(isset($sidebar)) : ?>
3
  <div class="bf-wrap-small _right">
4
+
5
+ <!-- Place this tag where you want the button to render. -->
6
+ <a class="github-button" href="https://github.com/kamalkhan/kk-star-ratings" data-icon="octicon-star" data-style="mega" data-count-href="/kamalkhan/kk-star-ratings/stargazers" data-count-api="/repos/kamalkhan/kk-star-ratings#stargazers_count" data-count-aria-label="# stargazers on GitHub" aria-label="Star kamalkhan/kk-star-ratings on GitHub">
7
+ kk Star Ratings
8
+ </a>
9
+ <br><br>
10
+ <!-- Place this tag right after the last button or just before your close body tag. -->
11
+ <script async defer id="github-bjs" src="https://buttons.github.io/buttons.js"></script>
12
+
13
+ <a href="http://bit.ly/awesome-live-chat" title="Awesome Live Chat" target="_blank">
14
+ <img alt="Awesome Live Chat - CodeCanyon Item for Sale" border="0" class="landscape-image-magnifier preload no_preview" data-google-analytics-payload="{&quot;id&quot;:9931156,&quot;name&quot;:&quot;Awesome Live Chat&quot;,&quot;brand&quot;:&quot;KamalKhan&quot;,&quot;category&quot;:&quot;codecanyon.net/category/wordpress&quot;,&quot;position&quot;:5,&quot;list&quot;:&quot;Author portfolio&quot;}" data-item-author="KamalKhan" data-item-category="WordPress" data-item-cost="25" data-item-id="9931156" data-item-name="Awesome Live Chat" data-preview-height="" data-preview-url="https://preview-cc.s3.envato.com/files/116826712/jumbotron.jpg" data-preview-width="" height="80" src="https://thumb-cc.s3.envato.com/files/116826711/thumbnail.jpg" title="" width="80" data-tooltip="Awesome Live Chat">
15
+ </a>
16
+ <a href="http://bit.ly/awesome-live-chat-os-x" title="Awesome Live Chat Desk OS X" target="_blank">
17
+ <img alt="Awesome Live Chat Desk OS X - CodeCanyon Item for Sale" border="0" class="landscape-image-magnifier preload no_preview" data-google-analytics-payload="{&quot;id&quot;:10106623,&quot;name&quot;:&quot;Awesome Live Chat Desk OS X&quot;,&quot;brand&quot;:&quot;KamalKhan&quot;,&quot;category&quot;:&quot;codecanyon.net/category/apps/mac&quot;,&quot;position&quot;:3,&quot;list&quot;:&quot;Author portfolio&quot;}" data-item-author="KamalKhan" data-item-category="Apps / Mac" data-item-cost="10" data-item-id="10106623" data-item-name="Awesome Live Chat Desk OS X" data-preview-height="" data-preview-url="https://preview-cc.s3.envato.com/files/118693278/jumbotron-osx.png" data-preview-width="" height="80" src="https://thumb-cc.s3.envato.com/files/118693274/thumbnail.png" title="" width="80" data-tooltip="Awesome Live Chat Desk OS X">
18
+ </a>
19
+ <a href="http://bit.ly/awesome-live-chat-pc" title="Awesome Live Chat Desk PC" target="_blank">
20
+ <img alt="Awesome Live Chat Desk PC - CodeCanyon Item for Sale" border="0" class="landscape-image-magnifier preload no_preview" data-google-analytics-payload="{&quot;id&quot;:10398931,&quot;name&quot;:&quot;Awesome Live Chat Desk PC&quot;,&quot;brand&quot;:&quot;KamalKhan&quot;,&quot;category&quot;:&quot;codecanyon.net/category/apps/windows&quot;,&quot;position&quot;:2,&quot;list&quot;:&quot;Author portfolio&quot;}" data-item-author="KamalKhan" data-item-category="Apps / Windows" data-item-cost="11" data-item-id="10398931" data-item-name="Awesome Live Chat Desk PC" data-preview-height="" data-preview-url="https://preview-cc.s3.envato.com/files/122225936/jumbotron-pc.png" data-preview-width="" height="80" src="https://thumb-cc.s3.envato.com/files/122225933/thumbnail.png" title="" width="80" data-tooltip="Awesome Live Chat Desk PC">
21
+ </a>
22
+ <a href="http://bit.ly/awesome-live-chat-desk-linux" title="Awesome Live Chat Desk Linux" target="_blank">
23
+ <img alt="Awesome Live Chat Desk Linux - CodeCanyon Item for Sale" border="0" class="landscape-image-magnifier preload no_preview" data-google-analytics-payload="{&quot;id&quot;:11996346,&quot;name&quot;:&quot;Awesome Live Chat Desk Linux&quot;,&quot;brand&quot;:&quot;KamalKhan&quot;,&quot;category&quot;:&quot;codecanyon.net/category/html5/miscellaneous&quot;,&quot;position&quot;:1,&quot;list&quot;:&quot;Author portfolio&quot;}" data-item-author="KamalKhan" data-item-category="HTML5 / Miscellaneous" data-item-cost="11" data-item-id="11996346" data-item-name="Awesome Live Chat Desk Linux" data-preview-height="" data-preview-url="https://preview-cc.s3.envato.com/files/140022646/jumbotron-linux.png" data-preview-width="" height="80" src="https://thumb-cc.s3.envato.com/files/140022645/thumbnail.png" title="" width="80" data-tooltip="Awesome Live Chat Desk Linux">
24
+ </a>
25
+ <?php
26
+ /*
27
+ <a href="http://bit.ly/awesome-live-chat-server" title="Awesome Live Chat Server" target="_blank">
28
+ <img alt="Awesome Live Chat Server - CodeCanyon Item for Sale" border="0" class="landscape-image-magnifier preload no_preview" data-google-analytics-payload="{&quot;id&quot;:10010235,&quot;name&quot;:&quot;Awesome Live Chat Server&quot;,&quot;brand&quot;:&quot;KamalKhan&quot;,&quot;category&quot;:&quot;codecanyon.net/category/javascript/miscellaneous&quot;,&quot;position&quot;:4,&quot;list&quot;:&quot;Author portfolio&quot;}" data-item-author="KamalKhan" data-item-category="JavaScript / Miscellaneous" data-item-cost="14" data-item-id="10010235" data-item-name="Awesome Live Chat Server" data-preview-height="" data-preview-url="https://preview-cc.s3.envato.com/files/117666866/jumbotron.png" data-preview-width="" height="80" src="https://thumb-cc.s3.envato.com/files/117666864/thumbnail.png" title="" width="80" data-tooltip="Awesome Live Chat Server">
29
+ </a>
30
+ */
31
+ ?>
32
  </div>
33
  <!-- bf-wrap-small -->
34
  <?php endif; ?>
48
  <?php echo $h3; ?>
49
  </h3>
50
  <div class="links">
51
+ <div id="fb-root"></div>
52
+ <script>(function(d, s, id) {
53
+ var js, fjs = d.getElementsByTagName(s)[0];
54
+ if (d.getElementById(id)) return;
55
+ js = d.createElement(s); js.id = id;
56
+ js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.5";
57
+ fjs.parentNode.insertBefore(js, fjs);
58
+ }(document, 'script', 'facebook-jssdk'));</script>
59
+ <div class="fb-like" data-href="https://github.com/kamalkhan/kk-star-ratings" data-width="167" data-layout="button_count" data-action="like" data-show-faces="true" data-share="true"></div>
60
+ <?php
61
  if(isset($Url) && is_array($Url))
62
  {
63
  $url_sep = '';
76
  <form method="post" action="" name="bf_form">
77
  <div class="bf_container __settings <?php echo ($opt=='general')?'__active':''; ?>">
78
  <?php
79
+
80
  BhittaniPlugin_AdminMarkup::checkbox(array(
81
  'title' => 'Enable/Disable',
82
  'description' => 'Choose whether you want to enable or disable the plugin',
271
  </div>
272
  <!--bf_container __stars-->
273
  <div class="bf_container __tooltips <?php echo ($opt=='tooltips')?'__active':''; ?>">
274
+ <?php
275
  BhittaniPlugin_AdminMarkup::checkbox(array(
276
  'title' => 'Tooltips',
277
  'description' => 'Choose whether you want to enable or disable the tooltips',
304
  </div>
305
  <!--bf_container __tooltips-->
306
  <div class="bf_container __reset <?php echo ($opt=='reset')?'__active':''; ?>">
307
+ <?php
308
  global $wpdb;
309
  $table = $wpdb->prefix . 'postmeta';
310
+ $Posts = $wpdb->get_results("SELECT a.ID, a.post_title
311
+ FROM " . $wpdb->posts . " a, $table b
312
+ WHERE a.ID=b.post_id AND
313
+ b.meta_key='_kksr_ratings'
314
  ORDER BY a.ID ASC");
315
  if(is_array($Posts))
316
  {
325
  }
326
  if(count($Obj))
327
  {
328
+ BhittaniPlugin_AdminMarkup::html('<p>Select the posts/pages below
329
+ and click the reset button to reset
330
  their ratings.</p>
331
  <p>
332
+ <a href="#" rel="kksr-reset-all" class="button">Select All</a>
333
+ <a href="#" rel="kksr-reset-none" class="button">Select None</a>
334
  <a href="#" rel="kksr-reset" class="button-primary" style="color:white;">Reset</a>
335
  </p>'
336
  );
343
  }
344
  else
345
  {
346
+ BhittaniPlugin_AdminMarkup::html('No ratings have been placed.');
347
  }
348
  }
349
  else
350
  {
351
+ BhittaniPlugin_AdminMarkup::html('No ratings have been placed.');
352
  }
353
  ?>
354
  </div>
420
  </pre>
421
  </code>
422
  </p>'
423
+ );
424
  ?>
425
  </div>
426
  <!--bf_container __help-->
css.css CHANGED
@@ -43,6 +43,8 @@
43
  float: left;
44
  position: relative;
45
  z-index: 1;
 
 
46
  }
47
  .kk-star-ratings .kksr-legend {
48
  font-size: 12px;
43
  float: left;
44
  position: relative;
45
  z-index: 1;
46
+ text-decoration: none;
47
+ border: 0;
48
  }
49
  .kk-star-ratings .kksr-legend {
50
  font-size: 12px;
index.php CHANGED
@@ -2,9 +2,9 @@
2
 
3
  /*
4
  Plugin Name: kk Star Ratings
5
- Plugin URI: http://wakeusup.com/2011/05/kk-star-ratings/
6
  Description: Renewed from the ground up(as of v2.0), clean, animated and light weight ratings feature for your blog. With kk Star Ratings, you can <strong>allow your blog posts to be rated by your blog visitors</strong>. It also includes a <strong>widget</strong> which you can add to your sidebar to show the top rated post. Wait! There is more to it. Enjoy the extensive options you can set to customize this plugin.
7
- Version: 2.4.1
8
  Author: Kamal Khan
9
  Author URI: http://bhittani.com
10
  License: GPLv2 or later
@@ -17,7 +17,7 @@ if(!class_exists('BhittaniPlugin_kkStarRatings')) :
17
  class BhittaniPlugin_kkStarRatings extends BhittaniPlugin
18
  {
19
  private $_Menus;
20
-
21
  public function __construct($id, $nick, $ver)
22
  {
23
  parent::__construct($id, $nick, $ver);
@@ -129,7 +129,7 @@ if(!class_exists('BhittaniPlugin_kkStarRatings')) :
129
  echo $star_gray ? '.kk-star-ratings .kksr-star.gray { background-image: url('.$star_gray.'); }' : '';
130
  echo $star_yellow ? '.kk-star-ratings .kksr-star.yellow { background-image: url('.$star_yellow.'); }' : '';
131
  echo $star_orange ? '.kk-star-ratings .kksr-star.orange { background-image: url('.$star_orange.'); }' : '';
132
-
133
  echo '</style>';
134
  }
135
  /** function/method
@@ -167,7 +167,7 @@ if(!class_exists('BhittaniPlugin_kkStarRatings')) :
167
  $Options['kksr_legend'] = isset($Old_plugin['legend']) ? $Old_plugin['legend'] : $opt_legend;
168
  $Options['kksr_init_msg'] = isset($Old_plugin['init_msg']) ? $Old_plugin['init_msg'] : $opt_init_msg;
169
  $Options['kksr_column'] = isset($Old_plugin['column']) ? $Old_plugin['column'] : $opt_column;
170
-
171
  // Upgrade from old plugin(<2.0) to renewed plugin(>=2.0)
172
  if(!$ver_previous || version_compare($ver_previous, '2.0', '<'))
173
  {
@@ -177,12 +177,12 @@ if(!class_exists('BhittaniPlugin_kkStarRatings')) :
177
  // Update previous ratings
178
  global $wpdb;
179
  $table = $wpdb->prefix . 'postmeta';
180
- $Posts = $wpdb->get_results("SELECT a.ID, b.meta_key, b.meta_value
181
- FROM " . $wpdb->posts . " a, $table b
182
- WHERE a.ID=b.post_id AND
183
  (
184
- b.meta_key='_kk_ratings_ratings' OR
185
- b.meta_key='_kk_ratings_casts' OR
186
  b.meta_key='_kk_ratings_ips'
187
  ) ORDER BY a.ID ASC");
188
  $Wrap = array();
@@ -241,56 +241,56 @@ if(!class_exists('BhittaniPlugin_kkStarRatings')) :
241
  {
242
  // Create main menu tab
243
  $this->_Menus[] = add_menu_page(
244
- $this->nick.' - Settings',
245
- $this->nick,
246
- 'manage_options',
247
- $this->id.'_settings',
248
  array(&$this, 'options_general'),
249
  self::file_uri('icon.png')
250
  );
251
  // Create images menu tab
252
  $this->_Menus[] = add_submenu_page(
253
- $this->id.'_settings',
254
- $this->nick.' - Settings',
255
- 'Settings',
256
- 'manage_options',
257
- $this->id.'_settings',
258
  array(&$this, 'options_general')
259
  );
260
  // Create images menu tab
261
  $this->_Menus[] = add_submenu_page(
262
- $this->id.'_settings',
263
- $this->nick.' - Stars',
264
- 'Stars',
265
- 'manage_options',
266
- $this->id.'_settings_stars',
267
  array(&$this, 'options_stars')
268
  );
269
  // Create tooltips menu tab
270
  $this->_Menus[] = add_submenu_page(
271
- $this->id.'_settings',
272
- $this->nick.' - Tooltips',
273
- 'Tooltips',
274
- 'manage_options',
275
- $this->id.'_settings_tooltips',
276
  array(&$this, 'options_tooltips')
277
  );
278
  // Create reset menu tab
279
  $this->_Menus[] = add_submenu_page(
280
- $this->id.'_settings',
281
- $this->nick.' - Reset',
282
- 'Reset',
283
- 'manage_options',
284
- $this->id.'_settings_reset',
285
  array(&$this, 'options_reset')
286
  );
287
  // Create info menu tab
288
  $this->_Menus[] = add_submenu_page(
289
- $this->id.'_settings',
290
- $this->nick.' - Help',
291
- 'Help',
292
- 'manage_options',
293
- $this->id.'_settings_info',
294
  array(&$this, 'options_info')
295
  );
296
  }
@@ -300,22 +300,22 @@ if(!class_exists('BhittaniPlugin_kkStarRatings')) :
300
  * Return: void
301
  */
302
  public function options_page($opt)
303
- {
304
- if (!current_user_can('manage_options'))
305
  {
306
  wp_die( __('You do not have sufficient permissions to access this page.') );
307
  }
308
  $sidebar = true;
309
  $h3 = 'kk Star Ratings';
310
  $Url = array(
311
- array(
312
- 'title' => 'Home',
313
- 'link' => 'http://wpapis.com/kk-star-ratings/'
314
- ),
315
- array(
316
- 'title' => 'Changelog',
317
- 'link' => 'http://wpapis.com/kk-star-ratings/#tab-1369077219827-3-8'
318
- )
319
  );
320
  include self::file_path('admin.php');
321
  }
@@ -325,7 +325,7 @@ if(!class_exists('BhittaniPlugin_kkStarRatings')) :
325
  * Return: void
326
  */
327
  public function options_general()
328
- {
329
  $this->options_page('general');
330
  }
331
  /** function/method
@@ -334,7 +334,7 @@ if(!class_exists('BhittaniPlugin_kkStarRatings')) :
334
  * Return: void
335
  */
336
  public function options_stars()
337
- {
338
  $this->options_page('stars');
339
  }
340
  /** function/method
@@ -343,7 +343,7 @@ if(!class_exists('BhittaniPlugin_kkStarRatings')) :
343
  * Return: void
344
  */
345
  public function options_tooltips()
346
- {
347
  $this->options_page('tooltips');
348
  }
349
  /** function/method
@@ -352,7 +352,7 @@ if(!class_exists('BhittaniPlugin_kkStarRatings')) :
352
  * Return: void
353
  */
354
  public function options_reset()
355
- {
356
  $this->options_page('reset');
357
  }
358
  /** function/method
@@ -361,7 +361,7 @@ if(!class_exists('BhittaniPlugin_kkStarRatings')) :
361
  * Return: void
362
  */
363
  public function options_info()
364
- {
365
  $this->options_page('info');
366
  }
367
  public function kksr_admin_reset_ajax()
@@ -383,7 +383,7 @@ if(!class_exists('BhittaniPlugin_kkStarRatings')) :
383
  }
384
  }
385
  }
386
-
387
  $Response = array();
388
  $Response['success'] = 'true';
389
  echo json_encode($Response);
@@ -396,7 +396,7 @@ if(!class_exists('BhittaniPlugin_kkStarRatings')) :
396
 
397
  $Response = array();
398
 
399
- $total_stars = is_numeric(parent::get_options('kksr_stars')) ? parent::get_options('kksr_stars') : 5;
400
 
401
  $stars = is_numeric($_POST['stars']) && ((int)$_POST['stars']>0) && ((int)$_POST['stars']<=$total_stars)
402
  ? $_POST['stars']:
@@ -454,7 +454,7 @@ if(!class_exists('BhittaniPlugin_kkStarRatings')) :
454
  $Response[$pid]['success'] = true;
455
 
456
  endforeach;
457
-
458
  echo json_encode($Response);
459
  die();
460
  }
@@ -475,7 +475,7 @@ if(!class_exists('BhittaniPlugin_kkStarRatings')) :
475
  public function markup($id=false)
476
  {
477
  $id = !$id ? get_the_ID() : $id;
478
- if($this->exclude_cat($id))
479
  {
480
  return '';
481
  }
@@ -491,7 +491,7 @@ if(!class_exists('BhittaniPlugin_kkStarRatings')) :
491
  }
492
  }
493
  $pos = parent::get_options('kksr_position');
494
-
495
  $markup = '
496
  <div class="kk-star-ratings '.($disabled || (is_archive() && parent::get_options('kksr_disable_in_archives')) ? 'disabled ' : ' ').$pos.($pos=='top-right'||$pos=='bottom-right' ? ' rgt' : ' lft').'" data-id="'.$id.'">
497
  <div class="kksr-stars kksr-star gray">
@@ -510,7 +510,7 @@ if(!class_exists('BhittaniPlugin_kkStarRatings')) :
510
  {
511
  $markup .= apply_filters('kksr_legend', parent::get_options('kksr_legend'), $id);
512
  }
513
- $markup .=
514
  '</div>
515
  <!-- kksr-legend -->
516
  </div>
@@ -541,13 +541,13 @@ if(!class_exists('BhittaniPlugin_kkStarRatings')) :
541
  }
542
  public function filter($content)
543
  {
544
- if(parent::get_options('kksr_enable')) :
545
  if(
546
  ((parent::get_options('kksr_show_in_home')) && (is_front_page() || is_home()))
547
  || ((parent::get_options('kksr_show_in_archives')) && (is_archive()))
548
  || ((parent::get_options('kksr_show_in_posts')) && (is_single()))
549
  || ((parent::get_options('kksr_show_in_pages')) && (is_page()))
550
- ) :
551
  remove_shortcode('kkratings');
552
  remove_shortcode('kkstarratings');
553
  $content = str_replace('[kkratings]', '', $content);
@@ -581,7 +581,7 @@ if(!class_exists('BhittaniPlugin_kkStarRatings')) :
581
  $table3 = $wpdb->prefix . 'term_relationships';
582
  $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='_kksr_avg' AND e.meta_key='_kksr_casts' ORDER BY b.meta_value DESC, e.meta_value DESC LIMIT $total");
583
  }
584
-
585
  return $rated_posts;
586
  }
587
  public function add_column($Columns)
@@ -634,11 +634,11 @@ if(!class_exists('BhittaniPlugin_kkStarRatings')) :
634
  {
635
  return;
636
  }
637
- $orderby = $Query->get( 'orderby');
638
  if($orderby=='kk_star_ratings')
639
- {
640
  $Query->set('meta_key','_kksr_avg');
641
- $Query->set('orderby','meta_value_num');
642
  }
643
  }
644
  public function grs_legend($legend, $id)
@@ -646,22 +646,22 @@ if(!class_exists('BhittaniPlugin_kkStarRatings')) :
646
  if(parent::get_options('kksr_grs'))
647
  {
648
  $title = get_the_title($id);
649
-
650
  $best = parent::get_options('kksr_stars');
651
  $score = get_post_meta($id, '_kksr_ratings', true) ? get_post_meta($id, '_kksr_ratings', true) : 0;
652
-
653
  if($score)
654
  {
655
  $votes = get_post_meta($id, '_kksr_casts', true) ? get_post_meta($id, '_kksr_casts', true) : 0;
656
  $avg = $score ? number_format((float)($score/$votes), 2, '.', '') : 0;
657
  $per = $score ? number_format((float)((($score/$votes)/5)*100), 2, '.', '') : 0;
658
-
659
  $leg = str_replace('[total]', '<span property="v:votes">'.$votes.'</span>', $legend);
660
  $leg = str_replace('[avg]', '<span property="v:average">'.$avg.'</span>/<span property="v:best">'.$best.'</span>', $leg);
661
  $leg = str_replace('[per]',$per.'%', $leg);
662
  $leg = str_replace('[s]', $votes==1?'':'s', $leg);
663
-
664
- $snippet = '<div xmlns:v="http://rdf.data-vocabulary.org/#" typeof="v:Review-aggregate">';
665
  $snippet .= '<span property="v:itemreviewed" class="kksr-title">' . $title . '</span>';
666
  $snippet .= '<span rel="v:rating">';
667
  $snippet .= ' <span typeof="v:Rating">';
@@ -674,24 +674,24 @@ if(!class_exists('BhittaniPlugin_kkStarRatings')) :
674
  {
675
  $snippet = parent::get_options('kksr_init_msg');
676
  }
677
-
678
  return $snippet;
679
  }
680
  return $legend;
681
  }
682
  }
683
 
684
- $kkStarRatings_obj = new BhittaniPlugin_kkStarRatings('bhittani_plugin_kksr', 'kk Star Ratings', '2.4');
685
-
686
  // Setup
687
  register_activation_hook(__FILE__, array($kkStarRatings_obj, 'activate'));
688
-
689
  // Scripts
690
  add_action('wp_enqueue_scripts', array($kkStarRatings_obj, 'js'));
691
  add_action('wp_enqueue_scripts', array($kkStarRatings_obj, 'css'));
692
  add_action('wp_head', array($kkStarRatings_obj, 'css_custom'));
693
  add_action('admin_init', array($kkStarRatings_obj, 'admin_scripts'));
694
-
695
  // Menu
696
  add_action('admin_menu', array($kkStarRatings_obj, 'menu'));
697
 
@@ -704,7 +704,7 @@ if(!class_exists('BhittaniPlugin_kkStarRatings')) :
704
  add_filter('the_content', array($kkStarRatings_obj, 'filter'));
705
  add_shortcode('kkratings', array($kkStarRatings_obj, 'manual'));
706
  add_shortcode('kkstarratings', array($kkStarRatings_obj, 'manual'));
707
-
708
  // Google Rich Snippets
709
  add_filter('kksr_legend', array($kkStarRatings_obj, 'grs_legend'), 1, 2);
710
 
@@ -739,4 +739,4 @@ if(!class_exists('BhittaniPlugin_kkStarRatings')) :
739
 
740
  endif;
741
 
742
- ?>
2
 
3
  /*
4
  Plugin Name: kk Star Ratings
5
+ Plugin URI: https://github.com/kamalkhan/kk-star-ratings
6
  Description: Renewed from the ground up(as of v2.0), clean, animated and light weight ratings feature for your blog. With kk Star Ratings, you can <strong>allow your blog posts to be rated by your blog visitors</strong>. It also includes a <strong>widget</strong> which you can add to your sidebar to show the top rated post. Wait! There is more to it. Enjoy the extensive options you can set to customize this plugin.
7
+ Version: 2.5
8
  Author: Kamal Khan
9
  Author URI: http://bhittani.com
10
  License: GPLv2 or later
17
  class BhittaniPlugin_kkStarRatings extends BhittaniPlugin
18
  {
19
  private $_Menus;
20
+
21
  public function __construct($id, $nick, $ver)
22
  {
23
  parent::__construct($id, $nick, $ver);
129
  echo $star_gray ? '.kk-star-ratings .kksr-star.gray { background-image: url('.$star_gray.'); }' : '';
130
  echo $star_yellow ? '.kk-star-ratings .kksr-star.yellow { background-image: url('.$star_yellow.'); }' : '';
131
  echo $star_orange ? '.kk-star-ratings .kksr-star.orange { background-image: url('.$star_orange.'); }' : '';
132
+
133
  echo '</style>';
134
  }
135
  /** function/method
167
  $Options['kksr_legend'] = isset($Old_plugin['legend']) ? $Old_plugin['legend'] : $opt_legend;
168
  $Options['kksr_init_msg'] = isset($Old_plugin['init_msg']) ? $Old_plugin['init_msg'] : $opt_init_msg;
169
  $Options['kksr_column'] = isset($Old_plugin['column']) ? $Old_plugin['column'] : $opt_column;
170
+
171
  // Upgrade from old plugin(<2.0) to renewed plugin(>=2.0)
172
  if(!$ver_previous || version_compare($ver_previous, '2.0', '<'))
173
  {
177
  // Update previous ratings
178
  global $wpdb;
179
  $table = $wpdb->prefix . 'postmeta';
180
+ $Posts = $wpdb->get_results("SELECT a.ID, b.meta_key, b.meta_value
181
+ FROM " . $wpdb->posts . " a, $table b
182
+ WHERE a.ID=b.post_id AND
183
  (
184
+ b.meta_key='_kk_ratings_ratings' OR
185
+ b.meta_key='_kk_ratings_casts' OR
186
  b.meta_key='_kk_ratings_ips'
187
  ) ORDER BY a.ID ASC");
188
  $Wrap = array();
241
  {
242
  // Create main menu tab
243
  $this->_Menus[] = add_menu_page(
244
+ $this->nick.' - Settings',
245
+ $this->nick,
246
+ 'manage_options',
247
+ $this->id.'_settings',
248
  array(&$this, 'options_general'),
249
  self::file_uri('icon.png')
250
  );
251
  // Create images menu tab
252
  $this->_Menus[] = add_submenu_page(
253
+ $this->id.'_settings',
254
+ $this->nick.' - Settings',
255
+ 'Settings',
256
+ 'manage_options',
257
+ $this->id.'_settings',
258
  array(&$this, 'options_general')
259
  );
260
  // Create images menu tab
261
  $this->_Menus[] = add_submenu_page(
262
+ $this->id.'_settings',
263
+ $this->nick.' - Stars',
264
+ 'Stars',
265
+ 'manage_options',
266
+ $this->id.'_settings_stars',
267
  array(&$this, 'options_stars')
268
  );
269
  // Create tooltips menu tab
270
  $this->_Menus[] = add_submenu_page(
271
+ $this->id.'_settings',
272
+ $this->nick.' - Tooltips',
273
+ 'Tooltips',
274
+ 'manage_options',
275
+ $this->id.'_settings_tooltips',
276
  array(&$this, 'options_tooltips')
277
  );
278
  // Create reset menu tab
279
  $this->_Menus[] = add_submenu_page(
280
+ $this->id.'_settings',
281
+ $this->nick.' - Reset',
282
+ 'Reset',
283
+ 'manage_options',
284
+ $this->id.'_settings_reset',
285
  array(&$this, 'options_reset')
286
  );
287
  // Create info menu tab
288
  $this->_Menus[] = add_submenu_page(
289
+ $this->id.'_settings',
290
+ $this->nick.' - Help',
291
+ 'Help',
292
+ 'manage_options',
293
+ $this->id.'_settings_info',
294
  array(&$this, 'options_info')
295
  );
296
  }
300
  * Return: void
301
  */
302
  public function options_page($opt)
303
+ {
304
+ if (!current_user_can('manage_options'))
305
  {
306
  wp_die( __('You do not have sufficient permissions to access this page.') );
307
  }
308
  $sidebar = true;
309
  $h3 = 'kk Star Ratings';
310
  $Url = array(
311
+ // array(
312
+ // 'title' => 'Github Repository',
313
+ // 'link' => 'https://github.com/kamalkhan/kk-star-ratings'
314
+ // ),
315
+ // array(
316
+ // 'title' => 'Changelog',
317
+ // 'link' => '#'
318
+ // )
319
  );
320
  include self::file_path('admin.php');
321
  }
325
  * Return: void
326
  */
327
  public function options_general()
328
+ {
329
  $this->options_page('general');
330
  }
331
  /** function/method
334
  * Return: void
335
  */
336
  public function options_stars()
337
+ {
338
  $this->options_page('stars');
339
  }
340
  /** function/method
343
  * Return: void
344
  */
345
  public function options_tooltips()
346
+ {
347
  $this->options_page('tooltips');
348
  }
349
  /** function/method
352
  * Return: void
353
  */
354
  public function options_reset()
355
+ {
356
  $this->options_page('reset');
357
  }
358
  /** function/method
361
  * Return: void
362
  */
363
  public function options_info()
364
+ {
365
  $this->options_page('info');
366
  }
367
  public function kksr_admin_reset_ajax()
383
  }
384
  }
385
  }
386
+
387
  $Response = array();
388
  $Response['success'] = 'true';
389
  echo json_encode($Response);
396
 
397
  $Response = array();
398
 
399
+ $total_stars = is_numeric(parent::get_options('kksr_stars')) ? parent::get_options('kksr_stars') : 5;
400
 
401
  $stars = is_numeric($_POST['stars']) && ((int)$_POST['stars']>0) && ((int)$_POST['stars']<=$total_stars)
402
  ? $_POST['stars']:
454
  $Response[$pid]['success'] = true;
455
 
456
  endforeach;
457
+
458
  echo json_encode($Response);
459
  die();
460
  }
475
  public function markup($id=false)
476
  {
477
  $id = !$id ? get_the_ID() : $id;
478
+ if($this->exclude_cat($id))
479
  {
480
  return '';
481
  }
491
  }
492
  }
493
  $pos = parent::get_options('kksr_position');
494
+
495
  $markup = '
496
  <div class="kk-star-ratings '.($disabled || (is_archive() && parent::get_options('kksr_disable_in_archives')) ? 'disabled ' : ' ').$pos.($pos=='top-right'||$pos=='bottom-right' ? ' rgt' : ' lft').'" data-id="'.$id.'">
497
  <div class="kksr-stars kksr-star gray">
510
  {
511
  $markup .= apply_filters('kksr_legend', parent::get_options('kksr_legend'), $id);
512
  }
513
+ $markup .=
514
  '</div>
515
  <!-- kksr-legend -->
516
  </div>
541
  }
542
  public function filter($content)
543
  {
544
+ if(parent::get_options('kksr_enable')) :
545
  if(
546
  ((parent::get_options('kksr_show_in_home')) && (is_front_page() || is_home()))
547
  || ((parent::get_options('kksr_show_in_archives')) && (is_archive()))
548
  || ((parent::get_options('kksr_show_in_posts')) && (is_single()))
549
  || ((parent::get_options('kksr_show_in_pages')) && (is_page()))
550
+ ) :
551
  remove_shortcode('kkratings');
552
  remove_shortcode('kkstarratings');
553
  $content = str_replace('[kkratings]', '', $content);
581
  $table3 = $wpdb->prefix . 'term_relationships';
582
  $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='_kksr_avg' AND e.meta_key='_kksr_casts' ORDER BY b.meta_value DESC, e.meta_value DESC LIMIT $total");
583
  }
584
+
585
  return $rated_posts;
586
  }
587
  public function add_column($Columns)
634
  {
635
  return;
636
  }
637
+ $orderby = $Query->get( 'orderby');
638
  if($orderby=='kk_star_ratings')
639
+ {
640
  $Query->set('meta_key','_kksr_avg');
641
+ $Query->set('orderby','meta_value_num');
642
  }
643
  }
644
  public function grs_legend($legend, $id)
646
  if(parent::get_options('kksr_grs'))
647
  {
648
  $title = get_the_title($id);
649
+
650
  $best = parent::get_options('kksr_stars');
651
  $score = get_post_meta($id, '_kksr_ratings', true) ? get_post_meta($id, '_kksr_ratings', true) : 0;
652
+
653
  if($score)
654
  {
655
  $votes = get_post_meta($id, '_kksr_casts', true) ? get_post_meta($id, '_kksr_casts', true) : 0;
656
  $avg = $score ? number_format((float)($score/$votes), 2, '.', '') : 0;
657
  $per = $score ? number_format((float)((($score/$votes)/5)*100), 2, '.', '') : 0;
658
+
659
  $leg = str_replace('[total]', '<span property="v:votes">'.$votes.'</span>', $legend);
660
  $leg = str_replace('[avg]', '<span property="v:average">'.$avg.'</span>/<span property="v:best">'.$best.'</span>', $leg);
661
  $leg = str_replace('[per]',$per.'%', $leg);
662
  $leg = str_replace('[s]', $votes==1?'':'s', $leg);
663
+
664
+ $snippet = '<div xmlns:v="http://rdf.data-vocabulary.org/#Rating" typeof="v:Review-aggregate">';
665
  $snippet .= '<span property="v:itemreviewed" class="kksr-title">' . $title . '</span>';
666
  $snippet .= '<span rel="v:rating">';
667
  $snippet .= ' <span typeof="v:Rating">';
674
  {
675
  $snippet = parent::get_options('kksr_init_msg');
676
  }
677
+
678
  return $snippet;
679
  }
680
  return $legend;
681
  }
682
  }
683
 
684
+ $kkStarRatings_obj = new BhittaniPlugin_kkStarRatings('bhittani_plugin_kksr', 'kk Star Ratings', '2.5');
685
+
686
  // Setup
687
  register_activation_hook(__FILE__, array($kkStarRatings_obj, 'activate'));
688
+
689
  // Scripts
690
  add_action('wp_enqueue_scripts', array($kkStarRatings_obj, 'js'));
691
  add_action('wp_enqueue_scripts', array($kkStarRatings_obj, 'css'));
692
  add_action('wp_head', array($kkStarRatings_obj, 'css_custom'));
693
  add_action('admin_init', array($kkStarRatings_obj, 'admin_scripts'));
694
+
695
  // Menu
696
  add_action('admin_menu', array($kkStarRatings_obj, 'menu'));
697
 
704
  add_filter('the_content', array($kkStarRatings_obj, 'filter'));
705
  add_shortcode('kkratings', array($kkStarRatings_obj, 'manual'));
706
  add_shortcode('kkstarratings', array($kkStarRatings_obj, 'manual'));
707
+
708
  // Google Rich Snippets
709
  add_filter('kksr_legend', array($kkStarRatings_obj, 'grs_legend'), 1, 2);
710
 
739
 
740
  endif;
741
 
742
+ ?>
readme.txt CHANGED
@@ -9,9 +9,9 @@ Tags: star ratings, votings, rate posts, ajax ratings, infinite stars, unlimited
9
 
10
  Requires at least: 3.0
11
 
12
- Tested up to: 4.1
13
 
14
- Stable tag: 2.4
15
 
16
 
17
  kk Star Ratings allows blog visitors to involve and interact more effectively with your website by rating posts.
@@ -78,7 +78,15 @@ Enhanced settings page where you can adjust quite anything you may need to. You
78
 
79
  == Frequently Asked Questions ==
80
 
81
- =
 
 
 
 
 
 
 
 
82
 
83
  I have been using an older verion of the plugin. Is it safe for me to update?
84
 
@@ -86,7 +94,7 @@ I have been using an older verion of the plugin. Is it safe for me to update?
86
 
87
  Version 2.0+ has been re-coded from the ground up preserving backwards compatibility. Feel free to upgrade safely.
88
 
89
- =
90
 
91
  I need some help or have some issues?
92
 
@@ -132,6 +140,13 @@ Visit the help tab in the settings to find out what you can do.
132
 
133
  == Changelog ==
134
 
 
 
 
 
 
 
 
135
  = 2.4 =
136
  * Fix: Upper and Lower boundary limits for rating. Oops, had not noticed this before.
137
  * Fix: Fuelspeed. Strange! no one ever complained about it.
@@ -212,4 +227,4 @@ Visit the help tab in the settings to find out what you can do.
212
  = 1.1 =
213
  * Fixed the [avg] error, so now it will display average ratings properly.
214
 
215
- == Upgrade Notice ==
9
 
10
  Requires at least: 3.0
11
 
12
+ Tested up to: 4.4.2
13
 
14
+ Stable tag: 2.5
15
 
16
 
17
  kk Star Ratings allows blog visitors to involve and interact more effectively with your website by rating posts.
78
 
79
  == Frequently Asked Questions ==
80
 
81
+ =
82
+
83
+ I found a bug or want to contribute.
84
+
85
+ =
86
+
87
+ The source of this plugin is located at https://github.com/kamalkhan/kk-star-ratings (as of v2.5+). Feel free to post an issue or submit a pull request.
88
+
89
+ =
90
 
91
  I have been using an older verion of the plugin. Is it safe for me to update?
92
 
94
 
95
  Version 2.0+ has been re-coded from the ground up preserving backwards compatibility. Feel free to upgrade safely.
96
 
97
+ =
98
 
99
  I need some help or have some issues?
100
 
140
 
141
  == Changelog ==
142
 
143
+ = 2.5 =
144
+ * Fix: Deprecate WP_Widget for __construct. Required for wp 4.3+.
145
+ * Fix google rich snippets by using #Ratings as the vocabulary.
146
+ * Update: social and sponsored links in admin.
147
+ * Add: Css reset for star anchors.
148
+ * Use github for managing the plugin source at https://github.com/kamalkhan/kk-star-ratings.
149
+
150
  = 2.4 =
151
  * Fix: Upper and Lower boundary limits for rating. Oops, had not noticed this before.
152
  * Fix: Fuelspeed. Strange! no one ever complained about it.
227
  = 1.1 =
228
  * Fixed the [avg] error, so now it will display average ratings properly.
229
 
230
+ == Upgrade Notice ==
widget.php CHANGED
@@ -6,13 +6,13 @@ if(!class_exists('BhittaniPlugin_kkStarRatings_Widget') && function_exists('kk_s
6
  class BhittaniPlugin_kkStarRatings_Widget extends WP_Widget
7
  {
8
  // Runs when OBJECT DECLARED (Instanciated)
9
- public function BhittaniPlugin_kkStarRatings_Widget()
10
  {
11
  $widget_options = array(
12
  'classname' => 'kk-star-ratings-widget',
13
  'description' => 'Show top rated posts'
14
  );
15
- parent::WP_Widget('BhittaniPlugin_kkStarRatings_Widget', 'kk Star Ratings', $widget_options);
16
  }
17
  // Outputs USER INTERFACE
18
  public function widget($args, $instance)
@@ -25,7 +25,7 @@ class BhittaniPlugin_kkStarRatings_Widget extends WP_Widget
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>';
@@ -40,14 +40,14 @@ class BhittaniPlugin_kkStarRatings_Widget extends WP_Widget
40
  }
41
  echo '</ul>';
42
  // OUTPUT ends
43
-
44
  echo $after_widget;
45
  }
46
  // Updates OPTIONS
47
  /*
48
  public function update()
49
  {
50
-
51
  }
52
  */
53
  // The option FORM
@@ -57,7 +57,7 @@ class BhittaniPlugin_kkStarRatings_Widget extends WP_Widget
57
  <p>
58
  <label for="<?php echo $this->get_field_id('title'); ?>">Title:
59
  <input id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr(!empty($instance['title'])?$instance['title']: 'Top Posts'); ?>" /></label>
60
- </p>
61
  <p>
62
  <label for="<?php echo $this->get_field_id('noofposts'); ?>">No of Posts:
63
  <input id="<?php echo $this->get_field_id('noofposts'); ?>" name="<?php echo $this->get_field_name('noofposts'); ?>" type="text" value="<?php echo esc_attr(!empty($instance['noofposts'])?$instance['noofposts']: '5'); ?>" size="3" /></label>
@@ -101,4 +101,4 @@ if(!function_exists('kk_star_ratings_widget_init'))
101
 
102
  endif;
103
 
104
- ?>
6
  class BhittaniPlugin_kkStarRatings_Widget extends WP_Widget
7
  {
8
  // Runs when OBJECT DECLARED (Instanciated)
9
+ public function __construct()
10
  {
11
  $widget_options = array(
12
  'classname' => 'kk-star-ratings-widget',
13
  'description' => 'Show top rated posts'
14
  );
15
+ parent::__construct('BhittaniPlugin_kkStarRatings_Widget', 'kk Star Ratings', $widget_options);
16
  }
17
  // Outputs USER INTERFACE
18
  public function widget($args, $instance)
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>';
40
  }
41
  echo '</ul>';
42
  // OUTPUT ends
43
+
44
  echo $after_widget;
45
  }
46
  // Updates OPTIONS
47
  /*
48
  public function update()
49
  {
50
+
51
  }
52
  */
53
  // The option FORM
57
  <p>
58
  <label for="<?php echo $this->get_field_id('title'); ?>">Title:
59
  <input id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr(!empty($instance['title'])?$instance['title']: 'Top Posts'); ?>" /></label>
60
+ </p>
61
  <p>
62
  <label for="<?php echo $this->get_field_id('noofposts'); ?>">No of Posts:
63
  <input id="<?php echo $this->get_field_id('noofposts'); ?>" name="<?php echo $this->get_field_name('noofposts'); ?>" type="text" value="<?php echo esc_attr(!empty($instance['noofposts'])?$instance['noofposts']: '5'); ?>" size="3" /></label>
101
 
102
  endif;
103
 
104
+ ?>