Yasr – Yet Another Stars Rating - Version 0.2.10

Version Description

  • Added loading image when ajax is called
  • Added "select button" when choosing a multi set
Download this release

Release Info

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

Code changes from version 0.2.9 to 0.2.10

lib/yasr-ajax-functions.php CHANGED
@@ -95,96 +95,112 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
95
 
96
  //If this is a new post or post has no multi values data
97
  if (!$set_values) {
98
- echo "<p>";
99
 
100
- _e('Choose a vote for each element', 'yasr');
101
 
102
- echo "
103
 
104
- <br /> <br />
105
 
106
- <table class=\"yasr_table_multi_set_admin\">";
107
- //Get Set fields name
108
- $set_name=$wpdb->get_results("SELECT field_name AS name, field_id AS id
109
- FROM " . YASR_MULTI_SET_FIELDS_TABLE . "
110
- WHERE parent_set_id=$set_type
111
- ORDER BY field_id ASC");
112
 
113
- foreach ($set_name as $name) {
114
 
115
- //get the highest id in table
116
- $highest_id=$wpdb->get_results("SELECT id FROM " . YASR_MULTI_SET_VALUES_TABLE . " ORDER BY id DESC LIMIT 1 ");
117
-
118
- if (!$highest_id) {
119
- $new_id=0;
120
- }
121
 
122
- foreach ($highest_id as $id) {
123
- $new_id=$id->id + 1;
124
- }
125
-
126
- $query_success=$wpdb->replace(
127
- YASR_MULTI_SET_VALUES_TABLE,
128
- array (
129
- 'id'=>$new_id,
130
- 'post_id'=>$post_id,
131
- 'field_id'=>$name->id,
132
- 'votes'=>'-1',
133
- 'set_type'=>$set_type
134
- ),
135
- array ("%d", "%d", "%d", "%s", "%d")
136
- );
137
-
138
- echo "<tr> <td>";
139
- echo "$name->name </td>";
140
- echo "<td> <div class=\"rateit bigstars multi\" id=\"$name->id\" data-rateit-value=\"\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-step=\"0.5\" data-rateit-resetable=\"true\" data-rateit-readonly=\"false\"></div> </td>";
141
- echo "</tr>";
142
  }
143
- echo "</table>
144
 
145
- </p>";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
 
147
- echo "<p>";
148
 
149
- _e("Remember to insert this shortcode", "yasr");
150
- echo "<strong> [yasr_multiset setid=$set_type] </strong>";
151
- _e("where you want to display this multi set", "yasr");
152
 
153
- echo "</p>";
 
 
 
 
154
 
155
  } //
156
 
157
  //else means that post already has vote and here I show it
158
  else {
 
 
 
 
 
159
 
160
- _e('Choose a vote for every element', 'yasr');
161
 
162
- echo "<table class=\"yasr_table_multi_set_admin\">";
163
- foreach ($set_values as $set_content) {
164
- echo "<tr><td width=\"50%\">$set_content->name </td>";
 
 
 
 
 
 
 
 
 
 
165
 
166
- $integer_vote = floor($set_content->vote);
167
- if($set_content->vote < ($integer_vote+0.3)) {
168
- $set_content->vote = $integer_vote;
169
- }
170
- elseif ($set_content->vote >= ($integer_vote+0.3) AND $set_content->vote < ($integer_vote+0.7)) {
171
- $set_content->vote = $integer_vote+0.5;
172
- }
173
- elseif ($set_content->vote >= ($integer_vote+0.7)) {
174
- $set_content->vote = $integer_vote+1;
175
- }
176
 
177
- echo "<td width=\"50%\"> <div class=\"rateit bigstars multi\" id=\"$set_content->id\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$set_content->vote\" data-rateit-step=\"0.5\" data-rateit-resetable=\"true\" data-rateit-readonly=\"false\"></div> </td></tr>";
178
- } //End foreach
179
- echo "</table>";
180
 
181
- echo "<p>";
182
 
183
- _e("Remember to insert this shortcode", "yasr");
184
- echo "<strong> [yasr_multiset setid=$set_type] </strong>";
185
- _e("where you want to display this multi set", "yasr");
186
 
187
- echo "</p>";
 
 
 
 
 
 
188
  }
189
 
190
  die();
@@ -682,6 +698,8 @@ add_action( 'wp_ajax_yasr_change_log_page', 'yasr_change_log_page_callback' );
682
  echo "...&nbsp;&nbsp;<button class=\"yasr-log-page-num\" value=\"$num_of_pages\">Last &raquo;</button>&nbsp;&nbsp;";
683
  }
684
 
 
 
685
  }
686
 
687
  echo "
