Yasr – Yet Another Stars Rating - Version 0.3.6

Version Description

  • Changed permission: now while writing a post or page everyone with a role >
Download this release

Release Info

Developer Dudo
Plugin Icon 128x128 Yasr – Yet Another Stars Rating
Version 0.3.6
Comparing to
See all releases

Code changes from version 0.3.5 to 0.3.6

css/yasr-table-dark.css CHANGED
@@ -38,8 +38,34 @@
38
 
39
  .yasr-top-10-highest-rated tr:nth-child(odd) {
40
  background: #292929;
41
- }
42
  /* Define the background color for all the EVEN background rows */
43
  .yasr-top-10-highest-rated tr:nth-child(even) {
44
  background: #161616;
45
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
  .yasr-top-10-highest-rated tr:nth-child(odd) {
40
  background: #292929;
41
+ }
42
  /* Define the background color for all the EVEN background rows */
43
  .yasr-top-10-highest-rated tr:nth-child(even) {
44
  background: #161616;
45
+ }
46
+
47
+
48
+
49
+ .yasr-top-10-active-users {
50
+ border-spacing: 1px;
51
+ margin-top: 10px;
52
+ margin-bottom: 24px;
53
+ width: 100%;
54
+ }
55
+
56
+ .yasr-top-10-active-users th {
57
+ color: white;
58
+ }
59
+
60
+ .yasr-top-10-active-users td {
61
+ padding: 8px;
62
+ width: 50%;
63
+ }
64
+
65
+ .yasr-top-10-active-users tr:nth-child(odd) {
66
+ background: #292929;
67
+ }
68
+ /* Define the background color for all the EVEN background rows */
69
+ .yasr-top-10-active-users tr:nth-child(even) {
70
+ background: #161616;
71
+ }
css/yasr-table-light.css CHANGED
@@ -38,8 +38,33 @@
38
 
39
  .yasr-top-10-highest-rated tr:nth-child(odd) {
40
  background: #FFFFec;
41
- }
42
  /* Define the background color for all the EVEN background rows */
43
  .yasr-top-10-highest-rated tr:nth-child(even) {
44
  background: #FFFFFF;
45
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
  .yasr-top-10-highest-rated tr:nth-child(odd) {
40
  background: #FFFFec;
41
+ }
42
  /* Define the background color for all the EVEN background rows */
43
  .yasr-top-10-highest-rated tr:nth-child(even) {
44
  background: #FFFFFF;
45
+ }
46
+
47
+
48
+ .yasr-top-10-active-users {
49
+ border-spacing: 1px;
50
+ margin-top: 10px;
51
+ margin-bottom: 24px;
52
+ width: 100%;
53
+ }
54
+
55
+ .yasr-top-10-active-users th {
56
+ color: #555;
57
+ }
58
+
59
+ .yasr-top-10-active-users td {
60
+ padding: 8px;
61
+ width: 50%;
62
+ }
63
+
64
+ .yasr-top-10-active-users tr:nth-child(odd) {
65
+ background: #FFFFec;
66
+ }
67
+ /* Define the background color for all the EVEN background rows */
68
+ .yasr-top-10-active-users tr:nth-child(even) {
69
+ background: #FFFFFF;
70
+ }
js/addButton_tinymcs.js CHANGED
@@ -8,7 +8,7 @@ jQuery(document).ready(function() {
8
  // triggers the thickbox
9
  var width = jQuery(window).width(), W = ( 720 < width ) ? 720 : width;
10
  W = W - 80;
11
- tb_show( 'Insert YASR Shortcode', '#TB_inline?width=' + W + '&inlineId=yasr-form' );
12
 
13
  tinymce.execCommand('mceInsertContent', false, content);
14
  });
8
  // triggers the thickbox
9
  var width = jQuery(window).width(), W = ( 720 < width ) ? 720 : width;
10
  W = W - 80;
11
+ tb_show( 'Insert YASR Shortcode', '#TB_inline?width=' + W + '&&height=700&inlineId=yasr-form' );
12
 
13
  tinymce.execCommand('mceInsertContent', false, content);
14
  });
lib/yasr-ajax-functions.php CHANGED
@@ -25,7 +25,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
25
  exit();
26
  }
27
 
28
- if ( ! current_user_can( 'manage_options' ) ) {
29
  wp_die( __( 'You do not have sufficient permissions to access this page.', 'yasr' ) );
30
  }
31
 
@@ -85,7 +85,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
85
  exit();
