Yasr – Yet Another Stars Rating - Version 0.2.3

Version Description

  • [yasr_visitor_votes] it's now disabled outside a post or a page
  • Security fixes on ajax functions
  • Various fixes on multi-set settings
  • Code cleanup
Download this release

Release Info

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

Code changes from version 0.0.3 to 0.2.3

TODO CHANGED
@@ -2,4 +2,3 @@
2
  -Change thickbox
3
  -Use dashicons
4
  -Use get_option or json instead of regex to import gd star rating data
5
- -Use admin notice in settings page
2
  -Change thickbox
3
  -Use dashicons
4
  -Use get_option or json instead of regex to import gd star rating data
 
css/bigstars.css CHANGED
@@ -1,11 +1,11 @@
1
  /*
2
- SOURCE: http://iconexpo.com/2008/12/free-8color-star-icons/
3
-
4
  */
5
 
6
 
7
  div.bigstars div.rateit-range
8
  {
 
9
  background: url('../img/star-white32.png');
10
  height: 32px;
11
  }
1
  /*
2
+ SOURCE: Oxygen Team
 
3
  */
4
 
5
 
6
  div.bigstars div.rateit-range
7
  {
8
+
9
  background: url('../img/star-white32.png');
10
  height: 32px;
11
  }
css/rateit.css CHANGED
@@ -16,7 +16,7 @@
16
  position: relative;
17
  display: -moz-inline-box;
18
  display: inline-block;
19
- background: url('../img/star.gif');
20
  height: 16px;
21
  outline: none;
22
  }
@@ -51,7 +51,7 @@
51
 
52
  .rateit .rateit-hover
53
  {
54
- background: url('../img/star.gif') left -32px;
55
  }
56
 
57
  .rateit .rateit-hover-rtl
@@ -61,7 +61,7 @@
61
 
62
  .rateit .rateit-selected
63
  {
64
- background: url('../img/star.gif') left -16px;
65
  }
66
 
67
  .rateit .rateit-selected-rtl
@@ -71,12 +71,12 @@
71
 
72
  .rateit .rateit-preset
73
  {
74
- background: url('../img/star.gif') left -48px;
75
  }
76
 
77
  .rateit .rateit-preset-rtl
78
  {
79
- background: url('../img/star.gif') left -48px;
80
  }
81
 
82
  .rateit button.rateit-reset
@@ -95,4 +95,4 @@
95
  .rateit button.rateit-reset:hover, .rateit button.rateit-reset:focus
96
  {
97
  background-position: 0 -16px;
98
- }
16
  position: relative;
17
  display: -moz-inline-box;
18
  display: inline-block;
19
+ background: url('../img/star.png');
20
  height: 16px;
21
  outline: none;
22
  }
51
 
52
  .rateit .rateit-hover
53
  {
54
+ background: url('../img/star.png') left -32px;
55
  }
56
 
57
  .rateit .rateit-hover-rtl
61
 
62
  .rateit .rateit-selected
63
  {
64
+ background: url('../img/star.png') left -16px;
65
  }
66
 
67
  .rateit .rateit-selected-rtl
71
 
72
  .rateit .rateit-preset
73
  {
74
+ background: url('../img/star.png') left -48px;
75
  }
76
 
77
  .rateit .rateit-preset-rtl
78
  {
79
+ background: url('../img/star.png') left -48px;
80
  }
81
 
82
  .rateit button.rateit-reset
95
  .rateit button.rateit-reset:hover, .rateit button.rateit-reset:focus
96
  {
97
  background-position: 0 -16px;
98
+ }
css/yasr.css CHANGED
@@ -143,6 +143,14 @@
143
  padding: 5px;
144
  }
145
 
 
 
 
 
 
 
 
 
146
  .yasr_table_multi_set_shortcode tr:nth-child(odd) {
147
  background: #FFFFec;
148
  }
@@ -181,3 +189,54 @@
181
  .yasr_table_multi_set_admin tr:nth-child(even) {
182
  background: #FFFFFF;
183
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  padding: 5px;
144
  }
145
 
146
+ .yasr-edit-form-remove-entire-set {
147
+ padding-top: 30px;
148
+ padding-bottom: 30px;
149
+ text-align: center;
150
+ color: red;
151
+ }
152
+
153
+
154
  .yasr_table_multi_set_shortcode tr:nth-child(odd) {
155
  background: #FFFFec;
156
  }
189
  .yasr_table_multi_set_admin tr:nth-child(even) {
190
  background: #FFFFFF;
191
  }
192
+
193
+ #yasr-log-container {
194
+ width: 98%;
195
+ }
196
+
197
+ .yasr-log-div-child {
198
+ padding-top: 5px;
199
+ border-bottom: 1px solid #BBD8E7;
200
+ padding-bottom: 20px;
201
+ }
202
+
203
+ #yasr-log-image {
204
+ list-style-type: none;
205
+ display: inline-block;
206
+ float:left;
207
+ }
208
+
209
+ #yasr-log-child-head {
210
+ padding-left: 37px;
211
+ }
212
+
213
+ #yasr-log-vote {
214
+ color: red;
215
+ }
216
+
217
+ #yasr-log-post {
218
+ color: #2683AE;
219
+ }
220
+
221
+ #yasr-log-ip-date {
222
+ padding-top: 5px;
223
+ }
224
+
225
+ #yasr-log-ip {
226
+ float:left;
227
+ padding-left: 5px;
228
+ }
229
+
230
+ #yasr-log-date {
231
+ float: right;
232
+ }
233
+
234
+ #yasr-log-next-rows {
235
+ padding-top: 15px;
236
+ text-align: right;
237
+ }
238
+
239
+ #yasr-log-page-navigation {
240
+ padding-top: 7px;
241
+ text-align: center;
242
+ }
img/star-black32.png CHANGED
Binary file
img/star-gold32.png CHANGED
Binary file
img/star-red32.png CHANGED
Binary file
img/star-white32.png CHANGED
Binary file
img/star.gif DELETED
Binary file
img/star.png ADDED
Binary file
img/star_2.gif DELETED
Binary file
img/star_3.gif DELETED
Binary file
img/star_4.gif DELETED
Binary file
js/jquery.rateit.min.js CHANGED
@@ -1,7 +1,7 @@
1
- /*! RateIt | v1.0.20 / 01/26/2014 | https://rateit.codeplex.com/license
2
  http://rateit.codeplex.com | Twitter: @gjunge
3
  */
4
- (function(n){function t(n){var u=n.originalEvent.changedTouches,t=u[0],i="",r;switch(n.type){case"touchmove":i="mousemove";break;case"touchend":i="mouseup";break;default:return}r=document.createEvent("MouseEvent");r.initMouseEvent(i,!0,!0,window,1,t.screenX,t.screenY,t.clientX,t.clientY,!1,!1,!1,!1,0,null);t.target.dispatchEvent(r);n.preventDefault()}n.rateit={aria:{resetLabel:"reset rating",ratingLabel:"rating"}};n.fn.rateit=function(i,r){var e=1,u={},o="init",s=function(n){return n.charAt(0).toUpperCase()+n.substr(1)},f;if(this.length===0)return this;if(f=n.type(i),f=="object"||i===undefined||i===null)u=n.extend({},n.fn.rateit.defaults,i);else{if(f=="string"&&i!=="reset"&&r===undefined)return this.data("rateit"+s(i));f=="string"&&(o="setvalue")}return this.each(function(){var c=n(this),f=function(n,t){if(t!=null){var i="aria-value"+(n=="value"?"now":n),r=c.find(".rateit-range");r.attr(i)!=undefined&&r.attr(i,t)}return arguments[0]="rateit"+s(n),c.data.apply(c,arguments)},p,w,v,h,d,g,l,y,b,a;if(i=="reset"){p=f("init");for(w in p)c.data(w,p[w]);f("backingfld")&&(h=n(f("backingfld")),h.val(f("value")),h.trigger("change"),h[0].min&&(h[0].min=f("min")),h[0].max&&(h[0].max=f("max")),h[0].step&&(h[0].step=f("step")));c.trigger("reset")}if(c.hasClass("rateit")||c.addClass("rateit"),v=c.css("direction")!="rtl",o=="setvalue"){if(!f("init"))throw"Can't set value before init";i!="readonly"||r!=!0||f("readonly")||(c.find(".rateit-range").unbind(),f("wired",!1));i=="value"&&(r=r==null?f("min"):Math.max(f("min"),Math.min(f("max"),r)));f("backingfld")&&(h=n(f("backingfld")),i=="value"&&h.val(r),i=="min"&&h[0].min&&(h[0].min=r),i=="max"&&h[0].max&&(h[0].max=r),i=="step"&&h[0].step&&(h[0].step=r));f(i,r)}f("init")||(f("min",isNaN(f("min"))?u.min:f("min")),f("max",isNaN(f("max"))?u.max:f("max")),f("step",f("step")||u.step),f("readonly",f("readonly")!==undefined?f("readonly"):u.readonly),f("resetable",f("resetable")!==undefined?f("resetable"):u.resetable),f("backingfld",f("backingfld")||u.backingfld),f("starwidth",f("starwidth")||u.starwidth),f("starheight",f("starheight")||u.starheight),f("value",Math.max(f("min"),Math.min(f("max"),isNaN(f("value"))?isNaN(u.value)?u.min:u.value:f("value")))),f("ispreset",f("ispreset")!==undefined?f("ispreset"):u.ispreset),f("backingfld")&&(h=n(f("backingfld")),f("value",h.hide().val()),(h.attr("disabled")||h.attr("readonly"))&&f("readonly",!0),h[0].nodeName=="INPUT"&&(h[0].type=="range"||h[0].type=="text")&&(f("min",parseInt(h.attr("min"))||f("min")),f("max",parseInt(h.attr("max"))||f("max")),f("step",parseInt(h.attr("step"))||f("step"))),h[0].nodeName=="SELECT"&&h[0].options.length>1&&(f("min",Number(h[0].options[0].value)),f("max",Number(h[0].options[h[0].length-1].value)),f("step",Number(h[0].options[1].value)-Number(h[0].options[0].value)))),d=c[0].nodeName=="DIV"?"div":"span",e++,g='<button id="rateit-reset-{{index}}" data-role="none" class="rateit-reset" aria-label="'+n.rateit.aria.resetLabel+'" aria-controls="rateit-range-{{index}}"><\/button><{{element}} id="rateit-range-{{index}}" class="rateit-range" tabindex="0" role="slider" aria-label="'+n.rateit.aria.ratingLabel+'" aria-owns="rateit-reset-{{index}}" aria-valuemin="'+f("min")+'" aria-valuemax="'+f("max")+'" aria-valuenow="'+f("value")+'"><{{element}} class="rateit-selected" style="height:'+f("starheight")+'px"><\/{{element}}><{{element}} class="rateit-hover" style="height:'+f("starheight")+'px"><\/{{element}}><\/{{element}}>',c.append(g.replace(/{{index}}/gi,e).replace(/{{element}}/gi,d)),v||(c.find(".rateit-reset").css("float","right"),c.find(".rateit-selected").addClass("rateit-selected-rtl"),c.find(".rateit-hover").addClass("rateit-hover-rtl")),f("init",JSON.parse(JSON.stringify(c.data()))));c.find(".rateit-selected, .rateit-hover").height(f("starheight"));l=c.find(".rateit-range");l.width(f("starwidth")*(f("max")-f("min"))).height(f("starheight"));y="rateit-preset"+(v?"":"-rtl");f("ispreset")?c.find(".rateit-selected").addClass(y):c.find(".rateit-selected").removeClass(y);f("value")!=null&&(b=(f("value")-f("min"))*f("starwidth"),c.find(".rateit-selected").width(b));a=c.find(".rateit-reset");a.data("wired")!==!0&&a.bind("click",function(t){t.preventDefault();a.blur();var i=n.Event("beforereset");if(c.trigger(i),i.isDefaultPrevented())return!1;c.rateit("value",null);c.trigger("reset")}).data("wired",!0);var nt=function(t,i){var u=i.changedTouches?i.changedTouches[0].pageX:i.pageX,r=u-n(t).offset().left;return v||(r=l.width()-r),r>l.width()&&(r=l.width()),r<0&&(r=0),b=Math.ceil(r/f("starwidth")*(1/f("step")))},tt=function(n){var t=n*f("starwidth")*f("step"),r=l.find(".rateit-hover"),i;r.data("width")!=t&&(l.find(".rateit-selected").hide(),r.width(t).show().data("width",t),i=[n*f("step")+f("min")],c.trigger("hover",i).trigger("over",i))},k=function(t){var i=n.Event("beforerated");return(c.trigger(i,[t]),i.isDefaultPrevented())?!1:(f("value",t),f("backingfld")&&n(f("backingfld")).val(t).trigger("change"),f("ispreset")&&(l.find(".rateit-selected").removeClass(y),f("ispreset",!1)),l.find(".rateit-hover").hide(),l.find(".rateit-selected").width(t*f("starwidth")-f("min")*f("starwidth")).show(),c.trigger("hover",[null]).trigger("over",[null]).trigger("rated",[t]),!0)};f("readonly")?a.hide():(f("resetable")||a.hide(),f("wired")||(l.bind("touchmove touchend",t),l.mousemove(function(n){var t=nt(this,n);tt(t)}),l.mouseleave(function(){l.find(".rateit-hover").hide().width(0).data("width","");c.trigger("hover",[null]).trigger("over",[null]);l.find(".rateit-selected").show()}),l.mouseup(function(n){var t=nt(this,n),i=t*f("step")+f("min");k(i);l.blur()}),l.keyup(function(n){(n.which==38||n.which==(v?39:37))&&k(Math.min(f("value")+f("step"),f("max")));(n.which==40||n.which==(v?37:39))&&k(Math.max(f("value")-f("step"),f("min")))}),f("wired",!0)),f("resetable")&&a.show());l.attr("aria-readonly",f("readonly"))})};n.fn.rateit.defaults={min:0,max:5,step:.5,starwidth:16,starheight:16,readonly:!1,resetable:!0,ispreset:!1};n(function(){n("div.rateit, span.rateit").rateit()})})(jQuery);
5
- /*
6
- //# sourceMappingURL=jquery.rateit.min.js.map
7
  */
1
+ /*! RateIt | v1.0.22 / 05/27/2014 | https://rateit.codeplex.com/license
2
  http://rateit.codeplex.com | Twitter: @gjunge
3
  */