@@ -794,7 +812,7 @@ add_action( 'wp_ajax_yasr_change_log_page', 'yasr_change_log_page_callback' );
794
 
795
  elseif ($new_row_result) {
796
  echo "<div class=\"rateit bigstars\" id=\"yasr_rateit_user_votes_voted\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$rating\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
797
- <br /><strong>". __("Vote Saved" , "yasr") . "</strong><br />Rating $rating / 5 (1 " . __("vote casts", "yasr") . ")";
798
  }
799
 
800
  die(); // this is required to return a proper result
95
 
96
  //If this is a new post or post has no multi values data
97
  if (!$set_values) {
98
+ echo "<p>";
99
 
100
+ _e('Choose a vote for each element', 'yasr');
101
 
102
+ echo "
103
 
104
+ <br /> <br />
105
 
106
+ <table class=\"yasr_table_multi_set_admin\">";
107
+ //Get Set fields name
108
+ $set_name=$wpdb->get_results("SELECT field_name AS name, field_id AS id
109
+ FROM " . YASR_MULTI_SET_FIELDS_TABLE . "
110
+ WHERE parent_set_id=$set_type
111
+ ORDER BY field_id ASC");
112
 
113
+ foreach ($set_name as $name) {
114
 
115
+ //get the highest id in table
116
+ $highest_id=$wpdb->get_results("SELECT id FROM " . YASR_MULTI_SET_VALUES_TABLE . " ORDER BY id DESC LIMIT 1 ");
117
+
118
+ if (!$highest_id) {
119
+ $new_id=0;
120
+ }
121
 
122
+ foreach ($highest_id as $id) {
123
+ $new_id=$id->id + 1;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  }
 
125
 
126
+ $query_success=$wpdb->replace(
127
+ YASR_MULTI_SET_VALUES_TABLE,
128
+ array (
129
+ 'id'=>$new_id,
130
+ 'post_id'=>$post_id,
131
+ 'field_id'=>$name->id,
132
+ 'votes'=>'-1',
133
+ 'set_type'=>$set_type
134
+ ),
135
+ array ("%d", "%d", "%d", "%s", "%d")
136
+ );
137
+
138
+ echo "<tr> <td>";
139
+ echo "$name->name </td>";
140
+ echo "<td>
141
+ <div class=\"rateit bigstars multi\" id=\"$name->id\" data-rateit-value=\"\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-step=\"0.5\" data-rateit-resetable=\"true\" data-rateit-readonly=\"false\"></div>
142
+
143
+ <span id=\"yasr-loader-multi-set-field-$set_content->id\" style=\"display:none;\" >&nbsp;<img src=\"" . YASR_IMG_DIR . "/loader.gif\" ></span>
144
+ </td>
145
+ </tr>";
146
+
147
+
148
+ } //End foreach
149
+
150
+ echo "</table>
151
 
152
+ </p>";
153
 
154
+ echo "<p>";
 
 
155
 
156
+ _e("Remember to insert this shortcode", "yasr");
157
+ echo "<strong> [yasr_multiset setid=$set_type] </strong>";
158
+ _e("where you want to display this multi set", "yasr");
159
+
160
+ echo "</p>";
161
 
162
  } //
163
 
164
  //else means that post already has vote and here I show it
165
  else {
166
+ _e('Choose a vote for every element', 'yasr');
167
+
168
+ echo "<table class=\"yasr_table_multi_set_admin\">";
169
+
170
+ foreach ($set_values as $set_content) {
171
 
172
+ echo "<tr><td width=\"50%\">$set_content->name </td>";
173
 
174
+ $integer_vote = floor($set_content->vote);
175
+ if($set_content->vote < ($integer_vote+0.3)) {
176
+ $set_content->vote = $integer_vote;
177
+ }
178
+ elseif ($set_content->vote >= ($integer_vote+0.3) AND $set_content->vote < ($integer_vote+0.7)) {
179
+ $set_content->vote = $integer_vote+0.5;
180
+ }
181
+ elseif ($set_content->vote >= ($integer_vote+0.7)) {
182
+ $set_content->vote = $integer_vote+1;
183
+ }
184
+
185
+ echo "<td width=\"50%\">
186
+ <div class=\"rateit bigstars multi\" id=\"$set_content->id\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$set_content->vote\" data-rateit-step=\"0.5\" data-rateit-resetable=\"true\" data-rateit-readonly=\"false\"></div>
187
 
188
+ <span id=\"yasr-loader-multi-set-field-$set_content->id\" style=\"display:none;\" >&nbsp;<img src=\"" . YASR_IMG_DIR . "/loader.gif\"></span>
189
+ </td>
190
+ </tr>";
 
 
 
 
 
 
 
191
 
 
 
 
192
 
193
+ } //End foreach
194
 
195
+ echo "</table>";
 
 
196
 
197
+ echo "<p>";
198
+
199
+ _e("Remember to insert this shortcode", "yasr");
200
+ echo "<strong> [yasr_multiset setid=$set_type] </strong>";
201
+ _e("where you want to display this multi set", "yasr");
202
+
203
+ echo "</p>";
204
  }
205
 
206
  die();
698
  echo "...&nbsp;&nbsp;<button class=\"yasr-log-page-num\" value=\"$num_of_pages\">Last &raquo;</button>&nbsp;&nbsp;";
699
  }