86
  }
87
 
88
- if ( ! current_user_can( 'manage_options' ) ) {
89
  wp_die( __( 'You do not have sufficient permissions to access this page.', 'yasr' ) );
90
  }
91
 
@@ -224,7 +224,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
224
  exit();
225
  }
226
 
227
- if ( ! current_user_can( 'manage_options' ) ) {
228
  wp_die( __( 'You do not have sufficient permissions to access this page.', 'yasr' ) );
229
  }
230
 
@@ -361,11 +361,20 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
361
  //End elseif ?>
362
 
363
  <tr>
364
- <th><label for="yasr-id"><?php _e("Top 10 overall ratings"); ?></label></th>
365
  <td><input type="button" class="button-primary" name="yasr-top-10-overall-rating" id="yasr-top-10-overall-rating" value="Insert Top 10 highest rated"/><br />
366
  <small><?php _e("Insert Top 10 highest rated by post author"); ?></small></td>
367
  </tr>
368
 
 
 
 
 
 
 
 
 
 
369
  </table>
370
  </div>
371
 
@@ -424,7 +433,17 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
424
 
425
  // Add shortcode for top 10 by overall ratings
426
  jQuery('#yasr-top-10-overall-rating').on("click", function(){
427
- var shortcode = '[yasr_10_ten_highest_rated]';
 
 
 
 
 
 
 
 
 
 
428
  // inserts the shortcode into the active editor
429
  tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
430
  // closes Thickbox
@@ -464,7 +483,11 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
464
  <div class="yasr-result-step-1">
465
  <?php
466
  if ($check_query_success) {
467
- _e( "Reviews and visitor votes have been successfull imported.", 'yasr'); ?>
 
 
 
 
468
  <br />
469
  <?php _e ("Step2: I will check if you used multiple set and if so I will import it. THIS MAY TAKE A WHILE!", 'yasr'); ?>
470
  <br />
@@ -528,7 +551,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
528
  echo "&nbsp;&nbsp;&nbsp;";
529
  _e( "All votes has been successfull imported.", 'yasr');
530
  echo "<br />";
531
- update_option('yasr-gdstar-imported', '1');
532
  echo "<button href=\"#\" class=\"button-delete\" id=\"end-import\">" . __('Done', 'yasr') . "</button>";
533
 
534
  }
25
  exit();
26
  }
27
 
28
+ if ( ! current_user_can( 'publish_posts' ) ) {
29
  wp_die( __( 'You do not have sufficient permissions to access this page.', 'yasr' ) );
30
  }
31
 
85
  exit();
86
  }
87
 
88
+ if ( ! current_user_can( 'publish_posts' ) ) {
89
  wp_die( __( 'You do not have sufficient permissions to access this page.', 'yasr' ) );
90
  }
91
 
224
  exit();
225
  }
226
 
227
+ if ( ! current_user_can( 'publish_posts' ) ) {
228
  wp_die( __( 'You do not have sufficient permissions to access this page.', 'yasr' ) );
229
  }
230
 
361
  //End elseif ?>
362
 
363
  <tr>
364
+ <th><label for="yasr-10-overall"><?php _e("Top 10 overall ratings"); ?></label></th>
365
  <td><input type="button" class="button-primary" name="yasr-top-10-overall-rating" id="yasr-top-10-overall-rating" value="Insert Top 10 highest rated"/><br />
366
  <small><?php _e("Insert Top 10 highest rated by post author"); ?></small></td>
367
  </tr>
368
 
369
+ <!--
370
+ <tr>
371
+ <th><label for="yasr-10-active-users"><?php // _e("Most active users"); ?></label></th>
372
+ <td><input type="button" class="button-primary" name="yasr-top-10-active-users" id="yasr-top-10-active-users" value="Insert Top 10 most active users"/><br />
373
+ <small><?php // _e("Insert Top 10 active users in visitor ratings"); ?></small></td>
374
+ </tr>
375
+
376
+ -->
377
+
378
  </table>
379
  </div>
380
 
433
 
434
  // Add shortcode for top 10 by overall ratings
