Yasr – Yet Another Stars Rating - Version 1.1.7

Version Description

  • FIXED: filters on yasr_add_schema() functions
  • TWEAKED: disabled right click on rating
  • TWEAKED: install function is wrapped on register_activation_hook
Download this release

Release Info

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

Code changes from version 1.1.6 to 1.1.7

js/jquery.rateit.min.js CHANGED
@@ -1,5 +1,4 @@
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
-
1
  /*! RateIt | v1.0.22 / 05/27/2014 | https://rateit.codeplex.com/license
2
  http://rateit.codeplex.com | Twitter: @gjunge
3
  */
4
+ !function(e){function t(e){var t=e.originalEvent.changedTouches,a=t[0],i="";switch(e.type){case"touchmove":i="mousemove";break;case"touchend":i="mouseup";break;default:return}var r=document.createEvent("MouseEvent");r.initMouseEvent(i,!0,!0,window,1,a.screenX,a.screenY,a.clientX,a.clientY,!1,!1,!1,!1,0,null),a.target.dispatchEvent(r),e.preventDefault()}e.rateit={aria:{resetLabel:"reset rating",ratingLabel:"rating"}},e.fn.rateit=function(a,i){var r=1,n={},s="init",l=function(e){return e.charAt(0).toUpperCase()+e.substr(1)};if(0===this.length)return this;var d=e.type(a);if("object"==d||void 0===a||null===a)n=e.extend({},e.fn.rateit.defaults,a);else{if("string"==d&&"reset"!==a&&void 0===i)return this.data("rateit"+l(a));"string"==d&&(s="setvalue")}return this.each(function(){var d=e(this),h=function(e,t){if(null!=t){var a="aria-value"+("value"==e?"now":e),i=d.find(".rateit-range");void 0!=i.attr(a)&&i.attr(a,t)}return arguments[0]="rateit"+l(e),d.data.apply(d,arguments)};if("reset"==a){var o=h("init");for(var v in o)d.data(v,o[v]);if(h("backingfld")){var u=e(h("backingfld"));u.val(h("value")),u.trigger("change"),u[0].min&&(u[0].min=h("min")),u[0].max&&(u[0].max=h("max")),u[0].step&&(u[0].step=h("step"))}d.trigger("reset")}d.hasClass("rateit")||d.addClass("rateit");var m="rtl"!=d.css("direction");if("setvalue"==s){if(!h("init"))throw"Can't set value before init";if("readonly"!=a||1!=i||h("readonly")||(d.find(".rateit-range").unbind(),h("wired",!1)),"value"==a&&(i=null==i?h("min"):Math.max(h("min"),Math.min(h("max"),i))),h("backingfld")){var u=e(h("backingfld"));"value"==a&&u.val(i),"min"==a&&u[0].min&&(u[0].min=i),"max"==a&&u[0].max&&(u[0].max=i),"step"==a&&u[0].step&&(u[0].step=i)}h(a,i)}if(!h("init")){if(h("min",isNaN(h("min"))?n.min:h("min")),h("max",isNaN(h("max"))?n.max:h("max")),h("step",h("step")||n.step),h("readonly",void 0!==h("readonly")?h("readonly"):n.readonly),h("resetable",void 0!==h("resetable")?h("resetable"):n.resetable),h("backingfld",h("backingfld")||n.backingfld),h("starwidth",h("starwidth")||n.starwidth),h("starheight",h("starheight")||n.starheight),h("value",Math.max(h("min"),Math.min(h("max"),isNaN(h("value"))?isNaN(n.value)?n.min:n.value:h("value")))),h("ispreset",void 0!==h("ispreset")?h("ispreset"):n.ispreset),h("backingfld")){var u=e(h("backingfld")).hide();if((u.attr("disabled")||u.attr("readonly"))&&h("readonly",!0),"INPUT"==u[0].nodeName&&("range"==u[0].type||"text"==u[0].type)&&(h("min",parseInt(u.attr("min"))||h("min")),h("max",parseInt(u.attr("max"))||h("max")),h("step",parseInt(u.attr("step"))||h("step"))),"SELECT"==u[0].nodeName&&u[0].options.length>1){h("min",isNaN(h("min"))?Number(u[0].options[0].value):h("min")),h("max",Number(u[0].options[u[0].length-1].value)),h("step",Number(u[0].options[1].value)-Number(u[0].options[0].value));var c=u.find("option[selected]");1==c.length&&h("value",c.val())}else h("value",u.val())}var g="DIV"==d[0].nodeName?"div":"span";r++;var f='<button id="rateit-reset-{{index}}" type="button" data-role="none" class="rateit-reset" aria-label="'+e.rateit.aria.resetLabel+'" aria-controls="rateit-range-{{index}}"></button><{{element}} id="rateit-range-{{index}}" class="rateit-range" tabindex="0" role="slider" aria-label="'+e.rateit.aria.ratingLabel+'" aria-owns="rateit-reset-{{index}}" aria-valuemin="'+h("min")+'" aria-valuemax="'+h("max")+'" aria-valuenow="'+h("value")+'"><{{element}} class="rateit-selected" style="height:'+h("starheight")+'px"></{{element}}><{{element}} class="rateit-hover" style="height:'+h("starheight")+'px"></{{element}}></{{element}}>';d.append(f.replace(/{{index}}/gi,r).replace(/{{element}}/gi,g)),m||(d.find(".rateit-reset").css("float","right"),d.find(".rateit-selected").addClass("rateit-selected-rtl"),d.find(".rateit-hover").addClass("rateit-hover-rtl")),h("init",JSON.parse(JSON.stringify(d.data())))}d.find(".rateit-selected, .rateit-hover").height(h("starheight"));var p=d.find(".rateit-range");p.width(h("starwidth")*(h("max")-h("min"))).height(h("starheight"));var b="rateit-preset"+(m?"":"-rtl");if(h("ispreset")?d.find(".rateit-selected").addClass(b):d.find(".rateit-selected").removeClass(b),null!=h("value")){var w=(h("value")-h("min"))*h("starwidth");d.find(".rateit-selected").width(w)}var x=d.find(".rateit-reset");x.data("wired")!==!0&&x.bind("click",function(t){t.preventDefault(),x.blur();var a=e.Event("beforereset");return d.trigger(a),a.isDefaultPrevented()?!1:(d.rateit("value",null),void d.trigger("reset"))}).data("wired",!0);var y=function(t,a){var i=a.changedTouches?a.changedTouches[0].pageX:a.pageX,r=i-e(t).offset().left;return m||(r=p.width()-r),r>p.width()&&(r=p.width()),0>r&&(r=0),w=Math.ceil(r/h("starwidth")*(1/h("step")))},N=function(e){var t=e*h("starwidth")*h("step"),a=p.find(".rateit-hover");if(a.data("width")!=t){p.find(".rateit-selected").hide(),a.width(t).show().data("width",t);var i=[e*h("step")+h("min")];d.trigger("hover",i).trigger("over",i)}},k=function(t){var a=e.Event("beforerated");return d.trigger(a,[t]),a.isDefaultPrevented()?!1:(h("value",t),h("backingfld")&&e(h("backingfld")).val(t).trigger("change"),h("ispreset")&&(p.find(".rateit-selected").removeClass(b),h("ispreset",!1)),p.find(".rateit-hover").hide(),p.find(".rateit-selected").width(t*h("starwidth")-h("min")*h("starwidth")).show(),d.trigger("hover",[null]).trigger("over",[null]).trigger("rated",[t]),!0)};h("readonly")?x.hide():(h("resetable")||x.hide(),h("wired")||(p.bind("touchmove touchend",t),p.mousemove(function(e){var t=y(this,e);N(t)}),p.mouseleave(function(e){p.find(".rateit-hover").hide().width(0).data("width",""),d.trigger("hover",[null]).trigger("over",[null]),p.find(".rateit-selected").show()}),p.click(function(e){var t=y(this,e),a=t*h("step")+h("min");k(a),p.blur()}),p.keyup(function(e){(38==e.which||e.which==(m?39:37))&&k(Math.min(h("value")+h("step"),h("max"))),(40==e.which||e.which==(m?37:39))&&k(Math.max(h("value")-h("step"),h("min")))}),h("wired",!0)),h("resetable")&&x.show()),p.attr("aria-readonly",h("readonly"))})},e.fn.rateit.defaults={min:0,max:5,step:.5,starwidth:16,starheight:16,readonly:!1,resetable:!0,ispreset:!1},e(function(){e("div.rateit, span.rateit").rateit()})}(jQuery);
 