700
 
701
+ echo "<span id=\"yasr-loader-log-metabox\" style=\"display:none;\" >&nbsp;<img src=\"" . YASR_IMG_DIR . "/loader.gif\" ></span>";
702
+
703
  }
704
 
705
  echo "
812
 
813
  elseif ($new_row_result) {
814
  echo "<div class=\"rateit bigstars\" id=\"yasr_rateit_user_votes_voted\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$rating\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
815
+ <br /><strong>". __("Vote Saved" , "yasr") . "</strong><br />Rating $rating / 5 (1 " . __("vote cast", "yasr") . ")";
816
  }
817
 
818
  die(); // this is required to return a proper result
lib/yasr-db-functions.php CHANGED
@@ -280,6 +280,9 @@ add_action( 'plugins_loaded', 'add_action_dashboard_widget_log' );
280
  }
281
 
282
  echo "...&nbsp;&nbsp;<button class=\"yasr-log-pagenum\" value=\"$num_of_pages\">Last &raquo;</button>&nbsp;&nbsp;";
 
 
 
283
  }
284
 
285
  echo "
@@ -297,6 +300,8 @@ add_action( 'plugins_loaded', 'add_action_dashboard_widget_log' );
297
  //Log
298
  jQuery('.yasr-log-pagenum').on('click', function() {
299
 
 
 
300
  var data = {
301
  action : 'yasr_change_log_page',
302
  pagenum: jQuery(this).val(),
@@ -304,6 +309,7 @@ add_action( 'plugins_loaded', 'add_action_dashboard_widget_log' );
304
  };
305
 
306
  jQuery.post(ajaxurl, data, function(response) {
 
307
  jQuery('#yasr-log-container').html(response);
308
  });
309
 
@@ -313,13 +319,15 @@ add_action( 'plugins_loaded', 'add_action_dashboard_widget_log' );
313
 
314
  jQuery('.yasr-log-page-num').on('click', function() {
315
 
 
 
316
  var data = {
317
  action : 'yasr_change_log_page',
318
  pagenum: jQuery(this).val(),
319
-
320
  };
321
 
322
  jQuery.post(ajaxurl, data, function(response) {
 
323
  jQuery('#yasr-log-container').html(response);
324
  });
325
 
280
  }
281
 
282
  echo "...&nbsp;&nbsp;<button class=\"yasr-log-pagenum\" value=\"$num_of_pages\">Last &raquo;</button>&nbsp;&nbsp;";
283
+
284
+ echo "<span id=\"yasr-loader-log-metabox\" style=\"display:none\">&nbsp;<img src=\"" . YASR_IMG_DIR . "/loader.gif\" ></span>";
285
+
286
  }
287
 
288
  echo "
300
  //Log
301
  jQuery('.yasr-log-pagenum').on('click', function() {
302
 
303
+ jQuery('#yasr-loader-log-metabox').show();
304
+
305
  var data = {
306
  action : 'yasr_change_log_page',
307
  pagenum: jQuery(this).val(),
309
  };
310
 
311
  jQuery.post(ajaxurl, data, function(response) {
312
+ jQuery('yasr-loader-log-metabox').hide();
313
  jQuery('#yasr-log-container').html(response);
314
  });
315
 
319
 
320
  jQuery('.yasr-log-page-num').on('click', function() {
321
 
322
+ jQuery('#yasr-loader-log-metabox').show();
323
+
324
  var data = {
325
  action : 'yasr_change_log_page',
326
  pagenum: jQuery(this).val(),
 
327
  };
328
 
329
  jQuery.post(ajaxurl, data, function(response) {
330
+ jQuery('yasr-loader-log-metabox').hide();
331
  jQuery('#yasr-log-container').html(response);
332
  });
333
 
lib/yasr-settings-functions.php CHANGED
@@ -200,6 +200,9 @@ function yasr_edit_multi_form() {
200
  <option value="<?php echo $name->set_id ?>"><?php echo $name->set_name ?></option>
201
  <?php } //End foreach ?>
202
  </select>
 
 
 
203
 
204
  </div>
205
 
200
  <option value="<?php echo $name->set_id ?>"><?php echo $name->set_name ?></option>
201
  <?php } //End foreach ?>
202
  </select>
203
+
204
+ <button href="#" class="button-delete" id="yasr-button-select-set-edit-form"><?php _e("Select"); ?></button>
205
+
206
 
207
  </div>
208
 
lib/yasr-shortcode-functions.php CHANGED
@@ -50,11 +50,15 @@ function shortcode_visitor_votes_callback () {
50
  }
51
  }
52
 
53
- $medium_rating=round($medium_rating, 1);
 
 
 
 
54
 
55
  if ($votes_number>0) {
56
- $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit bigstars\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\">
57
- </div><br /> " . __("Average Rating", "yasr") . " $medium_rating / 5 (" . __("$votes_number votes casts" , "yasr") . ")</div>";
58
  }
59
 
60
  else {
@@ -63,10 +67,10 @@ function shortcode_visitor_votes_callback () {
63
  }
64
 
65
 
66
- ?>
67
 
68
- <script>
69
- jQuery(document).ready(function() {
70
 
71
  var tooltipvalues = ['bad', 'poor', 'ok', 'good', 'super'];
72
  jQuery("#yasr_rateit_visitor_votes").bind('over', function (event, value) { jQuery(this).attr('title', tooltipvalues[value-1]); });
@@ -79,25 +83,27 @@ function shortcode_visitor_votes_callback () {
79
 
80
  jQuery('#yasr_rateit_visitor_votes').on('rated', function() {
81
  var el = jQuery(this);
82
- var value = el.rateit('value');
83
- var value = value.toFixed(1); //
84
- var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
85
-
86
- var data = {
87
- action: 'yasr_send_visitor_rating',
88
- rating: value,
89
- post_id: postid,
 
 
90
  nonce_visitor: "<?php echo "$ajax_nonce_visitor"; ?>"
91
- };
92
 
93
- //Send value to the Server
94
- jQuery.post(ajaxurl, data, function(response) {
95
- jQuery('#yasr_visitor_votes').html(response);
96
- jQuery('.rateit').rateit();
97
  //Create a cookie to disable double vote
98
  jQuery.cookie(cookiename, value, { expires : 360 });
99
  }) ;
100
- });
101
  } //End if (!jQuery.cookie(cookiename))
102
 
103
  //Else user cannot vote
@@ -121,7 +127,7 @@ function shortcode_visitor_votes_callback () {
121
 
122
  });
123
 
124
- </script>
125
 
126
  <?php
127
 
50
  }
51
  }
52
 
53
+ $image = YASR_IMG_DIR . "/loader.gif";
54
+
55
+ $loader_html = "<div id=\"loader-visitor-rating\" >&nbsp; " . __("Loading, please wait","yasr") . " <img src= \" $image \"></div>";
56
+
57
+ $medium_rating=round($medium_rating, 1);
58
 
59
  if ($votes_number>0) {
60
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit bigstars\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\">
61
+ </div><br /> " . __("Average Rating", "yasr") . " $medium_rating / 5 (" . __("$votes_number votes casts" , "yasr") . ")</div>";
62
  }
63
 
64
  else {
67
  }
68
 
69
 
70
+ ?>
71
 
72
+ <script>
73
+ jQuery(document).ready(function() {
74
 
75
  var tooltipvalues = ['bad', 'poor', 'ok', 'good', 'super'];
76
  jQuery("#yasr_rateit_visitor_votes").bind('over', function (event, value) { jQuery(this).attr('title', tooltipvalues[value-1]); });
83
 
84
  jQuery('#yasr_rateit_visitor_votes').on('rated', function() {
85
  var el = jQuery(this);
86
+ var value = el.rateit('value');
87
+ var value = value.toFixed(1); //
88
+ var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
89
+
90
+ jQuery('#yasr_visitor_votes').html( ' <?php echo "$loader_html" ?> ');
91
+
92
+ var data = {
93
+ action: 'yasr_send_visitor_rating',
94
+ rating: value,
95
+ post_id: postid,
96
  nonce_visitor: "<?php echo "$ajax_nonce_visitor"; ?>"
97
+ };
98
 
99
+ //Send value to the Server
100
+ jQuery.post(ajaxurl, data, function(response) {
101
+ jQuery('#yasr_visitor_votes').html(response);
102
+ jQuery('.rateit').rateit();
103
  //Create a cookie to disable double vote
104
  jQuery.cookie(cookiename, value, { expires : 360 });
105
  }) ;
106
+ });
107
  } //End if (!jQuery.cookie(cookiename))
108
 
109
  //Else user cannot vote
127
 
128
  });
129
 
130
+ </script>
131
 
132
  <?php
133
 
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.2.9
7
  License: GPL2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -49,6 +49,10 @@ If with gd-star-rating you're using a different number of stars from the default
49
 
50
  == Changelog ==
51
 
 
 
 
 
52
  = 0.2.9 =
53
  * Settings page has been rewritten: now it use multi tab navigation
54
 
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.2.10
7
  License: GPL2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
49
 
50
  == Changelog ==
51
 
52
+ = 0.2.10 =
53
+ * Added loading image when ajax is called
54
+ * Added "select button" when choosing a multi set
55
+
56
  = 0.2.9 =
57
  * Settings page has been rewritten: now it use multi tab navigation
58
 
yasr-metabox-multiple-rating.php CHANGED
@@ -16,79 +16,101 @@ if ($n_multi_set>1) {
16
 
17
  ?>
18
 
19
- <br />
20
- <select id ="select_set">
21
- <?php foreach ($multi_set as $name) { ?>
22
- <option value="<?php echo $name->set_id ?>"><?php echo $name->set_name ?></option>
23
- <?php } //End foreach ?>
24
- </select>
25
-
26
-
27
- <script>
28
- // --------------IF multiple set are found -------------------
29
-
30
- jQuery('#select_set').on("change", function() {
31
-
32
- var postid = <?php the_ID(); ?>;
33
-
34
- var data_id = {
35
- action: 'yasr_send_id_nameset',
36
- set_id: jQuery(this).val(),
37
- post_id: postid
38
- }
39
-
40
- //Send value to the Server
41
- jQuery.post(ajaxurl, data_id, function(response) {
42
- jQuery('#yasr_rateit_multi_rating').html(response);
43
- jQuery('.rateit').rateit();
44
-
45
- jQuery('.multi').on('rated', function() {
46
- var el = jQuery(this);
47
- var value = el.rateit('value');
48
- var value = value.toFixed(1);
49
- var idField = el.attr('id');
50
- var setType = jQuery('#select_set').val();
51
-
52
- var data = {
53
- action: 'yasr_send_id_field_with_vote',
54
- nonce: "<?php echo "$ajax_nonce_multi"; ?>",
55
- rating: value,
56
- post_id: postid,
57
- id_field: idField,
58
- set_type: setType
59
- };
60
-
61
- //Send value to the Server
62
- jQuery.post(ajaxurl, data);
63
- });
64
-
65
-
66
- jQuery('.multi').on('reset', function() {
67
- var el = jQuery(this);
68
- var value = '0';
69
- var idField = el.attr('id');
70
- var setType = jQuery('#select_set').val();
71
-
72
- var data = {
73
- action: 'yasr_send_id_field_with_vote',
74
- nonce: "<?php echo "$ajax_nonce_multi"; ?>",
75
- rating: value,
76
- post_id: postid,
77
- id_field: idField,
78
- set_type: setType
79
- };
80
-
81
- //Send value to the Server
82
- jQuery.post(ajaxurl, data);
83
- });
84
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  });
86
- });
87
 
88
- </script>
 
89
 
 
90
 
91
- <?php
92
  } //End if
93
 
94
  elseif ($n_multi_set==1) {
@@ -96,79 +118,88 @@ elseif ($n_multi_set==1) {
96
  $set_id = $find_id->set_id;
97
  }
98
 
99
- ?>
100
 
101
- <script>
102
- // --------------IF we're using just 1 set -------------------
103
- jQuery( document ).ready(function() {
104
-
105
- var postid = <?php the_ID(); ?>;
106
-
107
- var data_id = {
108
- action: 'yasr_send_id_nameset',
109
- set_id: <?php echo $set_id ?>,
110
- post_id: postid
111
- }
112
-
113
- //Send value to the Server
114
- jQuery.post(ajaxurl, data_id, function(response) {
115
- jQuery('#yasr_rateit_multi_rating').html(response);
116
- jQuery('.rateit').rateit();
117
-
118
- jQuery('.multi').on('rated', function() {
119
- var el = jQuery(this);
120
- var value = el.rateit('value');
121
- var value = value.toFixed(1);
122
- var idField = el.attr('id');
123
-
124
- var data = {
125
- action: 'yasr_send_id_field_with_vote',
126
- nonce: "<?php echo "$ajax_nonce_multi"; ?>",
127
- rating: value,
128
- post_id: postid,
129
- id_field: idField,
130
- set_type: <?php echo $set_id ?>
131
- };
132
-
133
- //Send value to the Server
134
- jQuery.post(ajaxurl, data);
135
-
136
- });
137
-
138
- jQuery('.multi').on('reset', function() {
139
- var el = jQuery(this);
140
- var value = '0';
141
- var idField = el.attr('id');
142
- var setType = <?php echo $set_id ?>
143
-
144
- var data = {
145
- action: 'yasr_send_id_field_with_vote',
146
- nonce: "<?php echo "$ajax_nonce_multi"; ?>",
147
- rating: value,
148
- post_id: postid,
149
- id_field: idField,
150
- set_type: setType
151
- };
152
-
153
- //Send value to the Server
154
- jQuery.post(ajaxurl, data);
155
- });
156
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  });
158
- });
159
 
160
- </script>
161
 
162
- <?php
163
 
164
  } //End elseif ($n_multi_set==1)
165
 
166
- ?>
167
 
168
- <div>
169
- <p>
170
- <span id="yasr_rateit_multi_rating">
171
 
172
- </span>
173
- </p>
174
- </div>
16
 
17
  ?>
18
 
19
+ <br />
20
+ <select id ="select_set">
21
+ <?php foreach ($multi_set as $name) { ?>
22
+ <option value="<?php echo $name->set_id ?>"><?php echo $name->set_name ?></option>
23
+ <?php } //End foreach ?>
24
+ </select>
25
+
26
+ <button href="#" class="button-delete" id="yasr-button-select-set"><?php _e("Select"); ?></button>
27
+
28
+ <span id="yasr-loader-select-multi-set" style="display:none;" >&nbsp;<img src="<?php echo YASR_IMG_DIR . "/loader.gif" ?>">
29
+ </span>
30
+
31
+ <script>
32
+
33
+ // --------------IF multiple set are found -------------------
34
+
35
+
36
+ jQuery('#yasr-button-select-set').on("click", function() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
+ var postid = <?php the_ID(); ?>;
39
+
40
+ var data_id = {
41
+ action: 'yasr_send_id_nameset',
42
+ set_id: jQuery('#select_set').val(),
43
+ post_id: postid
44
+ }
45
+
46
+ jQuery("#yasr-loader-select-multi-set").show();
47
+
48
+ //Send value to the Server
49
+ jQuery.post(ajaxurl, data_id, function(response) {
50
+ jQuery("#yasr-loader-select-multi-set").hide();
51
+ jQuery('#yasr_rateit_multi_rating').html(response);
52
+ jQuery('.rateit').rateit();
53
+
54
+ jQuery('.multi').on('rated', function() {
55
+ var el = jQuery(this);
56
+ var value = el.rateit('value');
57
+ var value = value.toFixed(1);
58
+ var idField = el.attr('id');
59
+ var setType = jQuery('#select_set').val();
60
+
61
+ jQuery("#yasr-loader-multi-set-field-"+idField).show();
62
+
63
+ var data = {
64
+ action: 'yasr_send_id_field_with_vote',
65
+ nonce: "<?php echo "$ajax_nonce_multi"; ?>",
66
+ rating: value,
67
+ post_id: postid,
68
+ id_field: idField,
69
+ set_type: setType
70
+ };
71
+
72
+ //Send value to the Server
73
+ jQuery.post(ajaxurl, data, function() {
74
+ jQuery("#yasr-loader-multi-set-field-"+idField).hide();
75
+ });
76
+ });
77
+
78
+
79
+ jQuery('.multi').on('reset', function() {
80
+ var el = jQuery(this);
81
+ var value = '0';
82
+ var idField = el.attr('id');
83
+ var setType = jQuery('#select_set').val();
84
+
85
+ jQuery("#yasr-loader-multi-set-field-"+idField).show();
86
+
87
+ var data = {
88
+ action: 'yasr_send_id_field_with_vote',
89
+ nonce: "<?php echo "$ajax_nonce_multi"; ?>",
90
+ rating: value,
91
+ post_id: postid,
92
+ id_field: idField,
93
+ set_type: setType
94
+ };
95
+
96
+ //Send value to the Server
97
+ jQuery.post(ajaxurl, data, function() {
98
+ jQuery("#yasr-loader-multi-set-field-"+idField).hide();
99
+ });
100
+ });
101
+
102
+ });
103
+
104
+ return false; // prevent default click action from happening!
105
+ e.preventDefault(); // same thing as above
106
+
107
  });
 
108
 
109
+ </script>
110
+
111
 
112
+ <?php
113
 
 
114
  } //End if
115
 
116
  elseif ($n_multi_set==1) {
118
  $set_id = $find_id->set_id;
119
  }
120
 
121
+ ?>
122
 
123
+ <script>
124
+ // --------------IF we're using just 1 set -------------------
125
+ jQuery( document ).ready(function() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
 
127
+ var postid = <?php the_ID(); ?>;
128
+
129
+ var data_id = {
130
+ action: 'yasr_send_id_nameset',
131
+ set_id: <?php echo $set_id ?>,
132
+ post_id: postid
133
+ }
134
+
135
+ //Send value to the Server
136
+ jQuery.post(ajaxurl, data_id, function(response) {
137
+ jQuery('#yasr_rateit_multi_rating').html(response);
138
+ jQuery('.rateit').rateit();
139
+
140
+ jQuery('.multi').on('rated', function() {
141
+ var el = jQuery(this);
142
+ var value = el.rateit('value');
143
+ var value = value.toFixed(1);
144
+ var idField = el.attr('id');
145
+
146
+ jQuery("#yasr-loader-multi-set-field-"+idField).show();
147
+
148
+ var data = {
149
+ action: 'yasr_send_id_field_with_vote',
150
+ nonce: "<?php echo "$ajax_nonce_multi"; ?>",
151
+ rating: value,
152
+ post_id: postid,
153
+ id_field: idField,
154
+ set_type: <?php echo $set_id ?>
155
+ };
156
+
157
+ //Send value to the Server
158
+ jQuery.post(ajaxurl, data, function() {
159
+ jQuery("#yasr-loader-multi-set-field-"+idField).hide();
160
+ });
161
+
162
+ });
163
+
164
+ jQuery('.multi').on('reset', function() {
165
+ var el = jQuery(this);
166
+ var value = '0';
167
+ var idField = el.attr('id');
168
+ var setType = <?php echo $set_id ?>
169
+
170
+ jQuery("#yasr-loader-multi-set-field-"+idField).show();
171
+
172
+ var data = {
173
+ action: 'yasr_send_id_field_with_vote',
174
+ nonce: "<?php echo "$ajax_nonce_multi"; ?>",
175
+ rating: value,
176
+ post_id: postid,
177
+ id_field: idField,
178
+ set_type: setType
179
+ };
180
+
181
+ //Send value to the Server
182
+ jQuery.post(ajaxurl, data, function() {
183
+ jQuery("#yasr-loader-multi-set-field-"+idField).hide();
184
+ });
185
+
186
+ });
187
+
188
+ });
189
  });
 