435
  jQuery('#yasr-top-10-overall-rating').on("click", function(){
436
+ var shortcode = '[yasr_top_ten_highest_rated]';
437
+ // inserts the shortcode into the active editor
438
+ tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
439
+ // closes Thickbox
440
+ tb_remove();
441
+ });
442
+
443
+
444
+ // Add shortcode for top 10 by overall ratings
445
+ jQuery('#yasr-top-10-active-users').on("click", function(){
446
+ var shortcode = '[yasr_top_ten_active_users]';
447
  // inserts the shortcode into the active editor
448
  tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
449
  // closes Thickbox
483
  <div class="yasr-result-step-1">
484
  <?php
485
  if ($check_query_success) {
486
+ _e( "Reviews and visitor votes have been successfull imported.", 'yasr');
487
+
488
+ update_option('yasr-gdstar-imported', '1');
489
+
490
+ ?>
491
  <br />
492
  <?php _e ("Step2: I will check if you used multiple set and if so I will import it. THIS MAY TAKE A WHILE!", 'yasr'); ?>
493
  <br />
551
  echo "&nbsp;&nbsp;&nbsp;";
552
  _e( "All votes has been successfull imported.", 'yasr');
553
  echo "<br />";
554
+ //update_option('yasr-gdstar-imported', '1');
555
  echo "<button href=\"#\" class=\"button-delete\" id=\"end-import\">" . __('Done', 'yasr') . "</button>";
556
 
557
  }
lib/yasr-functions.php CHANGED
@@ -100,14 +100,14 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
100
  }
101
 
102
  function yasr_metabox_overall_rating_content() {
103
- if ( !current_user_can( 'manage_options' ) ) {
104
  wp_die( __( 'You do not have sufficient permissions to access this page.', 'yasr' ) );
105
  }
106
  include (YASR_ABSOLUTE_PATH . '/yasr-metabox-overall-rating.php');
107
  }
108
 
109
  function yasr_metabox_multiple_rating_content() {
110
- if ( !current_user_can( 'manage_options' ) ) {
111
  wp_die( __( 'You do not have sufficient permissions to access this page.', 'yasr' ) );
112
  }
113
  include (YASR_ABSOLUTE_PATH . '/yasr-metabox-multiple-rating.php');
@@ -305,9 +305,9 @@ function visitor_votes_auto_insert_code () {
305
  }
306
 
307
 
308
- } //End if user is logged in
309
 
310
- //Else mean user is not logged in
311
  else {
312
 
313
 
@@ -323,22 +323,22 @@ function visitor_votes_auto_insert_code () {
323
 
324
  }
325
 
326
- }
327
 
328
 
329
- if($option['text_before_stars'] == 1 && $option['text_before_visitor_rating'] != '') {
330
 
331
- $shortcode_html_tmp = "<div class=\"yasr-container-custom-text-and-visitor-rating\">
332
- <div id=\"yasr-custom-text-before-visitor-rating\">$option[text_before_visitor_rating]</div>" . $shortcode_html . "</div>";
333
 
334
- $shortcode_html = $shortcode_html_tmp;
335
 
336
- }
337
 
338
 
339
- ?>
340
 
341
- <script>
342
  jQuery(document).ready(function() {
343
 
344
  var logged_message_showed = false;
@@ -411,15 +411,15 @@ function visitor_votes_auto_insert_code () {
411
 
412
  } //End else !logged_user_already_rated)
413
 
414
- });
415
 
416
- </script>
417
 
418
- <?php
419
 
420
- } //End if is singular
421
 
422
- return $shortcode_html;
423
 
424
  } //End function shortcode_visitor_votes_callback
425
 
@@ -506,7 +506,7 @@ function visitor_votes_auto_insert_code () {
506
 
507
  $overall_rating=yasr_get_overall_rating();
508
 
509
- if($overall_rating && $overall_rating != '-1') {
510
 
511
  if(is_singular() && is_main_query() ) {
512
  global $post;
100
  }
101
 
102
  function yasr_metabox_overall_rating_content() {
103
+ if ( !current_user_can( 'publish_posts' ) ) {
104
  wp_die( __( 'You do not have sufficient permissions to access this page.', 'yasr' ) );
105
  }
106
  include (YASR_ABSOLUTE_PATH . '/yasr-metabox-overall-rating.php');
107
  }
108
 
109
  function yasr_metabox_multiple_rating_content() {
110
+ if ( !current_user_can( 'publish_posts' ) ) {
111
  wp_die( __( 'You do not have sufficient permissions to access this page.', 'yasr' ) );
112
  }
113
  include (YASR_ABSOLUTE_PATH . '/yasr-metabox-multiple-rating.php');
305
  }
306
 
307
 
308
+ } //End if user is logged in
309
 
310
+ //Else mean user is not logged in
311
  else {
312
 
313
 
323
 
324
  }
325
 
326
+ } //end ($allow_logged_option['allowed_user']==='logged_only')
327
 
