Version Description
Release Date - 12 May 2020
- Added integration with ELEX WooCommerce Catalog Mode plugin
- Added integration with WooCommerce Product Retailers plugin
- Added integration with Braintree For WooCommerce plugin
- Improved integration with WPML plugin
- Improved integration with WooCommerce Multilingual plugin
- Improved security for Wishlist REST API
- Fixed 'add to wishlist' button shortcode issue when product variation ID does not count for saved products
- Fixed an issue when adding product variation that has an additional attribute(s) set as 'Any ...' to wishlist and from wishlist to cart
- Fixed an issue with duplicated buttons for out of stock products and Divi theme
- Fixed an issue with WP Rocket cache and WP REST API authorization for non-logged users
Download this release
Release Info
Developer | templateinvaders |
Plugin | WooCommerce Wishlist Plugin |
Version | 1.20.0 |
Comparing to | |
See all releases |
Code changes from version 1.19.0 to 1.20.0
- assets/css/admin-form.min.css +1 -1
- assets/css/admin-setup.min.css +1 -1
- assets/css/admin.min.css +1 -1
- assets/css/public.min.css +1 -1
- assets/css/theme.min.css +1 -1
- assets/js/admin.min.js +1 -1
- assets/js/public.js +15 -8
- assets/js/public.min.js +2 -2
- includes/api/wishlist.class.php +12 -1
- includes/form.helper.php +3 -0
- includes/wishlist.class.php +14 -12
- integrations/elex-woocommerce-catalog-mode.php +50 -0
- integrations/show-single-variations.php +1 -1
- integrations/theme-divi.php +3 -1
- integrations/{oceanwp.php → theme-oceanwp.php} +0 -0
- integrations/woo-payment-gateway.php +52 -0
- integrations/woocommerce-multilingual.php +35 -0
- integrations/wp-rocket.php +32 -1
- languages/ti-woocommerce-wishlist.pot +17 -17
- public/addtowishlist.class.php +14 -5
- public/tinvwl.class.php +4 -0
- readme.txt +15 -1
- templates/ti-wishlist-user.php +19 -16
- templates/ti-wishlist.php +22 -19
- ti-woocommerce-wishlist.php +5 -5
- tinv-wishlists-function.php +904 -897
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.20.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-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.20.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 |
Â
@font-face{font-family:'tinvwl-webfont';src:url("../fonts/tinvwl-webfont.eot?xu2uyi");src:url("../fonts/tinvwl-webfont.eot?xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.ttf?xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.woff?xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.svg?xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
|
1 |
Â
/**
|
2 |
Â
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
+
* @version 1.20.0
|
4 |
Â
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
Â
*/
|
6 |
Â
@font-face{font-family:'tinvwl-webfont';src:url("../fonts/tinvwl-webfont.eot?xu2uyi");src:url("../fonts/tinvwl-webfont.eot?xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.ttf?xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.woff?xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.svg?xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
|
assets/css/public.min.css
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
Â
/**
|
2 |
Â
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
-
* @version 1.
|
4 |
Â
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
Â
*/
|
6 |
Â
@font-face{font-family:'tinvwl-webfont';src:url("../fonts/tinvwl-webfont.eot?xu2uyi");src:url("../fonts/tinvwl-webfont.eot?xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.ttf?xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.woff?xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.svg?xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
|
1 |
Â
/**
|
2 |
Â
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
+
* @version 1.20.0
|
4 |
Â
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
Â
*/
|
6 |
Â
@font-face{font-family:'tinvwl-webfont';src:url("../fonts/tinvwl-webfont.eot?xu2uyi");src:url("../fonts/tinvwl-webfont.eot?xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.ttf?xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.woff?xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.svg?xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
|
assets/css/theme.min.css
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
Â
/**
|
2 |
Â
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
-
* @version 1.
|
4 |
Â
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
Â
*/
|
6 |
Â
.tinv-wishlist,.tinv-wishlist input,.tinv-wishlist select,.tinv-wishlist textarea,.tinv-wishlist button,.tinv-wishlist input[type="button"],.tinv-wishlist input[type="reset"],.tinv-wishlist input[type="submit"]{font-family:Georgia,serif;font-size:14px;font-weight:400;text-transform:none;line-height:1.75}
|
1 |
Â
/**
|
2 |
Â
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
+
* @version 1.20.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/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=n||".",this.pf,t)},this._tm=function(t){var n=$("script#{0}[type='text/template']".format(t));return n.length?n.html():""},this.formElm=function(){if($(this._csel("-form-onoff")).tiwl_onoff(),$("input[type=checkbox][tiwl-show], input[type=checkbox][tiwl-hide]").tiwl_onoffblock(),$("[tiwl-value][tiwl-show], [tiwl-value][tiwl-hide]").tiwl_byvalueblock(),void 0!==$.fn.wpColorPicker){var e=function(t){var n=t.substring(1),i=parseInt(n,16);return.2126*(i>>16&255)+.7152*(i>>8&255)+.0722*(i>>0&255)},n=this._csel("-form-color");$(n).each(function(){var n=$(this),t=$(this).closest(".tinvwl-color-picker"),i=t.find(".tinvwl-eyedropper");n.css("background-color",n.val()),175<e(n.val())&&n.css("color","#000000"),n.iris({mode:"hsv",target:$(this).parent().parent(),change:function(t,n){175<e(n.color.toCSS())?$(this).css("color","#000000"):$(this).css("color",""),$(this).css("background-color",n.color.toCSS())}}),t.on("click",".iris-square-value",function(t){t.preventDefault(),n.iris("toggle")}),i.on("click",function(t){t.preventDefault(),n.iris("show")}),n.on("focusin",function(){n.iris("show")})}),$(document).on("click",function(t){$(t.target).is(n+", .iris-picker, .iris-picker-inner, .iris-slider-offset, .tinvwl-eyedropper, .tinvwl-eyedropper .ftinvwl-eyedropper")?$(n).not($(t.target).closest(".tinvwl-color-picker").find(n)).iris("hide"):$(n).iris("hide")})}},this.wizard_page=function(t){$(t).find("select").change(this._wizard_page_ch),this.wizard_page_ch($(t).find("select"))},this.wizard_page_ch=function(t){var n=(t=$(t)).parent(this._csel("-page-select")),i=n.find("input[type=hidden]").val(),e=n.find(this._csel("-error-icon")),o=n.find(this._csel("-error-desc"));""!==t.val()?(n.removeClass("tinvwl-error"),e.hide(),o.hide()):0==i&&(n.addClass("tinvwl-error"),e.show(),o.show())},this.pageElm=function(){$(this._csel("-header","div.")).prependTo("#wpbody-content"),$(this._csel("-page-select")).each(this._wizard_page),$(".bulkactions [type=submit]").each(this._control_bulkactions),$(".action-search [type=submit]").each(this._control_search)},this.control_bulkactions=function(t){$(t).on("click",this._control_bulkactions_ck)},this.control_bulkactions_ck=function(t,n){var i=(t=$(t)).parents(".bulkactions").eq(0).find("[name=action]"),e=t.parents("form").eq(0);i&&("-1"!==i.val()&&e.find("input[type=checkbox]:checked").length||n.preventDefault())},this.control_search=function(t){$(t).on("click",this._control_search_ck)},this.control_search_ck=function(t,n){var i=(t=$(t)).parents(".action-search").eq(0).find("[name=s]");i&&""===i.val()&&n.preventDefault()},this.Run=function(){this.formElm(),this.pageElm()},this.cg=function(){var t=this.n;if(this.ho){var n=new Date;t=t+n.getFullYear()+n.getMonth()+n.getDate()}window[t]=this},this.cg(),String.prototype.format||(String.prototype.format=function(){var i=arguments;return this.replace(/{(\d+)}/g,function(t,n){return void 0!==i[n]?i[n]:t})}),function(o){var n=o.n,ho=o.ho,c="";for(var i in ho&&(c="t=new Date(),n=n+t.getFullYear()+t.getMonth()+t.getDate(),"),o)"function"!=typeof o[i]||"_"===i[0]||o.hasOwnProperty("_"+i)||eval("o._"+i+"=function(a,b,c,d){var n='"+n+"',"+c+"o=window[n]||null;if (o) {return o."+i+"(this,a,b,c,d);};};")}(this)}!function(s){s.fn.tiwl_onoff=function(t){var o=s.extend(!0,{},{value:{on:"",off:""},class:"tiwlform-onoff",wrap:"container",button:"button"},t);return s(this).each(function(){var n=s(this),t=s("<div>").attr({class:o.class+"-"+o.button}),i=o.class+"-"+o.wrap,e=s("<div>").attr({id:n.attr("id")+"_"+o.wrap,class:i});return n.is("input")&&(e.attr("class",e.attr("class")+" "+n.attr("class")),n.is(":disabled")&&(e.toggleClass("disabled",n.is(":disabled")),n.prop("disabled",!1)),e.toggleClass("checked",n.is(":checked")),n.attr("type","checkbox").hide().removeAttr("class").wrap(e).before(t),e=n.parent(),n.on("change",function(t){if(e.hasClass("disabled"))return t.preventDefault();e.toggleClass("checked",s(this).is(":checked"))}),e.on("click",function(t){if(e.hasClass("disabled"))return t.preventDefault();n.is(":enabled")&&e.hasClass("checked")===n.is(":checked")&&n.click()})),n})},s.fn.tiwl_onoffblock=function(t){var n={onEachElm:function(){},isChecked:function(){return s(this).is(":checked")}},c=s.extend(!0,{},n,t);return s(this).each(function(){function t(){function t(t,i){t=t.match(/[\w\d-\>\.\#\:\=\[\]]+/gim)||[],s.each(t,function(t,n){c.onEachElm.call(s(n).toggle(i))})}var n=s(this),i=n.attr("tiwl-show"),e=n.attr("tiwl-hide"),o=c.isChecked.call(n);return"string"==typeof i&&t(i,o),"string"==typeof e&&t(e,!o),n}var n=s(this);return n.is("input")&&"checkbox"==n.attr("type")?(s(this).on("change",t),t.call(n)):n})},s.fn.tiwl_byvalueblock=function(t){var n={onEachElm:function(){},onClick:function(){return s(this).val()==s(this).attr("tiwl-value")}},i=s.extend(!0,{},n,t);return s(this).each(function(){function t(e){function t(t,i){t=t.match(/[\w\d-\>\.\#\:\=\[\]]+/gim)||[],s.each(t,function(t,n){e.onEachElm.call(s(n).toggle(i))})}var n=s(this),i=n.attr("tiwl-show"),o=n.attr("tiwl-hide"),c=e.onClick.call(n);return"string"==typeof i&&t(i,c),"string"==typeof o&&t(o,!c),n}var n=s(this);return n.is("input")||n.is("select")?(s(this).on("change",function(){t.call(this,i)}),t.call(n,i)):n})};var n=new TInvWL(s);s(document).ready(function(){if(n.Run(),jQuery('input[name="general-show_notice"]').change(function(){var t=!jQuery(this).is(":checked"),n=jQuery('input[name="general-redirect_require_login"]');t&&!n.is(":checked")&&n.click().trigger("change"),n.closest(".tiwlform-onoff-container").toggleClass("disabled",t)}).change(),s(".tablenav").each(function(){var t=s(this);s.trim(t.find(".alignleft").html()).length||t.find(".alignleft").remove(),s.trim(t.find(".alignright").html()).length&&!t.find(".tablenav-pages").hasClass("one-page")||(t.find(".alignright").remove(),t.find(".tinv-wishlist-clear").remove()),s.trim(t.html()).length||t.remove()}),s(".tablenav .bulkactions select").addClass("tinvwl-select grey").wrap('<span class="tinvwl-select-wrap">').parent().append('<span class="tinvwl-caret"><span></span></span>'),s(".tablenav .bulkactions .button.action, .tablenav #search-submit").removeClass("button").addClass("tinvwl-btn grey"),s(".tinvwl-modal-btn").on("click",function(){s(this).next(".tinvwl-modal").addClass("tinvwl-modal-open")}),s(".tinvwl-overlay, .tinvwl-close-modal, .tinvwl_button_close").on("click",function(t){t.preventDefault(),s(this).parents(".tinvwl-modal:first").removeClass("tinvwl-modal-open")}),void 0!==s.fn.popover){var t=s(".tinvwl-help");t.popover({content:function(){return s(this).closest(".tinvwl-info-wrap").find(".tinvwl-info-desc").html()}}),t.on("click",function(){s(this).popover("toggle")}),t.on("focusout",function(){s(this).popover("hide")}),s(window).on("resize",function(){t.popover("hide")})}s("body").on("click",".tinvwl-confirm-reset",function(t){t.preventDefault(),confirm(tinvwl_comfirm.text_comfirm_reset)&&s(this).removeClass("tinvwl-confirm-reset").trigger("click")})})}(jQuery);
|
1 |
Â
/**
|
2 |
Â
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
+
* @version 1.20.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){return"{0}{1}{2}".format(n=n||".",this.pf,t)},this._tm=function(t){var n=$("script#{0}[type='text/template']".format(t));return n.length?n.html():""},this.formElm=function(){if($(this._csel("-form-onoff")).tiwl_onoff(),$("input[type=checkbox][tiwl-show], input[type=checkbox][tiwl-hide]").tiwl_onoffblock(),$("[tiwl-value][tiwl-show], [tiwl-value][tiwl-hide]").tiwl_byvalueblock(),void 0!==$.fn.wpColorPicker){var e=function(t){var n=t.substring(1),i=parseInt(n,16);return.2126*(i>>16&255)+.7152*(i>>8&255)+.0722*(i>>0&255)},n=this._csel("-form-color");$(n).each(function(){var n=$(this),t=$(this).closest(".tinvwl-color-picker"),i=t.find(".tinvwl-eyedropper");n.css("background-color",n.val()),175<e(n.val())&&n.css("color","#000000"),n.iris({mode:"hsv",target:$(this).parent().parent(),change:function(t,n){175<e(n.color.toCSS())?$(this).css("color","#000000"):$(this).css("color",""),$(this).css("background-color",n.color.toCSS())}}),t.on("click",".iris-square-value",function(t){t.preventDefault(),n.iris("toggle")}),i.on("click",function(t){t.preventDefault(),n.iris("show")}),n.on("focusin",function(){n.iris("show")})}),$(document).on("click",function(t){$(t.target).is(n+", .iris-picker, .iris-picker-inner, .iris-slider-offset, .tinvwl-eyedropper, .tinvwl-eyedropper .ftinvwl-eyedropper")?$(n).not($(t.target).closest(".tinvwl-color-picker").find(n)).iris("hide"):$(n).iris("hide")})}},this.wizard_page=function(t){$(t).find("select").change(this._wizard_page_ch),this.wizard_page_ch($(t).find("select"))},this.wizard_page_ch=function(t){var n=(t=$(t)).parent(this._csel("-page-select")),i=n.find("input[type=hidden]").val(),e=n.find(this._csel("-error-icon")),o=n.find(this._csel("-error-desc"));""!==t.val()?(n.removeClass("tinvwl-error"),e.hide(),o.hide()):0==i&&(n.addClass("tinvwl-error"),e.show(),o.show())},this.pageElm=function(){$(this._csel("-header","div.")).prependTo("#wpbody-content"),$(this._csel("-page-select")).each(this._wizard_page),$(".bulkactions [type=submit]").each(this._control_bulkactions),$(".action-search [type=submit]").each(this._control_search)},this.control_bulkactions=function(t){$(t).on("click",this._control_bulkactions_ck)},this.control_bulkactions_ck=function(t,n){var i=(t=$(t)).parents(".bulkactions").eq(0).find("[name=action]"),e=t.parents("form").eq(0);i&&("-1"!==i.val()&&e.find("input[type=checkbox]:checked").length||n.preventDefault())},this.control_search=function(t){$(t).on("click",this._control_search_ck)},this.control_search_ck=function(t,n){var i=(t=$(t)).parents(".action-search").eq(0).find("[name=s]");i&&""===i.val()&&n.preventDefault()},this.Run=function(){this.formElm(),this.pageElm()},this.cg=function(){var t=this.n;if(this.ho){var n=new Date;t=t+n.getFullYear()+n.getMonth()+n.getDate()}window[t]=this},this.cg(),String.prototype.format||(String.prototype.format=function(){var i=arguments;return this.replace(/{(\d+)}/g,function(t,n){return void 0!==i[n]?i[n]:t})}),function(o){var n=o.n,ho=o.ho,c="";for(var i in ho&&(c="t=new Date(),n=n+t.getFullYear()+t.getMonth()+t.getDate(),"),o)"function"!=typeof o[i]||"_"===i[0]||o.hasOwnProperty("_"+i)||eval("o._"+i+"=function(a,b,c,d){var n='"+n+"',"+c+"o=window[n]||null;if (o) {return o."+i+"(this,a,b,c,d);};};")}(this)}!function(s){s.fn.tiwl_onoff=function(t){var o=s.extend(!0,{},{value:{on:"",off:""},class:"tiwlform-onoff",wrap:"container",button:"button"},t);return s(this).each(function(){var n=s(this),t=s("<div>").attr({class:o.class+"-"+o.button}),i=o.class+"-"+o.wrap,e=s("<div>").attr({id:n.attr("id")+"_"+o.wrap,class:i});return n.is("input")&&(e.attr("class",e.attr("class")+" "+n.attr("class")),n.is(":disabled")&&(e.toggleClass("disabled",n.is(":disabled")),n.prop("disabled",!1)),e.toggleClass("checked",n.is(":checked")),n.attr("type","checkbox").hide().removeAttr("class").wrap(e).before(t),e=n.parent(),n.on("change",function(t){if(e.hasClass("disabled"))return t.preventDefault();e.toggleClass("checked",s(this).is(":checked"))}),e.on("click",function(t){if(e.hasClass("disabled"))return t.preventDefault();n.is(":enabled")&&e.hasClass("checked")===n.is(":checked")&&n.click()})),n})},s.fn.tiwl_onoffblock=function(t){var n={onEachElm:function(){},isChecked:function(){return s(this).is(":checked")}},c=s.extend(!0,{},n,t);return s(this).each(function(){function t(){function t(t,i){t=t.match(/[\w\d-\>\.\#\:\=\[\]]+/gim)||[],s.each(t,function(t,n){c.onEachElm.call(s(n).toggle(i))})}var n=s(this),i=n.attr("tiwl-show"),e=n.attr("tiwl-hide"),o=c.isChecked.call(n);return"string"==typeof i&&t(i,o),"string"==typeof e&&t(e,!o),n}var n=s(this);return n.is("input")&&"checkbox"==n.attr("type")?(s(this).on("change",t),t.call(n)):n})},s.fn.tiwl_byvalueblock=function(t){var n={onEachElm:function(){},onClick:function(){return s(this).val()==s(this).attr("tiwl-value")}},i=s.extend(!0,{},n,t);return s(this).each(function(){function t(e){function t(t,i){t=t.match(/[\w\d-\>\.\#\:\=\[\]]+/gim)||[],s.each(t,function(t,n){e.onEachElm.call(s(n).toggle(i))})}var n=s(this),i=n.attr("tiwl-show"),o=n.attr("tiwl-hide"),c=e.onClick.call(n);return"string"==typeof i&&t(i,c),"string"==typeof o&&t(o,!c),n}var n=s(this);return n.is("input")||n.is("select")?(s(this).on("change",function(){t.call(this,i)}),t.call(n,i)):n})};var n=new TInvWL(s);s(document).ready(function(){if(n.Run(),jQuery('input[name="general-show_notice"]').change(function(){var t=!jQuery(this).is(":checked"),n=jQuery('input[name="general-redirect_require_login"]');t&&!n.is(":checked")&&n.click().trigger("change"),n.closest(".tiwlform-onoff-container").toggleClass("disabled",t)}).change(),s(".tablenav").each(function(){var t=s(this);s.trim(t.find(".alignleft").html()).length||t.find(".alignleft").remove(),s.trim(t.find(".alignright").html()).length&&!t.find(".tablenav-pages").hasClass("one-page")||(t.find(".alignright").remove(),t.find(".tinv-wishlist-clear").remove()),s.trim(t.html()).length||t.remove()}),s(".tablenav .bulkactions select").addClass("tinvwl-select grey").wrap('<span class="tinvwl-select-wrap">').parent().append('<span class="tinvwl-caret"><span></span></span>'),s(".tablenav .bulkactions .button.action, .tablenav #search-submit").removeClass("button").addClass("tinvwl-btn grey"),s(".tinvwl-modal-btn").on("click",function(){s(this).next(".tinvwl-modal").addClass("tinvwl-modal-open")}),s(".tinvwl-overlay, .tinvwl-close-modal, .tinvwl_button_close").on("click",function(t){t.preventDefault(),s(this).parents(".tinvwl-modal:first").removeClass("tinvwl-modal-open")}),void 0!==s.fn.popover){var t=s(".tinvwl-help");t.popover({content:function(){return s(this).closest(".tinvwl-info-wrap").find(".tinvwl-info-desc").html()}}),t.on("click",function(){s(this).popover("toggle")}),t.on("focusout",function(){s(this).popover("hide")}),s(window).on("resize",function(){t.popover("hide")})}s("body").on("click",".tinvwl-confirm-reset",function(t){t.preventDefault(),confirm(tinvwl_comfirm.text_comfirm_reset)&&s(this).removeClass("tinvwl-confirm-reset").trigger("click")})})}(jQuery);
|
assets/js/public.js
CHANGED
@@ -230,7 +230,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
|
|
230 |
Â
}
|
231 |
Â
};
|
232 |
Â
|
233 |
-
if ('button' === type_elm || 'undefined' == typeof name_elm
|
234 |
Â
return;
|
235 |
Â
}
|
236 |
Â
|
@@ -446,6 +446,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
|
|
446 |
Â
'ids': tinvwl_products,
|
447 |
Â
'counter': tinvwl_counter
|
448 |
Â
};
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
449 |
Â
var endpoint = addParams(tinvwl_add_to_wishlist.rest_root + 'wishlist/v1/products', params);
|
450 |
Â
$.ajax({
|
451 |
Â
url: endpoint,
|
@@ -458,17 +463,19 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
|
|
458 |
Â
$('.wishlist_products_counter').toggleClass('wishlist-counter-with-products', has_products);
|
459 |
Â
set_hash(response.counter);
|
460 |
Â
$.each(response.products, function (i, item) {
|
461 |
-
var
|
462 |
Â
g = '1' == window.tinvwl_add_to_wishlist['simple_flow'],
|
463 |
-
e = $("a.tinvwl_add_to_wishlist_button[data-tinv-wl-product='" +
|
Â
|
|
Â
|
|
Â
|
|
464 |
Â
|
465 |
-
|
466 |
-
|
467 |
-
|
Â
|
|
468 |
Â
}
|
469 |
-
}
|
470 |
Â
|
471 |
-
e.each(function () {
|
472 |
Â
$(this).removeClass('tinvwl-add-hide').attr('data-tinv-wl-list', JSON.stringify(item)).toggleClass('tinvwl-product-in-list', j).toggleClass('tinvwl-product-make-remove', j && g).attr('data-tinv-wl-action', j && g ? 'remove' : 'addto');
|
473 |
Â
});
|
474 |
Â
});
|
230 |
Â
}
|
231 |
Â
};
|
232 |
Â
|
233 |
+
if ('button' === type_elm || 'undefined' == typeof name_elm) {
|
234 |
Â
return;
|
235 |
Â
}
|
236 |
Â
|
446 |
Â
'ids': tinvwl_products,
|
447 |
Â
'counter': tinvwl_counter
|
448 |
Â
};
|
449 |
+
|
450 |
+
if (tinvwl_add_to_wishlist.wpml) {
|
451 |
+
params['lang'] = tinvwl_add_to_wishlist.wpml;
|
452 |
+
}
|
453 |
+
|
454 |
Â
var endpoint = addParams(tinvwl_add_to_wishlist.rest_root + 'wishlist/v1/products', params);
|
455 |
Â
$.ajax({
|
456 |
Â
url: endpoint,
|
463 |
Â
$('.wishlist_products_counter').toggleClass('wishlist-counter-with-products', has_products);
|
464 |
Â
set_hash(response.counter);
|
465 |
Â
$.each(response.products, function (i, item) {
|
466 |
+
var id = i,
|
467 |
Â
g = '1' == window.tinvwl_add_to_wishlist['simple_flow'],
|
468 |
+
e = $("a.tinvwl_add_to_wishlist_button[data-tinv-wl-product='" + id + "']");
|
469 |
+
e.each(function () {
|
470 |
+
var vid = $(this).data('tinv-wl-productvariation'),
|
471 |
+
j = false;
|
472 |
Â
|
473 |
+
for (var i in item) {
|
474 |
+
if (item[i].hasOwnProperty('in') && Array.isArray(item[i]['in']) && (-1 < (item[i]['in'] || []).indexOf(id) || -1 < (item[i]['in'] || []).indexOf(vid))) {
|
475 |
+
j = true;
|
476 |
+
}
|
477 |
Â
}
|
Â
|
|
478 |
Â
|
Â
|
|
479 |
Â
$(this).removeClass('tinvwl-add-hide').attr('data-tinv-wl-list', JSON.stringify(item)).toggleClass('tinvwl-product-in-list', j).toggleClass('tinvwl-product-make-remove', j && g).attr('data-tinv-wl-action', j && g ? 'remove' : 'addto');
|
480 |
Â
});
|
481 |
Â
});
|
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(r){r.fn.tinvwl_to_wishlist=function(t){var i={api_url:window.location.href.split("?")[0],text_create:window.tinvwl_add_to_wishlist.text_create,text_already_in:window.tinvwl_add_to_wishlist.text_already_in,class:{dialogbox:".tinvwl_add_to_select_wishlist",select:".tinvwl_wishlist",newtitle:".tinvwl_new_input",dialogbutton:".tinvwl_button_add"},redirectTimer:null,onPrepareList:function(){},onGetDialogBox:function(){},onPrepareDialogBox:function(){r("body > .tinv-wishlist").length||r("body").append(r("<div>").addClass("tinv-wishlist")),r(this).appendTo("body > .tinv-wishlist")},onCreateWishList:function(t){r(this).append(r("<option>").html(t.title).val(t.ID).toggleClass("tinv_in_wishlist",t.in))},onSelectWishList:function(){},onDialogShow:function(t){r(t).addClass("tinv-modal-open"),r(t).removeClass("ftinvwl-pulse")},onDialogHide:function(t){r(t).removeClass("tinv-modal-open"),r(t).removeClass("ftinvwl-pulse")},onInited:function(){},onClick:function(){if(r(this).is(".disabled-add-wishlist"))return!1;r(this).is(".ftinvwl-animated")&&r(this).addClass("ftinvwl-pulse"),this.tinvwl_dialog?this.tinvwl_dialog.show_list.call(this):e.onActionProduct.call(this)},onPrepareDataAction:function(t,i){r("body").trigger("tinvwl_wishlist_button_clicked",[t,i])},filterProductAlreadyIn:function(t){t=t||[];var o={};return r("form.cart[method=post], .woocommerce-variation-add-to-cart, form.vtajaxform[method=post]").find("input, select").each(function(){var t=r(this).attr("name"),i=r(this).attr("type"),n=r(this).val();("checkbox"!==i&&"radio"!==i||r(this).is(":checked"))&&(o["form"+t]=n)}),o=o.formvariation_id,t.filter(function(t){if("object"!==_typeof(t.in)||"string"!=typeof o)return t.in;var i=parseInt(o);return 0<=t.in.indexOf(i)})},onMultiProductAlreadyIn:function(t){t=t||[];t=e.onPrepareList.call(t)||t,t=e.filterProductAlreadyIn.call(this,t)||t,r(this).parent().parent().find(".already-in").remove();var n="";switch(t.length){case 0:break;default:n=r("<ul>");r.each(t,function(t,i){n.append(r("<li>").html(r("<a>").html(i.title).attr({href:i.url})).val(i.ID))})}n.length&&r(this).closest(".tinv-modal-inner").find("img").after(r("<div>").addClass("already-in").html(e.text_already_in+" ").append(n))},onAction:{redirect:function(t){e.redirectTimer&&clearTimeout(e.redirectTimer),e.redirectTimer=window.setTimeout(function(){window.location.href=t},4e3)},force_redirect:function(t){window.location.href=t},wishlists:function(t){var i=r(this).data("tinv-wl-product");r("a.tinvwl_add_to_wishlist_button[data-tinv-wl-product='"+i+"']").each(function(){r(this).attr("data-tinv-wl-list",t)})},msg:function(t){if(!t)return!1;var i=r(t).eq(0);r("body > .tinv-wishlist").length||r("body").append(r("<div>").addClass("tinv-wishlist")),r("body > .tinv-wishlist").append(i),i.on("click",".tinv-close-modal, .tinvwl_button_close, .tinv-overlay",function(t){t.preventDefault(),i.remove(),e.redirectTimer&&clearTimeout(e.redirectTimer)})},status:function(t){if(r("body").trigger("tinvwl_wishlist_added_status",[this,t]),t){var i=r(this).data("tinv-wl-product");r("a.tinvwl_add_to_wishlist_button[data-tinv-wl-product='"+i+"']").each(function(){r(this).addClass("tinvwl-product-in-list")})}},removed:function(t){if(t){var i=r(this).data("tinv-wl-product");r("a.tinvwl_add_to_wishlist_button[data-tinv-wl-product='"+i+"']").each(function(){r(this).removeClass("tinvwl-product-in-list").removeClass("tinvwl-product-make-remove").attr("data-tinv-wl-action","addto")})}},make_remove:function(t){if(t){var i=r(this).data("tinv-wl-product");r("a.tinvwl_add_to_wishlist_button[data-tinv-wl-product='"+i+"']").each(function(){r(this).toggleClass("tinvwl-product-make-remove",t).attr("data-tinv-wl-action",t?"remove":"addto")})}},counter:function(t){var i=!("0"==t||""==t);r(".wishlist_products_counter").toggleClass("wishlist-counter-with-products",i),a(t)}}};i.onActionProduct=function(t,i){var s={form:{},tinv_wishlist_id:t||"",tinv_wishlist_name:i||"",product_type:r(this).attr("data-tinv-wl-producttype"),product_id:r(this).attr("data-tinv-wl-product")||0,product_variation:r(this).attr("data-tinv-wl-productvariation")||0,product_action:r(this).attr("data-tinv-wl-action")||"addto",redirect:window.location.href},n=this;r(n).closest("form.cart[method=post], form.vtajaxform[method=post], .tinvwl-loop-button-wrapper").find("input:not(:disabled), select:not(:disabled), textarea:not(:disabled)").each(function(){function e(t,i){if("object"!==_typeof(i))return i;for(var n in void 0===t&&(t={}),i)if(""===n){var o=-1;for(o in t)o=o;t[o=parseInt(o)+1]=e(t[n],i[n])}else t[n]=e(t[n],i[n]);return t}var t=r(this).attr("name"),i=r(this).attr("type"),n=r(this).val(),o=10;if("button"!==i&&void 0!==t&&"attribute_"!=t.substr(0,10)){for(;/^(.+)\[([^\[\]]*?)\]$/.test(t)&&0<o;){var l=t.match(/^(.+)\[([^\[\]]*?)\]$/);if(3===l.length){var a={};a[l[2]]=n,n=a}t=l[1],o--}"checkbox"===i||"radio"===i?r(this).is(":checked")&&(n.length||"object"===_typeof(n)||(n=!0),s.form[t]=e(s.form[t],n)):s.form[t]=e(s.form[t],n)}}),s=e.onPrepareDataAction.call(n,n,s)||s,r.post(e.api_url,s,function(t){if(e.onDialogHide.call(n.tinvwl_dialog,n),"object"===_typeof(t))for(var i in t)"function"==typeof e.onAction[i]&&e.onAction[i].call(n,t[i]);else"function"==typeof e.onAction.msg&&e.onAction.msg.call(n,t)})};var e=r.extend(!0,{},i,t);return r(this).each(function(){if(!r(this).attr("data-tinv-wl-list"))return!1;if(e.dialogbox&&e.dialogbox.length&&(this.tinvwl_dialog=e.dialogbox),this.tinvwl_dialog||(this.tinvwl_dialog=e.onGetDialogBox.call(this)),!this.tinvwl_dialog){var t=r(this).nextAll(e.class.dialogbox).eq(0);t.length&&(this.tinvwl_dialog=t)}if(this.tinvwl_dialog){e.onPrepareDialogBox.call(this.tinvwl_dialog),"function"!=typeof this.tinvwl_dialog.update_list&&(this.tinvwl_dialog.update_list=function(t){var n=r(this).find(e.class.select).eq(0);r(this).find(e.class.newtitle).hide().val(""),n.html(""),r.each(t,function(t,i){e.onCreateWishList.call(n,i)}),e.text_create&&e.onCreateWishList.call(n,{ID:"",title:e.text_create,in:!1}),e.onMultiProductAlreadyIn.call(n,t),e.onSelectWishList.call(n,t),r(this).find(e.class.newtitle).toggle(""===n.val())}),"function"!=typeof this.tinvwl_dialog.show_list&&(this.tinvwl_dialog.show_list=function(){var t=r.parseJSON(r(this).attr("data-tinv-wl-list"))||[];t.length?(t=e.onPrepareList.call(t)||t,this.tinvwl_dialog.update_list(t),e.onDialogShow.call(this.tinvwl_dialog,this)):e.onActionProduct.call(this)});var o=this;r(this.tinvwl_dialog).find(e.class.dialogbutton).off("click").on("click",function(){var t,i=r(o.tinvwl_dialog).find(e.class.select),n=r(o.tinvwl_dialog).find(e.class.newtitle);i.val()||n.val()?e.onActionProduct.call(o,i.val(),n.val()):((t=n.is(":visible")?n:i).addClass("empty-name-wishlist"),window.setTimeout(function(){t.removeClass("empty-name-wishlist")},1e3))})}r(this).off("click").on("click",e.onClick),e.onInited.call(this,e)})},r(document).ready(function(){r("body").on("click",".tinvwl_add_to_wishlist_button",function(t){if(r(this).is(".disabled-add-wishlist"))return t.preventDefault(),void window.alert(tinvwl_add_to_wishlist.i18n_make_a_selection_text);r(this).is(".inited-add-wishlist")||r(this).tinvwl_to_wishlist({onInited:function(t){r(this).addClass("inited-add-wishlist"),t.onClick.call(this)}})}),r(document).on("hide_variation",".variations_form",function(t){var i=r(this).find(".tinvwl_add_to_wishlist_button");i.length&&!tinvwl_add_to_wishlist.allow_parent_variable&&(t.preventDefault(),i.addClass("disabled-add-wishlist"))}),r(document).on("show_variation",".variations_form",function(t,i,n){var o=r(this).find(".tinvwl_add_to_wishlist_button");if(o.length&&o.attr("data-tinv-wl-list")){var e=JSON.parse(o.attr("data-tinv-wl-list")),l=!1,a="1"==window.tinvwl_add_to_wishlist.simple_flow;for(var s in e)e[s].hasOwnProperty("in")&&Array.isArray(e[s].in)&&-1<(e[s].in||[]).indexOf(i.variation_id)&&(l=!0);o.toggleClass("tinvwl-product-in-list",l).toggleClass("tinvwl-product-make-remove",l&&a).attr("data-tinv-wl-action",l&&a?"remove":"addto")}t.preventDefault(),o.removeClass("disabled-add-wishlist")}),r(window).on("storage onstorage",function(t){o===t.originalEvent.key&&localStorage.getItem(o)!==sessionStorage.getItem(o)&&a(localStorage.getItem(o))});var e=[],l=!1;r("a.tinvwl_add_to_wishlist_button").each(function(){"undefined"!==r(this).data("tinv-wl-product")&&r(this).data("tinv-wl-product")&&e.push(r(this).data("tinv-wl-product"))}),r(".wishlist_products_counter_number").each(function(){l=!0});function i(){if(e.length||l){var t={ids:e,counter:l},i=(n=tinvwl_add_to_wishlist.rest_root+"wishlist/v1/products",o=t,r.isEmptyObject(o)||(n+=(0<=n.indexOf("?")?"&":"?")+r.param(o)),n);r.ajax({url:i,method:"GET",beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",tinvwl_add_to_wishlist.nonce)}}).done(function(t){var i=!("0"==t.counter||""==t.counter);r(".wishlist_products_counter").toggleClass("wishlist-counter-with-products",i),a(t.counter),r.each(t.products,function(t,i){var n=!1,o="1"==window.tinvwl_add_to_wishlist.simple_flow,e=r("a.tinvwl_add_to_wishlist_button[data-tinv-wl-product='"+t+"']");for(var t in i)i[t].hasOwnProperty("in")&&Array.isArray(i[t].in)&&(n=!0);e.each(function(){r(this).removeClass("tinvwl-add-hide").attr("data-tinv-wl-list",JSON.stringify(i)).toggleClass("tinvwl-product-in-list",n).toggleClass("tinvwl-product-make-remove",n&&o).attr("data-tinv-wl-action",n&&o?"remove":"addto")})})})}var n,o}i();var t=new MutationObserver(function(t){e=[],t.forEach(function(t){var i=t.addedNodes;null!==i&&r(i).each(function(){var t=r(this).find(".tinvwl_add_to_wishlist_button");t.length&&t.each(function(){"undefined"!==r(this).data("tinv-wl-product")&&r(this).data("tinv-wl-product")&&e.push(r(this).data("tinv-wl-product"))})})}),e.length&&i()}),n=document.body;t.observe(n,{childList:!0,subtree:!0})});var n=!0,o=tinvwl_add_to_wishlist.hash_key;try{n="sessionStorage"in window&&null!==window.sessionStorage,window.sessionStorage.setItem("ti","test"),window.sessionStorage.removeItem("ti"),window.localStorage.setItem("ti","test"),window.localStorage.removeItem("ti")}catch(t){n=!1}function a(t){if(n){localStorage.setItem(o,t),sessionStorage.setItem(o,t),"false"!==t?jQuery(".wishlist_products_counter_number, body.theme-woostify .wishlist-item-count").html(t):jQuery(".wishlist_products_counter_number, body.theme-woostify .wishlist-item-count").html("").closest("span.wishlist-counter-with-products").removeClass("wishlist-counter-with-products");var i=!("0"==t||"false"==t);jQuery(".wishlist_products_counter").toggleClass("wishlist-counter-with-products",i)}}}(jQuery),function(o){o(document).ready(function(){if(o("#tinvwl_manage_actions, #tinvwl_product_actions").addClass("form-control").parent().wrapInner('<div class="tinvwl-input-group tinvwl-no-full">').find("button").wrap('<span class="tinvwl-input-group-btn">'),o(".tinv-lists-nav").each(function(){o.trim(o(this).html()).length||o(this).remove()}),o("body").on("click",".social-buttons .social:not(.social-email,.social-whatsapp,.social-clipboard)",function(t){var i=window.open(o(this).attr("href"),o(this).attr("title"),"width=420,height=320,resizable=yes,scrollbars=yes,status=yes");i&&(i.focus(),t.preventDefault())}),"undefined"!=typeof ClipboardJS){new ClipboardJS(".social-buttons .social.social-clipboard",{text:function(t){return t.getAttribute("href")}}).on("success",function(t){showTooltip(t.trigger,tinvwl_add_to_wishlist.tinvwl_clipboard)});for(var t=document.querySelectorAll(".social-buttons .social.social-clipboard"),i=0;i<t.length;i++)t[i].addEventListener("mouseleave",clearTooltip),t[i].addEventListener("blur",clearTooltip)}o("body").on("click",".social-buttons .social.social-clipboard",function(t){t.preventDefault()}),o("body").on("click",".tinv-wishlist .tinv-overlay, .tinv-wishlist .tinv-close-modal, .tinv-wishlist .tinvwl_button_close",function(t){t.preventDefault(),o(this).parents(".tinv-modal:first").removeClass("tinv-modal-open")}),o("body").on("click",".tinv-wishlist .tinvwl-btn-onclick",function(t){o(this).data("url")&&(t.preventDefault(),window.location=o(this).data("url"))});var n=o(".tinv-wishlist .navigation-button");n.length&&n.each(function(){var t=o(this).find("> li");t.length<5&&t.parent().addClass("tinvwl-btns-count-"+t.length)}),o(".tinv-login .showlogin").unbind("click").on("click",function(t){t.preventDefault(),o(this).closest(".tinv-login").find(".login").toggle()}),o(".tinv-wishlist table.tinvwl-table-manage-list tfoot td").each(function(){o(this).toggle(!!o(this).children().not(".look_in").length||!!o(this).children(".look_in").children().length)})})}(jQuery),function(o){o.fn.tinvwl_break_submit=function(t){var i={selector:"input, select, textarea",ifempty:!0,invert:!1,validate:function(){return o(this).val()},rule:function(){var t=o(this).parents("form").eq(0).find(n.selector),i=n.invert;return 0===t.length?n.ifempty:(t.each(function(){i&&!n.invert||!i&&n.invert||(i=Boolean(n.validate.call(o(this))))}),i)}},n=o.extend(!0,{},i,t);return o(this).each(function(){o(this).on("click",function(t){n.rule.call(o(this))||(alert(window.tinvwl_add_to_wishlist.tinvwl_break_submit),t.preventDefault())})})},o(document).ready(function(){o(".tinvwl-break-input").tinvwl_break_submit({selector:".tinvwl-break-input-filed"}),o(".tinvwl-break-checkbox").tinvwl_break_submit({selector:"table td input[type=checkbox]",validate:function(){return o(this).is(":checked")}}),o(".global-cb").on("click",function(){o(this).closest("table").eq(0).find(".product-cb input[type=checkbox], .wishlist-cb input[type=checkbox]").prop("checked",o(this).is(":checked"))})})}(jQuery);
|
1 |
Â
/**
|
2 |
Â
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
+
* @version 1.20.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(r){r.fn.tinvwl_to_wishlist=function(t){var i={api_url:window.location.href.split("?")[0],text_create:window.tinvwl_add_to_wishlist.text_create,text_already_in:window.tinvwl_add_to_wishlist.text_already_in,class:{dialogbox:".tinvwl_add_to_select_wishlist",select:".tinvwl_wishlist",newtitle:".tinvwl_new_input",dialogbutton:".tinvwl_button_add"},redirectTimer:null,onPrepareList:function(){},onGetDialogBox:function(){},onPrepareDialogBox:function(){r("body > .tinv-wishlist").length||r("body").append(r("<div>").addClass("tinv-wishlist")),r(this).appendTo("body > .tinv-wishlist")},onCreateWishList:function(t){r(this).append(r("<option>").html(t.title).val(t.ID).toggleClass("tinv_in_wishlist",t.in))},onSelectWishList:function(){},onDialogShow:function(t){r(t).addClass("tinv-modal-open"),r(t).removeClass("ftinvwl-pulse")},onDialogHide:function(t){r(t).removeClass("tinv-modal-open"),r(t).removeClass("ftinvwl-pulse")},onInited:function(){},onClick:function(){if(r(this).is(".disabled-add-wishlist"))return!1;r(this).is(".ftinvwl-animated")&&r(this).addClass("ftinvwl-pulse"),this.tinvwl_dialog?this.tinvwl_dialog.show_list.call(this):e.onActionProduct.call(this)},onPrepareDataAction:function(t,i){r("body").trigger("tinvwl_wishlist_button_clicked",[t,i])},filterProductAlreadyIn:function(t){t=t||[];var o={};return r("form.cart[method=post], .woocommerce-variation-add-to-cart, form.vtajaxform[method=post]").find("input, select").each(function(){var t=r(this).attr("name"),i=r(this).attr("type"),n=r(this).val();("checkbox"!==i&&"radio"!==i||r(this).is(":checked"))&&(o["form"+t]=n)}),o=o.formvariation_id,t.filter(function(t){if("object"!==_typeof(t.in)||"string"!=typeof o)return t.in;var i=parseInt(o);return 0<=t.in.indexOf(i)})},onMultiProductAlreadyIn:function(t){t=t||[];t=e.onPrepareList.call(t)||t,t=e.filterProductAlreadyIn.call(this,t)||t,r(this).parent().parent().find(".already-in").remove();var n="";switch(t.length){case 0:break;default:n=r("<ul>");r.each(t,function(t,i){n.append(r("<li>").html(r("<a>").html(i.title).attr({href:i.url})).val(i.ID))})}n.length&&r(this).closest(".tinv-modal-inner").find("img").after(r("<div>").addClass("already-in").html(e.text_already_in+" ").append(n))},onAction:{redirect:function(t){e.redirectTimer&&clearTimeout(e.redirectTimer),e.redirectTimer=window.setTimeout(function(){window.location.href=t},4e3)},force_redirect:function(t){window.location.href=t},wishlists:function(t){var i=r(this).data("tinv-wl-product");r("a.tinvwl_add_to_wishlist_button[data-tinv-wl-product='"+i+"']").each(function(){r(this).attr("data-tinv-wl-list",t)})},msg:function(t){if(!t)return!1;var i=r(t).eq(0);r("body > .tinv-wishlist").length||r("body").append(r("<div>").addClass("tinv-wishlist")),r("body > .tinv-wishlist").append(i),i.on("click",".tinv-close-modal, .tinvwl_button_close, .tinv-overlay",function(t){t.preventDefault(),i.remove(),e.redirectTimer&&clearTimeout(e.redirectTimer)})},status:function(t){if(r("body").trigger("tinvwl_wishlist_added_status",[this,t]),t){var i=r(this).data("tinv-wl-product");r("a.tinvwl_add_to_wishlist_button[data-tinv-wl-product='"+i+"']").each(function(){r(this).addClass("tinvwl-product-in-list")})}},removed:function(t){if(t){var i=r(this).data("tinv-wl-product");r("a.tinvwl_add_to_wishlist_button[data-tinv-wl-product='"+i+"']").each(function(){r(this).removeClass("tinvwl-product-in-list").removeClass("tinvwl-product-make-remove").attr("data-tinv-wl-action","addto")})}},make_remove:function(t){if(t){var i=r(this).data("tinv-wl-product");r("a.tinvwl_add_to_wishlist_button[data-tinv-wl-product='"+i+"']").each(function(){r(this).toggleClass("tinvwl-product-make-remove",t).attr("data-tinv-wl-action",t?"remove":"addto")})}},counter:function(t){var i=!("0"==t||""==t);r(".wishlist_products_counter").toggleClass("wishlist-counter-with-products",i),a(t)}}};i.onActionProduct=function(t,i){var s={form:{},tinv_wishlist_id:t||"",tinv_wishlist_name:i||"",product_type:r(this).attr("data-tinv-wl-producttype"),product_id:r(this).attr("data-tinv-wl-product")||0,product_variation:r(this).attr("data-tinv-wl-productvariation")||0,product_action:r(this).attr("data-tinv-wl-action")||"addto",redirect:window.location.href},n=this;r(n).closest("form.cart[method=post], form.vtajaxform[method=post], .tinvwl-loop-button-wrapper").find("input:not(:disabled), select:not(:disabled), textarea:not(:disabled)").each(function(){function e(t,i){if("object"!==_typeof(i))return i;for(var n in void 0===t&&(t={}),i)if(""===n){var o=-1;for(o in t)o=o;t[o=parseInt(o)+1]=e(t[n],i[n])}else t[n]=e(t[n],i[n]);return t}var t=r(this).attr("name"),i=r(this).attr("type"),n=r(this).val(),o=10;if("button"!==i&&void 0!==t){for(;/^(.+)\[([^\[\]]*?)\]$/.test(t)&&0<o;){var l=t.match(/^(.+)\[([^\[\]]*?)\]$/);if(3===l.length){var a={};a[l[2]]=n,n=a}t=l[1],o--}"checkbox"===i||"radio"===i?r(this).is(":checked")&&(n.length||"object"===_typeof(n)||(n=!0),s.form[t]=e(s.form[t],n)):s.form[t]=e(s.form[t],n)}}),s=e.onPrepareDataAction.call(n,n,s)||s,r.post(e.api_url,s,function(t){if(e.onDialogHide.call(n.tinvwl_dialog,n),"object"===_typeof(t))for(var i in t)"function"==typeof e.onAction[i]&&e.onAction[i].call(n,t[i]);else"function"==typeof e.onAction.msg&&e.onAction.msg.call(n,t)})};var e=r.extend(!0,{},i,t);return r(this).each(function(){if(!r(this).attr("data-tinv-wl-list"))return!1;if(e.dialogbox&&e.dialogbox.length&&(this.tinvwl_dialog=e.dialogbox),this.tinvwl_dialog||(this.tinvwl_dialog=e.onGetDialogBox.call(this)),!this.tinvwl_dialog){var t=r(this).nextAll(e.class.dialogbox).eq(0);t.length&&(this.tinvwl_dialog=t)}if(this.tinvwl_dialog){e.onPrepareDialogBox.call(this.tinvwl_dialog),"function"!=typeof this.tinvwl_dialog.update_list&&(this.tinvwl_dialog.update_list=function(t){var n=r(this).find(e.class.select).eq(0);r(this).find(e.class.newtitle).hide().val(""),n.html(""),r.each(t,function(t,i){e.onCreateWishList.call(n,i)}),e.text_create&&e.onCreateWishList.call(n,{ID:"",title:e.text_create,in:!1}),e.onMultiProductAlreadyIn.call(n,t),e.onSelectWishList.call(n,t),r(this).find(e.class.newtitle).toggle(""===n.val())}),"function"!=typeof this.tinvwl_dialog.show_list&&(this.tinvwl_dialog.show_list=function(){var t=r.parseJSON(r(this).attr("data-tinv-wl-list"))||[];t.length?(t=e.onPrepareList.call(t)||t,this.tinvwl_dialog.update_list(t),e.onDialogShow.call(this.tinvwl_dialog,this)):e.onActionProduct.call(this)});var o=this;r(this.tinvwl_dialog).find(e.class.dialogbutton).off("click").on("click",function(){var t,i=r(o.tinvwl_dialog).find(e.class.select),n=r(o.tinvwl_dialog).find(e.class.newtitle);i.val()||n.val()?e.onActionProduct.call(o,i.val(),n.val()):((t=n.is(":visible")?n:i).addClass("empty-name-wishlist"),window.setTimeout(function(){t.removeClass("empty-name-wishlist")},1e3))})}r(this).off("click").on("click",e.onClick),e.onInited.call(this,e)})},r(document).ready(function(){r("body").on("click",".tinvwl_add_to_wishlist_button",function(t){if(r(this).is(".disabled-add-wishlist"))return t.preventDefault(),void window.alert(tinvwl_add_to_wishlist.i18n_make_a_selection_text);r(this).is(".inited-add-wishlist")||r(this).tinvwl_to_wishlist({onInited:function(t){r(this).addClass("inited-add-wishlist"),t.onClick.call(this)}})}),r(document).on("hide_variation",".variations_form",function(t){var i=r(this).find(".tinvwl_add_to_wishlist_button");i.length&&!tinvwl_add_to_wishlist.allow_parent_variable&&(t.preventDefault(),i.addClass("disabled-add-wishlist"))}),r(document).on("show_variation",".variations_form",function(t,i,n){var o=r(this).find(".tinvwl_add_to_wishlist_button");if(o.length&&o.attr("data-tinv-wl-list")){var e=JSON.parse(o.attr("data-tinv-wl-list")),l=!1,a="1"==window.tinvwl_add_to_wishlist.simple_flow;for(var s in e)e[s].hasOwnProperty("in")&&Array.isArray(e[s].in)&&-1<(e[s].in||[]).indexOf(i.variation_id)&&(l=!0);o.toggleClass("tinvwl-product-in-list",l).toggleClass("tinvwl-product-make-remove",l&&a).attr("data-tinv-wl-action",l&&a?"remove":"addto")}t.preventDefault(),o.removeClass("disabled-add-wishlist")}),r(window).on("storage onstorage",function(t){o===t.originalEvent.key&&localStorage.getItem(o)!==sessionStorage.getItem(o)&&a(localStorage.getItem(o))});var e=[],l=!1;r("a.tinvwl_add_to_wishlist_button").each(function(){"undefined"!==r(this).data("tinv-wl-product")&&r(this).data("tinv-wl-product")&&e.push(r(this).data("tinv-wl-product"))}),r(".wishlist_products_counter_number").each(function(){l=!0});function i(){if(e.length||l){var t={ids:e,counter:l};tinvwl_add_to_wishlist.wpml&&(t.lang=tinvwl_add_to_wishlist.wpml);var i=(n=tinvwl_add_to_wishlist.rest_root+"wishlist/v1/products",o=t,r.isEmptyObject(o)||(n+=(0<=n.indexOf("?")?"&":"?")+r.param(o)),n);r.ajax({url:i,method:"GET",beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",tinvwl_add_to_wishlist.nonce)}}).done(function(t){var i=!("0"==t.counter||""==t.counter);r(".wishlist_products_counter").toggleClass("wishlist-counter-with-products",i),a(t.counter),r.each(t.products,function(t,o){var e=t,l="1"==window.tinvwl_add_to_wishlist.simple_flow;r("a.tinvwl_add_to_wishlist_button[data-tinv-wl-product='"+e+"']").each(function(){var t=r(this).data("tinv-wl-productvariation"),i=!1;for(var n in o)o[n].hasOwnProperty("in")&&Array.isArray(o[n].in)&&(-1<(o[n].in||[]).indexOf(e)||-1<(o[n].in||[]).indexOf(t))&&(i=!0);r(this).removeClass("tinvwl-add-hide").attr("data-tinv-wl-list",JSON.stringify(o)).toggleClass("tinvwl-product-in-list",i).toggleClass("tinvwl-product-make-remove",i&&l).attr("data-tinv-wl-action",i&&l?"remove":"addto")})})})}var n,o}i();var t=new MutationObserver(function(t){e=[],t.forEach(function(t){var i=t.addedNodes;null!==i&&r(i).each(function(){var t=r(this).find(".tinvwl_add_to_wishlist_button");t.length&&t.each(function(){"undefined"!==r(this).data("tinv-wl-product")&&r(this).data("tinv-wl-product")&&e.push(r(this).data("tinv-wl-product"))})})}),e.length&&i()}),n=document.body;t.observe(n,{childList:!0,subtree:!0})});var n=!0,o=tinvwl_add_to_wishlist.hash_key;try{n="sessionStorage"in window&&null!==window.sessionStorage,window.sessionStorage.setItem("ti","test"),window.sessionStorage.removeItem("ti"),window.localStorage.setItem("ti","test"),window.localStorage.removeItem("ti")}catch(t){n=!1}function a(t){if(n){localStorage.setItem(o,t),sessionStorage.setItem(o,t),"false"!==t?jQuery(".wishlist_products_counter_number, body.theme-woostify .wishlist-item-count").html(t):jQuery(".wishlist_products_counter_number, body.theme-woostify .wishlist-item-count").html("").closest("span.wishlist-counter-with-products").removeClass("wishlist-counter-with-products");var i=!("0"==t||"false"==t);jQuery(".wishlist_products_counter").toggleClass("wishlist-counter-with-products",i)}}}(jQuery),function(o){o(document).ready(function(){if(o("#tinvwl_manage_actions, #tinvwl_product_actions").addClass("form-control").parent().wrapInner('<div class="tinvwl-input-group tinvwl-no-full">').find("button").wrap('<span class="tinvwl-input-group-btn">'),o(".tinv-lists-nav").each(function(){o.trim(o(this).html()).length||o(this).remove()}),o("body").on("click",".social-buttons .social:not(.social-email,.social-whatsapp,.social-clipboard)",function(t){var i=window.open(o(this).attr("href"),o(this).attr("title"),"width=420,height=320,resizable=yes,scrollbars=yes,status=yes");i&&(i.focus(),t.preventDefault())}),"undefined"!=typeof ClipboardJS){new ClipboardJS(".social-buttons .social.social-clipboard",{text:function(t){return t.getAttribute("href")}}).on("success",function(t){showTooltip(t.trigger,tinvwl_add_to_wishlist.tinvwl_clipboard)});for(var t=document.querySelectorAll(".social-buttons .social.social-clipboard"),i=0;i<t.length;i++)t[i].addEventListener("mouseleave",clearTooltip),t[i].addEventListener("blur",clearTooltip)}o("body").on("click",".social-buttons .social.social-clipboard",function(t){t.preventDefault()}),o("body").on("click",".tinv-wishlist .tinv-overlay, .tinv-wishlist .tinv-close-modal, .tinv-wishlist .tinvwl_button_close",function(t){t.preventDefault(),o(this).parents(".tinv-modal:first").removeClass("tinv-modal-open")}),o("body").on("click",".tinv-wishlist .tinvwl-btn-onclick",function(t){o(this).data("url")&&(t.preventDefault(),window.location=o(this).data("url"))});var n=o(".tinv-wishlist .navigation-button");n.length&&n.each(function(){var t=o(this).find("> li");t.length<5&&t.parent().addClass("tinvwl-btns-count-"+t.length)}),o(".tinv-login .showlogin").unbind("click").on("click",function(t){t.preventDefault(),o(this).closest(".tinv-login").find(".login").toggle()}),o(".tinv-wishlist table.tinvwl-table-manage-list tfoot td").each(function(){o(this).toggle(!!o(this).children().not(".look_in").length||!!o(this).children(".look_in").children().length)})})}(jQuery),function(o){o.fn.tinvwl_break_submit=function(t){var i={selector:"input, select, textarea",ifempty:!0,invert:!1,validate:function(){return o(this).val()},rule:function(){var t=o(this).parents("form").eq(0).find(n.selector),i=n.invert;return 0===t.length?n.ifempty:(t.each(function(){i&&!n.invert||!i&&n.invert||(i=Boolean(n.validate.call(o(this))))}),i)}},n=o.extend(!0,{},i,t);return o(this).each(function(){o(this).on("click",function(t){n.rule.call(o(this))||(alert(window.tinvwl_add_to_wishlist.tinvwl_break_submit),t.preventDefault())})})},o(document).ready(function(){o(".tinvwl-break-input").tinvwl_break_submit({selector:".tinvwl-break-input-filed"}),o(".tinvwl-break-checkbox").tinvwl_break_submit({selector:"table td input[type=checkbox]",validate:function(){return o(this).is(":checked")}}),o(".global-cb").on("click",function(){o(this).closest("table").eq(0).find(".product-cb input[type=checkbox], .wishlist-cb input[type=checkbox]").prop("checked",o(this).is(":checked"))})})}(jQuery);
|
includes/api/wishlist.class.php
CHANGED
@@ -174,7 +174,7 @@ class TInvWL_Includes_API_Wishlist {
|
|
174 |
Â
$data['author'] = $request['user_id'];
|
175 |
Â
}
|
176 |
Â
|
177 |
-
if ( $data ) {
|
178 |
Â
$update = $wl->update( $wishlist['ID'], $data );
|
179 |
Â
|
180 |
Â
if ( $update ) {
|
@@ -185,6 +185,8 @@ class TInvWL_Includes_API_Wishlist {
|
|
185 |
Â
|
186 |
Â
throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_wishlist_update_error', __( 'Update wishlist data failed.', 'ti-woocommerce-wishlist' ), 400 );
|
187 |
Â
|
Â
|
|
Â
|
|
188 |
Â
}
|
189 |
Â
}
|
190 |
Â
} catch ( WC_REST_Exception $e ) {
|
@@ -265,6 +267,10 @@ class TInvWL_Includes_API_Wishlist {
|
|
265 |
Â
throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_invalid_share_key', __( 'Invalid wishlist share key.', 'ti-woocommerce-wishlist' ), 400 );
|
266 |
Â
}
|
267 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
268 |
Â
$wlp = new TInvWL_Product();
|
269 |
Â
|
270 |
Â
$args = array();
|
@@ -312,6 +318,11 @@ class TInvWL_Includes_API_Wishlist {
|
|
312 |
Â
$item_id = $request['item_id'];
|
313 |
Â
|
314 |
Â
if ( ! empty( $item_id ) ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
315 |
Â
$wlp = new TInvWL_Product();
|
316 |
Â
|
317 |
Â
$args = array();
|
174 |
Â
$data['author'] = $request['user_id'];
|
175 |
Â
}
|
176 |
Â
|
177 |
+
if ( $data && current_user_can( 'tinvwl_general_settings' ) ) {
|
178 |
Â
$update = $wl->update( $wishlist['ID'], $data );
|
179 |
Â
|
180 |
Â
if ( $update ) {
|
185 |
Â
|
186 |
Â
throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_wishlist_update_error', __( 'Update wishlist data failed.', 'ti-woocommerce-wishlist' ), 400 );
|
187 |
Â
|
188 |
+
} else {
|
189 |
+
throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_wishlist_forbidden', __( 'Update wishlist data failed.', 'ti-woocommerce-wishlist' ), 403 );
|
190 |
Â
}
|
191 |
Â
}
|
192 |
Â
} catch ( WC_REST_Exception $e ) {
|
267 |
Â
throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_invalid_share_key', __( 'Invalid wishlist share key.', 'ti-woocommerce-wishlist' ), 400 );
|
268 |
Â
}
|
269 |
Â
|
270 |
+
if ( ! current_user_can( 'tinvwl_general_settings' ) ) {
|
271 |
+
throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_wishlist_forbidden', __( 'Add product to wishlist failed.', 'ti-woocommerce-wishlist' ), 403 );
|
272 |
+
}
|
273 |
+
|
274 |
Â
$wlp = new TInvWL_Product();
|
275 |
Â
|
276 |
Â
$args = array();
|
318 |
Â
$item_id = $request['item_id'];
|
319 |
Â
|
320 |
Â
if ( ! empty( $item_id ) ) {
|
321 |
+
|
322 |
+
if ( ! current_user_can( 'tinvwl_general_settings' ) ) {
|
323 |
+
throw new WC_REST_Exception( 'ti_woocommerce_wishlist_api_wishlist_forbidden', __( 'Product not found.', 'ti-woocommerce-wishlist' ), 403 );
|
324 |
+
}
|
325 |
+
|
326 |
Â
$wlp = new TInvWL_Product();
|
327 |
Â
|
328 |
Â
$args = array();
|
includes/form.helper.php
CHANGED
@@ -575,6 +575,9 @@ class TInvWL_Form {
|
|
575 |
Â
$mimefiles = array_filter( $mimefiles );
|
576 |
Â
$mimefiles = wp_json_encode( $mimefiles );
|
577 |
Â
|
Â
|
|
Â
|
|
Â
|
|
578 |
Â
wp_enqueue_media();
|
579 |
Â
|
580 |
Â
return sprintf( "<div class='tinvwl-input-group'>%s%s<div class='tinvwl-input-group-btn'>%s</div></div><script type=\"text/javascript\">jQuery(document).ready(function($){var nn='%s';" . ( empty( $value ) ? "$('.' + nn + '-preview').hide();" : "" ) . "$('input[name=\"'+nn+'-btn\"]').click(function(e){e.preventDefault();var i=wp.media({multiple:false, library:{type:{$mimefiles}}}).open().on('select',function(e){var u=i.state().get('selection').first();var iu=u.toJSON().url;$('input[name=\"'+nn+'\"]').val(iu);$('.' + nn + '-preview').show();$('.' + nn + '-preview span img').attr('src', iu);});});});</script>", // @codingStandardsIgnoreLine Squiz.Strings.DoubleQuoteUsage.NotRequired
|
575 |
Â
$mimefiles = array_filter( $mimefiles );
|
576 |
Â
$mimefiles = wp_json_encode( $mimefiles );
|
577 |
Â
|
578 |
+
$extra_field .= ' disabled="disabled"';
|
579 |
+
$data['type'] = 'text';
|
580 |
+
|
581 |
Â
wp_enqueue_media();
|
582 |
Â
|
583 |
Â
return sprintf( "<div class='tinvwl-input-group'>%s%s<div class='tinvwl-input-group-btn'>%s</div></div><script type=\"text/javascript\">jQuery(document).ready(function($){var nn='%s';" . ( empty( $value ) ? "$('.' + nn + '-preview').hide();" : "" ) . "$('input[name=\"'+nn+'-btn\"]').click(function(e){e.preventDefault();var i=wp.media({multiple:false, library:{type:{$mimefiles}}}).open().on('select',function(e){var u=i.state().get('selection').first();var iu=u.toJSON().url;$('input[name=\"'+nn+'\"]').val(iu);$('.' + nn + '-preview').show();$('.' + nn + '-preview span img').attr('src', iu);});});});</script>", // @codingStandardsIgnoreLine Squiz.Strings.DoubleQuoteUsage.NotRequired
|
includes/wishlist.class.php
CHANGED
@@ -62,14 +62,15 @@ class TInvWL_Wishlist {
|
|
62 |
Â
/**
|
63 |
Â
* Constructor
|
64 |
Â
*
|
Â
|
|
Â
|
|
65 |
Â
* @global wpdb $wpdb
|
66 |
Â
*
|
67 |
-
* @param string $plugin_name Plugin name.
|
68 |
Â
*/
|
69 |
Â
function __construct( $plugin_name = TINVWL_PREFIX ) {
|
70 |
Â
global $wpdb;
|
71 |
Â
|
72 |
-
$this->_name
|
73 |
Â
$this->table = sprintf( '%s%s_%s', $wpdb->prefix, $this->_name, 'lists' );
|
74 |
Â
$this->default_name = apply_filters( 'tinvwl_default_wishlist_title', tinv_get_option( 'general', 'default_title' ) );
|
75 |
Â
$this->default_privacy = 'share';
|
@@ -83,8 +84,8 @@ class TInvWL_Wishlist {
|
|
83 |
Â
/**
|
84 |
Â
* Generate unique share key
|
85 |
Â
*
|
86 |
-
* @global wpdb $wpdb
|
87 |
Â
* @return string
|
Â
|
|
88 |
Â
*/
|
89 |
Â
function unique_share_key() {
|
90 |
Â
global $wpdb;
|
@@ -155,14 +156,14 @@ class TInvWL_Wishlist {
|
|
155 |
Â
/**
|
156 |
Â
* Add wishlist
|
157 |
Â
*
|
158 |
-
* @global wpdb $wpdb
|
159 |
-
*
|
160 |
Â
* @param mixed $data wishlist name or object.
|
161 |
Â
* @param string $type List or default.
|
162 |
Â
* @param string $status Public, Share, Private.
|
163 |
Â
* @param integer $user_id Can put 0.
|
164 |
Â
*
|
165 |
Â
* @return boolean
|
Â
|
|
Â
|
|
166 |
Â
*/
|
167 |
Â
function add( $data, $type = 'list', $status = 'public', $user_id = 0 ) {
|
168 |
Â
$user_id = absint( $user_id );
|
@@ -271,7 +272,8 @@ class TInvWL_Wishlist {
|
|
271 |
Â
$_data = array(
|
272 |
Â
'author' => $user_id,
|
273 |
Â
);
|
274 |
-
|
Â
|
|
275 |
Â
$_data['status'] = 'public';
|
276 |
Â
}
|
277 |
Â
$data = tinv_array_merge( $data, $_data );
|
@@ -318,11 +320,11 @@ class TInvWL_Wishlist {
|
|
318 |
Â
/**
|
319 |
Â
* Get wishlist
|
320 |
Â
*
|
321 |
-
* @global wpdb $wpdb
|
322 |
-
*
|
323 |
Â
* @param array $data Requset.
|
324 |
Â
*
|
325 |
Â
* @return array
|
Â
|
|
Â
|
|
326 |
Â
*/
|
327 |
Â
function get( $data = array() ) {
|
328 |
Â
global $wpdb;
|
@@ -414,14 +416,14 @@ class TInvWL_Wishlist {
|
|
414 |
Â
/**
|
415 |
Â
* Update wishlist
|
416 |
Â
*
|
417 |
-
* @global wpdb $wpdb
|
418 |
-
*
|
419 |
Â
* @param integer $id id database wishlist.
|
420 |
Â
* @param mixed $data wishlist name or object.
|
421 |
Â
* @param string $type List or default.
|
422 |
Â
* @param string $status Public, Share, Private.
|
423 |
Â
*
|
424 |
Â
* @return boolean
|
Â
|
|
Â
|
|
425 |
Â
*/
|
426 |
Â
function update( $id, $data, $type = 'list', $status = 'public' ) {
|
427 |
Â
if ( ! is_array( $data ) ) {
|
@@ -453,11 +455,11 @@ class TInvWL_Wishlist {
|
|
453 |
Â
/**
|
454 |
Â
* Remove wishlist
|
455 |
Â
*
|
456 |
-
* @global wpdb $wpdb
|
457 |
-
*
|
458 |
Â
* @param integer $id id database wishlist.
|
459 |
Â
*
|
460 |
Â
* @return boolean
|
Â
|
|
Â
|
|
461 |
Â
*/
|
462 |
Â
public function remove( $id ) {
|
463 |
Â
$id = absint( $id );
|
62 |
Â
/**
|
63 |
Â
* Constructor
|
64 |
Â
*
|
65 |
+
* @param string $plugin_name Plugin name.
|
66 |
+
*
|
67 |
Â
* @global wpdb $wpdb
|
68 |
Â
*
|
Â
|
|
69 |
Â
*/
|
70 |
Â
function __construct( $plugin_name = TINVWL_PREFIX ) {
|
71 |
Â
global $wpdb;
|
72 |
Â
|
73 |
+
$this->_name = $plugin_name;
|
74 |
Â
$this->table = sprintf( '%s%s_%s', $wpdb->prefix, $this->_name, 'lists' );
|
75 |
Â
$this->default_name = apply_filters( 'tinvwl_default_wishlist_title', tinv_get_option( 'general', 'default_title' ) );
|
76 |
Â
$this->default_privacy = 'share';
|
84 |
Â
/**
|
85 |
Â
* Generate unique share key
|
86 |
Â
*
|
Â
|
|
87 |
Â
* @return string
|
88 |
+
* @global wpdb $wpdb
|
89 |
Â
*/
|
90 |
Â
function unique_share_key() {
|
91 |
Â
global $wpdb;
|
156 |
Â
/**
|
157 |
Â
* Add wishlist
|
158 |
Â
*
|
Â
|
|
Â
|
|
159 |
Â
* @param mixed $data wishlist name or object.
|
160 |
Â
* @param string $type List or default.
|
161 |
Â
* @param string $status Public, Share, Private.
|
162 |
Â
* @param integer $user_id Can put 0.
|
163 |
Â
*
|
164 |
Â
* @return boolean
|
165 |
+
* @global wpdb $wpdb
|
166 |
+
*
|
167 |
Â
*/
|
168 |
Â
function add( $data, $type = 'list', $status = 'public', $user_id = 0 ) {
|
169 |
Â
$user_id = absint( $user_id );
|
272 |
Â
$_data = array(
|
273 |
Â
'author' => $user_id,
|
274 |
Â
);
|
275 |
+
|
276 |
+
if ( ! current_user_can( 'tinvwl_general_settings' ) && ( empty( $this->user ) || ( $_data['author'] != $this->user ) ) ) { // WPCS: loose comparison ok.
|
277 |
Â
$_data['status'] = 'public';
|
278 |
Â
}
|
279 |
Â
$data = tinv_array_merge( $data, $_data );
|
320 |
Â
/**
|
321 |
Â
* Get wishlist
|
322 |
Â
*
|
Â
|
|
Â
|
|
323 |
Â
* @param array $data Requset.
|
324 |
Â
*
|
325 |
Â
* @return array
|
326 |
+
* @global wpdb $wpdb
|
327 |
+
*
|
328 |
Â
*/
|
329 |
Â
function get( $data = array() ) {
|
330 |
Â
global $wpdb;
|
416 |
Â
/**
|
417 |
Â
* Update wishlist
|
418 |
Â
*
|
Â
|
|
Â
|
|
419 |
Â
* @param integer $id id database wishlist.
|
420 |
Â
* @param mixed $data wishlist name or object.
|
421 |
Â
* @param string $type List or default.
|
422 |
Â
* @param string $status Public, Share, Private.
|
423 |
Â
*
|
424 |
Â
* @return boolean
|
425 |
+
* @global wpdb $wpdb
|
426 |
+
*
|
427 |
Â
*/
|
428 |
Â
function update( $id, $data, $type = 'list', $status = 'public' ) {
|
429 |
Â
if ( ! is_array( $data ) ) {
|
455 |
Â
/**
|
456 |
Â
* Remove wishlist
|
457 |
Â
*
|
Â
|
|
Â
|
|
458 |
Â
* @param integer $id id database wishlist.
|
459 |
Â
*
|
460 |
Â
* @return boolean
|
461 |
+
* @global wpdb $wpdb
|
462 |
+
*
|
463 |
Â
*/
|
464 |
Â
public function remove( $id ) {
|
465 |
Â
$id = absint( $id );
|
integrations/elex-woocommerce-catalog-mode.php
ADDED
@@ -0,0 +1,50 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* TI WooCommerce Wishlist integration with:
|
4 |
+
*
|
5 |
+
* @name ELEX WooCommerce Catalog Mode
|
6 |
+
*
|
7 |
+
* @version 1.0.6
|
8 |
+
*
|
9 |
+
* @slug elex-woocommerce-catalog-mode
|
10 |
+
*
|
11 |
+
* @url https://wordpress.org/plugins/elex-woocommerce-catalog-mode/
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
|
15 |
+
// If this file is called directly, abort.
|
16 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
17 |
+
die;
|
18 |
+
}
|
19 |
+
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Run hooks on page redirect.
|
23 |
+
*/
|
24 |
+
function elex_init() {
|
25 |
+
if ( class_exists( 'Elex_CM_Price_Discount_Admin' ) ) {
|
26 |
+
|
27 |
+
global $post;
|
28 |
+
$product = wc_get_product( $post->ID );
|
29 |
+
if ( ! empty( $product ) ) {
|
30 |
+
|
31 |
+
if ( 'yes' == get_option( 'eh_pricing_discount_cart_catalog_mode' ) && 'yes' == get_option( 'elex_catalog_remove_addtocart_product' ) ) {
|
32 |
+
if ( ! ( get_option( 'eh_pricing_discount_price_catalog_mode_exclude_admin' ) == 'yes' && in_array( 'administrator', (array) wp_get_current_user()->roles ) ) ) {
|
33 |
+
add_action( 'woocommerce_single_product_summary', 'elex_single_product_summary', 40 );
|
34 |
+
}
|
35 |
+
} elseif ( ( 'yes' == get_post_meta( $post->ID, 'product_adjustment_hide_addtocart_catalog', true ) ) && ( ( 'yes' == get_post_meta( $post->ID, 'product_adjustment_hide_addtocart_catalog_product', true ) ) || ( '' == get_post_meta( $post->ID, 'product_adjustment_hide_addtocart_catalog_product', true ) ) ) ) {
|
36 |
+
if ( ! ( get_post_meta( $post->ID, 'product_adjustment_exclude_admin_catalog', true ) == 'yes' && in_array( 'administrator', (array) wp_get_current_user()->roles ) ) ) {
|
37 |
+
add_action( 'woocommerce_single_product_summary', 'elex_single_product_summary', 40 );
|
38 |
+
}
|
39 |
+
}
|
40 |
+
}
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
add_action( 'template_redirect', 'elex_init' );
|
45 |
+
|
46 |
+
// Add a custom hook for single page.
|
47 |
+
function elex_single_product_summary() {
|
48 |
+
add_filter( 'tinvwl_allow_addtowishlist_single_product_summary', '__return_true' );
|
49 |
+
do_action( 'tinvwl_single_product_summary' );
|
50 |
+
}
|
integrations/show-single-variations.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
Â
*
|
5 |
Â
* @name WooCommerce Show Single Variations by Iconic
|
6 |
Â
*
|
7 |
-
* @version
|
8 |
Â
*
|
9 |
Â
* @slug show-single-variations-premium
|
10 |
Â
*
|
4 |
Â
*
|
5 |
Â
* @name WooCommerce Show Single Variations by Iconic
|
6 |
Â
*
|
7 |
+
* @version 1.1.16
|
8 |
Â
*
|
9 |
Â
* @slug show-single-variations-premium
|
10 |
Â
*
|
integrations/theme-divi.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
Â
*
|
5 |
Â
* @name Divi
|
6 |
Â
*
|
7 |
-
* @version 4.
|
8 |
Â
*
|
9 |
Â
* @slug Divi
|
10 |
Â
*
|
@@ -26,6 +26,8 @@ function divi_init() {
|
|
26 |
Â
global $post;
|
27 |
Â
$product = wc_get_product( $post->ID );
|
28 |
Â
if ( ! empty( $product ) && ! $product->is_in_stock() ) {
|
Â
|
|
Â
|
|
29 |
Â
add_action( 'woocommerce_' . $product->get_type() . '_add_to_cart', 'divi_single_product_summary', 40 );
|
30 |
Â
}
|
31 |
Â
}
|
4 |
Â
*
|
5 |
Â
* @name Divi
|
6 |
Â
*
|
7 |
+
* @version 4.4.6
|
8 |
Â
*
|
9 |
Â
* @slug Divi
|
10 |
Â
*
|
26 |
Â
global $post;
|
27 |
Â
$product = wc_get_product( $post->ID );
|
28 |
Â
if ( ! empty( $product ) && ! $product->is_in_stock() ) {
|
29 |
+
remove_action( 'woocommerce_single_product_summary', 'tinvwl_view_addto_htmlout', 29 );
|
30 |
+
remove_action( 'woocommerce_single_product_summary', 'tinvwl_view_addto_htmlout', 31 );
|
31 |
Â
add_action( 'woocommerce_' . $product->get_type() . '_add_to_cart', 'divi_single_product_summary', 40 );
|
32 |
Â
}
|
33 |
Â
}
|
integrations/{oceanwp.php → theme-oceanwp.php}
RENAMED
File without changes
|
integrations/woo-payment-gateway.php
ADDED
@@ -0,0 +1,52 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* TI WooCommerce Wishlist integration with:
|
4 |
+
*
|
5 |
+
* @name Braintree For WooCommerce
|
6 |
+
*
|
7 |
+
* @version 3.1.8
|
8 |
+
*
|
9 |
+
* @slug woo-payment-gateway
|
10 |
+
*
|
11 |
+
* @url https://wordpress.org/plugins/woo-payment-gateway/
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
|
15 |
+
// If this file is called directly, abort.
|
16 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
17 |
+
die;
|
18 |
+
}
|
19 |
+
|
20 |
+
if ( ! function_exists( 'tinv_wishlist_item_meta_woo_payment_gateway' ) ) {
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Set description for meta Braintree For WooCommerce
|
24 |
+
*
|
25 |
+
* @param array $meta Meta array.
|
26 |
+
* @param array $wl_product Wishlist Product.
|
27 |
+
* @param \WC_Product $product Woocommerce Product.
|
28 |
+
*
|
29 |
+
* @return array
|
30 |
+
*/
|
31 |
+
|
32 |
+
function tinv_wishlist_item_meta_woo_payment_gateway( $item_data, $product_id, $variation_id ) {
|
33 |
+
if ( defined( 'WC_BRAINTREE_PLUGIN_NAME' ) ) {
|
34 |
+
foreach ( array_keys( $item_data ) as $key ) {
|
35 |
+
if ( strpos( $key, 'billing_' ) === 0 ) {
|
36 |
+
unset( $item_data[ $key ] );
|
37 |
+
}
|
38 |
+
if ( strpos( $key, 'shipping_' ) === 0 ) {
|
39 |
+
unset( $item_data[ $key ] );
|
40 |
+
}
|
41 |
+
if ( strpos( $key, 'wc_braintree_' ) === 0 ) {
|
42 |
+
unset( $item_data[ $key ] );
|
43 |
+
}
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
return $item_data;
|
48 |
+
}
|
49 |
+
|
50 |
+
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_item_meta_woo_payment_gateway', 10, 3 );
|
51 |
+
}
|
52 |
+
// End if().
|
integrations/woocommerce-multilingual.php
CHANGED
@@ -54,6 +54,41 @@ if ( ! function_exists( 'tinvwl_wpml_addtowishlist_prepare' ) ) {
|
|
54 |
Â
add_filter( 'tinvwl_addtowishlist_prepare', 'tinvwl_wpml_addtowishlist_prepare' );
|
55 |
Â
}
|
56 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
57 |
Â
if ( ! function_exists( 'tinvwl_wpml_addtowishlist_out_prepare' ) ) {
|
58 |
Â
|
59 |
Â
/**
|
54 |
Â
add_filter( 'tinvwl_addtowishlist_prepare', 'tinvwl_wpml_addtowishlist_prepare' );
|
55 |
Â
}
|
56 |
Â
|
57 |
+
if ( ! function_exists( 'tinvwl_wpml_addtowishlist_check_product' ) ) {
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Change product data if product need translate in WooCommerce Multilingual
|
61 |
+
*
|
62 |
+
* @param object $product WC_Product object.
|
63 |
+
*
|
64 |
+
* @return object $product WC_Product object
|
65 |
+
*/
|
66 |
+
function tinvwl_wpml_addtowishlist_check_product( $product ) {
|
67 |
+
if ( class_exists( 'woocommerce_wpml' ) ) {
|
68 |
+
|
69 |
+
global $woocommerce_wpml, $sitepress, $wpdb;
|
70 |
+
|
71 |
+
// Reload products class.
|
72 |
+
if ( version_compare( WCML_VERSION, '4.4.0', '<' ) ) {
|
73 |
+
$woocommerce_wpml->products = new WCML_Products( $woocommerce_wpml, $sitepress, $wpdb );
|
74 |
+
} else {
|
75 |
+
global $wpml_post_translations;
|
76 |
+
$woocommerce_wpml->products = new WCML_Products( $woocommerce_wpml, $sitepress, $wpml_post_translations, $wpdb );
|
77 |
+
}
|
78 |
+
|
79 |
+
if ( $product ) {
|
80 |
+
$product = wc_get_product( $woocommerce_wpml->products->get_original_product_id( $product->get_id() ) );
|
81 |
+
}
|
82 |
+
|
83 |
+
}
|
84 |
+
|
85 |
+
return $product;
|
86 |
+
}
|
87 |
+
|
88 |
+
add_filter( 'tinvwl_addtowishlist_check_product', 'tinvwl_wpml_addtowishlist_check_product' );
|
89 |
+
}
|
90 |
+
|
91 |
+
|
92 |
Â
if ( ! function_exists( 'tinvwl_wpml_addtowishlist_out_prepare' ) ) {
|
93 |
Â
|
94 |
Â
/**
|
integrations/wp-rocket.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
Â
*
|
5 |
Â
* @name WP Rocket
|
6 |
Â
*
|
7 |
-
* @version 3.
|
8 |
Â
*
|
9 |
Â
* @slug wp-rocket
|
10 |
Â
*
|
@@ -146,4 +146,35 @@ if ( defined( 'WP_ROCKET_VERSION' ) ) {
|
|
146 |
Â
delete_transient( 'rocket_get_refreshed_fragments_cache' );
|
147 |
Â
}
|
148 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
149 |
Â
}
|
4 |
Â
*
|
5 |
Â
* @name WP Rocket
|
6 |
Â
*
|
7 |
+
* @version 3.5.4
|
8 |
Â
*
|
9 |
Â
* @slug wp-rocket
|
10 |
Â
*
|
146 |
Â
delete_transient( 'rocket_get_refreshed_fragments_cache' );
|
147 |
Â
}
|
148 |
Â
}
|
149 |
+
|
150 |
+
add_filter( 'nonce_user_logged_out', 'tinvwl_revert_uid_for_nonce_actions', 100, 2 );
|
151 |
+
|
152 |
+
/**
|
153 |
+
* Set $user_id to 0 for certain nonce actions.
|
154 |
+
*
|
155 |
+
* WooCommerce core changes how nonces are used for non-logged customers.
|
156 |
+
* When a user is logged out, but has items in their cart, WC core sets the $uid as a random string customer id.
|
157 |
+
* This is going to mess out nonce validation with WP Rocket and third party plugins which do not bypass WC nonce changes.
|
158 |
+
* WP Rocket caches the page so the nonce $uid will be always different than the session customer $uid.
|
159 |
+
* This function will check the nonce against a UID of 0 because this is how WP Rocket generated the cached page.
|
160 |
+
*
|
161 |
+
*
|
162 |
+
* @param string|int $user_id ID of the nonce-owning user.
|
163 |
+
* @param string|int $action The nonce action.
|
164 |
+
*
|
165 |
+
* @return int $uid ID of the nonce-owning user.
|
166 |
+
*
|
167 |
+
*/
|
168 |
+
function tinvwl_revert_uid_for_nonce_actions( $user_id, $action ) {
|
169 |
+
// User ID is invalid.
|
170 |
+
if ( empty( $user_id ) || 0 === $user_id ) {
|
171 |
+
return $user_id;
|
172 |
+
}
|
173 |
+
|
174 |
+
if ( ! $action || 'wp_rest' !== $action ) {
|
175 |
+
return $user_id;
|
176 |
+
}
|
177 |
+
|
178 |
+
return 0;
|
179 |
+
}
|
180 |
Â
}
|
languages/ti-woocommerce-wishlist.pot
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
-
# Copyright (C) 2020 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"
|
@@ -764,7 +764,7 @@ msgstr ""
|
|
764 |
Â
msgid "Return wishlist products counter."
|
765 |
Â
msgstr ""
|
766 |
Â
|
767 |
-
#: includes/api/wishlist.class.php:102, includes/api/wishlist.class.php:165, includes/api/wishlist.class.php:
|
768 |
Â
msgid "Invalid wishlist share key."
|
769 |
Â
msgstr ""
|
770 |
Â
|
@@ -772,19 +772,19 @@ msgstr ""
|
|
772 |
Â
msgid "No wishlists found for this user."
|
773 |
Â
msgstr ""
|
774 |
Â
|
775 |
-
#: includes/api/wishlist.class.php:186
|
776 |
Â
msgid "Update wishlist data failed."
|
777 |
Â
msgstr ""
|
778 |
Â
|
779 |
-
#: includes/api/wishlist.class.php:
|
780 |
Â
msgid "Add product to wishlist failed."
|
781 |
Â
msgstr ""
|
782 |
Â
|
783 |
-
#: includes/api/wishlist.class.php:323
|
784 |
Â
msgid "Product not found."
|
785 |
Â
msgstr ""
|
786 |
Â
|
787 |
-
#: includes/api/wishlist.class.php:
|
788 |
Â
msgid "Product removed from a wishlist."
|
789 |
Â
msgstr ""
|
790 |
Â
|
@@ -904,7 +904,7 @@ msgstr ""
|
|
904 |
Â
msgid "Page Setup"
|
905 |
Â
msgstr ""
|
906 |
Â
|
907 |
-
#: includes/wizard.class.php:289, includes/wizard.class.php:320, public/tinvwl.class.php:
|
908 |
Â
msgid "Wishlist"
|
909 |
Â
msgstr ""
|
910 |
Â
|
@@ -1048,15 +1048,15 @@ msgstr ""
|
|
1048 |
Â
msgid "Out of stock"
|
1049 |
Â
msgstr ""
|
1050 |
Â
|
1051 |
-
#: public/addtowishlist.class.php:
|
1052 |
Â
msgid "Please, login to add products to Wishlist"
|
1053 |
Â
msgstr ""
|
1054 |
Â
|
1055 |
-
#: public/addtowishlist.class.php:
|
1056 |
Â
msgid "Login"
|
1057 |
Â
msgstr ""
|
1058 |
Â
|
1059 |
-
#: public/addtowishlist.class.php:
|
1060 |
Â
msgid "Something went wrong"
|
1061 |
Â
msgstr ""
|
1062 |
Â
|
@@ -1119,7 +1119,7 @@ msgstr[1] ""
|
|
1119 |
Â
msgid "Actions"
|
1120 |
Â
msgstr ""
|
1121 |
Â
|
1122 |
-
#: public/wishlist/buttons.class.php:359, templates/ti-wishlist.php:
|
1123 |
Â
msgid "Remove"
|
1124 |
Â
msgstr ""
|
1125 |
Â
|
@@ -1213,19 +1213,19 @@ msgstr ""
|
|
1213 |
Â
msgid "Product"
|
1214 |
Â
msgstr ""
|
1215 |
Â
|
1216 |
-
#: templates/ti-wishlist-user.php:
|
1217 |
Â
msgid "Unit Price"
|
1218 |
Â
msgstr ""
|
1219 |
Â
|
1220 |
-
#: templates/ti-wishlist-user.php:
|
1221 |
Â
msgid "Date Added"
|
1222 |
Â
msgstr ""
|
1223 |
Â
|
1224 |
-
#: templates/ti-wishlist-user.php:
|
1225 |
Â
msgid "Stock Status"
|
1226 |
Â
msgstr ""
|
1227 |
Â
|
1228 |
-
#: templates/ti-wishlist-user.php:
|
1229 |
Â
msgid "Select for bulk action"
|
1230 |
Â
msgstr ""
|
1231 |
Â
|
1 |
+
# Copyright (C) 2020 TI WooCommerce Wishlist Plugin - 1.20.0
|
2 |
+
# This file is distributed under the same license as the TI WooCommerce Wishlist Plugin - 1.20.0 package.
|
3 |
Â
msgid ""
|
4 |
Â
msgstr ""
|
5 |
+
"Project-Id-Version: TI WooCommerce Wishlist Plugin - 1.20.0\n"
|
6 |
Â
"MIME-Version: 1.0\n"
|
7 |
Â
"Content-Type: text/plain; charset=UTF-8\n"
|
8 |
Â
"Content-Transfer-Encoding: 8bit\n"
|
764 |
Â
msgid "Return wishlist products counter."
|
765 |
Â
msgstr ""
|
766 |
Â
|
767 |
+
#: includes/api/wishlist.class.php:102, includes/api/wishlist.class.php:165, includes/api/wishlist.class.php:215, includes/api/wishlist.class.php:267
|
768 |
Â
msgid "Invalid wishlist share key."
|
769 |
Â
msgstr ""
|
770 |
Â
|
772 |
Â
msgid "No wishlists found for this user."
|
773 |
Â
msgstr ""
|
774 |
Â
|
775 |
+
#: includes/api/wishlist.class.php:189, includes/api/wishlist.class.php:186
|
776 |
Â
msgid "Update wishlist data failed."
|
777 |
Â
msgstr ""
|
778 |
Â
|
779 |
+
#: includes/api/wishlist.class.php:271, includes/api/wishlist.class.php:293
|
780 |
Â
msgid "Add product to wishlist failed."
|
781 |
Â
msgstr ""
|
782 |
Â
|
783 |
+
#: includes/api/wishlist.class.php:323, includes/api/wishlist.class.php:334
|
784 |
Â
msgid "Product not found."
|
785 |
Â
msgstr ""
|
786 |
Â
|
787 |
+
#: includes/api/wishlist.class.php:337
|
788 |
Â
msgid "Product removed from a wishlist."
|
789 |
Â
msgstr ""
|
790 |
Â
|
904 |
Â
msgid "Page Setup"
|
905 |
Â
msgstr ""
|
906 |
Â
|
907 |
+
#: includes/wizard.class.php:289, includes/wizard.class.php:320, public/tinvwl.class.php:592
|
908 |
Â
msgid "Wishlist"
|
909 |
Â
msgstr ""
|
910 |
Â
|
1048 |
Â
msgid "Out of stock"
|
1049 |
Â
msgstr ""
|
1050 |
Â
|
1051 |
+
#: public/addtowishlist.class.php:182
|
1052 |
Â
msgid "Please, login to add products to Wishlist"
|
1053 |
Â
msgstr ""
|
1054 |
Â
|
1055 |
+
#: public/addtowishlist.class.php:184
|
1056 |
Â
msgid "Login"
|
1057 |
Â
msgstr ""
|
1058 |
Â
|
1059 |
+
#: public/addtowishlist.class.php:203
|
1060 |
Â
msgid "Something went wrong"
|
1061 |
Â
msgstr ""
|
1062 |
Â
|
1119 |
Â
msgid "Actions"
|
1120 |
Â
msgstr ""
|
1121 |
Â
|
1122 |
+
#: public/wishlist/buttons.class.php:359, templates/ti-wishlist.php:93
|
1123 |
Â
msgid "Remove"
|
1124 |
Â
msgstr ""
|
1125 |
Â
|
1213 |
Â
msgid "Product"
|
1214 |
Â
msgstr ""
|
1215 |
Â
|
1216 |
+
#: templates/ti-wishlist-user.php:39, templates/ti-wishlist.php:40
|
1217 |
Â
msgid "Unit Price"
|
1218 |
Â
msgstr ""
|
1219 |
Â
|
1220 |
+
#: templates/ti-wishlist-user.php:42, templates/ti-wishlist.php:43
|
1221 |
Â
msgid "Date Added"
|
1222 |
Â
msgstr ""
|
1223 |
Â
|
1224 |
+
#: templates/ti-wishlist-user.php:45, templates/ti-wishlist.php:46
|
1225 |
Â
msgid "Stock Status"
|
1226 |
Â
msgstr ""
|
1227 |
Â
|
1228 |
+
#: templates/ti-wishlist-user.php:84, templates/ti-wishlist.php:85
|
1229 |
Â
msgid "Select for bulk action"
|
1230 |
Â
msgstr ""
|
1231 |
Â
|
public/addtowishlist.class.php
CHANGED
@@ -156,6 +156,8 @@ class TInvWL_Public_AddToWishlist {
|
|
156 |
Â
'redirect' => FILTER_SANITIZE_URL,
|
157 |
Â
) );
|
158 |
Â
|
Â
|
|
Â
|
|
159 |
Â
$wlp = null;
|
160 |
Â
$wishlist = null;
|
161 |
Â
$data = array( 'msg' => array() );
|
@@ -318,7 +320,7 @@ class TInvWL_Public_AddToWishlist {
|
|
318 |
Â
$data['redirect'] = $data['wishlist_url'];
|
319 |
Â
}
|
320 |
Â
|
321 |
-
$product = wc_get_product( $post['product_id'] );
|
322 |
Â
if ( empty( $form ) ) {
|
323 |
Â
$form = array();
|
324 |
Â
}
|
@@ -328,15 +330,19 @@ class TInvWL_Public_AddToWishlist {
|
|
328 |
Â
$data['msg'] = array_unique( $data['msg'] );
|
329 |
Â
$data['msg'] = implode( '<br>', $data['msg'] );
|
330 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
331 |
Â
$msg_placeholders = apply_filters( 'tinvwl_addtowishlist_message_placeholders',
|
332 |
Â
array(
|
333 |
Â
'{product_name}' => is_callable( array(
|
334 |
-
$
|
335 |
Â
'get_name'
|
336 |
-
) ) ? $
|
337 |
-
'{product_sku}' => $
|
338 |
Â
),
|
339 |
-
$
|
340 |
Â
);
|
341 |
Â
|
342 |
Â
$find = array_keys( $msg_placeholders );
|
@@ -403,6 +409,9 @@ class TInvWL_Public_AddToWishlist {
|
|
403 |
Â
* @return array
|
404 |
Â
*/
|
405 |
Â
function user_wishlist( $product, $wlp = null ) {
|
Â
|
|
Â
|
|
Â
|
|
406 |
Â
$this->wishlist = array();
|
407 |
Â
$vproduct = in_array( ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->product_type : $product->get_type() ), array(
|
408 |
Â
'variable',
|
156 |
Â
'redirect' => FILTER_SANITIZE_URL,
|
157 |
Â
) );
|
158 |
Â
|
159 |
+
$post['original_product_id'] = $post['product_id'];
|
160 |
+
|
161 |
Â
$wlp = null;
|
162 |
Â
$wishlist = null;
|
163 |
Â
$data = array( 'msg' => array() );
|
320 |
Â
$data['redirect'] = $data['wishlist_url'];
|
321 |
Â
}
|
322 |
Â
|
323 |
+
$product = $original_product = wc_get_product( $post['product_id'] );
|
324 |
Â
if ( empty( $form ) ) {
|
325 |
Â
$form = array();
|
326 |
Â
}
|
330 |
Â
$data['msg'] = array_unique( $data['msg'] );
|
331 |
Â
$data['msg'] = implode( '<br>', $data['msg'] );
|
332 |
Â
|
333 |
+
if ( $post['product_id'] !== $post['original_product_id'] ) {
|
334 |
+
$original_product = wc_get_product( $post['original_product_id'] );
|
335 |
+
}
|
336 |
+
|
337 |
Â
$msg_placeholders = apply_filters( 'tinvwl_addtowishlist_message_placeholders',
|
338 |
Â
array(
|
339 |
Â
'{product_name}' => is_callable( array(
|
340 |
+
$original_product,
|
341 |
Â
'get_name'
|
342 |
+
) ) ? $original_product->get_name() : $original_product->get_title(),
|
343 |
+
'{product_sku}' => $original_product->get_sku(),
|
344 |
Â
),
|
345 |
+
$original_product
|
346 |
Â
);
|
347 |
Â
|
348 |
Â
$find = array_keys( $msg_placeholders );
|
409 |
Â
* @return array
|
410 |
Â
*/
|
411 |
Â
function user_wishlist( $product, $wlp = null ) {
|
412 |
+
|
413 |
+
$product = apply_filters( 'tinvwl_addtowishlist_check_product', $product );
|
414 |
+
|
415 |
Â
$this->wishlist = array();
|
416 |
Â
$vproduct = in_array( ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->product_type : $product->get_type() ), array(
|
417 |
Â
'variable',
|
public/tinvwl.class.php
CHANGED
@@ -490,6 +490,10 @@ class TInvWL_Public_TInvWL {
|
|
490 |
Â
'rest_root' => esc_url_raw( get_rest_url() ),
|
491 |
Â
);
|
492 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
493 |
Â
wp_localize_script( $this->_name, 'tinvwl_add_to_wishlist', $args );
|
494 |
Â
|
495 |
Â
if ( wp_script_is( 'woocommerce', 'enqueued' ) ) {
|
490 |
Â
'rest_root' => esc_url_raw( get_rest_url() ),
|
491 |
Â
);
|
492 |
Â
|
493 |
+
if ( function_exists( 'wpml_get_current_language' ) ) {
|
494 |
+
$args['wpml'] = wpml_get_current_language();
|
495 |
+
}
|
496 |
+
|
497 |
Â
wp_localize_script( $this->_name, 'tinvwl_add_to_wishlist', $args );
|
498 |
Â
|
499 |
Â
if ( wp_script_is( 'woocommerce', 'enqueued' ) ) {
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: templateinvaders
|
|
3 |
Â
Tags: woocommerce, wishlist, woocommerce wishlist, e-commerce, ecommerce
|
4 |
Â
Requires at least: 4.7
|
5 |
Â
Tested up to: 5.4
|
6 |
-
Stable tag: 1.
|
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,20 @@ Yes, you can! Join in on our [GitHub repository](https://github.com/TemplateInva
|
|
163 |
Â
|
164 |
Â
|
165 |
Â
== Changelog ==
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
166 |
Â
= 1.19.0 =
|
167 |
Â
*Release Date - 24 April 2020*
|
168 |
Â
|
3 |
Â
Tags: woocommerce, wishlist, woocommerce wishlist, e-commerce, ecommerce
|
4 |
Â
Requires at least: 4.7
|
5 |
Â
Tested up to: 5.4
|
6 |
+
Stable tag: 1.20.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.20.0 =
|
167 |
+
*Release Date - 12 May 2020*
|
168 |
+
|
169 |
+
* Added integration with [ELEX WooCommerce Catalog Mode](https://wordpress.org/plugins/elex-woocommerce-catalog-mode/) plugin
|
170 |
+
* Added integration with [WooCommerce Product Retailers](https://woocommerce.com/products/product-retailers/?aff=3955) plugin
|
171 |
+
* Added integration with [Braintree For WooCommerce](https://wordpress.org/plugins/woo-payment-gateway/) plugin
|
172 |
+
* Improved integration with WPML plugin
|
173 |
+
* Improved integration with [WooCommerce Multilingual](https://wordpress.org/plugins/woocommerce-multilingual/) plugin
|
174 |
+
* Improved security for Wishlist REST API
|
175 |
+
* Fixed 'add to wishlist' button shortcode issue when product variation ID does not count for saved products
|
176 |
+
* Fixed an issue when adding product variation that has an additional attribute(s) set as 'Any ...' to wishlist and from wishlist to cart
|
177 |
+
* Fixed an issue with duplicated buttons for out of stock products and Divi theme
|
178 |
+
* Fixed an issue with WP Rocket cache and WP REST API authorization for non-logged users
|
179 |
+
|
180 |
Â
= 1.19.0 =
|
181 |
Â
*Release Date - 24 April 2020*
|
182 |
Â
|
templates/ti-wishlist-user.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
Â
/**
|
3 |
Â
* The Template for displaying wishlist if a current user not an owner.
|
4 |
Â
*
|
5 |
-
* @version 1.
|
6 |
Â
* @package TInvWishlist\Template
|
7 |
Â
*/
|
8 |
Â
|
@@ -27,13 +27,14 @@ wp_enqueue_script( 'tinvwl' );
|
|
27 |
Â
<tr>
|
28 |
Â
<?php if ( isset( $wishlist_table['colm_checkbox'] ) && $wishlist_table['colm_checkbox'] ) { ?>
|
29 |
Â
<th class="product-cb"><input type="checkbox" class="global-cb"
|
30 |
-
|
31 |
Â
</th>
|
32 |
Â
<?php } ?>
|
33 |
Â
<th class="product-thumbnail"> </th>
|
34 |
Â
<th class="product-name"><span
|
35 |
-
|
36 |
-
|
Â
|
|
37 |
Â
<?php if ( isset( $wishlist_table_row['colm_price'] ) && $wishlist_table_row['colm_price'] ) { ?>
|
38 |
Â
<th class="product-price"><?php esc_html_e( 'Unit Price', 'ti-woocommerce-wishlist' ); ?></th>
|
39 |
Â
<?php } ?>
|
@@ -80,7 +81,7 @@ wp_enqueue_script( 'tinvwl' );
|
|
80 |
Â
<td class="product-cb">
|
81 |
Â
<?php
|
82 |
Â
echo apply_filters( 'tinvwl_wishlist_item_cb', sprintf( // WPCS: xss ok.
|
83 |
-
|
84 |
Â
), $wl_product, $product );
|
85 |
Â
?>
|
86 |
Â
</td>
|
@@ -100,13 +101,13 @@ wp_enqueue_script( 'tinvwl' );
|
|
100 |
Â
<?php
|
101 |
Â
if ( ! $product->is_visible() ) {
|
102 |
Â
echo apply_filters( 'tinvwl_wishlist_item_name', is_callable( array(
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
Â
} else {
|
107 |
Â
echo apply_filters( 'tinvwl_wishlist_item_name', sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), is_callable( array(
|
108 |
-
|
109 |
-
|
110 |
Â
) ) ? $product->get_name() : $product->get_title() ), $wl_product, $product ); // WPCS: xss ok.
|
111 |
Â
}
|
112 |
Â
|
@@ -124,7 +125,7 @@ wp_enqueue_script( 'tinvwl' );
|
|
124 |
Â
<td class="product-date">
|
125 |
Â
<?php
|
126 |
Â
echo apply_filters( 'tinvwl_wishlist_item_date', sprintf( // WPCS: xss ok.
|
127 |
-
|
128 |
Â
), $wl_product, $product );
|
129 |
Â
?>
|
130 |
Â
</td>
|
@@ -151,13 +152,15 @@ wp_enqueue_script( 'tinvwl' );
|
|
151 |
Â
if ( apply_filters( 'tinvwl_wishlist_item_action_add_to_cart', $wishlist_table_row['add_to_cart'], $wl_product, $product ) ) {
|
152 |
Â
?>
|
153 |
Â
<button class="button alt" name="tinvwl-add-to-cart"
|
154 |
-
|
155 |
-
|
156 |
Â
<i
|
157 |
-
|
158 |
-
|
159 |
Â
</button>
|
160 |
-
<?php }
|
Â
|
|
Â
|
|
161 |
Â
</td>
|
162 |
Â
<?php } ?>
|
163 |
Â
</tr>
|
2 |
Â
/**
|
3 |
Â
* The Template for displaying wishlist if a current user not an owner.
|
4 |
Â
*
|
5 |
+
* @version 1.20.0
|
6 |
Â
* @package TInvWishlist\Template
|
7 |
Â
*/
|
8 |
Â
|
27 |
Â
<tr>
|
28 |
Â
<?php if ( isset( $wishlist_table['colm_checkbox'] ) && $wishlist_table['colm_checkbox'] ) { ?>
|
29 |
Â
<th class="product-cb"><input type="checkbox" class="global-cb"
|
30 |
+
title="<?php _e( 'Select all for bulk action', 'ti-woocommerce-wishlist' ) ?>">
|
31 |
Â
</th>
|
32 |
Â
<?php } ?>
|
33 |
Â
<th class="product-thumbnail"> </th>
|
34 |
Â
<th class="product-name"><span
|
35 |
+
class="tinvwl-full"><?php esc_html_e( 'Product Name', 'ti-woocommerce-wishlist' ); ?></span><span
|
36 |
+
class="tinvwl-mobile"><?php esc_html_e( 'Product', 'ti-woocommerce-wishlist' ); ?></span>
|
37 |
+
</th>
|
38 |
Â
<?php if ( isset( $wishlist_table_row['colm_price'] ) && $wishlist_table_row['colm_price'] ) { ?>
|
39 |
Â
<th class="product-price"><?php esc_html_e( 'Unit Price', 'ti-woocommerce-wishlist' ); ?></th>
|
40 |
Â
<?php } ?>
|
81 |
Â
<td class="product-cb">
|
82 |
Â
<?php
|
83 |
Â
echo apply_filters( 'tinvwl_wishlist_item_cb', sprintf( // WPCS: xss ok.
|
84 |
+
'<input type="checkbox" name="wishlist_pr[]" value="%d" title="%s">', esc_attr( $wl_product['ID'] ), __( 'Select for bulk action', 'ti-woocommerce-wishlist' )
|
85 |
Â
), $wl_product, $product );
|
86 |
Â
?>
|
87 |
Â
</td>
|
101 |
Â
<?php
|
102 |
Â
if ( ! $product->is_visible() ) {
|
103 |
Â
echo apply_filters( 'tinvwl_wishlist_item_name', is_callable( array(
|
104 |
+
$product,
|
105 |
+
'get_name'
|
106 |
+
) ) ? $product->get_name() : $product->get_title(), $wl_product, $product ) . ' '; // WPCS: xss ok.
|
107 |
Â
} else {
|
108 |
Â
echo apply_filters( 'tinvwl_wishlist_item_name', sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), is_callable( array(
|
109 |
+
$product,
|
110 |
+
'get_name'
|
111 |
Â
) ) ? $product->get_name() : $product->get_title() ), $wl_product, $product ); // WPCS: xss ok.
|
112 |
Â
}
|
113 |
Â
|
125 |
Â
<td class="product-date">
|
126 |
Â
<?php
|
127 |
Â
echo apply_filters( 'tinvwl_wishlist_item_date', sprintf( // WPCS: xss ok.
|
128 |
+
'<time class="entry-date" datetime="%1$s">%2$s</time>', $wl_product['date'], mysql2date( get_option( 'date_format' ), $wl_product['date'] )
|
129 |
Â
), $wl_product, $product );
|
130 |
Â
?>
|
131 |
Â
</td>
|
152 |
Â
if ( apply_filters( 'tinvwl_wishlist_item_action_add_to_cart', $wishlist_table_row['add_to_cart'], $wl_product, $product ) ) {
|
153 |
Â
?>
|
154 |
Â
<button class="button alt" name="tinvwl-add-to-cart"
|
155 |
+
value="<?php echo esc_attr( $wl_product['ID'] ); ?>"
|
156 |
+
title="<?php echo esc_html( apply_filters( 'tinvwl_wishlist_item_add_to_cart', $wishlist_table_row['text_add_to_cart'], $wl_product, $product ) ); ?>">
|
157 |
Â
<i
|
158 |
+
class="ftinvwl ftinvwl-shopping-cart"></i><span
|
159 |
+
class="tinvwl-txt"><?php echo esc_html( apply_filters( 'tinvwl_wishlist_item_add_to_cart', $wishlist_table_row['text_add_to_cart'], $wl_product, $product ) ); ?></span>
|
160 |
Â
</button>
|
161 |
+
<?php } elseif ( apply_filters( 'tinvwl_wishlist_item_action_default_loop_button', $wishlist_table_row['add_to_cart'], $wl_product, $product ) ) {
|
162 |
+
woocommerce_template_loop_add_to_cart();
|
163 |
+
} ?>
|
164 |
Â
</td>
|
165 |
Â
<?php } ?>
|
166 |
Â
</tr>
|
templates/ti-wishlist.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
Â
/**
|
3 |
Â
* The Template for displaying wishlist if a current user is owner.
|
4 |
Â
*
|
5 |
-
* @version 1.
|
6 |
Â
* @package TInvWishlist\Template
|
7 |
Â
*/
|
8 |
Â
|
@@ -27,14 +27,15 @@ wp_enqueue_script( 'tinvwl' );
|
|
27 |
Â
<tr>
|
28 |
Â
<?php if ( isset( $wishlist_table['colm_checkbox'] ) && $wishlist_table['colm_checkbox'] ) { ?>
|
29 |
Â
<th class="product-cb"><input type="checkbox" class="global-cb"
|
30 |
-
|
31 |
Â
</th>
|
32 |
Â
<?php } ?>
|
33 |
Â
<th class="product-remove"></th>
|
34 |
Â
<th class="product-thumbnail"> </th>
|
35 |
Â
<th class="product-name"><span
|
36 |
-
|
37 |
-
|
Â
|
|
38 |
Â
<?php if ( isset( $wishlist_table_row['colm_price'] ) && $wishlist_table_row['colm_price'] ) { ?>
|
39 |
Â
<th class="product-price"><?php esc_html_e( 'Unit Price', 'ti-woocommerce-wishlist' ); ?></th>
|
40 |
Â
<?php } ?>
|
@@ -81,16 +82,16 @@ wp_enqueue_script( 'tinvwl' );
|
|
81 |
Â
<td class="product-cb">
|
82 |
Â
<?php
|
83 |
Â
echo apply_filters( 'tinvwl_wishlist_item_cb', sprintf( // WPCS: xss ok.
|
84 |
-
|
85 |
Â
), $wl_product, $product );
|
86 |
Â
?>
|
87 |
Â
</td>
|
88 |
Â
<?php } ?>
|
89 |
Â
<td class="product-remove">
|
90 |
Â
<button type="submit" name="tinvwl-remove"
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
Â
</button>
|
95 |
Â
</td>
|
96 |
Â
<td class="product-thumbnail">
|
@@ -108,13 +109,13 @@ wp_enqueue_script( 'tinvwl' );
|
|
108 |
Â
<?php
|
109 |
Â
if ( ! $product->is_visible() ) {
|
110 |
Â
echo apply_filters( 'tinvwl_wishlist_item_name', is_callable( array(
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
Â
} else {
|
115 |
Â
echo apply_filters( 'tinvwl_wishlist_item_name', sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), is_callable( array(
|
116 |
-
|
117 |
-
|
118 |
Â
) ) ? $product->get_name() : $product->get_title() ), $wl_product, $product ); // WPCS: xss ok.
|
119 |
Â
}
|
120 |
Â
|
@@ -132,7 +133,7 @@ wp_enqueue_script( 'tinvwl' );
|
|
132 |
Â
<td class="product-date">
|
133 |
Â
<?php
|
134 |
Â
echo apply_filters( 'tinvwl_wishlist_item_date', sprintf( // WPCS: xss ok.
|
135 |
-
|
136 |
Â
), $wl_product, $product );
|
137 |
Â
?>
|
138 |
Â
</td>
|
@@ -159,13 +160,15 @@ wp_enqueue_script( 'tinvwl' );
|
|
159 |
Â
if ( apply_filters( 'tinvwl_wishlist_item_action_add_to_cart', $wishlist_table_row['add_to_cart'], $wl_product, $product ) ) {
|
160 |
Â
?>
|
161 |
Â
<button class="button alt" name="tinvwl-add-to-cart"
|
162 |
-
|
163 |
-
|
164 |
Â
<i
|
165 |
-
|
166 |
-
|
167 |
Â
</button>
|
168 |
-
<?php }
|
Â
|
|
Â
|
|
169 |
Â
</td>
|
170 |
Â
<?php } ?>
|
171 |
Â
</tr>
|
2 |
Â
/**
|
3 |
Â
* The Template for displaying wishlist if a current user is owner.
|
4 |
Â
*
|
5 |
+
* @version 1.20.0
|
6 |
Â
* @package TInvWishlist\Template
|
7 |
Â
*/
|
8 |
Â
|
27 |
Â
<tr>
|
28 |
Â
<?php if ( isset( $wishlist_table['colm_checkbox'] ) && $wishlist_table['colm_checkbox'] ) { ?>
|
29 |
Â
<th class="product-cb"><input type="checkbox" class="global-cb"
|
30 |
+
title="<?php _e( 'Select all for bulk action', 'ti-woocommerce-wishlist' ) ?>">
|
31 |
Â
</th>
|
32 |
Â
<?php } ?>
|
33 |
Â
<th class="product-remove"></th>
|
34 |
Â
<th class="product-thumbnail"> </th>
|
35 |
Â
<th class="product-name"><span
|
36 |
+
class="tinvwl-full"><?php esc_html_e( 'Product Name', 'ti-woocommerce-wishlist' ); ?></span><span
|
37 |
+
class="tinvwl-mobile"><?php esc_html_e( 'Product', 'ti-woocommerce-wishlist' ); ?></span>
|
38 |
+
</th>
|
39 |
Â
<?php if ( isset( $wishlist_table_row['colm_price'] ) && $wishlist_table_row['colm_price'] ) { ?>
|
40 |
Â
<th class="product-price"><?php esc_html_e( 'Unit Price', 'ti-woocommerce-wishlist' ); ?></th>
|
41 |
Â
<?php } ?>
|
82 |
Â
<td class="product-cb">
|
83 |
Â
<?php
|
84 |
Â
echo apply_filters( 'tinvwl_wishlist_item_cb', sprintf( // WPCS: xss ok.
|
85 |
+
'<input type="checkbox" name="wishlist_pr[]" value="%d" title="%s">', esc_attr( $wl_product['ID'] ), __( 'Select for bulk action', 'ti-woocommerce-wishlist' )
|
86 |
Â
), $wl_product, $product );
|
87 |
Â
?>
|
88 |
Â
</td>
|
89 |
Â
<?php } ?>
|
90 |
Â
<td class="product-remove">
|
91 |
Â
<button type="submit" name="tinvwl-remove"
|
92 |
+
value="<?php echo esc_attr( $wl_product['ID'] ); ?>"
|
93 |
+
title="<?php _e( 'Remove', 'ti-woocommerce-wishlist' ) ?>"><i
|
94 |
+
class="ftinvwl ftinvwl-times"></i>
|
95 |
Â
</button>
|
96 |
Â
</td>
|
97 |
Â
<td class="product-thumbnail">
|
109 |
Â
<?php
|
110 |
Â
if ( ! $product->is_visible() ) {
|
111 |
Â
echo apply_filters( 'tinvwl_wishlist_item_name', is_callable( array(
|
112 |
+
$product,
|
113 |
+
'get_name'
|
114 |
+
) ) ? $product->get_name() : $product->get_title(), $wl_product, $product ) . ' '; // WPCS: xss ok.
|
115 |
Â
} else {
|
116 |
Â
echo apply_filters( 'tinvwl_wishlist_item_name', sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), is_callable( array(
|
117 |
+
$product,
|
118 |
+
'get_name'
|
119 |
Â
) ) ? $product->get_name() : $product->get_title() ), $wl_product, $product ); // WPCS: xss ok.
|
120 |
Â
}
|
121 |
Â
|
133 |
Â
<td class="product-date">
|
134 |
Â
<?php
|
135 |
Â
echo apply_filters( 'tinvwl_wishlist_item_date', sprintf( // WPCS: xss ok.
|
136 |
+
'<time class="entry-date" datetime="%1$s">%2$s</time>', $wl_product['date'], mysql2date( get_option( 'date_format' ), $wl_product['date'] )
|
137 |
Â
), $wl_product, $product );
|
138 |
Â
?>
|
139 |
Â
</td>
|
160 |
Â
if ( apply_filters( 'tinvwl_wishlist_item_action_add_to_cart', $wishlist_table_row['add_to_cart'], $wl_product, $product ) ) {
|
161 |
Â
?>
|
162 |
Â
<button class="button alt" name="tinvwl-add-to-cart"
|
163 |
+
value="<?php echo esc_attr( $wl_product['ID'] ); ?>"
|
164 |
+
title="<?php echo esc_html( apply_filters( 'tinvwl_wishlist_item_add_to_cart', $wishlist_table_row['text_add_to_cart'], $wl_product, $product ) ); ?>">
|
165 |
Â
<i
|
166 |
+
class="ftinvwl ftinvwl-shopping-cart"></i><span
|
167 |
+
class="tinvwl-txt"><?php echo esc_html( apply_filters( 'tinvwl_wishlist_item_add_to_cart', $wishlist_table_row['text_add_to_cart'], $wl_product, $product ) ); ?></span>
|
168 |
Â
</button>
|
169 |
+
<?php } elseif ( apply_filters( 'tinvwl_wishlist_item_action_default_loop_button', $wishlist_table_row['add_to_cart'], $wl_product, $product ) ) {
|
170 |
+
woocommerce_template_loop_add_to_cart();
|
171 |
+
} ?>
|
172 |
Â
</td>
|
173 |
Â
<?php } ?>
|
174 |
Â
</tr>
|
ti-woocommerce-wishlist.php
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
Â
<?php
|
2 |
Â
/**
|
3 |
-
* TI WooCommerce Wishlist
|
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.4
|
10 |
Â
* WC requires at least: 2.6
|
11 |
-
* WC tested up to: 4.0
|
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' ) ) {
|
1 |
Â
<?php
|
2 |
Â
/**
|
3 |
+
* TI WooCommerce Wishlist.
|
4 |
+
* Plugin Name: TI WooCommerce Wishlist
|
5 |
Â
* Plugin URI: https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
6 |
Â
* Description: Wishlist functionality for your WooCommerce store.
|
7 |
+
* Version: 1.20.0
|
8 |
Â
* Requires at least: 4.7
|
9 |
Â
* Tested up to: 5.4
|
10 |
Â
* WC requires at least: 2.6
|
11 |
+
* WC tested up to: 4.1.0
|
12 |
Â
* Author: TemplateInvaders
|
13 |
Â
* Author URI: https://templateinvaders.com/
|
14 |
Â
* License: GPL-2.0+
|
41 |
Â
}
|
42 |
Â
|
43 |
Â
if ( ! defined( 'TINVWL_FVERSION' ) ) {
|
44 |
+
define( 'TINVWL_FVERSION', '1.20.0' );
|
45 |
Â
}
|
46 |
Â
|
47 |
Â
if ( ! defined( 'TINVWL_LOAD_FREE' ) ) {
|
tinv-wishlists-function.php
CHANGED
@@ -1,897 +1,904 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Basic function for plugin
|
4 |
-
*
|
5 |
-
* @since 1.0.0
|
6 |
-
* @package TInvWishlist
|
7 |
-
*/
|
8 |
-
|
9 |
-
// If this file is called directly, abort.
|
10 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
11 |
-
die;
|
12 |
-
}
|
13 |
-
|
14 |
-
|
15 |
-
if ( ! function_exists( 'tinv_get_option' ) ) {
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Extract options from database or default array settings.
|
19 |
-
*
|
20 |
-
* @param string $category Name category settings.
|
21 |
-
* @param string $option Name paremetr. If is empty string, then function return array category settings.
|
22 |
-
*
|
23 |
-
* @return mixed
|
24 |
-
*/
|
25 |
-
function tinv_get_option( $category, $option = '' ) {
|
26 |
-
$prefix = TINVWL_PREFIX . '-';
|
27 |
-
$values = get_option( $prefix . $category, array() );
|
28 |
-
if ( empty( $values ) ) {
|
29 |
-
$values = tinv_get_option_defaults( $category );
|
30 |
-
}
|
31 |
-
if ( empty( $option ) ) {
|
32 |
-
return $values;
|
33 |
-
} else {
|
34 |
-
if ( array_key_exists( $option, (array) $values ) ) {
|
35 |
-
return $values[ $option ];
|
36 |
-
} else {
|
37 |
-
$values = tinv_get_option_defaults( $category );
|
38 |
-
if ( array_key_exists( $option, (array) $values ) ) {
|
39 |
-
return $values[ $option ];
|
40 |
-
}
|
41 |
-
}
|
42 |
-
}
|
43 |
-
|
44 |
-
return null;
|
45 |
-
}
|
46 |
-
}
|
47 |
-
|
48 |
-
if ( ! function_exists( 'tinv_get_option_admin' ) ) {
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Extract options from database or default array settings.
|
52 |
-
*
|
53 |
-
* @param string $category Name category settings.
|
54 |
-
* @param string $option Name paremetr. If is empty string, then function return array category settings.
|
55 |
-
*
|
56 |
-
* @return mixed
|
57 |
-
*/
|
58 |
-
function tinv_get_option_admin( $category, $option = '' ) {
|
59 |
-
$prefix = TINVWL_PREFIX . '-';
|
60 |
-
$values = get_option( $prefix . $category, array() );
|
61 |
-
if ( empty( $values ) ) {
|
62 |
-
$values = array();
|
63 |
-
}
|
64 |
-
if ( empty( $option ) ) {
|
65 |
-
return $values;
|
66 |
-
} elseif ( array_key_exists( $option, $values ) ) {
|
67 |
-
return $values[ $option ];
|
68 |
-
}
|
69 |
-
|
70 |
-
return null;
|
71 |
-
}
|
72 |
-
}
|
73 |
-
|
74 |
-
if ( ! function_exists( 'tinv_style' ) ) {
|
75 |
-
|
76 |
-
/**
|
77 |
-
* Get style for custom style
|
78 |
-
*
|
79 |
-
* @param string $selector Selector style.
|
80 |
-
* @param string $element Attribute name.
|
81 |
-
*
|
82 |
-
* @return string
|
83 |
-
*/
|
84 |
-
function tinv_style( $selector = '', $element = '' ) {
|
85 |
-
$key = md5( $selector . '||' . $element );
|
86 |
-
$values = get_option( TINVWL_PREFIX . '-style_options', array() );
|
87 |
-
if ( empty( $values ) ) {
|
88 |
-
return '';
|
89 |
-
}
|
90 |
-
if ( array_key_exists( $key, $values ) ) {
|
91 |
-
return $values[ $key ];
|
92 |
-
}
|
93 |
-
|
94 |
-
return '';
|
95 |
-
}
|
96 |
-
}
|
97 |
-
|
98 |
-
if ( ! function_exists( 'tinv_update_option' ) ) {
|
99 |
-
|
100 |
-
/**
|
101 |
-
* Update options in database.
|
102 |
-
*
|
103 |
-
* @param string $category Name category settings.
|
104 |
-
* @param string $option Name paremetr. If is empty string, then function update array category settings.
|
105 |
-
* @param mixed $value Value option.
|
106 |
-
*
|
107 |
-
* @return boolean
|
108 |
-
*/
|
109 |
-
function tinv_update_option( $category, $option = '', $value = false ) {
|
110 |
-
$prefix = TINVWL_PREFIX . '-';
|
111 |
-
if ( empty( $option ) ) {
|
112 |
-
if ( is_array( $value ) ) {
|
113 |
-
update_option( $prefix . $category, $value );
|
114 |
-
|
115 |
-
return true;
|
116 |
-
}
|
117 |
-
} else {
|
118 |
-
$values = get_option( $prefix . $category, array() );
|
119 |
-
|
120 |
-
$values[ $option ] = $value;
|
121 |
-
update_option( $prefix . $category, $values );
|
122 |
-
|
123 |
-
return true;
|
124 |
-
}
|
125 |
-
|
126 |
-
return false;
|
127 |
-
}
|
128 |
-
}
|
129 |
-
|
130 |
-
if ( ! function_exists( 'tinv_wishlist_template' ) ) {
|
131 |
-
|
132 |
-
/**
|
133 |
-
* The function overwrites the method output templates woocommerce
|
134 |
-
*
|
135 |
-
* @param string $template_name Name file template.
|
136 |
-
* @param array $args Array variable in template.
|
137 |
-
* @param string $template_path Customization path.
|
138 |
-
*/
|
139 |
-
function tinv_wishlist_template( $template_name, $args = array(), $template_path = '' ) {
|
140 |
-
if ( function_exists( 'wc_get_template' ) ) {
|
141 |
-
wc_get_template( $template_name, $args, $template_path );
|
142 |
-
} else {
|
143 |
-
woocommerce_get_template( $template_name, $args, $template_path );
|
144 |
-
}
|
145 |
-
}
|
146 |
-
}
|
147 |
-
|
148 |
-
if ( ! function_exists( 'tinv_wishlist_locate_template' ) ) {
|
149 |
-
|
150 |
-
/**
|
151 |
-
* Overwrites path for email and other template
|
152 |
-
*
|
153 |
-
* @param string $template_name Requered Template file.
|
154 |
-
* @param string $template_path Template path.
|
155 |
-
* @param string $default_path Template default path.
|
156 |
-
*
|
157 |
-
* @return mixed
|
158 |
-
*/
|
159 |
-
function tinv_wishlist_locate_template( $template_name, $template_path = '', $default_path = '' ) {
|
160 |
-
$prefix = 'ti-';
|
161 |
-
|
162 |
-
if ( substr( basename( $template_name ), 0, strlen( $prefix ) ) !== $prefix ) {
|
163 |
-
return;
|
164 |
-
}
|
165 |
-
|
166 |
-
if ( ! $template_path ) {
|
167 |
-
$template_path = WC()->template_path();
|
168 |
-
}
|
169 |
-
|
170 |
-
if ( ! $default_path ) {
|
171 |
-
$default_path = TINVWL_PATH . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR;
|
172 |
-
}
|
173 |
-
|
174 |
-
// Look within passed path within the theme - this is priority.
|
175 |
-
$template = locate_template( array(
|
176 |
-
trailingslashit( $template_path ) . $template_name,
|
177 |
-
$template_name,
|
178 |
-
) );
|
179 |
-
|
180 |
-
// Get default template.
|
181 |
-
if ( ! $template && file_exists( $default_path . $template_name ) ) {
|
182 |
-
$template = $default_path . $template_name;
|
183 |
-
}
|
184 |
-
|
185 |
-
// Return what we found.
|
186 |
-
return apply_filters( 'tinvwl_locate_template', $template, $template_name, $template_path );
|
187 |
-
}
|
188 |
-
} // End if().
|
189 |
-
|
190 |
-
if ( ! function_exists( 'tinv_wishlist_template_html' ) ) {
|
191 |
-
|
192 |
-
/**
|
193 |
-
* The function overwrites the method return templates woocommerce
|
194 |
-
*
|
195 |
-
* @param string $template_name Name file template.
|
196 |
-
* @param array $args Array variable in template.
|
197 |
-
* @param string $template_path Customization path.
|
198 |
-
*
|
199 |
-
* @return string
|
200 |
-
*/
|
201 |
-
function tinv_wishlist_template_html( $template_name, $args = array(), $template_path = '' ) {
|
202 |
-
ob_start();
|
203 |
-
tinv_wishlist_template( $template_name, $args, $template_path );
|
204 |
-
|
205 |
-
return ob_get_clean();
|
206 |
-
}
|
207 |
-
}
|
208 |
-
|
209 |
-
if ( ! function_exists( 'tinv_wishlist_get_item_data' ) ) {
|
210 |
-
|
211 |
-
/**
|
212 |
-
* Extract meta attributes for product
|
213 |
-
*
|
214 |
-
* @param object $product Object selected product.
|
215 |
-
* @param array $wl_product Wishlist selected product.
|
216 |
-
* @param boolean $flat Return text or template.
|
217 |
-
*
|
218 |
-
* @return string
|
219 |
-
*/
|
220 |
-
function tinv_wishlist_get_item_data( $product, $wl_product = array(), $flat = false ) {
|
221 |
-
$item_data = array();
|
222 |
-
$variation_id = version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->variation_id : ( $product->is_type( 'variation' ) ? $product->get_id() : 0 );
|
223 |
-
$variation_data = version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->variation_data : ( $product->is_type( 'variation' ) ? wc_get_product_variation_attributes( $product->get_id() ) : array() );
|
224 |
-
if ( ! empty( $variation_id ) && is_array( $variation_data ) && is_array( $wl_product ) ) {
|
225 |
-
foreach ( $variation_data as $name => $value ) {
|
226 |
-
if ( '' === $value ) {
|
227 |
-
// Could be any value that saved to a custom meta.
|
228 |
-
if ( array_key_exists( 'meta', $wl_product ) && array_key_exists( $name, $wl_product['meta'] ) ) {
|
229 |
-
$value = $wl_product['meta'][ $name ];
|
230 |
-
} else {
|
231 |
-
continue;
|
232 |
-
}
|
233 |
-
}
|
234 |
-
|
235 |
-
$taxonomy = wc_attribute_taxonomy_name( str_replace( 'attribute_pa_', '', urldecode( $name ) ) );
|
236 |
-
|
237 |
-
// If this is a term slug, get the term's nice name.
|
238 |
-
if ( taxonomy_exists( $taxonomy ) ) {
|
239 |
-
$term = get_term_by( 'slug', $value, $taxonomy ); // @codingStandardsIgnoreLine WordPress.VIP.RestrictedFunctions.get_term_by
|
240 |
-
if ( ! is_wp_error( $term ) && $term && $term->name ) {
|
241 |
-
$value = $term->name;
|
242 |
-
}
|
243 |
-
$label = wc_attribute_label( $taxonomy );
|
244 |
-
|
245 |
-
// If this is a custom option slug, get the options name.
|
246 |
-
} else {
|
247 |
-
$value = apply_filters( 'woocommerce_variation_option_name', $value );
|
248 |
-
$product_attributes = $product->get_attributes();
|
249 |
-
$_name = str_replace( 'attribute_', '', $name );
|
250 |
-
if ( isset( $product_attributes[ $_name ] ) ) {
|
251 |
-
$_name = version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_attributes[ $_name ]['name'] : $_name;
|
252 |
-
$label = wc_attribute_label( $_name, $product );
|
253 |
-
} else {
|
254 |
-
$label = $name;
|
255 |
-
}
|
256 |
-
}
|
257 |
-
if ( '' === $value ) {
|
258 |
-
continue;
|
259 |
-
}
|
260 |
-
$item_data[] = array(
|
261 |
-
'key' => $label,
|
262 |
-
'value' => $value,
|
263 |
-
);
|
264 |
-
} // End foreach().
|
265 |
-
} // End if().
|
266 |
-
|
267 |
-
// Filter item data to allow 3rd parties to add more to the array.
|
268 |
-
$item_data = apply_filters( 'tinvwl_wishlist_get_item_data', $item_data, $product );
|
269 |
-
|
270 |
-
// Format item data ready to display.
|
271 |
-
foreach ( $item_data as $key => $data ) {
|
272 |
-
// Set hidden to true to not display meta on cart.
|
273 |
-
if ( ! empty( $data['hidden'] ) ) {
|
274 |
-
unset( $item_data[ $key ] );
|
275 |
-
continue;
|
276 |
-
}
|
277 |
-
$item_data[ $key ]['key'] = ! empty( $data['key'] ) ? $data['key'] : $data['name'];
|
278 |
-
$item_data[ $key ]['display'] = ! empty( $data['display'] ) ? $data['display'] : $data['value'];
|
279 |
-
}
|
280 |
-
|
281 |
-
// Output flat or in list format.
|
282 |
-
if ( 0 < count( $item_data ) ) {
|
283 |
-
ob_start();
|
284 |
-
if ( $flat ) {
|
285 |
-
foreach ( $item_data as $data ) {
|
286 |
-
echo esc_html( $data['key'] ) . ': ' . wp_kses_post( $data['display'] ) . '<br>';
|
287 |
-
}
|
288 |
-
} else {
|
289 |
-
tinv_wishlist_template( 'ti-wishlist-item-data.php', array( 'item_data' => $item_data ) );
|
290 |
-
}
|
291 |
-
|
292 |
-
return ob_get_clean();
|
293 |
-
}
|
294 |
-
|
295 |
-
return '';
|
296 |
-
}
|
297 |
-
} // End if().
|
298 |
-
|
299 |
-
if ( ! function_exists( 'tinv_wishlist_get' ) ) {
|
300 |
-
|
301 |
-
/**
|
302 |
-
* Return Wishlist by id or share key
|
303 |
-
*
|
304 |
-
* @param mixed $id Integer wishlist ID, or Share Key wishlist.
|
305 |
-
* @param boolean $toend Switches to the extract the default or guest wishlist.
|
306 |
-
*
|
307 |
-
* @return array
|
308 |
-
*/
|
309 |
-
function tinv_wishlist_get( $id = '', $toend = true ) {
|
310 |
-
$wl = new TInvWL_Wishlist();
|
311 |
-
$wishlist = null;
|
312 |
-
if ( empty( $id ) ) {
|
313 |
-
$id = get_query_var( 'tinvwlID', null );
|
314 |
-
}
|
315 |
-
|
316 |
-
if ( ! empty( $id ) ) {
|
317 |
-
if ( is_integer( $id ) ) {
|
318 |
-
$wishlist = $wl->get_by_id( $id );
|
319 |
-
}
|
320 |
-
if ( empty( $wishlist ) ) {
|
321 |
-
$wishlist = $wl->get_by_share_key( $id );
|
322 |
-
}
|
323 |
-
|
324 |
-
if ( is_array( $wishlist ) ) {
|
325 |
-
$wishlist['is_owner'] = false;
|
326 |
-
if ( is_user_logged_in() ) {
|
327 |
-
$wishlist['is_owner'] = get_current_user_id() == $wishlist['author']; // WPCS: loose comparison ok.
|
328 |
-
} else {
|
329 |
-
$wishlist['is_owner'] = $wl->get_sharekey() === $wishlist['share_key']; // WPCS: loose comparison ok.
|
330 |
-
}
|
331 |
-
}
|
332 |
-
} elseif ( is_user_logged_in() && $toend ) {
|
333 |
-
$wishlist = $wl->add_user_default();
|
334 |
-
|
335 |
-
$wishlist['is_owner'] = true;
|
336 |
-
} elseif ( $toend ) {
|
337 |
-
$wishlist = $wl->get_by_sharekey_default();
|
338 |
-
if ( ! empty( $wishlist ) ) {
|
339 |
-
$wishlist = array_shift( $wishlist );
|
340 |
-
$wishlist['is_owner'] = $wl->get_sharekey() === $wishlist['share_key'];
|
341 |
-
}
|
342 |
-
}
|
343 |
-
|
344 |
-
return $wishlist;
|
345 |
-
}
|
346 |
-
} // End if().
|
347 |
-
|
348 |
-
if ( ! function_exists( 'tinv_url_wishlist_default' ) ) {
|
349 |
-
|
350 |
-
/**
|
351 |
-
* Return the default wishlist url
|
352 |
-
*
|
353 |
-
* @return string
|
354 |
-
*/
|
355 |
-
function tinv_url_wishlist_default() {
|
356 |
-
$page = apply_filters( 'wpml_object_id', tinv_get_option( 'page', 'wishlist' ), 'page', true ); // @codingStandardsIgnoreLine WordPress.Variables.GlobalVariables.OverrideProhibited
|
357 |
-
if ( empty( $page ) ) {
|
358 |
-
return '';
|
359 |
-
}
|
360 |
-
$link = get_permalink( $page );
|
361 |
-
|
362 |
-
return $link;
|
363 |
-
}
|
364 |
-
}
|
365 |
-
|
366 |
-
if ( ! function_exists( 'tinv_url_wishlist_by_key' ) ) {
|
367 |
-
|
368 |
-
/**
|
369 |
-
* Return the wishlist url by share key
|
370 |
-
*
|
371 |
-
* @param string $share_key Share Key wishlist.
|
372 |
-
* @param integer $paged Page.
|
373 |
-
*
|
374 |
-
* @return string
|
375 |
-
*/
|
376 |
-
function tinv_url_wishlist_by_key( $share_key, $paged = 1 ) {
|
377 |
-
$paged = absint( $paged );
|
378 |
-
$paged = 1 < $paged ? $paged : 1;
|
379 |
-
$link = tinv_url_wishlist_default();
|
380 |
-
if ( empty( $link ) ) {
|
381 |
-
return $link;
|
382 |
-
}
|
383 |
-
|
384 |
-
if ( 1 < $paged ) {
|
385 |
-
$link = add_query_arg( 'wl_paged', $paged, $link );
|
386 |
-
}
|
387 |
-
|
388 |
-
if ( $share_key ) {
|
389 |
-
if ( get_option( 'permalink_structure' ) ) {
|
390 |
-
$suffix = '';
|
391 |
-
if ( preg_match( '/([^\?]+)\?*?(.*)/i', $link, $_link ) ) {
|
392 |
-
$link = $_link[1];
|
393 |
-
$suffix = $_link[2];
|
394 |
-
}
|
395 |
-
if ( ! preg_match( '/\/$/', $link ) ) {
|
396 |
-
$link .= '/';
|
397 |
-
}
|
398 |
-
$link .= $share_key . '/' . $suffix;
|
399 |
-
} else {
|
400 |
-
$link = add_query_arg( 'tinvwlID', $share_key, $link );
|
401 |
-
}
|
402 |
-
}
|
403 |
-
|
404 |
-
return $link;
|
405 |
-
}
|
406 |
-
} // End if().
|
407 |
-
|
408 |
-
if ( ! function_exists( 'tinv_url_wishlist' ) ) {
|
409 |
-
|
410 |
-
/**
|
411 |
-
* Return the wishlist url by id or share key
|
412 |
-
*
|
413 |
-
* @param mixed $id Integer wishlist ID, or Share Key wishlist.
|
414 |
-
* @param integer $paged Page.
|
415 |
-
* @param boolean $full Return full url or shroted url for logged in user.
|
416 |
-
*
|
417 |
-
* @return string
|
418 |
-
*/
|
419 |
-
function tinv_url_wishlist( $id = '', $paged = 1, $full = true ) {
|
420 |
-
$share_key = $id;
|
421 |
-
if ( ! ( is_string( $id ) && preg_match( '/^[A-Fa-f0-9]{6}$/', $id ) ) ) {
|
422 |
-
$wishlist = tinv_wishlist_get( $id, false );
|
423 |
-
$share_key = $wishlist['share_key'];
|
424 |
-
}
|
425 |
-
|
426 |
-
return tinv_url_wishlist_by_key( $share_key, $paged );
|
427 |
-
}
|
428 |
-
}
|
429 |
-
|
430 |
-
if ( ! function_exists( 'tinv_wishlist_status' ) ) {
|
431 |
-
|
432 |
-
/**
|
433 |
-
* Check status free or premium plugin and disable free
|
434 |
-
*
|
435 |
-
* @param string $transient Plugin transient name.
|
436 |
-
*
|
437 |
-
* @return string
|
438 |
-
* @global string $s
|
439 |
-
*
|
440 |
-
* @global string $status
|
441 |
-
* @global string $page
|
442 |
-
*/
|
443 |
-
function tinv_wishlist_status( $transient ) {
|
444 |
-
if ( TINVWL_LOAD_FREE === $transient ) {
|
445 |
-
TInvWL_PluginExtend::deactivate_self( TINVWL_LOAD_FREE );
|
446 |
-
|
447 |
-
return 'plugins.php';
|
448 |
-
}
|
449 |
-
if ( TINVWL_LOAD_PREMIUM === $transient ) {
|
450 |
-
if ( is_plugin_active( TINVWL_LOAD_FREE ) ) {
|
451 |
-
TInvWL_PluginExtend::deactivate_self( TINVWL_LOAD_FREE );
|
452 |
-
if ( ! function_exists( 'wp_create_nonce' ) ) {
|
453 |
-
return 'plugins.php';
|
454 |
-
}
|
455 |
-
|
456 |
-
global $status, $page, $s;
|
457 |
-
$redirect = 'plugins.php?';
|
458 |
-
$redirect .= http_build_query( array(
|
459 |
-
'action' => 'activate',
|
460 |
-
'plugin' => $transient,
|
461 |
-
'plugin_status' => $status,
|
462 |
-
'paged' => $page,
|
463 |
-
's' => $s,
|
464 |
-
) );
|
465 |
-
$redirect = esc_url_raw( add_query_arg( '_wpnonce', wp_create_nonce( 'activate-plugin_' . $transient ), $redirect ) );
|
466 |
-
|
467 |
-
return $redirect;
|
468 |
-
}
|
469 |
-
}
|
470 |
-
|
471 |
-
return false;
|
472 |
-
}
|
473 |
-
} // End if().
|
474 |
-
|
475 |
-
if ( ! function_exists( 'tinvwl_body_classes' ) ) {
|
476 |
-
|
477 |
-
/**
|
478 |
-
* Add custom class
|
479 |
-
*
|
480 |
-
* @param array $classes Current classes.
|
481 |
-
*
|
482 |
-
* @return array
|
483 |
-
*/
|
484 |
-
function tinvwl_body_classes( $classes ) {
|
485 |
-
if ( tinv_get_option( 'style', 'customstyle' ) ) {
|
486 |
-
$classes[] = 'tinvwl-theme-style';
|
487 |
-
} else {
|
488 |
-
$classes[] = 'tinvwl-custom-style';
|
489 |
-
}
|
490 |
-
|
491 |
-
return $classes;
|
492 |
-
}
|
493 |
-
|
494 |
-
add_filter( 'body_class', 'tinvwl_body_classes' );
|
495 |
-
}
|
496 |
-
|
497 |
-
if ( ! function_exists( 'tinvwl_shortcode_addtowishlist' ) ) {
|
498 |
-
|
499 |
-
/**
|
500 |
-
* Shortcode Add To Wishlist
|
501 |
-
*
|
502 |
-
* @param array $atts Array parameter from shortcode.
|
503 |
-
*
|
504 |
-
* @return string
|
505 |
-
*/
|
506 |
-
function tinvwl_shortcode_addtowishlist( $atts = array() ) {
|
507 |
-
$class = TInvWL_Public_AddToWishlist::instance();
|
508 |
-
|
509 |
-
return $class->shortcode( $atts );
|
510 |
-
}
|
511 |
-
|
512 |
-
add_shortcode( 'ti_wishlists_addtowishlist', 'tinvwl_shortcode_addtowishlist' );
|
513 |
-
}
|
514 |
-
|
515 |
-
if ( ! function_exists( 'tinvwl_shortcode_view' ) ) {
|
516 |
-
|
517 |
-
/**
|
518 |
-
* Shortcode view Wishlist
|
519 |
-
*
|
520 |
-
* @param array $atts Array parameter from shortcode.
|
521 |
-
*
|
522 |
-
* @return string
|
523 |
-
*/
|
524 |
-
function tinvwl_shortcode_view( $atts = array() ) {
|
525 |
-
$class = TInvWL_Public_Wishlist_View::instance();
|
526 |
-
|
527 |
-
return $class->shortcode( $atts );
|
528 |
-
}
|
529 |
-
|
530 |
-
add_shortcode( 'ti_wishlistsview', 'tinvwl_shortcode_view' );
|
531 |
-
}
|
532 |
-
|
533 |
-
if ( ! function_exists( 'tinvwl_shortcode_products_counter' ) ) {
|
534 |
-
|
535 |
-
/**
|
536 |
-
* Shortcode view Wishlist
|
537 |
-
*
|
538 |
-
* @param array $atts Array parameter from shortcode.
|
539 |
-
*
|
540 |
-
* @return string
|
541 |
-
*/
|
542 |
-
function tinvwl_shortcode_products_counter( $atts = array() ) {
|
543 |
-
$class = TInvWL_Public_WishlistCounter::instance();
|
544 |
-
|
545 |
-
return $class->shortcode( $atts );
|
546 |
-
}
|
547 |
-
|
548 |
-
add_shortcode( 'ti_wishlist_products_counter', 'tinvwl_shortcode_products_counter' );
|
549 |
-
}
|
550 |
-
|
551 |
-
if ( ! function_exists( 'tinvwl_view_addto_html' ) ) {
|
552 |
-
|
553 |
-
/**
|
554 |
-
* Show button Add to Wishlsit
|
555 |
-
*/
|
556 |
-
function tinvwl_view_addto_html() {
|
557 |
-
$class = TInvWL_Public_AddToWishlist::instance();
|
558 |
-
$class->htmloutput();
|
559 |
-
}
|
560 |
-
}
|
561 |
-
|
562 |
-
if ( ! function_exists( 'tinvwl_view_addto_htmlout' ) ) {
|
563 |
-
|
564 |
-
/**
|
565 |
-
* Show button Add to Wishlsit, if product is not purchasable
|
566 |
-
*/
|
567 |
-
function tinvwl_view_addto_htmlout() {
|
568 |
-
$class = TInvWL_Public_AddToWishlist::instance();
|
569 |
-
$class->htmloutput_out();
|
570 |
-
}
|
571 |
-
}
|
572 |
-
|
573 |
-
if ( ! function_exists( 'tinvwl_view_addto_htmlloop' ) ) {
|
574 |
-
|
575 |
-
/**
|
576 |
-
* Show button Add to Wishlsit, in loop
|
577 |
-
*/
|
578 |
-
function tinvwl_view_addto_htmlloop() {
|
579 |
-
$class = TInvWL_Public_AddToWishlist::instance();
|
580 |
-
$class->htmloutput_loop();
|
581 |
-
}
|
582 |
-
}
|
583 |
-
|
584 |
-
if ( ! function_exists( 'tinvwl_clean_url' ) ) {
|
585 |
-
|
586 |
-
/**
|
587 |
-
* Clear esc_url to original
|
588 |
-
*
|
589 |
-
* @param string $good_protocol_url Cleared URL.
|
590 |
-
* @param string $original_url Original URL.
|
591 |
-
*
|
592 |
-
* @return string
|
593 |
-
*/
|
594 |
-
function tinvwl_clean_url( $good_protocol_url, $original_url ) {
|
595 |
-
return $original_url;
|
596 |
-
}
|
597 |
-
}
|
598 |
-
|
599 |
-
if ( ! function_exists( 'tinvwl_add_to_cart_need_redirect' ) ) {
|
600 |
-
|
601 |
-
/**
|
602 |
-
* Check if the product is third-party, or has another link added to the cart then redirect to the product page.
|
603 |
-
*
|
604 |
-
* @param boolean $redirect Default value to redirect.
|
605 |
-
* @param \WC_Product $_product Product data.
|
606 |
-
* @param string $redirect_url Current url for redirect.
|
607 |
-
*
|
608 |
-
* @return boolean
|
609 |
-
*/
|
610 |
-
function tinvwl_add_to_cart_need_redirect( $redirect, $_product, $redirect_url ) {
|
611 |
-
if ( $redirect ) {
|
612 |
-
return true;
|
613 |
-
}
|
614 |
-
|
615 |
-
if ( 'external' === ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $_product->product_type : $_product->get_type() ) ) {
|
616 |
-
return true;
|
617 |
-
}
|
618 |
-
|
619 |
-
$need_url_data = array_merge( array(
|
620 |
-
'variation_id' => ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $_product->variation_id : ( $_product->is_type( 'variation' ) ? $_product->get_id() : 0 ) ),
|
621 |
-
'add-to-cart' => ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $_product->id : ( $_product->is_type( 'variation' ) ? $_product->get_parent_id() : $_product->get_id() ) ),
|
622 |
-
), array_map( 'urlencode', ( version_compare( WC_VERSION, '3.0.0', '<' ) ? ( is_array( $_product->variation_data ) ? $_product->variation_data : array() ) : array() ) ) );
|
623 |
-
|
624 |
-
$need_url_data = version_compare( WC_VERSION, '3.0.0', '<' ) ? $need_url_data : array_filter( $need_url_data );
|
625 |
-
|
626 |
-
$need_url = apply_filters( 'tinvwl_product_add_to_cart_redirect_slug_original', remove_query_arg( 'added-to-cart', ( version_compare( WC_VERSION, '3.8.0', '<' ) ? add_query_arg( $need_url_data ) : add_query_arg( $need_url_data, '' ) ) ), $_product );
|
627 |
-
$need_url_full = apply_filters( 'tinvwl_product_add_to_cart_redirect_url_original', remove_query_arg( 'added-to-cart', add_query_arg( $need_url_data, $_product->get_permalink() ) ), $_product );
|
628 |
-
|
629 |
-
global $product;
|
630 |
-
// store global product data.
|
631 |
-
$_product_tmp = $product;
|
632 |
-
// override global product data.
|
633 |
-
$product = $_product;
|
634 |
-
|
635 |
-
add_filter( 'clean_url', 'tinvwl_clean_url', 10, 2 );
|
636 |
-
do_action( 'before_get_redirect_url' );
|
637 |
-
$_redirect_url = apply_filters( 'tinvwl_product_add_to_cart_redirect_url', $_product->add_to_cart_url(), $_product );
|
638 |
-
do_action( 'after_get_redirect_url' );
|
639 |
-
remove_filter( 'clean_url', 'tinvwl_clean_url', 10 );
|
640 |
-
|
641 |
-
// restore global product data.
|
642 |
-
$product = $_product_tmp;
|
643 |
-
|
644 |
-
if ( $_redirect_url !== $need_url && $_redirect_url !== $need_url_full ) {
|
645 |
-
return true;
|
646 |
-
}
|
647 |
-
|
648 |
-
return $redirect;
|
649 |
-
}
|
650 |
-
|
651 |
-
add_filter( 'tinvwl_product_add_to_cart_need_redirect', 'tinvwl_add_to_cart_need_redirect', 10, 3 );
|
652 |
-
} // End if().
|
653 |
-
|
654 |
-
if ( ! function_exists( 'tinvwl_meta_validate_cart_add' ) ) {
|
655 |
-
|
656 |
-
/**
|
657 |
-
* Checks the ability to add a product
|
658 |
-
*
|
659 |
-
* @param boolean $redirect Default value to redirect.
|
660 |
-
* @param \WC_Product $product Product data.
|
661 |
-
* @param string $redirect_url Current url for redirect.
|
662 |
-
* @param array $wl_product Wishlist Product.
|
663 |
-
*
|
664 |
-
* @return boolean
|
665 |
-
*/
|
666 |
-
function tinvwl_meta_validate_cart_add( $redirect, $product, $redirect_url, $wl_product ) {
|
667 |
-
if ( $redirect && array_key_exists( 'meta', $wl_product ) && ! empty( $wl_product['meta'] ) ) {
|
668 |
-
|
669 |
-
TInvWL_Public_Cart::prepare_post( $wl_product );
|
670 |
-
|
671 |
-
$wl_product = apply_filters( 'tinvwl_addproduct_tocart', $wl_product );
|
672 |
-
$product_id = apply_filters( 'woocommerce_add_to_cart_product_id', absint( $wl_product['product_id'] ) );
|
673 |
-
$quantity = empty( $wl_product['quantity'] ) ? 1 : wc_stock_amount( $wl_product['quantity'] );
|
674 |
-
$variation_id = $wl_product['variation_id'];
|
675 |
-
$variations = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->variation_data : ( $product->is_type( 'variation' ) ? wc_get_product_variation_attributes( $product->get_id() ) : array() ) );
|
676 |
-
$passed_validation = $product->is_purchasable() && ( $product->is_in_stock() || $product->backorders_allowed() ) && 'external' !== ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->product_type : $product->get_type() );
|
677 |
-
ob_start();
|
678 |
-
if ( function_exists( 'wc_clear_notices' ) ) {
|
679 |
-
wc_clear_notices();
|
680 |
-
}
|
681 |
-
$passed_validation = apply_filters( 'woocommerce_add_to_cart_validation', $passed_validation, $product_id, $quantity, $variation_id, $variations );
|
682 |
-
$wc_errors = wc_get_notices( 'error' );
|
683 |
-
$wc_output = ob_get_clean();
|
684 |
-
if ( $passed_validation && empty( $wc_errors ) && empty( $wc_output ) ) {
|
685 |
-
$redirect = false;
|
686 |
-
}
|
687 |
-
|
688 |
-
TInvWL_Public_Cart::unprepare_post();
|
689 |
-
}
|
690 |
-
|
691 |
-
return $redirect;
|
692 |
-
}
|
693 |
-
|
694 |
-
add_filter( 'tinvwl_product_add_to_cart_need_redirect', 'tinvwl_meta_validate_cart_add', 90, 4 );
|
695 |
-
} // End if().
|
696 |
-
|
697 |
-
if ( ! function_exists( 'tinv_wishlist_print_meta' ) ) {
|
698 |
-
|
699 |
-
/**
|
700 |
-
* Print meta data for wishlist form
|
701 |
-
*
|
702 |
-
* @param array $meta Meta Array.
|
703 |
-
* @param boolean $flat Return text or template.
|
704 |
-
*
|
705 |
-
* @return string
|
706 |
-
*/
|
707 |
-
function tinv_wishlist_print_meta( $meta = array(), $flat = false ) {
|
708 |
-
if ( ! is_array( $meta ) ) {
|
709 |
-
$meta = array();
|
710 |
-
}
|
711 |
-
$product_id = $variation_id = 0;
|
712 |
-
if ( array_key_exists( 'product_id', $meta ) ) {
|
713 |
-
$product_id = $meta['product_id'];
|
714 |
-
}
|
715 |
-
if ( array_key_exists( 'variation_id', $meta ) ) {
|
716 |
-
$variation_id = $meta['variation_id'];
|
717 |
-
}
|
718 |
-
foreach ( array( 'add-to-cart', 'product_id', 'variation_id', 'quantity', 'action', 'variation' ) as $field ) {
|
719 |
-
if ( array_key_exists( $field, $meta ) ) {
|
720 |
-
unset( $meta[ $field ] );
|
721 |
-
}
|
722 |
-
}
|
723 |
-
$meta = array_filter( $meta );
|
724 |
-
if ( empty( $meta ) ) {
|
725 |
-
return '';
|
726 |
-
}
|
727 |
-
$item_data = array();
|
728 |
-
foreach ( $meta as $key => $value ) {
|
729 |
-
if ( ! preg_match( '/^\_/', $key ) ) {
|
730 |
-
$item_data[ $key ] = array(
|
731 |
-
'key' => $key,
|
732 |
-
'display' => $value,
|
733 |
-
);
|
734 |
-
}
|
735 |
-
}
|
736 |
-
|
737 |
-
foreach ( $item_data as $key
|
738 |
-
if (
|
739 |
-
$item_data[ $key ]
|
740 |
-
}
|
741 |
-
}
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
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 |
-
if (
|
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 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Basic function for plugin
|
4 |
+
*
|
5 |
+
* @since 1.0.0
|
6 |
+
* @package TInvWishlist
|
7 |
+
*/
|
8 |
+
|
9 |
+
// If this file is called directly, abort.
|
10 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
11 |
+
die;
|
12 |
+
}
|
13 |
+
|
14 |
+
|
15 |
+
if ( ! function_exists( 'tinv_get_option' ) ) {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Extract options from database or default array settings.
|
19 |
+
*
|
20 |
+
* @param string $category Name category settings.
|
21 |
+
* @param string $option Name paremetr. If is empty string, then function return array category settings.
|
22 |
+
*
|
23 |
+
* @return mixed
|
24 |
+
*/
|
25 |
+
function tinv_get_option( $category, $option = '' ) {
|
26 |
+
$prefix = TINVWL_PREFIX . '-';
|
27 |
+
$values = get_option( $prefix . $category, array() );
|
28 |
+
if ( empty( $values ) ) {
|
29 |
+
$values = tinv_get_option_defaults( $category );
|
30 |
+
}
|
31 |
+
if ( empty( $option ) ) {
|
32 |
+
return $values;
|
33 |
+
} else {
|
34 |
+
if ( array_key_exists( $option, (array) $values ) ) {
|
35 |
+
return $values[ $option ];
|
36 |
+
} else {
|
37 |
+
$values = tinv_get_option_defaults( $category );
|
38 |
+
if ( array_key_exists( $option, (array) $values ) ) {
|
39 |
+
return $values[ $option ];
|
40 |
+
}
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
return null;
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
if ( ! function_exists( 'tinv_get_option_admin' ) ) {
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Extract options from database or default array settings.
|
52 |
+
*
|
53 |
+
* @param string $category Name category settings.
|
54 |
+
* @param string $option Name paremetr. If is empty string, then function return array category settings.
|
55 |
+
*
|
56 |
+
* @return mixed
|
57 |
+
*/
|
58 |
+
function tinv_get_option_admin( $category, $option = '' ) {
|
59 |
+
$prefix = TINVWL_PREFIX . '-';
|
60 |
+
$values = get_option( $prefix . $category, array() );
|
61 |
+
if ( empty( $values ) ) {
|
62 |
+
$values = array();
|
63 |
+
}
|
64 |
+
if ( empty( $option ) ) {
|
65 |
+
return $values;
|
66 |
+
} elseif ( array_key_exists( $option, $values ) ) {
|
67 |
+
return $values[ $option ];
|
68 |
+
}
|
69 |
+
|
70 |
+
return null;
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
+
if ( ! function_exists( 'tinv_style' ) ) {
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Get style for custom style
|
78 |
+
*
|
79 |
+
* @param string $selector Selector style.
|
80 |
+
* @param string $element Attribute name.
|
81 |
+
*
|
82 |
+
* @return string
|
83 |
+
*/
|
84 |
+
function tinv_style( $selector = '', $element = '' ) {
|
85 |
+
$key = md5( $selector . '||' . $element );
|
86 |
+
$values = get_option( TINVWL_PREFIX . '-style_options', array() );
|
87 |
+
if ( empty( $values ) ) {
|
88 |
+
return '';
|
89 |
+
}
|
90 |
+
if ( array_key_exists( $key, $values ) ) {
|
91 |
+
return $values[ $key ];
|
92 |
+
}
|
93 |
+
|
94 |
+
return '';
|
95 |
+
}
|
96 |
+
}
|
97 |
+
|
98 |
+
if ( ! function_exists( 'tinv_update_option' ) ) {
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Update options in database.
|
102 |
+
*
|
103 |
+
* @param string $category Name category settings.
|
104 |
+
* @param string $option Name paremetr. If is empty string, then function update array category settings.
|
105 |
+
* @param mixed $value Value option.
|
106 |
+
*
|
107 |
+
* @return boolean
|
108 |
+
*/
|
109 |
+
function tinv_update_option( $category, $option = '', $value = false ) {
|
110 |
+
$prefix = TINVWL_PREFIX . '-';
|
111 |
+
if ( empty( $option ) ) {
|
112 |
+
if ( is_array( $value ) ) {
|
113 |
+
update_option( $prefix . $category, $value );
|
114 |
+
|
115 |
+
return true;
|
116 |
+
}
|
117 |
+
} else {
|
118 |
+
$values = get_option( $prefix . $category, array() );
|
119 |
+
|
120 |
+
$values[ $option ] = $value;
|
121 |
+
update_option( $prefix . $category, $values );
|
122 |
+
|
123 |
+
return true;
|
124 |
+
}
|
125 |
+
|
126 |
+
return false;
|
127 |
+
}
|
128 |
+
}
|
129 |
+
|
130 |
+
if ( ! function_exists( 'tinv_wishlist_template' ) ) {
|
131 |
+
|
132 |
+
/**
|
133 |
+
* The function overwrites the method output templates woocommerce
|
134 |
+
*
|
135 |
+
* @param string $template_name Name file template.
|
136 |
+
* @param array $args Array variable in template.
|
137 |
+
* @param string $template_path Customization path.
|
138 |
+
*/
|
139 |
+
function tinv_wishlist_template( $template_name, $args = array(), $template_path = '' ) {
|
140 |
+
if ( function_exists( 'wc_get_template' ) ) {
|
141 |
+
wc_get_template( $template_name, $args, $template_path );
|
142 |
+
} else {
|
143 |
+
woocommerce_get_template( $template_name, $args, $template_path );
|
144 |
+
}
|
145 |
+
}
|
146 |
+
}
|
147 |
+
|
148 |
+
if ( ! function_exists( 'tinv_wishlist_locate_template' ) ) {
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Overwrites path for email and other template
|
152 |
+
*
|
153 |
+
* @param string $template_name Requered Template file.
|
154 |
+
* @param string $template_path Template path.
|
155 |
+
* @param string $default_path Template default path.
|
156 |
+
*
|
157 |
+
* @return mixed
|
158 |
+
*/
|
159 |
+
function tinv_wishlist_locate_template( $template_name, $template_path = '', $default_path = '' ) {
|
160 |
+
$prefix = 'ti-';
|
161 |
+
|
162 |
+
if ( substr( basename( $template_name ), 0, strlen( $prefix ) ) !== $prefix ) {
|
163 |
+
return;
|
164 |
+
}
|
165 |
+
|
166 |
+
if ( ! $template_path ) {
|
167 |
+
$template_path = WC()->template_path();
|
168 |
+
}
|
169 |
+
|
170 |
+
if ( ! $default_path ) {
|
171 |
+
$default_path = TINVWL_PATH . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR;
|
172 |
+
}
|
173 |
+
|
174 |
+
// Look within passed path within the theme - this is priority.
|
175 |
+
$template = locate_template( array(
|
176 |
+
trailingslashit( $template_path ) . $template_name,
|
177 |
+
$template_name,
|
178 |
+
) );
|
179 |
+
|
180 |
+
// Get default template.
|
181 |
+
if ( ! $template && file_exists( $default_path . $template_name ) ) {
|
182 |
+
$template = $default_path . $template_name;
|
183 |
+
}
|
184 |
+
|
185 |
+
// Return what we found.
|
186 |
+
return apply_filters( 'tinvwl_locate_template', $template, $template_name, $template_path );
|
187 |
+
}
|
188 |
+
} // End if().
|
189 |
+
|
190 |
+
if ( ! function_exists( 'tinv_wishlist_template_html' ) ) {
|
191 |
+
|
192 |
+
/**
|
193 |
+
* The function overwrites the method return templates woocommerce
|
194 |
+
*
|
195 |
+
* @param string $template_name Name file template.
|
196 |
+
* @param array $args Array variable in template.
|
197 |
+
* @param string $template_path Customization path.
|
198 |
+
*
|
199 |
+
* @return string
|
200 |
+
*/
|
201 |
+
function tinv_wishlist_template_html( $template_name, $args = array(), $template_path = '' ) {
|
202 |
+
ob_start();
|
203 |
+
tinv_wishlist_template( $template_name, $args, $template_path );
|
204 |
+
|
205 |
+
return ob_get_clean();
|
206 |
+
}
|
207 |
+
}
|
208 |
+
|
209 |
+
if ( ! function_exists( 'tinv_wishlist_get_item_data' ) ) {
|
210 |
+
|
211 |
+
/**
|
212 |
+
* Extract meta attributes for product
|
213 |
+
*
|
214 |
+
* @param object $product Object selected product.
|
215 |
+
* @param array $wl_product Wishlist selected product.
|
216 |
+
* @param boolean $flat Return text or template.
|
217 |
+
*
|
218 |
+
* @return string
|
219 |
+
*/
|
220 |
+
function tinv_wishlist_get_item_data( $product, $wl_product = array(), $flat = false ) {
|
221 |
+
$item_data = array();
|
222 |
+
$variation_id = version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->variation_id : ( $product->is_type( 'variation' ) ? $product->get_id() : 0 );
|
223 |
+
$variation_data = version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->variation_data : ( $product->is_type( 'variation' ) ? wc_get_product_variation_attributes( $product->get_id() ) : array() );
|
224 |
+
if ( ! empty( $variation_id ) && is_array( $variation_data ) && is_array( $wl_product ) ) {
|
225 |
+
foreach ( $variation_data as $name => $value ) {
|
226 |
+
if ( '' === $value ) {
|
227 |
+
// Could be any value that saved to a custom meta.
|
228 |
+
if ( array_key_exists( 'meta', $wl_product ) && array_key_exists( $name, $wl_product['meta'] ) ) {
|
229 |
+
$value = $wl_product['meta'][ $name ];
|
230 |
+
} else {
|
231 |
+
continue;
|
232 |
+
}
|
233 |
+
}
|
234 |
+
|
235 |
+
$taxonomy = wc_attribute_taxonomy_name( str_replace( 'attribute_pa_', '', urldecode( $name ) ) );
|
236 |
+
|
237 |
+
// If this is a term slug, get the term's nice name.
|
238 |
+
if ( taxonomy_exists( $taxonomy ) ) {
|
239 |
+
$term = get_term_by( 'slug', $value, $taxonomy ); // @codingStandardsIgnoreLine WordPress.VIP.RestrictedFunctions.get_term_by
|
240 |
+
if ( ! is_wp_error( $term ) && $term && $term->name ) {
|
241 |
+
$value = $term->name;
|
242 |
+
}
|
243 |
+
$label = wc_attribute_label( $taxonomy );
|
244 |
+
|
245 |
+
// If this is a custom option slug, get the options name.
|
246 |
+
} else {
|
247 |
+
$value = apply_filters( 'woocommerce_variation_option_name', $value );
|
248 |
+
$product_attributes = $product->get_attributes();
|
249 |
+
$_name = str_replace( 'attribute_', '', $name );
|
250 |
+
if ( isset( $product_attributes[ $_name ] ) ) {
|
251 |
+
$_name = version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_attributes[ $_name ]['name'] : $_name;
|
252 |
+
$label = wc_attribute_label( $_name, $product );
|
253 |
+
} else {
|
254 |
+
$label = $name;
|
255 |
+
}
|
256 |
+
}
|
257 |
+
if ( '' === $value ) {
|
258 |
+
continue;
|
259 |
+
}
|
260 |
+
$item_data[] = array(
|
261 |
+
'key' => $label,
|
262 |
+
'value' => $value,
|
263 |
+
);
|
264 |
+
} // End foreach().
|
265 |
+
} // End if().
|
266 |
+
|
267 |
+
// Filter item data to allow 3rd parties to add more to the array.
|
268 |
+
$item_data = apply_filters( 'tinvwl_wishlist_get_item_data', $item_data, $product );
|
269 |
+
|
270 |
+
// Format item data ready to display.
|
271 |
+
foreach ( $item_data as $key => $data ) {
|
272 |
+
// Set hidden to true to not display meta on cart.
|
273 |
+
if ( ! empty( $data['hidden'] ) ) {
|
274 |
+
unset( $item_data[ $key ] );
|
275 |
+
continue;
|
276 |
+
}
|
277 |
+
$item_data[ $key ]['key'] = ! empty( $data['key'] ) ? $data['key'] : $data['name'];
|
278 |
+
$item_data[ $key ]['display'] = ! empty( $data['display'] ) ? $data['display'] : $data['value'];
|
279 |
+
}
|
280 |
+
|
281 |
+
// Output flat or in list format.
|
282 |
+
if ( 0 < count( $item_data ) ) {
|
283 |
+
ob_start();
|
284 |
+
if ( $flat ) {
|
285 |
+
foreach ( $item_data as $data ) {
|
286 |
+
echo esc_html( $data['key'] ) . ': ' . wp_kses_post( $data['display'] ) . '<br>';
|
287 |
+
}
|
288 |
+
} else {
|
289 |
+
tinv_wishlist_template( 'ti-wishlist-item-data.php', array( 'item_data' => $item_data ) );
|
290 |
+
}
|
291 |
+
|
292 |
+
return ob_get_clean();
|
293 |
+
}
|
294 |
+
|
295 |
+
return '';
|
296 |
+
}
|
297 |
+
} // End if().
|
298 |
+
|
299 |
+
if ( ! function_exists( 'tinv_wishlist_get' ) ) {
|
300 |
+
|
301 |
+
/**
|
302 |
+
* Return Wishlist by id or share key
|
303 |
+
*
|
304 |
+
* @param mixed $id Integer wishlist ID, or Share Key wishlist.
|
305 |
+
* @param boolean $toend Switches to the extract the default or guest wishlist.
|
306 |
+
*
|
307 |
+
* @return array
|
308 |
+
*/
|
309 |
+
function tinv_wishlist_get( $id = '', $toend = true ) {
|
310 |
+
$wl = new TInvWL_Wishlist();
|
311 |
+
$wishlist = null;
|
312 |
+
if ( empty( $id ) ) {
|
313 |
+
$id = get_query_var( 'tinvwlID', null );
|
314 |
+
}
|
315 |
+
|
316 |
+
if ( ! empty( $id ) ) {
|
317 |
+
if ( is_integer( $id ) ) {
|
318 |
+
$wishlist = $wl->get_by_id( $id );
|
319 |
+
}
|
320 |
+
if ( empty( $wishlist ) ) {
|
321 |
+
$wishlist = $wl->get_by_share_key( $id );
|
322 |
+
}
|
323 |
+
|
324 |
+
if ( is_array( $wishlist ) ) {
|
325 |
+
$wishlist['is_owner'] = false;
|
326 |
+
if ( is_user_logged_in() ) {
|
327 |
+
$wishlist['is_owner'] = get_current_user_id() == $wishlist['author']; // WPCS: loose comparison ok.
|
328 |
+
} else {
|
329 |
+
$wishlist['is_owner'] = $wl->get_sharekey() === $wishlist['share_key']; // WPCS: loose comparison ok.
|
330 |
+
}
|
331 |
+
}
|
332 |
+
} elseif ( is_user_logged_in() && $toend ) {
|
333 |
+
$wishlist = $wl->add_user_default();
|
334 |
+
|
335 |
+
$wishlist['is_owner'] = true;
|
336 |
+
} elseif ( $toend ) {
|
337 |
+
$wishlist = $wl->get_by_sharekey_default();
|
338 |
+
if ( ! empty( $wishlist ) ) {
|
339 |
+
$wishlist = array_shift( $wishlist );
|
340 |
+
$wishlist['is_owner'] = $wl->get_sharekey() === $wishlist['share_key'];
|
341 |
+
}
|
342 |
+
}
|
343 |
+
|
344 |
+
return $wishlist;
|
345 |
+
}
|
346 |
+
} // End if().
|
347 |
+
|
348 |
+
if ( ! function_exists( 'tinv_url_wishlist_default' ) ) {
|
349 |
+
|
350 |
+
/**
|
351 |
+
* Return the default wishlist url
|
352 |
+
*
|
353 |
+
* @return string
|
354 |
+
*/
|
355 |
+
function tinv_url_wishlist_default() {
|
356 |
+
$page = apply_filters( 'wpml_object_id', tinv_get_option( 'page', 'wishlist' ), 'page', true ); // @codingStandardsIgnoreLine WordPress.Variables.GlobalVariables.OverrideProhibited
|
357 |
+
if ( empty( $page ) ) {
|
358 |
+
return '';
|
359 |
+
}
|
360 |
+
$link = get_permalink( $page );
|
361 |
+
|
362 |
+
return $link;
|
363 |
+
}
|
364 |
+
}
|
365 |
+
|
366 |
+
if ( ! function_exists( 'tinv_url_wishlist_by_key' ) ) {
|
367 |
+
|
368 |
+
/**
|
369 |
+
* Return the wishlist url by share key
|
370 |
+
*
|
371 |
+
* @param string $share_key Share Key wishlist.
|
372 |
+
* @param integer $paged Page.
|
373 |
+
*
|
374 |
+
* @return string
|
375 |
+
*/
|
376 |
+
function tinv_url_wishlist_by_key( $share_key, $paged = 1 ) {
|
377 |
+
$paged = absint( $paged );
|
378 |
+
$paged = 1 < $paged ? $paged : 1;
|
379 |
+
$link = tinv_url_wishlist_default();
|
380 |
+
if ( empty( $link ) ) {
|
381 |
+
return $link;
|
382 |
+
}
|
383 |
+
|
384 |
+
if ( 1 < $paged ) {
|
385 |
+
$link = add_query_arg( 'wl_paged', $paged, $link );
|
386 |
+
}
|
387 |
+
|
388 |
+
if ( $share_key ) {
|
389 |
+
if ( get_option( 'permalink_structure' ) ) {
|
390 |
+
$suffix = '';
|
391 |
+
if ( preg_match( '/([^\?]+)\?*?(.*)/i', $link, $_link ) ) {
|
392 |
+
$link = $_link[1];
|
393 |
+
$suffix = $_link[2];
|
394 |
+
}
|
395 |
+
if ( ! preg_match( '/\/$/', $link ) ) {
|
396 |
+
$link .= '/';
|
397 |
+
}
|
398 |
+
$link .= $share_key . '/' . $suffix;
|
399 |
+
} else {
|
400 |
+
$link = add_query_arg( 'tinvwlID', $share_key, $link );
|
401 |
+
}
|
402 |
+
}
|
403 |
+
|
404 |
+
return $link;
|
405 |
+
}
|
406 |
+
} // End if().
|
407 |
+
|
408 |
+
if ( ! function_exists( 'tinv_url_wishlist' ) ) {
|
409 |
+
|
410 |
+
/**
|
411 |
+
* Return the wishlist url by id or share key
|
412 |
+
*
|
413 |
+
* @param mixed $id Integer wishlist ID, or Share Key wishlist.
|
414 |
+
* @param integer $paged Page.
|
415 |
+
* @param boolean $full Return full url or shroted url for logged in user.
|
416 |
+
*
|
417 |
+
* @return string
|
418 |
+
*/
|
419 |
+
function tinv_url_wishlist( $id = '', $paged = 1, $full = true ) {
|
420 |
+
$share_key = $id;
|
421 |
+
if ( ! ( is_string( $id ) && preg_match( '/^[A-Fa-f0-9]{6}$/', $id ) ) ) {
|
422 |
+
$wishlist = tinv_wishlist_get( $id, false );
|
423 |
+
$share_key = $wishlist['share_key'];
|
424 |
+
}
|
425 |
+
|
426 |
+
return tinv_url_wishlist_by_key( $share_key, $paged );
|
427 |
+
}
|
428 |
+
}
|
429 |
+
|
430 |
+
if ( ! function_exists( 'tinv_wishlist_status' ) ) {
|
431 |
+
|
432 |
+
/**
|
433 |
+
* Check status free or premium plugin and disable free
|
434 |
+
*
|
435 |
+
* @param string $transient Plugin transient name.
|
436 |
+
*
|
437 |
+
* @return string
|
438 |
+
* @global string $s
|
439 |
+
*
|
440 |
+
* @global string $status
|
441 |
+
* @global string $page
|
442 |
+
*/
|
443 |
+
function tinv_wishlist_status( $transient ) {
|
444 |
+
if ( TINVWL_LOAD_FREE === $transient ) {
|
445 |
+
TInvWL_PluginExtend::deactivate_self( TINVWL_LOAD_FREE );
|
446 |
+
|
447 |
+
return 'plugins.php';
|
448 |
+
}
|
449 |
+
if ( TINVWL_LOAD_PREMIUM === $transient ) {
|
450 |
+
if ( is_plugin_active( TINVWL_LOAD_FREE ) ) {
|
451 |
+
TInvWL_PluginExtend::deactivate_self( TINVWL_LOAD_FREE );
|
452 |
+
if ( ! function_exists( 'wp_create_nonce' ) ) {
|
453 |
+
return 'plugins.php';
|
454 |
+
}
|
455 |
+
|
456 |
+
global $status, $page, $s;
|
457 |
+
$redirect = 'plugins.php?';
|
458 |
+
$redirect .= http_build_query( array(
|
459 |
+
'action' => 'activate',
|
460 |
+
'plugin' => $transient,
|
461 |
+
'plugin_status' => $status,
|
462 |
+
'paged' => $page,
|
463 |
+
's' => $s,
|
464 |
+
) );
|
465 |
+
$redirect = esc_url_raw( add_query_arg( '_wpnonce', wp_create_nonce( 'activate-plugin_' . $transient ), $redirect ) );
|
466 |
+
|
467 |
+
return $redirect;
|
468 |
+
}
|
469 |
+
}
|
470 |
+
|
471 |
+
return false;
|
472 |
+
}
|
473 |
+
} // End if().
|
474 |
+
|
475 |
+
if ( ! function_exists( 'tinvwl_body_classes' ) ) {
|
476 |
+
|
477 |
+
/**
|
478 |
+
* Add custom class
|
479 |
+
*
|
480 |
+
* @param array $classes Current classes.
|
481 |
+
*
|
482 |
+
* @return array
|
483 |
+
*/
|
484 |
+
function tinvwl_body_classes( $classes ) {
|
485 |
+
if ( tinv_get_option( 'style', 'customstyle' ) ) {
|
486 |
+
$classes[] = 'tinvwl-theme-style';
|
487 |
+
} else {
|
488 |
+
$classes[] = 'tinvwl-custom-style';
|
489 |
+
}
|
490 |
+
|
491 |
+
return $classes;
|
492 |
+
}
|
493 |
+
|
494 |
+
add_filter( 'body_class', 'tinvwl_body_classes' );
|
495 |
+
}
|
496 |
+
|
497 |
+
if ( ! function_exists( 'tinvwl_shortcode_addtowishlist' ) ) {
|
498 |
+
|
499 |
+
/**
|
500 |
+
* Shortcode Add To Wishlist
|
501 |
+
*
|
502 |
+
* @param array $atts Array parameter from shortcode.
|
503 |
+
*
|
504 |
+
* @return string
|
505 |
+
*/
|
506 |
+
function tinvwl_shortcode_addtowishlist( $atts = array() ) {
|
507 |
+
$class = TInvWL_Public_AddToWishlist::instance();
|
508 |
+
|
509 |
+
return $class->shortcode( $atts );
|
510 |
+
}
|
511 |
+
|
512 |
+
add_shortcode( 'ti_wishlists_addtowishlist', 'tinvwl_shortcode_addtowishlist' );
|
513 |
+
}
|
514 |
+
|
515 |
+
if ( ! function_exists( 'tinvwl_shortcode_view' ) ) {
|
516 |
+
|
517 |
+
/**
|
518 |
+
* Shortcode view Wishlist
|
519 |
+
*
|
520 |
+
* @param array $atts Array parameter from shortcode.
|
521 |
+
*
|
522 |
+
* @return string
|
523 |
+
*/
|
524 |
+
function tinvwl_shortcode_view( $atts = array() ) {
|
525 |
+
$class = TInvWL_Public_Wishlist_View::instance();
|
526 |
+
|
527 |
+
return $class->shortcode( $atts );
|
528 |
+
}
|
529 |
+
|
530 |
+
add_shortcode( 'ti_wishlistsview', 'tinvwl_shortcode_view' );
|
531 |
+
}
|
532 |
+
|
533 |
+
if ( ! function_exists( 'tinvwl_shortcode_products_counter' ) ) {
|
534 |
+
|
535 |
+
/**
|
536 |
+
* Shortcode view Wishlist
|
537 |
+
*
|
538 |
+
* @param array $atts Array parameter from shortcode.
|
539 |
+
*
|
540 |
+
* @return string
|
541 |
+
*/
|
542 |
+
function tinvwl_shortcode_products_counter( $atts = array() ) {
|
543 |
+
$class = TInvWL_Public_WishlistCounter::instance();
|
544 |
+
|
545 |
+
return $class->shortcode( $atts );
|
546 |
+
}
|
547 |
+
|
548 |
+
add_shortcode( 'ti_wishlist_products_counter', 'tinvwl_shortcode_products_counter' );
|
549 |
+
}
|
550 |
+
|
551 |
+
if ( ! function_exists( 'tinvwl_view_addto_html' ) ) {
|
552 |
+
|
553 |
+
/**
|
554 |
+
* Show button Add to Wishlsit
|
555 |
+
*/
|
556 |
+
function tinvwl_view_addto_html() {
|
557 |
+
$class = TInvWL_Public_AddToWishlist::instance();
|
558 |
+
$class->htmloutput();
|
559 |
+
}
|
560 |
+
}
|
561 |
+
|
562 |
+
if ( ! function_exists( 'tinvwl_view_addto_htmlout' ) ) {
|
563 |
+
|
564 |
+
/**
|
565 |
+
* Show button Add to Wishlsit, if product is not purchasable
|
566 |
+
*/
|
567 |
+
function tinvwl_view_addto_htmlout() {
|
568 |
+
$class = TInvWL_Public_AddToWishlist::instance();
|
569 |
+
$class->htmloutput_out();
|
570 |
+
}
|
571 |
+
}
|
572 |
+
|
573 |
+
if ( ! function_exists( 'tinvwl_view_addto_htmlloop' ) ) {
|
574 |
+
|
575 |
+
/**
|
576 |
+
* Show button Add to Wishlsit, in loop
|
577 |
+
*/
|
578 |
+
function tinvwl_view_addto_htmlloop() {
|
579 |
+
$class = TInvWL_Public_AddToWishlist::instance();
|
580 |
+
$class->htmloutput_loop();
|
581 |
+
}
|
582 |
+
}
|
583 |
+
|
584 |
+
if ( ! function_exists( 'tinvwl_clean_url' ) ) {
|
585 |
+
|
586 |
+
/**
|
587 |
+
* Clear esc_url to original
|
588 |
+
*
|
589 |
+
* @param string $good_protocol_url Cleared URL.
|
590 |
+
* @param string $original_url Original URL.
|
591 |
+
*
|
592 |
+
* @return string
|
593 |
+
*/
|
594 |
+
function tinvwl_clean_url( $good_protocol_url, $original_url ) {
|
595 |
+
return $original_url;
|
596 |
+
}
|
597 |
+
}
|
598 |
+
|
599 |
+
if ( ! function_exists( 'tinvwl_add_to_cart_need_redirect' ) ) {
|
600 |
+
|
601 |
+
/**
|
602 |
+
* Check if the product is third-party, or has another link added to the cart then redirect to the product page.
|
603 |
+
*
|
604 |
+
* @param boolean $redirect Default value to redirect.
|
605 |
+
* @param \WC_Product $_product Product data.
|
606 |
+
* @param string $redirect_url Current url for redirect.
|
607 |
+
*
|
608 |
+
* @return boolean
|
609 |
+
*/
|
610 |
+
function tinvwl_add_to_cart_need_redirect( $redirect, $_product, $redirect_url ) {
|
611 |
+
if ( $redirect ) {
|
612 |
+
return true;
|
613 |
+
}
|
614 |
+
|
615 |
+
if ( 'external' === ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $_product->product_type : $_product->get_type() ) ) {
|
616 |
+
return true;
|
617 |
+
}
|
618 |
+
|
619 |
+
$need_url_data = array_merge( array(
|
620 |
+
'variation_id' => ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $_product->variation_id : ( $_product->is_type( 'variation' ) ? $_product->get_id() : 0 ) ),
|
621 |
+
'add-to-cart' => ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $_product->id : ( $_product->is_type( 'variation' ) ? $_product->get_parent_id() : $_product->get_id() ) ),
|
622 |
+
), array_map( 'urlencode', ( version_compare( WC_VERSION, '3.0.0', '<' ) ? ( is_array( $_product->variation_data ) ? $_product->variation_data : array() ) : array() ) ) );
|
623 |
+
|
624 |
+
$need_url_data = version_compare( WC_VERSION, '3.0.0', '<' ) ? $need_url_data : array_filter( $need_url_data );
|
625 |
+
|
626 |
+
$need_url = apply_filters( 'tinvwl_product_add_to_cart_redirect_slug_original', remove_query_arg( 'added-to-cart', ( version_compare( WC_VERSION, '3.8.0', '<' ) ? add_query_arg( $need_url_data ) : add_query_arg( $need_url_data, '' ) ) ), $_product );
|
627 |
+
$need_url_full = apply_filters( 'tinvwl_product_add_to_cart_redirect_url_original', remove_query_arg( 'added-to-cart', add_query_arg( $need_url_data, $_product->get_permalink() ) ), $_product );
|
628 |
+
|
629 |
+
global $product;
|
630 |
+
// store global product data.
|
631 |
+
$_product_tmp = $product;
|
632 |
+
// override global product data.
|
633 |
+
$product = $_product;
|
634 |
+
|
635 |
+
add_filter( 'clean_url', 'tinvwl_clean_url', 10, 2 );
|
636 |
+
do_action( 'before_get_redirect_url' );
|
637 |
+
$_redirect_url = apply_filters( 'tinvwl_product_add_to_cart_redirect_url', $_product->add_to_cart_url(), $_product );
|
638 |
+
do_action( 'after_get_redirect_url' );
|
639 |
+
remove_filter( 'clean_url', 'tinvwl_clean_url', 10 );
|
640 |
+
|
641 |
+
// restore global product data.
|
642 |
+
$product = $_product_tmp;
|
643 |
+
|
644 |
+
if ( $_redirect_url !== $need_url && $_redirect_url !== $need_url_full ) {
|
645 |
+
return true;
|
646 |
+
}
|
647 |
+
|
648 |
+
return $redirect;
|
649 |
+
}
|
650 |
+
|
651 |
+
add_filter( 'tinvwl_product_add_to_cart_need_redirect', 'tinvwl_add_to_cart_need_redirect', 10, 3 );
|
652 |
+
} // End if().
|
653 |
+
|
654 |
+
if ( ! function_exists( 'tinvwl_meta_validate_cart_add' ) ) {
|
655 |
+
|
656 |
+
/**
|
657 |
+
* Checks the ability to add a product
|
658 |
+
*
|
659 |
+
* @param boolean $redirect Default value to redirect.
|
660 |
+
* @param \WC_Product $product Product data.
|
661 |
+
* @param string $redirect_url Current url for redirect.
|
662 |
+
* @param array $wl_product Wishlist Product.
|
663 |
+
*
|
664 |
+
* @return boolean
|
665 |
+
*/
|
666 |
+
function tinvwl_meta_validate_cart_add( $redirect, $product, $redirect_url, $wl_product ) {
|
667 |
+
if ( $redirect && array_key_exists( 'meta', $wl_product ) && ! empty( $wl_product['meta'] ) ) {
|
668 |
+
|
669 |
+
TInvWL_Public_Cart::prepare_post( $wl_product );
|
670 |
+
|
671 |
+
$wl_product = apply_filters( 'tinvwl_addproduct_tocart', $wl_product );
|
672 |
+
$product_id = apply_filters( 'woocommerce_add_to_cart_product_id', absint( $wl_product['product_id'] ) );
|
673 |
+
$quantity = empty( $wl_product['quantity'] ) ? 1 : wc_stock_amount( $wl_product['quantity'] );
|
674 |
+
$variation_id = $wl_product['variation_id'];
|
675 |
+
$variations = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->variation_data : ( $product->is_type( 'variation' ) ? wc_get_product_variation_attributes( $product->get_id() ) : array() ) );
|
676 |
+
$passed_validation = $product->is_purchasable() && ( $product->is_in_stock() || $product->backorders_allowed() ) && 'external' !== ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->product_type : $product->get_type() );
|
677 |
+
ob_start();
|
678 |
+
if ( function_exists( 'wc_clear_notices' ) ) {
|
679 |
+
wc_clear_notices();
|
680 |
+
}
|
681 |
+
$passed_validation = apply_filters( 'woocommerce_add_to_cart_validation', $passed_validation, $product_id, $quantity, $variation_id, $variations );
|
682 |
+
$wc_errors = wc_get_notices( 'error' );
|
683 |
+
$wc_output = ob_get_clean();
|
684 |
+
if ( $passed_validation && empty( $wc_errors ) && empty( $wc_output ) ) {
|
685 |
+
$redirect = false;
|
686 |
+
}
|
687 |
+
|
688 |
+
TInvWL_Public_Cart::unprepare_post();
|
689 |
+
}
|
690 |
+
|
691 |
+
return $redirect;
|
692 |
+
}
|
693 |
+
|
694 |
+
add_filter( 'tinvwl_product_add_to_cart_need_redirect', 'tinvwl_meta_validate_cart_add', 90, 4 );
|
695 |
+
} // End if().
|
696 |
+
|
697 |
+
if ( ! function_exists( 'tinv_wishlist_print_meta' ) ) {
|
698 |
+
|
699 |
+
/**
|
700 |
+
* Print meta data for wishlist form
|
701 |
+
*
|
702 |
+
* @param array $meta Meta Array.
|
703 |
+
* @param boolean $flat Return text or template.
|
704 |
+
*
|
705 |
+
* @return string
|
706 |
+
*/
|
707 |
+
function tinv_wishlist_print_meta( $meta = array(), $flat = false ) {
|
708 |
+
if ( ! is_array( $meta ) ) {
|
709 |
+
$meta = array();
|
710 |
+
}
|
711 |
+
$product_id = $variation_id = 0;
|
712 |
+
if ( array_key_exists( 'product_id', $meta ) ) {
|
713 |
+
$product_id = $meta['product_id'];
|
714 |
+
}
|
715 |
+
if ( array_key_exists( 'variation_id', $meta ) ) {
|
716 |
+
$variation_id = $meta['variation_id'];
|
717 |
+
}
|
718 |
+
foreach ( array( 'add-to-cart', 'product_id', 'variation_id', 'quantity', 'action', 'variation' ) as $field ) {
|
719 |
+
if ( array_key_exists( $field, $meta ) ) {
|
720 |
+
unset( $meta[ $field ] );
|
721 |
+
}
|
722 |
+
}
|
723 |
+
$meta = array_filter( $meta );
|
724 |
+
if ( empty( $meta ) ) {
|
725 |
+
return '';
|
726 |
+
}
|
727 |
+
$item_data = array();
|
728 |
+
foreach ( $meta as $key => $value ) {
|
729 |
+
if ( ! preg_match( '/^\_/', $key ) ) {
|
730 |
+
$item_data[ $key ] = array(
|
731 |
+
'key' => $key,
|
732 |
+
'display' => $value,
|
733 |
+
);
|
734 |
+
}
|
735 |
+
}
|
736 |
+
|
737 |
+
foreach ( array_keys( $item_data ) as $key ) {
|
738 |
+
if ( strpos( $key, 'attribute_' ) === 0 ) {
|
739 |
+
unset( $item_data[ $key ] );
|
740 |
+
}
|
741 |
+
}
|
742 |
+
|
743 |
+
$item_data = apply_filters( 'tinvwl_wishlist_item_meta_post', $item_data, $product_id, $variation_id );
|
744 |
+
foreach ( $item_data as $key => $data ) {
|
745 |
+
if ( is_object( $data['display'] ) || is_array( $data['display'] ) ) {
|
746 |
+
$item_data[ $key ]['display'] = json_encode( $data['display'] );
|
747 |
+
}
|
748 |
+
}
|
749 |
+
ob_start();
|
750 |
+
if ( $flat ) {
|
751 |
+
foreach ( $item_data as $data ) {
|
752 |
+
echo esc_html( $data['key'] ) . ': ' . wp_kses_post( $data['display'] ) . '<br>';
|
753 |
+
}
|
754 |
+
} else {
|
755 |
+
if ( $item_data ) {
|
756 |
+
tinv_wishlist_template( 'ti-wishlist-item-data.php', array( 'item_data' => $item_data ) );
|
757 |
+
}
|
758 |
+
}
|
759 |
+
|
760 |
+
return apply_filters( 'tinvwl_wishlist_item_meta_wishlist', ob_get_clean() );
|
761 |
+
}
|
762 |
+
} // End if().
|
763 |
+
|
764 |
+
if ( ! function_exists( 'tinv_wishlistmeta' ) ) {
|
765 |
+
|
766 |
+
/**
|
767 |
+
* Show new meta data
|
768 |
+
*
|
769 |
+
* @param string $meta Print meta.
|
770 |
+
* @param array $wl_product Wishlist product.
|
771 |
+
* @param \WC_Product $product Woocommerce product.
|
772 |
+
*
|
773 |
+
* @return string
|
774 |
+
*/
|
775 |
+
function tinv_wishlistmeta( $meta = '', $wl_product, $product ) {
|
776 |
+
if ( array_key_exists( 'meta', $wl_product ) ) {
|
777 |
+
$wlmeta = apply_filters( 'tinvwl_wishlist_item_meta_wishlist_output', tinv_wishlist_print_meta( $wl_product['meta'] ), $wl_product, $product );
|
778 |
+
}
|
779 |
+
$meta .= $wlmeta;
|
780 |
+
|
781 |
+
return $meta;
|
782 |
+
}
|
783 |
+
|
784 |
+
add_filter( 'tinvwl_wishlist_item_meta_data', 'tinv_wishlistmeta', 10, 3 );
|
785 |
+
}
|
786 |
+
|
787 |
+
if ( ! function_exists( 'tinvwl_add_to_cart_item_meta_post' ) ) {
|
788 |
+
|
789 |
+
/**
|
790 |
+
* Save post data to cart item
|
791 |
+
*
|
792 |
+
* @param array $cart_item_data Array with cart imet information.
|
793 |
+
* @param string $cart_item_key Cart item key.
|
794 |
+
*
|
795 |
+
* @return array
|
796 |
+
*/
|
797 |
+
function tinvwl_add_to_cart_item_meta_post( $cart_item_data, $cart_item_key ) {
|
798 |
+
$postdata = $_POST; // @codingStandardsIgnoreLine WordPress.VIP.SuperGlobalInputUsage.AccessDetected
|
799 |
+
|
800 |
+
$postdata = apply_filters( 'tinvwl_product_prepare_meta', $postdata );
|
801 |
+
if ( array_key_exists( 'variation_id', $postdata ) && ! empty( $postdata['variation_id'] ) ) {
|
802 |
+
foreach ( $postdata as $key => $field ) {
|
803 |
+
if ( preg_match( '/^attribute\_/', $key ) ) {
|
804 |
+
unset( $postdata[ $key ] );
|
805 |
+
}
|
806 |
+
}
|
807 |
+
}
|
808 |
+
foreach ( array( 'add-to-cart', 'product_id', 'variation_id', 'quantity' ) as $field ) {
|
809 |
+
if ( array_key_exists( $field, $postdata ) ) {
|
810 |
+
unset( $postdata[ $field ] );
|
811 |
+
}
|
812 |
+
}
|
813 |
+
$postdata = array_filter( $postdata );
|
814 |
+
if ( empty( $postdata ) ) {
|
815 |
+
return $cart_item_data;
|
816 |
+
}
|
817 |
+
ksort( $postdata );
|
818 |
+
|
819 |
+
$cart_item_data['tinvwl_formdata'] = $postdata;
|
820 |
+
|
821 |
+
return $cart_item_data;
|
822 |
+
}
|
823 |
+
|
824 |
+
add_action( 'woocommerce_add_cart_item', 'tinvwl_add_to_cart_item_meta_post', 10, 2 );
|
825 |
+
} // End if().
|
826 |
+
|
827 |
+
if ( ! function_exists( 'tinvwl_set_utm' ) ) {
|
828 |
+
|
829 |
+
/**
|
830 |
+
* Set UTM sources.
|
831 |
+
*/
|
832 |
+
function tinvwl_set_utm() {
|
833 |
+
|
834 |
+
// Forcing partners UTM.
|
835 |
+
if ( class_exists( 'Ocean_Extra' ) && ! defined( 'TINVWL_PARTNER' ) && ! defined( 'TINVWL_CAMPAIGN' ) ) {
|
836 |
+
define( 'TINVWL_PARTNER', 'oceanwporg' );
|
837 |
+
define( 'TINVWL_CAMPAIGN', 'oceanwp_theme' );
|
838 |
+
}
|
839 |
+
|
840 |
+
// Set a source.
|
841 |
+
$source = get_option( TINVWL_PREFIX . '_utm_source' );
|
842 |
+
if ( ! $source || $source !== defined( 'TINVWL_PARTNER' ) ) {
|
843 |
+
$source = defined( 'TINVWL_PARTNER' ) ? TINVWL_PARTNER : 'wordpress_org';
|
844 |
+
update_option( TINVWL_PREFIX . '_utm_source', $source );
|
845 |
+
}
|
846 |
+
|
847 |
+
define( 'TINVWL_UTM_SOURCE', $source );
|
848 |
+
|
849 |
+
// Set a medium.
|
850 |
+
$medium = get_option( TINVWL_PREFIX . '_utm_medium' );
|
851 |
+
if ( ! $medium || ( 'organic' === $medium && defined( 'TINVWL_PARTNER' ) ) ) {
|
852 |
+
$medium = defined( 'TINVWL_PARTNER' ) ? 'integration' : 'organic';
|
853 |
+
update_option( TINVWL_PREFIX . '_utm_medium', $medium );
|
854 |
+
}
|
855 |
+
|
856 |
+
define( 'TINVWL_UTM_MEDIUM', $medium );
|
857 |
+
|
858 |
+
// Set a campaign.
|
859 |
+
$campaign = get_option( TINVWL_PREFIX . '_utm_campaign' );
|
860 |
+
if ( ! $campaign || $campaign !== defined( 'TINVWL_CAMPAIGN' ) ) {
|
861 |
+
$campaign = defined( 'TINVWL_PARTNER' ) ? ( defined( 'TINVWL_CAMPAIGN' ) ? TINVWL_CAMPAIGN : TINVWL_PARTNER ) : 'organic';
|
862 |
+
update_option( TINVWL_PREFIX . '_utm_campaign', $campaign );
|
863 |
+
}
|
864 |
+
|
865 |
+
define( 'TINVWL_UTM_CAMPAIGN', $campaign );
|
866 |
+
}
|
867 |
+
} // End if().
|
868 |
+
|
869 |
+
if ( ! function_exists( 'is_wishlist' ) ) {
|
870 |
+
|
871 |
+
/**
|
872 |
+
* is_wishlist - Returns true when viewing the wishlist page.
|
873 |
+
*
|
874 |
+
* @return bool
|
875 |
+
*/
|
876 |
+
function is_wishlist() {
|
877 |
+
return ( is_page( apply_filters( 'wpml_object_id', tinv_get_option( 'page', 'wishlist' ), 'page', true ) ) );
|
878 |
+
}
|
879 |
+
}
|
880 |
+
|
881 |
+
if ( ! function_exists( 'tinvwl_get_wishlist_products' ) ) {
|
882 |
+
/**
|
883 |
+
* Get wishlist products for default user wishlist or by ID or SHAREKEY
|
884 |
+
*
|
885 |
+
* @param int $wishlist_id by ID or SHAREKEY, 0 = default wishlist of current user
|
886 |
+
* @param array $data query parameters for get() method of TInvWL_Product() class.
|
887 |
+
*
|
888 |
+
* @return array|bool
|
889 |
+
*/
|
890 |
+
function tinvwl_get_wishlist_products( $wishlist_id = 0, $data = array() ) {
|
891 |
+
$wishlist = tinv_wishlist_get( $wishlist_id );
|
892 |
+
if ( empty( $wishlist ) ) {
|
893 |
+
return false;
|
894 |
+
}
|
895 |
+
$wlp = new TInvWL_Product( $wishlist );
|
896 |
+
$products = $wlp->get_wishlist( $data );
|
897 |
+
|
898 |
+
if ( empty( $products ) ) {
|
899 |
+
return false;
|
900 |
+
}
|
901 |
+
|
902 |
+
return $products;
|
903 |
+
}
|
904 |
+
}
|