4
+ (function(n){function t(n){var u=n.originalEvent.changedTouches,t=u[0],i="",r;switch(n.type){case"touchmove":i="mousemove";break;case"touchend":i="mouseup";break;default:return}r=document.createEvent("MouseEvent");r.initMouseEvent(i,!0,!0,window,1,t.screenX,t.screenY,t.clientX,t.clientY,!1,!1,!1,!1,0,null);t.target.dispatchEvent(r);n.preventDefault()}n.rateit={aria:{resetLabel:"reset rating",ratingLabel:"rating"}};n.fn.rateit=function(i,r){var e=1,u={},o="init",s=function(n){return n.charAt(0).toUpperCase()+n.substr(1)},f;if(this.length===0)return this;if(f=n.type(i),f=="object"||i===undefined||i===null)u=n.extend({},n.fn.rateit.defaults,i);else{if(f=="string"&&i!=="reset"&&r===undefined)return this.data("rateit"+s(i));f=="string"&&(o="setvalue")}return this.each(function(){var c=n(this),f=function(n,t){if(t!=null){var i="aria-value"+(n=="value"?"now":n),r=c.find(".rateit-range");r.attr(i)!=undefined&&r.attr(i,t)}return arguments[0]="rateit"+s(n),c.data.apply(c,arguments)},p,w,v,h,b,g,nt,l,y,k,a;if(i=="reset"){p=f("init");for(w in p)c.data(w,p[w]);f("backingfld")&&(h=n(f("backingfld")),h.val(f("value")),h.trigger("change"),h[0].min&&(h[0].min=f("min")),h[0].max&&(h[0].max=f("max")),h[0].step&&(h[0].step=f("step")));c.trigger("reset")}if(c.hasClass("rateit")||c.addClass("rateit"),v=c.css("direction")!="rtl",o=="setvalue"){if(!f("init"))throw"Can't set value before init";i!="readonly"||r!=!0||f("readonly")||(c.find(".rateit-range").unbind(),f("wired",!1));i=="value"&&(r=r==null?f("min"):Math.max(f("min"),Math.min(f("max"),r)));f("backingfld")&&(h=n(f("backingfld")),i=="value"&&h.val(r),i=="min"&&h[0].min&&(h[0].min=r),i=="max"&&h[0].max&&(h[0].max=r),i=="step"&&h[0].step&&(h[0].step=r));f(i,r)}f("init")||(f("min",isNaN(f("min"))?u.min:f("min")),f("max",isNaN(f("max"))?u.max:f("max")),f("step",f("step")||u.step),f("readonly",f("readonly")!==undefined?f("readonly"):u.readonly),f("resetable",f("resetable")!==undefined?f("resetable"):u.resetable),f("backingfld",f("backingfld")||u.backingfld),f("starwidth",f("starwidth")||u.starwidth),f("starheight",f("starheight")||u.starheight),f("value",Math.max(f("min"),Math.min(f("max"),isNaN(f("value"))?isNaN(u.value)?u.min:u.value:f("value")))),f("ispreset",f("ispreset")!==undefined?f("ispreset"):u.ispreset),f("backingfld")&&(h=n(f("backingfld")).hide(),(h.attr("disabled")||h.attr("readonly"))&&f("readonly",!0),h[0].nodeName=="INPUT"&&(h[0].type=="range"||h[0].type=="text")&&(f("min",parseInt(h.attr("min"))||f("min")),f("max",parseInt(h.attr("max"))||f("max")),f("step",parseInt(h.attr("step"))||f("step"))),h[0].nodeName=="SELECT"&&h[0].options.length>1?(f("min",isNaN(f("min"))?Number(h[0].options[0].value):f("min")),f("max",Number(h[0].options[h[0].length-1].value)),f("step",Number(h[0].options[1].value)-Number(h[0].options[0].value)),b=h.find("option[selected]"),b.length==1&&f("value",b.val())):f("value",h.val())),g=c[0].nodeName=="DIV"?"div":"span",e++,nt='<button id="rateit-reset-{{index}}" type="button" data-role="none" class="rateit-reset" aria-label="'+n.rateit.aria.resetLabel+'" aria-controls="rateit-range-{{index}}"><\/button><{{element}} id="rateit-range-{{index}}" class="rateit-range" tabindex="0" role="slider" aria-label="'+n.rateit.aria.ratingLabel+'" aria-owns="rateit-reset-{{index}}" aria-valuemin="'+f("min")+'" aria-valuemax="'+f("max")+'" aria-valuenow="'+f("value")+'"><{{element}} class="rateit-selected" style="height:'+f("starheight")+'px"><\/{{element}}><{{element}} class="rateit-hover" style="height:'+f("starheight")+'px"><\/{{element}}><\/{{element}}>',c.append(nt.replace(/{{index}}/gi,e).replace(/{{element}}/gi,g)),v||(c.find(".rateit-reset").css("float","right"),c.find(".rateit-selected").addClass("rateit-selected-rtl"),c.find(".rateit-hover").addClass("rateit-hover-rtl")),f("init",JSON.parse(JSON.stringify(c.data()))));c.find(".rateit-selected, .rateit-hover").height(f("starheight"));l=c.find(".rateit-range");l.width(f("starwidth")*(f("max")-f("min"))).height(f("starheight"));y="rateit-preset"+(v?"":"-rtl");f("ispreset")?c.find(".rateit-selected").addClass(y):c.find(".rateit-selected").removeClass(y);f("value")!=null&&(k=(f("value")-f("min"))*f("starwidth"),c.find(".rateit-selected").width(k));a=c.find(".rateit-reset");a.data("wired")!==!0&&a.bind("click",function(t){t.preventDefault();a.blur();var i=n.Event("beforereset");if(c.trigger(i),i.isDefaultPrevented())return!1;c.rateit("value",null);c.trigger("reset")}).data("wired",!0);var tt=function(t,i){var u=i.changedTouches?i.changedTouches[0].pageX:i.pageX,r=u-n(t).offset().left;return v||(r=l.width()-r),r>l.width()&&(r=l.width()),r<0&&(r=0),k=Math.ceil(r/f("starwidth")*(1/f("step")))},it=function(n){var t=n*f("starwidth")*f("step"),r=l.find(".rateit-hover"),i;r.data("width")!=t&&(l.find(".rateit-selected").hide(),r.width(t).show().data("width",t),i=[n*f("step")+f("min")],c.trigger("hover",i).trigger("over",i))},d=function(t){var i=n.Event("beforerated");return(c.trigger(i,[t]),i.isDefaultPrevented())?!1:(f("value",t),f("backingfld")&&n(f("backingfld")).val(t).trigger("change"),f("ispreset")&&(l.find(".rateit-selected").removeClass(y),f("ispreset",!1)),l.find(".rateit-hover").hide(),l.find(".rateit-selected").width(t*f("starwidth")-f("min")*f("starwidth")).show(),c.trigger("hover",[null]).trigger("over",[null]).trigger("rated",[t]),!0)};f("readonly")?a.hide():(f("resetable")||a.hide(),f("wired")||(l.bind("touchmove touchend",t),l.mousemove(function(n){var t=tt(this,n);it(t)}),l.mouseleave(function(){l.find(".rateit-hover").hide().width(0).data("width","");c.trigger("hover",[null]).trigger("over",[null]);l.find(".rateit-selected").show()}),l.mouseup(function(n){var t=tt(this,n),i=t*f("step")+f("min");d(i);l.blur()}),l.keyup(function(n){(n.which==38||n.which==(v?39:37))&&d(Math.min(f("value")+f("step"),f("max")));(n.which==40||n.which==(v?37:39))&&d(Math.max(f("value")-f("step"),f("min")))}),f("wired",!0)),f("resetable")&&a.show());l.attr("aria-readonly",f("readonly"))})};n.fn.rateit.defaults={min:0,max:5,step:.5,starwidth:16,starheight:16,readonly:!1,resetable:!0,ispreset:!1};n(function(){n("div.rateit, span.rateit").rateit()})})(jQuery);
5
+ /*
6
+ //# sourceMappingURL=jquery.rateit.min.js.map
7
  */
languages/yasr.mo CHANGED
Binary file
languages/yasr.pot CHANGED
@@ -1,8 +1,8 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Yasr Translation\n"
4
- "POT-Creation-Date: 2014-03-01 15:15+0100\n"
5
- "PO-Revision-Date: 2014-03-01 15:24+0100\n"
6
  "Last-Translator: Dario <thedudoworld@gmail.com>\n"
7
  "Language-Team: Me\n"
8
  "Language: en-gb\n"
@@ -15,14 +15,395 @@ msgstr ""
15
  "X-Poedit-SourceCharset: UTF-8\n"
16
  "X-Poedit-SearchPath-0: ..\n"
17
 
18
- #: ../lib/yasr-functions.php:21
19
- msgid "Front Page"
 
 
20
  msgstr ""
21
 
22
- #: ../lib/yasr-functions.php:24
23
- msgid "Settings"
24
  msgstr ""
25
 
26
- #: ../lib/yasr-functions.php:32 ../lib/yasr-functions.php:40
27
- msgid "You do not have sufficient permissions to access this page."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  msgstr ""
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Yasr Translation\n"
4
+ "POT-Creation-Date: 2014-06-07 16:41+0100\n"
5
+ "PO-Revision-Date: 2014-06-07 16:41+0100\n"
6
  "Last-Translator: Dario <thedudoworld@gmail.com>\n"
7
  "Language-Team: Me\n"
8
  "Language: en-gb\n"
15
  "X-Poedit-SourceCharset: UTF-8\n"
16
  "X-Poedit-SearchPath-0: ..\n"
17
 
18
+ #: ../yasr-settings-page.php:6 ../lib/yasr-functions.php:134
19
+ #: ../lib/yasr-functions.php:216 ../lib/yasr-functions.php:223
20
+ #: ../lib/yasr-ajax-functions.php:29 ../lib/yasr-ajax-functions.php:202
21
+ msgid "You do not have sufficient permissions to access this page."
22
  msgstr ""
23
 
24
+ #: ../yasr-settings-page.php:12 ../yasr-settings-page.php:131
25
+ msgid "Donations"
26
  msgstr ""
27
 