328
 
329
+ if($option['text_before_stars'] == 1 && $option['text_before_visitor_rating'] != '') {
330
 
331
+ $shortcode_html_tmp = "<div class=\"yasr-container-custom-text-and-visitor-rating\">
332
+ <div id=\"yasr-custom-text-before-visitor-rating\">$option[text_before_visitor_rating]</div>" . $shortcode_html . "</div>";
333
 
334
+ $shortcode_html = $shortcode_html_tmp;
335
 
336
+ }
337
 
338
 
339
+ ?>
340
 
341
+ <script>
342
  jQuery(document).ready(function() {
343
 
344
  var logged_message_showed = false;
411
 
412
  } //End else !logged_user_already_rated)
413
 
414
+ });
415
 
416
+ </script>
417
 
418
+ <?php
419
 
420
+ return $shortcode_html;
421
 
422
+ } //End if is singular
423
 
424
  } //End function shortcode_visitor_votes_callback
425
 
506
 
507
  $overall_rating=yasr_get_overall_rating();
508
 
509
+ if($overall_rating && $overall_rating != '-1' && $overall_rating != '0.0') {
510
 
511
  if(is_singular() && is_main_query() ) {
512
  global $post;
lib/yasr-shortcode-functions.php CHANGED
@@ -308,13 +308,13 @@ function shortcode_visitor_votes_callback () {
308
 
309
  });
310
 
311
- </script>
312
 
313
- <?php
314
 
315
- } //End if is singular
316
 
317
- return $shortcode_html;
318
 
319
  } //End if auto_insert_enabled
320
 
@@ -351,7 +351,7 @@ function shortcode_multi_set_callback( $atts ) {
351
  $shortcode_html.="</table>";
352
  }
353
 
354
- //If there is not vote for that set...(it should always be there, because when adding new post all set are initialized to -1)
355
  else {
356
  $set_name=$wpdb->get_results("SELECT field_name AS name, field_id AS id
357
  FROM " . YASR_MULTI_SET_FIELDS_TABLE . "
@@ -375,7 +375,7 @@ function shortcode_multi_set_callback( $atts ) {
375
 
376
  /****** Add top 10 highest rated post *****/
377
 
378
- add_shortcode ('yasr_10_ten_highest_rated', 'yasr_top_ten_highest_rated_callback');
379
 
380
  function yasr_top_ten_highest_rated_callback () {
381
 
@@ -400,8 +400,8 @@ function yasr_top_ten_highest_rated_callback () {
400
  $link = get_permalink($result->post_id); //Get permalink from post it
401
 
402
  $shortcode_html .= "<tr>
403
- <td><a href=\"$link\">$post_title</a></td>
404
- <td><div class=\"rateit charts\" data-rateit-starwidth=\"24\" data-rateit-starheight=\"24\" data-rateit-value=\"$result->overall_rating\" data-rateit-step=\"0.1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div></td>
405
  </tr>";
406
 
407
 
@@ -414,11 +414,62 @@ function yasr_top_ten_highest_rated_callback () {
414
  } //end if $query_result
415
 
416
  else {
417
- _e("There was an error while getting result for yasr_10_ten_highest_rated shortcode. Please report it", "yasr");
418
  }
419
 
420
  } //End function
421
 
422
 
423
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
424
  ?>
308
 
309
  });
310
 
311
+ </script>
312
 
313
+ <?php
314
 
315
+ return $shortcode_html;
316
 
317
+ } //End if is singular
318
 
319
  } //End if auto_insert_enabled
320
 
351
  $shortcode_html.="</table>";
352
  }
353
 
