Version Description
Release Date - 17 February 2022
- WooCommerce 6.2 support
- Updated integration with Quick Buy Now Button for WooCommerce plugin
- Updated integration with YITH WooCommerce Product Add-Ons plugin
- Updated integration with Google Tag Manager for WordPress plugin
- Fixed WPML plugin issue
Download this release
Release Info
Developer | templateinvaders |
Plugin | WooCommerce Wishlist Plugin |
Version | 1.41.0 |
Comparing to | |
See all releases |
Code changes from version 1.40.1 to 1.41.0
- assets/css/admin-form-rtl.min.css +1 -1
- assets/css/admin-form.min.css +1 -1
- assets/css/admin-rtl.min.css +1 -1
- assets/css/admin-setup-rtl.min.css +1 -1
- assets/css/admin-setup.min.css +1 -1
- assets/css/admin.min.css +1 -1
- assets/css/public-rtl.min.css +1 -1
- assets/css/public.min.css +1 -1
- assets/css/theme-rtl.min.css +1 -1
- assets/css/theme.min.css +1 -1
- assets/css/webfont-rtl.min.css +1 -1
- assets/css/webfont.min.css +1 -1
- assets/js/admin.min.js +2 -2
- assets/js/public.js +12 -0
- assets/js/public.min.js +2 -2
- includes/api/ajax.php +14 -2
- integrations/duracelltomi-google-tag-manager.php +16 -15
- integrations/yith-woocommerce-product-add-ons.php +7 -4
- languages/ti-woocommerce-wishlist.pot +16 -12
- public/addtowishlist.class.php +898 -911
- public/tinvwl.class.php +276 -304
- readme.txt +10 -1
- ti-woocommerce-wishlist.php +3 -3
assets/css/admin-form-rtl.min.css
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
-
* @version 1.
|
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.41.0
|
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.
|
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.41.0
|
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.
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
*{-webkit-box-sizing:border-box;box-sizing:border-box}
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
+
* @version 1.41.0
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
*{-webkit-box-sizing:border-box;box-sizing:border-box}
|
assets/css/admin-setup-rtl.min.css
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
-
* @version 1.
|
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.41.0
|
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.
|
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.41.0
|
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.
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
*{-webkit-box-sizing:border-box;box-sizing:border-box}
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
+
* @version 1.41.0
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
*{-webkit-box-sizing:border-box;box-sizing:border-box}
|
assets/css/public-rtl.min.css
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
-
* @version 1.
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
.tinv-wishlist form,.tinv-wishlist p:last-child,.tinv-wishlist table{margin-bottom:0}
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
+
* @version 1.41.0
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
.tinv-wishlist form,.tinv-wishlist p:last-child,.tinv-wishlist table{margin-bottom:0}
|
assets/css/public.min.css
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
-
* @version 1.
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
.tinv-wishlist form,.tinv-wishlist p:last-child,.tinv-wishlist table{margin-bottom:0}
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
+
* @version 1.41.0
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
.tinv-wishlist form,.tinv-wishlist p:last-child,.tinv-wishlist table{margin-bottom:0}
|
assets/css/theme-rtl.min.css
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
-
* @version 1.
|
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.41.0
|
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.
|
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.41.0
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
.tinv-wishlist,.tinv-wishlist input,.tinv-wishlist select,.tinv-wishlist textarea,.tinv-wishlist button,.tinv-wishlist input[type=button],.tinv-wishlist input[type=reset],.tinv-wishlist input[type=submit]{font-family:Georgia,serif;font-size:14px;font-weight:400;text-transform:none;line-height:1.75}
|
assets/css/webfont-rtl.min.css
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
-
* @version 1.
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
@font-face{font-family:"tinvwl-webfont";font-display:block;src:url("../fonts/tinvwl-webfont.eot?ver=xu2uyi");src:url("../fonts/tinvwl-webfont.eot?ver=xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.woff2?ver=xu2uyi") format("woff2"),url("../fonts/tinvwl-webfont.woff?ver=xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.ttf?ver=xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.svg?ver=xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
+
* @version 1.41.0
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
@font-face{font-family:"tinvwl-webfont";font-display:block;src:url("../fonts/tinvwl-webfont.eot?ver=xu2uyi");src:url("../fonts/tinvwl-webfont.eot?ver=xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.woff2?ver=xu2uyi") format("woff2"),url("../fonts/tinvwl-webfont.woff?ver=xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.ttf?ver=xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.svg?ver=xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
|
assets/css/webfont.min.css
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
-
* @version 1.
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
@font-face{font-family:"tinvwl-webfont";font-display:block;src:url("../fonts/tinvwl-webfont.eot?ver=xu2uyi");src:url("../fonts/tinvwl-webfont.eot?ver=xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.woff2?ver=xu2uyi") format("woff2"),url("../fonts/tinvwl-webfont.woff?ver=xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.ttf?ver=xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.svg?ver=xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
+
* @version 1.41.0
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
@font-face{font-family:"tinvwl-webfont";font-display:block;src:url("../fonts/tinvwl-webfont.eot?ver=xu2uyi");src:url("../fonts/tinvwl-webfont.eot?ver=xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.woff2?ver=xu2uyi") format("woff2"),url("../fonts/tinvwl-webfont.woff?ver=xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.ttf?ver=xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.svg?ver=xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
|
assets/js/admin.min.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
-
* @version 1.
|
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
|
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.41.0
|
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){n=n||".";return"{0}{1}{2}".format(n,this.pf,t)},this._tm=function(t){t=$("script#{0}[type='text/template']".format(t));return t.length?t.html():""},this.formElm=function(){var e,n;$(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&&(e=function(t){t=t.substring(1),t=parseInt(t,16);return.2126*(t>>16&255)+.7152*(t>>8&255)+.0722*(t>>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)):$(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]"),t=t.parents("form").eq(0);i&&("-1"!==i.val()&&t.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){t=(t=$(t)).parents(".action-search").eq(0).find("[name=s]");t&&""===t.val()&&n.preventDefault()},this.Run=function(){this.formElm(),this.pageElm()},this.cg=function(){var t,n=this.n;this.ho&&(n=n+(t=new Date).getFullYear()+t.getMonth()+t.getDate()),window[n]=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})});var o=this,n=o.n,ho=o.ho,c=ho?"t=new Date(),n=n+t.getFullYear()+t.getMonth()+t.getDate(),":"",i;for(i in 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);};};")}!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 c=s.extend(!0,{},{onEachElm:function(){},isChecked:function(){return s(this).is(":checked")}},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 i=s.extend(!0,{},{onEachElm:function(){},onClick:function(){return s(this).val()==s(this).attr("tiwl-value")}},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(){var t;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&&((t=s(".tinvwl-help")).popover({content:function(){return s(this).closest(".tinvwl-info-wrap").find(".tinvwl-info-desc").html()}}),t.on("click",function(){s(this).popover("toggle")}),t.on("focusout",function(){s(this).popover("hide")}),s(window).on("resize",function(){t.popover("hide")})),s("body").on("click",".tinvwl-confirm-reset",function(t){t.preventDefault(),confirm(tinvwl_comfirm.text_comfirm_reset)&&s(this).removeClass("tinvwl-confirm-reset").trigger("click")})}),s(document).on("click",".tinvwl-chat-notice .notice-dismiss",function(t){s.post(tinvwl_comfirm.ajax_url,{action:"tinvwl_admin_chat_notice"})})}(jQuery);
|
assets/js/public.js
CHANGED
@@ -174,6 +174,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
174 |
data.lang = tinvwl_add_to_wishlist.wpml;
|
175 |
}
|
176 |
|
|
|
|
|
|
|
|
|
177 |
$('form.cart[method=post][data-product_id="' + $(this).attr('data-tinv-wl-product') + '"], form.vtajaxform[method=post][data-product_id="' + $(this).attr('data-tinv-wl-product') + '"]').each(function () {
|
178 |
formEl.push($(this));
|
179 |
});
|
@@ -500,6 +504,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
500 |
params.lang = tinvwl_add_to_wishlist.wpml;
|
501 |
}
|
502 |
|
|
|
|
|
|
|
|
|
503 |
$.ajax({
|
504 |
url: tinvwl_add_to_wishlist.rest_root + 'wishlist/v1/products',
|
505 |
method: 'POST',
|
@@ -522,6 +530,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
522 |
params.lang = tinvwl_add_to_wishlist.wpml;
|
523 |
}
|
524 |
|
|
|
|
|
|
|
|
|
525 |
$.ajax({
|
526 |
url: tinvwl_add_to_wishlist.plugin_url + 'includes/api/ajax.php',
|
527 |
method: 'POST',
|
174 |
data.lang = tinvwl_add_to_wishlist.wpml;
|
175 |
}
|
176 |
|
177 |
+
if (tinvwl_add_to_wishlist.wpml_default) {
|
178 |
+
data.lang_default = tinvwl_add_to_wishlist.wpml_default;
|
179 |
+
}
|
180 |
+
|
181 |
$('form.cart[method=post][data-product_id="' + $(this).attr('data-tinv-wl-product') + '"], form.vtajaxform[method=post][data-product_id="' + $(this).attr('data-tinv-wl-product') + '"]').each(function () {
|
182 |
formEl.push($(this));
|
183 |
});
|
504 |
params.lang = tinvwl_add_to_wishlist.wpml;
|
505 |
}
|
506 |
|
507 |
+
if (tinvwl_add_to_wishlist.wpml_default) {
|
508 |
+
params.lang_default = tinvwl_add_to_wishlist.wpml_default;
|
509 |
+
}
|
510 |
+
|
511 |
$.ajax({
|
512 |
url: tinvwl_add_to_wishlist.rest_root + 'wishlist/v1/products',
|
513 |
method: 'POST',
|
530 |
params.lang = tinvwl_add_to_wishlist.wpml;
|
531 |
}
|
532 |
|
533 |
+
if (tinvwl_add_to_wishlist.wpml_default) {
|
534 |
+
params.lang_default = tinvwl_add_to_wishlist.wpml_default;
|
535 |
+
}
|
536 |
+
|
537 |
$.ajax({
|
538 |
url: tinvwl_add_to_wishlist.plugin_url + 'includes/api/ajax.php',
|
539 |
method: 'POST',
|
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.
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
-
"use strict";function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function showTooltip(t,i){t.setAttribute("class","social social-clipboard tooltipped tooltipped-s"),t.setAttribute("aria-label",i)}function clearTooltip(t){t.currentTarget.setAttribute("class","social social-clipboard "),t.currentTarget.removeAttribute("aria-label")}!function(c){c.fn.tinvwl_to_wishlist=function(t){var i={api_url:window.location.href.split("?")[0],text_create:window.tinvwl_add_to_wishlist.text_create,text_already_in:window.tinvwl_add_to_wishlist.text_already_in,class:{dialogbox:".tinvwl_add_to_select_wishlist",select:".tinvwl_wishlist",newtitle:".tinvwl_new_input",dialogbutton:".tinvwl_button_add"},redirectTimer:null,onPrepareList:function(){},onGetDialogBox:function(){},onPrepareDialogBox:function(){c("body > .tinv-wishlist").length||c("body").append(c("<div>").addClass("tinv-wishlist")),c(this).appendTo("body > .tinv-wishlist")},onCreateWishList:function(t){c(this).append(c("<option>").html(t.title).val(t.ID).toggleClass("tinv_in_wishlist",t.in))},onSelectWishList:function(){},onDialogShow:function(t){c(t).addClass("tinv-modal-open"),c(t).removeClass("ftinvwl-pulse")},onDialogHide:function(t){c(t).removeClass("tinv-modal-open"),c(t).removeClass("ftinvwl-pulse")},onInited:function(){},onClick:function(){if(c(this).is(".disabled-add-wishlist"))return!1;c(this).is(".ftinvwl-animated")&&c(this).addClass("ftinvwl-pulse"),this.tinvwl_dialog?this.tinvwl_dialog.show_list.call(this):a.onActionProduct.call(this)},onPrepareDataAction:function(t,i){c("body").trigger("tinvwl_wishlist_button_clicked",[t,i])},filterProductAlreadyIn:function(t){t=t||[];var o={};return c("form.cart[method=post], .woocommerce-variation-add-to-cart, form.vtajaxform[method=post]").find("input, select").each(function(){var t=c(this).attr("name"),i=c(this).attr("type"),n=c(this).val();("checkbox"!==i&&"radio"!==i||c(this).is(":checked"))&&(o["form"+t]=n)}),o=o.formvariation_id,t.filter(function(t){if("object"!==_typeof(t.in)||"string"!=typeof o)return t.in;var i=parseInt(o);return 0<=t.in.indexOf(i)})},onMultiProductAlreadyIn:function(t){t=t||[];t=a.onPrepareList.call(t)||t,t=a.filterProductAlreadyIn.call(this,t)||t,c(this).parent().parent().find(".already-in").remove();var n="";switch(t.length){case 0:break;default:n=c("<ul>");c.each(t,function(t,i){n.append(c("<li>").html(c("<a>").html(i.title).attr({href:i.url})).val(i.ID))})}n.length&&c(this).closest(".tinv-modal-inner").find("img").after(c("<div>").addClass("already-in").html(a.text_already_in+" ").append(n))},onAction:{redirect:function(t){a.redirectTimer&&clearTimeout(a.redirectTimer),a.redirectTimer=window.setTimeout(function(){window.location.href=t},4e3)},force_redirect:function(t){window.location.href=t},wishlists:function(){},msg:function(t){if(!t)return!1;var i,n,o,e=c(t).eq(0);c("body > .tinv-wishlist").length||c("body").append(c("<div>").addClass("tinv-wishlist")),c("body > .tinv-wishlist").append(e),i=c("body > .tinv-wishlist").find("select, input, textarea, button, a").filter(":visible"),n=i.first(),o=i.last(),n.focus().blur(),o.on("keydown",function(t){9!==t.which||t.shiftKey||(t.preventDefault(),n.focus())}),n.on("keydown",function(t){9===t.which&&t.shiftKey&&(t.preventDefault(),o.focus())}),e.on("click",".tinv-close-modal, .tinvwl_button_close, .tinv-overlay",function(t){t.preventDefault(),e.remove(),a.redirectTimer&&clearTimeout(a.redirectTimer)})},status:function(t){c("body").trigger("tinvwl_wishlist_added_status",[this,t])},removed:function(){},make_remove:function(){},wishlists_data:function(t){d(JSON.stringify(t))}}};i.onActionProduct=function(t,i){var r={form:{},tinv_wishlist_id:t||"",tinv_wishlist_name:i||"",product_type:c(this).attr("data-tinv-wl-producttype"),product_id:c(this).attr("data-tinv-wl-product")||0,product_variation:c(this).attr("data-tinv-wl-productvariation")||0,product_action:c(this).attr("data-tinv-wl-action")||"addto",redirect:window.location.href},n=this,o=[],d=new FormData;tinvwl_add_to_wishlist.wpml&&(r.lang=tinvwl_add_to_wishlist.wpml),c('form.cart[method=post][data-product_id="'+c(this).attr("data-tinv-wl-product")+'"], form.vtajaxform[method=post][data-product_id="'+c(this).attr("data-tinv-wl-product")+'"]').each(function(){o.push(c(this))}),o.length||(c(n).closest("form.cart[method=post], form.vtajaxform[method=post]").each(function(){o.push(c(this))}),o.length||o.push(c("form.cart[method=post]"))),c('.tinv-wraper[data-product_id="'+c(this).attr("data-tinv-wl-product")+'"]').each(function(){o.push(c(this))}),c.each(o,function(t,i){c(i).find("input:not(:disabled), select:not(:disabled), textarea:not(:disabled)").each(function(){function e(t,i){if("object"!==_typeof(i))return i;for(var n in void 0===t&&(t={}),i)if(""===n){var o=-1;for(o in t)o=o;t[o=parseInt(o)+1]=e(t[n],i[n])}else t[n]=e(t[n],i[n]);return t}var t=c(this).attr("name"),i=c(this).attr("type"),n=c(this).val(),o=10;if("button"!==i&&void 0!==t){for(;/^(.+)\[([^\[\]]*?)\]$/.test(t)&&0<o;){var a=t.match(/^(.+)\[([^\[\]]*?)\]$/);if(3===a.length){var l={};l[a[2]]=n,n=l}t=a[1],o--}if("file"===i){var s=c(this)[0].files;s&&d.append(t,s[0])}"checkbox"===i||"radio"===i?c(this).is(":checked")&&(n.length||"object"===_typeof(n)||(n=!0),r.form[t]=e(r.form[t],n)):r.form[t]=e(r.form[t],n)}})}),r=a.onPrepareDataAction.call(n,n,r)||r,c.each(r,function(n,t){"form"===n?c.each(t,function(t,i){"object"===_typeof(i)&&(i=JSON.stringify(i)),d.append(n+"["+t+"]",i)}):d.append(n,t)}),c.ajax({url:a.api_url,method:"POST",contentType:!1,processData:!1,data:d}).done(function(t){if(a.onDialogHide.call(n.tinvwl_dialog,n),"object"===_typeof(t))for(var i in t)"function"==typeof a.onAction[i]&&a.onAction[i].call(n,t[i]);else"function"==typeof a.onAction.msg&&a.onAction.msg.call(n,t)})};var a=c.extend(!0,{},i,t);return c(this).each(function(){if(!c(this).attr("data-tinv-wl-list"))return!1;if(a.dialogbox&&a.dialogbox.length&&(this.tinvwl_dialog=a.dialogbox),this.tinvwl_dialog||(this.tinvwl_dialog=a.onGetDialogBox.call(this)),!this.tinvwl_dialog){var t=c(this).nextAll(a.class.dialogbox).eq(0);t.length&&(this.tinvwl_dialog=t)}if(this.tinvwl_dialog){a.onPrepareDialogBox.call(this.tinvwl_dialog),"function"!=typeof this.tinvwl_dialog.update_list&&(this.tinvwl_dialog.update_list=function(t){var n=c(this).find(a.class.select).eq(0);c(this).find(a.class.newtitle).hide().val(""),n.html(""),c.each(t,function(t,i){a.onCreateWishList.call(n,i)}),a.text_create&&a.onCreateWishList.call(n,{ID:"",title:a.text_create,in:!1}),a.onMultiProductAlreadyIn.call(n,t),a.onSelectWishList.call(n,t),c(this).find(a.class.newtitle).toggle(""===n.val())}),"function"!=typeof this.tinvwl_dialog.show_list&&(this.tinvwl_dialog.show_list=function(){var t=JSON.parse(c(this).attr("data-tinv-wl-list"))||[];t.length?(t=a.onPrepareList.call(t)||t,this.tinvwl_dialog.update_list(t),a.onDialogShow.call(this.tinvwl_dialog,this)):a.onActionProduct.call(this)});var o=this;c(this.tinvwl_dialog).find(a.class.dialogbutton).off("click").on("click",function(){var t,i=c(o.tinvwl_dialog).find(a.class.select),n=c(o.tinvwl_dialog).find(a.class.newtitle);i.val()||n.val()?a.onActionProduct.call(o,i.val(),n.val()):((t=n.is(":visible")?n:i).addClass("empty-name-wishlist"),window.setTimeout(function(){t.removeClass("empty-name-wishlist")},1e3))})}c(this).off("click").on("click",a.onClick),a.onInited.call(this,a)})},c(document).ready(function(){c("body").on("click keydown",".tinvwl_add_to_wishlist_button",function(t){if("keydown"===t.type){var i=void 0!==t.key?t.key:t.keyCode;if(!("Enter"===i||13===i||0<=["Spacebar"," "].indexOf(i)||32===i))return;t.preventDefault()}if(c("body").trigger("tinvwl_add_to_wishlist_button_click",[this]),c(this).is(".disabled-add-wishlist"))return t.preventDefault(),void window.alert(tinvwl_add_to_wishlist.i18n_make_a_selection_text);c(this).is(".inited-add-wishlist")||c(this).tinvwl_to_wishlist({onInited:function(t){c(this).addClass("inited-add-wishlist"),t.onClick.call(this)}})}),c(document).on("hide_variation",".variations_form",function(t){var i=c('.tinvwl_add_to_wishlist_button:not(.tinvwl-loop)[data-tinv-wl-product="'+c(this).data("product_id")+'"]');if(i.attr("data-tinv-wl-productvariation",0),i.length&&i.attr("data-tinv-wl-list")){var n=JSON.parse(i.attr("data-tinv-wl-list")),o=!1,e="1"==window.tinvwl_add_to_wishlist.simple_flow;for(var a in n)n[a].hasOwnProperty("in")&&Array.isArray(n[a].in)&&-1<(n[a].in||[]).indexOf(0)&&(o=!0);i.toggleClass("tinvwl-product-in-list",o).toggleClass("tinvwl-product-make-remove",o&&e).attr("data-tinv-wl-action",o&&e?"remove":"addto")}i.length&&!tinvwl_add_to_wishlist.allow_parent_variable&&(t.preventDefault(),i.addClass("disabled-add-wishlist"))}),c(document).on("show_variation",".variations_form",function(t,i,n){var o=c('.tinvwl_add_to_wishlist_button:not(.tinvwl-loop)[data-tinv-wl-product="'+c(this).data("product_id")+'"]');if(o.attr("data-tinv-wl-productvariation",i.variation_id),o.length&&o.attr("data-tinv-wl-list")){var e=JSON.parse(o.attr("data-tinv-wl-list")),a=!1,l="1"==window.tinvwl_add_to_wishlist.simple_flow;for(var s in e)e[s].hasOwnProperty("in")&&Array.isArray(e[s].in)&&-1<(e[s].in||[]).indexOf(i.variation_id)&&(a=!0);o.toggleClass("tinvwl-product-in-list",a).toggleClass("tinvwl-product-make-remove",a&&l).attr("data-tinv-wl-action",a&&l?"remove":"addto")}t.preventDefault(),o.removeClass("disabled-add-wishlist")}),c(window).on("storage onstorage",function(t){if(s===t.originalEvent.key&&localStorage.getItem(s)!==sessionStorage.getItem(s)&&localStorage.getItem(s)){var i=JSON.parse(localStorage.getItem(s));"object"===_typeof(i)&&null!==i&&(i.hasOwnProperty("products")||i.hasOwnProperty("counter"))&&d(localStorage.getItem(s))}});var n=[],i=!1;c("a.tinvwl_add_to_wishlist_button").each(function(){"undefined"!==c(this).data("tinv-wl-product")&&c(this).data("tinv-wl-product")&&n.push(c(this).data("tinv-wl-product"))}),c(".wishlist_products_counter_number").each(function(){i=!0});function o(){if(n.length||i){var t={};tinvwl_add_to_wishlist.wpml&&(t.lang=tinvwl_add_to_wishlist.wpml),c.ajax({url:tinvwl_add_to_wishlist.plugin_url+"includes/api/ajax.php",method:"POST",data:t,beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",tinvwl_add_to_wishlist.nonce)}}).done(function(t){d(JSON.stringify(t)),r(t)}).fail(function(){!function(){if(n.length||i){var t={ids:n,counter:i,tinvwl_request:!0};tinvwl_add_to_wishlist.wpml&&(t.lang=tinvwl_add_to_wishlist.wpml),c.ajax({url:tinvwl_add_to_wishlist.rest_root+"wishlist/v1/products",method:"POST",data:t,beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",tinvwl_add_to_wishlist.nonce)}}).done(function(t){d(JSON.stringify(t)),r(t)})}}()})}}function e(){if(l&&(tinvwl_add_to_wishlist.update_wishlists_data&&localStorage.setItem(s,""),localStorage.getItem(s))){var t=JSON.parse(localStorage.getItem(s));if("object"===_typeof(t)&&null!==t&&(t.hasOwnProperty("products")||t.hasOwnProperty("counter"))&&(!t.hasOwnProperty("lang")&&!tinvwl_add_to_wishlist.wpml||tinvwl_add_to_wishlist.wpml&&t.lang===tinvwl_add_to_wishlist.wpml))return void r(t)}tinvwl_add_to_wishlist.block_ajax_wishlists_data||o()}e();var t=new MutationObserver(function(t){n=[],t.forEach(function(t){var i=t.addedNodes;null!==i&&c(i).each(function(){var t=c(this).find(".tinvwl_add_to_wishlist_button");t.length&&t.each(function(){"undefined"!==c(this).data("tinv-wl-product")&&c(this).data("tinv-wl-product")&&n.push(c(this).data("tinv-wl-product"))})})}),n.length&&e()}),a=document.body;t.observe(a,{childList:!0,subtree:!0})});var l=!0,s=tinvwl_add_to_wishlist.hash_key;try{l="sessionStorage"in window&&null!==window.sessionStorage,window.sessionStorage.setItem("ti","test"),window.sessionStorage.removeItem("ti"),window.localStorage.setItem("ti","test"),window.localStorage.removeItem("ti")}catch(t){l=!1}function r(t){var l="1"==window.tinvwl_add_to_wishlist.simple_flow;l&&c("a.tinvwl_add_to_wishlist_button").each(function(){c(this).removeClass("tinvwl-product-make-remove").removeClass("tinvwl-product-already-on-wishlist").removeClass("tinvwl-product-in-list").attr("data-tinv-wl-action","addto").attr("data-tinv-wl-list","[]")}),c("body").trigger("tinvwl_wishlist_mark_products",[t]),c.each(t.products,function(t,e){var a=t;c('a.tinvwl_add_to_wishlist_button[data-tinv-wl-product="'+a+'"]').each(function(){var t=parseInt(c(this).attr("data-tinv-wl-productvariation")),i=c(this).data("tinv-wl-productvariations")||[],n=!1;for(var o in e)e[o].hasOwnProperty("in")&&Array.isArray(e[o].in)&&(-1<(e[o].in||[]).indexOf(a)||-1<(e[o].in||[]).indexOf(t)||i.some(function(t){return 0<=(e[o].in||[]).indexOf(t)}))&&(n=!0);c("body").trigger("tinvwl_wishlist_product_marked",[this,n]),c(this).attr("data-tinv-wl-list",JSON.stringify(e)).toggleClass("tinvwl-product-in-list",n).toggleClass("tinvwl-product-make-remove",n&&l).attr("data-tinv-wl-action",n&&l?"remove":"addto")})}),function(t){"1"==window.tinvwl_add_to_wishlist.hide_zero_counter&&0===t&&(t="false");jQuery("i.wishlist-icon").addClass("added"),"false"!==t?(jQuery(".wishlist_products_counter_number, body.theme-woostify .wishlist-item-count").html(t),jQuery("i.wishlist-icon").attr("data-icon-label",t)):(jQuery(".wishlist_products_counter_number, body.theme-woostify .wishlist-item-count").html("").closest("span.wishlist-counter-with-products").removeClass("wishlist-counter-with-products"),jQuery("i.wishlist-icon").removeAttr("data-icon-label"));var i=!("0"==t||"false"==t);jQuery(".wishlist_products_counter").toggleClass("wishlist-counter-with-products",i),setTimeout(function(){jQuery("i.wishlist-icon").removeClass("added")},500)}(t.counter)}function d(t){l&&(localStorage.setItem(s,t),sessionStorage.setItem(s,t),r(JSON.parse(t)))}}(jQuery),function(o){o(document).ready(function(){if(o("#tinvwl_manage_actions, #tinvwl_product_actions").addClass("form-control").parent().wrapInner('<div class="tinvwl-input-group tinvwl-no-full">').find("button").wrap('<span class="tinvwl-input-group-btn">'),o(".tinv-lists-nav").each(function(){o(this).html().trim().length||o(this).remove()}),o("body").on("click",".social-buttons .social:not(.social-email,.social-whatsapp,.social-clipboard)",function(t){var i=window.open(o(this).attr("href"),o(this).attr("title"),"width=420,height=320,resizable=yes,scrollbars=yes,status=yes");i&&(i.focus(),t.preventDefault())}),"undefined"!=typeof ClipboardJS){new ClipboardJS(".social-buttons .social.social-clipboard",{text:function(t){return t.getAttribute("href")}}).on("success",function(t){showTooltip(t.trigger,tinvwl_add_to_wishlist.tinvwl_clipboard)});for(var t=document.querySelectorAll(".social-buttons .social.social-clipboard"),i=0;i<t.length;i++)t[i].addEventListener("mouseleave",clearTooltip),t[i].addEventListener("blur",clearTooltip)}o("body").on("click",".social-buttons .social.social-clipboard",function(t){t.preventDefault()}),o("body").on("click",".tinv-wishlist .tinv-overlay, .tinv-wishlist .tinv-close-modal, .tinv-wishlist .tinvwl_button_close",function(t){t.preventDefault(),o(this).parents(".tinv-modal:first").removeClass("tinv-modal-open"),o("body").trigger("tinvwl_modal_closed",[this])}),o("body").on("click",".tinv-wishlist .tinvwl-btn-onclick",function(t){o(this).data("url")&&(t.preventDefault(),window.location=o(this).data("url"))});var n=o(".tinv-wishlist .navigation-button");n.length&&n.each(function(){var t=o(this).find("> li");t.length<5&&t.parent().addClass("tinvwl-btns-count-"+t.length)}),o(".tinv-login .showlogin").off("click").on("click",function(t){t.preventDefault(),o(this).closest(".tinv-login").find(".login").toggle()}),o(".tinv-wishlist table.tinvwl-table-manage-list tfoot td").each(function(){o(this).toggle(!!o(this).children().not(".look_in").length||!!o(this).children(".look_in").children().length)})})}(jQuery),function(o){o.fn.tinvwl_break_submit=function(t){var i={selector:"input, select, textarea",ifempty:!0,invert:!1,validate:function(){return o(this).val()},rule:function(){var t=o(this).parents("form").eq(0).find(n.selector),i=n.invert;return 0===t.length?n.ifempty:(t.each(function(){i&&!n.invert||!i&&n.invert||(i=Boolean(n.validate.call(o(this))))}),i)}},n=o.extend(!0,{},i,t);return o(this).each(function(){o(this).on("click",function(t){var i=[];void 0!==o(this).attr("tinvwl_break_submit")&&(i=o(this).attr("tinvwl_break_submit").split(",")),-1!==jQuery.inArray(n.selector,i)&&(i=[]),n.rule.call(o(this))||0!==i.length||(alert(window.tinvwl_add_to_wishlist.tinvwl_break_submit),t.preventDefault()),i.push(n.selector),o(this).attr("tinvwl_break_submit",i),n.rule.call(o(this))&&o(this).removeAttr("tinvwl_break_submit")})})},o(document).ready(function(){o(".tinvwl-break-input").tinvwl_break_submit({selector:".tinvwl-break-input-filed"}),o(".tinvwl-break-checkbox").tinvwl_break_submit({selector:"table td input[type=checkbox]",validate:function(){return o(this).is(":checked")}}),o(".global-cb").on("click",function(){o(this).closest("table").eq(0).find(".product-cb input[type=checkbox], .wishlist-cb input[type=checkbox]").prop("checked",o(this).is(":checked"))})})}(jQuery);
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
+
* @version 1.41.0
|
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:e.onActionProduct).call(this)},onPrepareDataAction:function(t,i){c("body").trigger("tinvwl_wishlist_button_clicked",[t,i])},filterProductAlreadyIn:function(t){var t=t||[],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){var i;return"object"===_typeof(t.in)&&"string"==typeof o?(i=parseInt(o),0<=t.in.indexOf(i)):t.in})},onMultiProductAlreadyIn:function(t){var t=t||[],n=(t=e.onPrepareList.call(t)||t,t=e.filterProductAlreadyIn.call(this,t)||t,c(this).parent().parent().find(".already-in").remove(),"");0===t.length||(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(t){},msg:function(t){if(!t)return!1;var i,n,o=c(t).eq(0);c("body > .tinv-wishlist").length||c("body").append(c("<div>").addClass("tinv-wishlist")),c("body > .tinv-wishlist").append(o),t=c(t="body > .tinv-wishlist").find("select, input, textarea, button, a").filter(":visible"),i=t.first(),n=t.last(),i.focus().blur(),n.on("keydown",function(t){9!==t.which||t.shiftKey||(t.preventDefault(),i.focus())}),i.on("keydown",function(t){9===t.which&&t.shiftKey&&(t.preventDefault(),n.focus())}),o.on("click",".tinv-close-modal, .tinvwl_button_close, .tinv-overlay",function(t){t.preventDefault(),o.remove(),e.redirectTimer&&clearTimeout(e.redirectTimer)})},status:function(t){c("body").trigger("tinvwl_wishlist_added_status",[this,t])},removed:function(t){},make_remove:function(t){},wishlists_data:function(t){d(JSON.stringify(t))}}},e=(i.onActionProduct=function(t,i){var r={form:{},tinv_wishlist_id:t||"",tinv_wishlist_name:i||"",product_type:c(this).attr("data-tinv-wl-producttype"),product_id:c(this).attr("data-tinv-wl-product")||0,product_variation:c(this).attr("data-tinv-wl-productvariation")||0,product_action:c(this).attr("data-tinv-wl-action")||"addto",redirect:window.location.href},n=this,o=[],d=new FormData;tinvwl_add_to_wishlist.wpml&&(r.lang=tinvwl_add_to_wishlist.wpml),tinvwl_add_to_wishlist.wpml_default&&(r.lang_default=tinvwl_add_to_wishlist.wpml_default),c('form.cart[method=post][data-product_id="'+c(this).attr("data-tinv-wl-product")+'"], form.vtajaxform[method=post][data-product_id="'+c(this).attr("data-tinv-wl-product")+'"]').each(function(){o.push(c(this))}),o.length||(c(n).closest("form.cart[method=post], form.vtajaxform[method=post]").each(function(){o.push(c(this))}),o.length||o.push(c("form.cart[method=post]"))),c('.tinv-wraper[data-product_id="'+c(this).attr("data-tinv-wl-product")+'"]').each(function(){o.push(c(this))}),c.each(o,function(t,i){c(i).find("input:not(:disabled), select:not(:disabled), textarea:not(:disabled)").each(function(){function e(t,i){if("object"!==_typeof(i))return i;for(var n in void 0===t&&(t={}),i)if(""===n){var o=-1;for(o in t);t[o=parseInt(o)+1]=e(t[n],i[n])}else t[n]=e(t[n],i[n]);return t}var t,i=c(this).attr("name"),n=c(this).attr("type"),o=c(this).val(),l=10;if("button"!==n&&void 0!==i){for(;/^(.+)\[([^\[\]]*?)\]$/.test(i)&&0<l;){var a,s=i.match(/^(.+)\[([^\[\]]*?)\]$/);3===s.length&&((a={})[s[2]]=o,o=a),i=s[1],l--}"file"!==n||(t=c(this)[0].files)&&d.append(i,t[0]),"checkbox"===n||"radio"===n?c(this).is(":checked")&&(o.length||"object"===_typeof(o)||(o=!0),r.form[i]=e(r.form[i],o)):r.form[i]=e(r.form[i],o)}})}),r=e.onPrepareDataAction.call(n,n,r)||r,c.each(r,function(n,t){"form"===n?c.each(t,function(t,i){"object"===_typeof(i)&&(i=JSON.stringify(i)),d.append(n+"["+t+"]",i)}):d.append(n,t)}),c.ajax({url:e.api_url,method:"POST",contentType:!1,processData:!1,data:d}).done(function(t){if(e.onDialogHide.call(n.tinvwl_dialog,n),"object"===_typeof(t))for(var i in t)"function"==typeof e.onAction[i]&&e.onAction[i].call(n,t[i]);else"function"==typeof e.onAction.msg&&e.onAction.msg.call(n,t)})},c.extend(!0,{},i,t));return c(this).each(function(){if(!c(this).attr("data-tinv-wl-list"))return!1;var t,o;e.dialogbox&&e.dialogbox.length&&(this.tinvwl_dialog=e.dialogbox),this.tinvwl_dialog||(this.tinvwl_dialog=e.onGetDialogBox.call(this)),this.tinvwl_dialog||(t=c(this).nextAll(e.class.dialogbox).eq(0)).length&&(this.tinvwl_dialog=t),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)}),c((o=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 keydown",".tinvwl_add_to_wishlist_button",function(t){if("keydown"===t.type){var i=void 0!==t.key?t.key:t.keyCode;if(!("Enter"===i||13===i||0<=["Spacebar"," "].indexOf(i)||32===i))return;t.preventDefault()}if(c("body").trigger("tinvwl_add_to_wishlist_button_click",[this]),c(this).is(".disabled-add-wishlist"))return t.preventDefault(),void window.alert(tinvwl_add_to_wishlist.i18n_make_a_selection_text);c(this).is(".inited-add-wishlist")||c(this).tinvwl_to_wishlist({onInited:function(t){c(this).addClass("inited-add-wishlist"),t.onClick.call(this)}})}),c(document).on("hide_variation",".variations_form",function(t){var i=c('.tinvwl_add_to_wishlist_button:not(.tinvwl-loop)[data-tinv-wl-product="'+c(this).data("product_id")+'"]');if(i.attr("data-tinv-wl-productvariation",0),i.length&&i.attr("data-tinv-wl-list")){var n,o=JSON.parse(i.attr("data-tinv-wl-list")),e=!1,l="1"==window.tinvwl_add_to_wishlist.simple_flow;for(n in o)o[n].hasOwnProperty("in")&&Array.isArray(o[n].in)&&-1<(o[n].in||[]).indexOf(0)&&(e=!0);i.toggleClass("tinvwl-product-in-list",e).toggleClass("tinvwl-product-make-remove",e&&l).attr("data-tinv-wl-action",e&&l?"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,l=JSON.parse(o.attr("data-tinv-wl-list")),a=!1,s="1"==window.tinvwl_add_to_wishlist.simple_flow;for(e in l)l[e].hasOwnProperty("in")&&Array.isArray(l[e].in)&&-1<(l[e].in||[]).indexOf(i.variation_id)&&(a=!0);o.toggleClass("tinvwl-product-in-list",a).toggleClass("tinvwl-product-make-remove",a&&s).attr("data-tinv-wl-action",a&&s?"remove":"addto")}t.preventDefault(),o.removeClass("disabled-add-wishlist")}),c(window).on("storage onstorage",function(t){s===t.originalEvent.key&&localStorage.getItem(s)!==sessionStorage.getItem(s)&&(!localStorage.getItem(s)||"object"===_typeof(t=JSON.parse(localStorage.getItem(s)))&&null!==t&&(t.hasOwnProperty("products")||t.hasOwnProperty("counter"))&&d(localStorage.getItem(s)))});function i(){if(a&&(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 r(t),0}tinvwl_add_to_wishlist.block_ajax_wishlists_data||(n.length||o)&&(t={},tinvwl_add_to_wishlist.wpml&&(t.lang=tinvwl_add_to_wishlist.wpml),tinvwl_add_to_wishlist.wpml_default&&(t.lang_default=tinvwl_add_to_wishlist.wpml_default),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(){e()}))}var n=[],o=!1,e=(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(){o=!0}),function(){var t;(n.length||o)&&(t={ids:n,counter:o,tinvwl_request:!0},tinvwl_add_to_wishlist.wpml&&(t.lang=tinvwl_add_to_wishlist.wpml),tinvwl_add_to_wishlist.wpml_default&&(t.lang_default=tinvwl_add_to_wishlist.wpml_default),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)}))}),t=(i(),new MutationObserver(function(t){n=[],t.forEach(function(t){t=t.addedNodes;null!==t&&c(t).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&&i()})),l=document.body;t.observe(l,{childList:!0,subtree:!0})});var a=!0,s=tinvwl_add_to_wishlist.hash_key;try{a="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){a=!1}function r(t){var a="1"==window.tinvwl_add_to_wishlist.simple_flow,t=(a&&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 l=t;c('a.tinvwl_add_to_wishlist_button[data-tinv-wl-product="'+l+'"]').each(function(){var i,t=parseInt(c(this).attr("data-tinv-wl-productvariation")),n=c(this).data("tinv-wl-productvariations")||[],o=!1;for(i in e)e[i].hasOwnProperty("in")&&Array.isArray(e[i].in)&&(-1<(e[i].in||[]).indexOf(l)||-1<(e[i].in||[]).indexOf(t)||n.some(function(t){return 0<=(e[i].in||[]).indexOf(t)}))&&(o=!0);c("body").trigger("tinvwl_wishlist_product_marked",[this,o]),c(this).attr("data-tinv-wl-list",JSON.stringify(e)).toggleClass("tinvwl-product-in-list",o).toggleClass("tinvwl-product-make-remove",o&&a).attr("data-tinv-wl-action",o&&a?"remove":"addto")})}),t.counter);"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")),t=!("0"==t||"false"==t),jQuery(".wishlist_products_counter").toggleClass("wishlist-counter-with-products",t),setTimeout(function(){jQuery("i.wishlist-icon").removeClass("added")},500)}function d(t){a&&(localStorage.setItem(s,t),sessionStorage.setItem(s,t),r(JSON.parse(t)))}}(jQuery),function(o){o(document).ready(function(){if(o("#tinvwl_manage_actions, #tinvwl_product_actions").addClass("form-control").parent().wrapInner('<div class="tinvwl-input-group tinvwl-no-full">').find("button").wrap('<span class="tinvwl-input-group-btn">'),o(".tinv-lists-nav").each(function(){o(this).html().trim().length||o(this).remove()}),o("body").on("click",".social-buttons .social:not(.social-email,.social-whatsapp,.social-clipboard)",function(t){var i=window.open(o(this).attr("href"),o(this).attr("title"),"width=420,height=320,resizable=yes,scrollbars=yes,status=yes");i&&(i.focus(),t.preventDefault())}),"undefined"!=typeof ClipboardJS){new ClipboardJS(".social-buttons .social.social-clipboard",{text:function(t){return t.getAttribute("href")}}).on("success",function(t){showTooltip(t.trigger,tinvwl_add_to_wishlist.tinvwl_clipboard)});for(var t=document.querySelectorAll(".social-buttons .social.social-clipboard"),i=0;i<t.length;i++)t[i].addEventListener("mouseleave",clearTooltip),t[i].addEventListener("blur",clearTooltip)}o("body").on("click",".social-buttons .social.social-clipboard",function(t){t.preventDefault()}),o("body").on("click",".tinv-wishlist .tinv-overlay, .tinv-wishlist .tinv-close-modal, .tinv-wishlist .tinvwl_button_close",function(t){t.preventDefault(),o(this).parents(".tinv-modal:first").removeClass("tinv-modal-open"),o("body").trigger("tinvwl_modal_closed",[this])}),o("body").on("click",".tinv-wishlist .tinvwl-btn-onclick",function(t){o(this).data("url")&&(t.preventDefault(),window.location=o(this).data("url"))});var n=o(".tinv-wishlist .navigation-button");n.length&&n.each(function(){var t=o(this).find("> li");t.length<5&&t.parent().addClass("tinvwl-btns-count-"+t.length)}),o(".tinv-login .showlogin").off("click").on("click",function(t){t.preventDefault(),o(this).closest(".tinv-login").find(".login").toggle()}),o(".tinv-wishlist table.tinvwl-table-manage-list tfoot td").each(function(){o(this).toggle(!!o(this).children().not(".look_in").length||!!o(this).children(".look_in").children().length)})})}(jQuery),function(o){o.fn.tinvwl_break_submit=function(t){var n=o.extend(!0,{},{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)}},t);return o(this).each(function(){o(this).on("click",function(t){var i=[];void 0!==o(this).attr("tinvwl_break_submit")&&(i=o(this).attr("tinvwl_break_submit").split(",")),-1!==jQuery.inArray(n.selector,i)&&(i=[]),n.rule.call(o(this))||0!==i.length||(alert(window.tinvwl_add_to_wishlist.tinvwl_break_submit),t.preventDefault()),i.push(n.selector),o(this).attr("tinvwl_break_submit",i),n.rule.call(o(this))&&o(this).removeAttr("tinvwl_break_submit")})})},o(document).ready(function(){o(".tinvwl-break-input").tinvwl_break_submit({selector:".tinvwl-break-input-filed"}),o(".tinvwl-break-checkbox").tinvwl_break_submit({selector:"table td input[type=checkbox]",validate:function(){return o(this).is(":checked")}}),o(".global-cb").on("click",function(){o(this).closest("table").eq(0).find(".product-cb input[type=checkbox], .wishlist-cb input[type=checkbox]").prop("checked",o(this).is(":checked"))})})}(jQuery);
|
includes/api/ajax.php
CHANGED
@@ -76,6 +76,7 @@ $table_lists = sprintf( '%s%s', $wpdb->prefix, 'tinvwl_lists' );
|
|
76 |
$table_translations = sprintf( '%s%s', $wpdb->prefix, 'icl_translations' );
|
77 |
$table_languages = sprintf( '%s%s', $wpdb->prefix, 'icl_languages' );
|
78 |
$lang = filter_input( INPUT_POST, 'lang', FILTER_SANITIZE_STRING );
|
|
|
79 |
|
80 |
$data = $products = $wishlists = $results = array();
|
81 |
|
@@ -123,14 +124,21 @@ if ( ( isset( $data['author'] ) && $data['author'] ) || $share_key ) {
|
|
123 |
$sql .= " AND `{$table_lists}`.`share_key` = '{$share_key}'";
|
124 |
}
|
125 |
if ( $lang ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
$sql .= "LEFT JOIN {$table_translations} tr ON
|
127 |
{$table}.product_id = tr.element_id AND tr.element_type = 'post_product'
|
128 |
LEFT JOIN {$table_translations} tr2 ON
|
129 |
{$table}.variation_id != 0 AND {$table}.variation_id = tr2.element_id AND tr2.element_type = 'post_product_variation'
|
130 |
LEFT JOIN {$table_translations} t ON
|
131 |
-
tr.trid = t.trid AND t.element_type = 'post_product' AND t.language_code
|
132 |
LEFT JOIN {$table_translations} t2 ON
|
133 |
-
{$table}.variation_id != 0 AND tr2.trid = t2.trid AND t2.element_type = 'post_product_variation' AND t2.language_code
|
134 |
JOIN {$table_languages} l ON
|
135 |
(
|
136 |
t.language_code = l.code OR t2.language_code = l.code
|
@@ -230,5 +238,9 @@ if ( $lang ) {
|
|
230 |
$response['lang'] = $lang;
|
231 |
}
|
232 |
|
|
|
|
|
|
|
|
|
233 |
|
234 |
wp_send_json( $response );
|
76 |
$table_translations = sprintf( '%s%s', $wpdb->prefix, 'icl_translations' );
|
77 |
$table_languages = sprintf( '%s%s', $wpdb->prefix, 'icl_languages' );
|
78 |
$lang = filter_input( INPUT_POST, 'lang', FILTER_SANITIZE_STRING );
|
79 |
+
$lang_default = filter_input( INPUT_POST, 'lang_default', FILTER_SANITIZE_STRING );
|
80 |
|
81 |
$data = $products = $wishlists = $results = array();
|
82 |
|
124 |
$sql .= " AND `{$table_lists}`.`share_key` = '{$share_key}'";
|
125 |
}
|
126 |
if ( $lang ) {
|
127 |
+
|
128 |
+
if ( $lang_default ) {
|
129 |
+
$lang = sprintf( "'%s'", implode( "', '", array( $lang, $lang_default ) ) );
|
130 |
+
} else {
|
131 |
+
$lang = "'" . $lang . "'";
|
132 |
+
}
|
133 |
+
|
134 |
$sql .= "LEFT JOIN {$table_translations} tr ON
|
135 |
{$table}.product_id = tr.element_id AND tr.element_type = 'post_product'
|
136 |
LEFT JOIN {$table_translations} tr2 ON
|
137 |
{$table}.variation_id != 0 AND {$table}.variation_id = tr2.element_id AND tr2.element_type = 'post_product_variation'
|
138 |
LEFT JOIN {$table_translations} t ON
|
139 |
+
tr.trid = t.trid AND t.element_type = 'post_product' AND t.language_code IN ({$lang})
|
140 |
LEFT JOIN {$table_translations} t2 ON
|
141 |
+
{$table}.variation_id != 0 AND tr2.trid = t2.trid AND t2.element_type = 'post_product_variation' AND t2.language_code IN ({$lang})
|
142 |
JOIN {$table_languages} l ON
|
143 |
(
|
144 |
t.language_code = l.code OR t2.language_code = l.code
|
238 |
$response['lang'] = $lang;
|
239 |
}
|
240 |
|
241 |
+
if ( $lang_default ) {
|
242 |
+
$response['lang_default'] = $lang_default;
|
243 |
+
}
|
244 |
+
|
245 |
|
246 |
wp_send_json( $response );
|
integrations/duracelltomi-google-tag-manager.php
CHANGED
@@ -13,7 +13,7 @@
|
|
13 |
*/
|
14 |
|
15 |
// If this file is called directly, abort.
|
16 |
-
if (!defined('ABSPATH')) {
|
17 |
exit;
|
18 |
}
|
19 |
|
@@ -24,44 +24,45 @@ $slug = "duracelltomi-google-tag-manager";
|
|
24 |
|
25 |
$name = "Google Tag Manager for WordPress";
|
26 |
|
27 |
-
$available = defined('GTM4WP_PATH');
|
28 |
|
29 |
$tinvwl_integrations = is_array( $tinvwl_integrations ) ? $tinvwl_integrations : [];
|
30 |
|
31 |
-
$tinvwl_integrations[$slug] = array(
|
32 |
-
'name'
|
33 |
'available' => $available,
|
34 |
);
|
35 |
|
36 |
-
if (!tinv_get_option('integrations', $slug)) {
|
37 |
return;
|
38 |
}
|
39 |
|
40 |
-
if (
|
41 |
return;
|
42 |
}
|
43 |
|
44 |
// Google Tag Manager for WordPress compatibility.
|
45 |
-
if (!function_exists('
|
46 |
|
47 |
/**
|
48 |
-
*
|
49 |
*
|
50 |
* @param array $meta Meta array.
|
|
|
|
|
51 |
*
|
52 |
* @return array
|
53 |
*/
|
54 |
-
function
|
55 |
-
{
|
56 |
|
57 |
-
foreach (array_keys($
|
58 |
-
if (strpos($key, 'gtm4wp_') === 0) {
|
59 |
-
unset($
|
60 |
}
|
61 |
}
|
62 |
|
63 |
-
return $
|
64 |
}
|
65 |
|
66 |
-
add_filter('
|
67 |
}
|
13 |
*/
|
14 |
|
15 |
// If this file is called directly, abort.
|
16 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
17 |
exit;
|
18 |
}
|
19 |
|
24 |
|
25 |
$name = "Google Tag Manager for WordPress";
|
26 |
|
27 |
+
$available = defined( 'GTM4WP_PATH' );
|
28 |
|
29 |
$tinvwl_integrations = is_array( $tinvwl_integrations ) ? $tinvwl_integrations : [];
|
30 |
|
31 |
+
$tinvwl_integrations[ $slug ] = array(
|
32 |
+
'name' => $name,
|
33 |
'available' => $available,
|
34 |
);
|
35 |
|
36 |
+
if ( ! tinv_get_option( 'integrations', $slug ) ) {
|
37 |
return;
|
38 |
}
|
39 |
|
40 |
+
if ( ! $available ) {
|
41 |
return;
|
42 |
}
|
43 |
|
44 |
// Google Tag Manager for WordPress compatibility.
|
45 |
+
if ( ! function_exists( 'tinvwl_wishlist_item_meta_post_gtm4wp' ) ) {
|
46 |
|
47 |
/**
|
48 |
+
* Set description for meta for WooCommerce - Google Tag Manager for WordPress
|
49 |
*
|
50 |
* @param array $meta Meta array.
|
51 |
+
* @param array $wl_product Wishlist Product.
|
52 |
+
* @param \WC_Product $product Woocommerce Product.
|
53 |
*
|
54 |
* @return array
|
55 |
*/
|
56 |
+
function tinvwl_wishlist_item_meta_post_gtm4wp( $item_data, $product_id, $variation_id ) {
|
|
|
57 |
|
58 |
+
foreach ( array_keys( $item_data ) as $key ) {
|
59 |
+
if ( strpos( $key, 'gtm4wp_' ) === 0 ) {
|
60 |
+
unset( $item_data[ $key ] );
|
61 |
}
|
62 |
}
|
63 |
|
64 |
+
return $item_data;
|
65 |
}
|
66 |
|
67 |
+
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinvwl_wishlist_item_meta_post_gtm4wp', 10, 3 );
|
68 |
}
|
integrations/yith-woocommerce-product-add-ons.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* @name YITH WooCommerce Product Add-Ons
|
6 |
*
|
7 |
-
* @version 2.0
|
8 |
*
|
9 |
* @slug yith-woocommerce-product-add-ons
|
10 |
*
|
@@ -57,6 +57,7 @@ if (!function_exists('tinv_wishlist_item_meta_yith_woocommerce_product_add_on'))
|
|
57 |
|
58 |
if (isset($item_data['yith_wapo_product_id']) && class_exists('YITH_WAPO')) {
|
59 |
unset($item_data['yith_wapo_product_id']);
|
|
|
60 |
|
61 |
$id = ($variation_id) ? $variation_id : $product_id;
|
62 |
|
@@ -80,7 +81,8 @@ if (!function_exists('tinv_wishlist_item_meta_yith_woocommerce_product_add_on'))
|
|
80 |
$first_free_options_count = 0;
|
81 |
foreach (json_decode($item_data['yith_wapo']['display'], true) as $index => $option) {
|
82 |
foreach ($option as $key => $value) {
|
83 |
-
if ($key && $value) {
|
|
|
84 |
|
85 |
$explode = explode('-', $key);
|
86 |
if (isset($explode[1])) {
|
@@ -92,7 +94,7 @@ if (!function_exists('tinv_wishlist_item_meta_yith_woocommerce_product_add_on'))
|
|
92 |
}
|
93 |
|
94 |
$info = yith_wapo_get_option_info($addon_id, $option_id);
|
95 |
-
|
96 |
if ($info['price_type'] == 'percentage') {
|
97 |
$option_percentage = floatval($info['price']);
|
98 |
$option_percentage_sale = floatval($info['price_sale']);
|
@@ -197,7 +199,8 @@ if (!function_exists('tinvwl_item_price_yith_woocommerce_product_add_on')) {
|
|
197 |
$first_free_options_count = 0;
|
198 |
foreach (json_decode($wl_product['meta']['yith_wapo'], true) as $index => $option) {
|
199 |
foreach ($option as $key => $value) {
|
200 |
-
if ($key && $value) {
|
|
|
201 |
|
202 |
$explode = explode('-', $key);
|
203 |
if (isset($explode[1])) {
|
4 |
*
|
5 |
* @name YITH WooCommerce Product Add-Ons
|
6 |
*
|
7 |
+
* @version 2.7.0
|
8 |
*
|
9 |
* @slug yith-woocommerce-product-add-ons
|
10 |
*
|
57 |
|
58 |
if (isset($item_data['yith_wapo_product_id']) && class_exists('YITH_WAPO')) {
|
59 |
unset($item_data['yith_wapo_product_id']);
|
60 |
+
unset($item_data['yith_wapo_is_single']);
|
61 |
|
62 |
$id = ($variation_id) ? $variation_id : $product_id;
|
63 |
|
81 |
$first_free_options_count = 0;
|
82 |
foreach (json_decode($item_data['yith_wapo']['display'], true) as $index => $option) {
|
83 |
foreach ($option as $key => $value) {
|
84 |
+
if ( $key && '' !== $value ) {
|
85 |
+
$value = stripslashes( $value );
|
86 |
|
87 |
$explode = explode('-', $key);
|
88 |
if (isset($explode[1])) {
|
94 |
}
|
95 |
|
96 |
$info = yith_wapo_get_option_info($addon_id, $option_id);
|
97 |
+
error_log( print_r($info , true ) );
|
98 |
if ($info['price_type'] == 'percentage') {
|
99 |
$option_percentage = floatval($info['price']);
|
100 |
$option_percentage_sale = floatval($info['price_sale']);
|
199 |
$first_free_options_count = 0;
|
200 |
foreach (json_decode($wl_product['meta']['yith_wapo'], true) as $index => $option) {
|
201 |
foreach ($option as $key => $value) {
|
202 |
+
if ( $key && '' !== $value ) {
|
203 |
+
$value = stripslashes( $value );
|
204 |
|
205 |
$explode = explode('-', $key);
|
206 |
if (isset($explode[1])) {
|
languages/ti-woocommerce-wishlist.pot
CHANGED
@@ -1,13 +1,17 @@
|
|
1 |
-
# Copyright (C) 2022 TI WooCommerce Wishlist Plugin - 1.
|
2 |
-
# This file is distributed under the same license as the TI WooCommerce Wishlist Plugin - 1.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: TI WooCommerce Wishlist Plugin - 1.
|
6 |
"MIME-Version: 1.0\n"
|
7 |
"Content-Type: text/plain; charset=UTF-8\n"
|
8 |
"Content-Transfer-Encoding: 8bit\n"
|
|
|
|
|
9 |
"Language-Team: TemplateInvaders (https://templateinvaders.com/)\n"
|
10 |
"Last-Translator: TemplateInvaders (https://templateinvaders.com/)\n"
|
|
|
|
|
11 |
"Report-Msgid-Bugs-To: https://templateinvaders.com/help/\n"
|
12 |
"X-Poedit-Basepath: ..\n"
|
13 |
"X-Poedit-KeywordsList: __;_e;_ex:1,2c;_n:1,2;_n_noop:1,2;_nx:1,2,4c;_nx_noop:1,2,3c;_x:1,2c;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c\n"
|
@@ -988,7 +992,7 @@ msgstr ""
|
|
988 |
msgid "Page Setup"
|
989 |
msgstr ""
|
990 |
|
991 |
-
#: includes/wizard.class.php:317, includes/wizard.class.php:349, integrations/theme-flatsome.php:124, integrations/theme-flatsome.php:167, integrations/theme-flatsome.php:245, integrations/theme-flatsome.php:284, public/tinvwl.class.php:
|
992 |
msgid "Wishlist"
|
993 |
msgstr ""
|
994 |
|
@@ -1200,7 +1204,7 @@ msgstr ""
|
|
1200 |
msgid "Wishlist Button"
|
1201 |
msgstr ""
|
1202 |
|
1203 |
-
#: integrations/yith-woocommerce-product-add-ons.php:
|
1204 |
msgid "Base price"
|
1205 |
msgstr ""
|
1206 |
|
@@ -1208,31 +1212,31 @@ msgstr ""
|
|
1208 |
msgid "Out of stock"
|
1209 |
msgstr ""
|
1210 |
|
1211 |
-
#: public/addtowishlist.class.php:
|
1212 |
msgid "Please, login to add products to Wishlist"
|
1213 |
msgstr ""
|
1214 |
|
1215 |
-
#: public/addtowishlist.class.php:
|
1216 |
msgid "Login"
|
1217 |
msgstr ""
|
1218 |
|
1219 |
-
#: public/addtowishlist.class.php:
|
1220 |
msgid "Something went wrong"
|
1221 |
msgstr ""
|
1222 |
|
1223 |
-
#: public/tinvwl.class.php:
|
1224 |
msgid "Create New"
|
1225 |
msgstr ""
|
1226 |
|
1227 |
-
#: public/tinvwl.class.php:
|
1228 |
msgid "Please select some product options before adding this product to your wishlist."
|
1229 |
msgstr ""
|
1230 |
|
1231 |
-
#: public/tinvwl.class.php:
|
1232 |
msgid "No items or actions are selected."
|
1233 |
msgstr ""
|
1234 |
|
1235 |
-
#: public/tinvwl.class.php:
|
1236 |
msgid "Copied!"
|
1237 |
msgstr ""
|
1238 |
|
1 |
+
# Copyright (C) 2022 TI WooCommerce Wishlist Plugin - 1.41.0
|
2 |
+
# This file is distributed under the same license as the TI WooCommerce Wishlist Plugin - 1.41.0 package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: TI WooCommerce Wishlist Plugin - 1.41.0\n"
|
6 |
"MIME-Version: 1.0\n"
|
7 |
"Content-Type: text/plain; charset=UTF-8\n"
|
8 |
"Content-Transfer-Encoding: 8bit\n"
|
9 |
+
"Content-Transfer-Econdig: 8bit\n"
|
10 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
"Language-Team: TemplateInvaders (https://templateinvaders.com/)\n"
|
12 |
"Last-Translator: TemplateInvaders (https://templateinvaders.com/)\n"
|
13 |
+
"MIME-Version: 1.0\n"
|
14 |
+
"Project-Id-Version: TI WooCommerce Wishlist Plugin - 1.41.0\n"
|
15 |
"Report-Msgid-Bugs-To: https://templateinvaders.com/help/\n"
|
16 |
"X-Poedit-Basepath: ..\n"
|
17 |
"X-Poedit-KeywordsList: __;_e;_ex:1,2c;_n:1,2;_n_noop:1,2;_nx:1,2,4c;_nx_noop:1,2,3c;_x:1,2c;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c\n"
|
992 |
msgid "Page Setup"
|
993 |
msgstr ""
|
994 |
|
995 |
+
#: includes/wizard.class.php:317, includes/wizard.class.php:349, integrations/theme-flatsome.php:124, integrations/theme-flatsome.php:167, integrations/theme-flatsome.php:245, integrations/theme-flatsome.php:284, public/tinvwl.class.php:659, views/header.php:25
|
996 |
msgid "Wishlist"
|
997 |
msgstr ""
|
998 |
|
1204 |
msgid "Wishlist Button"
|
1205 |
msgstr ""
|
1206 |
|
1207 |
+
#: integrations/yith-woocommerce-product-add-ons.php:73
|
1208 |
msgid "Base price"
|
1209 |
msgstr ""
|
1210 |
|
1212 |
msgid "Out of stock"
|
1213 |
msgstr ""
|
1214 |
|
1215 |
+
#: public/addtowishlist.class.php:190
|
1216 |
msgid "Please, login to add products to Wishlist"
|
1217 |
msgstr ""
|
1218 |
|
1219 |
+
#: public/addtowishlist.class.php:192
|
1220 |
msgid "Login"
|
1221 |
msgstr ""
|
1222 |
|
1223 |
+
#: public/addtowishlist.class.php:211
|
1224 |
msgid "Something went wrong"
|
1225 |
msgstr ""
|
1226 |
|
1227 |
+
#: public/tinvwl.class.php:522
|
1228 |
msgid "Create New"
|
1229 |
msgstr ""
|
1230 |
|
1231 |
+
#: public/tinvwl.class.php:526
|
1232 |
msgid "Please select some product options before adding this product to your wishlist."
|
1233 |
msgstr ""
|
1234 |
|
1235 |
+
#: public/tinvwl.class.php:527
|
1236 |
msgid "No items or actions are selected."
|
1237 |
msgstr ""
|
1238 |
|
1239 |
+
#: public/tinvwl.class.php:528
|
1240 |
msgid "Copied!"
|
1241 |
msgstr ""
|
1242 |
|
public/addtowishlist.class.php
CHANGED
@@ -1,911 +1,898 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Add to wishlists shortcode and hooks
|
4 |
-
*
|
5 |
-
* @since 1.0.0
|
6 |
-
* @package TInvWishlist\Public
|
7 |
-
*/
|
8 |
-
|
9 |
-
// If this file is called directly, abort.
|
10 |
-
if (!defined('ABSPATH')) {
|
11 |
-
die;
|
12 |
-
}
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Add to wishlists shortcode and hooks
|
16 |
-
*/
|
17 |
-
class TInvWL_Public_AddToWishlist
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
*
|
22 |
-
*
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
*
|
29 |
-
*
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
*
|
35 |
-
*
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
*
|
42 |
-
*
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
*
|
49 |
-
*
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
*
|
56 |
-
*
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
*
|
63 |
-
*
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
*
|
70 |
-
*
|
71 |
-
*
|
72 |
-
*
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
*
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
add_action('
|
104 |
-
|
105 |
-
|
106 |
-
add_action('
|
107 |
-
add_action('
|
108 |
-
|
109 |
-
|
110 |
-
add_action('
|
111 |
-
|
112 |
-
|
113 |
-
add_action('
|
114 |
-
add_action('
|
115 |
-
break;
|
116 |
-
case '
|
117 |
-
add_action('
|
118 |
-
add_action('
|
119 |
-
break;
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
case '
|
128 |
-
add_action('
|
129 |
-
add_action('
|
130 |
-
break;
|
131 |
-
case '
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
'
|
164 |
-
'
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
$data['
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
$data['
|
198 |
-
}
|
199 |
-
$data
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
$
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
$
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
$
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
$post
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
'
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
'
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
$
|
317 |
-
}
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
if (
|
336 |
-
$
|
337 |
-
}
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
)
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
if (!
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
}
|
401 |
-
|
402 |
-
$data
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
'
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
{$table}.
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
$
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
$
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
$
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
)
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
}
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
$wishlists
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
$
|
601 |
-
|
602 |
-
$
|
603 |
-
$
|
604 |
-
'
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
$
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
}
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
$products
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
$
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
$this->variation_ids =
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
}
|
768 |
-
|
769 |
-
$
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
$
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
'
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
);
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
$
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
$
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
$
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
ob_start();
|
900 |
-
if ('yes' === $atts['loop']) {
|
901 |
-
$this->is_loop = true;
|
902 |
-
$this->htmloutput($atts, true);
|
903 |
-
$this->is_loop = false;
|
904 |
-
} else {
|
905 |
-
$this->htmloutput($atts, true);
|
906 |
-
}
|
907 |
-
|
908 |
-
return ob_get_clean();
|
909 |
-
}
|
910 |
-
|
911 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Add to wishlists shortcode and hooks
|
4 |
+
*
|
5 |
+
* @since 1.0.0
|
6 |
+
* @package TInvWishlist\Public
|
7 |
+
*/
|
8 |
+
|
9 |
+
// If this file is called directly, abort.
|
10 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
11 |
+
die;
|
12 |
+
}
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Add to wishlists shortcode and hooks
|
16 |
+
*/
|
17 |
+
class TInvWL_Public_AddToWishlist {
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Plugin name
|
21 |
+
*
|
22 |
+
* @var string
|
23 |
+
*/
|
24 |
+
private $_name;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Global product
|
28 |
+
*
|
29 |
+
* @var object
|
30 |
+
*/
|
31 |
+
private $product;
|
32 |
+
/**
|
33 |
+
* This user wishlists
|
34 |
+
*
|
35 |
+
* @var array
|
36 |
+
*/
|
37 |
+
private $user_wishlist;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* This wishlists and product
|
41 |
+
*
|
42 |
+
* @var array
|
43 |
+
*/
|
44 |
+
private $wishlist;
|
45 |
+
|
46 |
+
/**
|
47 |
+
* This wishlist all products
|
48 |
+
*
|
49 |
+
* @var array
|
50 |
+
*/
|
51 |
+
private $all_products;
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Check is loop button
|
55 |
+
*
|
56 |
+
* @var bolean
|
57 |
+
*/
|
58 |
+
private $is_loop;
|
59 |
+
|
60 |
+
/**
|
61 |
+
* This class
|
62 |
+
*
|
63 |
+
* @var \TInvWL_Public_AddToWishlist
|
64 |
+
*/
|
65 |
+
protected static $_instance = null;
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Get this class object
|
69 |
+
*
|
70 |
+
* @param string $plugin_name Plugin name.
|
71 |
+
*
|
72 |
+
* @return \TInvWL_Public_AddToWishlist
|
73 |
+
*/
|
74 |
+
public static function instance( $plugin_name = TINVWL_PREFIX ) {
|
75 |
+
if ( is_null( self::$_instance ) ) {
|
76 |
+
self::$_instance = new self( $plugin_name );
|
77 |
+
}
|
78 |
+
|
79 |
+
return self::$_instance;
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Constructor
|
84 |
+
*
|
85 |
+
* @param string $plugin_name Plugin name.
|
86 |
+
*/
|
87 |
+
function __construct( $plugin_name ) {
|
88 |
+
$this->_name = $plugin_name;
|
89 |
+
$this->is_loop = false;
|
90 |
+
$this->define_hooks();
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Defined shortcode and hooks
|
95 |
+
*/
|
96 |
+
function define_hooks() {
|
97 |
+
switch ( tinv_get_option( 'add_to_wishlist', 'position' ) ) {
|
98 |
+
case 'before':
|
99 |
+
add_action( 'tinvwl_before_add_to_cart_button', 'tinvwl_view_addto_html' );
|
100 |
+
add_action( 'tinvwl_single_product_summary', 'tinvwl_view_addto_htmlout' );
|
101 |
+
add_action( 'woocommerce_before_add_to_cart_button', 'tinvwl_view_addto_html', 9 );
|
102 |
+
add_action( 'woocommerce_single_product_summary', 'tinvwl_view_addto_htmlout', 29 );
|
103 |
+
add_action( 'catalog_visibility_before_alternate_add_to_cart_button', 'tinvwl_view_addto_html' );
|
104 |
+
break;
|
105 |
+
case 'after':
|
106 |
+
add_action( 'tinvwl_after_add_to_cart_button', 'tinvwl_view_addto_html' );
|
107 |
+
add_action( 'tinvwl_single_product_summary', 'tinvwl_view_addto_htmlout' );
|
108 |
+
add_action( 'woocommerce_after_add_to_cart_button', 'tinvwl_view_addto_html', 20 );
|
109 |
+
add_action( 'woocommerce_single_product_summary', 'tinvwl_view_addto_htmlout', 31 );
|
110 |
+
add_action( 'catalog_visibility_after_alternate_add_to_cart_button', 'tinvwl_view_addto_html' );
|
111 |
+
break;
|
112 |
+
case 'thumbnails':
|
113 |
+
add_action( 'tinvwl_after_thumbnails', 'tinvwl_view_addto_html' );
|
114 |
+
add_action( 'woocommerce_product_thumbnails', 'tinvwl_view_addto_html', 21 );
|
115 |
+
break;
|
116 |
+
case 'summary':
|
117 |
+
add_action( 'tinvwl_after_summary', 'tinvwl_view_addto_html' );
|
118 |
+
add_action( 'woocommerce_after_single_product_summary', 'tinvwl_view_addto_html', 11 );
|
119 |
+
break;
|
120 |
+
}
|
121 |
+
if ( tinv_get_option( 'add_to_wishlist_catalog', 'show_in_loop' ) ) {
|
122 |
+
switch ( tinv_get_option( 'add_to_wishlist_catalog', 'position' ) ) {
|
123 |
+
case 'before':
|
124 |
+
add_action( 'tinvwl_after_shop_loop_item', 'tinvwl_view_addto_htmlloop' );
|
125 |
+
add_action( 'woocommerce_after_shop_loop_item', 'tinvwl_view_addto_htmlloop', 8 );
|
126 |
+
break;
|
127 |
+
case 'above_thumb':
|
128 |
+
add_action( 'tinvwl_above_thumb_loop_item', 'tinvwl_view_addto_htmlloop' );
|
129 |
+
add_action( 'woocommerce_before_shop_loop_item', 'tinvwl_view_addto_htmlloop', 9 );
|
130 |
+
break;
|
131 |
+
case 'shortcode':
|
132 |
+
break;
|
133 |
+
case 'after':
|
134 |
+
default: // Compatibility with previous versions.
|
135 |
+
add_action( 'tinvwl_after_shop_loop_item', 'tinvwl_view_addto_htmlloop' );
|
136 |
+
add_action( 'woocommerce_after_shop_loop_item', 'tinvwl_view_addto_htmlloop', 20 );
|
137 |
+
break;
|
138 |
+
}
|
139 |
+
}
|
140 |
+
|
141 |
+
add_action( 'wp_loaded', array( $this, 'add_to_wishlist' ), 0 );
|
142 |
+
}
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Action add product to wishlist
|
146 |
+
*
|
147 |
+
* @return boolean
|
148 |
+
*/
|
149 |
+
function add_to_wishlist() {
|
150 |
+
if ( is_null( filter_input( INPUT_POST, 'tinv_wishlist_id' ) ) ) {
|
151 |
+
return false;
|
152 |
+
} else {
|
153 |
+
remove_action( 'init', 'woocommerce_add_to_cart_action' );
|
154 |
+
remove_action( 'wp_loaded', 'WC_Form_Handler::add_to_cart_action', 20 );
|
155 |
+
}
|
156 |
+
ob_start();
|
157 |
+
$post = filter_input_array( INPUT_POST, array(
|
158 |
+
'tinv_wishlist_id' => FILTER_VALIDATE_INT,
|
159 |
+
'tinv_wishlist_name' => FILTER_SANITIZE_STRING,
|
160 |
+
'product_id' => FILTER_VALIDATE_INT,
|
161 |
+
'product_variation' => FILTER_VALIDATE_INT,
|
162 |
+
'product_type' => FILTER_SANITIZE_STRING,
|
163 |
+
'product_action' => FILTER_SANITIZE_STRING,
|
164 |
+
'redirect' => FILTER_SANITIZE_URL,
|
165 |
+
) );
|
166 |
+
|
167 |
+
$post['original_product_id'] = $post['product_id'];
|
168 |
+
|
169 |
+
$wlp = null;
|
170 |
+
$wishlist = null;
|
171 |
+
$data = array( 'msg' => array() );
|
172 |
+
if ( is_user_logged_in() ) {
|
173 |
+
$wl = new TInvWL_Wishlist( $this->_name );
|
174 |
+
$wishlist = $wl->add_user_default();
|
175 |
+
$wishlist = apply_filters( 'tinvwl_addtowishlist_wishlist', $wishlist );
|
176 |
+
if ( empty( $wishlist ) ) {
|
177 |
+
$data['status'] = false;
|
178 |
+
$data = apply_filters( 'tinvwl_addtowishlist_return_ajax', $data, $post );
|
179 |
+
ob_clean();
|
180 |
+
wp_send_json( $data );
|
181 |
+
}
|
182 |
+
$wlp = new TInvWL_Product( $wishlist, $this->_name );
|
183 |
+
} elseif ( tinv_get_option( 'general', 'require_login' ) ) {
|
184 |
+
$data['status'] = false;
|
185 |
+
$data['icon'] = 'icon_big_times';
|
186 |
+
if ( tinv_get_option( 'general', 'redirect_require_login' ) ) {
|
187 |
+
$data['msg'] = array();
|
188 |
+
$data['force_redirect'] = apply_filters( 'tinvwl_addtowishlist_login_page', add_query_arg( 'tinvwl_redirect', rawurlencode( $post['redirect'] ), wc_get_page_permalink( 'myaccount' ) ), $post );
|
189 |
+
} else {
|
190 |
+
$data['msg'][] = __( 'Please, login to add products to Wishlist', 'ti-woocommerce-wishlist' );
|
191 |
+
$data['dialog_custom_url'] = apply_filters( 'tinvwl_addtowishlist_login_page', add_query_arg( 'tinvwl_redirect', rawurlencode( $post['redirect'] ), wc_get_page_permalink( 'myaccount' ) ), $post );
|
192 |
+
$data['dialog_custom_html'] = '<i class="ftinvwl ftinvwl-key"></i>' . esc_html( __( 'Login', 'ti-woocommerce-wishlist' ) );
|
193 |
+
}
|
194 |
+
$data['msg'] = array_unique( $data['msg'] );
|
195 |
+
$data['msg'] = implode( '<br>', $data['msg'] );
|
196 |
+
if ( ! empty( $data['msg'] ) ) {
|
197 |
+
$data['msg'] = tinv_wishlist_template_html( 'ti-addedtowishlist-dialogbox.php', apply_filters( 'tinvwl_addtowishlist_dialog_box', $data, $post ) );
|
198 |
+
}
|
199 |
+
$data = apply_filters( 'tinvwl_addtowishlist_return_ajax', $data, $post );
|
200 |
+
ob_clean();
|
201 |
+
wp_send_json( $data );
|
202 |
+
} else {
|
203 |
+
$wl = new TInvWL_Wishlist( $this->_name );
|
204 |
+
$wishlist = $wl->add_sharekey_default();
|
205 |
+
$wlp = new TInvWL_Product( $wishlist );
|
206 |
+
}
|
207 |
+
|
208 |
+
$status = true;
|
209 |
+
if ( empty( $post['product_id'] ) || apply_filters( 'tinvwl_addtowishlist_not_allowed', false, $post ) ) {
|
210 |
+
$status = false;
|
211 |
+
$data['msg'][] = __( 'Something went wrong', 'ti-woocommerce-wishlist' );
|
212 |
+
} else {
|
213 |
+
$post['product_type'] = apply_filters( 'tinvwl_addtowishlist_modify_type', $post['product_type'], $post );
|
214 |
+
$post = apply_filters( 'tinvwl_addtowishlist_prepare', $post );
|
215 |
+
$form = apply_filters( 'tinvwl_addtowishlist_prepare_form', filter_input( INPUT_POST, 'form', FILTER_DEFAULT, FILTER_FORCE_ARRAY ), $_POST, $_FILES );
|
216 |
+
if ( empty( $form ) ) {
|
217 |
+
$form = array();
|
218 |
+
}
|
219 |
+
switch ( $post['product_type'] ) {
|
220 |
+
case 'group':
|
221 |
+
case 'grouped' :
|
222 |
+
$product = $wlp->product_data( $post['product_id'] );
|
223 |
+
if ( empty( $product ) ) {
|
224 |
+
$status = false;
|
225 |
+
} else {
|
226 |
+
$variations = $product->get_children();
|
227 |
+
|
228 |
+
foreach ( $variations as $variation_id ) {
|
229 |
+
$quantity = 1;
|
230 |
+
$allowed_adding = ! count( $wlp->get_wishlist( array(
|
231 |
+
'product_id' => $post['product_id'],
|
232 |
+
'variation_id' => $variation_id,
|
233 |
+
'external' => false,
|
234 |
+
) ) );
|
235 |
+
if ( tinv_get_option( 'general', 'simple_flow' ) && 'remove' === $post['product_action'] ) {
|
236 |
+
if ( $wlp->remove_product_from_wl( 0, $post['product_id'], $variation_id, apply_filters( 'tinvwl_addtowishlist_add_form', $form ) ) ) {
|
237 |
+
$data['msg'][] = apply_filters( 'tinvwl_removed_from_wishlist_text', tinv_get_option( 'general', 'text_removed_from' ) );
|
238 |
+
$data['removed'] = true;
|
239 |
+
$status = false;
|
240 |
+
}
|
241 |
+
} elseif ( ! $allowed_adding ) {
|
242 |
+
$data['msg'][] = apply_filters( 'tinvwl_already_in_wishlist_text', tinv_get_option( 'general', 'text_already_in' ) );
|
243 |
+
$status = false;
|
244 |
+
} elseif ( $wlp->add_product( apply_filters( 'tinvwl_addtowishlist_add', array(
|
245 |
+
'product_id' => $post['product_id'],
|
246 |
+
'variation_id' => $variation_id,
|
247 |
+
'quantity' => $quantity,
|
248 |
+
) ) )
|
249 |
+
) {
|
250 |
+
$data['msg'][] = apply_filters( 'tinvwl_added_to_wishlist_text', tinv_get_option( 'general', 'text_added_to' ) );
|
251 |
+
} else {
|
252 |
+
$status = false;
|
253 |
+
}
|
254 |
+
}
|
255 |
+
}
|
256 |
+
break;
|
257 |
+
case 'variable' :
|
258 |
+
case 'variation' :
|
259 |
+
case 'variable-subscription' :
|
260 |
+
|
261 |
+
if ( $post['product_variation'] ) {
|
262 |
+
$variation_id = $post['product_variation'];
|
263 |
+
} else {
|
264 |
+
$variation_id = absint( array_key_exists( 'variation_id', $form ) ? filter_var( $form['variation_id'], FILTER_VALIDATE_INT ) : 0 );
|
265 |
+
}
|
266 |
+
|
267 |
+
$post['original_product_id'] = $variation_id;
|
268 |
+
|
269 |
+
$quantity = 1;
|
270 |
+
$allowed_adding = ! count( $wlp->get_wishlist( array(
|
271 |
+
'product_id' => $post['product_id'],
|
272 |
+
'variation_id' => $variation_id,
|
273 |
+
'meta' => apply_filters( 'tinvwl_addtowishlist_add_form', $form ),
|
274 |
+
'external' => false,
|
275 |
+
) ) );
|
276 |
+
if ( tinv_get_option( 'general', 'simple_flow' ) && 'remove' === $post['product_action'] ) {
|
277 |
+
if ( $wlp->remove_product_from_wl( 0, $post['product_id'], $variation_id, apply_filters( 'tinvwl_addtowishlist_add_form', $form ) ) ) {
|
278 |
+
$data['msg'][] = apply_filters( 'tinvwl_removed_from_wishlist_text', tinv_get_option( 'general', 'text_removed_from' ) );
|
279 |
+
$data['removed'] = true;
|
280 |
+
$status = false;
|
281 |
+
}
|
282 |
+
} elseif ( ! $allowed_adding ) {
|
283 |
+
$data['msg'][] = apply_filters( 'tinvwl_already_in_wishlist_text', tinv_get_option( 'general', 'text_already_in' ) );
|
284 |
+
$status = false;
|
285 |
+
} elseif ( $wlp->add_product( apply_filters( 'tinvwl_addtowishlist_add', array(
|
286 |
+
'product_id' => $post['product_id'],
|
287 |
+
'quantity' => $quantity,
|
288 |
+
'variation_id' => $variation_id,
|
289 |
+
) ), apply_filters( 'tinvwl_addtowishlist_add_form', $form ) ) ) {
|
290 |
+
$data['msg'][] = apply_filters( 'tinvwl_added_to_wishlist_text', tinv_get_option( 'general', 'text_added_to' ) );
|
291 |
+
} else {
|
292 |
+
$status = false;
|
293 |
+
}
|
294 |
+
break;
|
295 |
+
case 'simple' :
|
296 |
+
default:
|
297 |
+
$quantity = 1;
|
298 |
+
$allowed_adding = ! count( $wlp->get_wishlist( array(
|
299 |
+
'product_id' => $post['product_id'],
|
300 |
+
'meta' => apply_filters( 'tinvwl_addtowishlist_add_form', $form ),
|
301 |
+
'external' => false,
|
302 |
+
) ) );
|
303 |
+
if ( tinv_get_option( 'general', 'simple_flow' ) && 'remove' === $post['product_action'] ) {
|
304 |
+
if ( $wlp->remove_product_from_wl( 0, $post['product_id'], 0, apply_filters( 'tinvwl_addtowishlist_add_form', $form ) ) ) {
|
305 |
+
$data['msg'][] = apply_filters( 'tinvwl_removed_from_wishlist_text', tinv_get_option( 'general', 'text_removed_from' ) );
|
306 |
+
$data['removed'] = true;
|
307 |
+
$status = false;
|
308 |
+
}
|
309 |
+
} elseif ( ! $allowed_adding ) {
|
310 |
+
$data['msg'][] = apply_filters( 'tinvwl_already_in_wishlist_text', tinv_get_option( 'general', 'text_already_in' ) );
|
311 |
+
$status = false;
|
312 |
+
} elseif ( $wlp->add_product( apply_filters( 'tinvwl_addtowishlist_add', array(
|
313 |
+
'product_id' => $post['product_id'],
|
314 |
+
'quantity' => $quantity,
|
315 |
+
) ), apply_filters( 'tinvwl_addtowishlist_add_form', $form ) ) ) {
|
316 |
+
$data['msg'][] = apply_filters( 'tinvwl_added_to_wishlist_text', tinv_get_option( 'general', 'text_added_to' ) );
|
317 |
+
} else {
|
318 |
+
$status = false;
|
319 |
+
}
|
320 |
+
break;
|
321 |
+
} // End switch().
|
322 |
+
} // End if().
|
323 |
+
$data['status'] = $status;
|
324 |
+
$data['wishlist_url'] = tinv_url_wishlist_default();
|
325 |
+
|
326 |
+
if ( ! empty( $wishlist ) ) {
|
327 |
+
$data['wishlist_url'] = tinv_url_wishlist( $wishlist['ID'] );
|
328 |
+
}
|
329 |
+
|
330 |
+
if ( $status && tinv_get_option( 'general', 'redirect' ) && tinv_get_option( 'page', 'wishlist' ) && tinv_get_option( 'general', 'show_notice' ) ) {
|
331 |
+
$data['redirect'] = $data['wishlist_url'];
|
332 |
+
}
|
333 |
+
|
334 |
+
$product = $original_product = wc_get_product( $post['product_id'] );
|
335 |
+
if ( empty( $form ) ) {
|
336 |
+
$form = array();
|
337 |
+
}
|
338 |
+
$data['wishlists'] = wp_json_encode( $this->user_wishlist( $product, $wlp ) );
|
339 |
+
|
340 |
+
$data['icon'] = $data['status'] ? 'icon_big_heart_check' : 'icon_big_times';
|
341 |
+
$data['msg'] = array_unique( $data['msg'] );
|
342 |
+
$data['msg'] = implode( '<br>', $data['msg'] );
|
343 |
+
|
344 |
+
if ( $post['original_product_id'] && $post['product_id'] !== $post['original_product_id'] ) {
|
345 |
+
$original_product = wc_get_product( $post['original_product_id'] );
|
346 |
+
}
|
347 |
+
|
348 |
+
$msg_placeholders = apply_filters( 'tinvwl_addtowishlist_message_placeholders',
|
349 |
+
array(
|
350 |
+
'{product_name}' => is_callable( array(
|
351 |
+
$original_product,
|
352 |
+
'get_name'
|
353 |
+
) ) ? $original_product->get_name() : $original_product->get_title(),
|
354 |
+
'{product_sku}' => $original_product->get_sku(),
|
355 |
+
),
|
356 |
+
$original_product
|
357 |
+
);
|
358 |
+
|
359 |
+
$find = array_keys( $msg_placeholders );
|
360 |
+
$replace = array_values( $msg_placeholders );
|
361 |
+
|
362 |
+
if ( ! empty( $data['msg'] ) ) {
|
363 |
+
$data['msg'] = str_replace( $find, $replace, $data['msg'] );
|
364 |
+
$data['msg'] = apply_filters( 'tinvwl_addtowishlist_message_after', $data['msg'], $data, $post, $form, $product );
|
365 |
+
$data['msg'] = tinv_wishlist_template_html( 'ti-addedtowishlist-dialogbox.php', apply_filters( 'tinvwl_addtowishlist_dialog_box', $data, $post ) );
|
366 |
+
}
|
367 |
+
if ( ! tinv_get_option( 'general', 'show_notice' ) && array_key_exists( 'msg', $data ) ) {
|
368 |
+
unset( $data['msg'] );
|
369 |
+
}
|
370 |
+
if ( tinv_get_option( 'general', 'simple_flow' ) ) {
|
371 |
+
$data['make_remove'] = $data['status'];
|
372 |
+
}
|
373 |
+
$data['wishlists_data'] = $this->get_wishlists_data( $wishlist['share_key'] );
|
374 |
+
$data = apply_filters( 'tinvwl_addtowishlist_return_ajax', $data, $post, $form, $product );
|
375 |
+
ob_clean();
|
376 |
+
wp_send_json( $data );
|
377 |
+
}
|
378 |
+
|
379 |
+
function get_wishlists_data( $share_key ) {
|
380 |
+
|
381 |
+
global $wpdb, $sitepress;
|
382 |
+
|
383 |
+
$table = sprintf( '%s%s', $wpdb->prefix, 'tinvwl_items' );
|
384 |
+
$table_lists = sprintf( '%s%s', $wpdb->prefix, 'tinvwl_lists' );
|
385 |
+
$table_translations = sprintf( '%s%s', $wpdb->prefix, 'icl_translations' );
|
386 |
+
$table_languages = sprintf( '%s%s', $wpdb->prefix, 'icl_languages' );
|
387 |
+
$lang = filter_input( INPUT_POST, 'lang', FILTER_SANITIZE_STRING );
|
388 |
+
|
389 |
+
if ( $sitepress && $sitepress instanceof SitePress ) {
|
390 |
+
$wpml_settings = $sitepress->get_settings();
|
391 |
+
if ( isset( $wpml_settings['custom_posts_sync_option'] ) && isset( $wpml_settings['custom_posts_sync_option']['product'] ) && '1' !== $wpml_settings['custom_posts_sync_option']['product'] ) {
|
392 |
+
$lang = false;
|
393 |
+
}
|
394 |
+
}
|
395 |
+
|
396 |
+
$data = $products = $wishlists = $results = array();
|
397 |
+
|
398 |
+
if ( is_user_logged_in() ) {
|
399 |
+
$data['author'] = get_current_user_id();
|
400 |
+
}
|
401 |
+
|
402 |
+
if ( ( isset( $data['author'] ) && $data['author'] ) || $share_key ) {
|
403 |
+
|
404 |
+
$default = array(
|
405 |
+
'count' => 99999,
|
406 |
+
'field' => null,
|
407 |
+
'offset' => 0,
|
408 |
+
'order' => 'DESC',
|
409 |
+
'order_by' => 'date',
|
410 |
+
'external' => true,
|
411 |
+
'sql' => '',
|
412 |
+
);
|
413 |
+
|
414 |
+
foreach ( $default as $_k => $_v ) {
|
415 |
+
if ( array_key_exists( $_k, $data ) ) {
|
416 |
+
$default[ $_k ] = $data[ $_k ];
|
417 |
+
unset( $data[ $_k ] );
|
418 |
+
}
|
419 |
+
}
|
420 |
+
|
421 |
+
$default['offset'] = absint( $default['offset'] );
|
422 |
+
$default['count'] = absint( $default['count'] );
|
423 |
+
|
424 |
+
if ( $lang ) {
|
425 |
+
$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,';
|
426 |
+
} else {
|
427 |
+
$default['field'] = $table . '.*, ';
|
428 |
+
}
|
429 |
+
$default['field'] .= $table_lists . '.ID as wishlist_id, ' . $table_lists . '.status as wishlist_status, ' . $table_lists . '.title as wishlist_title, ' . $table_lists . '.share_key as wishlist_share_key';
|
430 |
+
|
431 |
+
$sql = "SELECT {$default[ 'field' ]} FROM `{$table}` INNER JOIN `{$table_lists}` ON `{$table}`.`wishlist_id` = `{$table_lists}`.`ID` AND `{$table_lists}`.`type` = 'default'";
|
432 |
+
|
433 |
+
if ( $share_key ) {
|
434 |
+
$sql .= " AND `{$table_lists}`.`share_key` = '{$share_key}'";
|
435 |
+
}
|
436 |
+
if ( $lang ) {
|
437 |
+
$sql .= "LEFT JOIN {$table_translations} tr ON
|
438 |
+
{$table}.product_id = tr.element_id AND tr.element_type = 'post_product'
|
439 |
+
LEFT JOIN {$table_translations} tr2 ON
|
440 |
+
{$table}.variation_id != 0 AND {$table}.variation_id = tr2.element_id AND tr2.element_type = 'post_product_variation'
|
441 |
+
LEFT JOIN {$table_translations} t ON
|
442 |
+
tr.trid = t.trid AND t.element_type = 'post_product' AND t.language_code = '{$lang}'
|
443 |
+
LEFT JOIN {$table_translations} t2 ON
|
444 |
+
{$table}.variation_id != 0 AND tr2.trid = t2.trid AND t2.element_type = 'post_product_variation' AND t2.language_code = '{$lang}'
|
445 |
+
JOIN {$table_languages} l ON
|
446 |
+
(
|
447 |
+
t.language_code = l.code OR t2.language_code = l.code
|
448 |
+
) AND l.active = 1";
|
449 |
+
}
|
450 |
+
$where = '1';
|
451 |
+
|
452 |
+
if ( ! empty( $data ) && is_array( $data ) ) {
|
453 |
+
|
454 |
+
if ( array_key_exists( 'meta', $data ) ) {
|
455 |
+
$product_id = $variation_id = 0;
|
456 |
+
if ( array_key_exists( 'product_id', $data ) ) {
|
457 |
+
$product_id = $data['product_id'];
|
458 |
+
}
|
459 |
+
if ( array_key_exists( 'variation_id', $data ) ) {
|
460 |
+
$variation_id = $data['variation_id'];
|
461 |
+
}
|
462 |
+
$data['formdata'] = '';
|
463 |
+
unset( $data['meta'] );
|
464 |
+
}
|
465 |
+
|
466 |
+
foreach ( $data as $f => $v ) {
|
467 |
+
$s = is_array( $v ) ? ' IN ' : '=';
|
468 |
+
if ( is_array( $v ) ) {
|
469 |
+
foreach ( $v as $_f => $_v ) {
|
470 |
+
$v[ $_f ] = $wpdb->prepare( '%s', $_v );
|
471 |
+
}
|
472 |
+
$v = implode( ',', $v );
|
473 |
+
$v = "($v)";
|
474 |
+
} else {
|
475 |
+
$v = $wpdb->prepare( '%s', $v );
|
476 |
+
}
|
477 |
+
$data[ $f ] = sprintf( $table . '.' . '`%s`%s%s', $f, $s, $v );
|
478 |
+
}
|
479 |
+
|
480 |
+
$where = implode( ' AND ', $data );
|
481 |
+
|
482 |
+
$sql .= ' WHERE ' . $where;
|
483 |
+
}
|
484 |
+
|
485 |
+
$sql .= sprintf( ' ORDER BY `%s` %s LIMIT %d,%d;', $default['order_by'], $default['order'], $default['offset'], $default['count'] );
|
486 |
+
|
487 |
+
if ( ! empty( $default['sql'] ) ) {
|
488 |
+
$replacer = $replace = array();
|
489 |
+
$replace[0] = '{table}';
|
490 |
+
$replacer[0] = $table;
|
491 |
+
$replace[1] = '{where}';
|
492 |
+
$replacer[1] = $where;
|
493 |
+
|
494 |
+
foreach ( $default as $key => $value ) {
|
495 |
+
$i = count( $replace );
|
496 |
+
|
497 |
+
$replace[ $i ] = '{' . $key . '}';
|
498 |
+
$replacer[ $i ] = $value;
|
499 |
+
}
|
500 |
+
|
501 |
+
$sql = str_replace( $replace, $replacer, $default['sql'] );
|
502 |
+
}
|
503 |
+
|
504 |
+
$results = $wpdb->get_results( $sql, ARRAY_A );
|
505 |
+
|
506 |
+
if ( ! empty( $results ) ) {
|
507 |
+
foreach ( $results as $product ) {
|
508 |
+
$wishlists[ $product['wishlist_id'] ] = array(
|
509 |
+
'ID' => (int) $product['wishlist_id'],
|
510 |
+
'title' => $product['wishlist_title'],
|
511 |
+
'status' => $product['wishlist_status'],
|
512 |
+
'share_key' => $product['wishlist_share_key'],
|
513 |
+
);
|
514 |
+
|
515 |
+
}
|
516 |
+
|
517 |
+
foreach ( $wishlists as $wishlist ) {
|
518 |
+
|
519 |
+
foreach ( $results as $product ) {
|
520 |
+
if ( array_key_exists( $product['product_id'], $products ) ) {
|
521 |
+
$products[ $product['product_id'] ][ $wishlist['ID'] ]['in'][] = (int) $product['variation_id'];
|
522 |
+
} else {
|
523 |
+
$products[ $product['product_id'] ][ $wishlist['ID'] ] = $wishlist;
|
524 |
+
$products[ $product['product_id'] ][ $wishlist['ID'] ]['in'][] = (int) $product['variation_id'];
|
525 |
+
}
|
526 |
+
|
527 |
+
}
|
528 |
+
}
|
529 |
+
}
|
530 |
+
|
531 |
+
}
|
532 |
+
|
533 |
+
$count = is_array( $results ) ? count( $results ) : 0;
|
534 |
+
|
535 |
+
$response = array(
|
536 |
+
'products' => $products,
|
537 |
+
'counter' => $count,
|
538 |
+
);
|
539 |
+
|
540 |
+
if ( $lang ) {
|
541 |
+
$response['lang'] = $lang;
|
542 |
+
}
|
543 |
+
|
544 |
+
return $response;
|
545 |
+
}
|
546 |
+
|
547 |
+
/**
|
548 |
+
* Get user wishlist
|
549 |
+
*
|
550 |
+
* @return array
|
551 |
+
*/
|
552 |
+
function user_wishlists() {
|
553 |
+
if ( ! empty( $this->user_wishlist ) ) {
|
554 |
+
return $this->user_wishlist;
|
555 |
+
}
|
556 |
+
|
557 |
+
$wl = new TInvWL_Wishlist( $this->_name );
|
558 |
+
if ( is_user_logged_in() ) {
|
559 |
+
$wishlists = $wl->get_by_user_default();
|
560 |
+
} else {
|
561 |
+
$wishlists = $wl->get_by_sharekey_default();
|
562 |
+
}
|
563 |
+
$wishlists = array_filter( $wishlists );
|
564 |
+
if ( ! empty( $wishlists ) ) {
|
565 |
+
$_wishlists = array();
|
566 |
+
foreach ( $wishlists as $key => $wishlist ) {
|
567 |
+
if ( is_array( $wishlist ) && array_key_exists( 'ID', $wishlist ) ) {
|
568 |
+
$_wishlists[ $key ] = array(
|
569 |
+
'ID' => $wishlist['ID'],
|
570 |
+
'title' => $wishlist['title'],
|
571 |
+
'url' => tinv_url_wishlist_by_key( $wishlist['share_key'] ),
|
572 |
+
);
|
573 |
+
}
|
574 |
+
}
|
575 |
+
$wishlists = $_wishlists;
|
576 |
+
}
|
577 |
+
$this->user_wishlist = $wishlists;
|
578 |
+
|
579 |
+
return $wishlists;
|
580 |
+
}
|
581 |
+
|
582 |
+
/**
|
583 |
+
* Check exists product in user wishlists
|
584 |
+
*
|
585 |
+
* @param object $product Product object.
|
586 |
+
* @param object $wlp Product class, used for local products.
|
587 |
+
*
|
588 |
+
* @return array
|
589 |
+
*/
|
590 |
+
function user_wishlist( $product, $wlp = null ) {
|
591 |
+
|
592 |
+
$product = apply_filters( 'tinvwl_addtowishlist_check_product', $product );
|
593 |
+
|
594 |
+
$this->wishlist = array();
|
595 |
+
$vproduct = in_array( $product->get_type(), array(
|
596 |
+
'variable',
|
597 |
+
'variation',
|
598 |
+
'variable-subscription',
|
599 |
+
) );
|
600 |
+
$wlp = new TInvWL_Product();
|
601 |
+
$wishlists = $this->user_wishlists();
|
602 |
+
$ids = array();
|
603 |
+
foreach ( $wishlists as $key => $wishlist ) {
|
604 |
+
$ids[] = $wishlist['ID'];
|
605 |
+
}
|
606 |
+
$ids = array_filter( $ids );
|
607 |
+
|
608 |
+
if ( empty( $ids ) ) {
|
609 |
+
return $wishlists;
|
610 |
+
}
|
611 |
+
|
612 |
+
if ( ! $this->all_products ) {
|
613 |
+
$this->all_products = $wlp->get( array(
|
614 |
+
'wishlist_id' => $ids,
|
615 |
+
'external' => false,
|
616 |
+
'count' => 9999999,
|
617 |
+
) );
|
618 |
+
}
|
619 |
+
|
620 |
+
$products = array();
|
621 |
+
foreach ( $this->all_products as $_product ) {
|
622 |
+
if ( $_product['product_id'] === $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id() ) {
|
623 |
+
$products[] = $_product;
|
624 |
+
}
|
625 |
+
}
|
626 |
+
|
627 |
+
$in = array();
|
628 |
+
if ( ! empty( $products ) ) {
|
629 |
+
foreach ( $products as $product ) {
|
630 |
+
$in[ $product['wishlist_id'] ][] = $product['variation_id'];
|
631 |
+
}
|
632 |
+
foreach ( $in as $wishlist_id => $products ) {
|
633 |
+
sort( $in[ $wishlist_id ], SORT_NUMERIC );
|
634 |
+
if ( empty( $in[ $wishlist_id ] ) && ( $this->is_loop || ! $vproduct ) ) {
|
635 |
+
$in[ $wishlist_id ] = true;
|
636 |
+
}
|
637 |
+
}
|
638 |
+
}
|
639 |
+
foreach ( $wishlists as $key => $wishlist ) {
|
640 |
+
$wishlists[ $key ]['in'] = array_key_exists( $wishlist['ID'], $in ) ? $in[ $wishlist['ID'] ] : false;
|
641 |
+
}
|
642 |
+
$wishlists = apply_filters( 'tinvwl_addtowishlist_preparewishlists', $wishlists, $product );
|
643 |
+
$this->wishlist = $wishlists;
|
644 |
+
|
645 |
+
return $wishlists;
|
646 |
+
}
|
647 |
+
|
648 |
+
/**
|
649 |
+
* Create add button in loop
|
650 |
+
*
|
651 |
+
* @global object $product
|
652 |
+
*/
|
653 |
+
function htmloutput_loop() {
|
654 |
+
global $product;
|
655 |
+
|
656 |
+
if ( $product ) {
|
657 |
+
if ( apply_filters( 'tinvwl_allow_addtowishlist_shop_loop_item', true, $product ) ) { // @codingStandardsIgnoreLine WordPress.PHP.StrictInArray.MissingTrueStrict
|
658 |
+
$this->is_loop = true;
|
659 |
+
$this->htmloutput();
|
660 |
+
$this->is_loop = false;
|
661 |
+
}
|
662 |
+
}
|
663 |
+
}
|
664 |
+
|
665 |
+
/**
|
666 |
+
* Create add button if simple product out stock
|
667 |
+
*
|
668 |
+
* @global object $product
|
669 |
+
*/
|
670 |
+
function htmloutput_out() {
|
671 |
+
global $product;
|
672 |
+
|
673 |
+
if ( $product ) {
|
674 |
+
$allow = false;
|
675 |
+
if ( 'simple' === $product->get_type() ) {
|
676 |
+
$allow = ( ( ! $product->is_purchasable() && '' == $product->get_price() ) || ( $product->is_purchasable() && ! $product->is_in_stock() ) );
|
677 |
+
}
|
678 |
+
|
679 |
+
if ( in_array( $product->get_type(), array(
|
680 |
+
'variable',
|
681 |
+
'variable-subscription'
|
682 |
+
) ) ) {
|
683 |
+
$get_variations = count( $product->get_children() ) <= apply_filters( 'woocommerce_ajax_variation_threshold', 30, $product );
|
684 |
+
$available_variations = $get_variations ? $product->get_available_variations() : false;
|
685 |
+
$allow = ( empty( $available_variations ) && false !== $available_variations );
|
686 |
+
}
|
687 |
+
|
688 |
+
if ( apply_filters( 'tinvwl_allow_addtowishlist_single_product_summary', $allow, $product ) ) {
|
689 |
+
$this->htmloutput();
|
690 |
+
}
|
691 |
+
}
|
692 |
+
}
|
693 |
+
|
694 |
+
/**
|
695 |
+
* Output page
|
696 |
+
*
|
697 |
+
* @param array $attr Array parameter for shortcode.
|
698 |
+
* @param boolean $is_shortcode Shortcode or action.
|
699 |
+
*
|
700 |
+
* @return boolean
|
701 |
+
* @global object $product
|
702 |
+
*
|
703 |
+
*/
|
704 |
+
function htmloutput( $attr = array(), $is_shortcode = false ) {
|
705 |
+
global $product, $post;
|
706 |
+
|
707 |
+
$attr = apply_filters( 'tinvwl_addtowishlist_out_prepare_attr', $attr );
|
708 |
+
$_product = $product;
|
709 |
+
if ( empty( $product ) && ! empty( $post ) && 'product' === $post->post_type ) {
|
710 |
+
$_product = wc_get_product( $post->ID );
|
711 |
+
}
|
712 |
+
|
713 |
+
$this->product = apply_filters( 'tinvwl_addtowishlist_out_prepare_product', $_product );
|
714 |
+
|
715 |
+
$position = tinv_get_option( 'add_to_wishlist', 'position' );
|
716 |
+
|
717 |
+
if ( $is_shortcode ) {
|
718 |
+
$position = 'shortcode';
|
719 |
+
|
720 |
+
$product_id = ! empty( $attr['product_id'] ) ? absint( $attr['product_id'] ) : ( ( $this->product instanceof WC_Product ) ? $this->product->get_id() : null );
|
721 |
+
|
722 |
+
$variation_id = ! empty( $attr['variation_id'] ) ? absint( $attr['variation_id'] ) : null;
|
723 |
+
|
724 |
+
if ( 'product_variation' == get_post_type( $product_id ) ) { // WPCS: loose comparison ok.
|
725 |
+
$variation_id = $product_id;
|
726 |
+
$product_id = wp_get_post_parent_id( $variation_id );
|
727 |
+
}
|
728 |
+
|
729 |
+
$product_data = ( $product_id !== ( ( $this->product instanceof WC_Product ) ? $this->product->get_id() : null ) ) ? wc_get_product( $variation_id ? $variation_id : $product_id ) : $this->product;
|
730 |
+
|
731 |
+
if ( $product_data instanceof WC_Product && 'trash' !== get_post( $product_data->get_id() )->post_status ) {
|
732 |
+
$this->product = apply_filters( 'tinvwl_addtowishlist_out_prepare_product', $product_data );
|
733 |
+
} else {
|
734 |
+
return false;
|
735 |
+
}
|
736 |
+
}
|
737 |
+
|
738 |
+
if ( empty( $this->product ) || ! ( $this->product instanceof WC_Product ) || ! apply_filters( 'tinvwl_allow_addtowishlist_single_product', true, $this->product ) ) {
|
739 |
+
return false;
|
740 |
+
}
|
741 |
+
|
742 |
+
add_action( 'tinvwl_wishlist_addtowishlist_button', array( $this, 'button' ) );
|
743 |
+
|
744 |
+
if ( $this->is_loop && in_array( $this->product->get_type(), array(
|
745 |
+
'variable',
|
746 |
+
'variable-subscription',
|
747 |
+
) ) ) {
|
748 |
+
|
749 |
+
$this->variation_ids = array();
|
750 |
+
|
751 |
+
|
752 |
+
if ( ! tinv_get_option( 'general', 'simple_flow' ) ) {
|
753 |
+
foreach ( $this->product->get_children() as $oid ) {
|
754 |
+
$this->variation_ids[] = apply_filters( 'wpml_object_id', $oid, 'product', true );
|
755 |
+
}
|
756 |
+
}
|
757 |
+
|
758 |
+
$this->variation_ids[] = 0;
|
759 |
+
|
760 |
+
$this->variation_ids = apply_filters( 'tinvwl_wishlist_addtowishlist_button_variation_ids', $this->variation_ids, $this );
|
761 |
+
|
762 |
+
$this->variation_id = 0;
|
763 |
+
$match_attributes = array();
|
764 |
+
|
765 |
+
foreach ( $this->product->get_default_attributes() as $attribute_name => $value ) {
|
766 |
+
$match_attributes[ 'attribute_' . sanitize_title( $attribute_name ) ] = $value;
|
767 |
+
}
|
768 |
+
|
769 |
+
if ( $match_attributes ) {
|
770 |
+
$data_store = WC_Data_Store::load( 'product' );
|
771 |
+
$this->variation_id = $data_store->find_matching_product_variation( $this->product, $match_attributes );
|
772 |
+
}
|
773 |
+
}
|
774 |
+
|
775 |
+
$data = array(
|
776 |
+
'class_postion' => sprintf( 'tinvwl-%s-add-to-cart', $this->is_loop ? tinv_get_option( 'add_to_wishlist_catalog', 'position' ) : $position ) . ( $this->is_loop ? ' tinvwl-loop-button-wrapper' : '' ),
|
777 |
+
'product' => $this->product,
|
778 |
+
'variation_id' => ( $this->is_loop && in_array( ( $this->product->get_type() ), array(
|
779 |
+
'variable',
|
780 |
+
'variable-subscription',
|
781 |
+
) ) ) ? $this->variation_id : ( $this->product->is_type( 'variation' ) ? $this->product->get_id() : 0 ),
|
782 |
+
'button_icon' => tinv_get_option( 'add_to_wishlist' . ( $this->is_loop ? '_catalog' : '' ), 'icon' ),
|
783 |
+
'add_to_wishlist' => apply_filters( 'tinvwl_added_to_wishlist_text_loop', tinv_get_option( 'add_to_wishlist' . ( $this->is_loop ? '_catalog' : '' ), 'text' ) ),
|
784 |
+
'browse_in_wishlist' => apply_filters( 'tinvwl_view_wishlist_text', tinv_get_option( 'general', 'text_browse' ) ),
|
785 |
+
'product_in_wishlist' => apply_filters( 'tinvwl_already_in_wishlist_text', tinv_get_option( 'general', 'text_already_in' ) ),
|
786 |
+
'product_to_wishlist' => apply_filters( 'tinvwl_added_to_wishlist_text', tinv_get_option( 'general', 'text_added_to' ) ),
|
787 |
+
'loop' => $this->is_loop,
|
788 |
+
);
|
789 |
+
tinv_wishlist_template( 'ti-addtowishlist.php', $data );
|
790 |
+
}
|
791 |
+
|
792 |
+
/**
|
793 |
+
* Create button
|
794 |
+
*
|
795 |
+
* @param boolean $echo Return or output.
|
796 |
+
*/
|
797 |
+
function button( $echo = true ) {
|
798 |
+
$content = apply_filters( 'tinvwl_wishlist_button_before', '' );
|
799 |
+
$button_text = apply_filters( 'tinvwl_added_to_wishlist_text_loop', tinv_get_option( 'add_to_wishlist' . ( $this->is_loop ? '_catalog' : '' ), 'text' ) );
|
800 |
+
$text = ( tinv_get_option( 'add_to_wishlist' . ( $this->is_loop ? '_catalog' : '' ), 'show_text' ) ) ? $button_text : '';
|
801 |
+
$icon = tinv_get_option( 'add_to_wishlist' . ( $this->is_loop ? '_catalog' : '' ), 'icon' );
|
802 |
+
$icon_color = tinv_get_option( 'add_to_wishlist' . ( $this->is_loop ? '_catalog' : '' ), 'icon_style' );
|
803 |
+
$icon_class = '';
|
804 |
+
$action = 'addto';
|
805 |
+
if ( empty( $text ) ) {
|
806 |
+
$icon_class = ' no-txt';
|
807 |
+
} else {
|
808 |
+
$content .= '<div class="tinv-wishlist-clear"></div>';
|
809 |
+
if ( tinv_get_option( 'general', 'simple_flow' ) ) {
|
810 |
+
$text = sprintf( '<span class="tinvwl_add_to_wishlist-text">%s</span><span class="tinvwl_remove_from_wishlist-text">%s</span>', $text, apply_filters( 'tinvwl_remove_from_wishlist_text' . ( $this->is_loop ? '_loop' : '' ), tinv_get_option( 'add_to_wishlist' . ( $this->is_loop ? '_catalog' : '' ), 'text_remove' ) ) );
|
811 |
+
} else {
|
812 |
+
|
813 |
+
$already_on = tinv_get_option( 'add_to_wishlist' . ( $this->is_loop ? '_catalog' : '' ), 'already_on' ) ? sprintf( '<span class="tinvwl_already_on_wishlist-text">%s</span>', apply_filters( 'tinvwl_already_on_wishlist_text' . ( $this->is_loop ? '_loop' : '' ), tinv_get_option( 'add_to_wishlist' . ( $this->is_loop ? '_catalog' : '' ), 'text_already_on' ) ) ) : '';
|
814 |
+
|
815 |
+
$text = sprintf( '<span class="tinvwl_add_to_wishlist-text">%s</span>' . $already_on, $text );
|
816 |
+
}
|
817 |
+
}
|
818 |
+
if ( ! empty( $icon ) ) {
|
819 |
+
$icon_upload = tinv_get_option( 'add_to_wishlist' . ( $this->is_loop ? '_catalog' : '' ), 'icon_upload' );
|
820 |
+
if ( 'custom' === $icon && ! empty( $icon_upload ) ) {
|
821 |
+
$text = sprintf( '<img src="%s" alt="%s" /> %s', esc_url( $icon_upload ), esc_attr( apply_filters( 'tinvwl_added_to_wishlist_text_loop', tinv_get_option( 'add_to_wishlist' . ( $this->is_loop ? '_catalog' : '' ), 'text' ) ) ), $text );
|
822 |
+
}
|
823 |
+
$icon = 'tinvwl-icon-' . $icon;
|
824 |
+
if ( 'custom' !== $icon && $icon_color ) {
|
825 |
+
$icon .= ' icon-' . $icon_color;
|
826 |
+
}
|
827 |
+
}
|
828 |
+
$icon .= $icon_class;
|
829 |
+
|
830 |
+
$icon .= tinv_get_option( 'add_to_wishlist' . ( $this->is_loop ? '_catalog' : '' ), 'already_on' ) ? ' tinvwl-product-already-on-wishlist' : '';
|
831 |
+
|
832 |
+
$icon .= ' ' . tinv_get_option( 'add_to_wishlist' . ( $this->is_loop ? '_catalog' : '' ), 'class' );
|
833 |
+
|
834 |
+
$icon .= ' tinvwl-position-' . tinv_get_option( 'add_to_wishlist' . ( $this->is_loop ? '_catalog' : '' ), 'position' );
|
835 |
+
|
836 |
+
$icon .= ( tinv_get_option( 'add_to_wishlist' . ( $this->is_loop ? '_catalog' : '' ), 'show_preloader' ) ) ? ' ftinvwl-animated' : '';
|
837 |
+
|
838 |
+
$icon .= $this->is_loop ? ' tinvwl-loop' : '';
|
839 |
+
|
840 |
+
$content .= sprintf( '<a role="button" tabindex="0" aria-label="%s" class="tinvwl_add_to_wishlist_button %s" data-tinv-wl-list="[]" data-tinv-wl-product="%s" data-tinv-wl-productvariation="%s" data-tinv-wl-productvariations="%s" data-tinv-wl-producttype="%s" data-tinv-wl-action="add">%s</a>',
|
841 |
+
$button_text,
|
842 |
+
$icon,
|
843 |
+
apply_filters( 'wpml_object_id', ( $this->product->is_type( 'variation' ) ? $this->product->get_parent_id() : $this->product->get_id() ), 'product', true ),
|
844 |
+
apply_filters( 'wpml_object_id', ( ( $this->is_loop && in_array( $this->product->get_type(), array(
|
845 |
+
'variable',
|
846 |
+
'variable-subscription',
|
847 |
+
) ) ) ? $this->variation_id : ( $this->product->is_type( 'variation' ) ? $this->product->get_id() : 0 ) ), 'product', true ),
|
848 |
+
json_encode( ( $this->is_loop && in_array( $this->product->get_type(), array(
|
849 |
+
'variable',
|
850 |
+
'variable-subscription',
|
851 |
+
) ) ) ? $this->variation_ids : ( $this->product->is_type( 'variation' ) ? array( $this->product->get_id() ) : array( 0 ) ) ),
|
852 |
+
$this->product->get_type(),
|
853 |
+
$text );
|
854 |
+
$content .= apply_filters( 'tinvwl_wishlist_button_after', '' );
|
855 |
+
|
856 |
+
if ( ! empty( $text ) ) {
|
857 |
+
$content .= '<div class="tinv-wishlist-clear"></div>';
|
858 |
+
}
|
859 |
+
|
860 |
+
echo apply_filters( 'tinvwl_wishlist_button', $content, $this->wishlist, $this->product, $this->is_loop, $icon, $action, $text ); // WPCS: xss ok.
|
861 |
+
}
|
862 |
+
|
863 |
+
/**
|
864 |
+
* Shortcode basic function
|
865 |
+
*
|
866 |
+
* @param array $atts Array parameter from shortcode.
|
867 |
+
*
|
868 |
+
* @return string
|
869 |
+
* @global object $product
|
870 |
+
*
|
871 |
+
*/
|
872 |
+
function shortcode( $atts = array() ) {
|
873 |
+
global $product;
|
874 |
+
|
875 |
+
$default = array(
|
876 |
+
'product_id' => 0,
|
877 |
+
'variation_id' => 0,
|
878 |
+
'loop' => 'no',
|
879 |
+
);
|
880 |
+
if ( $product && is_a( $product, 'WC_Product' ) ) {
|
881 |
+
$default['product_id'] = $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id();
|
882 |
+
$default['variation_id'] = $product->is_type( 'variation' ) ? $product->get_id() : 0;
|
883 |
+
}
|
884 |
+
$atts = shortcode_atts( $default, $atts );
|
885 |
+
|
886 |
+
ob_start();
|
887 |
+
if ( 'yes' === $atts['loop'] ) {
|
888 |
+
$this->is_loop = true;
|
889 |
+
$this->htmloutput( $atts, true );
|
890 |
+
$this->is_loop = false;
|
891 |
+
} else {
|
892 |
+
$this->htmloutput( $atts, true );
|
893 |
+
}
|
894 |
+
|
895 |
+
return ob_get_clean();
|
896 |
+
}
|
897 |
+
|
898 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public/tinvwl.class.php
CHANGED
@@ -7,15 +7,14 @@
|
|
7 |
*/
|
8 |
|
9 |
// If this file is called directly, abort.
|
10 |
-
if (!defined('ABSPATH')) {
|
11 |
die;
|
12 |
}
|
13 |
|
14 |
/**
|
15 |
* Public pages class
|
16 |
*/
|
17 |
-
class TInvWL_Public_TInvWL
|
18 |
-
{
|
19 |
|
20 |
/**
|
21 |
* Plugin name
|
@@ -52,10 +51,9 @@ class TInvWL_Public_TInvWL
|
|
52 |
*
|
53 |
* @return \TInvWL_Public_TInvWL
|
54 |
*/
|
55 |
-
public static function instance($plugin_name = TINVWL_PREFIX, $version = TINVWL_VERSION)
|
56 |
-
|
57 |
-
|
58 |
-
self::$_instance = new self($plugin_name, $version);
|
59 |
}
|
60 |
|
61 |
return self::$_instance;
|
@@ -67,9 +65,8 @@ class TInvWL_Public_TInvWL
|
|
67 |
* @param string $plugin_name Plugin name.
|
68 |
* @param string $version Plugin version.
|
69 |
*/
|
70 |
-
function __construct($plugin_name, $version)
|
71 |
-
|
72 |
-
$this->_name = $plugin_name;
|
73 |
$this->_version = $version;
|
74 |
$this->pre_load_function();
|
75 |
}
|
@@ -77,38 +74,36 @@ class TInvWL_Public_TInvWL
|
|
77 |
/**
|
78 |
* Create all object and shortcode
|
79 |
*/
|
80 |
-
function pre_load_function()
|
81 |
-
{
|
82 |
|
83 |
-
add_action('init', array(__CLASS__, 'add_rewrite_rules'));
|
84 |
|
85 |
-
add_action('tinvwl_flush_rewrite_rules', array(__CLASS__, 'apply_rewrite_rules'));
|
86 |
|
87 |
-
add_filter('rewrite_rules_array', array($this, 'add_rewrite_rules_raw'), 9999999);
|
88 |
|
89 |
-
add_filter('tinvwl_update_wishlists_data', array($this, 'update_local_wishlists_data'));
|
90 |
|
91 |
-
add_filter('query_vars', array($this, 'add_query_var'));
|
92 |
-
add_action('wp', array($this, 'analytics_referer'));
|
93 |
-
add_action('deleted_user', array($this, 'delete_user_wishlist'));
|
94 |
|
95 |
-
add_action('wp_ajax_nopriv_' . $this->_name . '_css', array($this, 'dynaminc_css'));
|
96 |
-
add_action('wp_ajax_' . $this->_name . '_css', array($this, 'dynaminc_css'));
|
97 |
-
add_action('widgets_init', array($this, 'register_widgets'));
|
98 |
|
99 |
-
add_filter('woocommerce_locate_core_template', array($this, 'locate_template'), 10, 3);
|
100 |
-
add_filter('woocommerce_locate_template', array($this, 'locate_template'), 10, 3);
|
101 |
|
102 |
-
$this->addto
|
103 |
-
$this->view
|
104 |
-
$this->cart
|
105 |
-
$this->topwishlist = TInvWL_Public_WishlistCounter::instance($this->_name);
|
106 |
}
|
107 |
|
108 |
-
function update_local_wishlists_data($state)
|
109 |
-
|
110 |
-
|
111 |
-
delete_transient('_tinvwl_update_wishlists_data');
|
112 |
|
113 |
return true;
|
114 |
}
|
@@ -121,9 +116,8 @@ class TInvWL_Public_TInvWL
|
|
121 |
*
|
122 |
* @return mixed
|
123 |
*/
|
124 |
-
function add_rewrite_rules_raw($rules)
|
125 |
-
|
126 |
-
if (is_array(self::$rules_raw) && tinv_get_option('permalinks', 'force')) {
|
127 |
self::add_rewrite_rules();
|
128 |
$rules = self::$rules_raw + $rules;
|
129 |
}
|
@@ -134,94 +128,88 @@ class TInvWL_Public_TInvWL
|
|
134 |
/**
|
135 |
* Define hooks
|
136 |
*/
|
137 |
-
function define_hooks()
|
138 |
-
|
139 |
-
|
140 |
-
add_filter('language_attributes', array($this, 'add_ogp'), 100);
|
141 |
}
|
142 |
|
143 |
-
if (tinv_get_option('general', 'link_in_myaccount')) {
|
144 |
-
add_filter('woocommerce_account_menu_items', array($this, 'account_menu_items'));
|
145 |
-
add_filter('woocommerce_get_endpoint_url', array($this, 'account_menu_endpoint'), 4, 10);
|
146 |
}
|
147 |
|
148 |
-
add_action('wp_enqueue_scripts', array($this, 'enqueue_header'));
|
149 |
-
add_action('wp_login', array($this, 'transfert_local_to_user'), 10, 2);
|
150 |
-
add_action('wp_logout', array($this, 'logout'), 10, 2);
|
151 |
-
add_action('user_register', array($this, 'transfert_local_to_user_register'));
|
152 |
-
add_action('init', array($this, 'legacy_transfer'), 90);
|
153 |
-
add_action('clear_auth_cookie', array($this, 'set_user_sharekey'));
|
154 |
|
155 |
-
add_action('tinvwl_after_wishlist_table', array($this, 'wishlist_button_action_before'), 0);
|
156 |
-
add_action('tinvwl_after_wishlist_table', array($this, 'wishlist_button_action_after'), 15);
|
157 |
-
add_action('tinvwl_after_wishlist_table', array($this, 'wishlist_button_updcart_before'), 15);
|
158 |
-
add_action('tinvwl_after_wishlist_table', array($this, 'wishlist_button_action_after'), 100);
|
159 |
}
|
160 |
|
161 |
/**
|
162 |
* Add analytic click from wishlist
|
163 |
*/
|
164 |
-
function analytics_referer()
|
165 |
-
|
166 |
-
$product_id
|
167 |
-
if (empty($product_id)) {
|
168 |
return false;
|
169 |
}
|
170 |
|
171 |
$wlp = new TInvWL_Product();
|
172 |
|
173 |
-
$items = $wlp->get(array('ID' => $product_id));
|
174 |
-
$item
|
175 |
-
if (empty($item)) {
|
176 |
return false;
|
177 |
}
|
178 |
-
if (empty($item['data'])) {
|
179 |
return false;
|
180 |
}
|
181 |
-
$wishlist = tinv_wishlist_get($item['wishlist_id']);
|
182 |
|
183 |
-
$wla = new TInvWL_Analytics($wishlist, $this->_name);
|
184 |
-
if ($wishlist['is_owner']) {
|
185 |
-
$wla->click_author_product_from_wl($item['product_id'], $item['variation_id']);
|
186 |
} else {
|
187 |
-
$wla->click_product_from_wl($item['product_id'], $item['variation_id']);
|
188 |
}
|
189 |
-
wp_redirect(remove_query_arg('tiwp')); // @codingStandardsIgnoreLine WordPress.VIP.RestrictedFunctions.wp_redirect
|
190 |
}
|
191 |
|
192 |
/**
|
193 |
* Left class button
|
194 |
*/
|
195 |
-
function wishlist_button_action_before()
|
196 |
-
{
|
197 |
echo '<div class="tinvwl-to-left look_in">';
|
198 |
}
|
199 |
|
200 |
/**
|
201 |
* Right class button
|
202 |
*/
|
203 |
-
function wishlist_button_updcart_before()
|
204 |
-
{
|
205 |
echo '<div class="tinvwl-to-right look_in">';
|
206 |
}
|
207 |
|
208 |
/**
|
209 |
* Close class button
|
210 |
*/
|
211 |
-
function wishlist_button_action_after()
|
212 |
-
{
|
213 |
echo '</div>';
|
214 |
}
|
215 |
|
216 |
/**
|
217 |
* Register Widgets
|
218 |
*/
|
219 |
-
function register_widgets()
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
register_widget('TInvWL_Public_Widget_' . $path);
|
225 |
}
|
226 |
}
|
227 |
|
@@ -234,10 +222,9 @@ class TInvWL_Public_TInvWL
|
|
234 |
*
|
235 |
* @return string
|
236 |
*/
|
237 |
-
function locate_template($core_file, $template, $template_base)
|
238 |
-
|
239 |
-
|
240 |
-
if (empty($_core_file)) {
|
241 |
return $core_file;
|
242 |
}
|
243 |
|
@@ -247,16 +234,14 @@ class TInvWL_Public_TInvWL
|
|
247 |
/**
|
248 |
* Update rewrite url for wishlist
|
249 |
*/
|
250 |
-
public static function update_rewrite_rules()
|
251 |
-
|
252 |
-
wp_schedule_single_event(time(), 'tinvwl_flush_rewrite_rules');
|
253 |
}
|
254 |
|
255 |
/**
|
256 |
* Apply rewrite url for wishlist
|
257 |
*/
|
258 |
-
public static function apply_rewrite_rules()
|
259 |
-
{
|
260 |
self::add_rewrite_rules();
|
261 |
flush_rewrite_rules();
|
262 |
}
|
@@ -264,78 +249,77 @@ class TInvWL_Public_TInvWL
|
|
264 |
/**
|
265 |
* Create rewrite url for wishlist
|
266 |
*/
|
267 |
-
public static function add_rewrite_rules()
|
268 |
-
|
269 |
-
$
|
270 |
-
$pages = array($id);
|
271 |
$language_codes = array();
|
272 |
-
if (function_exists('pll_languages_list')) {
|
273 |
-
$language_codes = implode('|', pll_languages_list());
|
274 |
-
$translations
|
275 |
-
$pages
|
276 |
} else {
|
277 |
-
$languages = apply_filters('wpml_active_languages', array(), array(
|
278 |
'skip_missing' => 0,
|
279 |
-
'orderby'
|
280 |
-
));
|
281 |
-
if (!empty($languages)) {
|
282 |
-
foreach ($languages as $l) {
|
283 |
-
$pages[]
|
284 |
$language_codes[] = $l['language_code'];
|
285 |
}
|
286 |
-
$pages
|
287 |
-
$language_codes = implode('|', array_unique($language_codes));
|
288 |
}
|
289 |
}
|
290 |
|
291 |
-
$pages = array_filter($pages);
|
292 |
-
if (!empty($pages)) {
|
293 |
-
foreach ($pages as $page) {
|
294 |
-
$page = get_post($page);
|
295 |
|
296 |
-
if (
|
297 |
continue;
|
298 |
}
|
299 |
|
300 |
$page_slug = $page->post_name;
|
301 |
|
302 |
-
if ($language_codes && (defined('POLYLANG_VERSION') || defined('ICL_PLUGIN_PATH'))) {
|
303 |
-
add_rewrite_rule('^(' . $language_codes . ')/(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/wl_page/([0-9]{1,})/{0,1}$', 'index.php?pagename=$matches[2]&tinvwlID=$matches[4]&wl_paged=$matches[5]&lang=$matches[1]', 'top');
|
304 |
-
self::$rules_raw['^(' . $language_codes . ')/(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/wl_page/([0-9]{1,})/{0,1}$'] = 'index.php?pagename=$matches[2]&tinvwlID=$matches[4]&wl_paged=$matches[5]&lang=$matches[1]';
|
305 |
-
add_rewrite_rule('^(' . $language_codes . ')/(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/{0,1}$', 'index.php?pagename=$matches[2]&tinvwlID=$matches[4]&lang=$matches[1]', 'top');
|
306 |
-
self::$rules_raw['^(' . $language_codes . ')/(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/{0,1}$'] = 'index.php?pagename=$matches[2]&tinvwlID=$matches[4]&lang=$matches[1]';
|
307 |
}
|
308 |
|
309 |
// Wishlist on frontpage.
|
310 |
-
$page_on_front = absint(get_option('page_on_front'));
|
311 |
-
if ($page_on_front && 'page' === get_option('show_on_front') && $page->ID === $page_on_front) {
|
312 |
-
add_filter('redirect_canonical', array(
|
313 |
'TInvWL_Public_TInvWL',
|
314 |
'disable_canonical_redirect_for_front_page',
|
315 |
-
));
|
316 |
// Match the front page and pass item value as a query var.
|
317 |
-
add_rewrite_rule('^([A-Fa-f0-9]{6})?/{0,1}$', 'index.php?page_id=' . $page_on_front . '&tinvwlID=$matches[1]', 'top');
|
318 |
self::$rules_raw['^([A-Fa-f0-9]{6})?/{0,1}$'] = 'index.php?page_id=' . $page_on_front . '&tinvwlID=$matches[1]';
|
319 |
-
add_rewrite_rule('^([A-Fa-f0-9]{6})?/wl_page/([0-9]{1,})/{0,1}$', 'index.php?page_id=' . $page_on_front . '&tinvwlID=$matches[3]&wl_paged=$matches[4]', 'top');
|
320 |
self::$rules_raw['^([A-Fa-f0-9]{6})?/wl_page/([0-9]{1,})/{0,1}$'] = 'index.php?page_id=' . $page_on_front . '&tinvwlID=$matches[3]&wl_paged=$matches[4]';
|
321 |
}
|
322 |
|
323 |
-
add_rewrite_rule('(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/wl_page/([0-9]{1,})/{0,1}$', 'index.php?pagename=$matches[1]&tinvwlID=$matches[3]&wl_paged=$matches[4]', 'top');
|
324 |
-
self::$rules_raw['(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/wl_page/([0-9]{1,})/{0,1}$'] = 'index.php?pagename=$matches[1]&tinvwlID=$matches[3]&wl_paged=$matches[4]';
|
325 |
-
add_rewrite_rule('(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/{0,1}$', 'index.php?pagename=$matches[1]&tinvwlID=$matches[3]', 'top');
|
326 |
-
self::$rules_raw['(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/{0,1}$'] = 'index.php?pagename=$matches[1]&tinvwlID=$matches[3]';
|
327 |
|
328 |
// Wishlist on shop page.
|
329 |
-
$shop_page_id = wc_get_page_id('shop');
|
330 |
-
if ($shop_page_id && $page->ID === $shop_page_id) {
|
331 |
-
$shop
|
332 |
$shop_slug = $shop->post_name;
|
333 |
-
add_rewrite_rule('(([^/]+/)*' . $shop_slug . ')/([A-Fa-f0-9]{6})?/{0,1}$', 'index.php?post_type=product&tinvwlID=$matches[3]', 'top');
|
334 |
-
self::$rules_raw['(([^/]+/)*' . $shop_slug . ')/([A-Fa-f0-9]{6})?/{0,1}$'] = 'index.php?post_type=product&tinvwlID=$matches[3]';
|
335 |
-
add_rewrite_rule('(([^/]+/)*' . $shop_slug . ')/([A-Fa-f0-9]{6})?/wl_page/([0-9]{1,})/{0,1}$', 'index.php?post_type=product&tinvwlID=$matches[3]&wl_paged=$matches[4]', 'top');
|
336 |
-
self::$rules_raw['(([^/]+/)*' . $shop_slug . ')/([A-Fa-f0-9]{6})?/wl_page/([0-9]{1,})/{0,1}$'] = 'index.php?post_type=product&tinvwlID=$matches[3]&wl_paged=$matches[4]';
|
337 |
-
add_rewrite_rule('(([^/]+/)*' . $shop_slug . ')/([A-Fa-f0-9]{6})?/page/([0-9]{1,})/{0,1}$', 'index.php?post_type=product&tinvwlID=$matches[3]&paged=$matches[4]', 'top');
|
338 |
-
self::$rules_raw['(([^/]+/)*' . $shop_slug . ')/([A-Fa-f0-9]{6})?/page/([0-9]{1,})/{0,1}$'] = 'index.php?post_type=product&tinvwlID=$matches[3]&paged=$matches[4]';
|
339 |
}
|
340 |
}
|
341 |
}
|
@@ -348,11 +332,10 @@ class TInvWL_Public_TInvWL
|
|
348 |
*
|
349 |
* @return bool
|
350 |
*/
|
351 |
-
public static function disable_canonical_redirect_for_front_page($redirect)
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
if (is_page($page_on_front)) {
|
356 |
$redirect = false;
|
357 |
}
|
358 |
}
|
@@ -367,8 +350,7 @@ class TInvWL_Public_TInvWL
|
|
367 |
*
|
368 |
* @return array
|
369 |
*/
|
370 |
-
function add_query_var($public_var)
|
371 |
-
{
|
372 |
$public_var[] = 'tinvwlID';
|
373 |
$public_var[] = 'tiws';
|
374 |
$public_var[] = 'tiwp';
|
@@ -384,17 +366,16 @@ class TInvWL_Public_TInvWL
|
|
384 |
*
|
385 |
* @return string
|
386 |
*/
|
387 |
-
function add_ogp($text)
|
388 |
-
{
|
389 |
global $wp_query;
|
390 |
-
if (isset($wp_query) && is_page(apply_filters('wpml_object_id', tinv_get_option('page', 'wishlist'), 'page', true))) {
|
391 |
-
if (!preg_match('/prefix\=/i', $text)) {
|
392 |
$text .= ' prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# product: http://ogp.me/ns/product#"';
|
393 |
}
|
394 |
-
if (!preg_match('/itemscope/i', $text)) {
|
395 |
$text .= ' itemscope';
|
396 |
}
|
397 |
-
if (!preg_match('/itemtype\=/i', $text)) {
|
398 |
$text .= ' itemtype="http://schema.org/Offer"';
|
399 |
}
|
400 |
}
|
@@ -407,12 +388,11 @@ class TInvWL_Public_TInvWL
|
|
407 |
*
|
408 |
* @return boolean
|
409 |
*/
|
410 |
-
function is_pluginpage()
|
411 |
-
|
412 |
-
$pages =
|
413 |
-
$pages
|
414 |
-
|
415 |
-
if (is_page(apply_filters('wpml_object_id', $page, 'page', true))) {
|
416 |
return true;
|
417 |
}
|
418 |
}
|
@@ -423,9 +403,8 @@ class TInvWL_Public_TInvWL
|
|
423 |
/**
|
424 |
* Load style and javascript
|
425 |
*/
|
426 |
-
function enqueue_header()
|
427 |
-
|
428 |
-
if ($this->is_pluginpage()) {
|
429 |
$this->enqueue_wc_styles();
|
430 |
}
|
431 |
$this->enqueue_scripts();
|
@@ -435,39 +414,38 @@ class TInvWL_Public_TInvWL
|
|
435 |
/**
|
436 |
* Load style
|
437 |
*/
|
438 |
-
function enqueue_styles()
|
439 |
-
|
440 |
-
|
441 |
-
wp_enqueue_style($this->_name . '-webfont
|
442 |
-
|
443 |
-
wp_style_add_data($this->_name . '-webfont', '
|
444 |
-
|
445 |
-
add_filter('style_loader_tag', array($this, 'font_loader_tag_filter'), 100, 2);
|
446 |
}
|
447 |
-
wp_enqueue_style('tinvwl', TINVWL_URL . 'assets/css/public.min.css', array(), $this->_version, 'all');
|
448 |
-
wp_style_add_data('tinvwl', 'rtl', 'replace');
|
449 |
-
wp_style_add_data('tinvwl', 'suffix', '.min');
|
450 |
-
|
451 |
-
if (!tinv_get_option('style', 'customstyle')) {
|
452 |
-
wp_enqueue_style('tinvwl-theme', TINVWL_URL . 'assets/css/theme.min.css', array(), $this->_version, 'all');
|
453 |
-
wp_style_add_data('tinvwl-theme', 'rtl', 'replace');
|
454 |
-
wp_style_add_data('tinvwl-theme', 'suffix', '.min');
|
455 |
}
|
456 |
-
if (!tinv_get_option('style', 'customstyle') || (tinv_get_option('style_plain', 'allow') && tinv_get_option('style_plain', 'css'))) {
|
457 |
$newcss = $this->dynaminc_css();
|
458 |
-
if ($newcss) {
|
459 |
-
$name_style = tinv_get_option('style', 'customstyle') ? 'tinvwl' : 'tinvwl-theme';
|
460 |
-
wp_add_inline_style($name_style, $newcss);
|
461 |
}
|
462 |
}
|
463 |
}
|
464 |
|
465 |
/* Preload Icons font */
|
466 |
-
function font_loader_tag_filter($html, $handle)
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
return str_replace("rel='stylesheet'", "rel='preload' as='font' type='font/woff2' crossorigin='anonymous'", $html);
|
471 |
}
|
472 |
|
473 |
return $html;
|
@@ -480,10 +458,9 @@ class TInvWL_Public_TInvWL
|
|
480 |
*
|
481 |
* @return string
|
482 |
*/
|
483 |
-
function compress_css($css)
|
484 |
-
|
485 |
-
$css = preg_replace('
|
486 |
-
$css = preg_replace('/(\r|\n|\t| {2,})/', ' ', $css);
|
487 |
|
488 |
return $css;
|
489 |
}
|
@@ -491,28 +468,27 @@ class TInvWL_Public_TInvWL
|
|
491 |
/**
|
492 |
* Generate dynaminc css
|
493 |
*/
|
494 |
-
function dynaminc_css()
|
495 |
-
|
496 |
-
|
497 |
-
if (!$css) {
|
498 |
$css = '';
|
499 |
-
if (!tinv_get_option('style', 'customstyle')) {
|
500 |
-
$newcss = tinv_get_option('style_options', 'css');
|
501 |
-
if ($newcss) {
|
502 |
-
$newcss = $this->compress_css($newcss);
|
503 |
-
$css
|
504 |
}
|
505 |
}
|
506 |
-
if (tinv_get_option('style_plain', 'allow')) {
|
507 |
-
$newcss = tinv_get_option('style_plain', 'css');
|
508 |
-
if ($newcss) {
|
509 |
-
$newcss = $this->compress_css($newcss);
|
510 |
-
$css
|
511 |
}
|
512 |
}
|
513 |
$image_url = TINVWL_URL . 'assets/img/';
|
514 |
-
$css
|
515 |
-
set_transient(TINVWL_PREFIX . '_dynamic_', $css, DAY_IN_SECONDS);
|
516 |
}
|
517 |
|
518 |
return $css;
|
@@ -521,12 +497,11 @@ class TInvWL_Public_TInvWL
|
|
521 |
/**
|
522 |
* Add woocommerce style
|
523 |
*/
|
524 |
-
function enqueue_wc_styles()
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
wp_enqueue_style($handle);
|
530 |
}
|
531 |
}
|
532 |
}
|
@@ -534,57 +509,62 @@ class TInvWL_Public_TInvWL
|
|
534 |
/**
|
535 |
* Load javascript
|
536 |
*/
|
537 |
-
function enqueue_scripts()
|
538 |
-
|
539 |
-
$
|
540 |
-
wp_register_script($this->_name
|
541 |
-
wp_register_script($this->_name, TINVWL_URL . 'assets/js/public' . $suffix . '.js', array(
|
542 |
'jquery',
|
543 |
'js-cookie',
|
544 |
-
apply_filters('tinvwl_wc_cart_fragments_enabled', true) ? 'wc-cart-fragments' : 'jquery',
|
545 |
-
), $this->_version, true);
|
546 |
|
547 |
$args = array(
|
548 |
-
'text_create'
|
549 |
-
'text_already_in'
|
550 |
-
'simple_flow'
|
551 |
-
'hide_zero_counter'
|
552 |
-
'i18n_make_a_selection_text' => esc_attr__('Please select some product options before adding this product to your wishlist.', 'ti-woocommerce-wishlist'),
|
553 |
-
'tinvwl_break_submit'
|
554 |
-
'tinvwl_clipboard'
|
555 |
-
'allow_parent_variable'
|
556 |
-
'block_ajax_wishlists_data'
|
557 |
-
'update_wishlists_data'
|
558 |
-
'hash_key'
|
559 |
-
'nonce'
|
560 |
-
'rest_root'
|
561 |
-
'plugin_url'
|
562 |
);
|
563 |
|
564 |
-
if (function_exists('wpml_get_current_language')) {
|
565 |
|
566 |
global $sitepress;
|
567 |
|
568 |
-
if ($sitepress && $sitepress instanceof SitePress) {
|
569 |
$wpml_settings = $sitepress->get_settings();
|
570 |
-
if (isset($wpml_settings['custom_posts_sync_option']) && isset($wpml_settings['custom_posts_sync_option']['product']) &&
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
571 |
$args['wpml'] = wpml_get_current_language();
|
572 |
}
|
573 |
}
|
574 |
}
|
575 |
|
576 |
-
wp_localize_script($this->_name, 'tinvwl_add_to_wishlist', $args);
|
577 |
|
578 |
-
if (wp_script_is('woocommerce', 'enqueued')) {
|
579 |
-
wp_enqueue_script('tinvwl');
|
580 |
}
|
581 |
}
|
582 |
|
583 |
/**
|
584 |
* Load function
|
585 |
*/
|
586 |
-
function load_function()
|
587 |
-
{
|
588 |
$this->define_hooks();
|
589 |
}
|
590 |
|
@@ -596,14 +576,12 @@ class TInvWL_Public_TInvWL
|
|
596 |
*
|
597 |
* @return boolean
|
598 |
*/
|
599 |
-
function transfert_local_to_user($user_login, $user)
|
600 |
-
|
601 |
-
return $this->transfert_local_to_user_register($user->ID);
|
602 |
}
|
603 |
|
604 |
-
function logout($user_id)
|
605 |
-
|
606 |
-
set_transient('_tinvwl_update_wishlists_data', '1');
|
607 |
}
|
608 |
|
609 |
/**
|
@@ -611,45 +589,44 @@ class TInvWL_Public_TInvWL
|
|
611 |
*
|
612 |
* @param integer $user_id New user id.
|
613 |
*/
|
614 |
-
function transfert_local_to_user_register($user_id)
|
615 |
-
{
|
616 |
|
617 |
-
set_transient('_tinvwl_update_wishlists_data', '1');
|
618 |
|
619 |
-
$wl
|
620 |
$wishlist = $wl->get_by_sharekey_default();
|
621 |
-
if (!empty($wishlist)) {
|
622 |
-
$wishlist = array_shift($wishlist);
|
623 |
-
if (empty($wishlist['author'])) {
|
624 |
-
$wlpl
|
625 |
-
$wl->user
|
626 |
-
$_wishlist = $wl->get_by_user_default($user_id);
|
627 |
-
if (empty($_wishlist)) {
|
628 |
$wishlist['author'] = $user_id;
|
629 |
-
unset($wishlist['title']);
|
630 |
-
$wl->update($wishlist['ID'], $wishlist);
|
631 |
-
$wlp
|
632 |
-
$products = $wlp->get_wishlist(array('external' => false));
|
633 |
-
foreach ($products as $product) {
|
634 |
$product['author'] = $user_id;
|
635 |
-
$wlp->update($product);
|
636 |
}
|
637 |
} else {
|
638 |
-
$_wishlist = array_shift($_wishlist);
|
639 |
-
if ($wishlist['ID'] != $_wishlist['ID']) {
|
640 |
-
$wlp
|
641 |
-
$products = $wlpl->get_wishlist(array('external' => false));
|
642 |
-
$added
|
643 |
-
foreach ($products as $product) {
|
644 |
-
unset($product['author']);
|
645 |
-
unset($product['wishlist_id']);
|
646 |
-
$added = $added && $wlp->add_product($product);
|
647 |
}
|
648 |
-
if ($added) {
|
649 |
$wlpl->remove_product_from_wl();
|
650 |
}
|
651 |
}
|
652 |
-
$wl->set_sharekey($_wishlist['share_key']);
|
653 |
}
|
654 |
}
|
655 |
}
|
@@ -658,13 +635,12 @@ class TInvWL_Public_TInvWL
|
|
658 |
/**
|
659 |
* Set the default wishlist key if the user loguot
|
660 |
*/
|
661 |
-
public function set_user_sharekey()
|
662 |
-
|
663 |
-
$wl = new TInvWL_Wishlist($this->_name);
|
664 |
$wishlist = $wl->get_by_user_default();
|
665 |
-
if (!empty($wishlist)) {
|
666 |
-
$wishlist = array_shift($wishlist);
|
667 |
-
$wl->set_sharekey($wishlist['share_key']);
|
668 |
}
|
669 |
}
|
670 |
|
@@ -675,15 +651,14 @@ class TInvWL_Public_TInvWL
|
|
675 |
*
|
676 |
* @return array
|
677 |
*/
|
678 |
-
function account_menu_items($items)
|
679 |
-
|
680 |
-
$
|
681 |
-
|
682 |
-
array_slice($items, 0, $index_position, true),
|
683 |
array(
|
684 |
-
'tinv_wishlist' => __('Wishlist', 'ti-woocommerce-wishlist'),
|
685 |
),
|
686 |
-
array_slice($items, $index_position, null, true)
|
687 |
);
|
688 |
flush_rewrite_rules();
|
689 |
|
@@ -700,9 +675,8 @@ class TInvWL_Public_TInvWL
|
|
700 |
*
|
701 |
* @return string
|
702 |
*/
|
703 |
-
function account_menu_endpoint($url, $endpoint, $value, $permalink)
|
704 |
-
|
705 |
-
if ('tinv_wishlist' === $endpoint) {
|
706 |
$url = tinv_url_wishlist_default();
|
707 |
}
|
708 |
|
@@ -714,16 +688,15 @@ class TInvWL_Public_TInvWL
|
|
714 |
*
|
715 |
* @param integer $id Removed userid.
|
716 |
*/
|
717 |
-
function delete_user_wishlist($id)
|
718 |
-
|
719 |
-
$
|
720 |
-
$wishlists = $wl->get(array(
|
721 |
'author' => $id,
|
722 |
-
'count'
|
723 |
-
));
|
724 |
-
if (!empty($wishlists)) {
|
725 |
-
foreach ($wishlists as $wishlist) {
|
726 |
-
$wl->remove($wishlist['ID']);
|
727 |
}
|
728 |
}
|
729 |
}
|
@@ -731,24 +704,23 @@ class TInvWL_Public_TInvWL
|
|
731 |
/**
|
732 |
* Export cookies wishlist to database
|
733 |
*/
|
734 |
-
function legacy_transfer()
|
735 |
-
|
736 |
-
$
|
737 |
-
$products
|
738 |
-
|
739 |
-
$wl = new TInvWL_Wishlist($this->_name);
|
740 |
$wishlist = $wl->add_user_default();
|
741 |
|
742 |
-
$wlp = new TInvWL_Product($wishlist, $this->_name);
|
743 |
|
744 |
$added = true;
|
745 |
-
foreach ($products as $product) {
|
746 |
-
unset($product['author']);
|
747 |
-
if (
|
748 |
$added = false;
|
749 |
}
|
750 |
}
|
751 |
-
if ($added) {
|
752 |
$wlpl->remove_product_from_wl();
|
753 |
}
|
754 |
}
|
7 |
*/
|
8 |
|
9 |
// If this file is called directly, abort.
|
10 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
11 |
die;
|
12 |
}
|
13 |
|
14 |
/**
|
15 |
* Public pages class
|
16 |
*/
|
17 |
+
class TInvWL_Public_TInvWL {
|
|
|
18 |
|
19 |
/**
|
20 |
* Plugin name
|
51 |
*
|
52 |
* @return \TInvWL_Public_TInvWL
|
53 |
*/
|
54 |
+
public static function instance( $plugin_name = TINVWL_PREFIX, $version = TINVWL_VERSION ) {
|
55 |
+
if ( is_null( self::$_instance ) ) {
|
56 |
+
self::$_instance = new self( $plugin_name, $version );
|
|
|
57 |
}
|
58 |
|
59 |
return self::$_instance;
|
65 |
* @param string $plugin_name Plugin name.
|
66 |
* @param string $version Plugin version.
|
67 |
*/
|
68 |
+
function __construct( $plugin_name, $version ) {
|
69 |
+
$this->_name = $plugin_name;
|
|
|
70 |
$this->_version = $version;
|
71 |
$this->pre_load_function();
|
72 |
}
|
74 |
/**
|
75 |
* Create all object and shortcode
|
76 |
*/
|
77 |
+
function pre_load_function() {
|
|
|
78 |
|
79 |
+
add_action( 'init', array( __CLASS__, 'add_rewrite_rules' ) );
|
80 |
|
81 |
+
add_action( 'tinvwl_flush_rewrite_rules', array( __CLASS__, 'apply_rewrite_rules' ) );
|
82 |
|
83 |
+
add_filter( 'rewrite_rules_array', array( $this, 'add_rewrite_rules_raw' ), 9999999 );
|
84 |
|
85 |
+
add_filter( 'tinvwl_update_wishlists_data', array( $this, 'update_local_wishlists_data' ) );
|
86 |
|
87 |
+
add_filter( 'query_vars', array( $this, 'add_query_var' ) );
|
88 |
+
add_action( 'wp', array( $this, 'analytics_referer' ) );
|
89 |
+
add_action( 'deleted_user', array( $this, 'delete_user_wishlist' ) );
|
90 |
|
91 |
+
add_action( 'wp_ajax_nopriv_' . $this->_name . '_css', array( $this, 'dynaminc_css' ) );
|
92 |
+
add_action( 'wp_ajax_' . $this->_name . '_css', array( $this, 'dynaminc_css' ) );
|
93 |
+
add_action( 'widgets_init', array( $this, 'register_widgets' ) );
|
94 |
|
95 |
+
add_filter( 'woocommerce_locate_core_template', array( $this, 'locate_template' ), 10, 3 );
|
96 |
+
add_filter( 'woocommerce_locate_template', array( $this, 'locate_template' ), 10, 3 );
|
97 |
|
98 |
+
$this->addto = TInvWL_Public_AddToWishlist::instance( $this->_name );
|
99 |
+
$this->view = TInvWL_Public_Wishlist_View::instance( $this->_name );
|
100 |
+
$this->cart = TInvWL_Public_Cart::instance( $this->_name );
|
101 |
+
$this->topwishlist = TInvWL_Public_WishlistCounter::instance( $this->_name );
|
102 |
}
|
103 |
|
104 |
+
function update_local_wishlists_data( $state ) {
|
105 |
+
if ( get_transient( '_tinvwl_update_wishlists_data' ) ) {
|
106 |
+
delete_transient( '_tinvwl_update_wishlists_data' );
|
|
|
107 |
|
108 |
return true;
|
109 |
}
|
116 |
*
|
117 |
* @return mixed
|
118 |
*/
|
119 |
+
function add_rewrite_rules_raw( $rules ) {
|
120 |
+
if ( is_array( self::$rules_raw ) && tinv_get_option( 'permalinks', 'force' ) ) {
|
|
|
121 |
self::add_rewrite_rules();
|
122 |
$rules = self::$rules_raw + $rules;
|
123 |
}
|
128 |
/**
|
129 |
* Define hooks
|
130 |
*/
|
131 |
+
function define_hooks() {
|
132 |
+
if ( tinv_get_option( 'social', 'facebook' ) ) {
|
133 |
+
add_filter( 'language_attributes', array( $this, 'add_ogp' ), 100 );
|
|
|
134 |
}
|
135 |
|
136 |
+
if ( tinv_get_option( 'general', 'link_in_myaccount' ) ) {
|
137 |
+
add_filter( 'woocommerce_account_menu_items', array( $this, 'account_menu_items' ) );
|
138 |
+
add_filter( 'woocommerce_get_endpoint_url', array( $this, 'account_menu_endpoint' ), 4, 10 );
|
139 |
}
|
140 |
|
141 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_header' ) );
|
142 |
+
add_action( 'wp_login', array( $this, 'transfert_local_to_user' ), 10, 2 );
|
143 |
+
add_action( 'wp_logout', array( $this, 'logout' ), 10, 2 );
|
144 |
+
add_action( 'user_register', array( $this, 'transfert_local_to_user_register' ) );
|
145 |
+
add_action( 'init', array( $this, 'legacy_transfer' ), 90 );
|
146 |
+
add_action( 'clear_auth_cookie', array( $this, 'set_user_sharekey' ) );
|
147 |
|
148 |
+
add_action( 'tinvwl_after_wishlist_table', array( $this, 'wishlist_button_action_before' ), 0 );
|
149 |
+
add_action( 'tinvwl_after_wishlist_table', array( $this, 'wishlist_button_action_after' ), 15 );
|
150 |
+
add_action( 'tinvwl_after_wishlist_table', array( $this, 'wishlist_button_updcart_before' ), 15 );
|
151 |
+
add_action( 'tinvwl_after_wishlist_table', array( $this, 'wishlist_button_action_after' ), 100 );
|
152 |
}
|
153 |
|
154 |
/**
|
155 |
* Add analytic click from wishlist
|
156 |
*/
|
157 |
+
function analytics_referer() {
|
158 |
+
$product_id = absint( get_query_var( 'tiwp' ) );
|
159 |
+
if ( empty( $product_id ) ) {
|
|
|
160 |
return false;
|
161 |
}
|
162 |
|
163 |
$wlp = new TInvWL_Product();
|
164 |
|
165 |
+
$items = $wlp->get( array( 'ID' => $product_id ) );
|
166 |
+
$item = array_shift( $items );
|
167 |
+
if ( empty( $item ) ) {
|
168 |
return false;
|
169 |
}
|
170 |
+
if ( empty( $item['data'] ) ) {
|
171 |
return false;
|
172 |
}
|
173 |
+
$wishlist = tinv_wishlist_get( $item['wishlist_id'] );
|
174 |
|
175 |
+
$wla = new TInvWL_Analytics( $wishlist, $this->_name );
|
176 |
+
if ( $wishlist['is_owner'] ) {
|
177 |
+
$wla->click_author_product_from_wl( $item['product_id'], $item['variation_id'] );
|
178 |
} else {
|
179 |
+
$wla->click_product_from_wl( $item['product_id'], $item['variation_id'] );
|
180 |
}
|
181 |
+
wp_redirect( remove_query_arg( 'tiwp' ) ); // @codingStandardsIgnoreLine WordPress.VIP.RestrictedFunctions.wp_redirect
|
182 |
}
|
183 |
|
184 |
/**
|
185 |
* Left class button
|
186 |
*/
|
187 |
+
function wishlist_button_action_before() {
|
|
|
188 |
echo '<div class="tinvwl-to-left look_in">';
|
189 |
}
|
190 |
|
191 |
/**
|
192 |
* Right class button
|
193 |
*/
|
194 |
+
function wishlist_button_updcart_before() {
|
|
|
195 |
echo '<div class="tinvwl-to-right look_in">';
|
196 |
}
|
197 |
|
198 |
/**
|
199 |
* Close class button
|
200 |
*/
|
201 |
+
function wishlist_button_action_after() {
|
|
|
202 |
echo '</div>';
|
203 |
}
|
204 |
|
205 |
/**
|
206 |
* Register Widgets
|
207 |
*/
|
208 |
+
function register_widgets() {
|
209 |
+
$paths = glob( TINVWL_PATH . 'public' . DIRECTORY_SEPARATOR . 'widget' . DIRECTORY_SEPARATOR . '*.class.php' );
|
210 |
+
foreach ( $paths as $path ) {
|
211 |
+
$path = ucfirst( str_replace( '.class.php', '', basename( $path ) ) );
|
212 |
+
register_widget( 'TInvWL_Public_Widget_' . $path );
|
|
|
213 |
}
|
214 |
}
|
215 |
|
222 |
*
|
223 |
* @return string
|
224 |
*/
|
225 |
+
function locate_template( $core_file, $template, $template_base ) {
|
226 |
+
$_core_file = tinv_wishlist_locate_template( $template, $template_base );
|
227 |
+
if ( empty( $_core_file ) ) {
|
|
|
228 |
return $core_file;
|
229 |
}
|
230 |
|
234 |
/**
|
235 |
* Update rewrite url for wishlist
|
236 |
*/
|
237 |
+
public static function update_rewrite_rules() {
|
238 |
+
wp_schedule_single_event( time(), 'tinvwl_flush_rewrite_rules' );
|
|
|
239 |
}
|
240 |
|
241 |
/**
|
242 |
* Apply rewrite url for wishlist
|
243 |
*/
|
244 |
+
public static function apply_rewrite_rules() {
|
|
|
245 |
self::add_rewrite_rules();
|
246 |
flush_rewrite_rules();
|
247 |
}
|
249 |
/**
|
250 |
* Create rewrite url for wishlist
|
251 |
*/
|
252 |
+
public static function add_rewrite_rules() {
|
253 |
+
$id = tinv_get_option( 'page', 'wishlist' );
|
254 |
+
$pages = array( $id );
|
|
|
255 |
$language_codes = array();
|
256 |
+
if ( function_exists( 'pll_languages_list' ) ) {
|
257 |
+
$language_codes = implode( '|', pll_languages_list() );
|
258 |
+
$translations = PLL()->model->post->get_translations( $id );
|
259 |
+
$pages = array_merge( $pages, array_values( $translations ) );
|
260 |
} else {
|
261 |
+
$languages = apply_filters( 'wpml_active_languages', array(), array(
|
262 |
'skip_missing' => 0,
|
263 |
+
'orderby' => 'code',
|
264 |
+
) );
|
265 |
+
if ( ! empty( $languages ) ) {
|
266 |
+
foreach ( $languages as $l ) {
|
267 |
+
$pages[] = apply_filters( 'wpml_object_id', $id, 'page', true, $l['language_code'] );
|
268 |
$language_codes[] = $l['language_code'];
|
269 |
}
|
270 |
+
$pages = array_unique( $pages );
|
271 |
+
$language_codes = implode( '|', array_unique( $language_codes ) );
|
272 |
}
|
273 |
}
|
274 |
|
275 |
+
$pages = array_filter( $pages );
|
276 |
+
if ( ! empty( $pages ) ) {
|
277 |
+
foreach ( $pages as $page ) {
|
278 |
+
$page = get_post( $page );
|
279 |
|
280 |
+
if ( ! $page ) {
|
281 |
continue;
|
282 |
}
|
283 |
|
284 |
$page_slug = $page->post_name;
|
285 |
|
286 |
+
if ( $language_codes && ( defined( 'POLYLANG_VERSION' ) || defined( 'ICL_PLUGIN_PATH' ) ) ) {
|
287 |
+
add_rewrite_rule( '^(' . $language_codes . ')/(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/wl_page/([0-9]{1,})/{0,1}$', 'index.php?pagename=$matches[2]&tinvwlID=$matches[4]&wl_paged=$matches[5]&lang=$matches[1]', 'top' );
|
288 |
+
self::$rules_raw[ '^(' . $language_codes . ')/(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/wl_page/([0-9]{1,})/{0,1}$' ] = 'index.php?pagename=$matches[2]&tinvwlID=$matches[4]&wl_paged=$matches[5]&lang=$matches[1]';
|
289 |
+
add_rewrite_rule( '^(' . $language_codes . ')/(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/{0,1}$', 'index.php?pagename=$matches[2]&tinvwlID=$matches[4]&lang=$matches[1]', 'top' );
|
290 |
+
self::$rules_raw[ '^(' . $language_codes . ')/(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/{0,1}$' ] = 'index.php?pagename=$matches[2]&tinvwlID=$matches[4]&lang=$matches[1]';
|
291 |
}
|
292 |
|
293 |
// Wishlist on frontpage.
|
294 |
+
$page_on_front = absint( get_option( 'page_on_front' ) );
|
295 |
+
if ( $page_on_front && 'page' === get_option( 'show_on_front' ) && $page->ID === $page_on_front ) {
|
296 |
+
add_filter( 'redirect_canonical', array(
|
297 |
'TInvWL_Public_TInvWL',
|
298 |
'disable_canonical_redirect_for_front_page',
|
299 |
+
) );
|
300 |
// Match the front page and pass item value as a query var.
|
301 |
+
add_rewrite_rule( '^([A-Fa-f0-9]{6})?/{0,1}$', 'index.php?page_id=' . $page_on_front . '&tinvwlID=$matches[1]', 'top' );
|
302 |
self::$rules_raw['^([A-Fa-f0-9]{6})?/{0,1}$'] = 'index.php?page_id=' . $page_on_front . '&tinvwlID=$matches[1]';
|
303 |
+
add_rewrite_rule( '^([A-Fa-f0-9]{6})?/wl_page/([0-9]{1,})/{0,1}$', 'index.php?page_id=' . $page_on_front . '&tinvwlID=$matches[3]&wl_paged=$matches[4]', 'top' );
|
304 |
self::$rules_raw['^([A-Fa-f0-9]{6})?/wl_page/([0-9]{1,})/{0,1}$'] = 'index.php?page_id=' . $page_on_front . '&tinvwlID=$matches[3]&wl_paged=$matches[4]';
|
305 |
}
|
306 |
|
307 |
+
add_rewrite_rule( '(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/wl_page/([0-9]{1,})/{0,1}$', 'index.php?pagename=$matches[1]&tinvwlID=$matches[3]&wl_paged=$matches[4]', 'top' );
|
308 |
+
self::$rules_raw[ '(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/wl_page/([0-9]{1,})/{0,1}$' ] = 'index.php?pagename=$matches[1]&tinvwlID=$matches[3]&wl_paged=$matches[4]';
|
309 |
+
add_rewrite_rule( '(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/{0,1}$', 'index.php?pagename=$matches[1]&tinvwlID=$matches[3]', 'top' );
|
310 |
+
self::$rules_raw[ '(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/{0,1}$' ] = 'index.php?pagename=$matches[1]&tinvwlID=$matches[3]';
|
311 |
|
312 |
// Wishlist on shop page.
|
313 |
+
$shop_page_id = wc_get_page_id( 'shop' );
|
314 |
+
if ( $shop_page_id && $page->ID === $shop_page_id ) {
|
315 |
+
$shop = get_post( $shop_page_id );
|
316 |
$shop_slug = $shop->post_name;
|
317 |
+
add_rewrite_rule( '(([^/]+/)*' . $shop_slug . ')/([A-Fa-f0-9]{6})?/{0,1}$', 'index.php?post_type=product&tinvwlID=$matches[3]', 'top' );
|
318 |
+
self::$rules_raw[ '(([^/]+/)*' . $shop_slug . ')/([A-Fa-f0-9]{6})?/{0,1}$' ] = 'index.php?post_type=product&tinvwlID=$matches[3]';
|
319 |
+
add_rewrite_rule( '(([^/]+/)*' . $shop_slug . ')/([A-Fa-f0-9]{6})?/wl_page/([0-9]{1,})/{0,1}$', 'index.php?post_type=product&tinvwlID=$matches[3]&wl_paged=$matches[4]', 'top' );
|
320 |
+
self::$rules_raw[ '(([^/]+/)*' . $shop_slug . ')/([A-Fa-f0-9]{6})?/wl_page/([0-9]{1,})/{0,1}$' ] = 'index.php?post_type=product&tinvwlID=$matches[3]&wl_paged=$matches[4]';
|
321 |
+
add_rewrite_rule( '(([^/]+/)*' . $shop_slug . ')/([A-Fa-f0-9]{6})?/page/([0-9]{1,})/{0,1}$', 'index.php?post_type=product&tinvwlID=$matches[3]&paged=$matches[4]', 'top' );
|
322 |
+
self::$rules_raw[ '(([^/]+/)*' . $shop_slug . ')/([A-Fa-f0-9]{6})?/page/([0-9]{1,})/{0,1}$' ] = 'index.php?post_type=product&tinvwlID=$matches[3]&paged=$matches[4]';
|
323 |
}
|
324 |
}
|
325 |
}
|
332 |
*
|
333 |
* @return bool
|
334 |
*/
|
335 |
+
public static function disable_canonical_redirect_for_front_page( $redirect ) {
|
336 |
+
$page_on_front = absint( get_option( 'page_on_front' ) );
|
337 |
+
if ( is_page() && 'page' === get_option( 'show_on_front' ) && $page_on_front ) {
|
338 |
+
if ( is_page( $page_on_front ) ) {
|
|
|
339 |
$redirect = false;
|
340 |
}
|
341 |
}
|
350 |
*
|
351 |
* @return array
|
352 |
*/
|
353 |
+
function add_query_var( $public_var ) {
|
|
|
354 |
$public_var[] = 'tinvwlID';
|
355 |
$public_var[] = 'tiws';
|
356 |
$public_var[] = 'tiwp';
|
366 |
*
|
367 |
* @return string
|
368 |
*/
|
369 |
+
function add_ogp( $text ) {
|
|
|
370 |
global $wp_query;
|
371 |
+
if ( isset( $wp_query ) && is_page( apply_filters( 'wpml_object_id', tinv_get_option( 'page', 'wishlist' ), 'page', true ) ) ) {
|
372 |
+
if ( ! preg_match( '/prefix\=/i', $text ) ) {
|
373 |
$text .= ' prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# product: http://ogp.me/ns/product#"';
|
374 |
}
|
375 |
+
if ( ! preg_match( '/itemscope/i', $text ) ) {
|
376 |
$text .= ' itemscope';
|
377 |
}
|
378 |
+
if ( ! preg_match( '/itemtype\=/i', $text ) ) {
|
379 |
$text .= ' itemtype="http://schema.org/Offer"';
|
380 |
}
|
381 |
}
|
388 |
*
|
389 |
* @return boolean
|
390 |
*/
|
391 |
+
function is_pluginpage() {
|
392 |
+
$pages = tinv_get_option( 'page' );
|
393 |
+
$pages = array_filter( $pages );
|
394 |
+
foreach ( $pages as $page ) {
|
395 |
+
if ( is_page( apply_filters( 'wpml_object_id', $page, 'page', true ) ) ) {
|
|
|
396 |
return true;
|
397 |
}
|
398 |
}
|
403 |
/**
|
404 |
* Load style and javascript
|
405 |
*/
|
406 |
+
function enqueue_header() {
|
407 |
+
if ( $this->is_pluginpage() ) {
|
|
|
408 |
$this->enqueue_wc_styles();
|
409 |
}
|
410 |
$this->enqueue_scripts();
|
414 |
/**
|
415 |
* Load style
|
416 |
*/
|
417 |
+
function enqueue_styles() {
|
418 |
+
if ( apply_filters( 'tinvwl_load_webfont', true ) ) {
|
419 |
+
wp_enqueue_style( $this->_name . '-webfont-font', TINVWL_URL . 'assets/fonts/tinvwl-webfont.woff2', array(), 'xu2uyi' );
|
420 |
+
wp_enqueue_style( $this->_name . '-webfont', TINVWL_URL . 'assets/css/webfont.min.css', array(), $this->_version, 'all' );
|
421 |
+
wp_style_add_data( $this->_name . '-webfont', 'rtl', 'replace' );
|
422 |
+
wp_style_add_data( $this->_name . '-webfont', 'suffix', '.min' );
|
423 |
+
add_filter( 'style_loader_tag', array( $this, 'font_loader_tag_filter' ), 100, 2 );
|
|
|
424 |
}
|
425 |
+
wp_enqueue_style( 'tinvwl', TINVWL_URL . 'assets/css/public.min.css', array(), $this->_version, 'all' );
|
426 |
+
wp_style_add_data( 'tinvwl', 'rtl', 'replace' );
|
427 |
+
wp_style_add_data( 'tinvwl', 'suffix', '.min' );
|
428 |
+
|
429 |
+
if ( ! tinv_get_option( 'style', 'customstyle' ) ) {
|
430 |
+
wp_enqueue_style( 'tinvwl-theme', TINVWL_URL . 'assets/css/theme.min.css', array(), $this->_version, 'all' );
|
431 |
+
wp_style_add_data( 'tinvwl-theme', 'rtl', 'replace' );
|
432 |
+
wp_style_add_data( 'tinvwl-theme', 'suffix', '.min' );
|
433 |
}
|
434 |
+
if ( ! tinv_get_option( 'style', 'customstyle' ) || ( tinv_get_option( 'style_plain', 'allow' ) && tinv_get_option( 'style_plain', 'css' ) ) ) {
|
435 |
$newcss = $this->dynaminc_css();
|
436 |
+
if ( $newcss ) {
|
437 |
+
$name_style = tinv_get_option( 'style', 'customstyle' ) ? 'tinvwl' : 'tinvwl-theme';
|
438 |
+
wp_add_inline_style( $name_style, $newcss );
|
439 |
}
|
440 |
}
|
441 |
}
|
442 |
|
443 |
/* Preload Icons font */
|
444 |
+
function font_loader_tag_filter( $html, $handle ) {
|
445 |
+
if ( $handle === $this->_name . '-webfont-font' ) {
|
446 |
+
$html = str_replace( "type='text/css'", '', $html );
|
447 |
+
|
448 |
+
return str_replace( "rel='stylesheet'", "rel='preload' as='font' type='font/woff2' crossorigin='anonymous'", $html );
|
449 |
}
|
450 |
|
451 |
return $html;
|
458 |
*
|
459 |
* @return string
|
460 |
*/
|
461 |
+
function compress_css( $css ) {
|
462 |
+
$css = preg_replace( '!/\*[^*]*\*+([^/][^*]*\*+)*/!', ' ', $css );
|
463 |
+
$css = preg_replace( '/(\r|\n|\t| {2,})/', ' ', $css );
|
|
|
464 |
|
465 |
return $css;
|
466 |
}
|
468 |
/**
|
469 |
* Generate dynaminc css
|
470 |
*/
|
471 |
+
function dynaminc_css() {
|
472 |
+
$css = get_transient( TINVWL_PREFIX . '_dynamic_' );
|
473 |
+
if ( ! $css ) {
|
|
|
474 |
$css = '';
|
475 |
+
if ( ! tinv_get_option( 'style', 'customstyle' ) ) {
|
476 |
+
$newcss = tinv_get_option( 'style_options', 'css' );
|
477 |
+
if ( $newcss ) {
|
478 |
+
$newcss = $this->compress_css( $newcss );
|
479 |
+
$css .= $newcss;
|
480 |
}
|
481 |
}
|
482 |
+
if ( tinv_get_option( 'style_plain', 'allow' ) ) {
|
483 |
+
$newcss = tinv_get_option( 'style_plain', 'css' );
|
484 |
+
if ( $newcss ) {
|
485 |
+
$newcss = $this->compress_css( $newcss );
|
486 |
+
$css .= $newcss;
|
487 |
}
|
488 |
}
|
489 |
$image_url = TINVWL_URL . 'assets/img/';
|
490 |
+
$css = str_replace( '../img/', $image_url, $css );
|
491 |
+
set_transient( TINVWL_PREFIX . '_dynamic_', $css, DAY_IN_SECONDS );
|
492 |
}
|
493 |
|
494 |
return $css;
|
497 |
/**
|
498 |
* Add woocommerce style
|
499 |
*/
|
500 |
+
function enqueue_wc_styles() {
|
501 |
+
if ( $enqueue_styles = WC_Frontend_Scripts::get_styles() ) {
|
502 |
+
foreach ( $enqueue_styles as $handle => $args ) {
|
503 |
+
wp_register_style( $handle, $args['src'], $args['deps'], $args['version'], $args['media'] );
|
504 |
+
wp_enqueue_style( $handle );
|
|
|
505 |
}
|
506 |
}
|
507 |
}
|
509 |
/**
|
510 |
* Load javascript
|
511 |
*/
|
512 |
+
function enqueue_scripts() {
|
513 |
+
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
514 |
+
wp_register_script( $this->_name . '-clipboard', TINVWL_URL . 'assets/js/clipboard.min.js', array( 'jquery' ), $this->_version, true );
|
515 |
+
wp_register_script( $this->_name, TINVWL_URL . 'assets/js/public' . $suffix . '.js', array(
|
|
|
516 |
'jquery',
|
517 |
'js-cookie',
|
518 |
+
apply_filters( 'tinvwl_wc_cart_fragments_enabled', true ) ? 'wc-cart-fragments' : 'jquery',
|
519 |
+
), $this->_version, true );
|
520 |
|
521 |
$args = array(
|
522 |
+
'text_create' => __( 'Create New', 'ti-woocommerce-wishlist' ),
|
523 |
+
'text_already_in' => apply_filters( 'tinvwl_already_in_wishlist_text', tinv_get_option( 'general', 'text_already_in' ) ),
|
524 |
+
'simple_flow' => tinv_get_option( 'general', 'simple_flow' ),
|
525 |
+
'hide_zero_counter' => tinv_get_option( 'topline', 'hide_zero_counter' ),
|
526 |
+
'i18n_make_a_selection_text' => esc_attr__( 'Please select some product options before adding this product to your wishlist.', 'ti-woocommerce-wishlist' ),
|
527 |
+
'tinvwl_break_submit' => esc_attr__( 'No items or actions are selected.', 'ti-woocommerce-wishlist' ),
|
528 |
+
'tinvwl_clipboard' => esc_attr__( 'Copied!', 'ti-woocommerce-wishlist' ),
|
529 |
+
'allow_parent_variable' => apply_filters( 'tinvwl_allow_add_parent_variable_product', false ),
|
530 |
+
'block_ajax_wishlists_data' => apply_filters( 'tinvwl_block_ajax_wishlists_data', false ),
|
531 |
+
'update_wishlists_data' => apply_filters( 'tinvwl_update_wishlists_data', false ),
|
532 |
+
'hash_key' => 'ti_wishlist_data_' . md5( get_current_blog_id() . '_' . get_site_url( get_current_blog_id(), '/' ) . get_template() ),
|
533 |
+
'nonce' => wp_create_nonce( 'wp_rest' ),
|
534 |
+
'rest_root' => esc_url_raw( get_rest_url() ),
|
535 |
+
'plugin_url' => esc_url_raw( TINVWL_URL ),
|
536 |
);
|
537 |
|
538 |
+
if ( function_exists( 'wpml_get_current_language' ) ) {
|
539 |
|
540 |
global $sitepress;
|
541 |
|
542 |
+
if ( $sitepress && $sitepress instanceof SitePress ) {
|
543 |
$wpml_settings = $sitepress->get_settings();
|
544 |
+
if ( isset( $wpml_settings['custom_posts_sync_option'] ) && isset( $wpml_settings['custom_posts_sync_option']['product'] ) && in_array( $wpml_settings['custom_posts_sync_option']['product'], array(
|
545 |
+
1,
|
546 |
+
2,
|
547 |
+
) ) ) {
|
548 |
+
|
549 |
+
if ( 2 == $wpml_settings['custom_posts_sync_option']['product'] ) {
|
550 |
+
$args['wpml_default'] = wpml_get_default_language();
|
551 |
+
}
|
552 |
$args['wpml'] = wpml_get_current_language();
|
553 |
}
|
554 |
}
|
555 |
}
|
556 |
|
557 |
+
wp_localize_script( $this->_name, 'tinvwl_add_to_wishlist', $args );
|
558 |
|
559 |
+
if ( wp_script_is( 'woocommerce', 'enqueued' ) ) {
|
560 |
+
wp_enqueue_script( 'tinvwl' );
|
561 |
}
|
562 |
}
|
563 |
|
564 |
/**
|
565 |
* Load function
|
566 |
*/
|
567 |
+
function load_function() {
|
|
|
568 |
$this->define_hooks();
|
569 |
}
|
570 |
|
576 |
*
|
577 |
* @return boolean
|
578 |
*/
|
579 |
+
function transfert_local_to_user( $user_login, $user ) {
|
580 |
+
return $this->transfert_local_to_user_register( $user->ID );
|
|
|
581 |
}
|
582 |
|
583 |
+
function logout( $user_id ) {
|
584 |
+
set_transient( '_tinvwl_update_wishlists_data', '1' );
|
|
|
585 |
}
|
586 |
|
587 |
/**
|
589 |
*
|
590 |
* @param integer $user_id New user id.
|
591 |
*/
|
592 |
+
function transfert_local_to_user_register( $user_id ) {
|
|
|
593 |
|
594 |
+
set_transient( '_tinvwl_update_wishlists_data', '1' );
|
595 |
|
596 |
+
$wl = new TInvWL_Wishlist( $this->_name );
|
597 |
$wishlist = $wl->get_by_sharekey_default();
|
598 |
+
if ( ! empty( $wishlist ) ) {
|
599 |
+
$wishlist = array_shift( $wishlist );
|
600 |
+
if ( empty( $wishlist['author'] ) ) {
|
601 |
+
$wlpl = new TInvWL_Product( $wishlist );
|
602 |
+
$wl->user = $user_id;
|
603 |
+
$_wishlist = $wl->get_by_user_default( $user_id );
|
604 |
+
if ( empty( $_wishlist ) ) {
|
605 |
$wishlist['author'] = $user_id;
|
606 |
+
unset( $wishlist['title'] );
|
607 |
+
$wl->update( $wishlist['ID'], $wishlist );
|
608 |
+
$wlp = new TInvWL_Product( $wishlist, $this->_name );
|
609 |
+
$products = $wlp->get_wishlist( array( 'external' => false ) );
|
610 |
+
foreach ( $products as $product ) {
|
611 |
$product['author'] = $user_id;
|
612 |
+
$wlp->update( $product );
|
613 |
}
|
614 |
} else {
|
615 |
+
$_wishlist = array_shift( $_wishlist );
|
616 |
+
if ( $wishlist['ID'] != $_wishlist['ID'] ) {
|
617 |
+
$wlp = new TInvWL_Product( $_wishlist, $this->_name );
|
618 |
+
$products = $wlpl->get_wishlist( array( 'external' => false ) );
|
619 |
+
$added = true;
|
620 |
+
foreach ( $products as $product ) {
|
621 |
+
unset( $product['author'] );
|
622 |
+
unset( $product['wishlist_id'] );
|
623 |
+
$added = $added && $wlp->add_product( $product );
|
624 |
}
|
625 |
+
if ( $added ) {
|
626 |
$wlpl->remove_product_from_wl();
|
627 |
}
|
628 |
}
|
629 |
+
$wl->set_sharekey( $_wishlist['share_key'] );
|
630 |
}
|
631 |
}
|
632 |
}
|
635 |
/**
|
636 |
* Set the default wishlist key if the user loguot
|
637 |
*/
|
638 |
+
public function set_user_sharekey() {
|
639 |
+
$wl = new TInvWL_Wishlist( $this->_name );
|
|
|
640 |
$wishlist = $wl->get_by_user_default();
|
641 |
+
if ( ! empty( $wishlist ) ) {
|
642 |
+
$wishlist = array_shift( $wishlist );
|
643 |
+
$wl->set_sharekey( $wishlist['share_key'] );
|
644 |
}
|
645 |
}
|
646 |
|
651 |
*
|
652 |
* @return array
|
653 |
*/
|
654 |
+
function account_menu_items( $items ) {
|
655 |
+
$index_position = apply_filters( 'tinvwl_myaccount_position_wishlist', - 1, $items );
|
656 |
+
$items = array_merge(
|
657 |
+
array_slice( $items, 0, $index_position, true ),
|
|
|
658 |
array(
|
659 |
+
'tinv_wishlist' => __( 'Wishlist', 'ti-woocommerce-wishlist' ),
|
660 |
),
|
661 |
+
array_slice( $items, $index_position, null, true )
|
662 |
);
|
663 |
flush_rewrite_rules();
|
664 |
|
675 |
*
|
676 |
* @return string
|
677 |
*/
|
678 |
+
function account_menu_endpoint( $url, $endpoint, $value, $permalink ) {
|
679 |
+
if ( 'tinv_wishlist' === $endpoint ) {
|
|
|
680 |
$url = tinv_url_wishlist_default();
|
681 |
}
|
682 |
|
688 |
*
|
689 |
* @param integer $id Removed userid.
|
690 |
*/
|
691 |
+
function delete_user_wishlist( $id ) {
|
692 |
+
$wl = new TInvWL_Wishlist( $this->_name );
|
693 |
+
$wishlists = $wl->get( array(
|
|
|
694 |
'author' => $id,
|
695 |
+
'count' => 9999999,
|
696 |
+
) );
|
697 |
+
if ( ! empty( $wishlists ) ) {
|
698 |
+
foreach ( $wishlists as $wishlist ) {
|
699 |
+
$wl->remove( $wishlist['ID'] );
|
700 |
}
|
701 |
}
|
702 |
}
|
704 |
/**
|
705 |
* Export cookies wishlist to database
|
706 |
*/
|
707 |
+
function legacy_transfer() {
|
708 |
+
$wlpl = TInvWL_Product_Legacy::instance( $this->_name );
|
709 |
+
$products = $wlpl->get_wishlist( array( 'external' => false ) );
|
710 |
+
if ( ! empty( $products ) && is_array( $products ) ) {
|
711 |
+
$wl = new TInvWL_Wishlist( $this->_name );
|
|
|
712 |
$wishlist = $wl->add_user_default();
|
713 |
|
714 |
+
$wlp = new TInvWL_Product( $wishlist, $this->_name );
|
715 |
|
716 |
$added = true;
|
717 |
+
foreach ( $products as $product ) {
|
718 |
+
unset( $product['author'] );
|
719 |
+
if ( ! $wlp->add_product( $product ) ) {
|
720 |
$added = false;
|
721 |
}
|
722 |
}
|
723 |
+
if ( $added ) {
|
724 |
$wlpl->remove_product_from_wl();
|
725 |
}
|
726 |
}
|
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.9
|
6 |
-
Stable tag: 1.
|
7 |
License: GPLv3
|
8 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
9 |
Plugin URI: https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
@@ -163,6 +163,15 @@ Yes, you can! Join in on our [GitHub repository](https://github.com/TemplateInva
|
|
163 |
|
164 |
|
165 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
= 1.40.1 =
|
167 |
*Release Date - 29 January 2022*
|
168 |
|
3 |
Tags: woocommerce, wishlist, woocommerce wishlist, e-commerce, ecommerce
|
4 |
Requires at least: 4.7
|
5 |
Tested up to: 5.9
|
6 |
+
Stable tag: 1.41.0
|
7 |
License: GPLv3
|
8 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
9 |
Plugin URI: https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
163 |
|
164 |
|
165 |
== Changelog ==
|
166 |
+
= 1.41.0 =
|
167 |
+
*Release Date - 17 February 2022*
|
168 |
+
|
169 |
+
* WooCommerce 6.2 support
|
170 |
+
* Updated integration with [Quick Buy Now Button for WooCommerce](https://woocommerce.com/products/quick-buy-now-button-for-woocommerce/?aff=3955) plugin
|
171 |
+
* Updated integration with [YITH WooCommerce Product Add-Ons](https://wordpress.org/plugins/yith-woocommerce-product-add-ons/) plugin
|
172 |
+
* Updated integration with [Google Tag Manager for WordPress](https://wordpress.org/plugins/duracelltomi-google-tag-manager/) plugin
|
173 |
+
* Fixed WPML plugin issue
|
174 |
+
|
175 |
= 1.40.1 =
|
176 |
*Release Date - 29 January 2022*
|
177 |
|
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.
|
8 |
* Requires at least: 4.7
|
9 |
* Tested up to: 5.9
|
10 |
* WC requires at least: 3.0
|
11 |
-
* WC tested up to: 6.
|
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.
|
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.41.0
|
8 |
* Requires at least: 4.7
|
9 |
* Tested up to: 5.9
|
10 |
* WC requires at least: 3.0
|
11 |
+
* WC tested up to: 6.2
|
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.41.0');
|
45 |
}
|
46 |
|
47 |
if (!defined('TINVWL_LOAD_FREE')) {
|