WooCommerce Wishlist Plugin - Version 1.28.3

Version Description

Download this release

Release Info

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

Code changes from version 1.28.2 to 1.28.3

assets/css/admin-form-rtl.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.28.2
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.28.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}
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.28.2
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.28.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}
assets/css/admin-rtl.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.28.2
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  *{-webkit-box-sizing:border-box;box-sizing:border-box}
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.28.3
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  *{-webkit-box-sizing:border-box;box-sizing:border-box}
assets/css/admin-setup-rtl.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.28.2
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.28.3
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  html{background:#f6f3ed}
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.28.2
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.28.3
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.28.2
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  *{-webkit-box-sizing:border-box;box-sizing:border-box}
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.28.3
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  *{-webkit-box-sizing:border-box;box-sizing:border-box}
assets/css/public-rtl.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.28.2
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  .tinv-wishlist form,.tinv-wishlist p:last-child,.tinv-wishlist table{margin-bottom:0}
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.28.3
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  .tinv-wishlist form,.tinv-wishlist p:last-child,.tinv-wishlist table{margin-bottom:0}
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.28.2
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  .tinv-wishlist form,.tinv-wishlist p:last-child,.tinv-wishlist table{margin-bottom:0}
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.28.3
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  .tinv-wishlist form,.tinv-wishlist p:last-child,.tinv-wishlist table{margin-bottom:0}
assets/css/theme-rtl.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.28.2
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.28.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}
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.28.2
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.28.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}
assets/css/webfont-rtl.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.28.2
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  @font-face{font-family:"tinvwl-webfont";font-display:block;src:url("../fonts/tinvwl-webfont.eot?ver=xu2uyi");src:url("../fonts/tinvwl-webfont.eot?ver=xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.woff2?ver=xu2uyi") format("woff2"),url("../fonts/tinvwl-webfont.woff?ver=xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.ttf?ver=xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.svg?ver=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.28.3
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  @font-face{font-family:"tinvwl-webfont";font-display:block;src:url("../fonts/tinvwl-webfont.eot?ver=xu2uyi");src:url("../fonts/tinvwl-webfont.eot?ver=xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.woff2?ver=xu2uyi") format("woff2"),url("../fonts/tinvwl-webfont.woff?ver=xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.ttf?ver=xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.svg?ver=xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
assets/css/webfont.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.28.2
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  @font-face{font-family:"tinvwl-webfont";font-display:block;src:url("../fonts/tinvwl-webfont.eot?ver=xu2uyi");src:url("../fonts/tinvwl-webfont.eot?ver=xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.woff2?ver=xu2uyi") format("woff2"),url("../fonts/tinvwl-webfont.woff?ver=xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.ttf?ver=xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.svg?ver=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.28.3
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  @font-face{font-family:"tinvwl-webfont";font-display:block;src:url("../fonts/tinvwl-webfont.eot?ver=xu2uyi");src:url("../fonts/tinvwl-webfont.eot?ver=xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.woff2?ver=xu2uyi") format("woff2"),url("../fonts/tinvwl-webfont.woff?ver=xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.ttf?ver=xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.svg?ver=xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
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.28.2
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.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")})}),s(document).on("click",".tinvwl-chat-notice .notice-dismiss",function(t){s.post(tinvwl_comfirm.ajax_url,{action:"tinvwl_admin_chat_notice"})})}(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.28.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.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")})}),s(document).on("click",".tinvwl-chat-notice .notice-dismiss",function(t){s.post(tinvwl_comfirm.ajax_url,{action:"tinvwl_admin_chat_notice"})})}(jQuery);
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.28.2
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):a.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=a.onPrepareList.call(t)||t,t=a.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(a.text_already_in+" ").append(n))},onAction:{redirect:function(t){a.redirectTimer&&clearTimeout(a.redirectTimer),a.redirectTimer=window.setTimeout(function(){window.location.href=t},4e3)},force_redirect:function(t){window.location.href=t},wishlists:function(){},msg:function(t){if(!t)return!1;var i,n,o,e=c(t).eq(0);c("body > .tinv-wishlist").length||c("body").append(c("<div>").addClass("tinv-wishlist")),c("body > .tinv-wishlist").append(e),i=c("body > .tinv-wishlist").find("select, input, textarea, button, a").filter(":visible"),n=i.first(),o=i.last(),n.focus().blur(),o.on("keydown",function(t){9!==t.which||t.shiftKey||(t.preventDefault(),n.focus())}),n.on("keydown",function(t){9===t.which&&t.shiftKey&&(t.preventDefault(),o.focus())}),e.on("click",".tinv-close-modal, .tinvwl_button_close, .tinv-overlay",function(t){t.preventDefault(),e.remove(),a.redirectTimer&&clearTimeout(a.redirectTimer)})},status:function(t){c("body").trigger("tinvwl_wishlist_added_status",[this,t])},removed:function(){},make_remove:function(){},wishlists_data:function(t){d(JSON.stringify(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,o=[],d=new FormData;tinvwl_add_to_wishlist.wpml&&(r.lang=tinvwl_add_to_wishlist.wpml),c('form.cart[method=post][data-product_id="'+c(this).attr("data-tinv-wl-product")+'"], form.vtajaxform[method=post][data-product_id="'+c(this).attr("data-tinv-wl-product")+'"]').each(function(){o.push(c(this))}),o.length||(c(n).closest("form.cart[method=post], form.vtajaxform[method=post]").each(function(){o.push(c(this))}),o.length||o.push(c("form.cart[method=post]"))),c('.tinv-wraper[data-product_id="'+c(this).attr("data-tinv-wl-product")+'"]').each(function(){o.push(c(this))}),c.each(o,function(t,i){c(i).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=a.onPrepareDataAction.call(n,n,r)||r,c.each(r,function(n,t){"form"===n?c.each(t,function(t,i){"object"===_typeof(i)&&(i=JSON.stringify(i)),d.append(n+"["+t+"]",i)}):d.append(n,t)}),c.ajax({url:a.api_url,method:"POST",contentType:!1,processData:!1,data:d}).done(function(t){if(a.onDialogHide.call(n.tinvwl_dialog,n),"object"===_typeof(t))for(var i in t)"function"==typeof a.onAction[i]&&a.onAction[i].call(n,t[i]);else"function"==typeof a.onAction.msg&&a.onAction.msg.call(n,t)})};var a=c.extend(!0,{},i,t);return c(this).each(function(){if(!c(this).attr("data-tinv-wl-list"))return!1;if(a.dialogbox&&a.dialogbox.length&&(this.tinvwl_dialog=a.dialogbox),this.tinvwl_dialog||(this.tinvwl_dialog=a.onGetDialogBox.call(this)),!this.tinvwl_dialog){var t=c(this).nextAll(a.class.dialogbox).eq(0);t.length&&(this.tinvwl_dialog=t)}if(this.tinvwl_dialog){a.onPrepareDialogBox.call(this.tinvwl_dialog),"function"!=typeof this.tinvwl_dialog.update_list&&(this.tinvwl_dialog.update_list=function(t){var n=c(this).find(a.class.select).eq(0);c(this).find(a.class.newtitle).hide().val(""),n.html(""),c.each(t,function(t,i){a.onCreateWishList.call(n,i)}),a.text_create&&a.onCreateWishList.call(n,{ID:"",title:a.text_create,in:!1}),a.onMultiProductAlreadyIn.call(n,t),a.onSelectWishList.call(n,t),c(this).find(a.class.newtitle).toggle(""===n.val())}),"function"!=typeof this.tinvwl_dialog.show_list&&(this.tinvwl_dialog.show_list=function(){var t=JSON.parse(c(this).attr("data-tinv-wl-list"))||[];t.length?(t=a.onPrepareList.call(t)||t,this.tinvwl_dialog.update_list(t),a.onDialogShow.call(this.tinvwl_dialog,this)):a.onActionProduct.call(this)});var o=this;c(this.tinvwl_dialog).find(a.class.dialogbutton).off("click").on("click",function(){var t,i=c(o.tinvwl_dialog).find(a.class.select),n=c(o.tinvwl_dialog).find(a.class.newtitle);i.val()||n.val()?a.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",a.onClick),a.onInited.call(this,a)})},c(document).ready(function(){c("body").on("click keydown",".tinvwl_add_to_wishlist_button",function(t){if("keydown"===t.type){var i=void 0!==t.key?t.key:t.keyCode;if(!("Enter"===i||13===i||0<=["Spacebar"," "].indexOf(i)||32===i))return;t.preventDefault()}if(c("body").trigger("tinvwl_add_to_wishlist_button_click",[this]),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('.tinvwl_add_to_wishlist_button:not(.tinvwl-loop)[data-tinv-wl-product="'+c(this).data("product_id")+'"]');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('.tinvwl_add_to_wishlist_button:not(.tinvwl-loop)[data-tinv-wl-product="'+c(this).data("product_id")+'"]');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){if(s===t.originalEvent.key&&localStorage.getItem(s)!==sessionStorage.getItem(s)&&localStorage.getItem(s)){var i=JSON.parse(localStorage.getItem(s));"object"===_typeof(i)&&null!==i&&(i.hasOwnProperty("products")||i.hasOwnProperty("counter"))&&d(localStorage.getItem(s))}});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={};tinvwl_add_to_wishlist.wpml&&(t.lang=tinvwl_add_to_wishlist.wpml),c.ajax({url:tinvwl_add_to_wishlist.plugin_url+"includes/api/ajax.php",method:"POST",data:t,beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",tinvwl_add_to_wishlist.nonce)}}).done(function(t){d(JSON.stringify(t)),r(t)}).fail(function(){!function(){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){d(JSON.stringify(t)),r(t)})}}()})}}function e(){if(l&&(tinvwl_add_to_wishlist.update_wishlists_data&&localStorage.setItem(s,""),localStorage.getItem(s))){var t=JSON.parse(localStorage.getItem(s));if("object"===_typeof(t)&&null!==t&&(t.hasOwnProperty("products")||t.hasOwnProperty("counter"))&&(!t.hasOwnProperty("lang")&&!tinvwl_add_to_wishlist.wpml||tinvwl_add_to_wishlist.wpml&&t.lang===tinvwl_add_to_wishlist.wpml))return void r(t)}tinvwl_add_to_wishlist.block_ajax_wishlists_data||o()}e();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&&e()}),a=document.body;t.observe(a,{childList:!0,subtree:!0})});var l=!0,s=tinvwl_add_to_wishlist.hash_key;try{l="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){l=!1}function r(t){var l="1"==window.tinvwl_add_to_wishlist.simple_flow;l&&c("a.tinvwl_add_to_wishlist_button").each(function(){c(this).removeClass("tinvwl-product-make-remove").removeClass("tinvwl-product-already-on-wishlist").removeClass("tinvwl-product-in-list").attr("data-tinv-wl-action","addto").attr("data-tinv-wl-list","[]")}),c("body").trigger("tinvwl_wishlist_mark_products",[t]),c.each(t.products,function(t,e){var a=t;c('a.tinvwl_add_to_wishlist_button[data-tinv-wl-product="'+a+'"]').each(function(){var t=parseInt(c(this).attr("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("body").trigger("tinvwl_wishlist_product_marked",[this,n]),c(this).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")})}),function(t){"1"==window.tinvwl_add_to_wishlist.hide_zero_counter&&0===t&&(t="false");jQuery("i.wishlist-icon").addClass("added"),"false"!==t?(jQuery(".wishlist_products_counter_number, body.theme-woostify .wishlist-item-count").html(t),jQuery("i.wishlist-icon").attr("data-icon-label",t)):(jQuery(".wishlist_products_counter_number, body.theme-woostify .wishlist-item-count").html("").closest("span.wishlist-counter-with-products").removeClass("wishlist-counter-with-products"),jQuery("i.wishlist-icon").removeAttr("data-icon-label"));var i=!("0"==t||"false"==t);jQuery(".wishlist_products_counter").toggleClass("wishlist-counter-with-products",i),setTimeout(function(){jQuery("i.wishlist-icon").removeClass("added")},500)}(t.counter)}function d(t){l&&(localStorage.setItem(s,t),sessionStorage.setItem(s,t),r(JSON.parse(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(this).html().trim().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").trigger("tinvwl_modal_closed",[this])}),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").off("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){var i=[];void 0!==o(this).attr("tinvwl_break_submit")&&(i=o(this).attr("tinvwl_break_submit").split(",")),-1!==jQuery.inArray(n.selector,i)&&(i=[]),n.rule.call(o(this))||0!==i.length||(alert(window.tinvwl_add_to_wishlist.tinvwl_break_submit),t.preventDefault()),i.push(n.selector),o(this).attr("tinvwl_break_submit",i),n.rule.call(o(this))&&o(this).removeAttr("tinvwl_break_submit")})})},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.28.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(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):a.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=a.onPrepareList.call(t)||t,t=a.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(a.text_already_in+" ").append(n))},onAction:{redirect:function(t){a.redirectTimer&&clearTimeout(a.redirectTimer),a.redirectTimer=window.setTimeout(function(){window.location.href=t},4e3)},force_redirect:function(t){window.location.href=t},wishlists:function(){},msg:function(t){if(!t)return!1;var i,n,o,e=c(t).eq(0);c("body > .tinv-wishlist").length||c("body").append(c("<div>").addClass("tinv-wishlist")),c("body > .tinv-wishlist").append(e),i=c("body > .tinv-wishlist").find("select, input, textarea, button, a").filter(":visible"),n=i.first(),o=i.last(),n.focus().blur(),o.on("keydown",function(t){9!==t.which||t.shiftKey||(t.preventDefault(),n.focus())}),n.on("keydown",function(t){9===t.which&&t.shiftKey&&(t.preventDefault(),o.focus())}),e.on("click",".tinv-close-modal, .tinvwl_button_close, .tinv-overlay",function(t){t.preventDefault(),e.remove(),a.redirectTimer&&clearTimeout(a.redirectTimer)})},status:function(t){c("body").trigger("tinvwl_wishlist_added_status",[this,t])},removed:function(){},make_remove:function(){},wishlists_data:function(t){d(JSON.stringify(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,o=[],d=new FormData;tinvwl_add_to_wishlist.wpml&&(r.lang=tinvwl_add_to_wishlist.wpml),c('form.cart[method=post][data-product_id="'+c(this).attr("data-tinv-wl-product")+'"], form.vtajaxform[method=post][data-product_id="'+c(this).attr("data-tinv-wl-product")+'"]').each(function(){o.push(c(this))}),o.length||(c(n).closest("form.cart[method=post], form.vtajaxform[method=post]").each(function(){o.push(c(this))}),o.length||o.push(c("form.cart[method=post]"))),c('.tinv-wraper[data-product_id="'+c(this).attr("data-tinv-wl-product")+'"]').each(function(){o.push(c(this))}),c.each(o,function(t,i){c(i).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=a.onPrepareDataAction.call(n,n,r)||r,c.each(r,function(n,t){"form"===n?c.each(t,function(t,i){"object"===_typeof(i)&&(i=JSON.stringify(i)),d.append(n+"["+t+"]",i)}):d.append(n,t)}),c.ajax({url:a.api_url,method:"POST",contentType:!1,processData:!1,data:d}).done(function(t){if(a.onDialogHide.call(n.tinvwl_dialog,n),"object"===_typeof(t))for(var i in t)"function"==typeof a.onAction[i]&&a.onAction[i].call(n,t[i]);else"function"==typeof a.onAction.msg&&a.onAction.msg.call(n,t)})};var a=c.extend(!0,{},i,t);return c(this).each(function(){if(!c(this).attr("data-tinv-wl-list"))return!1;if(a.dialogbox&&a.dialogbox.length&&(this.tinvwl_dialog=a.dialogbox),this.tinvwl_dialog||(this.tinvwl_dialog=a.onGetDialogBox.call(this)),!this.tinvwl_dialog){var t=c(this).nextAll(a.class.dialogbox).eq(0);t.length&&(this.tinvwl_dialog=t)}if(this.tinvwl_dialog){a.onPrepareDialogBox.call(this.tinvwl_dialog),"function"!=typeof this.tinvwl_dialog.update_list&&(this.tinvwl_dialog.update_list=function(t){var n=c(this).find(a.class.select).eq(0);c(this).find(a.class.newtitle).hide().val(""),n.html(""),c.each(t,function(t,i){a.onCreateWishList.call(n,i)}),a.text_create&&a.onCreateWishList.call(n,{ID:"",title:a.text_create,in:!1}),a.onMultiProductAlreadyIn.call(n,t),a.onSelectWishList.call(n,t),c(this).find(a.class.newtitle).toggle(""===n.val())}),"function"!=typeof this.tinvwl_dialog.show_list&&(this.tinvwl_dialog.show_list=function(){var t=JSON.parse(c(this).attr("data-tinv-wl-list"))||[];t.length?(t=a.onPrepareList.call(t)||t,this.tinvwl_dialog.update_list(t),a.onDialogShow.call(this.tinvwl_dialog,this)):a.onActionProduct.call(this)});var o=this;c(this.tinvwl_dialog).find(a.class.dialogbutton).off("click").on("click",function(){var t,i=c(o.tinvwl_dialog).find(a.class.select),n=c(o.tinvwl_dialog).find(a.class.newtitle);i.val()||n.val()?a.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",a.onClick),a.onInited.call(this,a)})},c(document).ready(function(){c("body").on("click keydown",".tinvwl_add_to_wishlist_button",function(t){if("keydown"===t.type){var i=void 0!==t.key?t.key:t.keyCode;if(!("Enter"===i||13===i||0<=["Spacebar"," "].indexOf(i)||32===i))return;t.preventDefault()}if(c("body").trigger("tinvwl_add_to_wishlist_button_click",[this]),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('.tinvwl_add_to_wishlist_button:not(.tinvwl-loop)[data-tinv-wl-product="'+c(this).data("product_id")+'"]');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('.tinvwl_add_to_wishlist_button:not(.tinvwl-loop)[data-tinv-wl-product="'+c(this).data("product_id")+'"]');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){if(s===t.originalEvent.key&&localStorage.getItem(s)!==sessionStorage.getItem(s)&&localStorage.getItem(s)){var i=JSON.parse(localStorage.getItem(s));"object"===_typeof(i)&&null!==i&&(i.hasOwnProperty("products")||i.hasOwnProperty("counter"))&&d(localStorage.getItem(s))}});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={};tinvwl_add_to_wishlist.wpml&&(t.lang=tinvwl_add_to_wishlist.wpml),c.ajax({url:tinvwl_add_to_wishlist.plugin_url+"includes/api/ajax.php",method:"POST",data:t,beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",tinvwl_add_to_wishlist.nonce)}}).done(function(t){d(JSON.stringify(t)),r(t)}).fail(function(){!function(){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){d(JSON.stringify(t)),r(t)})}}()})}}function e(){if(l&&(tinvwl_add_to_wishlist.update_wishlists_data&&localStorage.setItem(s,""),localStorage.getItem(s))){var t=JSON.parse(localStorage.getItem(s));if("object"===_typeof(t)&&null!==t&&(t.hasOwnProperty("products")||t.hasOwnProperty("counter"))&&(!t.hasOwnProperty("lang")&&!tinvwl_add_to_wishlist.wpml||tinvwl_add_to_wishlist.wpml&&t.lang===tinvwl_add_to_wishlist.wpml))return void r(t)}tinvwl_add_to_wishlist.block_ajax_wishlists_data||o()}e();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&&e()}),a=document.body;t.observe(a,{childList:!0,subtree:!0})});var l=!0,s=tinvwl_add_to_wishlist.hash_key;try{l="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){l=!1}function r(t){var l="1"==window.tinvwl_add_to_wishlist.simple_flow;l&&c("a.tinvwl_add_to_wishlist_button").each(function(){c(this).removeClass("tinvwl-product-make-remove").removeClass("tinvwl-product-already-on-wishlist").removeClass("tinvwl-product-in-list").attr("data-tinv-wl-action","addto").attr("data-tinv-wl-list","[]")}),c("body").trigger("tinvwl_wishlist_mark_products",[t]),c.each(t.products,function(t,e){var a=t;c('a.tinvwl_add_to_wishlist_button[data-tinv-wl-product="'+a+'"]').each(function(){var t=parseInt(c(this).attr("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("body").trigger("tinvwl_wishlist_product_marked",[this,n]),c(this).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")})}),function(t){"1"==window.tinvwl_add_to_wishlist.hide_zero_counter&&0===t&&(t="false");jQuery("i.wishlist-icon").addClass("added"),"false"!==t?(jQuery(".wishlist_products_counter_number, body.theme-woostify .wishlist-item-count").html(t),jQuery("i.wishlist-icon").attr("data-icon-label",t)):(jQuery(".wishlist_products_counter_number, body.theme-woostify .wishlist-item-count").html("").closest("span.wishlist-counter-with-products").removeClass("wishlist-counter-with-products"),jQuery("i.wishlist-icon").removeAttr("data-icon-label"));var i=!("0"==t||"false"==t);jQuery(".wishlist_products_counter").toggleClass("wishlist-counter-with-products",i),setTimeout(function(){jQuery("i.wishlist-icon").removeClass("added")},500)}(t.counter)}function d(t){l&&(localStorage.setItem(s,t),sessionStorage.setItem(s,t),r(JSON.parse(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(this).html().trim().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").trigger("tinvwl_modal_closed",[this])}),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").off("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){var i=[];void 0!==o(this).attr("tinvwl_break_submit")&&(i=o(this).attr("tinvwl_break_submit").split(",")),-1!==jQuery.inArray(n.selector,i)&&(i=[]),n.rule.call(o(this))||0!==i.length||(alert(window.tinvwl_add_to_wishlist.tinvwl_break_submit),t.preventDefault()),i.push(n.selector),o(this).attr("tinvwl_break_submit",i),n.rule.call(o(this))&&o(this).removeAttr("tinvwl_break_submit")})})},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/tinvwl.class.php CHANGED
@@ -78,8 +78,6 @@ class TInvWL
78
  TInvWL_Activator::activate();