354
+ //If there is not vote for that set...i.e. add shortcode without initialize it
355
  else {
356
  $set_name=$wpdb->get_results("SELECT field_name AS name, field_id AS id
357
  FROM " . YASR_MULTI_SET_FIELDS_TABLE . "
375
 
376
  /****** Add top 10 highest rated post *****/
377
 
378
+ add_shortcode ('yasr_top_ten_highest_rated', 'yasr_top_ten_highest_rated_callback');
379
 
380
  function yasr_top_ten_highest_rated_callback () {
381
 
400
  $link = get_permalink($result->post_id); //Get permalink from post it
401
 
402
  $shortcode_html .= "<tr>
403
+ <td width=\"60%\"><a href=\"$link\">$post_title</a></td>
404
+ <td width=\"40%\"><div class=\"rateit charts\" data-rateit-starwidth=\"24\" data-rateit-starheight=\"24\" data-rateit-value=\"$result->overall_rating\" data-rateit-step=\"0.1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div></td>
405
  </tr>";
406
 
407
 
414
  } //end if $query_result
415
 
416
  else {
417
+ _e("You don't have any votes stored", "yasr");
418
  }
419
 
420
  } //End function
421
 
422
 
423
 
424
+ /****** Add top 10 most active user *****/
425
+
426
+ add_shortcode ('yasr_top_ten_active_users', 'yasr_top_ten_active_users_callback');
427
+
428
+ function yasr_top_ten_active_users_callback () {
429
+
430
+ global $wpdb;
431
+
432
+ $query_result = $wpdb->get_results("SELECT COUNT( user_id ) as total_count, user_id as user
433
+ FROM " . YASR_LOG_TABLE . "
434
+ GROUP BY user_id
435
+ ORDER BY ( total_count ) DESC
436
+ LIMIT 10");
437
+
438
+ if ($query_result) {
439
+
440
+ $shortcode_html = "
441
+ <table class=\"yasr-top-10-active-users\">
442
+ <tr>
443
+ <th>UserName</th>
444
+ <th>Votes Number</th>
445
+ </tr>
446
+ ";
447
+
448
+ foreach ($query_result as $result) {
449
+
450
+ $user_data = get_userdata( $result->user );
451
+
452
+ $user_profile = the_author_meta( 'user_url', $result->user );
453
+
454
+ if (!$user_data) {
455
+ $user_data = new stdClass;
456
+ $user_data->user_login = 'Anonymous';
457
+ }
458
+
459
+ $shortcode_html .= "<tr>
460
+ <td><a href=\"$user_profile\">$user_data->user_login</a></td>
461
+ <td><a href=\"#\">$result->total_count</a></td>
462
+ </tr>";
463
+ }
464
+
465
+
466
+ $shortcode_html .= "</table>";
467
+
468
+ return $shortcode_html;
469
+
470
+ }
471
+
472
+
473
+ } //End function
474
+
475
  ?>
readme.txt CHANGED
@@ -3,7 +3,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
3
  Tags: Rating, Review, Star, Snippet, Rich snippet, Schema, Schema.org, Serp
4
  Requires at least: 3.5
5
  Tested up to: 3.9.1
6
- Stable tag: 0.3.5
7
  License: GPL2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -48,6 +48,10 @@ If with gd-star-rating you're using a different number of stars from the default
48
 
49
  == Changelog ==
50
 
 
 
 
 
51
  = 0.3.5 =
52
  * Added a new dark style to better suite dark theme
53
  * Added a new custom text to show when a non logged user has voted
3
  Tags: Rating, Review, Star, Snippet, Rich snippet, Schema, Schema.org, Serp
4
  Requires at least: 3.5
5
  Tested up to: 3.9.1
6
+ Stable tag: 0.3.6
7
  License: GPL2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
48
 
49
  == Changelog ==
50
 
51
+ = 0.3.6 =
52
+ * Changed permission: now while writing a post or page everyone with a role >= author can insert votes
53
+ * Some bugfixes
54
+
55
  = 0.3.5 =
56
  * Added a new dark style to better suite dark theme
57
  * Added a new custom text to show when a non logged user has voted
yet-another-stars-rating.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Yet Another Stars Rating
4
  * Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
5
  * Description: Rating system with rich snippets
6
- * Version: 0.3.5
7
  * Author: Dario Curvino
8
  * Author URI: http://profiles.wordpress.org/dudo/
9
  * License: GPL2
@@ -28,7 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
28
  */
29
 
30
 
31
- define('YASR_VERSION_NUM', '0.3.5');
32
 
33
  //Plugin absolute path
34
  define( "YASR_ABSOLUTE_PATH", dirname(__FILE__) );
3
  * Plugin Name: Yet Another Stars Rating
4
  * Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
5
  * Description: Rating system with rich snippets
6
+ * Version: 0.3.6
7
  * Author: Dario Curvino
8
  * Author URI: http://profiles.wordpress.org/dudo/
9
  * License: GPL2
28
  */
29
 
30
 
31
+ define('YASR_VERSION_NUM', '0.3.6');
32
 
33
  //Plugin absolute path
34
  define( "YASR_ABSOLUTE_PATH", dirname(__FILE__) );