28
+ #: ../yasr-settings-page.php:14 ../yasr-settings-page.php:133
29
+ msgid ""
30
+ "If you have found this plugin useful, please consider making a donation to "
31
+ "help support future development. Your support will be much appreciated. "
32
+ msgstr ""
33
+
34
+ #: ../yasr-settings-page.php:16 ../yasr-settings-page.php:135
35
+ msgid "Thank you!"
36
+ msgstr ""
37
+
38
+ #: ../yasr-settings-page.php:31
39
+ msgid "Manage multi set"
40
+ msgstr ""
41
+
42
+ #: ../yasr-settings-page.php:35
43
+ msgid "Add new multi-set"
44
+ msgstr ""
45
+
46
+ #: ../yasr-settings-page.php:71
47
+ msgid "Import Gd Star Rating"
48
+ msgstr ""
49
+
50
+ #: ../yasr-settings-page.php:72
51
+ msgid ""
52
+ "I've found a previous installation of Gd Star Rating . <br />Do you want "
53
+ "proceed to import data?"
54
+ msgstr ""
55
+
56
+ #: ../yasr-settings-page.php:74
57
+ msgid "Yes, Begin Import"
58
+ msgstr ""
59
+
60
+ #: ../yasr-settings-page.php:78
61
+ msgid "Click on Proceed to Import Gd Star Rating Data."
62
+ msgstr ""
63
+
64
+ #: ../yasr-settings-page.php:81 ../yasr-settings-page.php:110
65
+ msgid "Proceed"
66
+ msgstr ""
67
+
68
+ #: ../yasr-settings-page.php:99
69
+ msgid "Manage GD Star Data"
70
+ msgstr ""
71
+
72
+ #: ../yasr-settings-page.php:100
73
+ msgid "Gd Star Rating has been already imported."
74
+ msgstr ""
75
+
76
+ #: ../yasr-settings-page.php:101
77
+ msgid "If you wish you can import it again, but"
78
+ msgstr ""
79
+
80
+ #: ../yasr-settings-page.php:101
81
+ msgid "you will lose all data you've collect since the import!"
82
+ msgstr ""
83
+
84
+ #: ../yasr-settings-page.php:103
85
+ msgid "Ok, Import Again"
86
+ msgstr ""
87
+
88
+ #: ../yasr-settings-page.php:107
89
+ msgid ""
90
+ "Click on Proceed to Import again Gd Star Rating Data. This may take a while!"
91
+ msgstr ""
92
+
93
+ #: ../yasr-metabox-multiple-rating.php:13
94
+ msgid "Choose wich set you want to use"
95
+ msgstr ""
96
+
97
+ #: ../yasr-metabox-overall-rating.php:16
98
+ msgid "Rate this article / item"
99
+ msgstr ""
100
+
101
+ #: ../lib/yasr-shortcode-functions.php:51 ../lib/yasr-ajax-functions.php:878
102
+ #: ../lib/yasr-ajax-functions.php:906
103
+ msgid "Average Rating"
104
+ msgstr ""
105
+
106
+ #: ../lib/yasr-shortcode-functions.php:55
107
+ msgid "No rating yet"
108
+ msgstr ""
109
+
110
+ #: ../lib/yasr-db-functions.php:96
111
+ msgid "Gd Star Rating non trovato"
112
+ msgstr ""
113
+
114
+ #: ../lib/yasr-db-functions.php:506 ../lib/yasr-db-functions.php:721
115
+ msgid "Settings Saved"
116
+ msgstr ""
117
+
118
+ #: ../lib/yasr-db-functions.php:511
119
+ msgid "Something goes wrong trying insert set field name. Please report it"
120
+ msgstr ""
121
+
122
+ #: ../lib/yasr-db-functions.php:517
123
+ msgid "Something goes wrong trying insert multi set name. Please report it"
124
+ msgstr ""
125
+
126
+ #: ../lib/yasr-db-functions.php:584
127
+ msgid "Something goes wrong trying to delete a multi-set . Please report it"
128
+ msgstr ""
129
+
130
+ #: ../lib/yasr-db-functions.php:589
131
+ msgid ""
132
+ "Something goes wrong trying to delete data values for a set. Please report it"
133
+ msgstr ""
134
+
135
+ #: ../lib/yasr-db-functions.php:620
136
+ msgid ""
137
+ "Something goes wrong trying to delete a multi-set element. Please report it"
138
+ msgstr ""
139
+
140
+ #: ../lib/yasr-db-functions.php:625
141
+ msgid ""
142
+ "Something goes wrong trying to delete data value for an element. Please "
143
+ "report it"
144
+ msgstr ""
145
+
146
+ #: ../lib/yasr-db-functions.php:665
147
+ msgid ""
148
+ "Something goes wrong trying to update a multi set element. Please report it"
149
+ msgstr ""
150
+
151
+ #: ../lib/yasr-db-functions.php:706
152
+ msgid ""
153
+ "Something goes wrong trying to insert set field name in edit form. Please "
154
+ "report it"
155
+ msgstr ""
156
+
157
+ #: ../lib/yasr-db-functions.php:765 ../lib/yasr-ajax-functions.php:678
158
+ msgid "anonymous"
159
+ msgstr ""
160
+
161
+ #: ../lib/yasr-db-functions.php:788 ../lib/yasr-ajax-functions.php:701
162
+ msgid "Ip address"
163
+ msgstr ""
164
+
165
+ #: ../lib/yasr-db-functions.php:826 ../lib/yasr-ajax-functions.php:739
166
+ msgid "Pages"
167
+ msgstr ""
168
+
169
+ #: ../lib/yasr-functions.php:40
170
+ msgid "Yet Another Stars Rating: Settings"
171
+ msgstr ""
172
+
173
+ #: ../lib/yasr-functions.php:64
174
+ msgid "Auto insert Settings"
175
+ msgstr ""
176
+
177
+ #: ../lib/yasr-functions.php:65
178
+ msgid "Use auto insert?"
179
+ msgstr ""
180
+
181
+ #: ../lib/yasr-functions.php:66
182
+ msgid "What?"
183
+ msgstr ""
184
+
185
+ #: ../lib/yasr-functions.php:67
186
+ msgid "Where?"
187
+ msgstr ""
188
+
189
+ #: ../lib/yasr-functions.php:80
190
+ msgid "Yes"
191
+ msgstr ""
192
+
193
+ #: ../lib/yasr-functions.php:84
194
+ msgid "No"
195
+ msgstr ""
196
+
197
+ #: ../lib/yasr-functions.php:104
198
+ msgid "Overall Rating / Author Rating"
199
+ msgstr ""
200
+
201
+ #: ../lib/yasr-functions.php:108 ../lib/yasr-ajax-functions.php:299
202
+ msgid "Visitor Votes"
203
+ msgstr ""
204
+
205
+ #: ../lib/yasr-functions.php:112
206
+ msgid "Both"
207
+ msgstr ""
208
+
209
+ #: ../lib/yasr-functions.php:121
210
+ msgid "Before the post"
211
+ msgstr ""
212
+
213
+ #: ../lib/yasr-functions.php:125
214
+ msgid "After the post"
215
+ msgstr ""
216
+
217
+ #: ../lib/yasr-functions.php:176
218
+ msgid "Save"
219
+ msgstr ""
220
+
221
+ #: ../lib/yasr-functions.php:202 ../lib/yasr-functions.php:209
222
+ msgid "Overall Rating"
223
+ msgstr ""
224
+
225
+ #: ../lib/yasr-functions.php:203
226
+ msgid "Yet Another Stars Rating: Multiple set"
227
+ msgstr ""
228
+
229
+ #: ../lib/yasr-functions.php:248
230
+ msgid " reviewed by "
231
+ msgstr ""
232
+
233
+ #: ../lib/yasr-functions.php:249
234
+ msgid " on "
235
+ msgstr ""
236
+
237
+ #: ../lib/yasr-functions.php:250
238
+ msgid " rated "
239
+ msgstr ""
240
+
241
+ #: ../lib/yasr-functions.php:250
242
+ msgid " on 5.0"
243
+ msgstr ""
244
+
245
+ #: ../lib/yasr-functions.php:369
246
+ msgid ""
247
+ "Field Name, Element#1 and Element#2 MUST be filled and must be long at least "
248
+ "3 characters"
249
+ msgstr ""
250
+
251
+ #: ../lib/yasr-functions.php:372
252
+ msgid "Name"
253
+ msgstr ""
254
+
255
+ #: ../lib/yasr-functions.php:377
256
+ msgid "You can insert up to nine element"
257
+ msgstr ""
258
+
259
+ #: ../lib/yasr-functions.php:382
260
+ msgid "Element "
261
+ msgstr ""
262
+
263
+ #: ../lib/yasr-functions.php:392
264
+ msgid "Create New Set"
265
+ msgstr ""
266
+
267
+ #: ../lib/yasr-functions.php:411 ../lib/yasr-functions.php:431
268
+ msgid "Manage existing multi-set"
269
+ msgstr ""
270
+
271
+ #: ../lib/yasr-functions.php:415
272
+ msgid "Wich set do you want to edit or remove?"
273
+ msgstr ""
274
+
275
+ #: ../lib/yasr-functions.php:455
276
+ msgid "No multiple set were found"
277
+ msgstr ""
278
+
279
+ #: ../lib/yasr-ajax-functions.php:91 ../lib/yasr-ajax-functions.php:151
280
+ msgid "Choose a vote for every element"
281
+ msgstr ""
282
+
283
+ #: ../lib/yasr-ajax-functions.php:140 ../lib/yasr-ajax-functions.php:174
284
+ msgid "Remember to insert this shortcode"
285
+ msgstr ""
286
+
287
+ #: ../lib/yasr-ajax-functions.php:142 ../lib/yasr-ajax-functions.php:176
288
+ msgid "where you want to display this multi set"
289
+ msgstr ""
290
+
291
+ #: ../lib/yasr-ajax-functions.php:294
292
+ msgid "Overall Rating / Review"
293
+ msgstr ""
294
+
295
+ #: ../lib/yasr-ajax-functions.php:296
296
+ msgid "Insert Overall Rating / Review for this post"
297
+ msgstr ""
298
+
299
+ #: ../lib/yasr-ajax-functions.php:301
300
+ msgid "Insert the ability for your visitor to vote"
301
+ msgstr ""
302
+
303
+ #: ../lib/yasr-ajax-functions.php:307
304
+ msgid "If you want to insert a multi-set, pick one:"
305
+ msgstr ""
306
+
307
+ #: ../lib/yasr-ajax-functions.php:313
308
+ msgid "Choose wich set you want to insert."
309
+ msgstr ""
310
+
311
+ #: ../lib/yasr-ajax-functions.php:321
312
+ msgid "Insert Multiset:"
313
+ msgstr ""
314
+
315
+ #: ../lib/yasr-ajax-functions.php:432
316
+ msgid "Field name"
317
+ msgstr ""
318
+
319
+ #: ../lib/yasr-ajax-functions.php:436
320
+ msgid "Remove"
321
+ msgstr ""
322
+
323
+ #: ../lib/yasr-ajax-functions.php:484
324
+ msgid ""
325
+ "If you remove something you will remove all the votes for that set or field. "
326
+ "This operation CAN'T BE undone."
327
+ msgstr ""
328
+
329
+ #: ../lib/yasr-ajax-functions.php:491
330
+ msgid "You can use up to 9 elements"
331
+ msgstr ""
332
+
333
+ #: ../lib/yasr-ajax-functions.php:493
334
+ msgid "Add element"
335
+ msgstr ""
336
+
337
+ #: ../lib/yasr-ajax-functions.php:495
338
+ msgid "Save changes"
339
+ msgstr ""
340
+
341
+ #: ../lib/yasr-ajax-functions.php:536
342
+ msgid "Reviews and visitor votes have been successfull imported."
343
+ msgstr ""
344
+
345
+ #: ../lib/yasr-ajax-functions.php:538
346
+ msgid ""
347
+ "Step2: I will check if you used multiple set and if so I will import it. "
348
+ "THIS MAY TAKE A WHILE!"
349
+ msgstr ""
350
+
351
+ #: ../lib/yasr-ajax-functions.php:540
352
+ msgid "Proceed Step 2"
353
+ msgstr ""
354
+
355
+ #: ../lib/yasr-ajax-functions.php:547
356
+ msgid "Something goes wrong! Refresh the page and try again!"
357
+ msgstr ""
358
+
359
+ #: ../lib/yasr-ajax-functions.php:571
360
+ msgid "I've found multiple set! Importing..."
361
+ msgstr ""
362
+
363
+ #: ../lib/yasr-ajax-functions.php:580
364
+ msgid "Multi set's name has been successfull imported."
365
+ msgstr ""
366
+
367
+ #: ../lib/yasr-ajax-functions.php:582
368
+ msgid "Now I'm going to import multi set data"
369
+ msgstr ""
370
+
371
+ #: ../lib/yasr-ajax-functions.php:593
372
+ msgid "All votes has been successfull imported."
373
+ msgstr ""
374
+
375
+ #: ../lib/yasr-ajax-functions.php:596
376
+ msgid "Done"
377
+ msgstr ""
378
+
379
+ #: ../lib/yasr-ajax-functions.php:601
380
+ msgid "I've found multiple set votes but I couldn't insert into db"
381
+ msgstr ""
382
+
383
+ #: ../lib/yasr-ajax-functions.php:609
384
+ msgid "I've found multi set but with no data"
385
+ msgstr ""
386
+
387
+ #: ../lib/yasr-ajax-functions.php:618
388
+ msgid "I've found multi set name but I couldn't insert into db"
389
+ msgstr ""
390
+
391
+ #: ../lib/yasr-ajax-functions.php:626
392
+ msgid "Multiset was not found. Imported is done!"
393
+ msgstr ""
394
+
395
+ #: ../lib/yasr-ajax-functions.php:665
396
+ msgid "No Recenet votes yet"
397
+ msgstr ""
398
+
399
+ #: ../lib/yasr-ajax-functions.php:878 ../lib/yasr-ajax-functions.php:883
400
+ msgid "Vote Saved"
401
+ msgstr ""
402
+
403
+ #: ../lib/yasr-ajax-functions.php:878 ../lib/yasr-ajax-functions.php:906
404
+ msgid "votes casts"
405
+ msgstr ""
406
+
407
+ #: ../lib/yasr-ajax-functions.php:883
408
+ msgid "vote casts"
409
  msgstr ""
lib/yasr-ajax-functions.php CHANGED
@@ -15,10 +15,10 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
15
  if (isset($_POST['rating']) && ($_POST['post_id'])) {
16
  global $current_user;
17
  get_currentuserinfo();
18
-
19
  $rating = $_POST['rating'];
20
  $post_id = $_POST['post_id'];
21
  $reviewer_id = $current_user->ID;
 
22
  }
23
 
24
  else {
@@ -29,6 +29,10 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
29
  wp_die( __( 'You do not have sufficient permissions to access this page.', 'yasr' ) );
30
  }
31
 
 
 
 
 
32
  global $wpdb;
33
 
34
  //If update works means that visitor already rated this post
@@ -71,15 +75,25 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
71
 
72
  add_action( 'wp_ajax_yasr_send_id_nameset', 'yasr_output_multiple_set_callback' );
73
 
 
74
  function yasr_output_multiple_set_callback() {
75
  if(isset($_POST['set_id']) && isset($_POST['post_id'])) {
76
  $set_type = $_POST['set_id'];
77
  $post_id = $_POST['post_id'];
 
78
  }
79
  else {
80
  exit();
81
  }
82
 
 
 
 
 
 
 
 
 
83
  global $wpdb;
84
 
85
  $set_values=yasr_get_multi_set_values_and_field ($post_id, $set_type);
@@ -88,7 +102,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
88
  if (!$set_values) {
89
  echo "<p>";
90
 
91
- _e('Choose a vote for every element', 'yasr');
92
 
93
  echo "
94
 
@@ -128,7 +142,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
128
 
129
  echo "<tr> <td>";
130
  echo "$name->name </td>";
131
- echo "<td> <div class=\"rateit\" id=\"$name->id\" data-rateit-value=\"\" data-rateit-step=\"0.5\" data-rateit-resetable=\"true\" data-rateit-readonly=\"false\"></div> </td>";
132
  echo "</tr>";
133
  }
134
  echo "</table>
@@ -165,7 +179,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
165
  $set_content->vote = $integer_vote+1;
166
  }
167
 
168
- echo "<td width=\"50%\"> <div class=\"rateit\" id=\"$set_content->id\" data-rateit-value=\"$set_content->vote\" data-rateit-step=\"0.5\" data-rateit-resetable=\"true\" data-rateit-readonly=\"false\"></div> </td></tr>";
169
  } //End foreach
170
  echo "</table>";
171
 
@@ -193,6 +207,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
193
  $vote = $_POST['rating'];
194
  $id_field = $_POST['id_field'];
195
  $set_type = $_POST['set_type'];
 
196
  }
197
  else {
198
  exit();
@@ -202,6 +217,10 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
202
  wp_die( __( 'You do not have sufficient permissions to access this page.', 'yasr' ) );
203
  }
204
 
 
 
 
 
205
  global $wpdb;
206
 
207
  //Check if vote already exist