190
 
191
+ </script>
192
 
193
+ <?php
194
 
195
  } //End elseif ($n_multi_set==1)
196
 
197
+ ?>
198
 
199
+ <div>
200
+ <p>
201
+ <span id="yasr_rateit_multi_rating">
202
 
203
+ </span>
204
+ </p>
205
+ </div>
yasr-metabox-overall-rating.php CHANGED
@@ -21,6 +21,9 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
21
  <div class="rateit bigstars" id="yasr_rateit_overall" data-rateit-starwidth="32" data-rateit-starheight="32" data-rateit-value="<?php echo $overall_rating ?>" data-rateit-step="0.1" data-rateit-resetable="true" data-rateit-readonly="false">
22
  </div>
23
 
 
 
 
24
  </p>
25
 
26
  <div>
@@ -36,43 +39,49 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
36
 
37
  ?>
38
  <script>
39
- jQuery(document).ready(function($) {
40
- $('#yasr_rateit_overall').on('rated', function() {
41
- var el = jQuery(this);
42
- var postid = <?php the_ID(); ?>;
43
- var value = el.rateit('value');
44
- var value = value.toFixed(1); //
45
-
46
- var data = {
47
- action: 'yasr_send_overall_rating',
48
- nonce: "<?php echo "$ajax_nonce_overall"; ?>",
49
- rating: value,
50
- post_id: postid
51
- };
52
-
53
- //Send value to the Server
54
- $.post(ajaxurl, data, function(response) {
55
- jQuery('#yasr_rateit_overall_value').text('You\'ve rated it: ' + value);
56
- }) ;
57
- });
58
-
59
- $('#yasr_rateit_overall').on('reset', function() {
60
- var el = jQuery(this);
61
- var postid = <?php the_ID(); ?>;
62
- var value = '-1';
63
-
64
- var data = {
65
- action: 'yasr_send_overall_rating',
66
- nonce: "<?php echo "$ajax_nonce_overall"; ?>",
67
- rating: value,
68
- post_id: postid
69
- };
70
-
71
- //Send value to the Server
72
- $.post(ajaxurl, data, function(response) {
73
- jQuery('#yasr_rateit_overall_value').text('You\'ve reset the vote');
74
- }) ;
75
- });
 
 
 
 
 
 
76
 
77
  });
