WooCommerce Wishlist Plugin - Version 1.20.4

Version Description

Release Date - 24 June 2020

  • Fixed accessibility issue for add to wishlist button markup
  • Fixed an issue with file upload for the integration of WooCommerce TM Extra Product Options plugin
  • Fixed an issue with the wrong wishlist status for add to wishlist shortcode
  • Fixed an issue when wishlist status wrong on specific variation product page load
  • Improved security for Wishlist REST API methods
  • Enhanced integration with WooCommerce Custom Product Addons plugin
  • Updated integration with WP Fastest Cache plugin
Download this release

Release Info

Developer templateinvaders
Plugin Icon 128x128 WooCommerce Wishlist Plugin
Version 1.20.4
Comparing to
See all releases

Code changes from version 1.20.3 to 1.20.4

assets/css/admin-form.min.css CHANGED
@@ -1,6 +1,6 @@
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
- * @version 1.20.3
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  .tiwlform-number-container{display:inline-block;margin:2px;position:relative;vertical-align:middle}
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.20.4
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  .tiwlform-number-container{display:inline-block;margin:2px;position:relative;vertical-align:middle}
assets/css/admin-setup.min.css CHANGED
@@ -1,6 +1,6 @@
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
- * @version 1.20.3
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  html{background:#f6f3ed}
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.20.4
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  html{background:#f6f3ed}
assets/css/admin.min.css CHANGED
@@ -1,6 +1,6 @@
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
- * @version 1.20.3
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  @font-face{font-family:'tinvwl-webfont';src:url("../fonts/tinvwl-webfont.eot?xu2uyi");src:url("../fonts/tinvwl-webfont.eot?xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.ttf?xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.woff?xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.svg?xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.20.4
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  @font-face{font-family:'tinvwl-webfont';src:url("../fonts/tinvwl-webfont.eot?xu2uyi");src:url("../fonts/tinvwl-webfont.eot?xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.ttf?xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.woff?xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.svg?xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
assets/css/public.min.css CHANGED
@@ -1,6 +1,6 @@
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
- * @version 1.20.3
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  @font-face{font-family:'tinvwl-webfont';src:url("../fonts/tinvwl-webfont.eot?xu2uyi");src:url("../fonts/tinvwl-webfont.eot?xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.ttf?xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.woff?xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.svg?xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.20.4
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  @font-face{font-family:'tinvwl-webfont';src:url("../fonts/tinvwl-webfont.eot?xu2uyi");src:url("../fonts/tinvwl-webfont.eot?xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.ttf?xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.woff?xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.svg?xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
assets/css/theme.min.css CHANGED
@@ -1,6 +1,6 @@
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
- * @version 1.20.3
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  .tinv-wishlist,.tinv-wishlist input,.tinv-wishlist select,.tinv-wishlist textarea,.tinv-wishlist button,.tinv-wishlist input[type="button"],.tinv-wishlist input[type="reset"],.tinv-wishlist input[type="submit"]{font-family:Georgia,serif;font-size:14px;font-weight:400;text-transform:none;line-height:1.75}
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.20.4
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  .tinv-wishlist,.tinv-wishlist input,.tinv-wishlist select,.tinv-wishlist textarea,.tinv-wishlist button,.tinv-wishlist input[type="button"],.tinv-wishlist input[type="reset"],.tinv-wishlist input[type="submit"]{font-family:Georgia,serif;font-size:14px;font-weight:400;text-transform:none;line-height:1.75}
assets/js/admin.min.js CHANGED
@@ -1,6 +1,6 @@
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
- * @version 1.20.3
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  "use strict";function TInvWL($,h){this.pf="tinvwl",this.g="_",this.ho=h||!1,this.n="TInvWL",this.aj_act=function(t){return[this.pf,t].join(this.g)},this._csel=function(t,n){return"{0}{1}{2}".format(n=n||".",this.pf,t)},this._tm=function(t){var n=$("script#{0}[type='text/template']".format(t));return n.length?n.html():""},this.formElm=function(){if($(this._csel("-form-onoff")).tiwl_onoff(),$("input[type=checkbox][tiwl-show], input[type=checkbox][tiwl-hide]").tiwl_onoffblock(),$("[tiwl-value][tiwl-show], [tiwl-value][tiwl-hide]").tiwl_byvalueblock(),void 0!==$.fn.wpColorPicker){var e=function(t){var n=t.substring(1),i=parseInt(n,16);return.2126*(i>>16&255)+.7152*(i>>8&255)+.0722*(i>>0&255)},n=this._csel("-form-color");$(n).each(function(){var n=$(this),t=$(this).closest(".tinvwl-color-picker"),i=t.find(".tinvwl-eyedropper");n.css("background-color",n.val()),175<e(n.val())&&n.css("color","#000000"),n.iris({mode:"hsv",target:$(this).parent().parent(),change:function(t,n){175<e(n.color.toCSS())?$(this).css("color","#000000"):$(this).css("color",""),$(this).css("background-color",n.color.toCSS())}}),t.on("click",".iris-square-value",function(t){t.preventDefault(),n.iris("toggle")}),i.on("click",function(t){t.preventDefault(),n.iris("show")}),n.on("focusin",function(){n.iris("show")})}),$(document).on("click",function(t){$(t.target).is(n+", .iris-picker, .iris-picker-inner, .iris-slider-offset, .tinvwl-eyedropper, .tinvwl-eyedropper .ftinvwl-eyedropper")?$(n).not($(t.target).closest(".tinvwl-color-picker").find(n)).iris("hide"):$(n).iris("hide")})}},this.wizard_page=function(t){$(t).find("select").change(this._wizard_page_ch),this.wizard_page_ch($(t).find("select"))},this.wizard_page_ch=function(t){var n=(t=$(t)).parent(this._csel("-page-select")),i=n.find("input[type=hidden]").val(),e=n.find(this._csel("-error-icon")),o=n.find(this._csel("-error-desc"));""!==t.val()?(n.removeClass("tinvwl-error"),e.hide(),o.hide()):0==i&&(n.addClass("tinvwl-error"),e.show(),o.show())},this.pageElm=function(){$(this._csel("-header","div.")).prependTo("#wpbody-content"),$(this._csel("-page-select")).each(this._wizard_page),$(".bulkactions [type=submit]").each(this._control_bulkactions),$(".action-search [type=submit]").each(this._control_search)},this.control_bulkactions=function(t){$(t).on("click",this._control_bulkactions_ck)},this.control_bulkactions_ck=function(t,n){var i=(t=$(t)).parents(".bulkactions").eq(0).find("[name=action]"),e=t.parents("form").eq(0);i&&("-1"!==i.val()&&e.find("input[type=checkbox]:checked").length||n.preventDefault())},this.control_search=function(t){$(t).on("click",this._control_search_ck)},this.control_search_ck=function(t,n){var i=(t=$(t)).parents(".action-search").eq(0).find("[name=s]");i&&""===i.val()&&n.preventDefault()},this.Run=function(){this.formElm(),this.pageElm()},this.cg=function(){var t=this.n;if(this.ho){var n=new Date;t=t+n.getFullYear()+n.getMonth()+n.getDate()}window[t]=this},this.cg(),String.prototype.format||(String.prototype.format=function(){var i=arguments;return this.replace(/{(\d+)}/g,function(t,n){return void 0!==i[n]?i[n]:t})}),function(o){var n=o.n,ho=o.ho,c="";for(var i in ho&&(c="t=new Date(),n=n+t.getFullYear()+t.getMonth()+t.getDate(),"),o)"function"!=typeof o[i]||"_"===i[0]||o.hasOwnProperty("_"+i)||eval("o._"+i+"=function(a,b,c,d){var n='"+n+"',"+c+"o=window[n]||null;if (o) {return o."+i+"(this,a,b,c,d);};};")}(this)}!function(s){s.fn.tiwl_onoff=function(t){var o=s.extend(!0,{},{value:{on:"",off:""},class:"tiwlform-onoff",wrap:"container",button:"button"},t);return s(this).each(function(){var n=s(this),t=s("<div>").attr({class:o.class+"-"+o.button}),i=o.class+"-"+o.wrap,e=s("<div>").attr({id:n.attr("id")+"_"+o.wrap,class:i});return n.is("input")&&(e.attr("class",e.attr("class")+" "+n.attr("class")),n.is(":disabled")&&(e.toggleClass("disabled",n.is(":disabled")),n.prop("disabled",!1)),e.toggleClass("checked",n.is(":checked")),n.attr("type","checkbox").hide().removeAttr("class").wrap(e).before(t),e=n.parent(),n.on("change",function(t){if(e.hasClass("disabled"))return t.preventDefault();e.toggleClass("checked",s(this).is(":checked"))}),e.on("click",function(t){if(e.hasClass("disabled"))return t.preventDefault();n.is(":enabled")&&e.hasClass("checked")===n.is(":checked")&&n.click()})),n})},s.fn.tiwl_onoffblock=function(t){var n={onEachElm:function(){},isChecked:function(){return s(this).is(":checked")}},c=s.extend(!0,{},n,t);return s(this).each(function(){function t(){function t(t,i){t=t.match(/[\w\d-\>\.\#\:\=\[\]]+/gim)||[],s.each(t,function(t,n){c.onEachElm.call(s(n).toggle(i))})}var n=s(this),i=n.attr("tiwl-show"),e=n.attr("tiwl-hide"),o=c.isChecked.call(n);return"string"==typeof i&&t(i,o),"string"==typeof e&&t(e,!o),n}var n=s(this);return n.is("input")&&"checkbox"==n.attr("type")?(s(this).on("change",t),t.call(n)):n})},s.fn.tiwl_byvalueblock=function(t){var n={onEachElm:function(){},onClick:function(){return s(this).val()==s(this).attr("tiwl-value")}},i=s.extend(!0,{},n,t);return s(this).each(function(){function t(e){function t(t,i){t=t.match(/[\w\d-\>\.\#\:\=\[\]]+/gim)||[],s.each(t,function(t,n){e.onEachElm.call(s(n).toggle(i))})}var n=s(this),i=n.attr("tiwl-show"),o=n.attr("tiwl-hide"),c=e.onClick.call(n);return"string"==typeof i&&t(i,c),"string"==typeof o&&t(o,!c),n}var n=s(this);return n.is("input")||n.is("select")?(s(this).on("change",function(){t.call(this,i)}),t.call(n,i)):n})};var n=new TInvWL(s);s(document).ready(function(){if(n.Run(),jQuery('input[name="general-show_notice"]').change(function(){var t=!jQuery(this).is(":checked"),n=jQuery('input[name="general-redirect_require_login"]');t&&!n.is(":checked")&&n.click().trigger("change"),n.closest(".tiwlform-onoff-container").toggleClass("disabled",t)}).change(),s(".tablenav").each(function(){var t=s(this);s.trim(t.find(".alignleft").html()).length||t.find(".alignleft").remove(),s.trim(t.find(".alignright").html()).length&&!t.find(".tablenav-pages").hasClass("one-page")||(t.find(".alignright").remove(),t.find(".tinv-wishlist-clear").remove()),s.trim(t.html()).length||t.remove()}),s(".tablenav .bulkactions select").addClass("tinvwl-select grey").wrap('<span class="tinvwl-select-wrap">').parent().append('<span class="tinvwl-caret"><span></span></span>'),s(".tablenav .bulkactions .button.action, .tablenav #search-submit").removeClass("button").addClass("tinvwl-btn grey"),s(".tinvwl-modal-btn").on("click",function(){s(this).next(".tinvwl-modal").addClass("tinvwl-modal-open")}),s(".tinvwl-overlay, .tinvwl-close-modal, .tinvwl_button_close").on("click",function(t){t.preventDefault(),s(this).parents(".tinvwl-modal:first").removeClass("tinvwl-modal-open")}),void 0!==s.fn.popover){var t=s(".tinvwl-help");t.popover({content:function(){return s(this).closest(".tinvwl-info-wrap").find(".tinvwl-info-desc").html()}}),t.on("click",function(){s(this).popover("toggle")}),t.on("focusout",function(){s(this).popover("hide")}),s(window).on("resize",function(){t.popover("hide")})}s("body").on("click",".tinvwl-confirm-reset",function(t){t.preventDefault(),confirm(tinvwl_comfirm.text_comfirm_reset)&&s(this).removeClass("tinvwl-confirm-reset").trigger("click")})})}(jQuery);
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.20.4
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  "use strict";function TInvWL($,h){this.pf="tinvwl",this.g="_",this.ho=h||!1,this.n="TInvWL",this.aj_act=function(t){return[this.pf,t].join(this.g)},this._csel=function(t,n){return"{0}{1}{2}".format(n=n||".",this.pf,t)},this._tm=function(t){var n=$("script#{0}[type='text/template']".format(t));return n.length?n.html():""},this.formElm=function(){if($(this._csel("-form-onoff")).tiwl_onoff(),$("input[type=checkbox][tiwl-show], input[type=checkbox][tiwl-hide]").tiwl_onoffblock(),$("[tiwl-value][tiwl-show], [tiwl-value][tiwl-hide]").tiwl_byvalueblock(),void 0!==$.fn.wpColorPicker){var e=function(t){var n=t.substring(1),i=parseInt(n,16);return.2126*(i>>16&255)+.7152*(i>>8&255)+.0722*(i>>0&255)},n=this._csel("-form-color");$(n).each(function(){var n=$(this),t=$(this).closest(".tinvwl-color-picker"),i=t.find(".tinvwl-eyedropper");n.css("background-color",n.val()),175<e(n.val())&&n.css("color","#000000"),n.iris({mode:"hsv",target:$(this).parent().parent(),change:function(t,n){175<e(n.color.toCSS())?$(this).css("color","#000000"):$(this).css("color",""),$(this).css("background-color",n.color.toCSS())}}),t.on("click",".iris-square-value",function(t){t.preventDefault(),n.iris("toggle")}),i.on("click",function(t){t.preventDefault(),n.iris("show")}),n.on("focusin",function(){n.iris("show")})}),$(document).on("click",function(t){$(t.target).is(n+", .iris-picker, .iris-picker-inner, .iris-slider-offset, .tinvwl-eyedropper, .tinvwl-eyedropper .ftinvwl-eyedropper")?$(n).not($(t.target).closest(".tinvwl-color-picker").find(n)).iris("hide"):$(n).iris("hide")})}},this.wizard_page=function(t){$(t).find("select").change(this._wizard_page_ch),this.wizard_page_ch($(t).find("select"))},this.wizard_page_ch=function(t){var n=(t=$(t)).parent(this._csel("-page-select")),i=n.find("input[type=hidden]").val(),e=n.find(this._csel("-error-icon")),o=n.find(this._csel("-error-desc"));""!==t.val()?(n.removeClass("tinvwl-error"),e.hide(),o.hide()):0==i&&(n.addClass("tinvwl-error"),e.show(),o.show())},this.pageElm=function(){$(this._csel("-header","div.")).prependTo("#wpbody-content"),$(this._csel("-page-select")).each(this._wizard_page),$(".bulkactions [type=submit]").each(this._control_bulkactions),$(".action-search [type=submit]").each(this._control_search)},this.control_bulkactions=function(t){$(t).on("click",this._control_bulkactions_ck)},this.control_bulkactions_ck=function(t,n){var i=(t=$(t)).parents(".bulkactions").eq(0).find("[name=action]"),e=t.parents("form").eq(0);i&&("-1"!==i.val()&&e.find("input[type=checkbox]:checked").length||n.preventDefault())},this.control_search=function(t){$(t).on("click",this._control_search_ck)},this.control_search_ck=function(t,n){var i=(t=$(t)).parents(".action-search").eq(0).find("[name=s]");i&&""===i.val()&&n.preventDefault()},this.Run=function(){this.formElm(),this.pageElm()},this.cg=function(){var t=this.n;if(this.ho){var n=new Date;t=t+n.getFullYear()+n.getMonth()+n.getDate()}window[t]=this},this.cg(),String.prototype.format||(String.prototype.format=function(){var i=arguments;return this.replace(/{(\d+)}/g,function(t,n){return void 0!==i[n]?i[n]:t})}),function(o){var n=o.n,ho=o.ho,c="";for(var i in ho&&(c="t=new Date(),n=n+t.getFullYear()+t.getMonth()+t.getDate(),"),o)"function"!=typeof o[i]||"_"===i[0]||o.hasOwnProperty("_"+i)||eval("o._"+i+"=function(a,b,c,d){var n='"+n+"',"+c+"o=window[n]||null;if (o) {return o."+i+"(this,a,b,c,d);};};")}(this)}!function(s){s.fn.tiwl_onoff=function(t){var o=s.extend(!0,{},{value:{on:"",off:""},class:"tiwlform-onoff",wrap:"container",button:"button"},t);return s(this).each(function(){var n=s(this),t=s("<div>").attr({class:o.class+"-"+o.button}),i=o.class+"-"+o.wrap,e=s("<div>").attr({id:n.attr("id")+"_"+o.wrap,class:i});return n.is("input")&&(e.attr("class",e.attr("class")+" "+n.attr("class")),n.is(":disabled")&&(e.toggleClass("disabled",n.is(":disabled")),n.prop("disabled",!1)),e.toggleClass("checked",n.is(":checked")),n.attr("type","checkbox").hide().removeAttr("class").wrap(e).before(t),e=n.parent(),n.on("change",function(t){if(e.hasClass("disabled"))return t.preventDefault();e.toggleClass("checked",s(this).is(":checked"))}),e.on("click",function(t){if(e.hasClass("disabled"))return t.preventDefault();n.is(":enabled")&&e.hasClass("checked")===n.is(":checked")&&n.click()})),n})},s.fn.tiwl_onoffblock=function(t){var n={onEachElm:function(){},isChecked:function(){return s(this).is(":checked")}},c=s.extend(!0,{},n,t);return s(this).each(function(){function t(){function t(t,i){t=t.match(/[\w\d-\>\.\#\:\=\[\]]+/gim)||[],s.each(t,function(t,n){c.onEachElm.call(s(n).toggle(i))})}var n=s(this),i=n.attr("tiwl-show"),e=n.attr("tiwl-hide"),o=c.isChecked.call(n);return"string"==typeof i&&t(i,o),"string"==typeof e&&t(e,!o),n}var n=s(this);return n.is("input")&&"checkbox"==n.attr("type")?(s(this).on("change",t),t.call(n)):n})},s.fn.tiwl_byvalueblock=function(t){var n={onEachElm:function(){},onClick:function(){return s(this).val()==s(this).attr("tiwl-value")}},i=s.extend(!0,{},n,t);return s(this).each(function(){function t(e){function t(t,i){t=t.match(/[\w\d-\>\.\#\:\=\[\]]+/gim)||[],s.each(t,function(t,n){e.onEachElm.call(s(n).toggle(i))})}var n=s(this),i=n.attr("tiwl-show"),o=n.attr("tiwl-hide"),c=e.onClick.call(n);return"string"==typeof i&&t(i,c),"string"==typeof o&&t(o,!c),n}var n=s(this);return n.is("input")||n.is("select")?(s(this).on("change",function(){t.call(this,i)}),t.call(n,i)):n})};var n=new TInvWL(s);s(document).ready(function(){if(n.Run(),jQuery('input[name="general-show_notice"]').change(function(){var t=!jQuery(this).is(":checked"),n=jQuery('input[name="general-redirect_require_login"]');t&&!n.is(":checked")&&n.click().trigger("change"),n.closest(".tiwlform-onoff-container").toggleClass("disabled",t)}).change(),s(".tablenav").each(function(){var t=s(this);s.trim(t.find(".alignleft").html()).length||t.find(".alignleft").remove(),s.trim(t.find(".alignright").html()).length&&!t.find(".tablenav-pages").hasClass("one-page")||(t.find(".alignright").remove(),t.find(".tinv-wishlist-clear").remove()),s.trim(t.html()).length||t.remove()}),s(".tablenav .bulkactions select").addClass("tinvwl-select grey").wrap('<span class="tinvwl-select-wrap">').parent().append('<span class="tinvwl-caret"><span></span></span>'),s(".tablenav .bulkactions .button.action, .tablenav #search-submit").removeClass("button").addClass("tinvwl-btn grey"),s(".tinvwl-modal-btn").on("click",function(){s(this).next(".tinvwl-modal").addClass("tinvwl-modal-open")}),s(".tinvwl-overlay, .tinvwl-close-modal, .tinvwl_button_close").on("click",function(t){t.preventDefault(),s(this).parents(".tinvwl-modal:first").removeClass("tinvwl-modal-open")}),void 0!==s.fn.popover){var t=s(".tinvwl-help");t.popover({content:function(){return s(this).closest(".tinvwl-info-wrap").find(".tinvwl-info-desc").html()}}),t.on("click",function(){s(this).popover("toggle")}),t.on("focusout",function(){s(this).popover("hide")}),s(window).on("resize",function(){t.popover("hide")})}s("body").on("click",".tinvwl-confirm-reset",function(t){t.preventDefault(),confirm(tinvwl_comfirm.text_comfirm_reset)&&s(this).removeClass("tinvwl-confirm-reset").trigger("click")})})}(jQuery);
assets/js/public.js CHANGED
@@ -122,10 +122,28 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
122
  window.location.href = url;
123
  },
124
  wishlists: function wishlists(wishlist) {
125
- var i = $(this).data('tinv-wl-product'),
126
- e = $("a.tinvwl_add_to_wishlist_button[data-tinv-wl-product='" + i + "']");
 
127
  e.each(function () {
128
- $(this).attr('data-tinv-wl-list', wishlist);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
  });
130
  },
131
  msg: function msg(html) {
@@ -151,33 +169,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
151
  },
152
  status: function status(_status) {
153
  $('body').trigger('tinvwl_wishlist_added_status', [this, _status]);
154
-
155
- if (_status) {
156
- var i = $(this).data('tinv-wl-product'),
157
- e = $("a.tinvwl_add_to_wishlist_button[data-tinv-wl-product='" + i + "']");
158
- e.each(function () {
159
- $(this).addClass('tinvwl-product-in-list');
160
- });
161
- }
162
- },
163
- removed: function removed(status) {
164
- if (status) {
165
- var i = $(this).data('tinv-wl-product'),
166
- e = $("a.tinvwl_add_to_wishlist_button[data-tinv-wl-product='" + i + "']");
167
- e.each(function () {
168
- $(this).removeClass('tinvwl-product-in-list').removeClass('tinvwl-product-make-remove').attr('data-tinv-wl-action', 'addto');
169
- });
170
- }
171
- },
172
- make_remove: function make_remove(status) {
173
- if (status) {
174
- var i = $(this).data('tinv-wl-product'),
175
- e = $("a.tinvwl_add_to_wishlist_button[data-tinv-wl-product='" + i + "']");
176
- e.each(function () {
177
- $(this).toggleClass('tinvwl-product-make-remove', status).attr('data-tinv-wl-action', status ? 'remove' : 'addto');
178
- });
179
- }
180
  },
 
 
181
  counter: function counter(value) {
182
  var has_products = !('0' == value || '' == value);
183
  $('.wishlist_products_counter').toggleClass('wishlist-counter-with-products', has_products);
@@ -197,7 +191,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
197
  product_action: $(this).attr('data-tinv-wl-action') || 'addto',
198
  redirect: window.location.href
199
  },
200
- a = this;
 
201
  $(a).closest('form.cart[method=post], form.vtajaxform[method=post], .tinvwl-loop-button-wrapper').find('input:not(:disabled), select:not(:disabled), textarea:not(:disabled)').each(function () {
202
  var name_elm = $(this).attr('name'),
203
  type_elm = $(this).attr('type'),
@@ -247,6 +242,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
247
  count--;
248
  }
249
 
 
 
 
 
 
 
 
 
250
  if ('checkbox' === type_elm || 'radio' === type_elm) {
251
  if ($(this).is(':checked')) {
252
  if (!value_elm.length && 'object' !== _typeof(value_elm)) {
@@ -260,7 +263,22 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
260
  }
261
  });
262
  data = s.onPrepareDataAction.call(a, a, data) || data;
263
- $.post(s.api_url, data, function (body) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
264
  s.onDialogHide.call(a.tinvwl_dialog, a);
265
 
266
  if ('object' === _typeof(body)) {
@@ -387,6 +405,21 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
387
 
388
  $(document).on('hide_variation', '.variations_form', function (a) {
389
  var e = $(this).find('.tinvwl_add_to_wishlist_button');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
390
 
391
  if (e.length && !tinvwl_add_to_wishlist.allow_parent_variable) {
392
  a.preventDefault();
@@ -395,6 +428,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
395
  });
396
  $(document).on('show_variation', '.variations_form', function (a, b, d) {
397
  var e = $(this).find('.tinvwl_add_to_wishlist_button');
 
398
 
399
  if (e.length && e.attr('data-tinv-wl-list')) {
400
  var f = JSON.parse(e.attr('data-tinv-wl-list')),
@@ -537,16 +571,19 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
537
  if ($supports_html5_storage) {
538
  localStorage.setItem(hash_key, hash);
539
  sessionStorage.setItem(hash_key, hash);
 
 
 
540
 
541
- if ('false' !== hash) {
542
- jQuery('.wishlist_products_counter_number, body.theme-woostify .wishlist-item-count').html(hash);
543
- } else {
544
- jQuery('.wishlist_products_counter_number, body.theme-woostify .wishlist-item-count').html('').closest('span.wishlist-counter-with-products').removeClass('wishlist-counter-with-products');
545
- }
546
-
547
- var has_products = !('0' == hash || 'false' == hash);
548
- jQuery('.wishlist_products_counter').toggleClass('wishlist-counter-with-products', has_products);
549
  }
 
 
 
550
  }
551
  })(jQuery);
552
  "use strict";
122
  window.location.href = url;
123
  },
124
  wishlists: function wishlists(wishlist) {
125
+ var id = $(this).data('tinv-wl-product'),
126
+ e = $("a.tinvwl_add_to_wishlist_button[data-tinv-wl-product='" + id + "']"),
127
+ g = '1' == window.tinvwl_add_to_wishlist['simple_flow'];
128
  e.each(function () {
129
+ var vid = $(this).data('tinv-wl-productvariation'),
130
+ vids = $(this).data('tinv-wl-productvariations') || [],
131
+ j = false,
132
+ data = [];
133
+
134
+ if (wishlist) {
135
+ data = $.parseJSON(wishlist);
136
+ }
137
+
138
+ for (var i in data) {
139
+ if (data[i].hasOwnProperty('in') && Array.isArray(data[i]['in']) && (-1 < (data[i]['in'] || []).indexOf(id) || -1 < (data[i]['in'] || []).indexOf(vid) || vids.some(function (r) {
140
+ return (data[i]['in'] || []).indexOf(r) >= 0;
141
+ }))) {
142
+ j = true;
143
+ }
144
+ }
145
+
146
+ $(this).attr('data-tinv-wl-list', wishlist).toggleClass('tinvwl-product-in-list', j).toggleClass('tinvwl-product-make-remove', j && g).attr('data-tinv-wl-action', j && g ? 'remove' : 'addto');
147
  });
148
  },
149
  msg: function msg(html) {
169
  },
170
  status: function status(_status) {
171
  $('body').trigger('tinvwl_wishlist_added_status', [this, _status]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  },
173
+ removed: function removed(status) {},
174
+ make_remove: function make_remove(status) {},
175
  counter: function counter(value) {
176
  var has_products = !('0' == value || '' == value);
177
  $('.wishlist_products_counter').toggleClass('wishlist-counter-with-products', has_products);
191
  product_action: $(this).attr('data-tinv-wl-action') || 'addto',
192
  redirect: window.location.href
193
  },
194
+ a = this,
195
+ formData = new FormData();
196
  $(a).closest('form.cart[method=post], form.vtajaxform[method=post], .tinvwl-loop-button-wrapper').find('input:not(:disabled), select:not(:disabled), textarea:not(:disabled)').each(function () {
197
  var name_elm = $(this).attr('name'),
198
  type_elm = $(this).attr('type'),
242
  count--;
243
  }
244
 
245
+ if ('file' === type_elm) {
246
+ var file_data = $(this)[0].files;
247
+
248
+ if (file_data) {
249
+ formData.append(name_elm, file_data[0]);
250
+ }
251
+ }
252
+
253
  if ('checkbox' === type_elm || 'radio' === type_elm) {
254
  if ($(this).is(':checked')) {
255
  if (!value_elm.length && 'object' !== _typeof(value_elm)) {
263
  }
264
  });
265
  data = s.onPrepareDataAction.call(a, a, data) || data;
266
+ $.each(data, function (key, value) {
267
+ if ('form' === key) {
268
+ $.each(value, function (k, v) {
269
+ formData.append(key + '[' + k + ']', v);
270
+ });
271
+ } else {
272
+ formData.append(key, value);
273
+ }
274
+ });
275
+ $.ajax({
276
+ url: s.api_url,
277
+ method: 'POST',
278
+ contentType: false,
279
+ processData: false,
280
+ data: formData
281
+ }).done(function (body) {
282
  s.onDialogHide.call(a.tinvwl_dialog, a);
283
 
284
  if ('object' === _typeof(body)) {
405
 
406
  $(document).on('hide_variation', '.variations_form', function (a) {
407
  var e = $(this).find('.tinvwl_add_to_wishlist_button');
408
+ e.attr('data-tinv-wl-productvariation', 0);
409
+
410
+ if (e.length && e.attr('data-tinv-wl-list')) {
411
+ var f = JSON.parse(e.attr('data-tinv-wl-list')),
412
+ j = false,
413
+ g = '1' == window.tinvwl_add_to_wishlist['simple_flow'];
414
+
415
+ for (var i in f) {
416
+ if (f[i].hasOwnProperty('in') && Array.isArray(f[i]['in']) && -1 < (f[i]['in'] || []).indexOf(0)) {
417
+ j = true;
418
+ }
419
+ }
420
+
421
+ e.toggleClass('tinvwl-product-in-list', j).toggleClass('tinvwl-product-make-remove', j && g).attr('data-tinv-wl-action', j && g ? 'remove' : 'addto');
422
+ }
423
 
424
  if (e.length && !tinvwl_add_to_wishlist.allow_parent_variable) {
425
  a.preventDefault();
428
  });
429
  $(document).on('show_variation', '.variations_form', function (a, b, d) {
430
  var e = $(this).find('.tinvwl_add_to_wishlist_button');
431
+ e.attr('data-tinv-wl-productvariation', b.variation_id);
432
 
433
  if (e.length && e.attr('data-tinv-wl-list')) {
434
  var f = JSON.parse(e.attr('data-tinv-wl-list')),
571
  if ($supports_html5_storage) {
572
  localStorage.setItem(hash_key, hash);
573
  sessionStorage.setItem(hash_key, hash);
574
+ update_product_counter(hash);
575
+ }
576
+ }
577
 
578
+ function update_product_counter(counter) {
579
+ if ('false' !== counter) {
580
+ jQuery('.wishlist_products_counter_number, body.theme-woostify .wishlist-item-count').html(counter);
581
+ } else {
582
+ jQuery('.wishlist_products_counter_number, body.theme-woostify .wishlist-item-count').html('').closest('span.wishlist-counter-with-products').removeClass('wishlist-counter-with-products');
 
 
 
583
  }
584
+
585
+ var has_products = !('0' == counter || 'false' == counter);
586
+ jQuery('.wishlist_products_counter').toggleClass('wishlist-counter-with-products', has_products);
587
  }
588
  })(jQuery);
589
  "use strict";
assets/js/public.min.js CHANGED
@@ -1,6 +1,6 @@
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
- * @version 1.20.3
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
- "use strict";function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function showTooltip(t,i){t.setAttribute("class","social social-clipboard tooltipped tooltipped-s"),t.setAttribute("aria-label",i)}function clearTooltip(t){t.currentTarget.setAttribute("class","social social-clipboard "),t.currentTarget.removeAttribute("aria-label")}!function(r){r.fn.tinvwl_to_wishlist=function(t){var i={api_url:window.location.href.split("?")[0],text_create:window.tinvwl_add_to_wishlist.text_create,text_already_in:window.tinvwl_add_to_wishlist.text_already_in,class:{dialogbox:".tinvwl_add_to_select_wishlist",select:".tinvwl_wishlist",newtitle:".tinvwl_new_input",dialogbutton:".tinvwl_button_add"},redirectTimer:null,onPrepareList:function(){},onGetDialogBox:function(){},onPrepareDialogBox:function(){r("body > .tinv-wishlist").length||r("body").append(r("<div>").addClass("tinv-wishlist")),r(this).appendTo("body > .tinv-wishlist")},onCreateWishList:function(t){r(this).append(r("<option>").html(t.title).val(t.ID).toggleClass("tinv_in_wishlist",t.in))},onSelectWishList:function(){},onDialogShow:function(t){r(t).addClass("tinv-modal-open"),r(t).removeClass("ftinvwl-pulse")},onDialogHide:function(t){r(t).removeClass("tinv-modal-open"),r(t).removeClass("ftinvwl-pulse")},onInited:function(){},onClick:function(){if(r(this).is(".disabled-add-wishlist"))return!1;r(this).is(".ftinvwl-animated")&&r(this).addClass("ftinvwl-pulse"),this.tinvwl_dialog?this.tinvwl_dialog.show_list.call(this):e.onActionProduct.call(this)},onPrepareDataAction:function(t,i){r("body").trigger("tinvwl_wishlist_button_clicked",[t,i])},filterProductAlreadyIn:function(t){t=t||[];var o={};return r("form.cart[method=post], .woocommerce-variation-add-to-cart, form.vtajaxform[method=post]").find("input, select").each(function(){var t=r(this).attr("name"),i=r(this).attr("type"),n=r(this).val();("checkbox"!==i&&"radio"!==i||r(this).is(":checked"))&&(o["form"+t]=n)}),o=o.formvariation_id,t.filter(function(t){if("object"!==_typeof(t.in)||"string"!=typeof o)return t.in;var i=parseInt(o);return 0<=t.in.indexOf(i)})},onMultiProductAlreadyIn:function(t){t=t||[];t=e.onPrepareList.call(t)||t,t=e.filterProductAlreadyIn.call(this,t)||t,r(this).parent().parent().find(".already-in").remove();var n="";switch(t.length){case 0:break;default:n=r("<ul>");r.each(t,function(t,i){n.append(r("<li>").html(r("<a>").html(i.title).attr({href:i.url})).val(i.ID))})}n.length&&r(this).closest(".tinv-modal-inner").find("img").after(r("<div>").addClass("already-in").html(e.text_already_in+" ").append(n))},onAction:{redirect:function(t){e.redirectTimer&&clearTimeout(e.redirectTimer),e.redirectTimer=window.setTimeout(function(){window.location.href=t},4e3)},force_redirect:function(t){window.location.href=t},wishlists:function(t){var i=r(this).data("tinv-wl-product");r("a.tinvwl_add_to_wishlist_button[data-tinv-wl-product='"+i+"']").each(function(){r(this).attr("data-tinv-wl-list",t)})},msg:function(t){if(!t)return!1;var i=r(t).eq(0);r("body > .tinv-wishlist").length||r("body").append(r("<div>").addClass("tinv-wishlist")),r("body > .tinv-wishlist").append(i),i.on("click",".tinv-close-modal, .tinvwl_button_close, .tinv-overlay",function(t){t.preventDefault(),i.remove(),e.redirectTimer&&clearTimeout(e.redirectTimer)})},status:function(t){if(r("body").trigger("tinvwl_wishlist_added_status",[this,t]),t){var i=r(this).data("tinv-wl-product");r("a.tinvwl_add_to_wishlist_button[data-tinv-wl-product='"+i+"']").each(function(){r(this).addClass("tinvwl-product-in-list")})}},removed:function(t){if(t){var i=r(this).data("tinv-wl-product");r("a.tinvwl_add_to_wishlist_button[data-tinv-wl-product='"+i+"']").each(function(){r(this).removeClass("tinvwl-product-in-list").removeClass("tinvwl-product-make-remove").attr("data-tinv-wl-action","addto")})}},make_remove:function(t){if(t){var i=r(this).data("tinv-wl-product");r("a.tinvwl_add_to_wishlist_button[data-tinv-wl-product='"+i+"']").each(function(){r(this).toggleClass("tinvwl-product-make-remove",t).attr("data-tinv-wl-action",t?"remove":"addto")})}},counter:function(t){var i=!("0"==t||""==t);r(".wishlist_products_counter").toggleClass("wishlist-counter-with-products",i),a(t)}}};i.onActionProduct=function(t,i){var s={form:{},tinv_wishlist_id:t||"",tinv_wishlist_name:i||"",product_type:r(this).attr("data-tinv-wl-producttype"),product_id:r(this).attr("data-tinv-wl-product")||0,product_variation:r(this).attr("data-tinv-wl-productvariation")||0,product_action:r(this).attr("data-tinv-wl-action")||"addto",redirect:window.location.href},n=this;r(n).closest("form.cart[method=post], form.vtajaxform[method=post], .tinvwl-loop-button-wrapper").find("input:not(:disabled), select:not(:disabled), textarea:not(:disabled)").each(function(){function e(t,i){if("object"!==_typeof(i))return i;for(var n in void 0===t&&(t={}),i)if(""===n){var o=-1;for(o in t)o=o;t[o=parseInt(o)+1]=e(t[n],i[n])}else t[n]=e(t[n],i[n]);return t}var t=r(this).attr("name"),i=r(this).attr("type"),n=r(this).val(),o=10;if("button"!==i&&void 0!==t){for(;/^(.+)\[([^\[\]]*?)\]$/.test(t)&&0<o;){var l=t.match(/^(.+)\[([^\[\]]*?)\]$/);if(3===l.length){var a={};a[l[2]]=n,n=a}t=l[1],o--}"checkbox"===i||"radio"===i?r(this).is(":checked")&&(n.length||"object"===_typeof(n)||(n=!0),s.form[t]=e(s.form[t],n)):s.form[t]=e(s.form[t],n)}}),s=e.onPrepareDataAction.call(n,n,s)||s,r.post(e.api_url,s,function(t){if(e.onDialogHide.call(n.tinvwl_dialog,n),"object"===_typeof(t))for(var i in t)"function"==typeof e.onAction[i]&&e.onAction[i].call(n,t[i]);else"function"==typeof e.onAction.msg&&e.onAction.msg.call(n,t)})};var e=r.extend(!0,{},i,t);return r(this).each(function(){if(!r(this).attr("data-tinv-wl-list"))return!1;if(e.dialogbox&&e.dialogbox.length&&(this.tinvwl_dialog=e.dialogbox),this.tinvwl_dialog||(this.tinvwl_dialog=e.onGetDialogBox.call(this)),!this.tinvwl_dialog){var t=r(this).nextAll(e.class.dialogbox).eq(0);t.length&&(this.tinvwl_dialog=t)}if(this.tinvwl_dialog){e.onPrepareDialogBox.call(this.tinvwl_dialog),"function"!=typeof this.tinvwl_dialog.update_list&&(this.tinvwl_dialog.update_list=function(t){var n=r(this).find(e.class.select).eq(0);r(this).find(e.class.newtitle).hide().val(""),n.html(""),r.each(t,function(t,i){e.onCreateWishList.call(n,i)}),e.text_create&&e.onCreateWishList.call(n,{ID:"",title:e.text_create,in:!1}),e.onMultiProductAlreadyIn.call(n,t),e.onSelectWishList.call(n,t),r(this).find(e.class.newtitle).toggle(""===n.val())}),"function"!=typeof this.tinvwl_dialog.show_list&&(this.tinvwl_dialog.show_list=function(){var t=r.parseJSON(r(this).attr("data-tinv-wl-list"))||[];t.length?(t=e.onPrepareList.call(t)||t,this.tinvwl_dialog.update_list(t),e.onDialogShow.call(this.tinvwl_dialog,this)):e.onActionProduct.call(this)});var o=this;r(this.tinvwl_dialog).find(e.class.dialogbutton).off("click").on("click",function(){var t,i=r(o.tinvwl_dialog).find(e.class.select),n=r(o.tinvwl_dialog).find(e.class.newtitle);i.val()||n.val()?e.onActionProduct.call(o,i.val(),n.val()):((t=n.is(":visible")?n:i).addClass("empty-name-wishlist"),window.setTimeout(function(){t.removeClass("empty-name-wishlist")},1e3))})}r(this).off("click").on("click",e.onClick),e.onInited.call(this,e)})},r(document).ready(function(){r("body").on("click",".tinvwl_add_to_wishlist_button",function(t){if(r(this).is(".disabled-add-wishlist"))return t.preventDefault(),void window.alert(tinvwl_add_to_wishlist.i18n_make_a_selection_text);r(this).is(".inited-add-wishlist")||r(this).tinvwl_to_wishlist({onInited:function(t){r(this).addClass("inited-add-wishlist"),t.onClick.call(this)}})}),r(document).on("hide_variation",".variations_form",function(t){var i=r(this).find(".tinvwl_add_to_wishlist_button");i.length&&!tinvwl_add_to_wishlist.allow_parent_variable&&(t.preventDefault(),i.addClass("disabled-add-wishlist"))}),r(document).on("show_variation",".variations_form",function(t,i,n){var o=r(this).find(".tinvwl_add_to_wishlist_button");if(o.length&&o.attr("data-tinv-wl-list")){var e=JSON.parse(o.attr("data-tinv-wl-list")),l=!1,a="1"==window.tinvwl_add_to_wishlist.simple_flow;for(var s in e)e[s].hasOwnProperty("in")&&Array.isArray(e[s].in)&&-1<(e[s].in||[]).indexOf(i.variation_id)&&(l=!0);o.toggleClass("tinvwl-product-in-list",l).toggleClass("tinvwl-product-make-remove",l&&a).attr("data-tinv-wl-action",l&&a?"remove":"addto")}t.preventDefault(),o.removeClass("disabled-add-wishlist")}),r(window).on("storage onstorage",function(t){l===t.originalEvent.key&&localStorage.getItem(l)!==sessionStorage.getItem(l)&&a(localStorage.getItem(l))});var n=[],i=!1;r("a.tinvwl_add_to_wishlist_button").each(function(){"undefined"!==r(this).data("tinv-wl-product")&&r(this).data("tinv-wl-product")&&n.push(r(this).data("tinv-wl-product"))}),r(".wishlist_products_counter_number").each(function(){i=!0});function o(){if(n.length||i){var t={ids:n,counter:i,tinvwl_request:!0};tinvwl_add_to_wishlist.wpml&&(t.lang=tinvwl_add_to_wishlist.wpml),r.ajax({url:tinvwl_add_to_wishlist.rest_root+"wishlist/v1/products",method:"POST",data:t,beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",tinvwl_add_to_wishlist.nonce)}}).done(function(t){var i=!("0"==t.counter||""==t.counter);r(".wishlist_products_counter").toggleClass("wishlist-counter-with-products",i),a(t.counter),r.each(t.products,function(t,e){var l=t,a="1"==window.tinvwl_add_to_wishlist.simple_flow;r("a.tinvwl_add_to_wishlist_button[data-tinv-wl-product='"+l+"']").each(function(){var t=r(this).data("tinv-wl-productvariation"),i=r(this).data("tinv-wl-productvariations")||[],n=!1;for(var o in e)e[o].hasOwnProperty("in")&&Array.isArray(e[o].in)&&(-1<(e[o].in||[]).indexOf(l)||-1<(e[o].in||[]).indexOf(t)||i.some(function(t){return 0<=(e[o].in||[]).indexOf(t)}))&&(n=!0);r(this).removeClass("tinvwl-add-hide").attr("data-tinv-wl-list",JSON.stringify(e)).toggleClass("tinvwl-product-in-list",n).toggleClass("tinvwl-product-make-remove",n&&a).attr("data-tinv-wl-action",n&&a?"remove":"addto")})})})}}o();var t=new MutationObserver(function(t){n=[],t.forEach(function(t){var i=t.addedNodes;null!==i&&r(i).each(function(){var t=r(this).find(".tinvwl_add_to_wishlist_button");t.length&&t.each(function(){"undefined"!==r(this).data("tinv-wl-product")&&r(this).data("tinv-wl-product")&&n.push(r(this).data("tinv-wl-product"))})})}),n.length&&o()}),e=document.body;t.observe(e,{childList:!0,subtree:!0})});var n=!0,l=tinvwl_add_to_wishlist.hash_key;try{n="sessionStorage"in window&&null!==window.sessionStorage,window.sessionStorage.setItem("ti","test"),window.sessionStorage.removeItem("ti"),window.localStorage.setItem("ti","test"),window.localStorage.removeItem("ti")}catch(t){n=!1}function a(t){if(n){localStorage.setItem(l,t),sessionStorage.setItem(l,t),"false"!==t?jQuery(".wishlist_products_counter_number, body.theme-woostify .wishlist-item-count").html(t):jQuery(".wishlist_products_counter_number, body.theme-woostify .wishlist-item-count").html("").closest("span.wishlist-counter-with-products").removeClass("wishlist-counter-with-products");var i=!("0"==t||"false"==t);jQuery(".wishlist_products_counter").toggleClass("wishlist-counter-with-products",i)}}}(jQuery),function(o){o(document).ready(function(){if(o("#tinvwl_manage_actions, #tinvwl_product_actions").addClass("form-control").parent().wrapInner('<div class="tinvwl-input-group tinvwl-no-full">').find("button").wrap('<span class="tinvwl-input-group-btn">'),o(".tinv-lists-nav").each(function(){o.trim(o(this).html()).length||o(this).remove()}),o("body").on("click",".social-buttons .social:not(.social-email,.social-whatsapp,.social-clipboard)",function(t){var i=window.open(o(this).attr("href"),o(this).attr("title"),"width=420,height=320,resizable=yes,scrollbars=yes,status=yes");i&&(i.focus(),t.preventDefault())}),"undefined"!=typeof ClipboardJS){new ClipboardJS(".social-buttons .social.social-clipboard",{text:function(t){return t.getAttribute("href")}}).on("success",function(t){showTooltip(t.trigger,tinvwl_add_to_wishlist.tinvwl_clipboard)});for(var t=document.querySelectorAll(".social-buttons .social.social-clipboard"),i=0;i<t.length;i++)t[i].addEventListener("mouseleave",clearTooltip),t[i].addEventListener("blur",clearTooltip)}o("body").on("click",".social-buttons .social.social-clipboard",function(t){t.preventDefault()}),o("body").on("click",".tinv-wishlist .tinv-overlay, .tinv-wishlist .tinv-close-modal, .tinv-wishlist .tinvwl_button_close",function(t){t.preventDefault(),o(this).parents(".tinv-modal:first").removeClass("tinv-modal-open")}),o("body").on("click",".tinv-wishlist .tinvwl-btn-onclick",function(t){o(this).data("url")&&(t.preventDefault(),window.location=o(this).data("url"))});var n=o(".tinv-wishlist .navigation-button");n.length&&n.each(function(){var t=o(this).find("> li");t.length<5&&t.parent().addClass("tinvwl-btns-count-"+t.length)}),o(".tinv-login .showlogin").unbind("click").on("click",function(t){t.preventDefault(),o(this).closest(".tinv-login").find(".login").toggle()}),o(".tinv-wishlist table.tinvwl-table-manage-list tfoot td").each(function(){o(this).toggle(!!o(this).children().not(".look_in").length||!!o(this).children(".look_in").children().length)})})}(jQuery),function(o){o.fn.tinvwl_break_submit=function(t){var i={selector:"input, select, textarea",ifempty:!0,invert:!1,validate:function(){return o(this).val()},rule:function(){var t=o(this).parents("form").eq(0).find(n.selector),i=n.invert;return 0===t.length?n.ifempty:(t.each(function(){i&&!n.invert||!i&&n.invert||(i=Boolean(n.validate.call(o(this))))}),i)}},n=o.extend(!0,{},i,t);return o(this).each(function(){o(this).on("click",function(t){n.rule.call(o(this))||(alert(window.tinvwl_add_to_wishlist.tinvwl_break_submit),t.preventDefault())})})},o(document).ready(function(){o(".tinvwl-break-input").tinvwl_break_submit({selector:".tinvwl-break-input-filed"}),o(".tinvwl-break-checkbox").tinvwl_break_submit({selector:"table td input[type=checkbox]",validate:function(){return o(this).is(":checked")}}),o(".global-cb").on("click",function(){o(this).closest("table").eq(0).find(".product-cb input[type=checkbox], .wishlist-cb input[type=checkbox]").prop("checked",o(this).is(":checked"))})})}(jQuery);
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.20.4
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
+ "use strict";function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function showTooltip(t,i){t.setAttribute("class","social social-clipboard tooltipped tooltipped-s"),t.setAttribute("aria-label",i)}function clearTooltip(t){t.currentTarget.setAttribute("class","social social-clipboard "),t.currentTarget.removeAttribute("aria-label")}!function(c){c.fn.tinvwl_to_wishlist=function(t){var i={api_url:window.location.href.split("?")[0],text_create:window.tinvwl_add_to_wishlist.text_create,text_already_in:window.tinvwl_add_to_wishlist.text_already_in,class:{dialogbox:".tinvwl_add_to_select_wishlist",select:".tinvwl_wishlist",newtitle:".tinvwl_new_input",dialogbutton:".tinvwl_button_add"},redirectTimer:null,onPrepareList:function(){},onGetDialogBox:function(){},onPrepareDialogBox:function(){c("body > .tinv-wishlist").length||c("body").append(c("<div>").addClass("tinv-wishlist")),c(this).appendTo("body > .tinv-wishlist")},onCreateWishList:function(t){c(this).append(c("<option>").html(t.title).val(t.ID).toggleClass("tinv_in_wishlist",t.in))},onSelectWishList:function(){},onDialogShow:function(t){c(t).addClass("tinv-modal-open"),c(t).removeClass("ftinvwl-pulse")},onDialogHide:function(t){c(t).removeClass("tinv-modal-open"),c(t).removeClass("ftinvwl-pulse")},onInited:function(){},onClick:function(){if(c(this).is(".disabled-add-wishlist"))return!1;c(this).is(".ftinvwl-animated")&&c(this).addClass("ftinvwl-pulse"),this.tinvwl_dialog?this.tinvwl_dialog.show_list.call(this):e.onActionProduct.call(this)},onPrepareDataAction:function(t,i){c("body").trigger("tinvwl_wishlist_button_clicked",[t,i])},filterProductAlreadyIn:function(t){t=t||[];var o={};return c("form.cart[method=post], .woocommerce-variation-add-to-cart, form.vtajaxform[method=post]").find("input, select").each(function(){var t=c(this).attr("name"),i=c(this).attr("type"),n=c(this).val();("checkbox"!==i&&"radio"!==i||c(this).is(":checked"))&&(o["form"+t]=n)}),o=o.formvariation_id,t.filter(function(t){if("object"!==_typeof(t.in)||"string"!=typeof o)return t.in;var i=parseInt(o);return 0<=t.in.indexOf(i)})},onMultiProductAlreadyIn:function(t){t=t||[];t=e.onPrepareList.call(t)||t,t=e.filterProductAlreadyIn.call(this,t)||t,c(this).parent().parent().find(".already-in").remove();var n="";switch(t.length){case 0:break;default:n=c("<ul>");c.each(t,function(t,i){n.append(c("<li>").html(c("<a>").html(i.title).attr({href:i.url})).val(i.ID))})}n.length&&c(this).closest(".tinv-modal-inner").find("img").after(c("<div>").addClass("already-in").html(e.text_already_in+" ").append(n))},onAction:{redirect:function(t){e.redirectTimer&&clearTimeout(e.redirectTimer),e.redirectTimer=window.setTimeout(function(){window.location.href=t},4e3)},force_redirect:function(t){window.location.href=t},wishlists:function(a){var l=c(this).data("tinv-wl-product"),t=c("a.tinvwl_add_to_wishlist_button[data-tinv-wl-product='"+l+"']"),s="1"==window.tinvwl_add_to_wishlist.simple_flow;t.each(function(){var t=c(this).data("tinv-wl-productvariation"),i=c(this).data("tinv-wl-productvariations")||[],n=!1,o=[];for(var e in a&&(o=c.parseJSON(a)),o)o[e].hasOwnProperty("in")&&Array.isArray(o[e].in)&&(-1<(o[e].in||[]).indexOf(l)||-1<(o[e].in||[]).indexOf(t)||i.some(function(t){return 0<=(o[e].in||[]).indexOf(t)}))&&(n=!0);c(this).attr("data-tinv-wl-list",a).toggleClass("tinvwl-product-in-list",n).toggleClass("tinvwl-product-make-remove",n&&s).attr("data-tinv-wl-action",n&&s?"remove":"addto")})},msg:function(t){if(!t)return!1;var i=c(t).eq(0);c("body > .tinv-wishlist").length||c("body").append(c("<div>").addClass("tinv-wishlist")),c("body > .tinv-wishlist").append(i),i.on("click",".tinv-close-modal, .tinvwl_button_close, .tinv-overlay",function(t){t.preventDefault(),i.remove(),e.redirectTimer&&clearTimeout(e.redirectTimer)})},status:function(t){c("body").trigger("tinvwl_wishlist_added_status",[this,t])},removed:function(){},make_remove:function(){},counter:function(t){var i=!("0"==t||""==t);c(".wishlist_products_counter").toggleClass("wishlist-counter-with-products",i),l(t)}}};i.onActionProduct=function(t,i){var r={form:{},tinv_wishlist_id:t||"",tinv_wishlist_name:i||"",product_type:c(this).attr("data-tinv-wl-producttype"),product_id:c(this).attr("data-tinv-wl-product")||0,product_variation:c(this).attr("data-tinv-wl-productvariation")||0,product_action:c(this).attr("data-tinv-wl-action")||"addto",redirect:window.location.href},n=this,d=new FormData;c(n).closest("form.cart[method=post], form.vtajaxform[method=post], .tinvwl-loop-button-wrapper").find("input:not(:disabled), select:not(:disabled), textarea:not(:disabled)").each(function(){function e(t,i){if("object"!==_typeof(i))return i;for(var n in void 0===t&&(t={}),i)if(""===n){var o=-1;for(o in t)o=o;t[o=parseInt(o)+1]=e(t[n],i[n])}else t[n]=e(t[n],i[n]);return t}var t=c(this).attr("name"),i=c(this).attr("type"),n=c(this).val(),o=10;if("button"!==i&&void 0!==t){for(;/^(.+)\[([^\[\]]*?)\]$/.test(t)&&0<o;){var a=t.match(/^(.+)\[([^\[\]]*?)\]$/);if(3===a.length){var l={};l[a[2]]=n,n=l}t=a[1],o--}if("file"===i){var s=c(this)[0].files;s&&d.append(t,s[0])}"checkbox"===i||"radio"===i?c(this).is(":checked")&&(n.length||"object"===_typeof(n)||(n=!0),r.form[t]=e(r.form[t],n)):r.form[t]=e(r.form[t],n)}}),r=e.onPrepareDataAction.call(n,n,r)||r,c.each(r,function(n,t){"form"===n?c.each(t,function(t,i){d.append(n+"["+t+"]",i)}):d.append(n,t)}),c.ajax({url:e.api_url,method:"POST",contentType:!1,processData:!1,data:d}).done(function(t){if(e.onDialogHide.call(n.tinvwl_dialog,n),"object"===_typeof(t))for(var i in t)"function"==typeof e.onAction[i]&&e.onAction[i].call(n,t[i]);else"function"==typeof e.onAction.msg&&e.onAction.msg.call(n,t)})};var e=c.extend(!0,{},i,t);return c(this).each(function(){if(!c(this).attr("data-tinv-wl-list"))return!1;if(e.dialogbox&&e.dialogbox.length&&(this.tinvwl_dialog=e.dialogbox),this.tinvwl_dialog||(this.tinvwl_dialog=e.onGetDialogBox.call(this)),!this.tinvwl_dialog){var t=c(this).nextAll(e.class.dialogbox).eq(0);t.length&&(this.tinvwl_dialog=t)}if(this.tinvwl_dialog){e.onPrepareDialogBox.call(this.tinvwl_dialog),"function"!=typeof this.tinvwl_dialog.update_list&&(this.tinvwl_dialog.update_list=function(t){var n=c(this).find(e.class.select).eq(0);c(this).find(e.class.newtitle).hide().val(""),n.html(""),c.each(t,function(t,i){e.onCreateWishList.call(n,i)}),e.text_create&&e.onCreateWishList.call(n,{ID:"",title:e.text_create,in:!1}),e.onMultiProductAlreadyIn.call(n,t),e.onSelectWishList.call(n,t),c(this).find(e.class.newtitle).toggle(""===n.val())}),"function"!=typeof this.tinvwl_dialog.show_list&&(this.tinvwl_dialog.show_list=function(){var t=c.parseJSON(c(this).attr("data-tinv-wl-list"))||[];t.length?(t=e.onPrepareList.call(t)||t,this.tinvwl_dialog.update_list(t),e.onDialogShow.call(this.tinvwl_dialog,this)):e.onActionProduct.call(this)});var o=this;c(this.tinvwl_dialog).find(e.class.dialogbutton).off("click").on("click",function(){var t,i=c(o.tinvwl_dialog).find(e.class.select),n=c(o.tinvwl_dialog).find(e.class.newtitle);i.val()||n.val()?e.onActionProduct.call(o,i.val(),n.val()):((t=n.is(":visible")?n:i).addClass("empty-name-wishlist"),window.setTimeout(function(){t.removeClass("empty-name-wishlist")},1e3))})}c(this).off("click").on("click",e.onClick),e.onInited.call(this,e)})},c(document).ready(function(){c("body").on("click",".tinvwl_add_to_wishlist_button",function(t){if(c(this).is(".disabled-add-wishlist"))return t.preventDefault(),void window.alert(tinvwl_add_to_wishlist.i18n_make_a_selection_text);c(this).is(".inited-add-wishlist")||c(this).tinvwl_to_wishlist({onInited:function(t){c(this).addClass("inited-add-wishlist"),t.onClick.call(this)}})}),c(document).on("hide_variation",".variations_form",function(t){var i=c(this).find(".tinvwl_add_to_wishlist_button");if(i.attr("data-tinv-wl-productvariation",0),i.length&&i.attr("data-tinv-wl-list")){var n=JSON.parse(i.attr("data-tinv-wl-list")),o=!1,e="1"==window.tinvwl_add_to_wishlist.simple_flow;for(var a in n)n[a].hasOwnProperty("in")&&Array.isArray(n[a].in)&&-1<(n[a].in||[]).indexOf(0)&&(o=!0);i.toggleClass("tinvwl-product-in-list",o).toggleClass("tinvwl-product-make-remove",o&&e).attr("data-tinv-wl-action",o&&e?"remove":"addto")}i.length&&!tinvwl_add_to_wishlist.allow_parent_variable&&(t.preventDefault(),i.addClass("disabled-add-wishlist"))}),c(document).on("show_variation",".variations_form",function(t,i,n){var o=c(this).find(".tinvwl_add_to_wishlist_button");if(o.attr("data-tinv-wl-productvariation",i.variation_id),o.length&&o.attr("data-tinv-wl-list")){var e=JSON.parse(o.attr("data-tinv-wl-list")),a=!1,l="1"==window.tinvwl_add_to_wishlist.simple_flow;for(var s in e)e[s].hasOwnProperty("in")&&Array.isArray(e[s].in)&&-1<(e[s].in||[]).indexOf(i.variation_id)&&(a=!0);o.toggleClass("tinvwl-product-in-list",a).toggleClass("tinvwl-product-make-remove",a&&l).attr("data-tinv-wl-action",a&&l?"remove":"addto")}t.preventDefault(),o.removeClass("disabled-add-wishlist")}),c(window).on("storage onstorage",function(t){a===t.originalEvent.key&&localStorage.getItem(a)!==sessionStorage.getItem(a)&&l(localStorage.getItem(a))});var n=[],i=!1;c("a.tinvwl_add_to_wishlist_button").each(function(){"undefined"!==c(this).data("tinv-wl-product")&&c(this).data("tinv-wl-product")&&n.push(c(this).data("tinv-wl-product"))}),c(".wishlist_products_counter_number").each(function(){i=!0});function o(){if(n.length||i){var t={ids:n,counter:i,tinvwl_request:!0};tinvwl_add_to_wishlist.wpml&&(t.lang=tinvwl_add_to_wishlist.wpml),c.ajax({url:tinvwl_add_to_wishlist.rest_root+"wishlist/v1/products",method:"POST",data:t,beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",tinvwl_add_to_wishlist.nonce)}}).done(function(t){var i=!("0"==t.counter||""==t.counter);c(".wishlist_products_counter").toggleClass("wishlist-counter-with-products",i),l(t.counter),c.each(t.products,function(t,e){var a=t,l="1"==window.tinvwl_add_to_wishlist.simple_flow;c("a.tinvwl_add_to_wishlist_button[data-tinv-wl-product='"+a+"']").each(function(){var t=c(this).data("tinv-wl-productvariation"),i=c(this).data("tinv-wl-productvariations")||[],n=!1;for(var o in e)e[o].hasOwnProperty("in")&&Array.isArray(e[o].in)&&(-1<(e[o].in||[]).indexOf(a)||-1<(e[o].in||[]).indexOf(t)||i.some(function(t){return 0<=(e[o].in||[]).indexOf(t)}))&&(n=!0);c(this).removeClass("tinvwl-add-hide").attr("data-tinv-wl-list",JSON.stringify(e)).toggleClass("tinvwl-product-in-list",n).toggleClass("tinvwl-product-make-remove",n&&l).attr("data-tinv-wl-action",n&&l?"remove":"addto")})})})}}o();var t=new MutationObserver(function(t){n=[],t.forEach(function(t){var i=t.addedNodes;null!==i&&c(i).each(function(){var t=c(this).find(".tinvwl_add_to_wishlist_button");t.length&&t.each(function(){"undefined"!==c(this).data("tinv-wl-product")&&c(this).data("tinv-wl-product")&&n.push(c(this).data("tinv-wl-product"))})})}),n.length&&o()}),e=document.body;t.observe(e,{childList:!0,subtree:!0})});var i=!0,a=tinvwl_add_to_wishlist.hash_key;try{i="sessionStorage"in window&&null!==window.sessionStorage,window.sessionStorage.setItem("ti","test"),window.sessionStorage.removeItem("ti"),window.localStorage.setItem("ti","test"),window.localStorage.removeItem("ti")}catch(t){i=!1}function l(t){i&&(localStorage.setItem(a,t),sessionStorage.setItem(a,t),function(t){"false"!==t?jQuery(".wishlist_products_counter_number, body.theme-woostify .wishlist-item-count").html(t):jQuery(".wishlist_products_counter_number, body.theme-woostify .wishlist-item-count").html("").closest("span.wishlist-counter-with-products").removeClass("wishlist-counter-with-products");var i=!("0"==t||"false"==t);jQuery(".wishlist_products_counter").toggleClass("wishlist-counter-with-products",i)}(t))}}(jQuery),function(o){o(document).ready(function(){if(o("#tinvwl_manage_actions, #tinvwl_product_actions").addClass("form-control").parent().wrapInner('<div class="tinvwl-input-group tinvwl-no-full">').find("button").wrap('<span class="tinvwl-input-group-btn">'),o(".tinv-lists-nav").each(function(){o.trim(o(this).html()).length||o(this).remove()}),o("body").on("click",".social-buttons .social:not(.social-email,.social-whatsapp,.social-clipboard)",function(t){var i=window.open(o(this).attr("href"),o(this).attr("title"),"width=420,height=320,resizable=yes,scrollbars=yes,status=yes");i&&(i.focus(),t.preventDefault())}),"undefined"!=typeof ClipboardJS){new ClipboardJS(".social-buttons .social.social-clipboard",{text:function(t){return t.getAttribute("href")}}).on("success",function(t){showTooltip(t.trigger,tinvwl_add_to_wishlist.tinvwl_clipboard)});for(var t=document.querySelectorAll(".social-buttons .social.social-clipboard"),i=0;i<t.length;i++)t[i].addEventListener("mouseleave",clearTooltip),t[i].addEventListener("blur",clearTooltip)}o("body").on("click",".social-buttons .social.social-clipboard",function(t){t.preventDefault()}),o("body").on("click",".tinv-wishlist .tinv-overlay, .tinv-wishlist .tinv-close-modal, .tinv-wishlist .tinvwl_button_close",function(t){t.preventDefault(),o(this).parents(".tinv-modal:first").removeClass("tinv-modal-open")}),o("body").on("click",".tinv-wishlist .tinvwl-btn-onclick",function(t){o(this).data("url")&&(t.preventDefault(),window.location=o(this).data("url"))});var n=o(".tinv-wishlist .navigation-button");n.length&&n.each(function(){var t=o(this).find("> li");t.length<5&&t.parent().addClass("tinvwl-btns-count-"+t.length)}),o(".tinv-login .showlogin").unbind("click").on("click",function(t){t.preventDefault(),o(this).closest(".tinv-login").find(".login").toggle()}),o(".tinv-wishlist table.tinvwl-table-manage-list tfoot td").each(function(){o(this).toggle(!!o(this).children().not(".look_in").length||!!o(this).children(".look_in").children().length)})})}(jQuery),function(o){o.fn.tinvwl_break_submit=function(t){var i={selector:"input, select, textarea",ifempty:!0,invert:!1,validate:function(){return o(this).val()},rule:function(){var t=o(this).parents("form").eq(0).find(n.selector),i=n.invert;return 0===t.length?n.ifempty:(t.each(function(){i&&!n.invert||!i&&n.invert||(i=Boolean(n.validate.call(o(this))))}),i)}},n=o.extend(!0,{},i,t);return o(this).each(function(){o(this).on("click",function(t){n.rule.call(o(this))||(alert(window.tinvwl_add_to_wishlist.tinvwl_break_submit),t.preventDefault())})})},o(document).ready(function(){o(".tinvwl-break-input").tinvwl_break_submit({selector:".tinvwl-break-input-filed"}),o(".tinvwl-break-checkbox").tinvwl_break_submit({selector:"table td input[type=checkbox]",validate:function(){return o(this).is(":checked")}}),o(".global-cb").on("click",function(){o(this).closest("table").eq(0).find(".product-cb input[type=checkbox], .wishlist-cb input[type=checkbox]").prop("checked",o(this).is(":checked"))})})}(jQuery);
includes/api/wishlist.class.php CHANGED
@@ -1,381 +1,387 @@
1
- <?php
2
- /**
3
- * REST API plugin class
4
- *
5
- * @since 1.13.0
6
- * @package TInvWishlist
7
- */
8
-
9
- // If this file is called directly, abort.
10
- if ( ! defined( 'ABSPATH' ) ) {
11
- die;
12
- }
13
-
14
-
15
- /**
16
- * REST API plugin class
17
- */
18
- class TInvWL_Includes_API_Wishlist {
19
-
20
- /**
21
- * Endpoint namespace.
22
- *
23
- * @var string
24
- */
25
- protected $namespace = 'wc/v3';
26
-
27
- /**
28
- * Route base.
29
- *
30
- * @var string
31
- */
32
- protected $rest_base = 'wishlist';
33
-
34
- /**
35
- * Register the routes for wishlist.
36
- */
37
- public function register_routes() {
38
-
39
- // Get wishlist data by share key.
40
- register_rest_route( $this->namespace, '/' . $this->rest_base . '/get_by_share_key/(?P<share_key>[A-Fa-f0-9]{6})', array(
41
- array(
42
- 'methods' => WP_REST_Server::READABLE,
43
- 'callback' => array( $this, 'wishlist_get_by_share_key' ),
44
- ),
45
- ) );
46
-
47
- // Get wishlist(s) data by user ID.
48
- register_rest_route( $this->namespace, '/' . $this->rest_base . '/get_by_user/(?P<user_id>[\d]+)', array(
49
- array(
50
- 'methods' => WP_REST_Server::READABLE,
51
- 'callback' => array( $this, 'wishlist_get_by_user' ),
52
- ),
53
- ) );
54
-
55
- // Update wishlist data by share key.
56
- register_rest_route( $this->namespace, '/' . $this->rest_base . '/update/(?P<share_key>[A-Fa-f0-9]{6})', array(
57
- array(
58
- 'methods' => WP_REST_Server::CREATABLE,
59
- 'callback' => array( $this, 'wishlist_update' ),
60
- ),
61
- ) );
62
-
63
- // Get wishlist products by share key.
64
- register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<share_key>[A-Fa-f0-9]{6})/get_products', array(
65
- array(
66
- 'methods' => WP_REST_Server::READABLE,
67
- 'callback' => array( $this, 'wishlist_get_products' ),
68
- ),
69
- ) );
70
-
71
- // Add product to wishlist by share key.
72
- register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<share_key>[A-Fa-f0-9]{6})/add_product', array(
73
- array(
74
- 'methods' => WP_REST_Server::CREATABLE,
75
- 'callback' => array( $this, 'wishlist_add_product' ),
76
- ),
77
- ) );
78
-
79
- // Remove product by item ID.
80
- register_rest_route( $this->namespace, '/' . $this->rest_base . '/remove_product/(?P<item_id>[\d]+)', array(
81
- array(
82
- 'methods' => WP_REST_Server::READABLE,
83
- 'callback' => array( $this, 'wishlist_remove_product' ),
84
- ),
85
- ) );
86
- }
87
-
88
- /**
89
- * Get wishlist data by share key.
90
- *
91
- * @param WP_REST_Request $request Request object.
92
- *
93
- * @return mixed|WP_Error|WP_REST_Response
94
- */
95
- public function wishlist_get_by_share_key( $request ) {
96
- try {
97
- $share_key = $request['share_key'];
98
-
99
- if ( ! empty( $share_key ) && preg_match( '/^[A-Fa-f0-9]{6}$/', $share_key ) ) {
100
- $wishlist = tinv_wishlist_get( $share_key );
101
- if ( ! $wishlist ) {
102
- throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_invalid_share_key', __( 'Invalid wishlist share key.', 'ti-woocommerce-wishlist' ), 400 );
103
- }
104
-
105
- $response = $this->prepare_wishlist_data( $wishlist );
106
-
107
- return rest_ensure_response( $response );
108
-
109
-
110
- }
111
- } catch ( WC_REST_Exception $e ) {
112
- return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
113
- }
114
- }
115
-
116
- /**
117
- * Get wishlist(s) data by user ID.
118
- *
119
- * @param WP_REST_Request $request Request object.
120
- *
121
- * @return mixed|WP_Error|WP_REST_Response
122
- */
123
- public function wishlist_get_by_user( $request ) {
124
- try {
125
- $user_id = $request['user_id'];
126
-
127
- if ( ! empty( $user_id ) ) {
128
- $wl = new TInvWL_Wishlist();
129
- $wishlists = $wl->get_by_user( $user_id );
130
-
131
- if ( ! $wishlists ) {
132
- throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_wishlist_not_found', __( 'No wishlists found for this user.', 'ti-woocommerce-wishlist' ), 400 );
133
- }
134
-
135
- $response = array();
136
- foreach ( $wishlists as $wishlist ) {
137
- $response[] = $this->prepare_wishlist_data( $wishlist );
138
- }
139
-
140
- return rest_ensure_response( $response );
141
- }
142
- } catch ( WC_REST_Exception $e ) {
143
- return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
144
- }
145
- }
146
-
147
- /**
148
- * Update wishlist data by share key.
149
- *
150
- * @param WP_REST_Request $request Request object.
151
- *
152
- * @return mixed|WP_Error|WP_REST_Response
153
- */
154
- public function wishlist_update( $request ) {
155
- try {
156
- $share_key = $request['share_key'];
157
-
158
- if ( ! empty( $share_key ) && preg_match( '/^[A-Fa-f0-9]{6}$/', $share_key ) ) {
159
-
160
- $wl = new TInvWL_Wishlist();
161
-
162
- $wishlist = $wl->get_by_share_key( $share_key );
163
-
164
- if ( ! $wishlist ) {
165
- throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_invalid_share_key', __( 'Invalid wishlist share key.', 'ti-woocommerce-wishlist' ), 400 );
166
- }
167
-
168
- $data = array();
169
- if ( ! empty( $request['title'] ) ) {
170
- $data['title'] = $request['title'];
171
- }
172
-
173
- if ( ! empty( $request['user_id'] ) ) {
174
- $data['author'] = $request['user_id'];
175
- }
176
-
177
- if ( $data && current_user_can( 'tinvwl_general_settings' ) ) {
178
- $update = $wl->update( $wishlist['ID'], $data );
179
-
180
- if ( $update ) {
181
- $response = $wl->get_by_share_key( $share_key );
182
-
183
- return rest_ensure_response( $this->prepare_wishlist_data( $response ) );
184
- }
185
-
186
- throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_wishlist_update_error', __( 'Update wishlist data failed.', 'ti-woocommerce-wishlist' ), 400 );
187
-
188
- } else {
189
- throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_wishlist_forbidden', __( 'Update wishlist data failed.', 'ti-woocommerce-wishlist' ), 403 );
190
- }
191
- }
192
- } catch ( WC_REST_Exception $e ) {
193
- return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
194
- }
195
- }
196
-
197
- /**
198
- * Get wishlist products by share key.
199
- *
200
- * @param WP_REST_Request $request Request object.
201
- *
202
- * @return mixed|WP_Error|WP_REST_Response
203
- */
204
- public function wishlist_get_products( $request ) {
205
- try {
206
- $share_key = $request['share_key'];
207
-
208
- if ( ! empty( $share_key ) && preg_match( '/^[A-Fa-f0-9]{6}$/', $share_key ) ) {
209
-
210
- $wl = new TInvWL_Wishlist();
211
-
212
- $wishlist = $wl->get_by_share_key( $share_key );
213
-
214
- if ( ! $wishlist ) {
215
- throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_invalid_share_key', __( 'Invalid wishlist share key.', 'ti-woocommerce-wishlist' ), 400 );
216
- }
217
-
218
- $wlp = new TInvWL_Product();
219
-
220
- $args = array();
221
- $args['wishlist_id'] = $wishlist['ID'];
222
- $args['external'] = false;
223
-
224
- if ( $request['count'] ) {
225
- $args['count'] = $request['count'];
226
- }
227
- if ( $request['offset'] ) {
228
- $args['offset'] = $request['offset'];
229
- }
230
- if ( $request['order'] ) {
231
- $args['order'] = $request['order'];
232
- }
233
-
234
- $products = $wlp->get( $args );
235
-
236
- $response = array();
237
-
238
- foreach ( $products as $product ) {
239
- $response[] = $this->prepare_product_data( $product );
240
- }
241
-
242
- return rest_ensure_response( apply_filters( 'tinvwl_api_wishlist_get_products_response', $response ) );
243
- }
244
- } catch ( WC_REST_Exception $e ) {
245
- return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
246
- }
247
- }
248
-
249
- /**
250
- * Add product to wishlist by share key.
251
- *
252
- * @param WP_REST_Request $request Request object.
253
- *
254
- * @return mixed|WP_Error|WP_REST_Response
255
- */
256
- public function wishlist_add_product( $request ) {
257
- try {
258
- $share_key = $request['share_key'];
259
-
260
- if ( ! empty( $share_key ) && preg_match( '/^[A-Fa-f0-9]{6}$/', $share_key ) ) {
261
-
262
- $wl = new TInvWL_Wishlist();
263
-
264
- $wishlist = $wl->get_by_share_key( $share_key );
265
-
266
- if ( ! $wishlist ) {
267
- throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_invalid_share_key', __( 'Invalid wishlist share key.', 'ti-woocommerce-wishlist' ), 400 );
268
- }
269
-
270
- if ( ! current_user_can( 'tinvwl_general_settings' ) ) {
271
- throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_wishlist_forbidden', __( 'Add product to wishlist failed.', 'ti-woocommerce-wishlist' ), 403 );
272
- }
273
-
274
- $wlp = new TInvWL_Product();
275
-
276
- $args = array();
277
- $args['wishlist_id'] = $wishlist['ID'];
278
- $args['author'] = $wishlist['author'];
279
-
280
- if ( $request['product_id'] ) {
281
- $args['product_id'] = $request['product_id'];
282
- }
283
- if ( $request['variation_id'] ) {
284
- $args['variation_id'] = $request['variation_id'];
285
- }
286
- if ( $request['meta'] ) {
287
- $meta = $request['meta'];
288
- }
289
-
290
- $product = $wlp->add_product( $args, $meta );
291
-
292
- if ( ! $product ) {
293
- throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_wishlist_products_not_found', __( 'Add product to wishlist failed.', 'ti-woocommerce-wishlist' ), 400 );
294
- }
295
-
296
- $response = array();
297
- $products = $wlp->get( array( 'ID' => $product ) );
298
- foreach ( $products as $product ) {
299
- $response[] = $this->prepare_product_data( $product );
300
- }
301
-
302
- return rest_ensure_response( $response );
303
- }
304
- } catch ( WC_REST_Exception $e ) {
305
- return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
306
- }
307
- }
308
-
309
- /**
310
- * Remove product by item ID.
311
- *
312
- * @param WP_REST_Request $request Request object.
313
- *
314
- * @return mixed|WP_Error|WP_REST_Response
315
- */
316
- public function wishlist_remove_product( $request ) {
317
- try {
318
- $item_id = $request['item_id'];
319
-
320
- if ( ! empty( $item_id ) ) {
321
-
322
- if ( ! current_user_can( 'tinvwl_general_settings' ) ) {
323
- throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_wishlist_forbidden', __( 'Product not found.', 'ti-woocommerce-wishlist' ), 403 );
324
- }
325
-
326
- $wlp = new TInvWL_Product();
327
-
328
- $args = array();
329
- $args['ID'] = $item_id;
330
-
331
- $result = $wlp->remove( $args );
332
-
333
- if ( ! $result ) {
334
- throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_wishlist_product_not_found', __( 'Product not found.', 'ti-woocommerce-wishlist' ), 400 );
335
- }
336
-
337
- return rest_ensure_response( __( 'Product removed from a wishlist.', 'ti-woocommerce-wishlist' ) );
338
- }
339
- } catch ( WC_REST_Exception $e ) {
340
- return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
341
- }
342
- }
343
-
344
- /**
345
- * Prepare wishlist data.
346
- *
347
- * @param array $wishlist Default wishlist data.
348
- *
349
- * @return array
350
- */
351
- public function prepare_wishlist_data( $wishlist ) {
352
- $response = array();
353
- $response['id'] = $wishlist['ID'];
354
- $response['user_id'] = $wishlist['author'];
355
- $response['date_added'] = $wishlist['date'];
356
- $response['title'] = $wishlist['title'];
357
- $response['share_key'] = $wishlist['share_key'];
358
-
359
- return $response;
360
- }
361
-
362
- /**
363
- * Prepare wishlist item data.
364
- *
365
- * @param array $product Default wishlist item data.
366
- *
367
- * @return array
368
- */
369
- public function prepare_product_data( $product ) {
370
- $response = array();
371
- $response['item_id'] = $product['ID'];
372
- $response['product_id'] = $product['product_id'];
373
- $response['variation_id'] = $product['variation_id'];
374
- $response['meta'] = $product['meta'];
375
- $response['date_added'] = $product['date'];
376
- $response['price'] = $product['price'];
377
- $response['in_stock'] = $product['in_stock'];
378
-
379
- return $response;
380
- }
381
- }
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * REST API plugin class
4
+ *
5
+ * @since 1.13.0
6
+ * @package TInvWishlist
7
+ */
8
+
9
+ // If this file is called directly, abort.
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ die;
12
+ }
13
+
14
+
15
+ /**
16
+ * REST API plugin class
17
+ */
18
+ class TInvWL_Includes_API_Wishlist {
19
+
20
+ /**
21
+ * Endpoint namespace.
22
+ *
23
+ * @var string
24
+ */
25
+ protected $namespace = 'wc/v3';
26
+
27
+ /**
28
+ * Route base.
29
+ *
30
+ * @var string
31
+ */
32
+ protected $rest_base = 'wishlist';
33
+
34
+ /**
35
+ * Register the routes for wishlist.
36
+ */
37
+ public function register_routes() {
38
+
39
+ // Get wishlist data by share key.
40
+ register_rest_route( $this->namespace, '/' . $this->rest_base . '/get_by_share_key/(?P<share_key>[A-Fa-f0-9]{6})', array(
41
+ array(
42
+ 'methods' => WP_REST_Server::READABLE,
43
+ 'callback' => array( $this, 'wishlist_get_by_share_key' ),
44
+ ),
45
+ ) );
46
+
47
+ // Get wishlist(s) data by user ID.
48
+ register_rest_route( $this->namespace, '/' . $this->rest_base . '/get_by_user/(?P<user_id>[\d]+)', array(
49
+ array(
50
+ 'methods' => WP_REST_Server::READABLE,
51
+ 'callback' => array( $this, 'wishlist_get_by_user' ),
52
+ ),
53
+ ) );
54
+
55
+ // Update wishlist data by share key.
56
+ register_rest_route( $this->namespace, '/' . $this->rest_base . '/update/(?P<share_key>[A-Fa-f0-9]{6})', array(
57
+ array(
58
+ 'methods' => WP_REST_Server::CREATABLE,
59
+ 'callback' => array( $this, 'wishlist_update' ),
60
+ ),
61
+ ) );
62
+
63
+ // Get wishlist products by share key.
64
+ register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<share_key>[A-Fa-f0-9]{6})/get_products', array(
65
+ array(
66
+ 'methods' => WP_REST_Server::READABLE,
67
+ 'callback' => array( $this, 'wishlist_get_products' ),
68
+ ),
69
+ ) );
70
+
71
+ // Add product to wishlist by share key.
72
+ register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<share_key>[A-Fa-f0-9]{6})/add_product', array(
73
+ array(
74
+ 'methods' => WP_REST_Server::CREATABLE,
75
+ 'callback' => array( $this, 'wishlist_add_product' ),
76
+ ),
77
+ ) );
78
+
79
+ // Remove product by item ID.
80
+ register_rest_route( $this->namespace, '/' . $this->rest_base . '/remove_product/(?P<item_id>[\d]+)', array(
81
+ array(
82
+ 'methods' => WP_REST_Server::READABLE,
83
+ 'callback' => array( $this, 'wishlist_remove_product' ),
84
+ ),
85
+ ) );
86
+ }
87
+
88
+ /**
89
+ * Get wishlist data by share key.
90
+ *
91
+ * @param WP_REST_Request $request Request object.
92
+ *
93
+ * @return mixed|WP_Error|WP_REST_Response
94
+ */
95
+ public function wishlist_get_by_share_key( $request ) {
96
+ try {
97
+ $share_key = $request['share_key'];
98
+
99
+ if ( ! empty( $share_key ) && preg_match( '/^[A-Fa-f0-9]{6}$/', $share_key ) ) {
100
+ $wishlist = tinv_wishlist_get( $share_key );
101
+ if ( ! $wishlist ) {
102
+ throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_invalid_share_key', __( 'Invalid wishlist share key.', 'ti-woocommerce-wishlist' ), 400 );
103
+ }
104
+
105
+ $response = $this->prepare_wishlist_data( $wishlist );
106
+
107
+ return rest_ensure_response( $response );
108
+
109
+
110
+ }
111
+ } catch ( WC_REST_Exception $e ) {
112
+ return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
113
+ }
114
+ }
115
+
116
+ /**
117
+ * Get wishlist(s) data by user ID.
118
+ *
119
+ * @param WP_REST_Request $request Request object.
120
+ *
121
+ * @return mixed|WP_Error|WP_REST_Response
122
+ */
123
+ public function wishlist_get_by_user( $request ) {
124
+ try {
125
+ $user_id = $request['user_id'];
126
+
127
+ if ( ! empty( $user_id ) ) {
128
+ $wl = new TInvWL_Wishlist();
129
+ $wishlists = $wl->get_by_user( $user_id );
130
+
131
+ if ( ! $wishlists ) {
132
+ throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_wishlist_not_found', __( 'No wishlists found for this user.', 'ti-woocommerce-wishlist' ), 400 );
133
+ }
134
+
135
+ $response = array();
136
+ foreach ( $wishlists as $wishlist ) {
137
+ $response[] = $this->prepare_wishlist_data( $wishlist );
138
+ }
139
+
140
+ return rest_ensure_response( $response );
141
+ }
142
+ } catch ( WC_REST_Exception $e ) {
143
+ return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
144
+ }
145
+ }
146
+
147
+ /**
148
+ * Update wishlist data by share key.
149
+ *
150
+ * @param WP_REST_Request $request Request object.
151
+ *
152
+ * @return mixed|WP_Error|WP_REST_Response
153
+ */
154
+ public function wishlist_update( $request ) {
155
+ try {
156
+ $share_key = $request['share_key'];
157
+
158
+ if ( ! empty( $share_key ) && preg_match( '/^[A-Fa-f0-9]{6}$/', $share_key ) ) {
159
+
160
+ $wl = new TInvWL_Wishlist();
161
+
162
+ $wishlist = $wl->get_by_share_key( $share_key );
163
+
164
+ if ( ! $wishlist ) {
165
+ throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_invalid_share_key', __( 'Invalid wishlist share key.', 'ti-woocommerce-wishlist' ), 400 );
166
+ }
167
+
168
+ $data = array();
169
+ if ( ! empty( $request['title'] ) ) {
170
+ $data['title'] = $request['title'];
171
+ }
172
+
173
+ if ( ! empty( $request['user_id'] ) ) {
174
+ $data['author'] = $request['user_id'];
175
+ }
176
+
177
+ if ( $data && ( current_user_can( 'tinvwl_general_settings' || $wishlist['author'] === get_current_user_id() ) ) ) {
178
+ $update = $wl->update( $wishlist['ID'], $data );
179
+
180
+ if ( $update ) {
181
+ $response = $wl->get_by_share_key( $share_key );
182
+
183
+ return rest_ensure_response( $this->prepare_wishlist_data( $response ) );
184
+ }
185
+
186
+ throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_wishlist_update_error', __( 'Update wishlist data failed.', 'ti-woocommerce-wishlist' ), 400 );
187
+
188
+ } else {
189
+ throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_wishlist_forbidden', __( 'Update wishlist data failed.', 'ti-woocommerce-wishlist' ), 403 );
190
+ }
191
+ }
192
+ } catch ( WC_REST_Exception $e ) {
193
+ return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
194
+ }
195
+ }
196
+
197
+ /**
198
+ * Get wishlist products by share key.
199
+ *
200
+ * @param WP_REST_Request $request Request object.
201
+ *
202
+ * @return mixed|WP_Error|WP_REST_Response
203
+ */
204
+ public function wishlist_get_products( $request ) {
205
+ try {
206
+ $share_key = $request['share_key'];
207
+
208
+ if ( ! empty( $share_key ) && preg_match( '/^[A-Fa-f0-9]{6}$/', $share_key ) ) {
209
+
210
+ $wl = new TInvWL_Wishlist();
211
+
212
+ $wishlist = $wl->get_by_share_key( $share_key );
213
+
214
+ if ( ! $wishlist ) {
215
+ throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_invalid_share_key', __( 'Invalid wishlist share key.', 'ti-woocommerce-wishlist' ), 400 );
216
+ }
217
+
218
+ $wlp = new TInvWL_Product();
219
+
220
+ $args = array();
221
+ $args['wishlist_id'] = $wishlist['ID'];
222
+ $args['external'] = false;
223
+
224
+ if ( $request['count'] ) {
225
+ $args['count'] = $request['count'];
226
+ }
227
+ if ( $request['offset'] ) {
228
+ $args['offset'] = $request['offset'];
229
+ }
230
+ if ( $request['order'] ) {
231
+ $args['order'] = $request['order'];
232
+ }
233
+
234
+ $products = $wlp->get( $args );
235
+
236
+ $response = array();
237
+
238
+ foreach ( $products as $product ) {
239
+ $response[] = $this->prepare_product_data( $product );
240
+ }
241
+
242
+ return rest_ensure_response( apply_filters( 'tinvwl_api_wishlist_get_products_response', $response ) );
243
+ }
244
+ } catch ( WC_REST_Exception $e ) {
245
+ return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
246
+ }
247
+ }
248
+
249
+ /**
250
+ * Add product to wishlist by share key.
251
+ *
252
+ * @param WP_REST_Request $request Request object.
253
+ *
254
+ * @return mixed|WP_Error|WP_REST_Response
255
+ */
256
+ public function wishlist_add_product( $request ) {
257
+ try {
258
+ $share_key = $request['share_key'];
259
+
260
+ if ( ! empty( $share_key ) && preg_match( '/^[A-Fa-f0-9]{6}$/', $share_key ) ) {
261
+
262
+ $wl = new TInvWL_Wishlist();
263
+
264
+ $wishlist = $wl->get_by_share_key( $share_key );
265
+
266
+ if ( ! $wishlist ) {
267
+ throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_invalid_share_key', __( 'Invalid wishlist share key.', 'ti-woocommerce-wishlist' ), 400 );
268
+ }
269
+
270
+ if ( ! ( current_user_can( 'tinvwl_general_settings' ) || $wishlist['author'] === get_current_user_id() ) ) {
271
+ throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_wishlist_forbidden', __( 'Add product to wishlist failed.', 'ti-woocommerce-wishlist' ), 403 );
272
+ }
273
+
274
+ $wlp = new TInvWL_Product();
275
+
276
+ $args = array();
277
+ $args['wishlist_id'] = $wishlist['ID'];
278
+ $args['author'] = $wishlist['author'];
279
+
280
+ if ( $request['product_id'] ) {
281
+ $args['product_id'] = $request['product_id'];
282
+ }
283
+ if ( $request['variation_id'] ) {
284
+ $args['variation_id'] = $request['variation_id'];
285
+ }
286
+ $meta = array();
287
+ if ( $request['meta'] ) {
288
+ $meta = $request['meta'];
289
+ }
290
+
291
+ $product = $wlp->add_product( $args, $meta );
292
+
293
+ if ( ! $product ) {
294
+ throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_wishlist_products_not_found', __( 'Add product to wishlist failed.', 'ti-woocommerce-wishlist' ), 400 );
295
+ }
296
+
297
+ $response = array();
298
+ $products = $wlp->get( array( 'ID' => $product ) );
299
+ foreach ( $products as $product ) {
300
+ $response[] = $this->prepare_product_data( $product );
301
+ }
302
+
303
+ return rest_ensure_response( $response );
304
+ }
305
+ } catch ( WC_REST_Exception $e ) {
306
+ return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
307
+ }
308
+ }
309
+
310
+ /**
311
+ * Remove product by item ID.
312
+ *
313
+ * @param WP_REST_Request $request Request object.
314
+ *
315
+ * @return mixed|WP_Error|WP_REST_Response
316
+ */
317
+ public function wishlist_remove_product( $request ) {
318
+ try {
319
+ $item_id = $request['item_id'];
320
+
321
+ if ( ! empty( $item_id ) ) {
322
+
323
+ $wlp = new TInvWL_Product();
324
+ $wishlist = $wlp->get_wishlist_by_product_id( $item_id );
325
+
326
+ if ( ! $wishlist ) {
327
+ throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_wishlist_product_not_found', __( 'Product not found.', 'ti-woocommerce-wishlist' ), 400 );
328
+ }
329
+
330
+ if ( ! ( current_user_can( 'tinvwl_general_settings' ) || $wishlist['author'] === get_current_user_id() ) ) {
331
+ throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_wishlist_forbidden', __( 'Remove product from wishlist failed.', 'ti-woocommerce-wishlist' ), 403 );
332
+ }
333
+
334
+ $args = array();
335
+ $args['ID'] = $item_id;
336
+
337
+ $result = $wlp->remove( $args );
338
+
339
+ if ( ! $result ) {
340
+ throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_wishlist_product_not_found', __( 'Product not found.', 'ti-woocommerce-wishlist' ), 400 );
341
+ }
342
+
343
+ return rest_ensure_response( __( 'Product removed from a wishlist.', 'ti-woocommerce-wishlist' ) );
344
+ }
345
+ } catch ( WC_REST_Exception $e ) {
346
+ return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
347
+ }
348
+ }
349
+
350
+ /**
351
+ * Prepare wishlist data.
352
+ *
353
+ * @param array $wishlist Default wishlist data.
354
+ *
355
+ * @return array
356
+ */
357
+ public function prepare_wishlist_data( $wishlist ) {
358
+ $response = array();
359
+ $response['id'] = $wishlist['ID'];
360
+ $response['user_id'] = $wishlist['author'];
361
+ $response['date_added'] = $wishlist['date'];
362
+ $response['title'] = $wishlist['title'];
363
+ $response['share_key'] = $wishlist['share_key'];
364
+
365
+ return $response;
366
+ }
367
+
368
+ /**
369
+ * Prepare wishlist item data.
370
+ *
371
+ * @param array $product Default wishlist item data.
372
+ *
373
+ * @return array
374
+ */
375
+ public function prepare_product_data( $product ) {
376
+ $response = array();
377
+ $response['item_id'] = $product['ID'];
378
+ $response['product_id'] = $product['product_id'];
379
+ $response['variation_id'] = $product['variation_id'];
380
+ $response['meta'] = $product['meta'];
381
+ $response['date_added'] = $product['date'];
382
+ $response['price'] = $product['price'];
383
+ $response['in_stock'] = $product['in_stock'];
384
+
385
+ return $response;
386
+ }
387
+ }
includes/product.helper.php CHANGED
@@ -583,6 +583,35 @@ class TInvWL_Product {
583
  return $result;
584
  }
585
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
586
  /**
587
  * Remove product by ID
588
  *
583
  return $result;
584
  }
585
 
586
+ /**
587
+ * Get wishlist data by product from wishlist
588
+ *
589
+ * @param integer $product_id Product id.
590
+ *
591
+ * @return boolean
592
+ * @global wpdb $wpdb
593
+ *
594
+ */
595
+ function get_wishlist_by_product_id( $product_id = 0 ) {
596
+ if ( empty( $product_id ) ) {
597
+ return false;
598
+ }
599
+
600
+ global $wpdb;
601
+ $sql = "SELECT `wishlist_id` FROM `{$this->table}` WHERE `ID`={$product_id}";
602
+ $result = $wpdb->get_results( $sql, ARRAY_A );
603
+
604
+ if ( ! $result ) {
605
+ return false;
606
+ }
607
+
608
+ $wl = new TInvWL_Wishlist();
609
+
610
+ $wishlist = $wl->get_by_id( $result[0]['wishlist_id'] );
611
+
612
+ return $wishlist;
613
+ }
614
+
615
  /**
616
  * Remove product by ID
617
  *
integrations/woo-custom-product-addons.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @name WooCommerce Custom Product Addons
6
  *
7
- * @version 2.3.5
8
  *
9
  * @slug woo-custom-product-addons
10
  *
@@ -179,3 +179,65 @@ if ( ! function_exists( 'tinvwl_item_price_woocommerce_custom_product_addons' )
179
 
180
  add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_custom_product_addons', 10, 3 );
181
  } // End if().
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  *
5
  * @name WooCommerce Custom Product Addons
6
  *
7
+ * @version 2.4.4
8
  *
9
  * @slug woo-custom-product-addons
10
  *
179
 
180
  add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_custom_product_addons', 10, 3 );
181
  } // End if().
182
+
183
+ if ( ! function_exists( 'tinvwl_item_price_woocommerce_custom_product_addons_text_button' ) ) {
184
+
185
+ /**
186
+ * Change text for button add to cart
187
+ *
188
+ * @param string $text_add_to_cart Text "Add to cart".
189
+ * @param array $wl_product Wishlist product.
190
+ * @param object $product WooCommerce Product.
191
+ *
192
+ * @return string
193
+ */
194
+ function tinvwl_item_price_woocommerce_custom_product_addons_text_button( $text_add_to_cart, $wl_product, $product ) {
195
+
196
+ if ( function_exists( 'WCPA' ) ) {
197
+ $product_id = $product->get_id();
198
+ $form = new WCPA_Form();
199
+ $post_ids = $form->get_form_ids( $product_id );
200
+ $data = array();
201
+ if ( wcpa_get_option( 'form_loading_order_by_date' ) === true ) {
202
+ if ( is_array( $post_ids ) && count( $post_ids ) ) {
203
+ $post_ids = get_posts( array(
204
+ 'posts_per_page' => - 1,
205
+ 'include' => $post_ids,
206
+ 'fields' => 'ids',
207
+ 'post_type' => WCPA_POST_TYPE,
208
+ 'posts_per_page' => - 1
209
+ ) );
210
+ }
211
+ }
212
+ foreach ( $post_ids as $id ) {
213
+ if ( get_post_status( $id ) == 'publish' ) {
214
+ $json_string = get_post_meta( $id, WCPA_FORM_META_KEY, true );
215
+ $json_encoded = json_decode( $json_string );
216
+ if ( $json_encoded && is_array( $json_encoded ) ) {
217
+ $data = array_merge( $data, $json_encoded );
218
+ }
219
+ }
220
+ }
221
+
222
+ $status = true;
223
+
224
+ foreach ( $data as $v ) {
225
+ if ( $v->type != 'file' && isset( $v->required ) && $v->required && ( ! isset( $wl_product['meta'][ $v->name ] ) || empty( $wl_product['meta'][ $v->name ] ) ) ) {
226
+ $status = false;
227
+ }
228
+ }
229
+
230
+ if ( ! $status ) {
231
+
232
+ $WCPA = new WCPA_Front_End();
233
+
234
+ return $WCPA->add_to_cart_text( $text_add_to_cart, $product );
235
+ }
236
+ }
237
+
238
+ return $text_add_to_cart;
239
+
240
+ }
241
+
242
+ add_filter( 'tinvwl_wishlist_item_add_to_cart', 'tinvwl_item_price_woocommerce_custom_product_addons_text_button', 10, 3 );
243
+ }
integrations/woocommerce-tm-extra-product-options.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @name WooCommerce TM Extra Product Options
6
  *
7
- * @version 4.9.11
8
  *
9
  * @slug woocommerce-tm-extra-product-options
10
  *
@@ -127,3 +127,44 @@ if ( ! function_exists( 'tinvwl_item_price_woocommerce_tm_extra_product_options'
127
 
128
  add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_tm_extra_product_options', 10, 3 );
129
  } // End if().
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  *
5
  * @name WooCommerce TM Extra Product Options
6
  *
7
+ * @version 5.0.12.1
8
  *
9
  * @slug woocommerce-tm-extra-product-options
10
  *
127
 
128
  add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_tm_extra_product_options', 10, 3 );
129
  } // End if().
130
+
131
+ add_filter( 'tinvwl_addtowishlist_prepare_form', 'tinvwl_meta_woocommerce_tm_extra_product_options', 10, 3 );
132
+
133
+ function tinvwl_meta_woocommerce_tm_extra_product_options( $meta, $post, $files ) {
134
+
135
+ if ( defined( 'THEMECOMPLETE_EPO_VERSION' ) || defined( 'TM_EPO_VERSION' ) ) {
136
+ foreach ( $files as $name => $file ) {
137
+
138
+ if ( array_key_exists( $name, $meta ) ) {
139
+ $upload = THEMECOMPLETE_EPO()->upload_file( $file );
140
+ if ( empty( $upload['error'] ) && ! empty( $upload['file'] ) ) {
141
+ $meta[ $name ] = wc_clean( $upload['url'] );
142
+ }
143
+ }
144
+ }
145
+ }
146
+
147
+ return $meta;
148
+ }
149
+
150
+ add_filter( 'tinvwl_product_prepare_meta', 'tinvwl_cart_meta_woocommerce_tm_extra_product_options' );
151
+
152
+ function tinvwl_cart_meta_woocommerce_tm_extra_product_options( $meta ) {
153
+
154
+ if ( defined( 'THEMECOMPLETE_EPO_VERSION' ) || defined( 'TM_EPO_VERSION' ) ) {
155
+
156
+ $files = $_FILES;
157
+
158
+ foreach ( $files as $name => $file ) {
159
+
160
+ if ( ! array_key_exists( $name, $meta ) ) {
161
+ $upload = THEMECOMPLETE_EPO()->upload_file( $file );
162
+ if ( empty( $upload['error'] ) && ! empty( $upload['file'] ) ) {
163
+ $meta[ $name ] = wc_clean( $upload['url'] );
164
+ }
165
+ }
166
+ }
167
+ }
168
+
169
+ return $meta;
170
+ }
integrations/wp-fastest-cache.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @name WP Fastest Cache
6
  *
7
- * @version 0.8.9.6
8
  *
9
  * @slug wp-fastest-cache
10
  *
@@ -23,64 +23,63 @@ if ( ! function_exists( 'tinvwl_wp_fastest_cache_reject' ) ) {
23
  */
24
  function tinvwl_wp_fastest_cache_reject() {
25
  if ( defined( 'WPFC_WP_PLUGIN_DIR' ) ) {
26
- if ( $rules_json = get_option( 'WpFastestCacheExclude' ) ) {
27
- if ( 'null' !== $rules_json ) {
28
- $ids = array(
29
- tinv_get_option( 'page', 'wishlist' ),
30
- tinv_get_option( 'page', 'manage' ),
31
- );
32
- $pages = $ids;
33
- $languages = apply_filters( 'wpml_active_languages', array(), array(
34
- 'skip_missing' => 0,
35
- 'orderby' => 'code',
36
- ) );
37
- if ( ! empty( $languages ) ) {
38
- foreach ( $ids as $id ) {
39
- foreach ( $languages as $l ) {
40
- $pages[] = apply_filters( 'wpml_object_id', $id, 'page', true, $l['language_code'] );
41
- }
42
- }
43
- $pages = array_unique( $pages );
44
- }
45
- $pages = array_filter( $pages );
46
- if ( ! empty( $pages ) ) {
47
- foreach ( $pages as $i => $page ) {
48
- $pages[ $i ] = preg_replace( "/^\//", '', str_replace( get_site_url(), '', get_permalink( $page ) ) ); // @codingStandardsIgnoreLine Squiz.Strings.DoubleQuoteUsage.NotRequired
49
- }
50
- }
51
- $pages = array_unique( $pages );
52
- $pages = array_filter( $pages );
53
 
54
- $rules_std = json_decode( $rules_json, true );
55
- $ex_pages = array();
56
- foreach ( $rules_std as $value ) {
57
- $value['type'] = isset( $value['type'] ) ? $value['type'] : 'page';
58
- if ( 'page' === $value['type'] ) {
59
- $ex_pages[] = $value['content'];
60
- }
 
 
 
 
 
 
61
  }
62
- $ex_pages = array_unique( $ex_pages );
63
- $ex_pages = array_filter( $ex_pages );
64
- $changed = false;
 
 
 
 
 
 
 
 
65
 
66
- foreach ( $pages as $page ) {
67
- $page = preg_replace( '/\/$/', '', $page );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
 
69
- if ( ! in_array( $page, $ex_pages ) ) {
70
- $changed = true;
71
- $rules_std[] = array(
72
- 'prefix' => 'startwith',
73
- 'content' => $page,
74
- 'type' => 'page',
75
- );
76
- }
77
- }
78
- if ( $changed ) {
79
- $data = json_encode( $rules_std );
80
- update_option( 'WpFastestCacheExclude', $data );
81
- }
82
- } // End if().
83
- } // End if().
84
  } // End if().
85
  }
86
 
4
  *
5
  * @name WP Fastest Cache
6
  *
7
+ * @version 0.9.0.7
8
  *
9
  * @slug wp-fastest-cache
10
  *
23
  */
24
  function tinvwl_wp_fastest_cache_reject() {
25
  if ( defined( 'WPFC_WP_PLUGIN_DIR' ) ) {
26
+ $rules_json = get_option( 'WpFastestCacheExclude' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
+ $ids = array(
29
+ tinv_get_option( 'page', 'wishlist' ),
30
+ tinv_get_option( 'page', 'manage' ),
31
+ );
32
+ $pages = $ids;
33
+ $languages = apply_filters( 'wpml_active_languages', array(), array(
34
+ 'skip_missing' => 0,
35
+ 'orderby' => 'code',
36
+ ) );
37
+ if ( ! empty( $languages ) ) {
38
+ foreach ( $ids as $id ) {
39
+ foreach ( $languages as $l ) {
40
+ $pages[] = apply_filters( 'wpml_object_id', $id, 'page', true, $l['language_code'] );
41
  }
42
+ }
43
+ $pages = array_unique( $pages );
44
+ }
45
+ $pages = array_filter( $pages );
46
+ if ( ! empty( $pages ) ) {
47
+ foreach ( $pages as $i => $page ) {
48
+ $pages[ $i ] = preg_replace( "/^\//", '', str_replace( get_site_url(), '', get_permalink( $page ) ) ); // @codingStandardsIgnoreLine Squiz.Strings.DoubleQuoteUsage.NotRequired
49
+ }
50
+ }
51
+ $pages = array_unique( $pages );
52
+ $pages = array_filter( $pages );
53
 
54
+ $rules_std = json_decode( $rules_json, true );
55
+ $ex_pages = array();
56
+ foreach ( $rules_std as $value ) {
57
+ $value['type'] = isset( $value['type'] ) ? $value['type'] : 'page';
58
+ if ( 'page' === $value['type'] ) {
59
+ $ex_pages[] = $value['content'];
60
+ }
61
+ }
62
+ $ex_pages = array_unique( $ex_pages );
63
+ $ex_pages = array_filter( $ex_pages );
64
+ $changed = false;
65
+
66
+ foreach ( $pages as $page ) {
67
+ $page = preg_replace( '/\/$/', '', $page );
68
+
69
+ if ( ! in_array( $page, $ex_pages ) ) {
70
+ $changed = true;
71
+ $rules_std[] = array(
72
+ 'prefix' => 'startwith',
73
+ 'content' => $page,
74
+ 'type' => 'page',
75
+ );
76
+ }
77
+ }
78
+ if ( $changed ) {
79
+ $data = json_encode( $rules_std );
80
+ update_option( 'WpFastestCacheExclude', $data );
81
+ }
82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  } // End if().
84
  }
85
 
languages/ti-woocommerce-wishlist.pot CHANGED
@@ -1,8 +1,8 @@
1
- # Copyright (C) 2020 TI WooCommerce Wishlist Plugin - 1.20.3
2
- # This file is distributed under the same license as the TI WooCommerce Wishlist Plugin - 1.20.3 package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: TI WooCommerce Wishlist Plugin - 1.20.3\n"
6
  "MIME-Version: 1.0\n"
7
  "Content-Type: text/plain; charset=UTF-8\n"
8
  "Content-Transfer-Encoding: 8bit\n"
@@ -776,15 +776,19 @@ msgstr ""
776
  msgid "Update wishlist data failed."
777
  msgstr ""
778
 
779
- #: includes/api/wishlist.class.php:271, includes/api/wishlist.class.php:293
780
  msgid "Add product to wishlist failed."
781
  msgstr ""
782
 
783
- #: includes/api/wishlist.class.php:323, includes/api/wishlist.class.php:334
784
  msgid "Product not found."
785
  msgstr ""
786
 
787
- #: includes/api/wishlist.class.php:337
 
 
 
 
788
  msgid "Product removed from a wishlist."
789
  msgstr ""
790
 
1
+ # Copyright (C) 2020 TI WooCommerce Wishlist Plugin - 1.20.4
2
+ # This file is distributed under the same license as the TI WooCommerce Wishlist Plugin - 1.20.4 package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: TI WooCommerce Wishlist Plugin - 1.20.4\n"
6
  "MIME-Version: 1.0\n"
7
  "Content-Type: text/plain; charset=UTF-8\n"
8
  "Content-Transfer-Encoding: 8bit\n"
776
  msgid "Update wishlist data failed."
777
  msgstr ""
778
 
779
+ #: includes/api/wishlist.class.php:271, includes/api/wishlist.class.php:294
780
  msgid "Add product to wishlist failed."
781
  msgstr ""
782
 
783
+ #: includes/api/wishlist.class.php:327, includes/api/wishlist.class.php:340
784
  msgid "Product not found."
785
  msgstr ""
786
 
787
+ #: includes/api/wishlist.class.php:331
788
+ msgid "Remove product from wishlist failed."
789
+ msgstr ""
790
+
791
+ #: includes/api/wishlist.class.php:343
792
  msgid "Product removed from a wishlist."
793
  msgstr ""
794
 
public/addtowishlist.class.php CHANGED
@@ -204,7 +204,7 @@ class TInvWL_Public_AddToWishlist {
204
  } else {
205
  $post['product_type'] = apply_filters( 'tinvwl_addtowishlist_modify_type', $post['product_type'], $post );
206
  $post = apply_filters( 'tinvwl_addtowishlist_prepare', $post );
207
- $form = apply_filters( 'tinvwl_addtowishlist_prepare_form', filter_input( INPUT_POST, 'form', FILTER_DEFAULT, FILTER_FORCE_ARRAY ) );
208
  if ( empty( $form ) ) {
209
  $form = array();
210
  }
@@ -610,12 +610,13 @@ class TInvWL_Public_AddToWishlist {
610
  * @param boolean $echo Return or output.
611
  */
612
  function button( $echo = true ) {
613
- $content = apply_filters( 'tinvwl_wishlist_button_before', '' );
614
- $text = ( tinv_get_option( 'add_to_wishlist' . ( $this->is_loop ? '_catalog' : '' ), 'show_text' ) ) ? apply_filters( 'tinvwl_added_to_wishlist_text_loop', tinv_get_option( 'add_to_wishlist' . ( $this->is_loop ? '_catalog' : '' ), 'text' ) ) : '';
615
- $icon = tinv_get_option( 'add_to_wishlist' . ( $this->is_loop ? '_catalog' : '' ), 'icon' );
616
- $icon_color = tinv_get_option( 'add_to_wishlist' . ( $this->is_loop ? '_catalog' : '' ), 'icon_style' );
617
- $icon_class = '';
618
- $action = 'addto';
 
619
  if ( empty( $text ) ) {
620
  $icon_class = ' no-txt';
621
  } else {
@@ -649,7 +650,8 @@ class TInvWL_Public_AddToWishlist {
649
 
650
  $icon .= ( tinv_get_option( 'add_to_wishlist' . ( $this->is_loop ? '_catalog' : '' ), 'show_preloader' ) ) ? ' ftinvwl-animated' : '';
651
 
652
- $content .= sprintf( '<a role="button" class="tinvwl_add_to_wishlist_button tinvwl-add-hide %s" data-tinv-wl-list="" data-tinv-wl-product="%s" data-tinv-wl-productvariation="%s" data-tinv-wl-productvariations="%s" data-tinv-wl-producttype="%s" data-tinv-wl-action="add">%s</a>',
 
653
  $icon,
654
  apply_filters( 'wpml_object_id', ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $this->product->id : ( $this->product->is_type( 'variation' ) ? $this->product->get_parent_id() : $this->product->get_id() ) ), 'product', true ),
655
  apply_filters( 'wpml_object_id', ( ( $this->is_loop && in_array( ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $this->product->product_type : $this->product->get_type() ), array(
204
  } else {
205
  $post['product_type'] = apply_filters( 'tinvwl_addtowishlist_modify_type', $post['product_type'], $post );
206
  $post = apply_filters( 'tinvwl_addtowishlist_prepare', $post );
207
+ $form = apply_filters( 'tinvwl_addtowishlist_prepare_form', filter_input( INPUT_POST, 'form', FILTER_DEFAULT, FILTER_FORCE_ARRAY ), $_POST, $_FILES );
208
  if ( empty( $form ) ) {
209
  $form = array();
210
  }
610
  * @param boolean $echo Return or output.
611
  */
612
  function button( $echo = true ) {
613
+ $content = apply_filters( 'tinvwl_wishlist_button_before', '' );
614
+ $button_text = apply_filters( 'tinvwl_added_to_wishlist_text_loop', tinv_get_option( 'add_to_wishlist' . ( $this->is_loop ? '_catalog' : '' ), 'text' ) );
615
+ $text = ( tinv_get_option( 'add_to_wishlist' . ( $this->is_loop ? '_catalog' : '' ), 'show_text' ) ) ? $button_text : '';
616
+ $icon = tinv_get_option( 'add_to_wishlist' . ( $this->is_loop ? '_catalog' : '' ), 'icon' );
617
+ $icon_color = tinv_get_option( 'add_to_wishlist' . ( $this->is_loop ? '_catalog' : '' ), 'icon_style' );
618
+ $icon_class = '';
619
+ $action = 'addto';
620
  if ( empty( $text ) ) {
621
  $icon_class = ' no-txt';
622
  } else {
650
 
651
  $icon .= ( tinv_get_option( 'add_to_wishlist' . ( $this->is_loop ? '_catalog' : '' ), 'show_preloader' ) ) ? ' ftinvwl-animated' : '';
652
 
653
+ $content .= sprintf( '<a role="button" aria-label="%s" class="tinvwl_add_to_wishlist_button tinvwl-add-hide %s" data-tinv-wl-list="" data-tinv-wl-product="%s" data-tinv-wl-productvariation="%s" data-tinv-wl-productvariations="%s" data-tinv-wl-producttype="%s" data-tinv-wl-action="add">%s</a>',
654
+ $button_text,
655
  $icon,
656
  apply_filters( 'wpml_object_id', ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $this->product->id : ( $this->product->is_type( 'variation' ) ? $this->product->get_parent_id() : $this->product->get_id() ) ), 'product', true ),
657
  apply_filters( 'wpml_object_id', ( ( $this->is_loop && in_array( ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $this->product->product_type : $this->product->get_type() ), array(
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: templateinvaders
3
  Tags: woocommerce, wishlist, woocommerce wishlist, e-commerce, ecommerce
4
  Requires at least: 4.7
5
  Tested up to: 5.4
6
- Stable tag: 1.20.3
7
  License: GPLv3
8
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
9
  Plugin URI: https://wordpress.org/plugins/ti-woocommerce-wishlist/
@@ -163,6 +163,17 @@ Yes, you can! Join in on our [GitHub repository](https://github.com/TemplateInva
163
 
164
 
165
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
 
166
  = 1.20.3 =
167
  *Release Date - 11 June 2020*
168
 
@@ -200,217 +211,4 @@ Yes, you can! Join in on our [GitHub repository](https://github.com/TemplateInva
200
  * Fixed an issue with duplicated buttons for out of stock products and Divi theme
201
  * Fixed an issue with WP Rocket cache and WP REST API authorization for non-logged users
202
 
203
- = 1.19.0 =
204
- *Release Date - 24 April 2020*
205
-
206
- * Added integration with [Product Options and Price Calculation Formulas for WooCommerce – Uni CPO](https://wordpress.org/plugins/uni-woo-custom-product-options/) plugin
207
- * Added integration with [Hide Price and Add to Cart Button](https://woocommerce.com/products/hide-price-add-to-cart-button/?aff=3955) plugin
208
- * Added integration with [Advanced Product Fields (Product Options) for WooCommerce](https://wordpress.org/plugins/advanced-product-fields-for-woocommerce/) plugin
209
- * Added integration with WooCommerce Product Add-Ons Ultimate plugin
210
- * Added compatibility for wishlist products counter in Woostify theme
211
- * Fixed integration with WooCommerce Rental & Bookings System plugin
212
- * Fixed integration with Improved Product Options for WooCommerce plugin
213
- * Improved integration with [WooCommerce Composite Products](https://woocommerce.com/products/composite-products/?aff=3955) plugin
214
- * Fixed multiple REST API queries for dynamic buttons
215
- * Fixed wishlist product counter "hide zero value" issue
216
-
217
- = 1.18.4 =
218
- *Release Date - 22 April 2020*
219
-
220
- * Added {product_sku} placeholder for add to wishlist message text
221
- * Added filter `tinvwl_addtowishlist_message_placeholders` to override add to wishlist message placeholders from a 3rd party code
222
- * Fixed an issue with multiple wishlist button requests for AJAX products filtering
223
-
224
- = 1.18.3 =
225
- *Release Date - 18 April 2020*
226
-
227
- * Fixed an issue with wishlist buttons for multilingual setups
228
-
229
- = 1.18.2 =
230
- *Release Date - 14 April 2020*
231
-
232
- * Fixed an issue with REST API requests error for plain permalinks structure
233
-
234
- = 1.18.1 =
235
- *Release Date - 14 April 2020*
236
-
237
- * Fixed a JavaScript error for variable products with a default variation
238
-
239
- = 1.18.0 =
240
- *Release Date - 14 April 2020*
241
-
242
- * Improved cache compatibility for 'add to wishlist' button states and wishlist products counter
243
- * Wishlist products counter updating moved from WooCommerce AJAX fragments to a custom solution
244
- * Added option to add wishlist products counter to multiple WordPress menus from plugin settings
245
- * Added filter 'tinvwl_add_to_menu' to allow disabling wishlist products counter from 3rd party code
246
- * Added filter 'tinvwl_addtowishlist_not_allowed' for validation of product addition to wishlist from a 3rd party code
247
-
248
- = 1.17.1 =
249
- *Release Date - 02 April 2020*
250
-
251
- * Fixed PHP fatal error for WP Rocket integration
252
-
253
- = 1.17.0 =
254
- *Release Date - 29 March 2020*
255
-
256
- * WordPress 5.4 support
257
- * WooCommerce 4.0.x support
258
- * Added tool for export and import plugin settings
259
- * Added to share buttons translated title
260
- * REST API tweak: empty wishlist returns 200 response code and empty array now
261
-
262
-
263
- = 1.16.2 =
264
- *Release Date - 27 January 2020*
265
-
266
- * Fixed PHP error for WP Rocket old versions
267
-
268
- = 1.16.1 =
269
- *Release Date - 24 January 2020*
270
-
271
- * Fixed PHP Warning related to cart clearing in WooCommerce 3.9+
272
- * WP Rocket integration updated to use dynamic cookies for cache and fixed issue with cached wishlist products counter value
273
-
274
- = 1.16.0 =
275
- *Release Date - 30 December 2019*
276
-
277
- * WooCommerce 3.9.0 support
278
- * PHP 7.4 support
279
- * Added {product_name} placeholder support for options of add to wishlist notice text
280
- * Added filter `tinvwl_api_wishlist_get_products_response` to allow modify REST API response via 3rd party code
281
- * Fixed fatal error throws by add to wishlist shortcode
282
- * Fixed wishlist frontend issue when WooCommerce session doesn’t exists
283
-
284
- = 1.15.4 =
285
- *Release Date - 16 December 2019*
286
-
287
- * Added compatibility with Kallyas theme and guest issue when cart is hidden
288
- * Fixed product meta display on wishlist table
289
- * Improved compatibility with Divi builder
290
-
291
- = 1.15.3 =
292
- *Release Date - 12 December 2019*
293
-
294
- * Added compatibility for Divi builder to fix 'out of stock' issue
295
- * Enhanced compatibility with Improved Product Options for WooCommerce plugin
296
-
297
- = 1.15.2 =
298
- *Release Date - 6 December 2019*
299
-
300
- * Added compatibility with WooCommerce Variation Swatches - Pro plugin
301
- * Enhanced integration with WP Grid Builder plugin
302
- * Updated integration with WooCommerce TM Extra Product Options plugin
303
- * Updated integration with [WooCommerce Bookings](https://woocommerce.com/products/woocommerce-bookings/?aff=3955) plugin
304
-
305
- = 1.15.1 =
306
- *Release Date - 4 December 2019*
307
-
308
- * Added WP GridBuilder plugin custom block to show wishlist button
309
- * Fixed bulk-adding products from wishlist to cart for WooCommerce versions below 3.8
310
- * Fixed pricing issue for TM Extra Product Options plugin integration
311
-
312
- = 1.15.0 =
313
- *Release Date - 27 November 2019*
314
-
315
- * Added support for WordPress 5.3
316
- * Added support for WooCommerce 3.8
317
- * Added compatibility with Flatsome theme
318
- * Added AutomateWoo plugin integration with following triggers:
319
- * product added to wishlist;
320
- * wishlist reminder;
321
- * product from wishlist added to cart;
322
- * product from wishlist purchased;
323
- * product removed from wishlist;
324
- * Fixed issue related to 'Add All to cart' action
325
- * Fixed issue with removing products after adding to cart
326
- * Fixed issue with uppercase while wishlist share via copy to clipboard action
327
-
328
- = 1.14.6 =
329
- *Release Date - 1 October 2019*
330
-
331
- * Fixed PHP fatal error from product title method
332
-
333
- = 1.14.5 =
334
- *Release Date - 30 September 2019*
335
-
336
- * Added compatibility with Flatsome theme
337
- * Added compatibility with WooCommerce Variations Table - Grid plugin
338
- * Added compatibility with YITH WooCommerce Quick View plugin
339
- * Enhanced integration with WooCommerce Composite Products plugin
340
- * Enhanced integration with WooCommerce Product Bundles plugin
341
- * Enhanced integration with Improved Product Options for WooCommerce plugin
342
- * Updated title method to the name method for WooCommerce 3+
343
- * Fixed potential warning for conditional function is_page()
344
- * Fixed JavaScript issue with URL get parameters
345
-
346
- = 1.14.4 =
347
- *Release Date - 4 September 2019*
348
-
349
- * Fixed an issue with bundle products inside the composite product
350
- * Fixed Setup Wizard errors
351
- * Fixed WooCommerce 'My account' endpoint rewrites issue
352
-
353
- = 1.14.3 =
354
- *Release Date - 31 August 2019*
355
-
356
- * Added compatibility for hook 'woocommerce_before_cart_item_quantity_zero' that deprecated from WooCommerce 3.7.0
357
- * Fixed 'Add All to Cart' button issue
358
- * Fixed PHP Error when 'wc_clear_notices' method is not available
359
- * Improved stylesheets loading for plugin settings
360
-
361
- = 1.14.2 =
362
- *Release Date - 28 August 2019*
363
-
364
- * Added JavaScript event 'tinvwl_wishlist_added_status'
365
- * Added integration with WP Grid Builder plugin
366
- * Added integration with WooCommerce Show Single Variations by Iconic plugin
367
- * Fixed the option name 'Already In Wishlist'
368
- * Fixed PHP Error when 'wc_clear_notices' method is not available
369
- * Fixed integration with WooCommerce TM Extra Product Options plugin
370
- * Fixed WooCommerce.com affiliate code issue
371
- * Improved integration with WooCommerce Custom Product Addons (Pro) plugin
372
-
373
- = 1.14.1 =
374
- *Release Date - 15 August 2019*
375
-
376
- * Added feature to show 'Already on Wishlist' text on buttons
377
-
378
- = 1.14.0 =
379
- *Release Date - 12 August 2019*
380
-
381
- * Added support for WooCommerce 3.7
382
- * Added compatibility with [Variations Swatches and Photos](https://woocommerce.com/products/variation-swatches-and-photos/?aff=3955) plugin
383
- * Added compatibility with Clever Swatches plugin
384
- * Added compatibility with WooCommerce Custom Product Addons (Pro) plugin
385
- * Added compatibility with WooCommerce Rental & Bookings System plugin
386
- * Added compatibility with Booking & Appointment Plugin for WooCommerce
387
- * Refactored all 3rd party integrations code
388
- * Fixed an issue with properly load custom translation files
389
-
390
- = 1.13.2 =
391
- *Release Date - 30 July 2019*
392
-
393
- * Fixed a compatibility issue with WooCommerce Show Single Variations by Iconic plugin
394
-
395
- = 1.13.1 =
396
- *Release Date - 29 July 2019*
397
-
398
- * Fixed unclosed 'strong' tag in admin notification
399
- * Fixed empty URL issue for sharing buttons
400
- * Fixed performance for meta tags addition on the wishlist page
401
- * Fixed empty text issue for 'View Wishlist' button
402
- * Removed Google Plus (G+) sharing option since the service is closed
403
- * Added cleanup of deleted products from wishlist
404
- * Added parameters to the 'tinvwl_get_wishlist_products' to get a custom products query results
405
-
406
- = 1.13.0 =
407
- *Release Date - 15 July 2019*
408
-
409
- * Added wishlist [REST API](https://templateinvaders.com/api/wishlist/?utm_source=wordpressorg&utm_content=changelog)
410
- * Refactored filters and actions
411
- * Prevent plugin network-wide activation
412
- * Fixed an issue with deleted products in frontend templates
413
- * Fixed wishlist products query issue on multilingual setup
414
- * TM Product Options plugin integration updated
415
-
416
  [See the changelog for all versions](https://templateinvaders.com/changelogs/ti-woocommerce-wishlist-plugin-free-changelog/?utm_source=wordpressorg&utm_content=changelog).
3
  Tags: woocommerce, wishlist, woocommerce wishlist, e-commerce, ecommerce
4
  Requires at least: 4.7
5
  Tested up to: 5.4
6
+ Stable tag: 1.20.4
7
  License: GPLv3
8
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
9
  Plugin URI: https://wordpress.org/plugins/ti-woocommerce-wishlist/
163
 
164
 
165
  == Changelog ==
166
+ = 1.20.4 =
167
+ *Release Date - 24 June 2020*
168
+
169
+ * Fixed accessibility issue for add to wishlist button markup
170
+ * Fixed an issue with file upload for the integration of WooCommerce TM Extra Product Options plugin
171
+ * Fixed an issue with the wrong wishlist status for add to wishlist shortcode
172
+ * Fixed an issue when wishlist status wrong on specific variation product page load
173
+ * Improved security for Wishlist REST API methods
174
+ * Enhanced integration with WooCommerce Custom Product Addons plugin
175
+ * Updated integration with WP Fastest Cache plugin
176
+
177
  = 1.20.3 =
178
  *Release Date - 11 June 2020*
179
 
211
  * Fixed an issue with duplicated buttons for out of stock products and Divi theme
212
  * Fixed an issue with WP Rocket cache and WP REST API authorization for non-logged users
213
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
  [See the changelog for all versions](https://templateinvaders.com/changelogs/ti-woocommerce-wishlist-plugin-free-changelog/?utm_source=wordpressorg&utm_content=changelog).
ti-woocommerce-wishlist.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: TI WooCommerce Wishlist
5
  * Plugin URI: https://wordpress.org/plugins/ti-woocommerce-wishlist/
6
  * Description: Wishlist functionality for your WooCommerce store.
7
- * Version: 1.20.3
8
  * Requires at least: 4.7
9
  * Tested up to: 5.4
10
  * WC requires at least: 2.6
@@ -41,7 +41,7 @@ if ( ! defined( 'TINVWL_DOMAIN' ) ) {
41
  }
42
 
43
  if ( ! defined( 'TINVWL_FVERSION' ) ) {
44
- define( 'TINVWL_FVERSION', '1.20.3' );
45
  }
46
 
47
  if ( ! defined( 'TINVWL_LOAD_FREE' ) ) {
4
  * Plugin Name: TI WooCommerce Wishlist
5
  * Plugin URI: https://wordpress.org/plugins/ti-woocommerce-wishlist/
6
  * Description: Wishlist functionality for your WooCommerce store.
7
+ * Version: 1.20.4
8
  * Requires at least: 4.7
9
  * Tested up to: 5.4
10
  * WC requires at least: 2.6
41
  }
42
 
43
  if ( ! defined( 'TINVWL_FVERSION' ) ) {
44
+ define( 'TINVWL_FVERSION', '1.20.4' );
45
  }
46
 
47
  if ( ! defined( 'TINVWL_LOAD_FREE' ) ) {