@@ -442,12 +461,15 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
442
  foreach ($set_name as $name) {
443
  echo "
444
  <tr>
445
- <td>
446
- Element #$i <input type=\"text\" value=\"$name->name\" name=\"edit-multi-set-element-$name->id\">
447
- </td>
448
- <td id=\"yasr-table-form-edit-multi-set-checkbox\" style=\"text-align:center\">
449
- <input type=\"checkbox\" name=\"remove-element-$name->id\">
450
- </td>
 
 
 
451
  </tr>
452
  ";
453
  $i++;
@@ -458,14 +480,27 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
458
 
459
  echo "
460
 
461
- <input type=\"hidden\" name=\"yasr-edit-form-number-elements\" value=\"$i\">
 
 
 
 
 
 
 
 
 
 
 
 
 
462
 
463
  </table>
464
 
465
  ";
466
 
467
  echo "<p>";
468
- _e("If you remove a field, you will lost all the vote for that field." , "yasr");
469
  echo "</p>";
470
 
471
  wp_nonce_field( 'edit-multi-set', 'add-nonce-edit-multi-set' )
@@ -480,14 +515,6 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
480
 
481
  </form>
482
 
483
- <script type="text/javascript">
484
-
485
- var counter = <?php echo "$i"; ?>;
486
-
487
- counter = counter+1;
488
-
489
- </script>
490
-
491
  <?php
492
 
493
  die();
@@ -501,134 +528,299 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
501
 
502
  /********* IMPORT FUNCTIONS *********/
503
 
 
504
 
505
- if (is_admin()) {
506
- add_action( 'wp_ajax_yasr_import_step1', 'yasr_import_step1_callback' );
507
- }
 
 
508
 
509
- function yasr_import_step1_callback () {
510
- //Import reviews from GD star
511
- $reviews=yasr_import_gdstar_data();
512
 
513
- //Insert GD star review in yasr votes table
514
- $check_query_success=yasr_insert_gdstar_data($reviews);
515
- ?>
516
 
517
- <div class="yasr-result-step-1">
518
- <?php
519
- if ($check_query_success) {
520
- _e( "Reviews and visitor votes have been successfull imported.", 'yasr'); ?>
521
- <br />
522
- <?php _e ("Step2: I will check if you used multiple set and if so I will import it. THIS MAY TAKE A WHILE!", 'yasr'); ?>
523
- <br />
524
- <button href=\"#\" class=\"button-primary\" id=\"import-button-step2\"> <?php _e('Proceed Step 2', 'yasr');?> </button>
525
- <span id="loader2" style="display:none;" >&nbsp;<img src="<?php echo YASR_IMG_DIR . "/loader.gif" ?>">
526
- </span>
527
  <?php
528
- }
 
 
 
 
 
 
 
 
 
529
 
530
- else {
531
- _e( "Something goes wrong! Refresh the page and try again!", 'yasr');
532
- }
533
 
534
- ?>
535
 
536
- </div>
537
 
538
- <?php
539
 
540
- die ();
541
- } //End import step 1
542
 
543
- if (is_admin()) {
544
- add_action( 'wp_ajax_yasr_import_multi_set', 'yasr_check_import_set_callback' );
545
- }
546
 
547
- function yasr_check_import_set_callback () {
548
- $multi_set_names=yasr_import_gdstar_multi_set();
549
 
550
- echo "<div class=\"yasr-result-step-2\">";
 
 
 
 
551
 
552
- //If multiple set are found
553
- if($multi_set_names) {
554
- echo "<br /><strong>";
555
- _e("I've found multiple set! Importing..." , 'yasr');
556
- echo "</strong><br />";
557
 
558
- //If multi set are found write in yasr_multi_set table
559
- $insert_multi_set=yasr_insert_gdstar_multi_set($multi_set_names);
560
 
561
- //If insert succes, go ahed
562
- if ($insert_multi_set) {
563
- echo "&nbsp;&nbsp;&nbsp;";
564
- _e("Multi set's name has been successfull imported.", 'yasr');
565
- echo "<br /><strong>";
566
- _e("Now I'm going to import multi set data", 'yasr');
567
- echo "</strong> <br />";
568
-
569
- //Import multiple set's values from GD star rating
570
- $multi_data=yasr_import_gdstar_multi_value();
571
-
572
- //If set values are found, insert Gd Star multi values in yasr_multi_values
573
- if($multi_data) {
574
- $insert_multidata=yasr_insert_gdstar_multi_value($multi_data);
575
- if ($insert_multidata) {
576
- echo "&nbsp;&nbsp;&nbsp;";
577
- _e( "All votes has been successfull imported.", 'yasr');
578
- echo "<br />";
579
- update_option('yasr-gdstar-imported', '1');
580
- echo "<button href=\"#\" class=\"button-delete\" id=\"end-import\">" . __('Done', 'yasr') . "</button>";
581
 
582
- }
583
- else {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
584
  echo "&nbsp;&nbsp;&nbsp;";
585
- _e("I've found multiple set votes but I couldn't insert into db", 'yasr');
586
- echo "<br />";
587
  }
588
- } //End if $multi_data
589
 
590
- //Multiple set are found, but there is not data
591
- else {
 
 
592
  echo "&nbsp;&nbsp;&nbsp;";
593
- _e( "I've found multi set but with no data", 'yasr');
594
  echo "<br />";
595
  }
 
 
596
 
597
- } //End if $insert_multi_set
598
-
599
- //Query failed insert set name
600
  else {
601
  echo "&nbsp;&nbsp;&nbsp;";
602
- _e("I've found multi set name but I couldn't insert into db", 'yasr');
603
- echo "<br />";
604
  }
605
-
606
- } //End if $multi_set_names
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
607
 
608
  else {
609
- echo "&nbsp;&nbsp;&nbsp;";
610
- _e ("Multiset was not found. Imported is done!", 'yasr');
 
 
 
611
  }
612
 
613
- echo "</div>";
614
 
615
- die ();
616
 
617
- } //End function
618
 
619
- /**************** END Admin ajax functions ****************/
620
 
 
 
 
621
 
622
- /**************** NON Admin ajax functions ****************/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
623
 
624
- /****** Yasr insert visitor votes ******/
625
 
626
- function yasr_insert_visitor_votes() {
627
 
628
- if (is_admin()) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
629
  add_action( 'wp_ajax_yasr_send_visitor_rating', 'yasr_insert_visitor_votes_callback' );
630
  add_action( 'wp_ajax_nopriv_yasr_send_visitor_rating', 'yasr_insert_visitor_votes_callback' );
631
- }
632
 
633
  function yasr_insert_visitor_votes_callback () {
634
  if(isset($_POST['rating']) && isset($_POST['post_id'])) {
@@ -707,24 +899,21 @@ function yasr_insert_visitor_votes() {
707
  $total_rating = ($user_votes_sum / $number_of_votes);
708
  $total_rating=round ($total_rating, 1);
709
  echo "<div class=\"rateit bigstars\" id=\"yasr_rateit_user_votes_voted\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$total_rating\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
710
- <br /><strong>Vote Saved.</strong><br />Average Rating $total_rating / 5 ($number_of_votes votes casts)";
711
  }
712
 
713
  elseif ($new_row_result) {
714
  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>
715
- <br /><strong>Vote Saved.</strong><br />Rating $rating / 5 (1 vote casts)";
716
  }
717
 
718
  die(); // this is required to return a proper result
719
  }
720
 
721
- }
722
 
723
- function yasr_get_readonly_visitor_shortcode () {
724
- if (is_admin()) {
725
- add_action( 'wp_ajax_yasr_readonly_visitor_shortcode', 'yasr_readonly_visitor_shortcode_callback' );
726
- add_action( 'wp_ajax_nopriv_yasr_readonly_visitor_shortcode', 'yasr_readonly_visitor_shortcode_callback' );
727
- }
728
 
729
  function yasr_readonly_visitor_shortcode_callback() {
730
  if(isset($_POST['rating']) && isset($_POST['post_id']) && isset($_POST['votes']) && isset($_POST['votes_number'])) {
@@ -738,11 +927,13 @@ function yasr_get_readonly_visitor_shortcode () {
738
  }
739
 
740
  echo "<div class=\"rateit bigstars\" id=\"yasr_rateit_user_votes_voted_ro\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$average_rating\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
741
- <br /><strong>You've already voted this article with $rating</strong><br />Average $average_rating / 5 ($number_of_votes votes casts)";
 
 
742
 
743
  die(); // this is required to return a proper result
744
 
745
  } //End callback function
746
- }
747
 
748
  ?>
15
  if (isset($_POST['rating']) && ($_POST['post_id'])) {
16
  global $current_user;
17
  get_currentuserinfo();
 
18
  $rating = $_POST['rating'];
19
  $post_id = $_POST['post_id'];
20
  $reviewer_id = $current_user->ID;
21
+ $nonce = $_POST['nonce'];
22
  }
23
 
24
  else {
29
  wp_die( __( 'You do not have sufficient permissions to access this page.', 'yasr' ) );
30
  }
31
 
32
+ if ( ! wp_verify_nonce( $nonce, 'yasr_nonce_insert_overall_rating' ) ) {
33
+ die( 'Security check' );
34
+ }
35
+
36
  global $wpdb;
37
 
38
  //If update works means that visitor already rated this post
75
 
76
  add_action( 'wp_ajax_yasr_send_id_nameset', 'yasr_output_multiple_set_callback' );
77
 
78
+
79
  function yasr_output_multiple_set_callback() {
80
  if(isset($_POST['set_id']) && isset($_POST['post_id'])) {
81
  $set_type = $_POST['set_id'];
82
  $post_id = $_POST['post_id'];
83
+ $nonce_visitor = $_POST['nonce_visitor'];
84
  }
85
  else {
86
  exit();
87
  }
88
 
89
+ if ( ! current_user_can( 'manage_options' ) ) {
90
+ wp_die( __( 'You do not have sufficient permissions to access this page.', 'yasr' ) );
91
+ }
92
+
93
+ if ( ! wp_verify_nonce( $nonce_visitor, 'yasr_nonce_insert_visitor_rating' ) ) {
94
+ die( 'Security check' );
95
+ }
96
+
97
  global $wpdb;
98
 
99
  $set_values=yasr_get_multi_set_values_and_field ($post_id, $set_type);
102
  if (!$set_values) {
103
  echo "<p>";
104
 
105
+ _e('Choose a vote for each element', 'yasr');
106
 
107
  echo "
108
 
142
 
143
  echo "<tr> <td>";
144
  echo "$name->name </td>";
145
+ 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>";
146
  echo "</tr>";
147
  }
148
  echo "</table>
179
  $set_content->vote = $integer_vote+1;
180
  }
181
 
182
+ 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>";
183
  } //End foreach
184
  echo "</table>";
185
 
207
  $vote = $_POST['rating'];
208
  $id_field = $_POST['id_field'];
209
  $set_type = $_POST['set_type'];
210
+ $nonce = $_POST['nonce'];
211
  }
212
  else {
213
  exit();
217
  wp_die( __( 'You do not have sufficient permissions to access this page.', 'yasr' ) );
218
  }
219
 
220
+ if ( ! wp_verify_nonce( $nonce, 'yasr_nonce_insert_multi_rating' ) ) {
221
+ die( 'Security check' );
222
+ }
223
+
224
  global $wpdb;
225
 
226
  //Check if vote already exist