78
  </script>
21
  <div class="rateit bigstars" id="yasr_rateit_overall" data-rateit-starwidth="32" data-rateit-starheight="32" data-rateit-value="<?php echo $overall_rating ?>" data-rateit-step="0.1" data-rateit-resetable="true" data-rateit-readonly="false">
22
  </div>
23
 
24
+ <div id="loader-overall-rating" style="display:none;" >&nbsp;<?php _e("Loading, please wait","yasr"); ?><img src="<?php echo YASR_IMG_DIR . "/loader.gif" ?>">
25
+ </div>
26
+
27
  </p>
28
 
29
  <div>
39
 
40
  ?>
41
  <script>
42
+ jQuery(document).ready(function() {
43
+
44
+ jQuery('#yasr_rateit_overall').on('rated', function() {
45
+ jQuery('#loader-overall-rating').show();
46
+ var el = jQuery(this);
47
+ var postid = <?php the_ID(); ?>;
48
+ var value = el.rateit('value');
49
+ var value = value.toFixed(1); //
50
+
51
+ var data = {
52
+ action: 'yasr_send_overall_rating',
53
+ nonce: "<?php echo "$ajax_nonce_overall"; ?>",
54
+ rating: value,
55
+ post_id: postid
56
+ };
57
+
58
+ //Send value to the Server
59
+ jQuery.post(ajaxurl, data, function(response) {
60
+ jQuery('#loader-overall-rating').hide();
61
+ jQuery('#yasr_rateit_overall_value').text('You\'ve rated it: ' + value);
62
+ }) ;
63
+
64
+ });
65
+
66
+ jQuery('#yasr_rateit_overall').on('reset', function() {
67
+ jQuery('#loader-overall-rating').show();
68
+ var el = jQuery(this);
69
+ var postid = <?php the_ID(); ?>;
70
+ var value = '-1';
71
+
72
+ var data = {
73
+ action: 'yasr_send_overall_rating',
74
+ nonce: "<?php echo "$ajax_nonce_overall"; ?>",
75
+ rating: value,
76
+ post_id: postid
77
+ };
78
+
79
+ //Send value to the Server
80
+ jQuery.post(ajaxurl, data, function(response) {
81
+ jQuery('#loader-overall-rating').hide();
82
+ jQuery('#yasr_rateit_overall_value').text('You\'ve reset the vote');
83
+ }) ;
84
+ });
85
 
86
  });