lib/yasr-db-functions.php CHANGED
@@ -122,9 +122,6 @@ function yasr_install() {
122
  $style_options['scheme_color_multiset'] = 'light';
123
 
124
  update_option("yasr_style_options", $style_options);
125
-
126
-
127
- do_action( 'yasr_scripts_on_install');
128
 
129
 
130
  }
122
  $style_options['scheme_color_multiset'] = 'light';
123
 
124
  update_option("yasr_style_options", $style_options);
 
 
 
125
 
126
 
127
  }
lib/yasr-functions.php CHANGED
@@ -312,15 +312,15 @@ add_filter('the_content', 'yasr_add_schema');
312
 
313
  $review_choosen = yasr_get_snippet_type();
314
 
315
- //$schema = apply_filters( 'yasr_filter_schema_microdata', $review_choosen );
 
316
 
317
- //$schema = yasr_pro_microdata_reviews($review_choosen);
318
-
319
- /*if ($schema) {
320
 
321
  return $content . $schema;
322
 
323
- }*/
324
 
325
  if (YASR_SNIPPET == 'overall_rating') {
326
 
@@ -459,13 +459,15 @@ add_filter('the_content', 'yasr_add_schema');
459
 
460
  $rich_snippet["@context"] = "http://schema.org/";
461
 
462
- /* $schema = apply_filters( 'yasr_filter_schema_jsonld', $review_choosen );
 
463
 
464
- if ($schema) {
 
465
 
466
  return $content . $script_type . $schema . $end_script_type;
467
 
468
- }*/
469
 
470
  if (YASR_SNIPPET == 'overall_rating') {
471
 
312
 
313
  $review_choosen = yasr_get_snippet_type();
314
 
315
+ //if doesn't exists a filter for yasr_filter_schema_microdata $review_chosen value is assigned to $schema...
316
+ $schema = apply_filters( 'yasr_filter_schema_microdata', $review_choosen );
317
 
318
+ //So check here if $schema != $review_choosen
319
+ if ($schema != $review_choosen) {
 
320
 
321
  return $content . $schema;
322
 
323
+ }
324
 
325
  if (YASR_SNIPPET == 'overall_rating') {
326
 
459
 
460
  $rich_snippet["@context"] = "http://schema.org/";
461
 
462
+ //if doesn't exists a filter for yasr_filter_schema_microdata $review_chosen value is assigned to $schema...
463
+ $schema = apply_filters( 'yasr_filter_schema_jsonld', $review_choosen );
464
 
465
+ //So check here if $schema != $review_choosen
466
+ if ($schema != $review_choosen) {
467
 
468
  return $content . $script_type . $schema . $end_script_type;
469
 
470
+ }
471
 
472
  if (YASR_SNIPPET == 'overall_rating') {
473
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: 5 star, admin, administrator, AJAX, five-star, javascript, jquery, post r
4
  Requires at least: 3.5
5
  Contributors: Dudo
6
  Tested up to: 4.4
7
- Stable tag: 1.1.6
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
  Yet Another Stars Rating is a simple plugin which allows you and / or your visitor to rate a post or element. Ideal for review's website
@@ -110,7 +110,13 @@ Of course not: you can easily add it on the visual editor just by clicking on th
110
 
111
  == Changelog ==
112
 
113
- 1.1.6
 
 
 
 
 
 
114
  * FIXED: Rich snippet non added in some cases
115
 
116
  = 1.1.5 =
4
  Requires at least: 3.5
5
  Contributors: Dudo
6
  Tested up to: 4.4
7
+ Stable tag: 1.1.7
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
  Yet Another Stars Rating is a simple plugin which allows you and / or your visitor to rate a post or element. Ideal for review's website
110
 
111
  == Changelog ==
112
 
113
+ = 1.1.7 =
114
+ * FIXED: filters on yasr_add_schema() functions
115
+ * TWEAKED: disabled right click on rating
116
+ * TWEAKED: install function is wrapped on register_activation_hook
117
+
118
+
119
+ = 1.1.6 =
120
  * FIXED: Rich snippet non added in some cases
121
 
122
  = 1.1.5 =
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: Yet Another Stars Rating turn your WordPress into a complete review website.
6
- * Version: 1.1.6
7
  * Author: Dario Curvino
8
  * Author URI: https://yetanotherstarsrating.com/
9
  * Text Domain: yet-another-stars-rating
@@ -32,7 +32,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
32
  if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // Exit if accessed directly
33
 
34
 
35
- define('YASR_VERSION_NUM', '1.1.6');
36
 
37
  //Plugin relative path
38
  define( "YASR_ABSOLUTE_PATH", dirname(__FILE__) );
@@ -198,16 +198,6 @@ require (YASR_ABSOLUTE_PATH . '/lib/yasr-ajax-functions.php');
198
 
199
  require (YASR_ABSOLUTE_PATH . '/lib/yasr-shortcode-functions.php');
200
 
201
- $version_installed = get_option('yasr-version') ;
202
-
203
- //If this is a fresh new installation
204
-
205
- if (!$version_installed ) {
206
-
207
- yasr_install();
208
-
209
- }
210
-
211
  global $wpdb;
212
 
213
  define ("YASR_VOTES_TABLE", $wpdb->prefix . 'yasr_votes');
@@ -225,62 +215,95 @@ define ("YASR_LOADER_IMAGE", YASR_IMG_DIR . "/loader.gif");
225
 
226
  /****** backward compatibility functions ******/
227
 
228
- //Remove july 2016
229
- if ($version_installed && $version_installed < '1.0.5') {
230
 
231
- $multiset_options = get_option('yasr_multiset_options');
232
 
233
- if($multiset_options && $multiset_options['scheme_color'] != '') {
234
 
235
- $style_options['scheme_color_multiset'] = $multiset_options['scheme_color'];
236
 
237
- }
 
238
 
239
- else {
240
 
241
- $style_options['scheme_color_multiset'] = 'light';
242
 
243
- }
 
244
 
245
- update_option("yasr_style_options", $style_options);
 
 
246
 
247
  }
248
 
249
- //remove end may 2016
250
- if ($version_installed && $version_installed < '1.0.2') {
251
 
252
- $wpdb->query("ALTER TABLE " . YASR_MULTI_SET_FIELDS_TABLE . " CHANGE field_name field_name VARCHAR( 40 )
253
- CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ;");
254
 
255
- }
256
 
257
- //Remove end April 2016
258
- if ($version_installed && $version_installed < '0.9.9') {
259
 
260
- $stored_options['snippet_format'] = 'microdata';
261
 
262
- update_option("yasr_general_options", $stored_options);
 
263
 
264
- }
265
 
 
266
 
267
- //Remove end March 2016
268
- if ($version_installed && $version_installed < '0.9.7') {
269
 
270
- $stored_options['snippet_itemtype'] = 'Product';
271
 
272
- update_option("yasr_general_options", $stored_options);
273
 
274
- }
275
 
 
276
 
277
- /****** End backward compatibility functions ******/
278
 
 
 
 
 
279
 
280
- if ($version_installed != YASR_VERSION_NUM) {
 
 
 
281
 
282
- update_option('yasr-version', YASR_VERSION_NUM);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
283
 
284
  }
285
 
 
286
  ?>
3
  * Plugin Name: Yet Another Stars Rating
4
  * Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
5
  * Description: Yet Another Stars Rating turn your WordPress into a complete review website.
6
+ * Version: 1.1.7
7
  * Author: Dario Curvino
8
  * Author URI: https://yetanotherstarsrating.com/
9
  * Text Domain: yet-another-stars-rating
32
  if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // Exit if accessed directly
33
 
34
 
35
+ define('YASR_VERSION_NUM', '1.1.7');
36
 
37
  //Plugin relative path
38
  define( "YASR_ABSOLUTE_PATH", dirname(__FILE__) );
198
 
199
  require (YASR_ABSOLUTE_PATH . '/lib/yasr-shortcode-functions.php');
200
 
 
 
 
 
 
 
 
 
 
 
201
  global $wpdb;
202
 
203
  define ("YASR_VOTES_TABLE", $wpdb->prefix . 'yasr_votes');
215
 
216
  /****** backward compatibility functions ******/
217
 
218
+ $version_installed = get_option('yasr-version');
 
219
 
220
+ global $version_installed;
221
 
222
+ //TODO use transient for version installed
223
 
 
224
 
225
+ //Run this only on plugin activation (doesn't work on update)
226
+ register_activation_hook( __FILE__, 'yasr_on_activation' );
227
 
228
+ function yasr_on_activation () {
229
 
230
+ global $version_installed;
231
 
232
+ //If this is a fresh new installation
233
+ if (!$version_installed ) {
234
 
235
+ yasr_install();
236
+
237
+ }
238
 
239
  }
240
 
 
 
241
 
 
 
242
 
243
+ add_action('plugins_loaded', 'yasr_update_version' );
244
 
245
+ function yasr_update_version() {
 
246
 
247
+ global $version_installed;
248
 
249
+ //Remove july 2016
250
+ if ($version_installed && $version_installed < '1.0.5') {
251
 
252
+ $multiset_options = get_option('yasr_multiset_options');
253
 
254
+ if($multiset_options && $multiset_options['scheme_color'] != '') {
255
 
256
+ $style_options['scheme_color_multiset'] = $multiset_options['scheme_color'];
 
257
 
258
+ }
259
 
260
+ else {
261
 
262
+ $style_options['scheme_color_multiset'] = 'light';
263
 
264
+ }
265
 
266
+ update_option("yasr_style_options", $style_options);
267
 
268
+ }
269
+
270
+ //remove end may 2016
271
+ if ($version_installed && $version_installed < '1.0.2') {
272
 
273
+ $wpdb->query("ALTER TABLE " . YASR_MULTI_SET_FIELDS_TABLE . " CHANGE field_name field_name VARCHAR( 40 )
274
+ CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ;");
275
+
276
+ }
277
 
278
+ //Remove end April 2016
279
+ if ($version_installed && $version_installed < '0.9.9') {
280
+
281
+ $stored_options['snippet_format'] = 'microdata';
282
+
283
+ update_option("yasr_general_options", $stored_options);
284
+
285
+ }
286
+
287
+
288
+ //Remove end March 2016
289
+ if ($version_installed && $version_installed < '0.9.7') {
290
+
291
+ $stored_options['snippet_itemtype'] = 'Product';
292
+
293
+ update_option("yasr_general_options", $stored_options);
294
+
295
+ }
296
+
297
+ /****** End backward compatibility functions ******/
298
+
299
+
300
+ if ($version_installed != YASR_VERSION_NUM) {
301
+
302
+ update_option('yasr-version', YASR_VERSION_NUM);
303
+
304
+ }
305
 
306
  }
307
 
308
+
309
  ?>