WooCommerce Wishlist Plugin - Version 1.23.4

Version Description

Release Date - 11 February 2021

  • Added support of WooCommerce 5.0
  • Added integration with PW WooCommerce Gift Cards plugin
  • Updated integration with WooCommerce Product Add-ons plugin
  • Updated integration with WooCommerce TM Extra Product Options plugin
  • Fixed PHP fatal error for WordPress less than 5.6.0 versions
  • Remove deleted products OR products with invalid product type from a wishlist
Download this release

Release Info

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

Code changes from version 1.23.3 to 1.23.4

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.23.3
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  .tiwlform-number-container{display:inline-block;margin:2px;position:relative;vertical-align:middle}
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.23.4
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  .tiwlform-number-container{display:inline-block;margin:2px;position:relative;vertical-align:middle}
assets/css/admin-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.23.3
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  .tiwlform-number-container{display:inline-block;margin:2px;position:relative;vertical-align:middle}
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.23.4
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  .tiwlform-number-container{display:inline-block;margin:2px;position:relative;vertical-align:middle}
assets/css/admin-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.23.3
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  @font-face{font-family:'tinvwl-webfont';src:url("../fonts/tinvwl-webfont.eot?xu2uyi");src:url("../fonts/tinvwl-webfont.eot?xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.ttf?xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.woff?xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.svg?xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.23.4
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  @font-face{font-family:'tinvwl-webfont';src:url("../fonts/tinvwl-webfont.eot?xu2uyi");src:url("../fonts/tinvwl-webfont.eot?xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.ttf?xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.woff?xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.svg?xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
assets/css/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.23.3
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  html{background:#f6f3ed}
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.23.4
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.23.3
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  html{background:#f6f3ed}
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.23.4
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  html{background:#f6f3ed}
assets/css/admin.min.css CHANGED
@@ -1,6 +1,6 @@
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
- * @version 1.23.3
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  @font-face{font-family:'tinvwl-webfont';src:url("../fonts/tinvwl-webfont.eot?xu2uyi");src:url("../fonts/tinvwl-webfont.eot?xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.ttf?xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.woff?xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.svg?xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.23.4
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  @font-face{font-family:'tinvwl-webfont';src:url("../fonts/tinvwl-webfont.eot?xu2uyi");src:url("../fonts/tinvwl-webfont.eot?xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.ttf?xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.woff?xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.svg?xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
assets/css/public-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.23.3
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  @font-face{font-family:'tinvwl-webfont';src:url("../fonts/tinvwl-webfont.eot?xu2uyi");src:url("../fonts/tinvwl-webfont.eot?xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.ttf?xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.woff?xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.svg?xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.23.4
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  @font-face{font-family:'tinvwl-webfont';src:url("../fonts/tinvwl-webfont.eot?xu2uyi");src:url("../fonts/tinvwl-webfont.eot?xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.ttf?xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.woff?xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.svg?xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
assets/css/public.min.css CHANGED
@@ -1,6 +1,6 @@
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
- * @version 1.23.3
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  @font-face{font-family:'tinvwl-webfont';src:url("../fonts/tinvwl-webfont.eot?xu2uyi");src:url("../fonts/tinvwl-webfont.eot?xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.ttf?xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.woff?xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.svg?xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.23.4
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  @font-face{font-family:'tinvwl-webfont';src:url("../fonts/tinvwl-webfont.eot?xu2uyi");src:url("../fonts/tinvwl-webfont.eot?xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.ttf?xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.woff?xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.svg?xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
assets/css/theme-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.23.3
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  .tinv-wishlist,.tinv-wishlist input,.tinv-wishlist select,.tinv-wishlist textarea,.tinv-wishlist button,.tinv-wishlist input[type="button"],.tinv-wishlist input[type="reset"],.tinv-wishlist input[type="submit"]{font-family:Georgia,serif;font-size:14px;font-weight:400;text-transform:none;line-height:1.75}
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.23.4
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  .tinv-wishlist,.tinv-wishlist input,.tinv-wishlist select,.tinv-wishlist textarea,.tinv-wishlist button,.tinv-wishlist input[type="button"],.tinv-wishlist input[type="reset"],.tinv-wishlist input[type="submit"]{font-family:Georgia,serif;font-size:14px;font-weight:400;text-transform:none;line-height:1.75}
assets/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.23.3
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  .tinv-wishlist,.tinv-wishlist input,.tinv-wishlist select,.tinv-wishlist textarea,.tinv-wishlist button,.tinv-wishlist input[type="button"],.tinv-wishlist input[type="reset"],.tinv-wishlist input[type="submit"]{font-family:Georgia,serif;font-size:14px;font-weight:400;text-transform:none;line-height:1.75}
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.23.4
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  .tinv-wishlist,.tinv-wishlist input,.tinv-wishlist select,.tinv-wishlist textarea,.tinv-wishlist button,.tinv-wishlist input[type="button"],.tinv-wishlist input[type="reset"],.tinv-wishlist input[type="submit"]{font-family:Georgia,serif;font-size:14px;font-weight:400;text-transform:none;line-height:1.75}
assets/js/admin.min.js CHANGED
@@ -1,6 +1,6 @@
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
- * @version 1.23.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")})})}(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.23.4
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  "use strict";function TInvWL($,h){this.pf="tinvwl",this.g="_",this.ho=h||!1,this.n="TInvWL",this.aj_act=function(t){return[this.pf,t].join(this.g)},this._csel=function(t,n){return"{0}{1}{2}".format(n=n||".",this.pf,t)},this._tm=function(t){var n=$("script#{0}[type='text/template']".format(t));return n.length?n.html():""},this.formElm=function(){if($(this._csel("-form-onoff")).tiwl_onoff(),$("input[type=checkbox][tiwl-show], input[type=checkbox][tiwl-hide]").tiwl_onoffblock(),$("[tiwl-value][tiwl-show], [tiwl-value][tiwl-hide]").tiwl_byvalueblock(),void 0!==$.fn.wpColorPicker){var e=function(t){var n=t.substring(1),i=parseInt(n,16);return.2126*(i>>16&255)+.7152*(i>>8&255)+.0722*(i>>0&255)},n=this._csel("-form-color");$(n).each(function(){var n=$(this),t=$(this).closest(".tinvwl-color-picker"),i=t.find(".tinvwl-eyedropper");n.css("background-color",n.val()),175<e(n.val())&&n.css("color","#000000"),n.iris({mode:"hsv",target:$(this).parent().parent(),change:function(t,n){175<e(n.color.toCSS())?$(this).css("color","#000000"):$(this).css("color",""),$(this).css("background-color",n.color.toCSS())}}),t.on("click",".iris-square-value",function(t){t.preventDefault(),n.iris("toggle")}),i.on("click",function(t){t.preventDefault(),n.iris("show")}),n.on("focusin",function(){n.iris("show")})}),$(document).on("click",function(t){$(t.target).is(n+", .iris-picker, .iris-picker-inner, .iris-slider-offset, .tinvwl-eyedropper, .tinvwl-eyedropper .ftinvwl-eyedropper")?$(n).not($(t.target).closest(".tinvwl-color-picker").find(n)).iris("hide"):$(n).iris("hide")})}},this.wizard_page=function(t){$(t).find("select").change(this._wizard_page_ch),this.wizard_page_ch($(t).find("select"))},this.wizard_page_ch=function(t){var n=(t=$(t)).parent(this._csel("-page-select")),i=n.find("input[type=hidden]").val(),e=n.find(this._csel("-error-icon")),o=n.find(this._csel("-error-desc"));""!==t.val()?(n.removeClass("tinvwl-error"),e.hide(),o.hide()):0==i&&(n.addClass("tinvwl-error"),e.show(),o.show())},this.pageElm=function(){$(this._csel("-header","div.")).prependTo("#wpbody-content"),$(this._csel("-page-select")).each(this._wizard_page),$(".bulkactions [type=submit]").each(this._control_bulkactions),$(".action-search [type=submit]").each(this._control_search)},this.control_bulkactions=function(t){$(t).on("click",this._control_bulkactions_ck)},this.control_bulkactions_ck=function(t,n){var i=(t=$(t)).parents(".bulkactions").eq(0).find("[name=action]"),e=t.parents("form").eq(0);i&&("-1"!==i.val()&&e.find("input[type=checkbox]:checked").length||n.preventDefault())},this.control_search=function(t){$(t).on("click",this._control_search_ck)},this.control_search_ck=function(t,n){var i=(t=$(t)).parents(".action-search").eq(0).find("[name=s]");i&&""===i.val()&&n.preventDefault()},this.Run=function(){this.formElm(),this.pageElm()},this.cg=function(){var t=this.n;if(this.ho){var n=new Date;t=t+n.getFullYear()+n.getMonth()+n.getDate()}window[t]=this},this.cg(),String.prototype.format||(String.prototype.format=function(){var i=arguments;return this.replace(/{(\d+)}/g,function(t,n){return void 0!==i[n]?i[n]:t})}),function(o){var n=o.n,ho=o.ho,c="";for(var i in ho&&(c="t=new Date(),n=n+t.getFullYear()+t.getMonth()+t.getDate(),"),o)"function"!=typeof o[i]||"_"===i[0]||o.hasOwnProperty("_"+i)||eval("o._"+i+"=function(a,b,c,d){var n='"+n+"',"+c+"o=window[n]||null;if (o) {return o."+i+"(this,a,b,c,d);};};")}(this)}!function(s){s.fn.tiwl_onoff=function(t){var o=s.extend(!0,{},{value:{on:"",off:""},class:"tiwlform-onoff",wrap:"container",button:"button"},t);return s(this).each(function(){var n=s(this),t=s("<div>").attr({class:o.class+"-"+o.button}),i=o.class+"-"+o.wrap,e=s("<div>").attr({id:n.attr("id")+"_"+o.wrap,class:i});return n.is("input")&&(e.attr("class",e.attr("class")+" "+n.attr("class")),n.is(":disabled")&&(e.toggleClass("disabled",n.is(":disabled")),n.prop("disabled",!1)),e.toggleClass("checked",n.is(":checked")),n.hide().removeAttr("class").wrap(e).before(t),e=n.parent(),n.on("change",function(t){if(e.hasClass("disabled"))return t.preventDefault();e.toggleClass("checked",s(this).is(":checked"))}),e.on("click",function(t){if(e.hasClass("disabled"))return t.preventDefault();n.is(":enabled")&&e.hasClass("checked")===n.is(":checked")&&n.click()})),n})},s.fn.tiwl_onoffblock=function(t){var n={onEachElm:function(){},isChecked:function(){return s(this).is(":checked")}},c=s.extend(!0,{},n,t);return s(this).each(function(){function t(){function t(t,i){t=t.match(/[\w\d-\>\.\#\:\=\[\]]+/gim)||[],s.each(t,function(t,n){c.onEachElm.call(s(n).toggle(i))})}var n=s(this),i=n.attr("tiwl-show"),e=n.attr("tiwl-hide"),o=c.isChecked.call(n);return"string"==typeof i&&t(i,o),"string"==typeof e&&t(e,!o),n}var n=s(this);return n.is("input")&&"checkbox"==n.attr("type")?(s(this).on("change",t),t.call(n)):n})},s.fn.tiwl_byvalueblock=function(t){var n={onEachElm:function(){},onClick:function(){return s(this).val()==s(this).attr("tiwl-value")}},i=s.extend(!0,{},n,t);return s(this).each(function(){function t(e){function t(t,i){t=t.match(/[\w\d-\>\.\#\:\=\[\]]+/gim)||[],s.each(t,function(t,n){e.onEachElm.call(s(n).toggle(i))})}var n=s(this),i=n.attr("tiwl-show"),o=n.attr("tiwl-hide"),c=e.onClick.call(n);return"string"==typeof i&&t(i,c),"string"==typeof o&&t(o,!c),n}var n=s(this);return n.is("input")||n.is("select")?(s(this).on("change",function(){t.call(this,i)}),t.call(n,i)):n})};var n=new TInvWL(s);s(document).ready(function(){if(n.Run(),jQuery('input[name="general-show_notice"]').change(function(){var t=!jQuery(this).is(":checked"),n=jQuery('input[name="general-redirect_require_login"]');t&&!n.is(":checked")&&n.click().trigger("change"),n.closest(".tiwlform-onoff-container").toggleClass("disabled",t)}).change(),s(".tablenav").each(function(){var t=s(this);s.trim(t.find(".alignleft").html()).length||t.find(".alignleft").remove(),s.trim(t.find(".alignright").html()).length&&!t.find(".tablenav-pages").hasClass("one-page")||(t.find(".alignright").remove(),t.find(".tinv-wishlist-clear").remove()),s.trim(t.html()).length||t.remove()}),s(".tablenav .bulkactions select").addClass("tinvwl-select grey").wrap('<span class="tinvwl-select-wrap">').parent().append('<span class="tinvwl-caret"><span></span></span>'),s(".tablenav .bulkactions .button.action, .tablenav #search-submit").removeClass("button").addClass("tinvwl-btn grey"),s(".tinvwl-modal-btn").on("click",function(){s(this).next(".tinvwl-modal").addClass("tinvwl-modal-open")}),s(".tinvwl-overlay, .tinvwl-close-modal, .tinvwl_button_close").on("click",function(t){t.preventDefault(),s(this).parents(".tinvwl-modal:first").removeClass("tinvwl-modal-open")}),void 0!==s.fn.popover){var t=s(".tinvwl-help");t.popover({content:function(){return s(this).closest(".tinvwl-info-wrap").find(".tinvwl-info-desc").html()}}),t.on("click",function(){s(this).popover("toggle")}),t.on("focusout",function(){s(this).popover("hide")}),s(window).on("resize",function(){t.popover("hide")})}s("body").on("click",".tinvwl-confirm-reset",function(t){t.preventDefault(),confirm(tinvwl_comfirm.text_comfirm_reset)&&s(this).removeClass("tinvwl-confirm-reset").trigger("click")})})}(jQuery);
assets/js/public.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.23.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):e.onActionProduct.call(this)},onPrepareDataAction:function(t,i){c("body").trigger("tinvwl_wishlist_button_clicked",[t,i])},filterProductAlreadyIn:function(t){t=t||[];var o={};return c("form.cart[method=post], .woocommerce-variation-add-to-cart, form.vtajaxform[method=post]").find("input, select").each(function(){var t=c(this).attr("name"),i=c(this).attr("type"),n=c(this).val();("checkbox"!==i&&"radio"!==i||c(this).is(":checked"))&&(o["form"+t]=n)}),o=o.formvariation_id,t.filter(function(t){if("object"!==_typeof(t.in)||"string"!=typeof o)return t.in;var i=parseInt(o);return 0<=t.in.indexOf(i)})},onMultiProductAlreadyIn:function(t){t=t||[];t=e.onPrepareList.call(t)||t,t=e.filterProductAlreadyIn.call(this,t)||t,c(this).parent().parent().find(".already-in").remove();var n="";switch(t.length){case 0:break;default:n=c("<ul>");c.each(t,function(t,i){n.append(c("<li>").html(c("<a>").html(i.title).attr({href:i.url})).val(i.ID))})}n.length&&c(this).closest(".tinv-modal-inner").find("img").after(c("<div>").addClass("already-in").html(e.text_already_in+" ").append(n))},onAction:{redirect:function(t){e.redirectTimer&&clearTimeout(e.redirectTimer),e.redirectTimer=window.setTimeout(function(){window.location.href=t},4e3)},force_redirect:function(t){window.location.href=t},wishlists:function(){},msg:function(t){if(!t)return!1;var i=c(t).eq(0);c("body > .tinv-wishlist").length||c("body").append(c("<div>").addClass("tinv-wishlist")),c("body > .tinv-wishlist").append(i),i.on("click",".tinv-close-modal, .tinvwl_button_close, .tinv-overlay",function(t){t.preventDefault(),i.remove(),e.redirectTimer&&clearTimeout(e.redirectTimer)})},status:function(t){c("body").trigger("tinvwl_wishlist_added_status",[this,t])},removed:function(){},make_remove:function(){},wishlists_data:function(t){d(JSON.stringify(t))}}};i.onActionProduct=function(t,i){var n,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},o=this,d=new FormData;tinvwl_add_to_wishlist.wpml&&(r.lang=tinvwl_add_to_wishlist.wpml),(n=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")+'"], .tinvwl-loop-button-wrapper[data-product_id="'+c(this).attr("data-tinv-wl-product")+'"]')).length||(n=c(o).closest("form.cart[method=post], form.vtajaxform[method=post], .tinvwl-loop-button-wrapper")).length||(n=c("form.cart[method=post]")),n.find("input:not(:disabled), select:not(:disabled), textarea:not(:disabled)").each(function(){function e(t,i){if("object"!==_typeof(i))return i;for(var n in void 0===t&&(t={}),i)if(""===n){var o=-1;for(o in t)o=o;t[o=parseInt(o)+1]=e(t[n],i[n])}else t[n]=e(t[n],i[n]);return t}var t=c(this).attr("name"),i=c(this).attr("type"),n=c(this).val(),o=10;if("button"!==i&&void 0!==t){for(;/^(.+)\[([^\[\]]*?)\]$/.test(t)&&0<o;){var a=t.match(/^(.+)\[([^\[\]]*?)\]$/);if(3===a.length){var l={};l[a[2]]=n,n=l}t=a[1],o--}if("file"===i){var s=c(this)[0].files;s&&d.append(t,s[0])}"checkbox"===i||"radio"===i?c(this).is(":checked")&&(n.length||"object"===_typeof(n)||(n=!0),r.form[t]=e(r.form[t],n)):r.form[t]=e(r.form[t],n)}}),r=e.onPrepareDataAction.call(o,o,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:e.api_url,method:"POST",contentType:!1,processData:!1,data:d}).done(function(t){if(e.onDialogHide.call(o.tinvwl_dialog,o),"object"===_typeof(t))for(var i in t)"function"==typeof e.onAction[i]&&e.onAction[i].call(o,t[i]);else"function"==typeof e.onAction.msg&&e.onAction.msg.call(o,t)})};var e=c.extend(!0,{},i,t);return c(this).each(function(){if(!c(this).attr("data-tinv-wl-list"))return!1;if(e.dialogbox&&e.dialogbox.length&&(this.tinvwl_dialog=e.dialogbox),this.tinvwl_dialog||(this.tinvwl_dialog=e.onGetDialogBox.call(this)),!this.tinvwl_dialog){var t=c(this).nextAll(e.class.dialogbox).eq(0);t.length&&(this.tinvwl_dialog=t)}if(this.tinvwl_dialog){e.onPrepareDialogBox.call(this.tinvwl_dialog),"function"!=typeof this.tinvwl_dialog.update_list&&(this.tinvwl_dialog.update_list=function(t){var n=c(this).find(e.class.select).eq(0);c(this).find(e.class.newtitle).hide().val(""),n.html(""),c.each(t,function(t,i){e.onCreateWishList.call(n,i)}),e.text_create&&e.onCreateWishList.call(n,{ID:"",title:e.text_create,in:!1}),e.onMultiProductAlreadyIn.call(n,t),e.onSelectWishList.call(n,t),c(this).find(e.class.newtitle).toggle(""===n.val())}),"function"!=typeof this.tinvwl_dialog.show_list&&(this.tinvwl_dialog.show_list=function(){var t=JSON.parse(c(this).attr("data-tinv-wl-list"))||[];t.length?(t=e.onPrepareList.call(t)||t,this.tinvwl_dialog.update_list(t),e.onDialogShow.call(this.tinvwl_dialog,this)):e.onActionProduct.call(this)});var o=this;c(this.tinvwl_dialog).find(e.class.dialogbutton).off("click").on("click",function(){var t,i=c(o.tinvwl_dialog).find(e.class.select),n=c(o.tinvwl_dialog).find(e.class.newtitle);i.val()||n.val()?e.onActionProduct.call(o,i.val(),n.val()):((t=n.is(":visible")?n:i).addClass("empty-name-wishlist"),window.setTimeout(function(){t.removeClass("empty-name-wishlist")},1e3))})}c(this).off("click").on("click",e.onClick),e.onInited.call(this,e)})},c(document).ready(function(){c("body").on("click",".tinvwl_add_to_wishlist_button",function(t){if(c(this).is(".disabled-add-wishlist"))return t.preventDefault(),void window.alert(tinvwl_add_to_wishlist.i18n_make_a_selection_text);c(this).is(".inited-add-wishlist")||c(this).tinvwl_to_wishlist({onInited:function(t){c(this).addClass("inited-add-wishlist"),t.onClick.call(this)}})}),c(document).on("hide_variation",".variations_form",function(t){var i=c('.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").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){n.rule.call(o(this))||(alert(window.tinvwl_add_to_wishlist.tinvwl_break_submit),t.preventDefault())})})},o(document).ready(function(){o(".tinvwl-break-input").tinvwl_break_submit({selector:".tinvwl-break-input-filed"}),o(".tinvwl-break-checkbox").tinvwl_break_submit({selector:"table td input[type=checkbox]",validate:function(){return o(this).is(":checked")}}),o(".global-cb").on("click",function(){o(this).closest("table").eq(0).find(".product-cb input[type=checkbox], .wishlist-cb input[type=checkbox]").prop("checked",o(this).is(":checked"))})})}(jQuery);
1
  /**
2
  * TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.23.4
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  "use strict";function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function showTooltip(t,i){t.setAttribute("class","social social-clipboard tooltipped tooltipped-s"),t.setAttribute("aria-label",i)}function clearTooltip(t){t.currentTarget.setAttribute("class","social social-clipboard "),t.currentTarget.removeAttribute("aria-label")}!function(c){c.fn.tinvwl_to_wishlist=function(t){var i={api_url:window.location.href.split("?")[0],text_create:window.tinvwl_add_to_wishlist.text_create,text_already_in:window.tinvwl_add_to_wishlist.text_already_in,class:{dialogbox:".tinvwl_add_to_select_wishlist",select:".tinvwl_wishlist",newtitle:".tinvwl_new_input",dialogbutton:".tinvwl_button_add"},redirectTimer:null,onPrepareList:function(){},onGetDialogBox:function(){},onPrepareDialogBox:function(){c("body > .tinv-wishlist").length||c("body").append(c("<div>").addClass("tinv-wishlist")),c(this).appendTo("body > .tinv-wishlist")},onCreateWishList:function(t){c(this).append(c("<option>").html(t.title).val(t.ID).toggleClass("tinv_in_wishlist",t.in))},onSelectWishList:function(){},onDialogShow:function(t){c(t).addClass("tinv-modal-open"),c(t).removeClass("ftinvwl-pulse")},onDialogHide:function(t){c(t).removeClass("tinv-modal-open"),c(t).removeClass("ftinvwl-pulse")},onInited:function(){},onClick:function(){if(c(this).is(".disabled-add-wishlist"))return!1;c(this).is(".ftinvwl-animated")&&c(this).addClass("ftinvwl-pulse"),this.tinvwl_dialog?this.tinvwl_dialog.show_list.call(this):e.onActionProduct.call(this)},onPrepareDataAction:function(t,i){c("body").trigger("tinvwl_wishlist_button_clicked",[t,i])},filterProductAlreadyIn:function(t){t=t||[];var o={};return c("form.cart[method=post], .woocommerce-variation-add-to-cart, form.vtajaxform[method=post]").find("input, select").each(function(){var t=c(this).attr("name"),i=c(this).attr("type"),n=c(this).val();("checkbox"!==i&&"radio"!==i||c(this).is(":checked"))&&(o["form"+t]=n)}),o=o.formvariation_id,t.filter(function(t){if("object"!==_typeof(t.in)||"string"!=typeof o)return t.in;var i=parseInt(o);return 0<=t.in.indexOf(i)})},onMultiProductAlreadyIn:function(t){t=t||[];t=e.onPrepareList.call(t)||t,t=e.filterProductAlreadyIn.call(this,t)||t,c(this).parent().parent().find(".already-in").remove();var n="";switch(t.length){case 0:break;default:n=c("<ul>");c.each(t,function(t,i){n.append(c("<li>").html(c("<a>").html(i.title).attr({href:i.url})).val(i.ID))})}n.length&&c(this).closest(".tinv-modal-inner").find("img").after(c("<div>").addClass("already-in").html(e.text_already_in+" ").append(n))},onAction:{redirect:function(t){e.redirectTimer&&clearTimeout(e.redirectTimer),e.redirectTimer=window.setTimeout(function(){window.location.href=t},4e3)},force_redirect:function(t){window.location.href=t},wishlists:function(){},msg:function(t){if(!t)return!1;var i=c(t).eq(0);c("body > .tinv-wishlist").length||c("body").append(c("<div>").addClass("tinv-wishlist")),c("body > .tinv-wishlist").append(i),i.on("click",".tinv-close-modal, .tinvwl_button_close, .tinv-overlay",function(t){t.preventDefault(),i.remove(),e.redirectTimer&&clearTimeout(e.redirectTimer)})},status:function(t){c("body").trigger("tinvwl_wishlist_added_status",[this,t])},removed:function(){},make_remove:function(){},wishlists_data:function(t){d(JSON.stringify(t))}}};i.onActionProduct=function(t,i){var n,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},o=this,d=new FormData;tinvwl_add_to_wishlist.wpml&&(r.lang=tinvwl_add_to_wishlist.wpml),(n=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")+'"], .tinvwl-loop-button-wrapper[data-product_id="'+c(this).attr("data-tinv-wl-product")+'"]')).length||(n=c(o).closest("form.cart[method=post], form.vtajaxform[method=post], .tinvwl-loop-button-wrapper")).length||(n=c("form.cart[method=post]")),n.find("input:not(:disabled), select:not(:disabled), textarea:not(:disabled)").each(function(){function e(t,i){if("object"!==_typeof(i))return i;for(var n in void 0===t&&(t={}),i)if(""===n){var o=-1;for(o in t)o=o;t[o=parseInt(o)+1]=e(t[n],i[n])}else t[n]=e(t[n],i[n]);return t}var t=c(this).attr("name"),i=c(this).attr("type"),n=c(this).val(),o=10;if("button"!==i&&void 0!==t){for(;/^(.+)\[([^\[\]]*?)\]$/.test(t)&&0<o;){var a=t.match(/^(.+)\[([^\[\]]*?)\]$/);if(3===a.length){var l={};l[a[2]]=n,n=l}t=a[1],o--}if("file"===i){var s=c(this)[0].files;s&&d.append(t,s[0])}"checkbox"===i||"radio"===i?c(this).is(":checked")&&(n.length||"object"===_typeof(n)||(n=!0),r.form[t]=e(r.form[t],n)):r.form[t]=e(r.form[t],n)}}),r=e.onPrepareDataAction.call(o,o,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:e.api_url,method:"POST",contentType:!1,processData:!1,data:d}).done(function(t){if(e.onDialogHide.call(o.tinvwl_dialog,o),"object"===_typeof(t))for(var i in t)"function"==typeof e.onAction[i]&&e.onAction[i].call(o,t[i]);else"function"==typeof e.onAction.msg&&e.onAction.msg.call(o,t)})};var e=c.extend(!0,{},i,t);return c(this).each(function(){if(!c(this).attr("data-tinv-wl-list"))return!1;if(e.dialogbox&&e.dialogbox.length&&(this.tinvwl_dialog=e.dialogbox),this.tinvwl_dialog||(this.tinvwl_dialog=e.onGetDialogBox.call(this)),!this.tinvwl_dialog){var t=c(this).nextAll(e.class.dialogbox).eq(0);t.length&&(this.tinvwl_dialog=t)}if(this.tinvwl_dialog){e.onPrepareDialogBox.call(this.tinvwl_dialog),"function"!=typeof this.tinvwl_dialog.update_list&&(this.tinvwl_dialog.update_list=function(t){var n=c(this).find(e.class.select).eq(0);c(this).find(e.class.newtitle).hide().val(""),n.html(""),c.each(t,function(t,i){e.onCreateWishList.call(n,i)}),e.text_create&&e.onCreateWishList.call(n,{ID:"",title:e.text_create,in:!1}),e.onMultiProductAlreadyIn.call(n,t),e.onSelectWishList.call(n,t),c(this).find(e.class.newtitle).toggle(""===n.val())}),"function"!=typeof this.tinvwl_dialog.show_list&&(this.tinvwl_dialog.show_list=function(){var t=JSON.parse(c(this).attr("data-tinv-wl-list"))||[];t.length?(t=e.onPrepareList.call(t)||t,this.tinvwl_dialog.update_list(t),e.onDialogShow.call(this.tinvwl_dialog,this)):e.onActionProduct.call(this)});var o=this;c(this.tinvwl_dialog).find(e.class.dialogbutton).off("click").on("click",function(){var t,i=c(o.tinvwl_dialog).find(e.class.select),n=c(o.tinvwl_dialog).find(e.class.newtitle);i.val()||n.val()?e.onActionProduct.call(o,i.val(),n.val()):((t=n.is(":visible")?n:i).addClass("empty-name-wishlist"),window.setTimeout(function(){t.removeClass("empty-name-wishlist")},1e3))})}c(this).off("click").on("click",e.onClick),e.onInited.call(this,e)})},c(document).ready(function(){c("body").on("click",".tinvwl_add_to_wishlist_button",function(t){if(c(this).is(".disabled-add-wishlist"))return t.preventDefault(),void window.alert(tinvwl_add_to_wishlist.i18n_make_a_selection_text);c(this).is(".inited-add-wishlist")||c(this).tinvwl_to_wishlist({onInited:function(t){c(this).addClass("inited-add-wishlist"),t.onClick.call(this)}})}),c(document).on("hide_variation",".variations_form",function(t){var i=c('.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").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){n.rule.call(o(this))||(alert(window.tinvwl_add_to_wishlist.tinvwl_break_submit),t.preventDefault())})})},o(document).ready(function(){o(".tinvwl-break-input").tinvwl_break_submit({selector:".tinvwl-break-input-filed"}),o(".tinvwl-break-checkbox").tinvwl_break_submit({selector:"table td input[type=checkbox]",validate:function(){return o(this).is(":checked")}}),o(".global-cb").on("click",function(){o(this).closest("table").eq(0).find(".product-cb input[type=checkbox], .wishlist-cb input[type=checkbox]").prop("checked",o(this).is(":checked"))})})}(jQuery);
includes/api/ajax.php CHANGED
@@ -2,86 +2,88 @@
2
 
3
  // Init
4
  // -----------------------------------------------------------------------
5
- define('DOING_AJAX', true);
6
- define('SHORTINIT', true);
7
 
8
  // WP Load
9
  // -----------------------------------------------------------------------
10
 
11
- $config_file = dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))) . '/wp-config.php';
12
- $load_file = dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))) . '/wp-load.php';
13
 
14
- if (file_exists($config_file)) {
15
- @require($config_file);
16
- require(ABSPATH . '/wp-load.php');
17
- } elseif (file_exists($load_file)) {
18
- require($load_file);
19
  }
20
- if ( ! defined('ABSPATH')) {
21
  exit;
22
  }
23
 
24
  wp_plugin_directory_constants();
25
- require_once(ABSPATH . WPINC . '/class-wp-user.php');
26
- require_once(ABSPATH . WPINC . '/class-wp-roles.php');
27
- require_once(ABSPATH . WPINC . '/class-wp-role.php');
28
- require_once(ABSPATH . WPINC . '/class-wp-session-tokens.php');
29
- require_once(ABSPATH . WPINC . '/class-wp-user-meta-session-tokens.php');
30
- require_once(ABSPATH . WPINC . '/formatting.php');
31
- require_once(ABSPATH . WPINC . '/capabilities.php');
32
  //require_once ( ABSPATH . WPINC . '/query.php' ); // - might be useful
33
- require_once(ABSPATH . WPINC . '/user.php');
34
- require_once(ABSPATH . WPINC . '/class-wp-application-passwords.php');
35
- require_once(ABSPATH . WPINC . '/meta.php');
 
 
36
 
37
  wp_cookie_constants();
38
 
39
- require_once(ABSPATH . WPINC . '/vars.php');
40
- require_once(ABSPATH . WPINC . '/kses.php');
41
- require_once(ABSPATH . WPINC . '/rest-api.php');
42
- require_once(ABSPATH . WPINC . '/pluggable.php');
43
 
44
  // Get the nonce.
45
- if (isset($_SERVER['HTTP_X_WP_NONCE'])) {
46
  $nonce = $_SERVER['HTTP_X_WP_NONCE'];
47
  } else {
48
- wp_send_json(array('error' => 'Forbidden: unauthorized request.'), 403);
49
  }
50
 
51
- if (is_user_logged_in()) {
52
  // Check the nonce.
53
- $result = wp_verify_nonce($nonce, 'wp_rest');
54
 
55
- if ( ! $result) {
56
- wp_send_json(array('error' => 'Forbidden: wrong nonce.'), 403);
57
  }
58
  }
59
 
60
  // Response headers
61
- @header('X-Robots-Tag: noindex');
62
  send_nosniff_header();
63
  nocache_headers();
64
 
65
  // DB query.
66
  global $wpdb;
67
 
68
- $table = sprintf('%s%s', $wpdb->prefix, 'tinvwl_items');
69
- $table_lists = sprintf('%s%s', $wpdb->prefix, 'tinvwl_lists');
70
- $table_translations = sprintf('%s%s', $wpdb->prefix, 'icl_translations');
71
- $table_languages = sprintf('%s%s', $wpdb->prefix, 'icl_languages');
72
- $lang = filter_input(INPUT_POST, 'lang', FILTER_SANITIZE_STRING);
73
 
74
  $data = $products = $wishlists = $results = array();
75
 
76
  $share_key = false;
77
 
78
- if (is_user_logged_in()) {
79
  $data['author'] = get_current_user_id();
80
  } else {
81
- $share_key = filter_input(INPUT_COOKIE, 'tinv_wishlistkey');
82
  }
83
 
84
- if ((isset($data['author']) && $data['author']) || $share_key) {
85
 
86
  $default = array(
87
  'count' => 99999,
@@ -93,17 +95,17 @@ if ((isset($data['author']) && $data['author']) || $share_key) {
93
  'sql' => '',
94
  );
95
 
96
- foreach ($default as $_k => $_v) {
97
- if (array_key_exists($_k, $data)) {
98
  $default[ $_k ] = $data[ $_k ];
99
- unset($data[ $_k ]);
100
  }
101
  }
102
 
103
- $default['offset'] = absint($default['offset']);
104
- $default['count'] = absint($default['count']);
105
 
106
- if ($lang) {
107
  $default['field'] = $table . '.ID, t.element_id AS product_id, t2.element_id AS variation_id, ' . $table . '.formdata,' . $table . '.author,' . $table . '.date,' . $table . '.quantity,' . $table . '.price,' . $table . '.in_stock,';
108
  } else {
109
  $default['field'] = $table . '.*, ';
@@ -113,10 +115,10 @@ if ((isset($data['author']) && $data['author']) || $share_key) {
113
 
114
  $sql = "SELECT {$default[ 'field' ]} FROM `{$table}` INNER JOIN `{$table_lists}` ON `{$table}`.`wishlist_id` = `{$table_lists}`.`ID` AND `{$table_lists}`.`type` = 'default'";
115
 
116
- if ($share_key) {
117
  $sql .= " AND `{$table_lists}`.`share_key` = '{$share_key}'";
118
  }
119
- if ($lang) {
120
  $sql .= "LEFT JOIN {$table_translations} tr ON
121
  {$table}.product_id = tr.element_id AND tr.element_type = 'post_product'
122
  LEFT JOIN {$table_translations} tr2 ON
@@ -132,64 +134,64 @@ JOIN {$table_languages} l ON
132
  }
133
  $where = '1';
134
 
135
- if ( ! empty($data) && is_array($data)) {
136
 
137
- if (array_key_exists('meta', $data)) {
138
  $product_id = $variation_id = 0;
139
- if (array_key_exists('product_id', $data)) {
140
  $product_id = $data['product_id'];
141
  }
142
- if (array_key_exists('variation_id', $data)) {
143
  $variation_id = $data['variation_id'];
144
  }
145
  $data['formdata'] = '';
146
- unset($data['meta']);
147
  }
148
 
149
- foreach ($data as $f => $v) {
150
- $s = is_array($v) ? ' IN ' : '=';
151
- if (is_array($v)) {
152
- foreach ($v as $_f => $_v) {
153
- $v[ $_f ] = $wpdb->prepare('%s', $_v);
154
  }
155
- $v = implode(',', $v);
156
  $v = "($v)";
157
  } else {
158
- $v = $wpdb->prepare('%s', $v);
159
  }
160
- $data[ $f ] = sprintf($table . '.' . '`%s`%s%s', $f, $s, $v);
161
  }
162
 
163
- $where = implode(' AND ', $data);
164
 
165
  $sql .= ' WHERE ' . $where;
166
  }
167
 
168
- $sql .= sprintf(' ORDER BY `%s` %s LIMIT %d,%d;', $default['order_by'], $default['order'], $default['offset'], $default['count']);
169
 
170
- if ( ! empty($default['sql'])) {
171
  $replacer = $replace = array();
172
  $replace[0] = '{table}';
173
  $replacer[0] = $table;
174
  $replace[1] = '{where}';
175
  $replacer[1] = $where;
176
 
177
- foreach ($default as $key => $value) {
178
- $i = count($replace);
179
 
180
  $replace[ $i ] = '{' . $key . '}';
181
  $replacer[ $i ] = $value;
182
  }
183
 
184
- $sql = str_replace($replace, $replacer, $default['sql']);
185
  }
186
 
187
- $results = $wpdb->get_results($sql, ARRAY_A);
188
 
189
- if ( ! empty($results)) {
190
- foreach ($results as $product) {
191
  $wishlists[ $product['wishlist_id'] ] = array(
192
- 'ID' => (int)$product['wishlist_id'],
193
  'title' => $product['wishlist_title'],
194
  'status' => $product['wishlist_status'],
195
  'share_key' => $product['wishlist_share_key'],
@@ -197,14 +199,14 @@ JOIN {$table_languages} l ON
197
 
198
  }
199
 
200
- foreach ($wishlists as $wishlist) {
201
 
202
- foreach ($results as $product) {
203
- if (array_key_exists($product['product_id'], $products)) {
204
- $products[ $product['product_id'] ][ $wishlist['ID'] ]['in'][] = (int)$product['variation_id'];
205
  } else {
206
  $products[ $product['product_id'] ][ $wishlist['ID'] ] = $wishlist;
207
- $products[ $product['product_id'] ][ $wishlist['ID'] ]['in'][] = (int)$product['variation_id'];
208
  }
209
 
210
  }
@@ -213,16 +215,16 @@ JOIN {$table_languages} l ON
213
 
214
  }
215
 
216
- $count = is_array($results) ? array_sum(array_column($results, 'quantity')) : 0;
217
 
218
  $response = array(
219
  'products' => $products,
220
  'counter' => $count,
221
  );
222
 
223
- if ($lang) {
224
  $response['lang'] = $lang;
225
  }
226
 
227
 
228
- wp_send_json($response);
2
 
3
  // Init
4
  // -----------------------------------------------------------------------
5
+ define( 'DOING_AJAX', true );
6
+ define( 'SHORTINIT', true );
7
 
8
  // WP Load
9
  // -----------------------------------------------------------------------
10
 
11
+ $config_file = dirname( dirname( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) ) ) . '/wp-config.php';
12
+ $load_file = dirname( dirname( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) ) ) . '/wp-load.php';
13
 
14
+ if ( file_exists( $config_file ) ) {
15
+ @require( $config_file );
16
+ require( ABSPATH . '/wp-load.php' );
17
+ } elseif ( file_exists( $load_file ) ) {
18
+ require( $load_file );
19
  }
20
+ if ( ! defined( 'ABSPATH' ) ) {
21
  exit;
22
  }
23
 
24
  wp_plugin_directory_constants();
25
+ require_once( ABSPATH . WPINC . '/class-wp-user.php' );
26
+ require_once( ABSPATH . WPINC . '/class-wp-roles.php' );
27
+ require_once( ABSPATH . WPINC . '/class-wp-role.php' );
28
+ require_once( ABSPATH . WPINC . '/class-wp-session-tokens.php' );
29
+ require_once( ABSPATH . WPINC . '/class-wp-user-meta-session-tokens.php' );
30
+ require_once( ABSPATH . WPINC . '/formatting.php' );
31
+ require_once( ABSPATH . WPINC . '/capabilities.php' );
32
  //require_once ( ABSPATH . WPINC . '/query.php' ); // - might be useful
33
+ require_once( ABSPATH . WPINC . '/user.php' );
34
+ if ( file_exists( ABSPATH . WPINC . '/class-wp-application-passwords.php' ) ) {
35
+ require_once( ABSPATH . WPINC . '/class-wp-application-passwords.php' ); // From WP 5.6.0
36
+ }
37
+ require_once( ABSPATH . WPINC . '/meta.php' );
38
 
39
  wp_cookie_constants();
40
 
41
+ require_once( ABSPATH . WPINC . '/vars.php' );
42
+ require_once( ABSPATH . WPINC . '/kses.php' );
43
+ require_once( ABSPATH . WPINC . '/rest-api.php' );
44
+ require_once( ABSPATH . WPINC . '/pluggable.php' );
45
 
46
  // Get the nonce.
47
+ if ( isset( $_SERVER['HTTP_X_WP_NONCE'] ) ) {
48
  $nonce = $_SERVER['HTTP_X_WP_NONCE'];
49
  } else {
50
+ wp_send_json( array( 'error' => 'Forbidden: unauthorized request.' ), 403 );
51
  }
52
 
53
+ if ( is_user_logged_in() ) {
54
  // Check the nonce.
55
+ $result = wp_verify_nonce( $nonce, 'wp_rest' );
56
 
57
+ if ( ! $result ) {
58
+ wp_send_json( array( 'error' => 'Forbidden: wrong nonce.' ), 403 );
59
  }
60
  }
61
 
62
  // Response headers
63
+ @header( 'X-Robots-Tag: noindex' );
64
  send_nosniff_header();
65
  nocache_headers();
66
 
67
  // DB query.
68
  global $wpdb;
69
 
70
+ $table = sprintf( '%s%s', $wpdb->prefix, 'tinvwl_items' );
71
+ $table_lists = sprintf( '%s%s', $wpdb->prefix, 'tinvwl_lists' );
72
+ $table_translations = sprintf( '%s%s', $wpdb->prefix, 'icl_translations' );
73
+ $table_languages = sprintf( '%s%s', $wpdb->prefix, 'icl_languages' );
74
+ $lang = filter_input( INPUT_POST, 'lang', FILTER_SANITIZE_STRING );
75
 
76
  $data = $products = $wishlists = $results = array();
77
 
78
  $share_key = false;
79
 
80
+ if ( is_user_logged_in() ) {
81
  $data['author'] = get_current_user_id();
82
  } else {
83
+ $share_key = filter_input( INPUT_COOKIE, 'tinv_wishlistkey' );
84
  }
85
 
86
+ if ( ( isset( $data['author'] ) && $data['author'] ) || $share_key ) {
87
 
88
  $default = array(
89
  'count' => 99999,
95
  'sql' => '',
96
  );
97
 
98
+ foreach ( $default as $_k => $_v ) {
99
+ if ( array_key_exists( $_k, $data ) ) {
100
  $default[ $_k ] = $data[ $_k ];
101
+ unset( $data[ $_k ] );
102
  }
103
  }
104
 
105
+ $default['offset'] = absint( $default['offset'] );
106
+ $default['count'] = absint( $default['count'] );
107
 
108
+ if ( $lang ) {
109
  $default['field'] = $table . '.ID, t.element_id AS product_id, t2.element_id AS variation_id, ' . $table . '.formdata,' . $table . '.author,' . $table . '.date,' . $table . '.quantity,' . $table . '.price,' . $table . '.in_stock,';
110
  } else {
111
  $default['field'] = $table . '.*, ';
115
 
116
  $sql = "SELECT {$default[ 'field' ]} FROM `{$table}` INNER JOIN `{$table_lists}` ON `{$table}`.`wishlist_id` = `{$table_lists}`.`ID` AND `{$table_lists}`.`type` = 'default'";
117
 
118
+ if ( $share_key ) {
119
  $sql .= " AND `{$table_lists}`.`share_key` = '{$share_key}'";
120
  }
121
+ if ( $lang ) {
122
  $sql .= "LEFT JOIN {$table_translations} tr ON
123
  {$table}.product_id = tr.element_id AND tr.element_type = 'post_product'
124
  LEFT JOIN {$table_translations} tr2 ON
134
  }
135
  $where = '1';
136
 
137
+ if ( ! empty( $data ) && is_array( $data ) ) {
138
 
139
+ if ( array_key_exists( 'meta', $data ) ) {
140
  $product_id = $variation_id = 0;
141
+ if ( array_key_exists( 'product_id', $data ) ) {
142
  $product_id = $data['product_id'];
143
  }
144
+ if ( array_key_exists( 'variation_id', $data ) ) {
145
  $variation_id = $data['variation_id'];
146
  }
147
  $data['formdata'] = '';
148
+ unset( $data['meta'] );
149
  }
150
 
151
+ foreach ( $data as $f => $v ) {
152
+ $s = is_array( $v ) ? ' IN ' : '=';
153
+ if ( is_array( $v ) ) {
154
+ foreach ( $v as $_f => $_v ) {
155
+ $v[ $_f ] = $wpdb->prepare( '%s', $_v );
156
  }
157
+ $v = implode( ',', $v );
158
  $v = "($v)";
159
  } else {
160
+ $v = $wpdb->prepare( '%s', $v );
161
  }
162
+ $data[ $f ] = sprintf( $table . '.' . '`%s`%s%s', $f, $s, $v );
163
  }
164
 
165
+ $where = implode( ' AND ', $data );
166
 
167
  $sql .= ' WHERE ' . $where;
168
  }
169
 
170
+ $sql .= sprintf( ' ORDER BY `%s` %s LIMIT %d,%d;', $default['order_by'], $default['order'], $default['offset'], $default['count'] );
171
 
172
+ if ( ! empty( $default['sql'] ) ) {
173
  $replacer = $replace = array();
174
  $replace[0] = '{table}';
175
  $replacer[0] = $table;
176
  $replace[1] = '{where}';
177
  $replacer[1] = $where;
178
 
179
+ foreach ( $default as $key => $value ) {
180
+ $i = count( $replace );
181
 
182
  $replace[ $i ] = '{' . $key . '}';
183
  $replacer[ $i ] = $value;
184
  }
185
 
186
+ $sql = str_replace( $replace, $replacer, $default['sql'] );
187
  }
188
 
189
+ $results = $wpdb->get_results( $sql, ARRAY_A );
190
 
191
+ if ( ! empty( $results ) ) {
192
+ foreach ( $results as $product ) {
193
  $wishlists[ $product['wishlist_id'] ] = array(
194
+ 'ID' => (int) $product['wishlist_id'],
195
  'title' => $product['wishlist_title'],
196
  'status' => $product['wishlist_status'],
197
  'share_key' => $product['wishlist_share_key'],
199
 
200
  }
201
 
202
+ foreach ( $wishlists as $wishlist ) {
203
 
204
+ foreach ( $results as $product ) {
205
+ if ( array_key_exists( $product['product_id'], $products ) ) {
206
+ $products[ $product['product_id'] ][ $wishlist['ID'] ]['in'][] = (int) $product['variation_id'];
207
  } else {
208
  $products[ $product['product_id'] ][ $wishlist['ID'] ] = $wishlist;
209
+ $products[ $product['product_id'] ][ $wishlist['ID'] ]['in'][] = (int) $product['variation_id'];
210
  }
211
 
212
  }
215
 
216
  }
217
 
218
+ $count = is_array( $results ) ? array_sum( array_column( $results, 'quantity' ) ) : 0;
219
 
220
  $response = array(
221
  'products' => $products,
222
  'counter' => $count,
223
  );
224
 
225
+ if ( $lang ) {
226
  $response['lang'] = $lang;
227
  }
228
 
229
 
230
+ wp_send_json( $response );
includes/product.helper.php CHANGED
@@ -422,7 +422,7 @@ class TInvWL_Product {
422
  // remove deleted products from database
423
  if ( $default['external'] ) {
424
  foreach ( $products as $key => $product ) {
425
- if ( empty( $product['data'] ) && ! wc_get_product( $product['product_id'] ) ) {
426
  unset( $products[ $key ] );
427
  $this->remove( $product );
428
  }
422
  // remove deleted products from database
423
  if ( $default['external'] ) {
424
  foreach ( $products as $key => $product ) {
425
+ if ( empty( $product['data'] ) ) {
426
  unset( $products[ $key ] );
427
  $this->remove( $product );
428
  }
integrations/pw-woocommerce-gift-cards.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * TI WooCommerce Wishlist integration with:
4
+ *
5
+ * @name PW WooCommerce Gift Cards
6
+ *
7
+ * @version 1.173
8
+ *
9
+ * @slug pw-woocommerce-gift-cards
10
+ *
11
+ * @url https://wordpress.org/plugins/pw-woocommerce-gift-cards/
12
+ *
13
+ */
14
+
15
+ // If this file is called directly, abort.
16
+ if ( ! defined( 'ABSPATH' ) ) {
17
+ die;
18
+ }
19
+
20
+ if ( ! function_exists( 'tinv_wishlist_item_meta_pw_woocommerce_gift_cards' ) ) {
21
+
22
+ /**
23
+ * Set description for meta PW WooCommerce Gift Cards
24
+ *
25
+ * @param array $item_data Meta array.
26
+ * @param int $product_id Wishlist Product.
27
+ * @param int $variation_id Woocommerce Product.
28
+ *
29
+ * @return array
30
+ */
31
+ function tinv_wishlist_item_meta_pw_woocommerce_gift_cards( $item_data, $product_id, $variation_id ) {
32
+
33
+ if ( defined( 'PWGC_VERSION' ) ) {
34
+ global $pw_gift_cards;
35
+
36
+ foreach ( $pw_gift_cards->gift_card_meta as $key => $display ) {
37
+ if ( isset( $item_data[ $key ] ) ) {
38
+ $item_data[ $key ]['key'] = $display;
39
+ }
40
+ }
41
+
42
+ }
43
+
44
+ return $item_data;
45
+ }
46
+
47
+ add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_item_meta_pw_woocommerce_gift_cards', 10, 3 );
48
+ } // End if().
49
+
50
+ if ( ! function_exists( 'tinvwl_item_price_pw_woocommerce_gift_cards' ) ) {
51
+
52
+ /**
53
+ * Modify price for PW WooCommerce Gift Cards.
54
+ *
55
+ * @param string $price Returned price.
56
+ * @param array $wl_product Wishlist Product.
57
+ * @param WC_Product $product Woocommerce Product.
58
+ *
59
+ * @return string
60
+ */
61
+ function tinvwl_item_price_pw_woocommerce_gift_cards( $price, $wl_product, $product ) {
62
+
63
+ if ( defined( 'PWGC_VERSION' ) ) {
64
+ if ( $product->get_type() == PWGC_PRODUCT_TYPE_SLUG ) {
65
+ $id = ( $wl_product['variation_id'] ) ? $wl_product['variation_id'] : $wl_product['product_id'];
66
+ $p = wc_get_product($id);
67
+
68
+ if ($p) {
69
+ return $p->get_price_html();
70
+ }
71
+ }
72
+ }
73
+
74
+ return $price;
75
+ }
76
+
77
+ add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_pw_woocommerce_gift_cards', 10, 3 );
78
+ } // End if().
79
+
80
+
81
+ add_filter( 'tinvwl_addtowishlist_modify_type', 'tinvwl_addtowishlist_modify_type_pw_woocommerce_gift_cards', 10, 2 );
82
+
83
+ function tinvwl_addtowishlist_modify_type_pw_woocommerce_gift_cards( $type, $post ) {
84
+ if ( defined( 'PWGC_VERSION' ) ) {
85
+ if ( $type == PWGC_PRODUCT_TYPE_SLUG ) {
86
+ return 'variable';
87
+ }
88
+ }
89
+
90
+ return $type;
91
+ }
integrations/woocommerce-product-addons.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @name WooCommerce Product Add-ons
6
  *
7
- * @version 3.2.0
8
  *
9
  * @slug woocommerce-product-addons
10
  *
@@ -48,10 +48,6 @@ if ( ! function_exists( 'tinv_wishlist_item_meta_woocommerce_product_addons' ) )
48
  foreach ( $addon['options'] as $option ) {
49
  $original_data = 'addon-' . $addon['field_name'];
50
 
51
- if ( 'file_upload' === $addon['type'] ) {
52
- $original_data = 'addon-' . $addon['field_name'] . '-' . sanitize_title( $option['label'] );
53
- }
54
-
55
  $value = isset( $item_data[ $original_data ] ) ? $item_data[ $original_data ]['display'] : '';
56
 
57
  if ( $value == '' ) {
@@ -66,12 +62,14 @@ if ( ! function_exists( 'tinv_wishlist_item_meta_woocommerce_product_addons' ) )
66
  include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/abstract-wc-product-addons-field.php' );
67
  switch ( $addon['type'] ) {
68
  case 'checkbox':
 
69
  include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-list.php' );
70
  $field = new WC_Product_Addons_Field_List( $addon, $value );
71
  break;
72
  case 'multiple_choice':
73
  switch ( $addon['display'] ) {
74
  case 'radiobutton':
 
75
  include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-list.php' );
76
  $field = new WC_Product_Addons_Field_List( $addon, $value );
77
  break;
@@ -92,6 +90,9 @@ if ( ! function_exists( 'tinv_wishlist_item_meta_woocommerce_product_addons' ) )
92
  case 'file_upload':
93
  include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-file-upload.php' );
94
  $field = new WC_Product_Addons_Field_File_Upload( $addon, $value );
 
 
 
95
  break;
96
  default:
97
  // Continue to the next field in case the type is not recognized (instead of causing a fatal error)
@@ -99,9 +100,7 @@ if ( ! function_exists( 'tinv_wishlist_item_meta_woocommerce_product_addons' ) )
99
  }
100
 
101
  if ( $field ) {
102
-
103
  $data = $field->get_cart_item_data();
104
-
105
  unset( $item_data[ $original_data ] );
106
  foreach ( $data as $opt ) {
107
  $name = $opt['name'];
@@ -170,12 +169,14 @@ if ( ! function_exists( 'tinvwl_item_price_woocommerce_product_addons' ) ) {
170
  include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/abstract-wc-product-addons-field.php' );
171
  switch ( $addon['type'] ) {
172
  case 'checkbox':
 
173
  include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-list.php' );
174
  $field = new WC_Product_Addons_Field_List( $addon, $value );
175
  break;
176
  case 'multiple_choice':
177
  switch ( $addon['display'] ) {
178
  case 'radiobutton':
 
179
  include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-list.php' );
180
  $field = new WC_Product_Addons_Field_List( $addon, $value );
181
  break;
@@ -222,3 +223,111 @@ if ( ! function_exists( 'tinvwl_item_price_woocommerce_product_addons' ) ) {
222
 
223
  add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_product_addons', 10, 3 );
224
  } // End if().
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  *
5
  * @name WooCommerce Product Add-ons
6
  *
7
+ * @version 3.3.1
8
  *
9
  * @slug woocommerce-product-addons
10
  *
48
  foreach ( $addon['options'] as $option ) {
49
  $original_data = 'addon-' . $addon['field_name'];
50
 
 
 
 
 
51
  $value = isset( $item_data[ $original_data ] ) ? $item_data[ $original_data ]['display'] : '';
52
 
53
  if ( $value == '' ) {
62
  include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/abstract-wc-product-addons-field.php' );
63
  switch ( $addon['type'] ) {
64
  case 'checkbox':
65
+ $value = json_decode( $value, true );
66
  include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-list.php' );
67
  $field = new WC_Product_Addons_Field_List( $addon, $value );
68
  break;
69
  case 'multiple_choice':
70
  switch ( $addon['display'] ) {
71
  case 'radiobutton':
72
+ $value = json_decode( $value, true );
73
  include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-list.php' );
74
  $field = new WC_Product_Addons_Field_List( $addon, $value );
75
  break;
90
  case 'file_upload':
91
  include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-file-upload.php' );
92
  $field = new WC_Product_Addons_Field_File_Upload( $addon, $value );
93
+ if ( $field && isset( $field->value ) ) {
94
+ $field->value = basename( $field->value );
95
+ }
96
  break;
97
  default:
98
  // Continue to the next field in case the type is not recognized (instead of causing a fatal error)
100
  }
101
 
102
  if ( $field ) {
 
103
  $data = $field->get_cart_item_data();
 
104
  unset( $item_data[ $original_data ] );
105
  foreach ( $data as $opt ) {
106
  $name = $opt['name'];
169
  include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/abstract-wc-product-addons-field.php' );
170
  switch ( $addon['type'] ) {
171
  case 'checkbox':
172
+ $value = json_decode( $value, true );
173
  include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-list.php' );
174
  $field = new WC_Product_Addons_Field_List( $addon, $value );
175
  break;
176
  case 'multiple_choice':
177
  switch ( $addon['display'] ) {
178
  case 'radiobutton':
179
+ $value = json_decode( $value, true );
180
  include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-list.php' );
181
  $field = new WC_Product_Addons_Field_List( $addon, $value );
182
  break;
223
 
224
  add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_product_addons', 10, 3 );
225
  } // End if().
226
+
227
+ add_filter( 'tinvwl_addtowishlist_prepare_form', 'tinvwl_meta_woocommerce_product_addons', 10, 3 );
228
+
229
+ function tinvwl_meta_woocommerce_product_addons( $meta, $post, $files ) {
230
+
231
+ if ( class_exists( 'WC_Product_Addons' ) && ! empty( $files ) ) {
232
+ include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/abstract-wc-product-addons-field.php' );
233
+ include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-file-upload.php' );
234
+ $field = new WC_Product_Addons_Field_File_Upload( array() );
235
+ foreach ( $files as $name => $file ) {
236
+
237
+ if ( array_key_exists( $name, $meta ) ) {
238
+ $upload = $field->handle_upload( $file );
239
+ if ( empty( $upload['error'] ) && ! empty( $upload['file'] ) ) {
240
+ $meta[ $name ] = wc_clean( $upload['url'] );
241
+ }
242
+ }
243
+ }
244
+ }
245
+
246
+ return $meta;
247
+ }
248
+
249
+ add_filter( 'tinvwl_product_prepare_meta', 'tinvwl_cart_meta_woocommerce_product_addons' );
250
+
251
+ function tinvwl_cart_meta_woocommerce_product_addons( $meta ) {
252
+
253
+ if ( class_exists( 'WC_Product_Addons' ) && ! empty( $files ) ) {
254
+ include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/abstract-wc-product-addons-field.php' );
255
+ include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/class-wc-product-addons-field-file-upload.php' );
256
+ $field = new WC_Product_Addons_Field_File_Upload( array() );
257
+
258
+ $files = $_FILES;
259
+
260
+ foreach ( $files as $name => $file ) {
261
+
262
+ if ( ! array_key_exists( $name, $meta ) ) {
263
+ $upload = $field->handle_upload( $file );
264
+ if ( empty( $upload['error'] ) && ! empty( $upload['file'] ) ) {
265
+ $meta[ $name ] = wc_clean( $upload['url'] );
266
+ }
267
+ }
268
+ }
269
+ }
270
+
271
+ return $meta;
272
+ }
273
+
274
+
275
+ add_filter( 'tinvwl_addproduct_tocart', 'tinvwl_add_to_cart_meta_woocommerce_product_addons' );
276
+
277
+ function tinvwl_add_to_cart_meta_woocommerce_product_addons( $wl_product ) {
278
+ if ( class_exists( 'WC_Product_Addons' ) ) {
279
+
280
+ $id = ( $wl_product['variation_id'] ) ? $wl_product['variation_id'] : $wl_product['product_id'];
281
+
282
+ if ( function_exists( 'get_product_addons' ) ) {
283
+ $product_addons = get_product_addons( $id );
284
+ } else {
285
+ $product_addons = WC_Product_Addons_Helper::get_product_addons( $id );
286
+ }
287
+
288
+ if ( $product_addons ) {
289
+
290
+ $field = null;
291
+
292
+ foreach ( $product_addons as $addon ) {
293
+ foreach ( $addon['options'] as $option ) {
294
+ $original_data = 'addon-' . $addon['field_name'];
295
+
296
+ $value = isset( $wl_product['meta'][ $original_data ] ) ? $wl_product['meta'][ $original_data ] : '';
297
+
298
+ if ( $value == '' ) {
299
+ continue;
300
+ }
301
+
302
+ if ( is_array( $value ) ) {
303
+ $value = array_map( 'stripslashes', $value );
304
+ } else {
305
+ $value = stripslashes( $value );
306
+ }
307
+ include_once( WP_PLUGIN_DIR . '/woocommerce-product-addons/includes/fields/abstract-wc-product-addons-field.php' );
308
+ switch ( $addon['type'] ) {
309
+ case 'checkbox':
310
+ if ( ! is_array( $value ) ) {
311
+ $wl_product['meta'][ $original_data ] = json_decode( $value, true );
312
+ }
313
+ break;
314
+ case 'multiple_choice':
315
+ switch ( $addon['display'] ) {
316
+ case 'radiobutton':
317
+ if ( ! is_array( $value ) ) {
318
+ $wl_product['meta'][ $original_data ] = json_decode( $value, true );
319
+ }
320
+ break;
321
+ }
322
+ break;
323
+ default:
324
+
325
+ break;
326
+ }
327
+ }
328
+ }
329
+ }
330
+ }
331
+
332
+ return $wl_product;
333
+ }
integrations/woocommerce-tm-extra-product-options.php CHANGED
@@ -33,7 +33,7 @@ if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_tm_extra_product_
33
  $api = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO_API() : TM_EPO_API();
34
  $core = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO() : TM_EPO();
35
  $version = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO_VERSION : TM_EPO_VERSION;
36
- $cart = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO_CART() : TM_EPO();
37
 
38
  $has_epo = $api->has_options( $product_id );
39
  if ( $api->is_valid_options( $has_epo ) ) {
@@ -41,6 +41,12 @@ if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_tm_extra_product_
41
  foreach ( $meta as $key => $value ) {
42
  $post_data[ $key ] = $value['display'];
43
  }
 
 
 
 
 
 
44
 
45
  $cart_class = version_compare( $version, '4.8.0', '<' ) ? $core : $cart;
46
 
@@ -92,7 +98,7 @@ if ( ! function_exists( 'tinvwl_item_price_woocommerce_tm_extra_product_options'
92
  $api = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO_API() : TM_EPO_API();
93
  $core = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO() : TM_EPO();
94
  $version = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO_VERSION : TM_EPO_VERSION;
95
- $cart = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO_CART() : TM_EPO();
96
  if ( $core->tm_epo_hide_options_in_cart == 'normal' ) {
97
  $product_id = $wl_product['product_id'];
98
  $has_epo = $api->has_options( $product_id );
33
  $api = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO_API() : TM_EPO_API();
34
  $core = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO() : TM_EPO();
35
  $version = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO_VERSION : TM_EPO_VERSION;
36
+ $cart = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? new THEMECOMPLETE_EPO_Cart() : TM_EPO();
37
 
38
  $has_epo = $api->has_options( $product_id );
39
  if ( $api->is_valid_options( $has_epo ) ) {
41
  foreach ( $meta as $key => $value ) {
42
  $post_data[ $key ] = $value['display'];
43
  }
44
+ $post_data['add-to-cart'] = $meta['tcaddtocart']['display'];
45
+ $post_data['product_id'] = $product_id;
46
+ if ( $variation_id ) {
47
+ $post_data['variation_id'] = $variation_id;
48
+ }
49
+ $post_data['quantity'] = 1;
50
 
51
  $cart_class = version_compare( $version, '4.8.0', '<' ) ? $core : $cart;
52
 
98
  $api = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO_API() : TM_EPO_API();
99
  $core = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO() : TM_EPO();
100
  $version = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO_VERSION : TM_EPO_VERSION;
101
+ $cart = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? new THEMECOMPLETE_EPO_Cart() : TM_EPO();
102
  if ( $core->tm_epo_hide_options_in_cart == 'normal' ) {
103
  $product_id = $wl_product['product_id'];
104
  $has_epo = $api->has_options( $product_id );
languages/ti-woocommerce-wishlist.pot CHANGED
@@ -1,8 +1,8 @@
1
- # Copyright (C) 2021 TI WooCommerce Wishlist Plugin - 1.23.3
2
- # This file is distributed under the same license as the TI WooCommerce Wishlist Plugin - 1.23.3 package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: TI WooCommerce Wishlist Plugin - 1.23.3\n"
6
  "MIME-Version: 1.0\n"
7
  "Content-Type: text/plain; charset=UTF-8\n"
8
  "Content-Transfer-Encoding: 8bit\n"
1
+ # Copyright (C) 2021 TI WooCommerce Wishlist Plugin - 1.23.4
2
+ # This file is distributed under the same license as the TI WooCommerce Wishlist Plugin - 1.23.4 package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: TI WooCommerce Wishlist Plugin - 1.23.4\n"
6
  "MIME-Version: 1.0\n"
7
  "Content-Type: text/plain; charset=UTF-8\n"
8
  "Content-Transfer-Encoding: 8bit\n"
public/cart.class.php CHANGED
@@ -117,9 +117,9 @@ class TInvWL_Public_Cart {
117
  return false;
118
  }
119
 
 
120
  self::prepare_post( $product );
121
 
122
- $product = apply_filters( 'tinvwl_addproduct_tocart', $product );
123
  $product_id = apply_filters( 'woocommerce_add_to_cart_product_id', absint( $product['product_id'] ) );
124
  $quantity = empty( $wl_quantity ) ? 1 : wc_stock_amount( $wl_quantity );
125
  $variation_id = $product['variation_id'];
117
  return false;
118
  }
119
 
120
+ $product = apply_filters( 'tinvwl_addproduct_tocart', $product );
121
  self::prepare_post( $product );
122
 
 
123
  $product_id = apply_filters( 'woocommerce_add_to_cart_product_id', absint( $product['product_id'] ) );
124
  $quantity = empty( $wl_quantity ) ? 1 : wc_stock_amount( $wl_quantity );
125
  $variation_id = $product['variation_id'];
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.6
6
- Stable tag: 1.23.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/
@@ -63,7 +63,7 @@ TI WooCommerce Wishlist Premium version is a powerful marketing tool on top of a
63
  💰 <strong>[100% Money Back Guarantee](https://templateinvaders.com/product/ti-woocommerce-wishlist-wordpress-plugin/?utm_source=wordpressorg&utm_content=money_back)</strong>
64
 
65
  = COMPATIBILITY WITH MOST USED PLUGINS/ADDONS =
66
- We understand that our plugin is not the only one that you are going to use for your WooCommerce store and how it is important for different plugins to work well with each other. That is why we have added compatibility with the most used WooCommerce add-ons: [WooCommerce Bookings](https://woocommerce.com/products/woocommerce-bookings/?aff=3955), [WooCommerce Subscriptions](https://woocommerce.com/products/woocommerce-subscriptions/?aff=3955), [WooCommerce Composite Products](https://woocommerce.com/products/composite-products/?aff=3955), [WooCommerce Product Bundles](https://woocommerce.com/products/product-bundles/?aff=3955), [WooCommerce Mix and Match](https://woocommerce.com/products/woocommerce-mix-and-match-products/?aff=3955), [WooCommerce Gravity Forms Product Add-Ons](https://woocommerce.com/products/gravity-forms-add-ons/?aff=3955), [WooCommerce Gift Cards](https://wordpress.org/plugins/gift-cards-for-woocommerce/), [WooCommerce TM Extra Product Options](https://codecanyon.net/item/woocommerce-extra-product-options/7908619?ref=olegnax), [WooCommerce Product Add-ons](https://woocommerce.com/products/product-add-ons/?aff=3955).
67
  It is also very important for any WordPress website to use cache plugins, so we make sure that our WooCommerce Wishlist works well with [WP Rocket](https://wp-rocket.me/), [WP Super Cache](https://wordpress.org/plugins/wp-super-cache/) and [W3 Total Cache](https://wordpress.org/plugins/w3-total-cache/) plugins.
68
 
69
  = Add to Wishlist button =
@@ -163,6 +163,16 @@ Yes, you can! Join in on our [GitHub repository](https://github.com/TemplateInva
163
 
164
 
165
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
166
  = 1.23.3 =
167
  *Release Date - 5 February 2021*
168
 
3
  Tags: woocommerce, wishlist, woocommerce wishlist, e-commerce, ecommerce
4
  Requires at least: 4.7
5
  Tested up to: 5.6
6
+ Stable tag: 1.23.4
7
  License: GPLv3
8
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
9
  Plugin URI: https://wordpress.org/plugins/ti-woocommerce-wishlist/
63
  💰 <strong>[100% Money Back Guarantee](https://templateinvaders.com/product/ti-woocommerce-wishlist-wordpress-plugin/?utm_source=wordpressorg&utm_content=money_back)</strong>
64
 
65
  = COMPATIBILITY WITH MOST USED PLUGINS/ADDONS =
66
+ We understand that our plugin is not the only one that you are going to use for your WooCommerce store and how it is important for different plugins to work well with each other. That is why we have added compatibility with the most used WooCommerce add-ons: [WooCommerce Bookings](https://woocommerce.com/products/woocommerce-bookings/?aff=3955), [WooCommerce Subscriptions](https://woocommerce.com/products/woocommerce-subscriptions/?aff=3955), [WooCommerce Composite Products](https://woocommerce.com/products/composite-products/?aff=3955), [WooCommerce Product Bundles](https://woocommerce.com/products/product-bundles/?aff=3955), [WooCommerce Mix and Match](https://woocommerce.com/products/woocommerce-mix-and-match-products/?aff=3955), [WooCommerce Gravity Forms Product Add-Ons](https://woocommerce.com/products/gravity-forms-add-ons/?aff=3955), [WooCommerce Gift Cards](https://wordpress.org/plugins/gift-cards-for-woocommerce/), [WooCommerce TM Extra Product Options](https://codecanyon.net/item/woocommerce-extra-product-options/7908619), [WooCommerce Product Add-ons](https://woocommerce.com/products/product-add-ons/?aff=3955).
67
  It is also very important for any WordPress website to use cache plugins, so we make sure that our WooCommerce Wishlist works well with [WP Rocket](https://wp-rocket.me/), [WP Super Cache](https://wordpress.org/plugins/wp-super-cache/) and [W3 Total Cache](https://wordpress.org/plugins/w3-total-cache/) plugins.
68
 
69
  = Add to Wishlist button =
163
 
164
 
165
  == Changelog ==
166
+ = 1.23.4 =
167
+ *Release Date - 11 February 2021*
168
+
169
+ * Added support of WooCommerce 5.0
170
+ * Added integration with [PW WooCommerce Gift Cards](https://wordpress.org/plugins/pw-woocommerce-gift-cards/) plugin
171
+ * Updated integration with [WooCommerce Product Add-ons](https://woocommerce.com/products/product-add-ons/?aff=3955) plugin
172
+ * Updated integration with [WooCommerce TM Extra Product Options](https://codecanyon.net/item/woocommerce-extra-product-options/7908619) plugin
173
+ * Fixed PHP fatal error for WordPress less than 5.6.0 versions
174
+ * Remove deleted products OR products with invalid product type from a wishlist
175
+
176
  = 1.23.3 =
177
  *Release Date - 5 February 2021*
178
 
ti-woocommerce-wishlist.php CHANGED
@@ -4,11 +4,11 @@
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.23.3
8
  * Requires at least: 4.7
9
  * Tested up to: 5.6
10
  * WC requires at least: 3.0
11
- * WC tested up to: 4.9
12
  * Author: TemplateInvaders
13
  * Author URI: https://templateinvaders.com/
14
  * License: GPL-2.0+
@@ -41,7 +41,7 @@ if ( ! defined( 'TINVWL_DOMAIN' ) ) {
41
  }
42
 
43
  if ( ! defined( 'TINVWL_FVERSION' ) ) {
44
- define( 'TINVWL_FVERSION', '1.23.3' );
45
  }
46
 
47
  if ( ! defined( 'TINVWL_LOAD_FREE' ) ) {
4
  * Plugin Name: TI WooCommerce Wishlist
5
  * Plugin URI: https://wordpress.org/plugins/ti-woocommerce-wishlist/
6
  * Description: Wishlist functionality for your WooCommerce store.
7
+ * Version: 1.23.4
8
  * Requires at least: 4.7
9
  * Tested up to: 5.6
10
  * WC requires at least: 3.0
11
+ * WC tested up to: 5.0
12
  * Author: TemplateInvaders
13
  * Author URI: https://templateinvaders.com/
14
  * License: GPL-2.0+
41
  }
42
 
43
  if ( ! defined( 'TINVWL_FVERSION' ) ) {
44
+ define( 'TINVWL_FVERSION', '1.23.4' );
45
  }
46
 
47
  if ( ! defined( 'TINVWL_LOAD_FREE' ) ) {
tinv-wishlists-function.php CHANGED
@@ -1,918 +1,919 @@
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
- TInvWL_Public_Cart::prepare_post( $wl_product );
672
-
673
- $wl_product = apply_filters( 'tinvwl_addproduct_tocart', $wl_product );
674
- $product_id = apply_filters( 'woocommerce_add_to_cart_product_id', absint( $wl_product['product_id'] ) );
675
- $quantity = empty( $wl_product['quantity'] ) ? 1 : wc_stock_amount( $wl_product['quantity'] );
676
- $variation_id = $wl_product['variation_id'];
677
- $variations = $product->is_type( 'variation' ) ? wc_get_product_variation_attributes( $product->get_id() ) : array();
678
- $passed_validation = $product->is_purchasable() && ( $product->is_in_stock() || $product->backorders_allowed() ) && 'external' !== $product->get_type();
679
- ob_start();
680
- if ( function_exists( 'wc_clear_notices' ) ) {
681
- wc_clear_notices();
682
- }
683
- $passed_validation = apply_filters( 'woocommerce_add_to_cart_validation', $passed_validation, $product_id, $quantity, $variation_id, $variations );
684
- $wc_errors = wc_get_notices( 'error' );
685
- $wc_output = ob_get_clean();
686
- if ( $passed_validation && empty( $wc_errors ) && empty( $wc_output ) ) {
687
- $redirect = false;
688
- }
689
-
690
- TInvWL_Public_Cart::unprepare_post();
691
- }
692
-
693
- return $redirect;
694
- }
695
-
696
- add_filter( 'tinvwl_product_add_to_cart_need_redirect', 'tinvwl_meta_validate_cart_add', 90, 4 );
697
- } // End if().
698
-
699
- if ( ! function_exists( 'tinv_wishlist_print_meta' ) ) {
700
-
701
- /**
702
- * Print meta data for wishlist form
703
- *
704
- * @param array $meta Meta Array.
705
- * @param boolean $flat Return text or template.
706
- *
707
- * @return string
708
- */
709
- function tinv_wishlist_print_meta( $meta = array(), $flat = false ) {
710
- if ( ! is_array( $meta ) ) {
711
- $meta = array();
712
- }
713
- $product_id = $variation_id = 0;
714
- if ( array_key_exists( 'product_id', $meta ) ) {
715
- $product_id = $meta['product_id'];
716
- }
717
- if ( array_key_exists( 'variation_id', $meta ) ) {
718
- $variation_id = $meta['variation_id'];
719
- }
720
- foreach ( array( 'add-to-cart', 'product_id', 'variation_id', 'quantity', 'action', 'variation' ) as $field ) {
721
- if ( array_key_exists( $field, $meta ) ) {
722
- unset( $meta[ $field ] );
723
- }
724
- }
725
- $meta = array_filter( $meta );
726
- if ( empty( $meta ) ) {
727
- return '';
728
- }
729
- $item_data = array();
730
- foreach ( $meta as $key => $value ) {
731
- if ( ! preg_match( '/^\_/', $key ) ) {
732
- $item_data[ $key ] = array(
733
- 'key' => $key,
734
- 'display' => $value,
735
- );
736
- }
737
- }
738
-
739
- foreach ( array_keys( $item_data ) as $key ) {
740
- if ( strpos( $key, 'attribute_' ) === 0 ) {
741
- unset( $item_data[ $key ] );
742
- }
743
- }
744
-
745
- $item_data = apply_filters( 'tinvwl_wishlist_item_meta_post', $item_data, $product_id, $variation_id );
746
- foreach ( $item_data as $key => $data ) {
747
- if ( is_object( $data['display'] ) || is_array( $data['display'] ) ) {
748
- $item_data[ $key ]['display'] = json_encode( $data['display'] );
749
- }
750
- }
751
- ob_start();
752
- if ( $flat ) {
753
- foreach ( $item_data as $data ) {
754
- echo esc_html( $data['key'] ) . ': ' . wp_kses_post( $data['display'] ) . '<br>';
755
- }
756
- } else {
757
- if ( $item_data ) {
758
- tinv_wishlist_template( 'ti-wishlist-item-data.php', array( 'item_data' => $item_data ) );
759
- }
760
- }
761
-
762
- return apply_filters( 'tinvwl_wishlist_item_meta_wishlist', ob_get_clean() );
763
- }
764
- } // End if().
765
-
766
- if ( ! function_exists( 'tinv_wishlistmeta' ) ) {
767
-
768
- /**
769
- * Show new meta data
770
- *
771
- * @param string $meta Print meta.
772
- * @param array $wl_product Wishlist product.
773
- * @param \WC_Product $product Woocommerce product.
774
- *
775
- * @return string
776
- */
777
- function tinv_wishlistmeta( $meta, $wl_product, $product ) {
778
- if ( array_key_exists( 'meta', $wl_product ) ) {
779
- $wlmeta = apply_filters( 'tinvwl_wishlist_item_meta_wishlist_output', tinv_wishlist_print_meta( $wl_product['meta'] ), $wl_product, $product );
780
- }
781
- $meta .= $wlmeta;
782
-
783
- return $meta;
784
- }
785
-
786
- add_filter( 'tinvwl_wishlist_item_meta_data', 'tinv_wishlistmeta', 10, 3 );
787
- }
788
-
789
- if ( ! function_exists( 'tinvwl_add_to_cart_item_meta_post' ) ) {
790
-
791
- /**
792
- * Save post data to cart item
793
- *
794
- * @param array $cart_item_data Array with cart imet information.
795
- * @param string $cart_item_key Cart item key.
796
- *
797
- * @return array
798
- */
799
- function tinvwl_add_to_cart_item_meta_post( $cart_item_data, $cart_item_key ) {
800
- $postdata = $_POST; // @codingStandardsIgnoreLine WordPress.VIP.SuperGlobalInputUsage.AccessDetected
801
-
802
- $postdata = apply_filters( 'tinvwl_product_prepare_meta', $postdata );
803
- if ( array_key_exists( 'variation_id', $postdata ) && ! empty( $postdata['variation_id'] ) ) {
804
- foreach ( $postdata as $key => $field ) {
805
- if ( preg_match( '/^attribute\_/', $key ) ) {
806
- unset( $postdata[ $key ] );
807
- }
808
- }
809
- }
810
- foreach ( array( 'add-to-cart', 'product_id', 'variation_id', 'quantity' ) as $field ) {
811
- if ( array_key_exists( $field, $postdata ) ) {
812
- unset( $postdata[ $field ] );
813
- }
814
- }
815
- $postdata = array_filter( $postdata );
816
- if ( empty( $postdata ) ) {
817
- return $cart_item_data;
818
- }
819
- ksort( $postdata );
820
-
821
- $cart_item_data['tinvwl_formdata'] = $postdata;
822
-
823
- return $cart_item_data;
824
- }
825
-
826
- add_action( 'woocommerce_add_cart_item', 'tinvwl_add_to_cart_item_meta_post', 10, 2 );
827
- } // End if().
828
-
829
- if ( ! function_exists( 'tinvwl_set_utm' ) ) {
830
-
831
- /**
832
- * Set UTM sources.
833
- */
834
- function tinvwl_set_utm() {
835
-
836
- // Forcing partners UTM.
837
- if ( class_exists( 'Ocean_Extra' ) && ! defined( 'TINVWL_PARTNER' ) && ! defined( 'TINVWL_CAMPAIGN' ) ) {
838
- define( 'TINVWL_PARTNER', 'oceanwporg' );
839
- define( 'TINVWL_CAMPAIGN', 'oceanwp_theme' );
840
- }
841
-
842
- // Set a source.
843
- $source = get_option( TINVWL_PREFIX . '_utm_source' );
844
- if ( ! $source || $source !== defined( 'TINVWL_PARTNER' ) ) {
845
- $source = defined( 'TINVWL_PARTNER' ) ? TINVWL_PARTNER : 'wordpress_org';
846
- update_option( TINVWL_PREFIX . '_utm_source', $source );
847
- }
848
-
849
- define( 'TINVWL_UTM_SOURCE', $source );
850
-
851
- // Set a medium.
852
- $medium = get_option( TINVWL_PREFIX . '_utm_medium' );
853
- if ( ! $medium || ( 'organic' === $medium && defined( 'TINVWL_PARTNER' ) ) ) {
854
- $medium = defined( 'TINVWL_PARTNER' ) ? 'integration' : 'organic';
855
- update_option( TINVWL_PREFIX . '_utm_medium', $medium );
856
- }
857
-
858
- define( 'TINVWL_UTM_MEDIUM', $medium );
859
-
860
- // Set a campaign.
861
- $campaign = get_option( TINVWL_PREFIX . '_utm_campaign' );
862
- if ( ! $campaign || $campaign !== defined( 'TINVWL_CAMPAIGN' ) ) {
863
- $campaign = defined( 'TINVWL_PARTNER' ) ? ( defined( 'TINVWL_CAMPAIGN' ) ? TINVWL_CAMPAIGN : TINVWL_PARTNER ) : 'organic';
864
- update_option( TINVWL_PREFIX . '_utm_campaign', $campaign );
865
- }
866
-
867
- define( 'TINVWL_UTM_CAMPAIGN', $campaign );
868
- }
869
- } // End if().
870
-
871
- if ( ! function_exists( 'is_wishlist' ) ) {
872
-
873
- /**
874
- * is_wishlist - Returns true when viewing the wishlist page.
875
- *
876
- * @return bool
877
- */
878
- function is_wishlist() {
879
- return ( is_page( apply_filters( 'wpml_object_id', tinv_get_option( 'page', 'wishlist' ), 'page', true ) ) );
880
- }
881
- }
882
-
883
- if ( ! function_exists( 'tinvwl_get_wishlist_products' ) ) {
884
- /**
885
- * Get wishlist products for default user wishlist or by ID or SHAREKEY
886
- *
887
- * @param int $wishlist_id by ID or SHAREKEY, 0 = default wishlist of current user
888
- * @param array $data query parameters for get() method of TInvWL_Product() class.
889
- *
890
- * @return array|bool
891
- */
892
- function tinvwl_get_wishlist_products( $wishlist_id = 0, $data = array() ) {
893
- $wishlist = tinv_wishlist_get( $wishlist_id );
894
- if ( empty( $wishlist ) ) {
895
- return false;
896
- }
897
- $wlp = new TInvWL_Product( $wishlist );
898
- $products = $wlp->get_wishlist( $data );
899
-
900
- if ( empty( $products ) ) {
901
- return false;
902
- }
903
-
904
- return $products;
905
- }
906
- }
907
-
908
- add_action( 'init', function () {
909
- if ( ! is_user_logged_in() ) {
910
- add_filter( 'nonce_user_logged_out', function ( $uid, $action = - 1 ) {
911
- if ( $action === 'wp_rest' ) {
912
- return get_current_user_id();
913
- }
914
-
915
- return $uid;
916
- }, 99, 2 );
917
- }
918
- } );
 
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
+ $wc_errors = wc_get_notices( 'error' );
686
+ $wc_output = ob_get_clean();
687
+ if ( $passed_validation && empty( $wc_errors ) && empty( $wc_output ) ) {
688
+ $redirect = false;
689
+ }
690
+
691
+ TInvWL_Public_Cart::unprepare_post();
692
+ }
693
+
694
+ return $redirect;
695
+ }
696
+
697
+ add_filter( 'tinvwl_product_add_to_cart_need_redirect', 'tinvwl_meta_validate_cart_add', 90, 4 );
698
+ } // End if().
699
+
700
+ if ( ! function_exists( 'tinv_wishlist_print_meta' ) ) {
701
+
702
+ /**
703
+ * Print meta data for wishlist form
704
+ *
705
+ * @param array $meta Meta Array.
706
+ * @param boolean $flat Return text or template.
707
+ *
708
+ * @return string
709
+ */
710
+ function tinv_wishlist_print_meta( $meta = array(), $flat = false ) {
711
+ if ( ! is_array( $meta ) ) {
712
+ $meta = array();
713
+ }
714
+ $product_id = $variation_id = 0;
715
+ if ( array_key_exists( 'product_id', $meta ) ) {
716
+ $product_id = $meta['product_id'];
717
+ }
718
+ if ( array_key_exists( 'variation_id', $meta ) ) {
719
+ $variation_id = $meta['variation_id'];
720
+ }
721
+ foreach ( array( 'add-to-cart', 'product_id', 'variation_id', 'quantity', 'action', 'variation' ) as $field ) {
722
+ if ( array_key_exists( $field, $meta ) ) {
723
+ unset( $meta[ $field ] );
724
+ }
725
+ }
726
+ $meta = array_filter( $meta );
727
+ if ( empty( $meta ) ) {
728
+ return '';
729
+ }
730
+ $item_data = array();
731
+ foreach ( $meta as $key => $value ) {
732
+ if ( ! preg_match( '/^\_/', $key ) ) {
733
+ $item_data[ $key ] = array(
734
+ 'key' => $key,
735
+ 'display' => $value,
736
+ );
737
+ }
738
+ }
739
+
740
+ foreach ( array_keys( $item_data ) as $key ) {
741
+ if ( strpos( $key, 'attribute_' ) === 0 ) {
742
+ unset( $item_data[ $key ] );
743
+ }
744
+ }
745
+
746
+ $item_data = apply_filters( 'tinvwl_wishlist_item_meta_post', $item_data, $product_id, $variation_id );
747
+ foreach ( $item_data as $key => $data ) {
748
+ if ( is_object( $data['display'] ) || is_array( $data['display'] ) ) {
749
+ $item_data[ $key ]['display'] = json_encode( $data['display'] );
750
+ }
751
+ }
752
+ ob_start();
753
+ if ( $flat ) {
754
+ foreach ( $item_data as $data ) {
755
+ echo esc_html( $data['key'] ) . ': ' . wp_kses_post( $data['display'] ) . '<br>';
756
+ }
757
+ } else {
758
+ if ( $item_data ) {
759
+ tinv_wishlist_template( 'ti-wishlist-item-data.php', array( 'item_data' => $item_data ) );
760
+ }
761
+ }
762
+
763
+ return apply_filters( 'tinvwl_wishlist_item_meta_wishlist', ob_get_clean() );
764
+ }
765
+ } // End if().
766
+
767
+ if ( ! function_exists( 'tinv_wishlistmeta' ) ) {
768
+
769
+ /**
770
+ * Show new meta data
771
+ *
772
+ * @param string $meta Print meta.
773
+ * @param array $wl_product Wishlist product.
774
+ * @param \WC_Product $product Woocommerce product.
775
+ *
776
+ * @return string
777
+ */
778
+ function tinv_wishlistmeta( $meta, $wl_product, $product ) {
779
+ if ( array_key_exists( 'meta', $wl_product ) ) {
780
+ $wlmeta = apply_filters( 'tinvwl_wishlist_item_meta_wishlist_output', tinv_wishlist_print_meta( $wl_product['meta'] ), $wl_product, $product );
781
+ }
782
+ $meta .= $wlmeta;
783
+
784
+ return $meta;
785
+ }
786
+
787
+ add_filter( 'tinvwl_wishlist_item_meta_data', 'tinv_wishlistmeta', 10, 3 );
788
+ }
789
+
790
+ if ( ! function_exists( 'tinvwl_add_to_cart_item_meta_post' ) ) {
791
+
792
+ /**
793
+ * Save post data to cart item
794
+ *
795
+ * @param array $cart_item_data Array with cart imet information.
796
+ * @param string $cart_item_key Cart item key.
797
+ *
798
+ * @return array
799
+ */
800
+ function tinvwl_add_to_cart_item_meta_post( $cart_item_data, $cart_item_key ) {
801
+ $postdata = $_POST; // @codingStandardsIgnoreLine WordPress.VIP.SuperGlobalInputUsage.AccessDetected
802
+
803
+ $postdata = apply_filters( 'tinvwl_product_prepare_meta', $postdata );
804
+ if ( array_key_exists( 'variation_id', $postdata ) && ! empty( $postdata['variation_id'] ) ) {
805
+ foreach ( $postdata as $key => $field ) {
806
+ if ( preg_match( '/^attribute\_/', $key ) ) {
807
+ unset( $postdata[ $key ] );
808
+ }
809
+ }
810
+ }
811
+ foreach ( array( 'add-to-cart', 'product_id', 'variation_id', 'quantity' ) as $field ) {
812
+ if ( array_key_exists( $field, $postdata ) ) {
813
+ unset( $postdata[ $field ] );
814
+ }
815
+ }
816
+ $postdata = array_filter( $postdata );
817
+ if ( empty( $postdata ) ) {
818
+ return $cart_item_data;
819
+ }
820
+ ksort( $postdata );
821
+
822
+ $cart_item_data['tinvwl_formdata'] = $postdata;
823
+
824
+ return $cart_item_data;
825
+ }
826
+
827
+ add_action( 'woocommerce_add_cart_item', 'tinvwl_add_to_cart_item_meta_post', 10, 2 );
828
+ } // End if().
829
+
830
+ if ( ! function_exists( 'tinvwl_set_utm' ) ) {
831
+
832
+ /**
833
+ * Set UTM sources.
834
+ */
835
+ function tinvwl_set_utm() {
836
+
837
+ // Forcing partners UTM.
838
+ if ( class_exists( 'Ocean_Extra' ) && ! defined( 'TINVWL_PARTNER' ) && ! defined( 'TINVWL_CAMPAIGN' ) ) {
839
+ define( 'TINVWL_PARTNER', 'oceanwporg' );
840
+ define( 'TINVWL_CAMPAIGN', 'oceanwp_theme' );
841
+ }
842
+
843
+ // Set a source.
844
+ $source = get_option( TINVWL_PREFIX . '_utm_source' );
845
+ if ( ! $source || $source !== defined( 'TINVWL_PARTNER' ) ) {
846
+ $source = defined( 'TINVWL_PARTNER' ) ? TINVWL_PARTNER : 'wordpress_org';
847
+ update_option( TINVWL_PREFIX . '_utm_source', $source );
848
+ }
849
+
850
+ define( 'TINVWL_UTM_SOURCE', $source );
851
+
852
+ // Set a medium.
853
+ $medium = get_option( TINVWL_PREFIX . '_utm_medium' );
854
+ if ( ! $medium || ( 'organic' === $medium && defined( 'TINVWL_PARTNER' ) ) ) {
855
+ $medium = defined( 'TINVWL_PARTNER' ) ? 'integration' : 'organic';
856
+ update_option( TINVWL_PREFIX . '_utm_medium', $medium );
857
+ }
858
+
859
+ define( 'TINVWL_UTM_MEDIUM', $medium );
860
+
861
+ // Set a campaign.
862
+ $campaign = get_option( TINVWL_PREFIX . '_utm_campaign' );
863
+ if ( ! $campaign || $campaign !== defined( 'TINVWL_CAMPAIGN' ) ) {
864
+ $campaign = defined( 'TINVWL_PARTNER' ) ? ( defined( 'TINVWL_CAMPAIGN' ) ? TINVWL_CAMPAIGN : TINVWL_PARTNER ) : 'organic';
865
+ update_option( TINVWL_PREFIX . '_utm_campaign', $campaign );
866
+ }
867
+
868
+ define( 'TINVWL_UTM_CAMPAIGN', $campaign );
869
+ }
870
+ } // End if().
871
+
872
+ if ( ! function_exists( 'is_wishlist' ) ) {
873
+
874
+ /**
875
+ * is_wishlist - Returns true when viewing the wishlist page.
876
+ *
877
+ * @return bool
878
+ */
879
+ function is_wishlist() {
880
+ return ( is_page( apply_filters( 'wpml_object_id', tinv_get_option( 'page', 'wishlist' ), 'page', true ) ) );
881
+ }
882
+ }
883
+
884
+ if ( ! function_exists( 'tinvwl_get_wishlist_products' ) ) {
885
+ /**
886
+ * Get wishlist products for default user wishlist or by ID or SHAREKEY
887
+ *
888
+ * @param int $wishlist_id by ID or SHAREKEY, 0 = default wishlist of current user
889
+ * @param array $data query parameters for get() method of TInvWL_Product() class.
890
+ *
891
+ * @return array|bool
892
+ */
893
+ function tinvwl_get_wishlist_products( $wishlist_id = 0, $data = array() ) {
894
+ $wishlist = tinv_wishlist_get( $wishlist_id );
895
+ if ( empty( $wishlist ) ) {
896
+ return false;
897
+ }
898
+ $wlp = new TInvWL_Product( $wishlist );
899
+ $products = $wlp->get_wishlist( $data );
900
+
901
+ if ( empty( $products ) ) {
902
+ return false;
903
+ }
904
+
905
+ return $products;
906
+ }
907
+ }
908
+
909
+ add_action( 'init', function () {
910
+ if ( ! is_user_logged_in() ) {
911
+ add_filter( 'nonce_user_logged_out', function ( $uid, $action = - 1 ) {
912
+ if ( $action === 'wp_rest' ) {
913
+ return get_current_user_id();
914
+ }
915
+
916
+ return $uid;
917
+ }, 99, 2 );
918
+ }
919
+ } );