87
  </script>
yasr-settings-page.php CHANGED
@@ -334,7 +334,7 @@ if ( !current_user_can( 'manage_options' ) ) {
334
  jQuery('#yasr-element-limit').show();
335
  jQuery('#yasr-add-field-edit-multiset').hide();
336
  return false;
337
- }
338
 
339
  var newTextBoxDiv = jQuery(document.createElement('tr'))
340
 
@@ -356,23 +356,23 @@ if ( !current_user_can( 'manage_options' ) ) {
356
 
357
  ?>
358
 
359
-
360
  //If more then 1 set is used...
361
- jQuery('#yasr_select_edit_set').on("change", function() {
362
 
363
  var data = {
364
  action : 'yasr_get_multi_set',
365
- set_id : jQuery(this).val()
366
  }
367
 
368
  jQuery.post(ajaxurl, data, function(response) {
369
  jQuery('#yasr-multi-set-response').show();
370
- jQuery('#yasr-multi-set-response').toggle;
371
  jQuery('#yasr-multi-set-response').html(response);
372
  });
373
 
374
- });
 
375
 
 
376
 
377
  jQuery(document).ajaxComplete(function(){
378
 
334
  jQuery('#yasr-element-limit').show();
335
  jQuery('#yasr-add-field-edit-multiset').hide();
336
  return false;
337
+ }
338
 
339
  var newTextBoxDiv = jQuery(document.createElement('tr'))
340
 
356
 
357
  ?>
358
 
 
359
  //If more then 1 set is used...
360
+ jQuery('#yasr-button-select-set-edit-form').on("click", function() {
361
 
362
  var data = {
363
  action : 'yasr_get_multi_set',
364
+ set_id : jQuery('#yasr_select_edit_set').val()
365
  }
366
 
367
  jQuery.post(ajaxurl, data, function(response) {
368
  jQuery('#yasr-multi-set-response').show();
 
369
  jQuery('#yasr-multi-set-response').html(response);
370
  });
371
 
372
+ return false; // prevent default click action from happening!
373
+ e.preventDefault(); // same thing as above
374
 
375
+ });
376
 
377
  jQuery(document).ajaxComplete(function(){
378
 
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.2.9
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.2.9');
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.2.10
7
  * Author: Dario Curvino
8
  * Author URI: http://profiles.wordpress.org/dudo/
9
  * License: GPL2
28
  */
29
 
30
 
31
+ define('YASR_VERSION_NUM', '0.2.10');
32
 
33
  //Plugin absolute path
34
  define( "YASR_ABSOLUTE_PATH", dirname(__FILE__) );