79
  }
80
 
81
- $this->rename();
82
-
83
  TInvWL_View::_init($this->_name, $this->_version);
84
  TInvWL_Form::_init($this->_name);
85
 
@@ -99,67 +97,6 @@ class TInvWL
99
  $this->rest_api = TInvWL_API::init();
100
  }
101
 
102
-
103
- /**
104
- * Rename "wishlist" word across the plugin.
105
- */
106
- private function rename()
107
- {
108
- $this->rename = tinv_get_option('rename', 'rename');
109
- $this->rename_single = tinv_get_option('rename', 'rename_single');
110
- $this->rename_plural = tinv_get_option('rename', 'rename_plural');
111
-
112
- if ($this->rename && $this->rename_single) {
113
- add_filter('gettext', array($this, 'translations'), 999, 3);
114
- add_filter('ngettext', array($this, 'translations_n'), 999, 5);
115
- }
116
- }
117
-
118
-
119
- function translations_n($translation, $single, $plural, $number, $domain)
120
- {
121
- return $this->translation_update($translation, $domain);
122
- }
123
-
124
- function translations($translation, $text, $domain)
125
- {
126
- return $this->translation_update($translation, $domain);
127
- }
128
-
129
- private function translation_update($text, $domain)
130
- {
131
- if ('ti-woocommerce-wishlist' === $domain) {
132
-
133
- $translations = ['wishlist' => [$this->rename_single, $this->rename_plural ? $this->rename_plural : $this->rename_single . 's']];
134
-
135
- $text = preg_replace_callback('~\b[a-z]+(?:(?<=(s)))?~i', function ($m) use ($translations) {
136
- $lower = strtolower($m[0]);
137
- $rep = $m[0];
138
- if (isset($translations[$lower])) {
139
- $rep = is_array($translations[$lower]) ? $translations[$lower][0] : $translations[$lower];
140
- } elseif (isset($m[1])) {
141
- $sing = substr($lower, 0, -1);
142
- if (isset($translations[$sing]))
143
- $rep = is_array($translations[$sing]) ? $translations[$sing][1] : $translations[$sing] . 's';
144
- } else {
145
- return $rep;
146
- }
147
-
148
- if ($m[0] == $lower)
149
- return $rep;
150
- elseif ($m[0] == strtoupper($lower))
151
- return strtoupper($rep);
152
- elseif ($m[0] == ucfirst($lower))
153
- return ucfirst($rep);
154
-
155
- return $rep;
156
- }, $text);
157
-
158
- }
159
- return $text;
160
- }
161
-
162
-
163
  /**
164
  * Set localization
165
  */
78
  TInvWL_Activator::activate();
79
  }
80
 
 
 
81
  TInvWL_View::_init($this->_name, $this->_version);
82
  TInvWL_Form::_init($this->_name);
83
 
97
  $this->rest_api = TInvWL_API::init();
98
  }
99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  /**
101
  * Set localization
102
  */
languages/ti-woocommerce-wishlist.pot CHANGED
@@ -1,8 +1,8 @@
1
- # Copyright (C) 2021 TI WooCommerce Wishlist Plugin - 1.28.2
2
- # This file is distributed under the same license as the TI WooCommerce Wishlist Plugin - 1.28.2 package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: TI WooCommerce Wishlist Plugin - 1.28.2\n"
6
  "MIME-Version: 1.0\n"
7
  "Content-Type: text/plain; charset=UTF-8\n"
8
  "Content-Transfer-Encoding: 8bit\n"
@@ -952,15 +952,15 @@ msgstr ""
952
  msgid "%1$s is conflicted with %2$s %3$s. Deactivating %1$s."
953
  msgstr ""
954
 
955
- #: includes/tinvwl.class.php:239
956
  msgid "Settings"
957
  msgstr ""
958
 
959
- #: includes/tinvwl.class.php:240
960
  msgid "Premium Version"