461
  foreach ($set_name as $name) {
462
  echo "
463
  <tr>
464
+
465
+ <td width=\"80%\">
466
+ Element #$i <input type=\"text\" value=\"$name->name\" name=\"edit-multi-set-element-$name->id\">
467
+ </td>
468
+
469
+ <td width=\"20%\" style=\"text-align:center\">
470
+ <input type=\"checkbox\" name=\"remove-element-$name->id\">
471
+ </td>
472
+
473
  </tr>
474
  ";
475
  $i++;
480
 
481
  echo "
482
 
483
+ <input type=\"hidden\" name=\"yasr-edit-form-number-elements\" id=\"yasr-edit-form-number-elements\" value=\"$i\">
484
+
485
+ </table>
486
+
487
+ <table width=\"100%\" class=\"yasr-edit-form-remove-entire-set\">
488
+ <tr>
489
+
490
+ <td width=\"80%\">Remove whole set?</td>
491
+
492
+ <td width=\"20%\" style=\"text-align:center\">
493
+ <input type=\"checkbox\" name=\"yasr-remove-multi-set\" value=\"$set_type\">
494
+ </td>
495
+
496
+ </tr>
497
 
498
  </table>
499
 
500
  ";
501
 
502
  echo "<p>";
503
+ _e("If you remove something you will remove all the votes for that set or field. This operation CAN'T BE undone." , "yasr");
504
  echo "</p>";
505
 
506
  wp_nonce_field( 'edit-multi-set', 'add-nonce-edit-multi-set' )
515
 
516
  </form>
517
 
 
 
 
 
 
 
 
 
518
  <?php
519
 
520
  die();
528
 
529
  /********* IMPORT FUNCTIONS *********/
530
 
531
+ add_action( 'plugins_loaded', 'add_action_import_gdstar_1' );
532
 
533
+ function add_action_import_gdstar_1() {
534
+ if ( current_user_can( 'manage_options' ) ) {
535
+ add_action( 'wp_ajax_yasr_import_step1', 'yasr_import_step1_callback' );
536
+ }
537
+ }
538
 
539
+ function yasr_import_step1_callback () {
 
 
540
 
541
+ //Import reviews from GD star
542
+ $reviews=yasr_import_gdstar_data();
 
543
 
544
+ //Insert GD star review in yasr votes table
545
+ $check_query_success=yasr_insert_gdstar_data($reviews);
546
+ ?>
547
+
548
+ <div class="yasr-result-step-1">
 
 
 
 
 
549
  <?php
550
+ if ($check_query_success) {
551
+ _e( "Reviews and visitor votes have been successfull imported.", 'yasr'); ?>
552
+ <br />
553
+ <?php _e ("Step2: I will check if you used multiple set and if so I will import it. THIS MAY TAKE A WHILE!", 'yasr'); ?>
554
+ <br />
555
+ <button href=\"#\" class=\"button-primary\" id=\"import-button-step2\"> <?php _e('Proceed Step 2', 'yasr');?> </button>
556
+ <span id="loader2" style="display:none;" >&nbsp;<img src="<?php echo YASR_IMG_DIR . "/loader.gif" ?>">
557
+ </span>
558
+ <?php
559
+ }
560
 
561
+ else {
562
+ _e( "Something goes wrong! Refresh the page and try again!", 'yasr');
563
+ }
564
 
565
+ ?>
566
 
567
+ </div>
568
 
569
+ <?php
570
 
571
+ die ();
572
+ } //End import step 1
573
 
 
 
 
574
 
575
+ add_action( 'plugins_loaded', 'add_action_import_gdstar_2' );
 
576
 
577
+ function add_action_import_gdstar_2() {
578
+ if ( current_user_can( 'manage_options' ) ) {
579
+ add_action( 'wp_ajax_yasr_import_multi_set', 'yasr_check_import_set_callback' );
580
+ }
581
+ }
582
 
583
+ function yasr_check_import_set_callback () {
584
+ $multi_set_names=yasr_import_gdstar_multi_set();
 
 
 
585
 
586
+ echo "<div class=\"yasr-result-step-2\">";
 
587
 
588
+ //If multiple set are found
589
+ if($multi_set_names) {
590
+ echo "<br /><strong>";
591
+ _e("I've found multiple set! Importing..." , 'yasr');
592
+ echo "</strong><br />";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
593
 
594
+ //If multi set are found write in yasr_multi_set table
595
+ $insert_multi_set=yasr_insert_gdstar_multi_set($multi_set_names);
596
+
597
+ //If insert succes, go ahed
598
+ if ($insert_multi_set) {
599
+ echo "&nbsp;&nbsp;&nbsp;";
600
+ _e("Multi set's name has been successfull imported.", 'yasr');
601
+ echo "<br /><strong>";
602
+ _e("Now I'm going to import multi set data", 'yasr');
603
+ echo "</strong> <br />";
604
+
605
+ //Import multiple set's values from GD star rating
606
+ $multi_data=yasr_import_gdstar_multi_value();
607
+
608
+ //If set values are found, insert Gd Star multi values in yasr_multi_values
609
+ if($multi_data) {
610
+ $insert_multidata=yasr_insert_gdstar_multi_value($multi_data);
611
+ if ($insert_multidata) {
612
+ echo "&nbsp;&nbsp;&nbsp;";
613
+ _e( "All votes has been successfull imported.", 'yasr');
614
+ echo "<br />";
615
+ update_option('yasr-gdstar-imported', '1');
616
+ echo "<button href=\"#\" class=\"button-delete\" id=\"end-import\">" . __('Done', 'yasr') . "</button>";
617
+
618
+ }
619
+ else {
620
+ echo "&nbsp;&nbsp;&nbsp;";
621
+ _e("I've found multiple set votes but I couldn't insert into db", 'yasr');
622
+ echo "<br />";
623
+ }
624
+ } //End if $multi_data
625
+
626
+ //Multiple set are found, but there is not data
627
+ else {
628
  echo "&nbsp;&nbsp;&nbsp;";
629
+ _e( "I've found multi set but with no data", 'yasr');
630
+ echo "<br />";
631
  }
 
632
 
633
+ } //End if $insert_multi_set
634
+
635
+ //Query failed insert set name
636
+ else {
637
  echo "&nbsp;&nbsp;&nbsp;";
638
+ _e("I've found multi set name but I couldn't insert into db", 'yasr');
639
  echo "<br />";
640
  }
641
+
642
+ } //End if $multi_set_names
643
 
 
 
 
644
  else {
645
  echo "&nbsp;&nbsp;&nbsp;";
646
+ _e ("Multiset was not found. Imported is done!", 'yasr');
 
647
  }
648
+
649
+ echo "</div>";
650
+
651
+ die ();
652
+
653
+ } //End function
654
+
655
+
656
+
657
+
658
+ /******
659
+ Display recent votes on dashboard, called from function yasr_display_dashboard_log_wiget,
660
+ declared on yasr-db-function ******/
661
+
662
+
663
+ add_action( 'wp_ajax_yasr_change_log_page', 'yasr_change_log_page_callback' );
664
+
665
+ function yasr_change_log_page_callback () {
666
+
667
+ if (isset($_POST['pagenum'])) {
668
+
669
+ $page_num = $_POST['pagenum'];
670
+
671
+ }
672
 
673
  else {
674
+ $page_num = 1;
675
+ }
676
+
677
+ if ( ! current_user_can( 'manage_options' ) ) {
678
+ wp_die( __( 'You do not have sufficient permissions to access this page.', 'yasr' ) );
679
  }
680
 
681
+ $limit = 8; //max number of row to echo
682
 
683
+ $offset = ( $page_num - 1 ) * $limit;
684
 
685
+ global $wpdb;
686
 
687
+ $log_result = $wpdb->get_results ("SELECT * FROM ". YASR_LOG_TABLE . " ORDER BY date DESC LIMIT $offset, $limit ");
688
 
689
+ if (!$log_result) {
690
+ _e("No Recenet votes yet", "yasr");
691
+ }
692
 
693
+ else {
694
+
695
+ foreach ($log_result as $column) {
696
+
697
+ $user = get_user_by( 'id', $column->user_id ); //Get info user from user id
698
+
699
+ //If ! user means that the vote are anonymous
700
+ if ($user == FALSE) {
701
+
702
+ $user = (object) array('user_login');
703
+ $user->user_login = __('anonymous');
704
+
705
+ }
706
+
707
+ $avatar = get_avatar($column->user_id, '32'); //Get avatar from user id
708
+
709
+ $title_post = get_the_title( $column->post_id ); //Get post title from post id
710
+ $link = get_permalink( $column->post_id ); //Get post link from post id
711
+
712
+ echo "
713
+
714
+ <div class=\"yasr-log-div-child\">
715
+
716
+ <div id=\"yasr-log-image\">
717
+ $avatar
718
+ </div>
719
+
720
+ <div id=\"yasr-log-child-head\">
721
+ <span id=\"yasr-log-vote\">Vote $column->vote </span> from <strong style=\"color: blue\">$user->user_login</strong> on <span id=\"yasr-log-post\"><a href=\"$link\">$title_post</a></span>
722
+ </div>
723
+
724
+ <div id=\"yasr-log-ip-date\">
725
+
726
+ <span id=\"yasr-log-ip\">" . __("Ip address" , "yasr") . ": <span style=\"color:blue\">$column->ip</span></span>
727
+
728
+ <span id=\"yasr-log-date\">$column->date</span>
729
+
730
+ </div>
731
+
732
+ </div>
733
+
734
+ ";
735
+
736
+ } //End foreach
737
+
738
+ echo "<div id=\"yasr-log-page-navigation\">";
739
+
740
+ $wpdb->get_results ("SELECT id FROM " . YASR_LOG_TABLE );
741
+
742
+ $n_rows = $wpdb->num_rows; //Number of rows in YASR LOG TABLE
743
+
744
+ $num_of_pages = ceil($n_rows/$limit); //Number of page
745
+
746
+ if ($num_of_pages <= 3) {
747
+
748
+ for ($i=1; $i<=$num_of_pages; $i++) {
749
+
750
+ if ($i == $page_num) {
751
+ echo "<button class=\"button-primary\" value=\"$i\">$i</button>&nbsp;&nbsp;";
752
+ }
753
+
754
+ else {
755
+ echo "<button class=\"yasr-log-page-num\" value=\"$i\">$i</button>&nbsp;&nbsp;";
756
+ }
757
+
758
+ }
759
+
760
+ }
761
+
762
+ else {
763
 
764
+ _e("Pages", "yasr"); echo ": ($num_of_pages) &nbsp;&nbsp;&nbsp;";
765
 
766
+ $start_for = $page_num - 1;
767
 
768
+ if ($start_for <= 0) {
769
+ $start_for = 1;
770
+ }
771
+
772
+ $end_for = $page_num + 1;
773
+
774
+ if ($end_for >= $num_of_pages) {
775
+ $end_for = $num_of_pages;
776
+ }
777
+
778
+ if ($page_num >= 3) {
779
+ echo "<button class=\"yasr-log-page-num\" value=\"1\">&laquo; First </button>&nbsp;&nbsp;...&nbsp;&nbsp;";
780
+ }
781
+
782
+ for ($i=$start_for; $i<=$end_for; $i++) {
783
+
784
+ if ($i == $page_num) {
785
+ echo "<button class=\"button-primary\" value=\"$i\">$i</button>&nbsp;&nbsp;";
786
+ }
787
+
788
+ else {
789
+ echo "<button class=\"yasr-log-page-num\" value=\"$i\">$i</button>&nbsp;&nbsp;";
790
+ }
791
+
792
+ }
793
+
794
+ $num_of_page_less_one = $num_of_pages-1;
795
+
796
+ if ($page_num != $num_of_pages && $page_num != $num_of_page_less_one) {
797
+ echo "...&nbsp;&nbsp;<button class=\"yasr-log-page-num\" value=\"$num_of_pages\">Last &raquo;</button>&nbsp;&nbsp;";
798
+ }
799
+
800
+ }
801
+
802
+ echo "
803
+
804
+ </div>
805
+
806
+ </div>";
807
+
808
+ } // End else if !$log result
809
+
810
+ die();
811
+
812
+ }
813
+
814
+
815
+ /**************** END Admin ajax functions ****************/
816
+
817
+
818
+ /**************** NON Admin ajax functions ****************/
819
+
820
+ /****** Yasr insert visitor votes, called from yasr-shortcode-function ******/
821
+
822
  add_action( 'wp_ajax_yasr_send_visitor_rating', 'yasr_insert_visitor_votes_callback' );
823
  add_action( 'wp_ajax_nopriv_yasr_send_visitor_rating', 'yasr_insert_visitor_votes_callback' );
 
824
 
825
  function yasr_insert_visitor_votes_callback () {
826
  if(isset($_POST['rating']) && isset($_POST['post_id'])) {
899
  $total_rating = ($user_votes_sum / $number_of_votes);
900
  $total_rating=round ($total_rating, 1);
901
  echo "<div class=\"rateit bigstars\" id=\"yasr_rateit_user_votes_voted\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$total_rating\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
902
+ <br /><strong>" . __("Vote Saved" , "yasr") . "</strong><br />" . __("Average Rating", "yasr") . " $total_rating / 5 ($number_of_votes " . __("votes casts", "yasr") . ")";
903
  }
904
 
905
  elseif ($new_row_result) {
906
  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>
907
+ <br /><strong>". __("Vote Saved" , "yasr") . "</strong><br />Rating $rating / 5 (1 " . __("vote casts", "yasr") . ")";
908
  }
909
 
910
  die(); // this is required to return a proper result
911
  }
912
 
913
+ /****** Echo a readonly star set if user has already voted for a post ******/
914
 
915
+ add_action( 'wp_ajax_yasr_readonly_visitor_shortcode', 'yasr_readonly_visitor_shortcode_callback' );
916
+ add_action( 'wp_ajax_nopriv_yasr_readonly_visitor_shortcode', 'yasr_readonly_visitor_shortcode_callback' );
 
 
 
917
 
918
  function yasr_readonly_visitor_shortcode_callback() {
919
  if(isset($_POST['rating']) && isset($_POST['post_id']) && isset($_POST['votes']) && isset($_POST['votes_number'])) {
927
  }
928
 
929
  echo "<div class=\"rateit bigstars\" id=\"yasr_rateit_user_votes_voted_ro\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$average_rating\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
930
+ <br /><strong>" . __("You've already voted this article with $rating", "yasr") . "</strong><br />" . __("Average Rating", "yasr") . " $average_rating / 5 ($number_of_votes " . __("votes casts", "yasr") . ")";
931
+
932
+
933
 
934
  die(); // this is required to return a proper result
935
 
936
  } //End callback function
937
+
938
 
939
  ?>
lib/yasr-db-functions.php CHANGED
@@ -73,7 +73,7 @@ function yasr_install() {
73
 
74
  }
75
 
76
- /****************BEGIN IMPORT FUNCTIONS*******************/
77
 
78
  /****** Check for previous GD STAR INSTALLATION *******/
79
  function yasr_search_gd_star_rating () {
@@ -93,7 +93,7 @@ function yasr_search_gd_star_rating () {
93
  }
94
 
95
  else {
96
- _e( 'Gd Star Rating non trovato' );
97
  }
98
  }
99
 
@@ -324,7 +324,8 @@ function yasr_insert_gdstar_multi_value($multi_datas) {
324
  return $result;
325
  }
326
 
327
- /****************END IMPORT FUNCTIONS*******************/
 
328
 
329
 
330
 
@@ -405,7 +406,7 @@ function yasr_process_new_multi_set_form()
405
  //IF thes fields are not empty go ahed
406
  if ($_POST['multi-set-name']!='' && $_POST['multi-set-name-element-1']!='' && $_POST['multi-set-name-element-2']!='' ) {
407
 
408
- $multi_set_name = $_POST['multi-set-name'];
409
 
410
  $multi_set_name_element_=array();
411
 
@@ -532,7 +533,6 @@ function yasr_process_new_multi_set_form()
532
 
533
  } //End if ( isset( $_POST['multi-set-name']) ) {
534
 
535
-
536
  } //End yasr_process_new_multi_set_form() function
537
 
538
 