961
  msgstr ""
962
 
963
- #: includes/tinvwl.class.php:241
964
  msgid "Live Demo"
965
  msgstr ""
966
 
1
+ # Copyright (C) 2021 TI WooCommerce Wishlist Plugin - 1.28.3
2
+ # This file is distributed under the same license as the TI WooCommerce Wishlist Plugin - 1.28.3 package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: TI WooCommerce Wishlist Plugin - 1.28.3\n"
6
  "MIME-Version: 1.0\n"
7
  "Content-Type: text/plain; charset=UTF-8\n"
8
  "Content-Transfer-Encoding: 8bit\n"
952
  msgid "%1$s is conflicted with %2$s %3$s. Deactivating %1$s."
953
  msgstr ""
954
 
955
+ #: includes/tinvwl.class.php:176
956
  msgid "Settings"
957
  msgstr ""
958
 
959
+ #: includes/tinvwl.class.php:177
960
  msgid "Premium Version"
961
  msgstr ""
962
 
963
+ #: includes/tinvwl.class.php:178
964
  msgid "Live Demo"
965
  msgstr ""
966
 
public/tinvwl.class.php CHANGED
@@ -302,8 +302,8 @@ class TInvWL_Public_TInvWL
302
  if ($language_codes && (defined('POLYLANG_VERSION') || defined('ICL_PLUGIN_PATH'))) {
303
  add_rewrite_rule('^(' . $language_codes . ')/(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/wl_page/([0-9]{1,})/{0,1}$', 'index.php?pagename=$matches[2]&tinvwlID=$matches[4]&wl_paged=$matches[5]&lang=$matches[1]', 'top');
304
  self::$rules_raw['^(' . $language_codes . ')/(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/wl_page/([0-9]{1,})/{0,1}$'] = 'index.php?pagename=$matches[2]&tinvwlID=$matches[4]&wl_paged=$matches[5]&lang=$matches[1]';
305
- add_rewrite_rule('^(' . $language_codes . ')/(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/{0,1}$', 'index.php?pagename=$matches[2]&tinvwlID=$matches[4]&wl_paged=$matches[5]&lang=$matches[1]', 'top');
306
- self::$rules_raw['^(' . $language_codes . ')/(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/{0,1}$'] = 'index.php?pagename=$matches[2]&tinvwlID=$matches[4]&wl_paged=$matches[5]&lang=$matches[1]';
307
  }
308
 
309
  // Wishlist on frontpage.
302
  if ($language_codes && (defined('POLYLANG_VERSION') || defined('ICL_PLUGIN_PATH'))) {
303
  add_rewrite_rule('^(' . $language_codes . ')/(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/wl_page/([0-9]{1,})/{0,1}$', 'index.php?pagename=$matches[2]&tinvwlID=$matches[4]&wl_paged=$matches[5]&lang=$matches[1]', 'top');
304
  self::$rules_raw['^(' . $language_codes . ')/(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/wl_page/([0-9]{1,})/{0,1}$'] = 'index.php?pagename=$matches[2]&tinvwlID=$matches[4]&wl_paged=$matches[5]&lang=$matches[1]';
305
+ add_rewrite_rule('^(' . $language_codes . ')/(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/{0,1}$', 'index.php?pagename=$matches[2]&tinvwlID=$matches[4]&lang=$matches[1]', 'top');
306
+ self::$rules_raw['^(' . $language_codes . ')/(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/{0,1}$'] = 'index.php?pagename=$matches[2]&tinvwlID=$matches[4]&lang=$matches[1]';
307
  }
308
 