@@ -558,10 +558,57 @@ function yasr_process_edit_multi_set_form() {
558
  // Check nonce field
559
  check_admin_referer( 'edit-multi-set', 'add-nonce-edit-multi-set' );
560
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
561
  for ($i = 0; $i <= 9; $i++) {
562
 
563
- //First, che if the user want to remove some field
564
- if (isset($_POST["remove-element-$i"])) {
565
 
566
  $remove_field = $wpdb->delete (
567
  YASR_MULTI_SET_FIELDS_TABLE,
@@ -596,15 +643,15 @@ function yasr_process_edit_multi_set_form() {
596
 
597
 
598
  //update the stored elements with the new ones
599
- if (isset($_POST["edit-multi-set-element-$i"]) && !isset($_POST["remove-element-$i"]) && $i <= $number_of_stored_elements ) {
600
 
601
  $field_name = $_POST["edit-multi-set-element-$i"];
602
 
603
- //if elements name is shorter than 3 chars
604
- if (mb_strlen($field_name) <3 ) {
605
- $array_errors[] = __("Field # $i must be at least 3 charactersssss", "yasr");
606
- $error=TRUE;
607
- }
608
 
609
  else {
610
 
@@ -641,13 +688,16 @@ function yasr_process_edit_multi_set_form() {
641
 
642
  $field_name = $_POST["edit-multi-set-element-$i"];
643
 
644
- //if elements name is shorter than 3 chars
645
- if (mb_strlen($field_name) < 3) {
 
 
646
  $array_errors[] = __("Field # $i must be at least 3 characters", "yasr");
647
  $error=TRUE;
648
  }
649
 
650
- else {
 
651
 
652
  $highest_id=$wpdb->get_results("SELECT id FROM " . YASR_MULTI_SET_FIELDS_TABLE . " ORDER BY id DESC LIMIT 1 ");
653
 
@@ -694,4 +744,182 @@ function yasr_process_edit_multi_set_form() {
694
 
695
  } //End yasr_process_edit_multi_set_form() function
696
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
697
  ?>
73
 
74
  }
75
 
76
+ /*************************BEGIN IMPORT FUNCTIONS*******************************/
77
 
78
  /****** Check for previous GD STAR INSTALLATION *******/
79
  function yasr_search_gd_star_rating () {
93
  }
94
 
95
  else {
96
+ __( 'No previous Gd Star Ratings installation was found', 'yasr' );
97
  }
98
  }
99
 
324
  return $result;
325
  }
326
 
327
+
328
+ /****************************END IMPORT FUNCTIONS******************************/
329
 
330
 
331
 
406
  //IF thes fields are not empty go ahed
407
  if ($_POST['multi-set-name']!='' && $_POST['multi-set-name-element-1']!='' && $_POST['multi-set-name-element-2']!='' ) {
408
 
409
+ $multi_set_name = ucfirst(strtolower($_POST['multi-set-name']));
410
 
411
  $multi_set_name_element_=array();
412
 
533
 
534
  } //End if ( isset( $_POST['multi-set-name']) ) {
535
 
 
536
  } //End yasr_process_new_multi_set_form() function
537
 
538
 
558
  // Check nonce field
559
  check_admin_referer( 'edit-multi-set', 'add-nonce-edit-multi-set' );
560
 
561
+
562
+ //Check if user want to delete entire set
563
+
564
+ if (isset($_POST["yasr-remove-multi-set"])) {
565
+
566
+ $remove_set = $wpdb->delete (
567
+ YASR_MULTI_SET_NAME_TABLE,
568
+ array(
569
+ 'set_id' => $set_id,
570
+ ),
571
+ array ('%d')
572
+ );
573
+
574
+ $remove_set_values = $wpdb->delete (
575
+ YASR_MULTI_SET_FIELDS_TABLE,
576
+ array(
577
+ 'parent_set_id' => $set_id,
578
+ ),
579
+ array ('%d')
580
+ );
581
+
582
+ $remove_set_votes = $wpdb->delete (
583
+ YASR_MULTI_SET_VALUES_TABLE,
584
+ array(
585
+ 'set_type' => $set_id,
586
+ ),
587
+ array ('%d')
588
+ );
589
+
590
+ if ($remove_set===FALSE) {
591
+ $error = TRUE;
592
+ $array_errors[] = __("Something goes wrong trying to delete a multi-set . Please report it", 'yasr');
593
+ }
594
+
595
+ if ($remove_set_values===FALSE) {
596
+ $error = TRUE;
597
+ $array_errors[] = __("Something goes wrong trying to delete data fields for a set. Please report it", 'yasr');
598
+ }
599
+
600
+ if ($remove_set_votes===FALSE) {
601
+ $error = TRUE;
602
+ $array_errors[] = __("Something goes wrong trying to delete data values for a set. Please report it", 'yasr');
603
+ }
604
+
605
+ }
606
+
607
+
608
  for ($i = 0; $i <= 9; $i++) {
609
 
610
+ //Than, check if the user want to remove some field
611
+ if (isset($_POST["remove-element-$i"]) && !isset($_POST["yasr-remove-multi-set"]) ) {
612
 
613
  $remove_field = $wpdb->delete (
614
  YASR_MULTI_SET_FIELDS_TABLE,
643
 
644
 
645
  //update the stored elements with the new ones
646
+ if (isset($_POST["edit-multi-set-element-$i"]) && !isset($_POST["yasr-remove-multi-set"]) && !isset($_POST["remove-element-$i"]) && $i <= $number_of_stored_elements ) {
647
 
648
  $field_name = $_POST["edit-multi-set-element-$i"];
649
 
650
+ //if elements name is shorter than 3 chars
651
+ if (mb_strlen($field_name) <3 ) {
652
+ $array_errors[] = __("Field # $i must be at least 3 characters", "yasr");
653
+ $error=TRUE;
654
+ }
655
 
656
  else {
657
 
688
 
689
  $field_name = $_POST["edit-multi-set-element-$i"];
690
 
691
+ //if elements name is shorter than 3 chars return error. I use mb_strlen($field_name) > 1
692
+ //because I don't wont return error if an user add an empty field. An empty field will be
693
+ //just ignored
694
+ if (mb_strlen($field_name) > 1 && mb_strlen($field_name) < 3) {
695
  $array_errors[] = __("Field # $i must be at least 3 characters", "yasr");
696
  $error=TRUE;
697
  }
698
 
699
+ //if field is not empty
700
+ elseif ($field_name != '') {
701
 
702
  $highest_id=$wpdb->get_results("SELECT id FROM " . YASR_MULTI_SET_FIELDS_TABLE . " ORDER BY id DESC LIMIT 1 ");
703
 
744
 
745
  } //End yasr_process_edit_multi_set_form() function
746
 
747
+
748
+ /****** Adding log's widget to the dashboard ******/
749
+
750
+ add_action( 'plugins_loaded', 'add_action_dashboard_widget_log' );
751
+
752
+ function add_action_dashboard_widget_log() {
753
+
754
+ if ( current_user_can( 'manage_options' ) ) {
755
+ add_action ('wp_dashboard_setup', 'yasr_add_dashboard_widget_log');
756
+ }
757
+
758
+ }
759
+
760
+ function yasr_add_dashboard_widget_log () {
761
+
762
+ wp_add_dashboard_widget (
763
+ 'yasr_widget_log_dashboard', //slug for widget
764
+ 'Recent Ratings', //widget name
765
+ 'yasr_display_dashboard_log_wiget' //function callback
766
+ );
767
+
768
+ }
769
+
770
+
771
+ function yasr_display_dashboard_log_wiget () {
772
+
773
+
774
+ $limit = 8; //max number of row to echo
775
+
776
+ global $wpdb;
777
+
778
+ $log_result = $wpdb->get_results ("SELECT * FROM ". YASR_LOG_TABLE . " ORDER BY date DESC LIMIT 0, $limit ");
779
+
780
+ if (!$log_result) {
781
+ _e("No Recenet votes yet", "yasr");
782
+ }
783
+
784
+ else {
785
+
786
+ echo "<div id=\"yasr-log-container\">";
787
+
788
+ foreach ($log_result as $column) {
789
+
790
+ $user = get_user_by( 'id', $column->user_id );
791
+
792
+ //If ! user means that the vote are anonymous
793
+ if ($user == FALSE) {
794
+
795
+ $user = (object) array('user_login');
796
+ $user->user_login = __('anonymous');
797
+
798
+ }
799
+
800
+ $avatar = get_avatar($column->user_id, '32');
801
+
802
+ $title_post = get_the_title( $column->post_id );
803
+ $link = get_permalink( $column->post_id );
804
+
805
+ echo "
806
+
807
+ <div class=\"yasr-log-div-child\">
808
+
809
+ <div id=\"yasr-log-image\">
810
+ $avatar
811
+ </div>
812
+
813
+ <div id=\"yasr-log-child-head\">
814
+ <span id=\"yasr-log-vote\">Vote $column->vote </span> from <strong style=\"color: blue\">$user->user_login</strong> on <span id=\"yasr-log-post\"><a href=\"$link\">$title_post</a></span>
815
+ </div>
816
+
817
+ <div id=\"yasr-log-ip-date\">
818
+
819
+ <span id=\"yasr-log-ip\">" . __("Ip address" , "yasr") . ": <span style=\"color:blue\">$column->ip</span></span>
820
+
821
+ <span id=\"yasr-log-date\">$column->date</span>
822
+
823
+ </div>
824
+
825
+ </div>
826
+
827
+ ";
828
+
829
+ } //End foreach
830
+
831
+ echo "<div id=\"yasr-log-page-navigation\">";
832
+
833
+ $wpdb->get_results ("SELECT id FROM " . YASR_LOG_TABLE );
834
+
835
+ $n_rows = $wpdb->num_rows;
836
+
837
+ $num_of_pages= ceil($n_rows/$limit);
838
+
839
+ if ($num_of_pages <= 3) {
840
+
841
+ for ($i=1; $i<=$num_of_pages; $i++) {
842
+
843
+ if ($i == 1) {
844
+ echo "<button class=\"button-primary\" value=\"$i\">$i</button>&nbsp;&nbsp;";
845
+ }
846
+
847
+ else {
848
+ echo "<button class=\"yasr-log-pagenum\" value=\"$i\">$i</button>&nbsp;&nbsp;";
849
+ }
850
+
851
+ }
852
+
853
+ }
854
+
855
+ else {
856
+
857
+ _e("Pages", "yasr"); echo ": ($num_of_pages) &nbsp;&nbsp;&nbsp;";
858
+
859
+ for ($i=1; $i<=3; $i++) {
860
+
861
+ if ($i == 1) {
862
+ echo "<button class=\"button-primary\" value=\"$i\">$i</button>&nbsp;&nbsp;";
863
+ }
864
+
865
+ else {
866
+ echo "<button class=\"yasr-log-pagenum\" value=\"$i\">$i</button>&nbsp;&nbsp;";
867
+ }
868
+
869
+ }
870
+
871
+ echo "...&nbsp;&nbsp;<button class=\"yasr-log-pagenum\" value=\"$num_of_pages\">Last &raquo;</button>&nbsp;&nbsp;";
872
+ }
873
+
874
+ echo "
875
+
876
+ </div>
877
+
878
+ </div>";
879
+
880
+ }
881
+
882
+ ?>
883
+
884
+ <script type="text/javascript">
885
+
886
+ //Log
887
+ jQuery('.yasr-log-pagenum').on('click', function() {
888
+
889
+ var data = {
890
+ action : 'yasr_change_log_page',
891
+ pagenum: jQuery(this).val(),
892
+
893
+ };
894
+
895
+ jQuery.post(ajaxurl, data, function(response) {
896
+ jQuery('#yasr-log-container').html(response);
897
+ });
898
+
899
+ });
900
+
901
+ jQuery(document).ajaxComplete(function() {
902
+
903
+ jQuery('.yasr-log-page-num').on('click', function() {
904
+
905
+ var data = {
906
+ action : 'yasr_change_log_page',
907
+ pagenum: jQuery(this).val(),
908
+
909
+ };
910
+
911
+ jQuery.post(ajaxurl, data, function(response) {
912
+ jQuery('#yasr-log-container').html(response);
913
+ });
914
+
915
+ });
916
+
917
+ });
918
+
919
+ </script>
920
+
921
+ <?php
922
+
923
+ } //End callback function
924
+
925
  ?>
lib/yasr-functions.php CHANGED
@@ -4,7 +4,6 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
4
 
5
 
6
  /***** Adding javascript and css *****/
7
- function yasr_hook_js_and_css() {
8
 
9
  add_action( 'wp_enqueue_scripts', 'yasr_add_scripts' );
10
  add_action( 'admin_enqueue_scripts', 'yasr_add_scripts' );
@@ -17,20 +16,18 @@ function yasr_hook_js_and_css() {
17
  wp_enqueue_script( 'cookie', YASR_JS_DIR . 'jquery.cookie.js' , array('jquery', 'rateit'), '1.4.0', TRUE );
18
  }
19
 
20
- }
21
 
22
  /****** Translating YASR ******/
23
- function yasr_translate() {
24
 
25
  add_action('plugins_loaded', 'yasr_translate_option');
26
 
27
  function yasr_translate_option() {
28
  load_plugin_textdomain('yasr', FALSE, YASR_LANG_DIR);
29
  }
30
- }
31
 
32
  /****** Create a new Page in Administration Menu ******/
33
- function yasr_hook_options_page() {
34
 
35
  /* Hook to admin_menu the yasr_add_pages function above */
36
  add_action( 'admin_menu', 'yasr_add_pages' );
@@ -144,9 +141,9 @@ function yasr_hook_options_page() {
144
 
145
  <?php
146
 
147
- $error_new_multi_set=yasr_process_new_multi_set_form();
148
 
149
- $error_edit_multi_set=yasr_process_edit_multi_set_form();
150
 
151
  if ($error_new_multi_set) {
152
  echo "<div class=\"error\"> <p> <strong>";
@@ -189,12 +186,178 @@ function yasr_hook_options_page() {
189
 
190
  } //End yasr_settings_page_content
191
 
192
- } //End yasr hook settings page
193
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
 
195
 
196
  /****** Create 2 metaboxes in post and pages ******/
197
- function yasr_hook_metaboxes() {
198
  add_action( 'add_meta_boxes', 'yasr_add_metaboxes' );
199
 
200
  function yasr_add_metaboxes() {
@@ -229,10 +392,10 @@ function yasr_hook_metaboxes() {
229
  include (YASR_ABSOLUTE_PATH . '/yasr-metabox-multiple-rating.php');
230
  }
231
 
232
- }
 
233
 
234
  /****** Add review schema data at the end of the post *******/
235
- function yasr_add_filter_for_schema() {
236
 
237
  add_filter('the_content', 'yasr_add_overall_rating_schema');
238
 
@@ -262,10 +425,9 @@ function yasr_add_filter_for_schema() {
262
 
263
  } //END id if $overall_rating != '-1'
264
 
265
- }
266
 
267
  /****** Auto insert shortcode ******/
268
- function yasr_auto_insert_shortcode () {
269
 
270
  add_filter('the_content', 'yasr_auto_insert_shortcode_callback');
271
 
@@ -292,7 +454,7 @@ function yasr_auto_insert_shortcode () {
292
  return $content . $overall_rating_shortcode;
293
  break;
294
  } //End Switch
295
- } //end ($option['what']==='overall_rating')
296
 
297
  elseif ($option['what']=='visitor_rating') {
298
  switch ($option['where']) {
@@ -330,7 +492,6 @@ function yasr_auto_insert_shortcode () {
330
 
331
  } //End function yasr_auto_insert_shortcode_callback
332
 
333
- }
334
 
335
 
336
  /****** Create a new button in Tinymce for use shortag
@@ -364,101 +525,4 @@ function yasr_add_tinymce_button($buttons) {
364
  //Add the button ID to the $button array
365
  $buttons[] = "yasr_button";
366
  return $buttons;
367
- }
368
-
369
-
370
- /****** Create a form for settings page to create new multi set ******/
371
- function yasr_display_multi_set_form() {
372
- ?>
373
-
374
- <h4 align="center">Add New Multiple Set</h4>
375
- <em><?php _e('Field Name, Element#1 and Element#2 MUST be filled and must be long at least 3 characters', 'yasr') ?></em>
376
- <p>
377
- <form action="<?php echo admin_url('options-general.php?page=yasr_settings_page') ?>" id="form_add_multi_set" method="post">
378
- <strong><?php _e("Name", 'yasr')?></strong>
379
- <input type="text" name="multi-set-name" id="new-multi-set-name" class="input-text-multi-set">
380
- <input type="hidden" name="action" value="yasr_new_multi_set_form" />
381
-
382
- <p></p>
383
- <?php _e("You can insert up to nine element") ?>
384
- <br />
385
-
386
- <?php for($i=1; $i<=9; $i++) {
387
-
388
- echo "<strong>" . __("Element ", 'yasr') . "#$i" . "</strong>";
389
- ?>
390
- <input type="text" name="multi-set-name-element-<?php echo $i ?>" id="multi-set-name-element-<?php echo $i ?>" class="input-text-multi-set">
391
- <br />
392
-
393
- <?php } //End foreach
394
-
395
- wp_nonce_field( 'add-multi-set', 'add-nonce-new-multi-set' ) ?><!-- a little security to process on submission -->
396
-
397
- <br />
398
- <input type="submit" value="<?php _e("Create New Set", 'yasr') ?>" class="button-primary"/>
399
- </form>
400
-
401
- <?php
402
- } //End function
403
-
404
-
405
- /****** This function print the form to edit multi-set ******/
406
- function yasr_edit_multi_form() {
407
-
408
- $multi_set=yasr_get_multi_set();
409
-
410
- global $wpdb;
411
-
412
- $n_multi_set = $wpdb->num_rows; //wpdb->num_rows always store the last of the last query
413
-
414
- if ($n_multi_set > 1) {
415
- ?>
416
-
417
- <button href="#" class="button-delete" id="yasr-manage-multi-set"> <?php _e("Manage existing multi-set", 'yasr'); ?> </button>
418
-
419
- <div class="yasr-manage-multiset">
420
-
421
- <?php _e('Wich set do you want to edit or remove?', 'yasr')?>
422
-
423
- <select id ="yasr_select_edit_set">
424
- <?php foreach ($multi_set as $name) { ?>
425
- <option value="<?php echo $name->set_id ?>"><?php echo $name->set_name ?></option>
426
- <?php } //End foreach ?>
427
- </select>
428
-
429
- </div>
430
-
431
- <?php
432
- } //End if n_multi_set >1
433
-
434
- elseif ($n_multi_set == 1) {
435
- ?>
436
-
437
- <button href="#" class="button-delete" id="yasr-manage-multi-set-single"> <?php _e("Manage existing multi-set", 'yasr'); ?> </button>
438
-
439
- <div class="yasr-manage-multiset-single">
440
-
441
- <?php
442
-
443
- $set_name=$wpdb->get_results("SELECT field_name AS name, field_id AS id
444
- FROM " . YASR_MULTI_SET_FIELDS_TABLE . "
445
- ORDER BY field_id ASC");
446
-
447
- $i=1;
448
- foreach ($set_name as $name) {
449
- echo "Element #$i <input type=\"text\" value=\"$name->name\"> <br />";
450
- $i++;
451
- }
452
-
453
- ?>
454
-
455
- </div>
456
-
457
- <?php
458
- }
459
-
460
- else {
461
- _e("No multiple set were found");
462
- }
463
-
464
- }//End function
4
 
5
 
6
  /***** Adding javascript and css *****/
 
7
 
8
  add_action( 'wp_enqueue_scripts', 'yasr_add_scripts' );
9
  add_action( 'admin_enqueue_scripts', 'yasr_add_scripts' );
16
  wp_enqueue_script( 'cookie', YASR_JS_DIR . 'jquery.cookie.js' , array('jquery', 'rateit'), '1.4.0', TRUE );
17
  }
18
 
19
+
20
 
21
  /****** Translating YASR ******/
 
22
 
23
  add_action('plugins_loaded', 'yasr_translate_option');
24
 
25
  function yasr_translate_option() {
26
  load_plugin_textdomain('yasr', FALSE, YASR_LANG_DIR);
27
  }
28
+
29
 
30
  /****** Create a new Page in Administration Menu ******/
 
31
 
32
  /* Hook to admin_menu the yasr_add_pages function above */
33
  add_action( 'admin_menu', 'yasr_add_pages' );
141
 
142
  <?php
143
 
144
+ $error_new_multi_set=yasr_process_new_multi_set_form(); //defined in yasr-db-functions
145
 
146
+ $error_edit_multi_set=yasr_process_edit_multi_set_form(); //defined in yasr-db-functions
147
 
148
  if ($error_new_multi_set) {
149
  echo "<div class=\"error\"> <p> <strong>";
186
 
187
  } //End yasr_settings_page_content
188
 
 
189
 
190
+ /****** Create a form for settings page to create new multi set ******/
191
+ function yasr_display_multi_set_form() {
192
+ ?>
193
+
194
+ <h4 align="center">Add New Multiple Set</h4>
195
+ <em><?php _e('Field Name, Element#1 and Element#2 MUST be filled and must be long at least 3 characters', 'yasr') ?></em>
196
+ <p>
197
+ <form action="<?php echo admin_url('options-general.php?page=yasr_settings_page') ?>" id="form_add_multi_set" method="post">
198
+ <strong><?php _e("Name", 'yasr')?></strong>
199
+ <input type="text" name="multi-set-name" id="new-multi-set-name" class="input-text-multi-set">
200
+ <input type="hidden" name="action" value="yasr_new_multi_set_form" />
201
+
202
+ <p></p>
203
+ <?php _e("You can insert up to nine element") ?>
204
+ <br />
205
+
206
+ <?php for($i=1; $i<=9; $i++) {
207
+
208
+ echo "<strong>" . __("Element ", 'yasr') . "#$i" . "</strong>";
209
+ ?>
210
+ <input type="text" name="multi-set-name-element-<?php echo $i ?>" id="multi-set-name-element-<?php echo $i ?>" class="input-text-multi-set">
211
+ <br />
212
+
213
+ <?php } //End foreach
214
+
215
+ wp_nonce_field( 'add-multi-set', 'add-nonce-new-multi-set' ) ?><!-- a little security to process on submission -->
216
+
217
+ <br />
218
+ <input type="submit" value="<?php _e("Create New Set", 'yasr') ?>" class="button-primary"/>
219
+ </form>
220
+
221
+ <?php
222
+ } //End function
223
+
224
+
225
+ /****** This function print the form to edit multi-set ******/
226
+ function yasr_edit_multi_form() {
227
+
228
+ $multi_set=yasr_get_multi_set();
229
+
230
+ global $wpdb;
231
+
232
+ $n_multi_set = $wpdb->num_rows; //wpdb->num_rows always store the last of the last query
233
+
234
+ if ($n_multi_set > 1) {
235
+ ?>
236
+
237
+ <button href="#" class="button-delete" id="yasr-manage-multi-set"> <?php _e("Manage existing multi-set", 'yasr'); ?> </button>
238
+
239
+ <div class="yasr-manage-multiset">
240
+
241
+ <?php _e('Wich set do you want to edit or remove?', 'yasr')?>
242
+
243
+ <select id ="yasr_select_edit_set">
244
+ <?php foreach ($multi_set as $name) { ?>
245
+ <option value="<?php echo $name->set_id ?>"><?php echo $name->set_name ?></option>
246
+ <?php } //End foreach ?>
247
+ </select>
248
+
249
+ </div>
250
+
251
+ <?php
252
+ } //End if n_multi_set >1
253
+
254
+ elseif ($n_multi_set == 1) {
255
+
256
+ $set_name=$wpdb->get_results("SELECT field_name AS name, field_id AS id, parent_set_id AS set_id
257
+ FROM " . YASR_MULTI_SET_FIELDS_TABLE . "
258
+ ORDER BY field_id ASC");
259
+
260
+ foreach ($multi_set as $find_set_id) {
261
+ $set_type = $find_set_id->set_id;
262
+ }
263
+
264
+ ?>
265
+
266
+ <button href="#" class="button-delete" id="yasr-manage-multi-set-single"> <?php _e("Manage existing multi-set", 'yasr'); ?> </button>
267
+
268
+ <div class="yasr-manage-multiset-single">
269
+
270
+ <form action=" <?php echo admin_url('options-general.php?page=yasr_settings_page') ?>" id="form_edit_multi_set" method="post">
271
+
272
+ <input type="hidden" name="yasr_edit_multi_set_form" value="<?php echo $set_type ?>" />
273
+
274
+ <table id="yasr-table-form-edit-multi-set">
275
+ <tr>
276
+
277
+ <td id="yasr-table-form-edit-multi-set-header">
278
+ <?php _e('Field name', 'yasr') ?>
279
+ </td>
280
+
281
+ <td id="yasr-table-form-edit-multi-set-remove">
282
+ <?php _e('Remove', 'yasr') ?>
283
+ </td>
284
+
285
+ </tr>
286
+
287
+ <?php
288
+
289
+ $i=1;
290
+ foreach ($set_name as $name) {
291
+ echo "
292
+ <tr>
293
+
294
+ <td width=\"80%\">
295
+ Element #$i <input type=\"text\" value=\"$name->name\" name=\"edit-multi-set-element-$name->id\">
296
+ </td>
297
+
298
+ <td width=\"20%\" style=\"text-align:center\">
299
+ <input type=\"checkbox\" name=\"remove-element-$name->id\">
300
+ </td>
301
+
302
+ </tr>
303
+ ";
304
+ $i++;
305
+ }
306
+
307
+
308
+ $i = $i-1; //This is the number of the fields
309
+
310
+ echo "
311
+
312
+ <input type=\"hidden\" name=\"yasr-edit-form-number-elements\" id=\"yasr-edit-form-number-elements\" value=\"$i\">
313
+
314
+ </table>
315
+
316
+ <table width=\"100%\" class=\"yasr-edit-form-remove-entire-set\">
317
+ <tr>
318
+
319
+ <td width=\"80%\">Remove whole set?</td>
320
+
321
+ <td width=\"20%\" style=\"text-align:center\">
322
+ <input type=\"checkbox\" name=\"yasr-remove-multi-set\" value=\"$set_type\">
323
+ </td>
324
+
325
+ </tr>
326
+
327
+ </table>
328
+
329
+ ";
330
+
331
+ echo "<p>";
332
+ _e("If you remove something you will remove all the votes for that set or field. This operation CAN'T BE undone." , "yasr");
333
+ echo "</p>";
334
+
335
+ wp_nonce_field( 'edit-multi-set', 'add-nonce-edit-multi-set' )
336
+
337
+ ?>
338
+
339
+ <div id="yasr-element-limit" style="display:none; color:red"><?php _e("You can use up to 9 elements" , "yasr") ?></div>
340
+
341
+ <input type="button" class="button-delete" id="yasr-add-field-edit-multiset" value="<?php _e('Add element', 'yasr'); ?>">
342
+
343
+ <input type="submit" value="<?php _e('Save changes', 'yasr') ?>" class="button-primary" >
344
+
345
+ </form>
346
+
347
+ </div>
348
+
349
+ <?php
350
+ }
351
+
352
+ else {
353
+ _e("No multiple set were found");
354
+ }
355
+
356
+ }//End function
357
 
358
 
359
  /****** Create 2 metaboxes in post and pages ******/
360
+
361
  add_action( 'add_meta_boxes', 'yasr_add_metaboxes' );
362
 
363
  function yasr_add_metaboxes() {
392
  include (YASR_ABSOLUTE_PATH . '/yasr-metabox-multiple-rating.php');
393
  }
394
 
395
+
396
+
397
 
398
  /****** Add review schema data at the end of the post *******/
 
399
 
400
  add_filter('the_content', 'yasr_add_overall_rating_schema');
401
 
425
 
426
  } //END id if $overall_rating != '-1'
427
 
428
+
429
 
430
  /****** Auto insert shortcode ******/
 
431
 
432
  add_filter('the_content', 'yasr_auto_insert_shortcode_callback');
433
 
454
  return $content . $overall_rating_shortcode;
455
  break;
456
  } //End Switch
457
+ } //end ($option['what']=='overall_rating')
458
 
459
  elseif ($option['what']=='visitor_rating') {
460
  switch ($option['where']) {
492
 
493
  } //End function yasr_auto_insert_shortcode_callback
494
 
 
495
 
496
 
497
  /****** Create a new button in Tinymce for use shortag
525
  //Add the button ID to the $button array
526
  $buttons[] = "yasr_button";
527
  return $buttons;
528
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/yasr-shortcode-functions.php CHANGED
@@ -26,96 +26,109 @@ add_shortcode ('yasr_visitor_votes', 'shortcode_visitor_votes_callback');
26
 
27
  function shortcode_visitor_votes_callback () {
28
 
29
- $votes=yasr_get_visitor_votes();
30
 
31
- $medium_rating=0; //Avoid undefined variable
32
 
33
- if (!$votes) {
34
- $votes=0; //Avoid undefined variable if there is not overall rating
35
- $votes_number=0; //Avoid undefined variable
36
- }
 
37
 
38
- else {
39
- foreach ($votes as $user_votes) {
40
- $votes_number = $user_votes->number_of_votes;
41
- if ($votes_number !=0 ) {
42
- $medium_rating = ($user_votes->sum_votes/$votes_number);
 
 
 
 
 
 
43
  }
44
- }
45
- }
46
-
47
- $medium_rating=round($medium_rating, 1);
48
-
49
- if ($votes_number>0) {
50
- $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\">
51
- </div><br />Rating $medium_rating / 5 ($votes_number votes casts)</div>";
52
- }
53
- else {
54
- $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=\"0\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\">
55
- </div><br />No rating yet</div>";
56
- }
57
-
58
- ?>
59
-
60
- <script>
61
- jQuery(document).ready(function() {
62
-
63
- var tooltipvalues = ['bad', 'poor', 'ok', 'good', 'super'];
64
- jQuery("#yasr_rateit_visitor_votes").bind('over', function (event, value) { jQuery(this).attr('title', tooltipvalues[value-1]); });
65
-
66
- var postid = <?php the_ID(); ?>;
67
- var cookiename = "yasr_visitor_vote_" + postid;
68
-
69
- //If there is not cookie allow visitor to vote
70
- if (!jQuery.cookie(cookiename)) {
71
-
72
- jQuery('#yasr_rateit_visitor_votes').on('rated', function() {
73
- var el = jQuery(this);
74
- var value = el.rateit('value');
75
- var value = value.toFixed(1); //
76
- var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
77
-
78
- var data = {
79
- action: 'yasr_send_visitor_rating',
80
- rating: value,
81
- post_id: postid
82
- };
83
-
84
- //Send value to the Server
85
- jQuery.post(ajaxurl, data, function(response) {
86
- jQuery('#yasr_visitor_votes').html(response);
87
- jQuery('.rateit').rateit();
88
- //Create a cookie to disable double vote
89
- jQuery.cookie(cookiename, value, { expires : 360 });
90
- }) ;
91
- });
92
- } //End if (!jQuery.cookie(cookiename))
93
-
94
- //Else user cannot vote
95
- else {
96
- var cookievote=jQuery.cookie(cookiename);
97
- var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
98
-
99
- var data = {
100
- action: 'yasr_readonly_visitor_shortcode',
101
- rating: cookievote,
102
- votes: <?php echo $medium_rating ?>,
103
- votes_number: <?php echo $votes_number ?>,
104
- post_id: postid
105
  }
106
 
107
- jQuery.post(ajaxurl, data, function(response) {
108
- jQuery('#yasr_visitor_votes').html(response);
109
- jQuery('.rateit').rateit();
110
- });
111
- } //End else
112
 
113
- });
 
 
 
 
 
 
 
 
 
114
 
115
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
 
117
  <?php
118
- return $shortcode_html;
 
 
 
 
119
  }
120
 
121
 
26
 
27
  function shortcode_visitor_votes_callback () {
28
 
29
+ $shortcode_html = NULL; //Avoid undefined variable outside is_singular && is_main_query
30
 
31
+ if( is_singular() && is_main_query() ) {
32
 
33
+ $ajax_nonce_visitor = wp_create_nonce( "yasr_nonce_insert_visitor_rating" );
34
+
35
+ $votes=yasr_get_visitor_votes();
36
+
37
+ $medium_rating=0; //Avoid undefined variable
38
 
39
+ if (!$votes) {
40
+ $votes=0; //Avoid undefined variable if there is not overall rating
41
+ $votes_number=0; //Avoid undefined variable
42
+ }
43
+
44
+ else {
45
+ foreach ($votes as $user_votes) {
46
+ $votes_number = $user_votes->number_of_votes;
47
+ if ($votes_number !=0 ) {
48
+ $medium_rating = ($user_votes->sum_votes/$votes_number);
49
+ }
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 {
61
+ $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=\"0\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\">
62
+ </div><br /> " . __("No rating yet" , "yasr") . "</div>";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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]); });
73
+
74
+ var postid = <?php the_ID(); ?>;
75
+ var cookiename = "yasr_visitor_vote_" + postid;
76
 
77
+ //If there is not cookie allow visitor to vote
78
+ if (!jQuery.cookie(cookiename)) {
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
104
+ else {
105
+ var cookievote=jQuery.cookie(cookiename);
106
+ var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
107
+
108
+ var data = {
109
+ action: 'yasr_readonly_visitor_shortcode',
110
+ rating: cookievote,
111
+ votes: <?php echo $medium_rating ?>,
112
+ votes_number: <?php echo $votes_number ?>,
113
+ post_id: postid
114
+ }
115
+
116
+ jQuery.post(ajaxurl, data, function(response) {
117
+ jQuery('#yasr_visitor_votes').html(response);
118
+ jQuery('.rateit').rateit();
119
+ });
120
+ } //End else
121
+
122
+ });
123
+
124
+ </script>
125
 
126
  <?php
127
+
128
+ } //End if is singular
129
+
130
+ return $shortcode_html;
131
+
132
  }
133
 
134
 
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === Yasr - Yet Another Stars Rating ===
2
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8S963KJ3UW5XG
3
- Tags: Review, Star, Snippet
4
  Requires at least: 3.5
5
  Tested up to: 3.9.1
6
- Stable tag: 0.0.3
7
  License: GPL2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -49,6 +49,42 @@ If with gd-star-rating you're using a different number of stars from the default
49
 
50
  == Changelog ==
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  = 0.0.3 =
53
  * Fixed bug describe if
54
  * Code Cleanup
1
  === Yasr - Yet Another Stars Rating ===
2
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8S963KJ3UW5XG
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.3
7
  License: GPL2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
49
 
50
  == Changelog ==
51
 
52
+ = 0.2.3 =
53
+ * [yasr_visitor_votes] it's now disabled outside a post or a page
54
+ * Security fixes on ajax functions
55
+ * Various fixes on multi-set settings
56
+ * Code cleanup
57
+
58
+ = 0.2.2 =
59
+ * Fixed doulbe ajax request on overall rating when used just 1 multiple set
60
+ * Many other minor bug fixes
61
+
62
+ = 0.2.1 =
63
+ * Fixed insert rating on multi set if only 1 is used
64
+
65
+ = 0.2.0 =
66
+ * Fixed Table installation
67
+
68
+ = 0.1.3 =
69
+ * Fixed some security issues. Please Update
70
+
71
+ = 0.1.2 =
72
+ * Fixed Multi Icons
73
+
74
+ = 0.1.1 =
75
+ * Changed stars icons, now using the oxygen one
76
+ * Using big star when voting on multi set
77
+
78
+ = 0.1.0 =
79
+ * Added in admin dashboard votes log viewer
80
+ * .Po file updated
81
+ * Updated rateit to version 1.0.22
82
+
83
+ = 0.0.4 =
84
+ * Fixed creation of a new multi set
85
+ * Added the opportunity to remove entire multi set
86
+ * Code cleanup
87
+
88
  = 0.0.3 =
89
  * Fixed bug describe if
90
  * Code Cleanup
yasr-metabox-multiple-rating.php CHANGED
@@ -4,15 +4,18 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
4
 
5
  $multi_set=yasr_get_multi_set();
6
 
 
 
7
  global $wpdb;
8
 
9
- $n_multi_set = $wpdb->num_rows; //wpdb->num_rows always store the last of the last query
10
 
11
  if ($n_multi_set>1) {
12
 
13
  _e("Choose wich set you want to use");
14
 
15
  ?>
 
16
  <br />
17
  <select id ="select_set">
18
  <?php foreach ($multi_set as $name) { ?>
@@ -39,7 +42,7 @@ jQuery('#select_set').on("change", function() {
39
  jQuery('#yasr_rateit_multi_rating').html(response);
40
  jQuery('.rateit').rateit();
41
 
42
- jQuery('.rateit').on('rated', function() {
43
  var el = jQuery(this);
44
  var value = el.rateit('value');
45
  var value = value.toFixed(1);
@@ -48,6 +51,7 @@ jQuery('#select_set').on("change", function() {
48
 
49
  var data = {
50
  action: 'yasr_send_id_field_with_vote',
 
51
  rating: value,
52
  post_id: postid,
53
  id_field: idField,
@@ -59,7 +63,7 @@ jQuery('#select_set').on("change", function() {
59
  });
60
 
61
 
62
- jQuery('.rateit').on('reset', function() {
63
  var el = jQuery(this);
64
  var value = '0';
65
  var idField = el.attr('id');
@@ -67,6 +71,7 @@ jQuery('#select_set').on("change", function() {
67
 
68
  var data = {
69
  action: 'yasr_send_id_field_with_vote',
 
70
  rating: value,
71
  post_id: postid,
72
  id_field: idField,
@@ -104,20 +109,21 @@ jQuery( document ).ready(function() {
104
  set_id: <?php echo $set_id ?>,
105
  post_id: postid
106
  }
 
107
  //Send value to the Server
108
  jQuery.post(ajaxurl, data_id, function(response) {
109
  jQuery('#yasr_rateit_multi_rating').html(response);
110
  jQuery('.rateit').rateit();
111
 
112
- jQuery('.rateit').on('rated', function() {
113
  var el = jQuery(this);
114
  var value = el.rateit('value');
115
  var value = value.toFixed(1);
116
  var idField = el.attr('id');
117
- var setType = jQuery('#select_set').val();
118
 
119
  var data = {
120
  action: 'yasr_send_id_field_with_vote',
 
121
  rating: value,
122
  post_id: postid,
123
  id_field: idField,
@@ -129,7 +135,7 @@ jQuery( document ).ready(function() {
129
 
130
  });
131
 
132
- jQuery('.rateit').on('reset', function() {
133
  var el = jQuery(this);
134
  var value = '0';
135
  var idField = el.attr('id');
@@ -137,6 +143,7 @@ jQuery( document ).ready(function() {
137
 
138
  var data = {
139
  action: 'yasr_send_id_field_with_vote',
 
140
  rating: value,
141
  post_id: postid,
142
  id_field: idField,
@@ -160,6 +167,8 @@ jQuery( document ).ready(function() {
160
 
161
  <div>
162
  <p>
163
- <span id="yasr_rateit_multi_rating"></span>
 
 
164
  </p>
165
- </div>
4
 
5
  $multi_set=yasr_get_multi_set();
6
 
7
+ $ajax_nonce_multi = wp_create_nonce( "yasr_nonce_insert_multi_rating" );
8
+
9
  global $wpdb;
10
 
11
+ $n_multi_set = $wpdb->num_rows; //wpdb->num_rows always store the the count number of rows of the last query
12
 
13
  if ($n_multi_set>1) {
14
 
15
  _e("Choose wich set you want to use");
16
 
17
  ?>
18
+
19
  <br />
20
  <select id ="select_set">
21
  <?php foreach ($multi_set as $name) { ?>
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);
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,
63
  });
64
 
65
 
66
+ jQuery('.multi').on('reset', function() {
67
  var el = jQuery(this);
68
  var value = '0';
69
  var idField = el.attr('id');
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,
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,
135
 
136
  });
137
 
138
+ jQuery('.multi').on('reset', function() {
139
  var el = jQuery(this);
140
  var value = '0';
141
  var idField = el.attr('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,
167
 
168
  <div>
169
  <p>
170
+ <span id="yasr_rateit_multi_rating">
171
+
172
+ </span>
173
  </p>
174
+ </div>
yasr-metabox-overall-rating.php CHANGED
@@ -31,6 +31,9 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
31
 
32
  <?php
33
  function yasr_overall_rating_javascript() {
 
 
 
34
  ?>
35
  <script>
36
  jQuery(document).ready(function($) {
@@ -42,6 +45,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
42
 
43
  var data = {
44
  action: 'yasr_send_overall_rating',
 
45
  rating: value,
46
  post_id: postid
47
  };
@@ -59,6 +63,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
59
 
60
  var data = {
61
  action: 'yasr_send_overall_rating',
 
62
  rating: value,
63
  post_id: postid
64
  };
31
 
32
  <?php
33
  function yasr_overall_rating_javascript() {
34
+
35
+ $ajax_nonce_overall = wp_create_nonce( "yasr_nonce_insert_overall_rating" );
36
+
37
  ?>
38
  <script>
39
  jQuery(document).ready(function($) {
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
  };
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
  };
yasr-settings-page.php CHANGED
@@ -5,6 +5,13 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
5
  if ( !current_user_can( 'manage_options' ) ) {
6
  wp_die( __( 'You do not have sufficient permissions to access this page.', 'yasr' ));
7
  }
 
 
 
 
 
 
 
8
  ?>
9
 
10
 
@@ -44,6 +51,7 @@ if ( !current_user_can( 'manage_options' ) ) {
44
  </div> <!--End yasr-multi-set-left-->
45
 
46
  <div class="yasr-multi-set-right">
 
47
  <?php yasr_edit_multi_form(); ?>
48
 
49
  <div id="yasr-multi-set-response" style="display:none">
@@ -146,7 +154,6 @@ if ( !current_user_can( 'manage_options' ) ) {
146
  <!--End div wrap-->
147
  </div>
148
 
149
-
150
  <script type="text/javascript">
151
 
152
  //First Div code
@@ -168,50 +175,90 @@ if ( !current_user_can( 'manage_options' ) ) {
168
  jQuery('.yasr-manage-multiset').toggle();
169
  });
170
 
 
171
 
172
- jQuery('#yasr-manage-multi-set-single').on('click', function() {
173
- jQuery('.yasr-manage-multiset-single').toggle();
174
- });
175
 
 
176
 
177
- //If more then 1 set is used...
178
- jQuery('#yasr_select_edit_set').on("change", function() {
179
-
180
- var data = {
181
- action : 'yasr_get_multi_set',
182
- set_id : jQuery(this).val()
183
- }
184
-
185
- jQuery.post(ajaxurl, data, function(response) {
186
- jQuery('#yasr-multi-set-response').show();
187
- jQuery('#yasr-multi-set-response').toggle;
188
- jQuery('#yasr-multi-set-response').html(response);
189
- });
190
 
191
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
 
193
-
194
- jQuery(document).ajaxComplete(function(){
195
-
196
- jQuery("#yasr-add-field-edit-multiset").on('click', function() {
197
-
198
- if(counter>9){
199
- jQuery('#yasr-element-limit').show();
200
- jQuery('#yasr-add-field-edit-multiset').hide();
201
- return false;
202
- }
203
-
204
- var newTextBoxDiv = jQuery(document.createElement('tr'))
205
-
206
- newTextBoxDiv.html('<td colspan="2">Element #' + counter + ' <input type="text" name="edit-multi-set-element-' + counter + '" value="" ></td>');
207
-
208
- newTextBoxDiv.appendTo("#yasr-table-form-edit-multi-set");
209
-
210
- counter++;
211
-
212
- });
213
-
214
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
 
216
 
217
  //Terzo div code
@@ -223,16 +270,20 @@ if ( !current_user_can( 'manage_options' ) ) {
223
 
224
  //On click begin step1
225
  jQuery('#import-button').on('click', function() {
 
226
  var data = {
227
  action : 'yasr_import_step1'
228
  };
 
229
  jQuery.post(ajaxurl, data, function(response) {
230
  jQuery('#result-import').html(response);
231
  });
 
232
  }); //End step1
233
 
234
  jQuery('#result-import').on('click', '.yasr-result-step-1', function() {
235
  //Now we are going to prepare another ajax call to check if multiple set exists
 
236
  var data = {
237
  action: 'yasr_import_multi_set'
238
  };
@@ -240,6 +291,7 @@ if ( !current_user_can( 'manage_options' ) ) {
240
  jQuery.post(ajaxurl, data, function(response) {
241
  jQuery('#result-import').append(response);
242
  });
 
243
  }); //End second ajax call */
244
 
245
  //Reload page after importing is done
5
  if ( !current_user_can( 'manage_options' ) ) {
6
  wp_die( __( 'You do not have sufficient permissions to access this page.', 'yasr' ));
7
  }
8
+
9
+ $multi_set=yasr_get_multi_set();
10
+
11
+ global $wpdb;
12
+
13
+ $n_multi_set = $wpdb->num_rows; //wpdb->num_rows always store the last of the last query
14
+
15
  ?>
16
 
17
 
51
  </div> <!--End yasr-multi-set-left-->
52
 
53
  <div class="yasr-multi-set-right">
54
+
55
  <?php yasr_edit_multi_form(); ?>
56
 
57
  <div id="yasr-multi-set-response" style="display:none">
154
  <!--End div wrap-->
155
  </div>
156
 
 
157
  <script type="text/javascript">
158
 
159
  //First Div code
175
  jQuery('.yasr-manage-multiset').toggle();
176
  });
177
 
178
+ <?php if ($n_multi_set == 1) { ?>
179
 
 
 
 
180
 
181
+ jQuery('#yasr-manage-multi-set-single').on('click', function() {
182
 
183
+ jQuery('.yasr-manage-multiset-single').toggle();
 
 
 
 
 
 
 
 
 
 
 
 
184
 
185
+ var counter = jQuery("#yasr-edit-form-number-elements").attr('value');
186
+
187
+ counter++;
188
+
189
+ jQuery("#yasr-add-field-edit-multiset").on('click', function() {
190
+
191
+ if(counter>9){
192
+ jQuery('#yasr-element-limit').show();
193
+ jQuery('#yasr-add-field-edit-multiset').hide();
194
+ return false;
195
+ }
196
+
197
+ var newTextBoxDiv = jQuery(document.createElement('tr'))
198
+
199
+ newTextBoxDiv.html('<td colspan="2">Element #' + counter + ' <input type="text" name="edit-multi-set-element-' + counter + '" value="" ></td>');
200
+
201
+ newTextBoxDiv.appendTo("#yasr-table-form-edit-multi-set");
202
+
203
+ counter++;
204
+
205
+ });
206
+
207
+ });
208
+
209
+ <?php
210
+
211
+ } //End if ($n_multi_set == 1)
212
 
213
+ if ($n_multi_set > 1) {
214
+
215
+ ?>
216
+
217
+
218
+ //If more then 1 set is used...
219
+ jQuery('#yasr_select_edit_set').on("change", function() {
220
+
221
+ var data = {
222
+ action : 'yasr_get_multi_set',
223
+ set_id : jQuery(this).val()
224
+ }
225
+
226
+ jQuery.post(ajaxurl, data, function(response) {
227
+ jQuery('#yasr-multi-set-response').show();
228
+ jQuery('#yasr-multi-set-response').toggle;
229
+ jQuery('#yasr-multi-set-response').html(response);
230
+ });
231
+
232
+ });
233
+
234
+
235
+ jQuery(document).ajaxComplete(function(){
236
+
237
+ var counter = jQuery("#yasr-edit-form-number-elements").attr('value');
238
+
239
+ counter++;
240
+
241
+ jQuery("#yasr-add-field-edit-multiset").on('click', function() {
242
+
243
+ if(counter>9){
244
+ jQuery('#yasr-element-limit').show();
245
+ jQuery('#yasr-add-field-edit-multiset').hide();
246
+ return false;
247
+ }
248
+
249
+ var newTextBoxDiv = jQuery(document.createElement('tr'))
250
+
251
+ newTextBoxDiv.html('<td colspan="2">Element #' + counter + ' <input type="text" name="edit-multi-set-element-' + counter + '" value="" ></td>');
252
+
253
+ newTextBoxDiv.appendTo("#yasr-table-form-edit-multi-set");
254
+
255
+ counter++;
256
+
257
+ });
258
+
259
+ });
260
+
261
+ <?php } //End if ($n_multi_set > 1) ?>
262
 
263
 
264
  //Terzo div code
270
 
271
  //On click begin step1
272
  jQuery('#import-button').on('click', function() {
273
+
274
  var data = {
275
  action : 'yasr_import_step1'
276
  };
277
+
278
  jQuery.post(ajaxurl, data, function(response) {
279
  jQuery('#result-import').html(response);
280
  });
281
+
282
  }); //End step1
283
 
284
  jQuery('#result-import').on('click', '.yasr-result-step-1', function() {
285
  //Now we are going to prepare another ajax call to check if multiple set exists
286
+
287
  var data = {
288
  action: 'yasr_import_multi_set'
289
  };
291
  jQuery.post(ajaxurl, data, function(response) {
292
  jQuery('#result-import').append(response);
293
  });
294
+
295
  }); //End second ajax call */
296
 
297
  //Reload page after importing is done
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.0.3
7
  * Author: Dario Curvino
8
  * Author URI: http://profiles.wordpress.org/dudo/
9
  * License: GPL2
@@ -28,9 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
28
  */
29
 
30
 
31
- define('YASR_VERSION_NUM', '0.0.3');
32
-
33
- update_option('yasr-version', YASR_VERSION_NUM);
34
 
35
  //Plugin absolute path
36
  define( "YASR_ABSOLUTE_PATH", dirname(__FILE__) );
@@ -62,15 +60,16 @@ require (YASR_ABSOLUTE_PATH . '/lib/yasr-shortcode-functions.php');
62
 
63
  $version_installed = get_option('yasr-version') ;
64
 
 
65
 
66
- /*If this is a fresh new installation*/
67
-
68
- if (!$version_installed) {
69
 
70
  yasr_install();
71
 
72
  }
73
 
 
 
74
  global $wpdb;
75
 
76
  define ("YASR_VOTES_TABLE", $wpdb->prefix . 'yasr_votes');
@@ -83,20 +82,5 @@ define ("YASR_MULTI_SET_VALUES_TABLE", $wpdb->prefix . 'yasr_multi_values');
83
 
84
  define ("YASR_LOG_TABLE", $wpdb->prefix . 'yasr_log');
85
 
86
- yasr_hook_js_and_css(); //Declared in yasr-functions
87
-
88
- yasr_translate(); //Declared in yasr-functions
89
-
90
- yasr_hook_options_page(); //Declared in yasr-functions
91
-
92
- yasr_hook_metaboxes(); //Declared in yasr-functions
93
-
94
- yasr_auto_insert_shortcode (); //Declared in yasr-functions
95
-
96
- yasr_add_filter_for_schema(); //Declared in yasr-functions
97
-
98
- yasr_insert_visitor_votes(); //Declared in yasr-ajax-function
99
-
100
- yasr_get_readonly_visitor_shortcode(); //Declared in yasr-ajax-function
101
 
102
  ?>
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.3
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.3');
 
 
32
 
33
  //Plugin absolute path
34
  define( "YASR_ABSOLUTE_PATH", dirname(__FILE__) );
60
 
61
  $version_installed = get_option('yasr-version') ;
62
 
63
+ //If this is a fresh new installation or version < 0.2.0
64
 
65
+ if (!$version_installed || $version_installed < '0.2.0' ) {
 
 
66
 
67
  yasr_install();
68
 
69
  }
70
 
71
+ update_option('yasr-version', YASR_VERSION_NUM);
72
+
73
  global $wpdb;
74
 
75
  define ("YASR_VOTES_TABLE", $wpdb->prefix . 'yasr_votes');
82
 
83
  define ("YASR_LOG_TABLE", $wpdb->prefix . 'yasr_log');
84
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
 
86
  ?>