309
  // Wishlist on frontpage.
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.8
6
- Stable tag: 1.28.2
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,12 @@ Yes, you can! Join in on our [GitHub repository](https://github.com/TemplateInva
163
 
164
 
165
  == Changelog ==
 
 
 
 
 
 
166
  = 1.28.2 =
167
  *Release Date - 23 August 2021*
168
 
3
  Tags: woocommerce, wishlist, woocommerce wishlist, e-commerce, ecommerce
4
  Requires at least: 4.7
5
  Tested up to: 5.8
6
+ Stable tag: 1.28.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
 
164
 
165
  == Changelog ==
166
+ = 1.28.2 =
167
+ *Release Date - 25 August 2021*
168
+
169
+ * Fixed permalink issue for multilingual setups
170
+ * Fixed rename feature issues
171
+
172
  = 1.28.2 =
173
  *Release Date - 23 August 2021*
174
 
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.28.2
8
  * Requires at least: 4.7
9
  * Tested up to: 5.8
10
  * WC requires at least: 3.0
@@ -41,7 +41,7 @@ if (!defined('TINVWL_DOMAIN')) {
41
  }
42
 
43
  if (!defined('TINVWL_FVERSION')) {
44
- define('TINVWL_FVERSION', '1.28.2');
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.28.3
8
  * Requires at least: 4.7
9
  * Tested up to: 5.8
10
  * WC requires at least: 3.0
41
  }
42
 
43
  if (!defined('TINVWL_FVERSION')) {
44
+ define('TINVWL_FVERSION', '1.28.3');
45
  }
46
 
47
  if (!defined('TINVWL_LOAD_FREE')) {
tinv-wishlists-function.php CHANGED
@@ -1,921 +1,1020 @@
1
- <?php
2
- /**
3
- * Basic function for plugin
4
- *
5
- * @since 1.0.0
6
- * @package TInvWishlist
7
- */
8
-
9
- // If this file is called directly, abort.
10
- if ( ! defined( 'ABSPATH' ) ) {
11
- die;
12
- }
13
-
14
-
15
- if ( ! function_exists( 'tinv_get_option' ) ) {
16
-
17
- /**
18
- * Extract options from database or default array settings.
19
- *
20
- * @param string $category Name category settings.
21
- * @param string $option Name paremetr. If is empty string, then function return array category settings.
22
- *
23
- * @return mixed
24
- */
25
- function tinv_get_option( $category, $option = '' ) {
26
- $prefix = TINVWL_PREFIX . '-';
27
- $values = get_option( $prefix . $category, array() );
28
- if ( empty( $values ) ) {
29
- $values = tinv_get_option_defaults( $category );
30
- }
31
- if ( empty( $option ) ) {
32
- return $values;
33
- } else {
34
- if ( array_key_exists( $option, (array) $values ) ) {
35
- return $values[ $option ];
36
- } else {
37
- $values = tinv_get_option_defaults( $category );
38
- if ( array_key_exists( $option, (array) $values ) ) {
39
- return $values[ $option ];
40
- }
41
- }
42
- }
43
-
44
- return null;
45
- }
46
- }
47
-
48
- if ( ! function_exists( 'tinv_get_option_admin' ) ) {
49
-
50
- /**
51
- * Extract options from database or default array settings.
52
- *
53
- * @param string $category Name category settings.
54
- * @param string $option Name paremetr. If is empty string, then function return array category settings.
55
- *
56
- * @return mixed
57
- */
58
- function tinv_get_option_admin( $category, $option = '' ) {
59
- $prefix = TINVWL_PREFIX . '-';
60
- $values = get_option( $prefix . $category, array() );
61
- if ( empty( $values ) ) {
62
- $values = array();
63
- }
64
- if ( empty( $option ) ) {
65
- return $values;
66
- } elseif ( array_key_exists( $option, $values ) ) {
67
- return $values[ $option ];
68
- }
69
-
70
- return null;
71
- }
72
- }
73
-
74
- if ( ! function_exists( 'tinv_style' ) ) {
75
-
76
- /**
77
- * Get style for custom style
78
- *
79
- * @param string $selector Selector style.
80
- * @param string $element Attribute name.
81
- *
82
- * @return string
83
- */
84
- function tinv_style( $selector = '', $element = '' ) {
85
- $key = md5( $selector . '||' . $element );
86
- $values = get_option( TINVWL_PREFIX . '-style_options', array() );
87
- if ( empty( $values ) ) {
88
- return '';
89
- }
90
- if ( array_key_exists( $key, $values ) ) {
91
- return $values[ $key ];
92
- }
93
-
94
- return '';
95
- }
96
- }
97
-
98
- if ( ! function_exists( 'tinv_update_option' ) ) {
99
-
100
- /**
101
- * Update options in database.
102
- *
103
- * @param string $category Name category settings.
104
- * @param string $option Name paremetr. If is empty string, then function update array category settings.
105
- * @param mixed $value Value option.
106
- *
107
- * @return boolean
108
- */
109
- function tinv_update_option( $category, $option = '', $value = false ) {
110
- $prefix = TINVWL_PREFIX . '-';
111
- if ( empty( $option ) ) {
112
- if ( is_array( $value ) ) {
113
- update_option( $prefix . $category, $value );
114
-
115
- return true;
116
- }
117
- } else {
118
- $values = get_option( $prefix . $category, array() );
119
-
120
- $values[ $option ] = $value;
121
- update_option( $prefix . $category, $values );
122
-
123
- return true;
124
- }
125
-
126
- return false;
127
- }
128
- }
129
-
130
- if ( ! function_exists( 'tinv_wishlist_template' ) ) {
131
-
132
- /**
133
- * The function overwrites the method output templates woocommerce
134
- *
135
- * @param string $template_name Name file template.
136
- * @param array $args Array variable in template.
137
- * @param string $template_path Customization path.
138
- */
139
- function tinv_wishlist_template( $template_name, $args = array(), $template_path = '' ) {
140
- if ( function_exists( 'wc_get_template' ) ) {
141
- wc_get_template( $template_name, $args, $template_path );
142
- } else {
143
- woocommerce_get_template( $template_name, $args, $template_path );
144
- }
145
- }
146
- }
147
-
148
- if ( ! function_exists( 'tinv_wishlist_locate_template' ) ) {
149
-
150
- /**
151
- * Overwrites path for email and other template
152
- *
153
- * @param string $template_name Requered Template file.
154
- * @param string $template_path Template path.
155
- * @param string $default_path Template default path.
156
- *
157
- * @return mixed
158
- */
159
- function tinv_wishlist_locate_template( $template_name, $template_path = '', $default_path = '' ) {
160
- $prefix = 'ti-';
161
-
162
- if ( substr( basename( $template_name ), 0, strlen( $prefix ) ) !== $prefix ) {
163
- return;
164
- }
165
-
166
- if ( ! $template_path ) {
167
- $template_path = WC()->template_path();
168
- }
169
-
170
- if ( ! $default_path ) {
171
- $default_path = TINVWL_PATH . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR;
172
- }
173
-
174
- // Look within passed path within the theme - this is priority.
175
- $template = locate_template( array(
176
- trailingslashit( $template_path ) . $template_name,
177
- $template_name,
178
- ) );
179
-
180
- // Get default template.
181
- if ( ! $template && file_exists( $default_path . $template_name ) ) {
182
- $template = $default_path . $template_name;
183
- }
184
-
185
- // Return what we found.
186
- return apply_filters( 'tinvwl_locate_template', $template, $template_name, $template_path );
187
- }
188
- } // End if().
189
-
190
- if ( ! function_exists( 'tinv_wishlist_template_html' ) ) {
191
-
192
- /**
193
- * The function overwrites the method return templates woocommerce
194
- *
195
- * @param string $template_name Name file template.
196
- * @param array $args Array variable in template.
197
- * @param string $template_path Customization path.
198
- *
199
- * @return string
200
- */
201
- function tinv_wishlist_template_html( $template_name, $args = array(), $template_path = '' ) {
202
- ob_start();
203
- tinv_wishlist_template( $template_name, $args, $template_path );
204
-
205
- return ob_get_clean();
206
- }
207
- }
208
-
209
- if ( ! function_exists( 'tinv_wishlist_get_item_data' ) ) {
210
-
211
- /**
212
- * Extract meta attributes for product
213
- *
214
- * @param object $product Object selected product.
215
- * @param array $wl_product Wishlist selected product.
216
- * @param boolean $flat Return text or template.
217
- *
218
- * @return string
219
- */
220
- function tinv_wishlist_get_item_data( $product, $wl_product = array(), $flat = false ) {
221
- $item_data = array();
222
- $variation_id = $product->is_type( 'variation' ) ? $product->get_id() : 0;
223
- $variation_data = $product->is_type( 'variation' ) ? wc_get_product_variation_attributes( $product->get_id() ) : array();
224
- if ( ! empty( $variation_id ) && is_array( $variation_data ) && is_array( $wl_product ) ) {
225
- foreach ( $variation_data as $name => $value ) {
226
- if ( '' === $value ) {
227
- // Could be any value that saved to a custom meta.
228
- if ( array_key_exists( 'meta', $wl_product ) && array_key_exists( $name, $wl_product['meta'] ) ) {
229
- $value = $wl_product['meta'][ $name ];
230
- } else {
231
- continue;
232
- }
233
- }
234
-
235
- $taxonomy = wc_attribute_taxonomy_name( str_replace( 'attribute_pa_', '', urldecode( $name ) ) );
236
-
237
- // If this is a term slug, get the term's nice name.
238
- if ( taxonomy_exists( $taxonomy ) ) {
239
- $term = get_term_by( 'slug', $value, $taxonomy ); // @codingStandardsIgnoreLine WordPress.VIP.RestrictedFunctions.get_term_by
240
- if ( ! is_wp_error( $term ) && $term && $term->name ) {
241
- $value = $term->name;
242
- }
243
- $label = wc_attribute_label( $taxonomy );
244
-
245
- // If this is a custom option slug, get the options name.
246
- } else {
247
- $value = apply_filters( 'woocommerce_variation_option_name', $value );
248
- $product_attributes = $product->get_attributes();
249
- $_name = str_replace( 'attribute_', '', $name );
250
- if ( isset( $product_attributes[ $_name ] ) ) {
251
- $label = wc_attribute_label( $_name, $product );
252
- } else {
253
- $label = $name;
254
- }
255
- }
256
- if ( '' === $value || wc_is_attribute_in_product_name( $value, is_callable( array(
257
- $product,
258
- 'get_name'
259
- ) ) ? $product->get_name() : $product->get_title() ) ) {
260
- continue;
261
- }
262
- $item_data[] = array(
263
- 'key' => $label,
264
- 'value' => $value,
265
- );
266
- } // End foreach().
267
- } // End if().
268
-
269
- // Filter item data to allow 3rd parties to add more to the array.
270
- $item_data = apply_filters( 'tinvwl_wishlist_get_item_data', $item_data, $product );
271
-
272
- // Format item data ready to display.
273
- foreach ( $item_data as $key => $data ) {
274
- // Set hidden to true to not display meta on cart.
275
- if ( ! empty( $data['hidden'] ) ) {
276
- unset( $item_data[ $key ] );
277
- continue;
278
- }
279
- $item_data[ $key ]['key'] = ! empty( $data['key'] ) ? $data['key'] : $data['name'];
280
- $item_data[ $key ]['display'] = ! empty( $data['display'] ) ? $data['display'] : $data['value'];
281
- }
282
-
283
- // Output flat or in list format.
284
- if ( 0 < count( $item_data ) ) {
285
- ob_start();
286
- if ( $flat ) {
287
- foreach ( $item_data as $data ) {
288
- echo esc_html( $data['key'] ) . ': ' . wp_kses_post( $data['display'] ) . '<br>';
289
- }
290
- } else {
291
- tinv_wishlist_template( 'ti-wishlist-item-data.php', array( 'item_data' => $item_data ) );
292
- }
293
-
294
- return ob_get_clean();
295
- }
296
-
297
- return '';
298
- }
299
- } // End if().
300
-
301
- if ( ! function_exists( 'tinv_wishlist_get' ) ) {
302
-
303
- /**
304
- * Return Wishlist by id or share key
305
- *
306
- * @param mixed $id Integer wishlist ID, or Share Key wishlist.
307
- * @param boolean $toend Switches to the extract the default or guest wishlist.
308
- *
309
- * @return array
310
- */
311
- function tinv_wishlist_get( $id = '', $toend = true ) {
312
- $wl = new TInvWL_Wishlist();
313
- $wishlist = null;
314
- if ( empty( $id ) ) {
315
- $id = get_query_var( 'tinvwlID', null );
316
- }
317
-
318
- if ( ! empty( $id ) ) {
319
- if ( is_integer( $id ) ) {
320
- $wishlist = $wl->get_by_id( $id );
321
- }
322
- if ( empty( $wishlist ) ) {
323
- $wishlist = $wl->get_by_share_key( $id );
324
- }
325
-
326
- if ( is_array( $wishlist ) ) {
327
- $wishlist['is_owner'] = false;
328
- if ( is_user_logged_in() ) {
329
- $wishlist['is_owner'] = get_current_user_id() == $wishlist['author']; // WPCS: loose comparison ok.
330
- } else {
331
- $wishlist['is_owner'] = $wl->get_sharekey() === $wishlist['share_key']; // WPCS: loose comparison ok.
332
- }
333
- }
334
- } elseif ( is_user_logged_in() && $toend ) {
335
- $wishlist = $wl->add_user_default();
336
-
337
- $wishlist['is_owner'] = true;
338
- } elseif ( $toend ) {
339
- $wishlist = $wl->get_by_sharekey_default();
340
- if ( ! empty( $wishlist ) ) {
341
- $wishlist = array_shift( $wishlist );
342
- $wishlist['is_owner'] = $wl->get_sharekey() === $wishlist['share_key'];
343
- }
344
- }
345
-
346
- return $wishlist;
347
- }
348
- } // End if().
349
-
350
- if ( ! function_exists( 'tinv_url_wishlist_default' ) ) {
351
-
352
- /**
353
- * Return the default wishlist url
354
- *
355
- * @return string
356
- */
357
- function tinv_url_wishlist_default() {
358
- $page = apply_filters( 'wpml_object_id', tinv_get_option( 'page', 'wishlist' ), 'page', true ); // @codingStandardsIgnoreLine WordPress.Variables.GlobalVariables.OverrideProhibited
359
- if ( empty( $page ) ) {
360
- return '';
361
- }
362
- $link = get_permalink( $page );
363
-
364
- return $link;
365
- }
366
- }
367
-
368
- if ( ! function_exists( 'tinv_url_wishlist_by_key' ) ) {
369
-
370
- /**
371
- * Return the wishlist url by share key
372
- *
373
- * @param string $share_key Share Key wishlist.
374
- * @param integer $paged Page.
375
- *
376
- * @return string
377
- */
378
- function tinv_url_wishlist_by_key( $share_key, $paged = 1 ) {
379
- $paged = absint( $paged );
380
- $paged = 1 < $paged ? $paged : 1;
381
- $link = tinv_url_wishlist_default();
382
- if ( empty( $link ) ) {
383
- return $link;
384
- }
385
-
386
- if ( 1 < $paged ) {
387
- $link = add_query_arg( 'wl_paged', $paged, $link );
388
- }
389
-
390
- if ( $share_key ) {
391
- if ( get_option( 'permalink_structure' ) ) {
392
- $suffix = '';
393
- if ( preg_match( '/([^\?]+)\?*?(.*)/i', $link, $_link ) ) {
394
- $link = $_link[1];
395
- $suffix = $_link[2];
396
- }
397
- if ( ! preg_match( '/\/$/', $link ) ) {
398
- $link .= '/';
399
- }
400
- $link .= $share_key . '/' . $suffix;
401
- } else {
402
- $link = add_query_arg( 'tinvwlID', $share_key, $link );
403
- }
404
- }
405
-
406
- return $link;
407
- }
408
- } // End if().
409
-
410
- if ( ! function_exists( 'tinv_url_wishlist' ) ) {
411
-
412
- /**
413
- * Return the wishlist url by id or share key
414
- *
415
- * @param mixed $id Integer wishlist ID, or Share Key wishlist.
416
- * @param integer $paged Page.
417
- * @param boolean $full Return full url or shroted url for logged in user.
418
- *
419
- * @return string
420
- */
421
- function tinv_url_wishlist( $id = '', $paged = 1, $full = true ) {
422
- $share_key = $id;
423
- if ( ! ( is_string( $id ) && preg_match( '/^[A-Fa-f0-9]{6}$/', $id ) ) ) {
424
- $wishlist = tinv_wishlist_get( $id, false );
425
- $share_key = $wishlist['share_key'];
426
- }
427
-
428
- return tinv_url_wishlist_by_key( $share_key, $paged );
429
- }
430
- }
431
-
432
- if ( ! function_exists( 'tinv_wishlist_status' ) ) {
433
-
434
- /**
435
- * Check status free or premium plugin and disable free
436
- *
437
- * @param string $transient Plugin transient name.
438
- *
439
- * @return string
440
- * @global string $s
441
- *
442
- * @global string $status
443
- * @global string $page
444
- */
445
- function tinv_wishlist_status( $transient ) {
446
- if ( TINVWL_LOAD_FREE === $transient ) {
447
- TInvWL_PluginExtend::deactivate_self( TINVWL_LOAD_FREE );
448
-
449
- return 'plugins.php';
450
- }
451
- if ( TINVWL_LOAD_PREMIUM === $transient ) {
452
- if ( is_plugin_active( TINVWL_LOAD_FREE ) ) {
453
- TInvWL_PluginExtend::deactivate_self( TINVWL_LOAD_FREE );
454
- if ( ! function_exists( 'wp_create_nonce' ) ) {
455
- return 'plugins.php';
456
- }
457
-
458
- global $status, $page, $s;
459
- $redirect = 'plugins.php?';
460
- $redirect .= http_build_query( array(
461
- 'action' => 'activate',
462
- 'plugin' => $transient,
463
- 'plugin_status' => $status,
464
- 'paged' => $page,
465
- 's' => $s,
466
- ) );
467
- $redirect = esc_url_raw( add_query_arg( '_wpnonce', wp_create_nonce( 'activate-plugin_' . $transient ), $redirect ) );
468
-
469
- return $redirect;
470
- }
471
- }
472
-
473
- return false;
474
- }
475
- } // End if().
476
-
477
- if ( ! function_exists( 'tinvwl_body_classes' ) ) {
478
-
479
- /**
480
- * Add custom class
481
- *
482
- * @param array $classes Current classes.
483
- *
484
- * @return array
485
- */
486
- function tinvwl_body_classes( $classes ) {
487
- if ( tinv_get_option( 'style', 'customstyle' ) ) {
488
- $classes[] = 'tinvwl-theme-style';
489
- } else {
490
- $classes[] = 'tinvwl-custom-style';
491
- }
492
-
493
- return $classes;
494
- }
495
-
496
- add_filter( 'body_class', 'tinvwl_body_classes' );
497
- }
498
-
499
- if ( ! function_exists( 'tinvwl_shortcode_addtowishlist' ) ) {
500
-
501
- /**
502
- * Shortcode Add To Wishlist
503
- *
504
- * @param array $atts Array parameter from shortcode.
505
- *
506
- * @return string
507
- */
508
- function tinvwl_shortcode_addtowishlist( $atts = array() ) {
509
- $class = TInvWL_Public_AddToWishlist::instance();
510
-
511
- return $class->shortcode( $atts );
512
- }
513
-
514
- add_shortcode( 'ti_wishlists_addtowishlist', 'tinvwl_shortcode_addtowishlist' );
515
- }
516
-
517
- if ( ! function_exists( 'tinvwl_shortcode_view' ) ) {
518
-
519
- /**
520
- * Shortcode view Wishlist
521
- *
522
- * @param array $atts Array parameter from shortcode.
523
- *
524
- * @return string
525
- */
526
- function tinvwl_shortcode_view( $atts = array() ) {
527
- $class = TInvWL_Public_Wishlist_View::instance();
528
-
529
- return $class->shortcode( $atts );
530
- }
531
-
532
- add_shortcode( 'ti_wishlistsview', 'tinvwl_shortcode_view' );
533
- }
534
-
535
- if ( ! function_exists( 'tinvwl_shortcode_products_counter' ) ) {
536
-
537
- /**
538
- * Shortcode view Wishlist
539
- *
540
- * @param array $atts Array parameter from shortcode.
541
- *
542
- * @return string
543
- */
544
- function tinvwl_shortcode_products_counter( $atts = array() ) {
545
- $class = TInvWL_Public_WishlistCounter::instance();
546
-
547
- return $class->shortcode( $atts );
548
- }
549
-
550
- add_shortcode( 'ti_wishlist_products_counter', 'tinvwl_shortcode_products_counter' );
551
- }
552
-
553
- if ( ! function_exists( 'tinvwl_view_addto_html' ) ) {
554
-
555
- /**
556
- * Show button Add to Wishlsit
557
- */
558
- function tinvwl_view_addto_html() {
559
- $class = TInvWL_Public_AddToWishlist::instance();
560
- $class->htmloutput();
561
- }
562
- }
563
-
564
- if ( ! function_exists( 'tinvwl_view_addto_htmlout' ) ) {
565
-
566
- /**
567
- * Show button Add to Wishlsit, if product is not purchasable
568
- */
569
- function tinvwl_view_addto_htmlout() {
570
- $class = TInvWL_Public_AddToWishlist::instance();
571
- $class->htmloutput_out();
572
- }
573
- }
574
-
575
- if ( ! function_exists( 'tinvwl_view_addto_htmlloop' ) ) {
576
-
577
- /**
578
- * Show button Add to Wishlsit, in loop
579
- */
580
- function tinvwl_view_addto_htmlloop() {
581
- $class = TInvWL_Public_AddToWishlist::instance();
582
- $class->htmloutput_loop();
583
- }
584
- }
585
-
586
- if ( ! function_exists( 'tinvwl_clean_url' ) ) {
587
-
588
- /**
589
- * Clear esc_url to original
590
- *
591
- * @param string $good_protocol_url Cleared URL.
592
- * @param string $original_url Original URL.
593
- *
594
- * @return string
595
- */
596
- function tinvwl_clean_url( $good_protocol_url, $original_url ) {
597
- return $original_url;
598
- }
599
- }
600
-
601
- if ( ! function_exists( 'tinvwl_add_to_cart_need_redirect' ) ) {
602
-
603
- /**
604
- * Check if the product is third-party, or has another link added to the cart then redirect to the product page.
605
- *
606
- * @param boolean $redirect Default value to redirect.
607
- * @param \WC_Product $_product Product data.
608
- * @param string $redirect_url Current url for redirect.
609
- *
610
- * @return boolean
611
- */
612
- function tinvwl_add_to_cart_need_redirect( $redirect, $_product, $redirect_url ) {
613
- if ( $redirect ) {
614
- return true;
615
- }
616
-
617
- if ( 'external' === $_product->get_type() ) {
618
- return true;
619
- }
620
-
621
- $need_url_data = array_merge( array(
622
- 'variation_id' => $_product->is_type( 'variation' ) ? $_product->get_id() : 0,
623
- 'add-to-cart' => $_product->is_type( 'variation' ) ? $_product->get_parent_id() : $_product->get_id(),
624
- ), array_map( 'urlencode', array() ) );
625
-
626
- $need_url_data = array_filter( $need_url_data );
627
-
628
- $need_url = apply_filters( 'tinvwl_product_add_to_cart_redirect_slug_original', remove_query_arg( 'added-to-cart', ( version_compare( WC_VERSION, '3.8.0', '<' ) ? add_query_arg( $need_url_data ) : add_query_arg( $need_url_data, '' ) ) ), $_product );
629
- $need_url_full = apply_filters( 'tinvwl_product_add_to_cart_redirect_url_original', remove_query_arg( 'added-to-cart', add_query_arg( $need_url_data, $_product->get_permalink() ) ), $_product );
630
-
631
- global $product;
632
- // store global product data.
633
- $_product_tmp = $product;
634
- // override global product data.
635
- $product = $_product;
636
-
637
- add_filter( 'clean_url', 'tinvwl_clean_url', 10, 2 );
638
- do_action( 'before_get_redirect_url' );
639
- $_redirect_url = apply_filters( 'tinvwl_product_add_to_cart_redirect_url', $_product->add_to_cart_url(), $_product );
640
- do_action( 'after_get_redirect_url' );
641
- remove_filter( 'clean_url', 'tinvwl_clean_url', 10 );
642
-
643
- // restore global product data.
644
- $product = $_product_tmp;
645
-
646
- if ( $_redirect_url !== $need_url && $_redirect_url !== $need_url_full ) {
647
- return true;
648
- }
649
-
650
- return $redirect;
651
- }
652
-
653
- add_filter( 'tinvwl_product_add_to_cart_need_redirect', 'tinvwl_add_to_cart_need_redirect', 10, 3 );
654
- } // End if().
655
-
656
- if ( ! function_exists( 'tinvwl_meta_validate_cart_add' ) ) {
657
-
658
- /**
659
- * Checks the ability to add a product
660
- *
661
- * @param boolean $redirect Default value to redirect.
662
- * @param \WC_Product $product Product data.
663
- * @param string $redirect_url Current url for redirect.
664
- * @param array $wl_product Wishlist Product.
665
- *
666
- * @return boolean
667
- */
668
- function tinvwl_meta_validate_cart_add( $redirect, $product, $redirect_url, $wl_product ) {
669
- if ( $redirect && array_key_exists( 'meta', $wl_product ) && ! empty( $wl_product['meta'] ) ) {
670
-
671
- $wl_product = apply_filters( 'tinvwl_addproduct_tocart', $wl_product );
672
-
673
- TInvWL_Public_Cart::prepare_post( $wl_product );
674
-
675
- $product_id = apply_filters( 'woocommerce_add_to_cart_product_id', absint( $wl_product['product_id'] ) );
676
- $quantity = empty( $wl_product['quantity'] ) ? 1 : wc_stock_amount( $wl_product['quantity'] );
677
- $variation_id = $wl_product['variation_id'];
678
- $variations = $product->is_type( 'variation' ) ? wc_get_product_variation_attributes( $product->get_id() ) : array();
679
- $passed_validation = $product->is_purchasable() && ( $product->is_in_stock() || $product->backorders_allowed() ) && 'external' !== $product->get_type();
680
- ob_start();
681
- if ( function_exists( 'wc_clear_notices' ) ) {
682
- wc_clear_notices();
683
- }
684
- $passed_validation = apply_filters( 'woocommerce_add_to_cart_validation', $passed_validation, $product_id, $quantity, $variation_id, $variations );
685
- if ( function_exists( 'wc_get_notices' ) ) {
686
- $wc_errors = wc_get_notices('error');
687
- }
688
- $wc_output = ob_get_clean();
689
- if ( $passed_validation && empty( $wc_errors ) && empty( $wc_output ) ) {
690
- $redirect = false;
691
- }
692
-
693
- TInvWL_Public_Cart::unprepare_post();
694
- }
695
-
696
- return $redirect;
697
- }
698
-
699
- add_filter( 'tinvwl_product_add_to_cart_need_redirect', 'tinvwl_meta_validate_cart_add', 90, 4 );
700
- } // End if().
701
-
702
- if ( ! function_exists( 'tinv_wishlist_print_meta' ) ) {
703
-
704
- /**
705
- * Print meta data for wishlist form
706
- *
707
- * @param array $meta Meta Array.
708
- * @param boolean $flat Return text or template.
709
- *
710
- * @return string
711
- */
712
- function tinv_wishlist_print_meta( $meta = array(), $flat = false ) {
713
- if ( ! is_array( $meta ) ) {
714
- $meta = array();
715
- }
716
- $product_id = $variation_id = 0;
717
- if ( array_key_exists( 'product_id', $meta ) ) {
718
- $product_id = $meta['product_id'];
719
- }
720
- if ( array_key_exists( 'variation_id', $meta ) ) {
721
- $variation_id = $meta['variation_id'];
722
- }
723
- foreach ( array( 'add-to-cart', 'product_id', 'variation_id', 'quantity', 'action', 'variation' ) as $field ) {
724
- if ( array_key_exists( $field, $meta ) ) {
725
- unset( $meta[ $field ] );
726
- }
727
- }
728
- $meta = array_filter( $meta );
729
- if ( empty( $meta ) ) {
730
- return '';
731
- }
732
- $item_data = array();
733
- foreach ( $meta as $key => $value ) {
734
- if ( ! preg_match( '/^\_/', $key ) ) {
735
- $item_data[ $key ] = array(
736
- 'key' => $key,
737
- 'display' => $value,
738
- );
739
- }
740
- }
741
-
742
- foreach ( array_keys( $item_data ) as $key ) {
743
- if ( strpos( $key, 'attribute_' ) === 0 ) {
744
- unset( $item_data[ $key ] );
745
- }
746
- }
747
-
748
- $item_data = apply_filters( 'tinvwl_wishlist_item_meta_post', $item_data, $product_id, $variation_id );
749
- foreach ( $item_data as $key => $data ) {
750
- if ( is_object( $data['display'] ) || is_array( $data['display'] ) ) {
751
- $item_data[ $key ]['display'] = json_encode( $data['display'] );
752
- }
753
- }
754
- ob_start();
755
- if ( $flat ) {
756
- foreach ( $item_data as $data ) {
757
- echo esc_html( $data['key'] ) . ': ' . wp_kses_post( $data['display'] ) . '<br>';
758
- }
759
- } else {
760
- if ( $item_data ) {
761
- tinv_wishlist_template( 'ti-wishlist-item-data.php', array( 'item_data' => $item_data ) );
762
- }
763
- }
764
-
765
- return apply_filters( 'tinvwl_wishlist_item_meta_wishlist', ob_get_clean() );
766
- }
767
- } // End if().
768
-
769
- if ( ! function_exists( 'tinv_wishlistmeta' ) ) {
770
-
771
- /**
772
- * Show new meta data
773
- *
774
- * @param string $meta Print meta.
775
- * @param array $wl_product Wishlist product.
776
- * @param \WC_Product $product Woocommerce product.
777
- *
778
- * @return string
779
- */
780
- function tinv_wishlistmeta( $meta, $wl_product, $product ) {
781
- if ( array_key_exists( 'meta', $wl_product ) ) {
782
- $wlmeta = apply_filters( 'tinvwl_wishlist_item_meta_wishlist_output', tinv_wishlist_print_meta( $wl_product['meta'] ), $wl_product, $product );
783
- }
784
- $meta .= $wlmeta;
785
-
786
- return $meta;
787
- }
788
-
789
- add_filter( 'tinvwl_wishlist_item_meta_data', 'tinv_wishlistmeta', 10, 3 );
790
- }
791
-
792
- if ( ! function_exists( 'tinvwl_add_to_cart_item_meta_post' ) ) {
793
-
794
- /**
795
- * Save post data to cart item
796
- *
797
- * @param array $cart_item_data Array with cart imet information.
798
- * @param string $cart_item_key Cart item key.
799
- *
800
- * @return array
801
- */
802
- function tinvwl_add_to_cart_item_meta_post( $cart_item_data, $cart_item_key ) {
803
- $postdata = $_POST; // @codingStandardsIgnoreLine WordPress.VIP.SuperGlobalInputUsage.AccessDetected
804
-
805
- $postdata = apply_filters( 'tinvwl_product_prepare_meta', $postdata );
806
- if ( array_key_exists( 'variation_id', $postdata ) && ! empty( $postdata['variation_id'] ) ) {
807
- foreach ( $postdata as $key => $field ) {
808
- if ( preg_match( '/^attribute\_/', $key ) ) {
809
- unset( $postdata[ $key ] );
810
- }
811
- }
812
- }
813
- foreach ( array( 'add-to-cart', 'product_id', 'variation_id', 'quantity' ) as $field ) {
814
- if ( array_key_exists( $field, $postdata ) ) {
815
- unset( $postdata[ $field ] );
816
- }
817
- }
818
- $postdata = array_filter( $postdata );
819
- if ( empty( $postdata ) ) {
820
- return $cart_item_data;
821
- }
822
- ksort( $postdata );
823
-
824
- $cart_item_data['tinvwl_formdata'] = $postdata;
825
-
826
- return $cart_item_data;
827
- }
828
-
829
- add_action( 'woocommerce_add_cart_item', 'tinvwl_add_to_cart_item_meta_post', 10, 2 );
830
- } // End if().
831
-
832
- if ( ! function_exists( 'tinvwl_set_utm' ) ) {
833
-
834
- /**
835
- * Set UTM sources.
836
- */
837
- function tinvwl_set_utm() {
838
-
839
- // Forcing partners UTM.
840
- if ( class_exists( 'Ocean_Extra' ) && ! defined( 'TINVWL_PARTNER' ) && ! defined( 'TINVWL_CAMPAIGN' ) ) {
841
- define( 'TINVWL_PARTNER', 'oceanwporg' );
842
- define( 'TINVWL_CAMPAIGN', 'oceanwp_theme' );
843
- }
844
-
845
- // Set a source.
846
- $source = get_option( TINVWL_PREFIX . '_utm_source' );
847
- if ( ! $source || $source !== defined( 'TINVWL_PARTNER' ) ) {
848
- $source = defined( 'TINVWL_PARTNER' ) ? TINVWL_PARTNER : 'wordpress_org';
849
- update_option( TINVWL_PREFIX . '_utm_source', $source );
850
- }
851
-
852
- define( 'TINVWL_UTM_SOURCE', $source );
853
-
854
- // Set a medium.
855
- $medium = get_option( TINVWL_PREFIX . '_utm_medium' );
856
- if ( ! $medium || ( 'organic' === $medium && defined( 'TINVWL_PARTNER' ) ) ) {
857
- $medium = defined( 'TINVWL_PARTNER' ) ? 'integration' : 'organic';
858
- update_option( TINVWL_PREFIX . '_utm_medium', $medium );
859
- }
860
-
861
- define( 'TINVWL_UTM_MEDIUM', $medium );
862
-
863
- // Set a campaign.
864
- $campaign = get_option( TINVWL_PREFIX . '_utm_campaign' );
865
- if ( ! $campaign || $campaign !== defined( 'TINVWL_CAMPAIGN' ) ) {
866
- $campaign = defined( 'TINVWL_PARTNER' ) ? ( defined( 'TINVWL_CAMPAIGN' ) ? TINVWL_CAMPAIGN : TINVWL_PARTNER ) : 'organic';
867
- update_option( TINVWL_PREFIX . '_utm_campaign', $campaign );
868
- }
869
-
870
- define( 'TINVWL_UTM_CAMPAIGN', $campaign );
871
- }
872
- } // End if().
873
-
874
- if ( ! function_exists( 'is_wishlist' ) ) {
875
-
876
- /**
877
- * is_wishlist - Returns true when viewing the wishlist page.
878
- *
879
- * @return bool
880
- */
881
- function is_wishlist() {
882
- return ( is_page( apply_filters( 'wpml_object_id', tinv_get_option( 'page', 'wishlist' ), 'page', true ) ) );
883
- }
884
- }
885
-
886
- if ( ! function_exists( 'tinvwl_get_wishlist_products' ) ) {
887
- /**
888
- * Get wishlist products for default user wishlist or by ID or SHAREKEY
889
- *
890
- * @param int $wishlist_id by ID or SHAREKEY, 0 = default wishlist of current user
891
- * @param array $data query parameters for get() method of TInvWL_Product() class.
892
- *
893
- * @return array|bool
894
- */
895
- function tinvwl_get_wishlist_products( $wishlist_id = 0, $data = array() ) {
896
- $wishlist = tinv_wishlist_get( $wishlist_id );
897
- if ( empty( $wishlist ) ) {
898
- return false;
899
- }
900
- $wlp = new TInvWL_Product( $wishlist );
901
- $products = $wlp->get_wishlist( $data );
902
-
903
- if ( empty( $products ) ) {
904
- return false;
905
- }
906
-
907
- return $products;
908
- }
909
- }
910
-
911
- add_action( 'init', function () {
912
- if ( ! is_user_logged_in() ) {
913
- add_filter( 'nonce_user_logged_out', function ( $uid, $action = - 1 ) {
914
- if ( $action === 'wp_rest' ) {
915
- return get_current_user_id();
916
- }
917
-
918
- return $uid;
919
- }, 99, 2 );
920
- }
921
- } );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Basic function for plugin
4
+ *
5
+ * @since 1.0.0
6
+ * @package TInvWishlist
7
+ */
8
+
9
+ // If this file is called directly, abort.
10
+ if (!defined('ABSPATH')) {
11
+ die;
12
+ }
13
+
14
+
15
+ if (!function_exists('tinv_get_option')) {
16
+
17
+ /**
18
+ * Extract options from database or default array settings.
19
+ *
20
+ * @param string $category Name category settings.
21
+ * @param string $option Name paremetr. If is empty string, then function return array category settings.
22
+ *
23
+ * @return mixed
24
+ */
25
+ function tinv_get_option($category, $option = '')
26
+ {
27
+ $prefix = TINVWL_PREFIX . '-';
28
+ $values = get_option($prefix . $category, array());
29
+ if (empty($values)) {
30
+ $values = tinv_get_option_defaults($category);
31
+ }
32
+ if (empty($option)) {
33
+ return $values;
34
+ } else {
35
+ if (array_key_exists($option, (array)$values)) {
36
+ return $values[$option];
37
+ } else {
38
+ $values = tinv_get_option_defaults($category);
39
+ if (array_key_exists($option, (array)$values)) {
40
+ return $values[$option];
41
+ }
42
+ }
43
+ }
44
+
45
+ return null;
46
+ }
47
+ }
48
+
49
+ if (!function_exists('tinv_get_option_admin')) {
50
+
51
+ /**
52
+ * Extract options from database or default array settings.
53
+ *
54
+ * @param string $category Name category settings.
55
+ * @param string $option Name paremetr. If is empty string, then function return array category settings.
56
+ *
57
+ * @return mixed
58
+ */
59
+ function tinv_get_option_admin($category, $option = '')
60
+ {
61
+ $prefix = TINVWL_PREFIX . '-';
62
+ $values = get_option($prefix . $category, array());
63
+ if (empty($values)) {
64
+ $values = array();
65
+ }
66
+ if (empty($option)) {
67
+ return $values;
68
+ } elseif (array_key_exists($option, $values)) {
69
+ return $values[$option];
70
+ }
71
+
72
+ return null;
73
+ }
74
+ }
75
+
76
+ if (!function_exists('tinv_style')) {
77
+
78
+ /**
79
+ * Get style for custom style
80
+ *
81
+ * @param string $selector Selector style.
82
+ * @param string $element Attribute name.
83
+ *
84
+ * @return string
85
+ */
86
+ function tinv_style($selector = '', $element = '')
87
+ {
88
+ $key = md5($selector . '||' . $element);
89
+ $values = get_option(TINVWL_PREFIX . '-style_options', array());
90
+ if (empty($values)) {
91
+ return '';
92
+ }
93
+ if (array_key_exists($key, $values)) {
94
+ return $values[$key];
95
+ }
96
+
97
+ return '';
98
+ }
99
+ }
100
+
101
+ if (!function_exists('tinv_update_option')) {
102
+
103
+ /**
104
+ * Update options in database.
105
+ *
106
+ * @param string $category Name category settings.
107
+ * @param string $option Name paremetr. If is empty string, then function update array category settings.
108
+ * @param mixed $value Value option.
109
+ *
110
+ * @return boolean
111
+ */
112
+ function tinv_update_option($category, $option = '', $value = false)
113
+ {
114
+ $prefix = TINVWL_PREFIX . '-';
115
+ if (empty($option)) {
116
+ if (is_array($value)) {
117
+ update_option($prefix . $category, $value);
118
+
119
+ return true;
120
+ }
121
+ } else {
122
+ $values = get_option($prefix . $category, array());
123
+
124
+ $values[$option] = $value;
125
+ update_option($prefix . $category, $values);
126
+
127
+ return true;
128
+ }
129
+
130
+ return false;
131
+ }
132
+ }
133
+
134
+ /**
135
+ * Rename class
136
+ */
137
+ class TInvWLRename
138
+ {
139
+
140
+ /**
141
+ * Rename "wishlist" word across the plugin.
142
+ */
143
+ function rename()
144
+ {
145
+ $this->rename = tinv_get_option('rename', 'rename');
146
+ $this->rename_single = tinv_get_option('rename', 'rename_single');
147
+ $this->rename_plural = tinv_get_option('rename', 'rename_plural');
148
+
149
+ if ($this->rename && $this->rename_single) {
150
+ add_filter('gettext', array($this, 'translations'), 999, 3);
151
+ add_filter('ngettext', array($this, 'translations_n'), 999, 5);
152
+ }
153
+ }
154
+
155
+
156
+ function translations_n($translation, $single, $plural, $number, $domain)
157
+ {
158
+ return $this->translation_update($translation, $domain);
159
+ }
160
+
161
+ function translations($translation, $text, $domain)
162
+ {
163
+ return $this->translation_update($translation, $domain);
164
+ }
165
+
166
+ private function translation_update($text, $domain)
167
+ {
168
+ if ('ti-woocommerce-wishlist' === $domain) {
169
+
170
+ $translations = ['wishlist' => [$this->rename_single, $this->rename_plural ? $this->rename_plural : $this->rename_single . 's']];
171
+
172
+ $text = preg_replace_callback('~\b[a-z]+(?:(?<=(s)))?~i', function ($m) use ($translations) {
173
+ $lower = strtolower($m[0]);
174
+ $rep = $m[0];
175
+ if (isset($translations[$lower])) {
176
+ $rep = is_array($translations[$lower]) ? $translations[$lower][0] : $translations[$lower];
177
+ } elseif (isset($m[1])) {
178
+ $sing = substr($lower, 0, -1);
179
+ if (isset($translations[$sing]))
180
+ $rep = is_array($translations[$sing]) ? $translations[$sing][1] : $translations[$sing] . 's';
181
+ } else {
182
+ return $rep;
183
+ }
184
+
185
+ if ($m[0] == $lower)
186
+ return $rep;
187
+ elseif ($m[0] == strtoupper($lower))
188
+ return strtoupper($rep);
189
+ elseif ($m[0] == ucfirst($lower))
190
+ return ucfirst($rep);
191
+
192
+ return $rep;
193
+ }, $text);
194
+
195
+ }
196
+ return $text;
197
+ }
198
+ }
199
+
200
+ $tinvwl_rename = new TInvWLRename();
201
+ $tinvwl_rename->rename();
202
+
203
+ if (!function_exists('tinv_wishlist_template')) {
204
+
205
+ /**
206
+ * The function overwrites the method output templates woocommerce
207
+ *
208
+ * @param string $template_name Name file template.
209
+ * @param array $args Array variable in template.
210
+ * @param string $template_path Customization path.
211
+ */
212
+ function tinv_wishlist_template($template_name, $args = array(), $template_path = '')
213
+ {
214
+ if (function_exists('wc_get_template')) {
215
+ wc_get_template($template_name, $args, $template_path);
216
+ } else {
217
+ woocommerce_get_template($template_name, $args, $template_path);
218
+ }
219
+ }
220
+ }
221
+
222
+ if (!function_exists('tinv_wishlist_locate_template')) {
223
+
224
+ /**
225
+ * Overwrites path for email and other template
226
+ *
227
+ * @param string $template_name Requered Template file.
228
+ * @param string $template_path Template path.
229
+ * @param string $default_path Template default path.
230
+ *
231
+ * @return mixed
232
+ */
233
+ function tinv_wishlist_locate_template($template_name, $template_path = '', $default_path = '')
234
+ {
235
+ $prefix = 'ti-';
236
+
237
+ if (substr(basename($template_name), 0, strlen($prefix)) !== $prefix) {
238
+ return;
239
+ }
240
+
241
+ if (!$template_path) {
242
+ $template_path = WC()->template_path();
243
+ }
244
+
245
+ if (!$default_path) {
246
+ $default_path = TINVWL_PATH . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR;
247
+ }
248
+
249
+ // Look within passed path within the theme - this is priority.
250
+ $template = locate_template(array(
251
+ trailingslashit($template_path) . $template_name,
252
+ $template_name,
253
+ ));
254
+
255
+ // Get default template.
256
+ if (!$template && file_exists($default_path . $template_name)) {
257
+ $template = $default_path . $template_name;
258
+ }
259
+
260
+ // Return what we found.
261
+ return apply_filters('tinvwl_locate_template', $template, $template_name, $template_path);
262
+ }
263
+ } // End if().
264
+
265
+ if (!function_exists('tinv_wishlist_template_html')) {
266
+
267
+ /**
268
+ * The function overwrites the method return templates woocommerce
269
+ *
270
+ * @param string $template_name Name file template.
271
+ * @param array $args Array variable in template.
272
+ * @param string $template_path Customization path.
273
+ *
274
+ * @return string
275
+ */
276
+ function tinv_wishlist_template_html($template_name, $args = array(), $template_path = '')
277
+ {
278
+ ob_start();
279
+ tinv_wishlist_template($template_name, $args, $template_path);
280
+
281
+ return ob_get_clean();
282
+ }
283
+ }
284
+
285
+ if (!function_exists('tinv_wishlist_get_item_data')) {
286
+
287
+ /**
288
+ * Extract meta attributes for product
289
+ *
290
+ * @param object $product Object selected product.
291
+ * @param array $wl_product Wishlist selected product.
292
+ * @param boolean $flat Return text or template.
293
+ *
294
+ * @return string
295
+ */
296
+ function tinv_wishlist_get_item_data($product, $wl_product = array(), $flat = false)
297
+ {
298
+ $item_data = array();
299
+ $variation_id = $product->is_type('variation') ? $product->get_id() : 0;
300
+ $variation_data = $product->is_type('variation') ? wc_get_product_variation_attributes($product->get_id()) : array();
301
+ if (!empty($variation_id) && is_array($variation_data) && is_array($wl_product)) {
302
+ foreach ($variation_data as $name => $value) {
303
+ if ('' === $value) {
304
+ // Could be any value that saved to a custom meta.
305
+ if (array_key_exists('meta', $wl_product) && array_key_exists($name, $wl_product['meta'])) {
306
+ $value = $wl_product['meta'][$name];
307
+ } else {
308
+ continue;
309
+ }
310
+ }
311
+
312
+ $taxonomy = wc_attribute_taxonomy_name(str_replace('attribute_pa_', '', urldecode($name)));
313
+
314
+ // If this is a term slug, get the term's nice name.
315
+ if (taxonomy_exists($taxonomy)) {
316
+ $term = get_term_by('slug', $value, $taxonomy); // @codingStandardsIgnoreLine WordPress.VIP.RestrictedFunctions.get_term_by
317
+ if (!is_wp_error($term) && $term && $term->name) {
318
+ $value = $term->name;
319
+ }
320
+ $label = wc_attribute_label($taxonomy);
321
+
322
+ // If this is a custom option slug, get the options name.
323
+ } else {
324
+ $value = apply_filters('woocommerce_variation_option_name', $value);
325
+ $product_attributes = $product->get_attributes();
326
+ $_name = str_replace('attribute_', '', $name);
327
+ if (isset($product_attributes[$_name])) {
328
+ $label = wc_attribute_label($_name, $product);
329
+ } else {
330
+ $label = $name;
331
+ }
332
+ }
333
+ if ('' === $value || wc_is_attribute_in_product_name($value, is_callable(array(
334
+ $product,
335
+ 'get_name'
336
+ )) ? $product->get_name() : $product->get_title())) {
337
+ continue;
338
+ }
339
+ $item_data[] = array(
340
+ 'key' => $label,
341
+ 'value' => $value,
342
+ );
343
+ } // End foreach().
344
+ } // End if().
345
+
346
+ // Filter item data to allow 3rd parties to add more to the array.
347
+ $item_data = apply_filters('tinvwl_wishlist_get_item_data', $item_data, $product);
348
+
349
+ // Format item data ready to display.
350
+ foreach ($item_data as $key => $data) {
351
+ // Set hidden to true to not display meta on cart.
352
+ if (!empty($data['hidden'])) {
353
+ unset($item_data[$key]);
354
+ continue;
355
+ }
356
+ $item_data[$key]['key'] = !empty($data['key']) ? $data['key'] : $data['name'];
357
+ $item_data[$key]['display'] = !empty($data['display']) ? $data['display'] : $data['value'];
358
+ }
359
+
360
+ // Output flat or in list format.
361
+ if (0 < count($item_data)) {
362
+ ob_start();
363
+ if ($flat) {
364
+ foreach ($item_data as $data) {
365
+ echo esc_html($data['key']) . ': ' . wp_kses_post($data['display']) . '<br>';
366
+ }
367
+ } else {
368
+ tinv_wishlist_template('ti-wishlist-item-data.php', array('item_data' => $item_data));
369
+ }
370
+
371
+ return ob_get_clean();
372
+ }
373
+
374
+ return '';
375
+ }
376
+ } // End if().
377
+
378
+ if (!function_exists('tinv_wishlist_get')) {
379
+
380
+ /**
381
+ * Return Wishlist by id or share key
382
+ *
383
+ * @param mixed $id Integer wishlist ID, or Share Key wishlist.
384
+ * @param boolean $toend Switches to the extract the default or guest wishlist.
385
+ *
386
+ * @return array
387
+ */
388
+ function tinv_wishlist_get($id = '', $toend = true)
389
+ {
390
+ $wl = new TInvWL_Wishlist();
391
+ $wishlist = null;
392
+ if (empty($id)) {
393
+ $id = get_query_var('tinvwlID', null);
394
+ }
395
+
396
+ if (!empty($id)) {
397
+ if (is_integer($id)) {
398
+ $wishlist = $wl->get_by_id($id);
399
+ }
400
+ if (empty($wishlist)) {
401
+ $wishlist = $wl->get_by_share_key($id);
402
+ }
403
+
404
+ if (is_array($wishlist)) {
405
+ $wishlist['is_owner'] = false;
406
+ if (is_user_logged_in()) {
407
+ $wishlist['is_owner'] = get_current_user_id() == $wishlist['author']; // WPCS: loose comparison ok.
408
+ } else {
409
+ $wishlist['is_owner'] = $wl->get_sharekey() === $wishlist['share_key']; // WPCS: loose comparison ok.
410
+ }
411
+ }
412
+ } elseif (is_user_logged_in() && $toend) {
413
+ $wishlist = $wl->add_user_default();
414
+
415
+ $wishlist['is_owner'] = true;
416
+ } elseif ($toend) {
417
+ $wishlist = $wl->get_by_sharekey_default();
418
+ if (!empty($wishlist)) {
419
+ $wishlist = array_shift($wishlist);
420
+ $wishlist['is_owner'] = $wl->get_sharekey() === $wishlist['share_key'];
421
+ }
422
+ }
423
+
424
+ return $wishlist;
425
+ }
426
+ } // End if().
427
+
428
+ if (!function_exists('tinv_url_wishlist_default')) {
429
+
430
+ /**
431
+ * Return the default wishlist url
432
+ *
433
+ * @return string
434
+ */
435
+ function tinv_url_wishlist_default()
436
+ {
437
+ $page = apply_filters('wpml_object_id', tinv_get_option('page', 'wishlist'), 'page', true); // @codingStandardsIgnoreLine WordPress.Variables.GlobalVariables.OverrideProhibited
438
+ if (empty($page)) {
439
+ return '';
440
+ }
441
+ $link = get_permalink($page);
442
+
443
+ return $link;
444
+ }
445
+ }
446
+
447
+ if (!function_exists('tinv_url_wishlist_by_key')) {
448
+
449
+ /**
450
+ * Return the wishlist url by share key
451
+ *
452
+ * @param string $share_key Share Key wishlist.
453
+ * @param integer $paged Page.
454
+ *
455
+ * @return string
456
+ */
457
+ function tinv_url_wishlist_by_key($share_key, $paged = 1)
458
+ {
459
+ $paged = absint($paged);
460
+ $paged = 1 < $paged ? $paged : 1;
461
+ $link = tinv_url_wishlist_default();
462
+ if (empty($link)) {
463
+ return $link;
464
+ }
465
+
466
+ if (1 < $paged) {
467
+ $link = add_query_arg('wl_paged', $paged, $link);
468
+ }
469
+
470
+ if ($share_key) {
471
+ if (get_option('permalink_structure')) {
472
+ $suffix = '';
473
+ if (preg_match('/([^\?]+)\?*?(.*)/i', $link, $_link)) {
474
+ $link = $_link[1];
475
+ $suffix = $_link[2];
476
+ }
477
+ if (!preg_match('/\/$/', $link)) {
478
+ $link .= '/';
479
+ }
480
+ $link .= $share_key . '/' . $suffix;
481
+ } else {
482
+ $link = add_query_arg('tinvwlID', $share_key, $link);
483
+ }
484
+ }
485
+
486
+ return $link;
487
+ }
488
+ } // End if().
489
+
490
+ if (!function_exists('tinv_url_wishlist')) {
491
+
492
+ /**
493
+ * Return the wishlist url by id or share key
494
+ *
495
+ * @param mixed $id Integer wishlist ID, or Share Key wishlist.
496
+ * @param integer $paged Page.
497
+ * @param boolean $full Return full url or shroted url for logged in user.
498
+ *
499
+ * @return string
500
+ */
501
+ function tinv_url_wishlist($id = '', $paged = 1, $full = true)
502
+ {
503
+ $share_key = $id;
504
+ if (!(is_string($id) && preg_match('/^[A-Fa-f0-9]{6}$/', $id))) {
505
+ $wishlist = tinv_wishlist_get($id, false);
506
+ $share_key = $wishlist['share_key'];
507
+ }
508
+
509
+ return tinv_url_wishlist_by_key($share_key, $paged);
510
+ }
511
+ }
512
+
513
+ if (!function_exists('tinv_wishlist_status')) {
514
+
515
+ /**
516
+ * Check status free or premium plugin and disable free
517
+ *
518
+ * @param string $transient Plugin transient name.
519
+ *
520
+ * @return string
521
+ * @global string $s
522
+ *
523
+ * @global string $status
524
+ * @global string $page
525
+ */
526
+ function tinv_wishlist_status($transient)
527
+ {
528
+ if (TINVWL_LOAD_FREE === $transient) {
529
+ TInvWL_PluginExtend::deactivate_self(TINVWL_LOAD_FREE);
530
+
531
+ return 'plugins.php';
532
+ }
533
+ if (TINVWL_LOAD_PREMIUM === $transient) {
534
+ if (is_plugin_active(TINVWL_LOAD_FREE)) {
535
+ TInvWL_PluginExtend::deactivate_self(TINVWL_LOAD_FREE);
536
+ if (!function_exists('wp_create_nonce')) {
537
+ return 'plugins.php';
538
+ }
539
+
540
+ global $status, $page, $s;
541
+ $redirect = 'plugins.php?';
542
+ $redirect .= http_build_query(array(
543
+ 'action' => 'activate',
544
+ 'plugin' => $transient,
545
+ 'plugin_status' => $status,
546
+ 'paged' => $page,
547
+ 's' => $s,
548
+ ));
549
+ $redirect = esc_url_raw(add_query_arg('_wpnonce', wp_create_nonce('activate-plugin_' . $transient), $redirect));
550
+
551
+ return $redirect;
552
+ }
553
+ }
554
+
555
+ return false;
556
+ }
557
+ } // End if().
558
+
559
+ if (!function_exists('tinvwl_body_classes')) {
560
+
561
+ /**
562
+ * Add custom class
563
+ *
564
+ * @param array $classes Current classes.
565
+ *
566
+ * @return array
567
+ */
568
+ function tinvwl_body_classes($classes)
569
+ {
570
+ if (tinv_get_option('style', 'customstyle')) {
571
+ $classes[] = 'tinvwl-theme-style';
572
+ } else {
573
+ $classes[] = 'tinvwl-custom-style';
574
+ }
575
+
576
+ return $classes;
577
+ }
578
+
579
+ add_filter('body_class', 'tinvwl_body_classes');
580
+ }
581
+
582
+ if (!function_exists('tinvwl_shortcode_addtowishlist')) {
583
+
584
+ /**
585
+ * Shortcode Add To Wishlist
586
+ *
587
+ * @param array $atts Array parameter from shortcode.
588
+ *
589
+ * @return string
590
+ */
591
+ function tinvwl_shortcode_addtowishlist($atts = array())
592
+ {
593
+ $class = TInvWL_Public_AddToWishlist::instance();
594
+
595
+ return $class->shortcode($atts);
596
+ }
597
+
598
+ add_shortcode('ti_wishlists_addtowishlist', 'tinvwl_shortcode_addtowishlist');
599
+ }
600
+
601
+ if (!function_exists('tinvwl_shortcode_view')) {
602
+
603
+ /**
604
+ * Shortcode view Wishlist
605
+ *
606
+ * @param array $atts Array parameter from shortcode.
607
+ *
608
+ * @return string
609
+ */
610
+ function tinvwl_shortcode_view($atts = array())
611
+ {
612
+ $class = TInvWL_Public_Wishlist_View::instance();
613
+
614
+ return $class->shortcode($atts);
615
+ }
616
+
617
+ add_shortcode('ti_wishlistsview', 'tinvwl_shortcode_view');
618
+ }
619
+
620
+ if (!function_exists('tinvwl_shortcode_products_counter')) {
621
+
622
+ /**
623
+ * Shortcode view Wishlist
624
+ *
625
+ * @param array $atts Array parameter from shortcode.
626
+ *
627
+ * @return string
628
+ */
629
+ function tinvwl_shortcode_products_counter($atts = array())
630
+ {
631
+ $class = TInvWL_Public_WishlistCounter::instance();
632
+
633
+ return $class->shortcode($atts);
634
+ }
635
+
636
+ add_shortcode('ti_wishlist_products_counter', 'tinvwl_shortcode_products_counter');
637
+ }
638
+
639
+ if (!function_exists('tinvwl_view_addto_html')) {
640
+
641
+ /**
642
+ * Show button Add to Wishlsit
643
+ */
644
+ function tinvwl_view_addto_html()
645
+ {
646
+ $class = TInvWL_Public_AddToWishlist::instance();
647
+ $class->htmloutput();
648
+ }
649
+ }
650
+
651
+ if (!function_exists('tinvwl_view_addto_htmlout')) {
652
+
653
+ /**
654
+ * Show button Add to Wishlsit, if product is not purchasable
655
+ */
656
+ function tinvwl_view_addto_htmlout()
657
+ {
658
+ $class = TInvWL_Public_AddToWishlist::instance();
659
+ $class->htmloutput_out();
660
+ }
661
+ }
662
+
663
+ if (!function_exists('tinvwl_view_addto_htmlloop')) {
664
+
665
+ /**
666
+ * Show button Add to Wishlsit, in loop
667
+ */
668
+ function tinvwl_view_addto_htmlloop()
669
+ {
670
+ $class = TInvWL_Public_AddToWishlist::instance();
671
+ $class->htmloutput_loop();
672
+ }
673
+ }
674
+
675
+ if (!function_exists('tinvwl_clean_url')) {
676
+
677
+ /**
678
+ * Clear esc_url to original
679
+ *
680
+ * @param string $good_protocol_url Cleared URL.
681
+ * @param string $original_url Original URL.
682
+ *
683
+ * @return string
684
+ */
685
+ function tinvwl_clean_url($good_protocol_url, $original_url)
686
+ {
687
+ return $original_url;
688
+ }
689
+ }
690
+
691
+ if (!function_exists('tinvwl_add_to_cart_need_redirect')) {
692
+
693
+ /**
694
+ * Check if the product is third-party, or has another link added to the cart then redirect to the product page.
695
+ *
696
+ * @param boolean $redirect Default value to redirect.
697
+ * @param \WC_Product $_product Product data.
698
+ * @param string $redirect_url Current url for redirect.
699
+ *
700
+ * @return boolean
701
+ */
702
+ function tinvwl_add_to_cart_need_redirect($redirect, $_product, $redirect_url)
703
+ {
704
+ if ($redirect) {
705
+ return true;
706
+ }
707
+
708
+ if ('external' === $_product->get_type()) {
709
+ return true;
710
+ }
711
+
712
+ $need_url_data = array_merge(array(
713
+ 'variation_id' => $_product->is_type('variation') ? $_product->get_id() : 0,
714
+ 'add-to-cart' => $_product->is_type('variation') ? $_product->get_parent_id() : $_product->get_id(),
715
+ ), array_map('urlencode', array()));
716
+
717
+ $need_url_data = array_filter($need_url_data);
718
+
719
+ $need_url = apply_filters('tinvwl_product_add_to_cart_redirect_slug_original', remove_query_arg('added-to-cart', (version_compare(WC_VERSION, '3.8.0', '<') ? add_query_arg($need_url_data) : add_query_arg($need_url_data, ''))), $_product);
720
+ $need_url_full = apply_filters('tinvwl_product_add_to_cart_redirect_url_original', remove_query_arg('added-to-cart', add_query_arg($need_url_data, $_product->get_permalink())), $_product);
721
+
722
+ global $product;
723
+ // store global product data.
724
+ $_product_tmp = $product;
725
+ // override global product data.
726
+ $product = $_product;
727
+
728
+ add_filter('clean_url', 'tinvwl_clean_url', 10, 2);
729
+ do_action('before_get_redirect_url');
730
+ $_redirect_url = apply_filters('tinvwl_product_add_to_cart_redirect_url', $_product->add_to_cart_url(), $_product);
731
+ do_action('after_get_redirect_url');
732
+ remove_filter('clean_url', 'tinvwl_clean_url', 10);
733
+
734
+ // restore global product data.
735
+ $product = $_product_tmp;
736
+
737
+ if ($_redirect_url !== $need_url && $_redirect_url !== $need_url_full) {
738
+ return true;
739
+ }
740
+
741
+ return $redirect;
742
+ }
743
+
744
+ add_filter('tinvwl_product_add_to_cart_need_redirect', 'tinvwl_add_to_cart_need_redirect', 10, 3);
745
+ } // End if().
746
+
747
+ if (!function_exists('tinvwl_meta_validate_cart_add')) {
748
+
749
+ /**
750
+ * Checks the ability to add a product
751
+ *
752
+ * @param boolean $redirect Default value to redirect.
753
+ * @param \WC_Product $product Product data.
754
+ * @param string $redirect_url Current url for redirect.
755
+ * @param array $wl_product Wishlist Product.
756
+ *
757
+ * @return boolean
758
+ */
759
+ function tinvwl_meta_validate_cart_add($redirect, $product, $redirect_url, $wl_product)
760
+ {
761
+ if ($redirect && array_key_exists('meta', $wl_product) && !empty($wl_product['meta'])) {
762
+
763
+ $wl_product = apply_filters('tinvwl_addproduct_tocart', $wl_product);
764
+
765
+ TInvWL_Public_Cart::prepare_post($wl_product);
766
+
767
+ $product_id = apply_filters('woocommerce_add_to_cart_product_id', absint($wl_product['product_id']));
768
+ $quantity = empty($wl_product['quantity']) ? 1 : wc_stock_amount($wl_product['quantity']);
769
+ $variation_id = $wl_product['variation_id'];
770
+ $variations = $product->is_type('variation') ? wc_get_product_variation_attributes($product->get_id()) : array();
771
+ $passed_validation = $product->is_purchasable() && ($product->is_in_stock() || $product->backorders_allowed()) && 'external' !== $product->get_type();
772
+ ob_start();
773
+ if (function_exists('wc_clear_notices')) {
774
+ wc_clear_notices();
775
+ }
776
+ $passed_validation = apply_filters('woocommerce_add_to_cart_validation', $passed_validation, $product_id, $quantity, $variation_id, $variations);
777
+ if (function_exists('wc_get_notices')) {
778
+ $wc_errors = wc_get_notices('error');
779
+ }
780
+ $wc_output = ob_get_clean();
781
+ if ($passed_validation && empty($wc_errors) && empty($wc_output)) {
782
+ $redirect = false;
783
+ }
784
+
785
+ TInvWL_Public_Cart::unprepare_post();
786
+ }
787
+
788
+ return $redirect;
789
+ }
790
+
791
+ add_filter('tinvwl_product_add_to_cart_need_redirect', 'tinvwl_meta_validate_cart_add', 90, 4);
792
+ } // End if().
793
+
794
+ if (!function_exists('tinv_wishlist_print_meta')) {
795
+
796
+ /**
797
+ * Print meta data for wishlist form
798
+ *
799
+ * @param array $meta Meta Array.
800
+ * @param boolean $flat Return text or template.
801
+ *
802
+ * @return string
803
+ */
804
+ function tinv_wishlist_print_meta($meta = array(), $flat = false)
805
+ {
806
+ if (!is_array($meta)) {
807
+ $meta = array();
808
+ }
809
+ $product_id = $variation_id = 0;
810
+ if (array_key_exists('product_id', $meta)) {
811
+ $product_id = $meta['product_id'];
812
+ }
813
+ if (array_key_exists('variation_id', $meta)) {
814
+ $variation_id = $meta['variation_id'];
815
+ }
816
+ foreach (array('add-to-cart', 'product_id', 'variation_id', 'quantity', 'action', 'variation') as $field) {
817
+ if (array_key_exists($field, $meta)) {
818
+ unset($meta[$field]);
819
+ }
820
+ }
821
+ $meta = array_filter($meta);
822
+ if (empty($meta)) {
823
+ return '';
824
+ }
825
+ $item_data = array();
826
+ foreach ($meta as $key => $value) {
827
+ if (!preg_match('/^\_/', $key)) {
828
+ $item_data[$key] = array(
829
+ 'key' => $key,
830
+ 'display' => $value,
831
+ );
832
+ }
833
+ }
834
+
835
+ foreach (array_keys($item_data) as $key) {
836
+ if (strpos($key, 'attribute_') === 0) {
837
+ unset($item_data[$key]);
838
+ }
839
+ }
840
+
841
+ $item_data = apply_filters('tinvwl_wishlist_item_meta_post', $item_data, $product_id, $variation_id);
842
+ foreach ($item_data as $key => $data) {
843
+ if (is_object($data['display']) || is_array($data['display'])) {
844
+ $item_data[$key]['display'] = json_encode($data['display']);
845
+ }
846
+ }
847
+ ob_start();
848
+ if ($flat) {
849
+ foreach ($item_data as $data) {
850
+ echo esc_html($data['key']) . ': ' . wp_kses_post($data['display']) . '<br>';
851
+ }
852
+ } else {
853
+ if ($item_data) {
854
+ tinv_wishlist_template('ti-wishlist-item-data.php', array('item_data' => $item_data));
855
+ }
856
+ }
857
+
858
+ return apply_filters('tinvwl_wishlist_item_meta_wishlist', ob_get_clean());
859
+ }
860
+ } // End if().
861
+
862
+ if (!function_exists('tinv_wishlistmeta')) {
863
+
864
+ /**
865
+ * Show new meta data
866
+ *
867
+ * @param string $meta Print meta.
868
+ * @param array $wl_product Wishlist product.
869
+ * @param \WC_Product $product Woocommerce product.
870
+ *
871
+ * @return string
872
+ */
873
+ function tinv_wishlistmeta($meta, $wl_product, $product)
874
+ {
875
+ if (array_key_exists('meta', $wl_product)) {
876
+ $wlmeta = apply_filters('tinvwl_wishlist_item_meta_wishlist_output', tinv_wishlist_print_meta($wl_product['meta']), $wl_product, $product);
877
+ }
878
+ $meta .= $wlmeta;
879
+
880
+ return $meta;
881
+ }
882
+
883
+ add_filter('tinvwl_wishlist_item_meta_data', 'tinv_wishlistmeta', 10, 3);
884
+ }
885
+
886
+ if (!function_exists('tinvwl_add_to_cart_item_meta_post')) {
887
+
888
+ /**
889
+ * Save post data to cart item
890
+ *
891
+ * @param array $cart_item_data Array with cart imet information.
892
+ * @param string $cart_item_key Cart item key.
893
+ *
894
+ * @return array
895
+ */
896
+ function tinvwl_add_to_cart_item_meta_post($cart_item_data, $cart_item_key)
897
+ {
898
+ $postdata = $_POST; // @codingStandardsIgnoreLine WordPress.VIP.SuperGlobalInputUsage.AccessDetected
899
+
900
+ $postdata = apply_filters('tinvwl_product_prepare_meta', $postdata);
901
+
902
+ if (array_key_exists('variation_id', $postdata) && !empty($postdata['variation_id'])) {
903
+ foreach ($postdata as $key => $field) {
904
+ if (preg_match('/^attribute\_/', $key)) {
905
+ unset($postdata[$key]);
906
+ }
907
+ }
908
+ }
909
+ foreach (array('add-to-cart', 'product_id', 'variation_id', 'quantity') as $field) {
910
+ if (array_key_exists($field, $postdata)) {
911
+ unset($postdata[$field]);
912
+ }
913
+ }
914
+ $postdata = array_filter($postdata);
915
+ if (empty($postdata)) {
916
+ return $cart_item_data;
917
+ }
918
+ ksort($postdata);
919
+
920
+ $cart_item_data['tinvwl_formdata'] = $postdata;
921
+
922
+ return $cart_item_data;
923
+ }
924
+
925
+ add_action('woocommerce_add_cart_item', 'tinvwl_add_to_cart_item_meta_post', 10, 2);
926
+ } // End if().
927
+
928
+ if (!function_exists('tinvwl_set_utm')) {
929
+
930
+ /**
931
+ * Set UTM sources.
932
+ */
933
+ function tinvwl_set_utm()
934
+ {
935
+
936
+ // Forcing partners UTM.
937
+ if (class_exists('Ocean_Extra') && !defined('TINVWL_PARTNER') && !defined('TINVWL_CAMPAIGN')) {
938
+ define('TINVWL_PARTNER', 'oceanwporg');
939
+ define('TINVWL_CAMPAIGN', 'oceanwp_theme');
940
+ }
941
+
942
+ // Set a source.
943
+ $source = get_option(TINVWL_PREFIX . '_utm_source');
944
+ if (!$source || $source !== defined('TINVWL_PARTNER')) {
945
+ $source = defined('TINVWL_PARTNER') ? TINVWL_PARTNER : 'wordpress_org';
946
+ update_option(TINVWL_PREFIX . '_utm_source', $source);
947
+ }
948
+
949
+ define('TINVWL_UTM_SOURCE', $source);
950
+
951
+ // Set a medium.
952
+ $medium = get_option(TINVWL_PREFIX . '_utm_medium');
953
+ if (!$medium || ('organic' === $medium && defined('TINVWL_PARTNER'))) {
954
+ $medium = defined('TINVWL_PARTNER') ? 'integration' : 'organic';
955
+ update_option(TINVWL_PREFIX . '_utm_medium', $medium);
956
+ }
957
+
958
+ define('TINVWL_UTM_MEDIUM', $medium);
959
+
960
+ // Set a campaign.
961
+ $campaign = get_option(TINVWL_PREFIX . '_utm_campaign');
962
+ if (!$campaign || $campaign !== defined('TINVWL_CAMPAIGN')) {
963
+ $campaign = defined('TINVWL_PARTNER') ? (defined('TINVWL_CAMPAIGN') ? TINVWL_CAMPAIGN : TINVWL_PARTNER) : 'organic';
964
+ update_option(TINVWL_PREFIX . '_utm_campaign', $campaign);
965
+ }
966
+
967
+ define('TINVWL_UTM_CAMPAIGN', $campaign);
968
+ }
969
+ } // End if().
970
+
971
+ if (!function_exists('is_wishlist')) {
972
+
973
+ /**
974
+ * is_wishlist - Returns true when viewing the wishlist page.
975
+ *
976
+ * @return bool
977
+ */
978
+ function is_wishlist()
979
+ {
980
+ return (is_page(apply_filters('wpml_object_id', tinv_get_option('page', 'wishlist'), 'page', true)));
981
+ }
982
+ }
983
+
984
+ if (!function_exists('tinvwl_get_wishlist_products')) {
985
+ /**
986
+ * Get wishlist products for default user wishlist or by ID or SHAREKEY
987
+ *
988
+ * @param int $wishlist_id by ID or SHAREKEY, 0 = default wishlist of current user
989
+ * @param array $data query parameters for get() method of TInvWL_Product() class.
990
+ *
991
+ * @return array|bool
992
+ */
993
+ function tinvwl_get_wishlist_products($wishlist_id = 0, $data = array())
994
+ {
995
+ $wishlist = tinv_wishlist_get($wishlist_id);
996
+ if (empty($wishlist)) {
997
+ return false;
998
+ }
999
+ $wlp = new TInvWL_Product($wishlist);
1000
+ $products = $wlp->get_wishlist($data);
1001
+
1002
+ if (empty($products)) {
1003
+ return false;
1004
+ }
1005
+
1006
+ return $products;
1007
+ }
1008
+ }
1009
+
1010
+ add_action('init', function () {
1011
+ if (!is_user_logged_in()) {
1012
+ add_filter('nonce_user_logged_out', function ($uid, $action = -1) {
1013
+ if ($action === 'wp_rest') {
1014
+ return get_current_user_id();
1015
+ }
1016
+
1017
+ return $uid;
1018
+ }, 99, 2);
1019
+ }
1020
+ });