WooCommerce Variation Swatches - Version 2.0.12

Version Description

  • 31-10-2022 =

  • Update: Update Migration Script

  • Update: Modify woo_variation_swatches_variable_item_custom_attributes filter

Download this release

Release Info

Developer EmranAhmed
Plugin Icon 128x128 WooCommerce Variation Swatches
Version 2.0.12
Comparing to
See all releases

Code changes from version 2.0.11 to 2.0.12

README.txt CHANGED
@@ -2,11 +2,11 @@
2
  Contributors: EmranAhmed, getwooplugins
3
  Tags: woocommerce variation swatches, woocommerce variation, woocommerce, variation swatches, woocommerce attributes, product attributes, product color, product size, variable product attributes, variation product swatches, color variation swatch, image variation swatch, printful color swatches
4
  Requires PHP: 7.0
5
- Requires at least: 5.5
6
- Tested up to: 6.0
7
- WC requires at least: 5.5
8
- WC tested up to: 6.9
9
- Stable tag: 2.0.11
10
  License: GPLv3
11
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
12
 
@@ -616,6 +616,11 @@ And your are ready to go.
616
 
617
  == Changelog ==
618
 
 
 
 
 
 
619
  = 2.0.11 - 28-09-2022 =
620
 
621
  * Update: WooCommerce Support
2
  Contributors: EmranAhmed, getwooplugins
3
  Tags: woocommerce variation swatches, woocommerce variation, woocommerce, variation swatches, woocommerce attributes, product attributes, product color, product size, variable product attributes, variation product swatches, color variation swatch, image variation swatch, printful color swatches
4
  Requires PHP: 7.0
5
+ Requires at least: 5.6
6
+ Tested up to: 6.1
7
+ WC requires at least: 5.6
8
+ WC tested up to: 7.0
9
+ Stable tag: 2.0.12
10
  License: GPLv3
11
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
12
 
616
 
617
  == Changelog ==
618
 
619
+ = 2.0.12 - 31-10-2022 =
620
+
621
+ * Update: Update Migration Script
622
+ * Update: Modify `woo_variation_swatches_variable_item_custom_attributes` filter
623
+
624
  = 2.0.11 - 28-09-2022 =
625
 
626
  * Update: WooCommerce Support
assets/css/admin.css CHANGED
@@ -2,7 +2,7 @@
2
  * Variation Swatches for WooCommerce
3
  *
4
  * Author: Emran Ahmed ( emran.bd.08@gmail.com )
5
- * Date: 9/29/2022, 5:01:11 PM
6
  * Released under the GPLv3 license.
7
  */
8
  .button.button-danger {
2
  * Variation Swatches for WooCommerce
3
  *
4
  * Author: Emran Ahmed ( emran.bd.08@gmail.com )
5
+ * Date: 11/2/2022, 6:55:15 PM
6
  * Released under the GPLv3 license.
7
  */
8
  .button.button-danger {
assets/css/frontend.css CHANGED
@@ -2,7 +2,7 @@
2
  * Variation Swatches for WooCommerce
3
  *
4
  * Author: Emran Ahmed ( emran.bd.08@gmail.com )
5
- * Date: 9/29/2022, 5:01:11 PM
6
  * Released under the GPLv3 license.
7
  */
8
  .woo-variation-swatches.wvs-tooltip .radio-variable-item[data-wvstooltip] {
2
  * Variation Swatches for WooCommerce
3
  *
4
  * Author: Emran Ahmed ( emran.bd.08@gmail.com )
5
+ * Date: 11/2/2022, 6:55:15 PM
6
  * Released under the GPLv3 license.
7
  */
8
  .woo-variation-swatches.wvs-tooltip .radio-variable-item[data-wvstooltip] {
assets/js/admin.js CHANGED
@@ -2,7 +2,7 @@
2
  * Variation Swatches for WooCommerce
3
  *
4
  * Author: Emran Ahmed ( emran.bd.08@gmail.com )
5
- * Date: 9/29/2022, 5:01:11 PM
6
  * Released under the GPLv3 license.
7
  */
8
  /******/ (function() { // webpackBootstrap
2
  * Variation Swatches for WooCommerce
3
  *
4
  * Author: Emran Ahmed ( emran.bd.08@gmail.com )
5
+ * Date: 11/2/2022, 6:55:15 PM
6
  * Released under the GPLv3 license.
7
  */
8
  /******/ (function() { // webpackBootstrap
assets/js/frontend.js CHANGED
@@ -2,7 +2,7 @@
2
  * Variation Swatches for WooCommerce
3
  *
4
  * Author: Emran Ahmed ( emran.bd.08@gmail.com )
5
- * Date: 9/29/2022, 5:01:11 PM
6
  * Released under the GPLv3 license.
7
  */
8
  /******/ (function() { // webpackBootstrap
@@ -13,6 +13,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
13
 
14
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
15
 
 
 
 
 
 
 
 
 
16
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
17
 
18
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -25,22 +33,45 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
25
 
26
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
27
 
28
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
29
-
30
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
31
-
32
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
33
-
34
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
35
-
36
  // ================================================================
37
  // WooCommerce Variation Swatches
38
  // ================================================================
39
 
40
- /*global _, wc_add_to_cart_variation_params, woo_variation_swatches_options */
41
  (function (window) {
42
  'use strict';
43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  var Plugin = function ($) {
45
  return /*#__PURE__*/function () {
46
  function _class2(element, options, name) {
@@ -409,10 +440,10 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
409
  value: function findStockVariations(allVariations, selectedAttributes) {
410
  var found = [];
411
 
412
- for (var _i = 0, _Object$entries = Object.entries(selectedAttributes.data); _i < _Object$entries.length; _i++) {
413
- var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
414
- attribute_name = _Object$entries$_i[0],
415
- attribute_value = _Object$entries$_i[1];
416
 
417
  if (attribute_value.length === 0) {
418
  var values = this.$element.find("ul[data-attribute_name='".concat(attribute_name, "']")).data('attribute_values') || [];
@@ -552,6 +583,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
552
  }();
553
  // This entry need to be wrapped in an IIFE because it need to be isolated against other entry modules.
554
  !function() {
 
555
  jQuery(function ($) {
556
  try {
557
  $(document).on('woo_variation_swatches_init', function () {
@@ -576,7 +608,7 @@ jQuery(function ($) {
576
  $('.variations_form:not(.wvs-loaded)').each(function () {
577
  $(this).wc_variation_form();
578
  });
579
- }, 100);
580
  }); // Composite Product Load
581
  // JS API: https://docs.woocommerce.com/document/composite-products/composite-products-js-api-reference/
582
 
2
  * Variation Swatches for WooCommerce
3
  *
4
  * Author: Emran Ahmed ( emran.bd.08@gmail.com )
5
+ * Date: 11/2/2022, 6:55:15 PM
6
  * Released under the GPLv3 license.
7
  */
8
  /******/ (function() { // webpackBootstrap
13
 
14
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
15
 
16
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
17
+
18
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
19
+
20
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
21
+
22
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
23
+
24
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
25
 
26
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
33
 
34
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
35
 
 
 
 
 
 
 
 
 
36
  // ================================================================
37
  // WooCommerce Variation Swatches
38
  // ================================================================
39
 
40
+ /*global wp, _, wc_add_to_cart_variation_params, woo_variation_swatches_options */
41
  (function (window) {
42
  'use strict';
43
 
44
+ var isWooVariationSwatchesAPIRequest = function isWooVariationSwatchesAPIRequest(options) {
45
+ return !!options.path && options.path.indexOf('woo-variation-swatches') !== -1 || !!options.url && options.url.indexOf('woo-variation-swatches') !== -1;
46
+ };
47
+
48
+ window.createMiddlewareForExtraQueryParams = function () {
49
+ var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
50
+ return function (options, next) {
51
+ if (isWooVariationSwatchesAPIRequest(options) && Object.keys(args).length > 0) {
52
+ for (var _i = 0, _Object$entries = Object.entries(args); _i < _Object$entries.length; _i++) {
53
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
54
+ key = _Object$entries$_i[0],
55
+ value = _Object$entries$_i[1];
56
+
57
+ if (typeof options.url === 'string' && !wp.url.hasQueryArg(options.url, key)) {
58
+ options.url = wp.url.addQueryArgs(options.url, _defineProperty({}, key, value));
59
+ }
60
+
61
+ if (typeof options.path === 'string' && !wp.url.hasQueryArg(options.path, key)) {
62
+ options.path = wp.url.addQueryArgs(options.path, _defineProperty({}, key, value));
63
+ }
64
+ }
65
+ }
66
+
67
+ return next(options);
68
+ };
69
+ };
70
+ /*
71
+ wp.apiFetch.use((options, next) => createMiddlewareForExtraQueryParams({'lang':'en'}));
72
+ */
73
+
74
+
75
  var Plugin = function ($) {
76
  return /*#__PURE__*/function () {
77
  function _class2(element, options, name) {
440
  value: function findStockVariations(allVariations, selectedAttributes) {
441
  var found = [];
442
 
443
+ for (var _i2 = 0, _Object$entries2 = Object.entries(selectedAttributes.data); _i2 < _Object$entries2.length; _i2++) {
444
+ var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
445
+ attribute_name = _Object$entries2$_i[0],
446
+ attribute_value = _Object$entries2$_i[1];
447
 
448
  if (attribute_value.length === 0) {
449
  var values = this.$element.find("ul[data-attribute_name='".concat(attribute_name, "']")).data('attribute_values') || [];
583
  }();
584
  // This entry need to be wrapped in an IIFE because it need to be isolated against other entry modules.
585
  !function() {
586
+ /*global wp, _, wc_add_to_cart_variation_params, woo_variation_swatches_options */
587
  jQuery(function ($) {
588
  try {
589
  $(document).on('woo_variation_swatches_init', function () {
608
  $('.variations_form:not(.wvs-loaded)').each(function () {
609
  $(this).wc_variation_form();
610
  });
611
+ }, 1000);
612
  }); // Composite Product Load
613
  // JS API: https://docs.woocommerce.com/document/composite-products/composite-products-js-api-reference/
614
 
assets/js/frontend.min.js CHANGED
@@ -1 +1 @@
1
- !function(){function t(e){return t="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(e)}function e(t,e){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=i(t))||e&&t&&"number"==typeof t.length){a&&(t=a);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,s=!0,l=!1;return{s:function(){a=a.call(t)},n:function(){var t=a.next();return s=t.done,t},e:function(t){l=!0,r=t},f:function(){try{s||null==a.return||a.return()}finally{if(l)throw r}}}}function a(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var a=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=a){var i,n,o=[],r=!0,s=!1;try{for(a=a.call(t);!(r=(i=a.next()).done)&&(o.push(i.value),!e||o.length!==e);r=!0);}catch(t){s=!0,n=t}finally{try{r||null==a.return||a.return()}finally{if(s)throw n}}return o}}(t,e)||i(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,e){if(t){if("string"==typeof t)return n(t,e);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?n(t,e):void 0}}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var a=0,i=new Array(e);a<e;a++)i[a]=t[a];return i}function o(t,e){for(var a=0;a<e.length;a++){var i=e[a];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function r(t,e,a){return e in t?Object.defineProperty(t,e,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[e]=a,t}!function(i){"use strict";var n,s=(n=jQuery,function(){function t(e,a,i){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),r(this,"defaults",{}),this.name=i,this.element=e,this.$element=n(e),this.settings=n.extend(!0,{},this.defaults,a),this.product_variations=this.$element.data("product_variations")||[],this.is_ajax_variation=this.product_variations.length<1,this.product_id=this.$element.data("product_id"),this.reset_variations=this.$element.find(".reset_variations"),this.attributeFields=this.$element.find(".variations select"),this.selected_item_template='<span class="woo-selected-variation-item-name" data-default=""></span>',this.$element.addClass("wvs-loaded"),this.init(),this.update(),n(document).trigger("woo_variation_swatches_loaded",this)}var i,s,l;return i=t,(s=[{key:"isAjaxVariation",value:function(){return this.is_ajax_variation}},{key:"init",value:function(){this.prepareLabel(),this.prepareItems(),this.setupItems(),this.setupEvents(),this.setUpStockInfo()}},{key:"prepareLabel",value:function(){var t=this;woo_variation_swatches_options.show_variation_label&&this.$element.find(".variations .label").each((function(e,a){n(a).append(t.selected_item_template)}))}},{key:"prepareItems",value:function(){this.$element.find("ul.variable-items-wrapper").each((function(t,e){n(e).parent().addClass("woo-variation-items-wrapper")}))}},{key:"setupItems",value:function(){var t=this;this.$element.find("ul.variable-items-wrapper").each((function(e,a){var i="",o=n(a).parent().prev().find(".woo-selected-variation-item-name"),r=n(a).parent().find("select.woo-variation-raw-select"),s=r.find("option"),l=r.find("option:disabled"),c=r.find("option.enabled.out-of-stock"),u=r.find("option:selected"),d=r.find("option").eq(1),v=[],f=[],h=[];s.each((function(){""!==n(this).val()&&(v.push(n(this).val()),i=0===u.length?d.val():u.val())})),l.each((function(){""!==n(this).val()&&f.push(n(this).val())})),c.each((function(){""!==n(this).val()&&h.push(n(this).val())}));var p=_.difference(v,f);t.setupItem(a,i,p,h,o)}))}},{key:"setupItem",value:function(t,e,a,i,o){var r=this;n(t).find("li.variable-item").each((function(t,s){var l=n(s).attr("data-value"),c=n(s).attr("data-title");n(s).removeClass("selected disabled no-stock").addClass("disabled"),n(s).attr("aria-checked","false"),n(s).attr("tabindex","-1"),n(s).attr("data-wvstooltip-out-of-stock",""),n(s).find("input.variable-item-radio-input:radio").prop("disabled",!0).prop("checked",!1),e.length<1&&woo_variation_swatches_options.show_variation_label&&o.text(""),r.isAjaxVariation()?(n(s).find("input.variable-item-radio-input:radio").prop("disabled",!1),n(s).removeClass("selected disabled no-stock"),l===e&&(n(s).addClass("selected"),n(s).attr("aria-checked","true"),n(s).attr("tabindex","0"),n(s).find("input.variable-item-radio-input:radio").prop("disabled",!1).prop("checked",!0),woo_variation_swatches_options.show_variation_label&&o.text("".concat(woo_variation_swatches_options.variation_label_separator," ").concat(c)),n(s).trigger("wvs-item-updated",[e,l]))):(_.includes(a,l)&&(n(s).removeClass("selected disabled"),n(s).removeAttr("aria-hidden"),n(s).attr("tabindex","0"),n(s).find("input.variable-item-radio-input:radio").prop("disabled",!1),l===e&&(n(s).addClass("selected"),n(s).attr("aria-checked","true"),n(s).find("input.variable-item-radio-input:radio").prop("checked",!0),woo_variation_swatches_options.show_variation_label&&o.text("".concat(woo_variation_swatches_options.variation_label_separator," ").concat(c)),n(s).trigger("wvs-item-updated",[e,l]))),_.includes(i,l)&&woo_variation_swatches_options.clickable_out_of_stock&&(n(s).removeClass("disabled").addClass("no-stock"),n(s).attr("data-wvstooltip-out-of-stock",woo_variation_swatches_options.out_of_stock_tooltip_text)))}))}},{key:"setupEvents",value:function(){var t=this;this.$element.find("ul.variable-items-wrapper").each((function(e,a){var i=n(a).parent().find("select.woo-variation-raw-select");woo_variation_swatches_options.clear_on_reselect?(n(a).on("click.wvs","li.variable-item:not(.selected):not(.radio-variable-item)",(function(e){e.preventDefault(),e.stopPropagation();var a=n(this).data("value");i.val(a).trigger("change"),i.trigger("click"),woo_variation_swatches_options.is_mobile,n(this).trigger("wvs-selected-item",[a,i,t.$element])})),n(a).on("click.wvs","li.variable-item.selected:not(.radio-variable-item)",(function(e){e.preventDefault(),e.stopPropagation();var a=n(this).val();i.val("").trigger("change"),i.trigger("click"),woo_variation_swatches_options.is_mobile,n(this).trigger("wvs-unselected-item",[a,i,t.$element])})),n(a).on("click.wvs","input.variable-item-radio-input:radio",(function(t){t.stopPropagation(),n(this).trigger("change.wvs",{radioChange:!0})})),n(a).on("change.wvs","input.variable-item-radio-input:radio",(function(e,a){if(e.preventDefault(),e.stopPropagation(),a&&a.radioChange){var o=n(this).val();n(this).parent("li.radio-variable-item").hasClass("selected")?(i.val("").trigger("change"),n(this).parent("li.radio-variable-item").trigger("wvs-unselected-item",[o,i,t.$element])):(i.val(o).trigger("change"),n(this).parent("li.radio-variable-item").trigger("wvs-selected-item",[o,i,t.$element])),i.trigger("click"),woo_variation_swatches_options.is_mobile}}))):(n(a).on("click.wvs","li.variable-item:not(.radio-variable-item)",(function(e){e.preventDefault(),e.stopPropagation();var a=n(this).data("value");i.val(a).trigger("change"),i.trigger("click"),woo_variation_swatches_options.is_mobile,n(this).trigger("wvs-selected-item",[a,i,t.$element])})),n(a).on("change.wvs","input.variable-item-radio-input:radio",(function(e){e.preventDefault(),e.stopPropagation();var a=n(this).val();i.val(a).trigger("change"),i.trigger("click"),woo_variation_swatches_options.is_mobile,n(this).parent("li.radio-variable-item").removeClass("selected disabled no-stock").addClass("selected"),n(this).parent("li.radio-variable-item").trigger("wvs-selected-item",[a,i,t.$element])}))),n(a).on("keydown.wvs","li.variable-item:not(.disabled)",(function(t){(t.keyCode&&32===t.keyCode||t.key&&" "===t.key||t.keyCode&&13===t.keyCode||t.key&&"enter"===t.key.toLowerCase())&&(t.preventDefault(),n(this).trigger("click"))}))})),this.$element.on("click.wvs",".woo-variation-swatches-variable-item-more",(function(t){t.preventDefault(),n(this).parent().removeClass("enabled-display-limit-mode enabled-catalog-display-limit-mode"),n(this).remove()}))}},{key:"update",value:function(){var t=this;this.$element.on("woocommerce_variation_has_changed.wvs",(function(e){t.setupItems()}))}},{key:"setUpStockInfo",value:function(){var t=this;if(woo_variation_swatches_options.show_variation_stock){var e=parseInt(woo_variation_swatches_options.stock_label_threshold,10);this.$element.on("wvs-selected-item.wvs",(function(a){var i=t.getChosenAttributes(),n=t.findStockVariations(t.product_variations,i);i.count>1&&i.count===i.chosenCount&&t.resetStockInfo(),i.count>1&&i.count===i.mayChosenCount&&n.forEach((function(a){var i='[data-attribute_name="'.concat(a.attribute_name,'"] > [data-value="').concat(a.attribute_value,'"]');a.variation.is_in_stock&&a.variation.max_qty&&a.variation.variation_stock_left&&a.variation.max_qty<=e?(t.$element.find("".concat(i," .wvs-stock-left-info")).attr("data-wvs-stock-info",a.variation.variation_stock_left),t.$element.find(i).addClass("wvs-show-stock-left-info")):(t.$element.find(i).removeClass("wvs-show-stock-left-info"),t.$element.find("".concat(i," .wvs-stock-left-info")).attr("data-wvs-stock-info",""))}))})),this.$element.on("hide_variation.wvs",(function(){t.resetStockInfo()}))}}},{key:"resetStockInfo",value:function(){this.$element.find(".variable-item").removeClass("wvs-show-stock-left-info"),this.$element.find(".wvs-stock-left-info").attr("data-wvs-stock-info","")}},{key:"getChosenAttributes",value:function(){var t={},e=0,a=0;return this.attributeFields.each((function(){var i=n(this).data("attribute_name")||n(this).attr("name"),o=n(this).val()||"";o.length>0&&a++,e++,t[i]=o})),{count:e,chosenCount:a,mayChosenCount:a+1,data:t}}},{key:"findStockVariations",value:function(t,i){for(var n=[],o=0,s=Object.entries(i.data);o<s.length;o++){var l=a(s[o],2),c=l[0];if(0===l[1].length){var u,d=e(this.$element.find("ul[data-attribute_name='".concat(c,"']")).data("attribute_values")||[]);try{for(d.s();!(u=d.n()).done;){var v=u.value,f=_.extend(i.data,r({},c,v)),h=this.findMatchingVariations(t,f);if(h.length>0){var p=h.shift(),m={};m.attribute_name=c,m.attribute_value=v,m.variation=p,n.push(m)}}}catch(t){d.e(t)}finally{d.f()}}}return n}},{key:"findMatchingVariations",value:function(t,e){for(var a=[],i=0;i<t.length;i++){var n=t[i];this.isMatch(n.attributes,e)&&a.push(n)}return a}},{key:"isMatch",value:function(t,e){var a=!0;for(var i in t)if(t.hasOwnProperty(i)){var n=t[i],o=e[i];void 0!==n&&void 0!==o&&0!==n.length&&0!==o.length&&n!==o&&(a=!1)}return a}},{key:"destroy",value:function(){this.$element.removeClass("wvs-loaded"),this.$element.removeData(this.name)}}])&&o(i.prototype,s),l&&o(i,l),Object.defineProperty(i,"prototype",{writable:!1}),t}()),l=function(e){return function(a,i){e.fn[a]=function(n){for(var o=this,r=arguments.length,s=new Array(r>1?r-1:0),l=1;l<r;l++)s[l-1]=arguments[l];return this.each((function(r,l){var c=e(l),u=c.data(a);if(u||(u=new i(c,e.extend({},n),a),c.data(a,u)),"string"==typeof n){if("object"===t(u[n]))return u[n];var d;if("function"==typeof u[n])return(d=u)[n].apply(d,s)}return o}))},e.fn[a].Constructor=i,e[a]=function(t){for(var i,n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];return(i=e({}))[a].apply(i,[t].concat(o))},e.fn[a].noConflict=function(){return e.fn[a]}}}(jQuery);l("WooVariationSwatches",s)}(window)}(),jQuery((function(t){try{t(document).on("woo_variation_swatches_init",(function(){t(".variations_form:not(.wvs-loaded)").WooVariationSwatches(),t(".woo_variation_swatches_variations_form:not(.wvs-loaded)").WooVariationSwatches(),t(".ywcp_inner_selected_container:not(.wvs-loaded)").WooVariationSwatches()}))}catch(t){window.console.log("Variation Swatches:",t)}t(document).on("wc_variation_form.wvs",(function(e){t(document).trigger("woo_variation_swatches_init")})),t(document).ajaxComplete((function(e,a,i){_.delay((function(){t(".variations_form:not(.wvs-loaded)").each((function(){t(this).wc_variation_form()}))}),100)})),t(document.body).on("wc-composite-initializing",".composite_data",(function(e,a){a.actions.add_action("component_options_state_changed",(function(e){t(e.$component_content).find(".variations_form").WooVariationSwatches("destroy")}))}))}));
1
+ !function(){function t(e){return t="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(e)}function e(t,e){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=o(t))||e&&t&&"number"==typeof t.length){a&&(t=a);var i=0,n=function(){};return{s:n,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,s=!0,l=!1;return{s:function(){a=a.call(t)},n:function(){var t=a.next();return s=t.done,t},e:function(t){l=!0,r=t},f:function(){try{s||null==a.return||a.return()}finally{if(l)throw r}}}}function a(t,e){for(var a=0;a<e.length;a++){var i=e[a];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function i(t,e,a){return e in t?Object.defineProperty(t,e,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[e]=a,t}function n(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var a=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=a){var i,n,o=[],r=!0,s=!1;try{for(a=a.call(t);!(r=(i=a.next()).done)&&(o.push(i.value),!e||o.length!==e);r=!0);}catch(t){s=!0,n=t}finally{try{r||null==a.return||a.return()}finally{if(s)throw n}}return o}}(t,e)||o(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(t,e){if(t){if("string"==typeof t)return r(t,e);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?r(t,e):void 0}}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var a=0,i=new Array(e);a<e;a++)i[a]=t[a];return i}!function(o){"use strict";var r=function(t){return!!t.path&&-1!==t.path.indexOf("woo-variation-swatches")||!!t.url&&-1!==t.url.indexOf("woo-variation-swatches")};o.createMiddlewareForExtraQueryParams=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(e,a){if(r(e)&&Object.keys(t).length>0)for(var o=0,s=Object.entries(t);o<s.length;o++){var l=n(s[o],2),c=l[0],u=l[1];"string"!=typeof e.url||wp.url.hasQueryArg(e.url,c)||(e.url=wp.url.addQueryArgs(e.url,i({},c,u))),"string"!=typeof e.path||wp.url.hasQueryArg(e.path,c)||(e.path=wp.url.addQueryArgs(e.path,i({},c,u)))}return a(e)}};var s,l=(s=jQuery,function(){function t(e,a,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),i(this,"defaults",{}),this.name=n,this.element=e,this.$element=s(e),this.settings=s.extend(!0,{},this.defaults,a),this.product_variations=this.$element.data("product_variations")||[],this.is_ajax_variation=this.product_variations.length<1,this.product_id=this.$element.data("product_id"),this.reset_variations=this.$element.find(".reset_variations"),this.attributeFields=this.$element.find(".variations select"),this.selected_item_template='<span class="woo-selected-variation-item-name" data-default=""></span>',this.$element.addClass("wvs-loaded"),this.init(),this.update(),s(document).trigger("woo_variation_swatches_loaded",this)}var o,r,l;return o=t,(r=[{key:"isAjaxVariation",value:function(){return this.is_ajax_variation}},{key:"init",value:function(){this.prepareLabel(),this.prepareItems(),this.setupItems(),this.setupEvents(),this.setUpStockInfo()}},{key:"prepareLabel",value:function(){var t=this;woo_variation_swatches_options.show_variation_label&&this.$element.find(".variations .label").each((function(e,a){s(a).append(t.selected_item_template)}))}},{key:"prepareItems",value:function(){this.$element.find("ul.variable-items-wrapper").each((function(t,e){s(e).parent().addClass("woo-variation-items-wrapper")}))}},{key:"setupItems",value:function(){var t=this;this.$element.find("ul.variable-items-wrapper").each((function(e,a){var i="",n=s(a).parent().prev().find(".woo-selected-variation-item-name"),o=s(a).parent().find("select.woo-variation-raw-select"),r=o.find("option"),l=o.find("option:disabled"),c=o.find("option.enabled.out-of-stock"),u=o.find("option:selected"),d=o.find("option").eq(1),v=[],f=[],h=[];r.each((function(){""!==s(this).val()&&(v.push(s(this).val()),i=0===u.length?d.val():u.val())})),l.each((function(){""!==s(this).val()&&f.push(s(this).val())})),c.each((function(){""!==s(this).val()&&h.push(s(this).val())}));var p=_.difference(v,f);t.setupItem(a,i,p,h,n)}))}},{key:"setupItem",value:function(t,e,a,i,n){var o=this;s(t).find("li.variable-item").each((function(t,r){var l=s(r).attr("data-value"),c=s(r).attr("data-title");s(r).removeClass("selected disabled no-stock").addClass("disabled"),s(r).attr("aria-checked","false"),s(r).attr("tabindex","-1"),s(r).attr("data-wvstooltip-out-of-stock",""),s(r).find("input.variable-item-radio-input:radio").prop("disabled",!0).prop("checked",!1),e.length<1&&woo_variation_swatches_options.show_variation_label&&n.text(""),o.isAjaxVariation()?(s(r).find("input.variable-item-radio-input:radio").prop("disabled",!1),s(r).removeClass("selected disabled no-stock"),l===e&&(s(r).addClass("selected"),s(r).attr("aria-checked","true"),s(r).attr("tabindex","0"),s(r).find("input.variable-item-radio-input:radio").prop("disabled",!1).prop("checked",!0),woo_variation_swatches_options.show_variation_label&&n.text("".concat(woo_variation_swatches_options.variation_label_separator," ").concat(c)),s(r).trigger("wvs-item-updated",[e,l]))):(_.includes(a,l)&&(s(r).removeClass("selected disabled"),s(r).removeAttr("aria-hidden"),s(r).attr("tabindex","0"),s(r).find("input.variable-item-radio-input:radio").prop("disabled",!1),l===e&&(s(r).addClass("selected"),s(r).attr("aria-checked","true"),s(r).find("input.variable-item-radio-input:radio").prop("checked",!0),woo_variation_swatches_options.show_variation_label&&n.text("".concat(woo_variation_swatches_options.variation_label_separator," ").concat(c)),s(r).trigger("wvs-item-updated",[e,l]))),_.includes(i,l)&&woo_variation_swatches_options.clickable_out_of_stock&&(s(r).removeClass("disabled").addClass("no-stock"),s(r).attr("data-wvstooltip-out-of-stock",woo_variation_swatches_options.out_of_stock_tooltip_text)))}))}},{key:"setupEvents",value:function(){var t=this;this.$element.find("ul.variable-items-wrapper").each((function(e,a){var i=s(a).parent().find("select.woo-variation-raw-select");woo_variation_swatches_options.clear_on_reselect?(s(a).on("click.wvs","li.variable-item:not(.selected):not(.radio-variable-item)",(function(e){e.preventDefault(),e.stopPropagation();var a=s(this).data("value");i.val(a).trigger("change"),i.trigger("click"),woo_variation_swatches_options.is_mobile,s(this).trigger("wvs-selected-item",[a,i,t.$element])})),s(a).on("click.wvs","li.variable-item.selected:not(.radio-variable-item)",(function(e){e.preventDefault(),e.stopPropagation();var a=s(this).val();i.val("").trigger("change"),i.trigger("click"),woo_variation_swatches_options.is_mobile,s(this).trigger("wvs-unselected-item",[a,i,t.$element])})),s(a).on("click.wvs","input.variable-item-radio-input:radio",(function(t){t.stopPropagation(),s(this).trigger("change.wvs",{radioChange:!0})})),s(a).on("change.wvs","input.variable-item-radio-input:radio",(function(e,a){if(e.preventDefault(),e.stopPropagation(),a&&a.radioChange){var n=s(this).val();s(this).parent("li.radio-variable-item").hasClass("selected")?(i.val("").trigger("change"),s(this).parent("li.radio-variable-item").trigger("wvs-unselected-item",[n,i,t.$element])):(i.val(n).trigger("change"),s(this).parent("li.radio-variable-item").trigger("wvs-selected-item",[n,i,t.$element])),i.trigger("click"),woo_variation_swatches_options.is_mobile}}))):(s(a).on("click.wvs","li.variable-item:not(.radio-variable-item)",(function(e){e.preventDefault(),e.stopPropagation();var a=s(this).data("value");i.val(a).trigger("change"),i.trigger("click"),woo_variation_swatches_options.is_mobile,s(this).trigger("wvs-selected-item",[a,i,t.$element])})),s(a).on("change.wvs","input.variable-item-radio-input:radio",(function(e){e.preventDefault(),e.stopPropagation();var a=s(this).val();i.val(a).trigger("change"),i.trigger("click"),woo_variation_swatches_options.is_mobile,s(this).parent("li.radio-variable-item").removeClass("selected disabled no-stock").addClass("selected"),s(this).parent("li.radio-variable-item").trigger("wvs-selected-item",[a,i,t.$element])}))),s(a).on("keydown.wvs","li.variable-item:not(.disabled)",(function(t){(t.keyCode&&32===t.keyCode||t.key&&" "===t.key||t.keyCode&&13===t.keyCode||t.key&&"enter"===t.key.toLowerCase())&&(t.preventDefault(),s(this).trigger("click"))}))})),this.$element.on("click.wvs",".woo-variation-swatches-variable-item-more",(function(t){t.preventDefault(),s(this).parent().removeClass("enabled-display-limit-mode enabled-catalog-display-limit-mode"),s(this).remove()}))}},{key:"update",value:function(){var t=this;this.$element.on("woocommerce_variation_has_changed.wvs",(function(e){t.setupItems()}))}},{key:"setUpStockInfo",value:function(){var t=this;if(woo_variation_swatches_options.show_variation_stock){var e=parseInt(woo_variation_swatches_options.stock_label_threshold,10);this.$element.on("wvs-selected-item.wvs",(function(a){var i=t.getChosenAttributes(),n=t.findStockVariations(t.product_variations,i);i.count>1&&i.count===i.chosenCount&&t.resetStockInfo(),i.count>1&&i.count===i.mayChosenCount&&n.forEach((function(a){var i='[data-attribute_name="'.concat(a.attribute_name,'"] > [data-value="').concat(a.attribute_value,'"]');a.variation.is_in_stock&&a.variation.max_qty&&a.variation.variation_stock_left&&a.variation.max_qty<=e?(t.$element.find("".concat(i," .wvs-stock-left-info")).attr("data-wvs-stock-info",a.variation.variation_stock_left),t.$element.find(i).addClass("wvs-show-stock-left-info")):(t.$element.find(i).removeClass("wvs-show-stock-left-info"),t.$element.find("".concat(i," .wvs-stock-left-info")).attr("data-wvs-stock-info",""))}))})),this.$element.on("hide_variation.wvs",(function(){t.resetStockInfo()}))}}},{key:"resetStockInfo",value:function(){this.$element.find(".variable-item").removeClass("wvs-show-stock-left-info"),this.$element.find(".wvs-stock-left-info").attr("data-wvs-stock-info","")}},{key:"getChosenAttributes",value:function(){var t={},e=0,a=0;return this.attributeFields.each((function(){var i=s(this).data("attribute_name")||s(this).attr("name"),n=s(this).val()||"";n.length>0&&a++,e++,t[i]=n})),{count:e,chosenCount:a,mayChosenCount:a+1,data:t}}},{key:"findStockVariations",value:function(t,a){for(var o=[],r=0,s=Object.entries(a.data);r<s.length;r++){var l=n(s[r],2),c=l[0];if(0===l[1].length){var u,d=e(this.$element.find("ul[data-attribute_name='".concat(c,"']")).data("attribute_values")||[]);try{for(d.s();!(u=d.n()).done;){var v=u.value,f=_.extend(a.data,i({},c,v)),h=this.findMatchingVariations(t,f);if(h.length>0){var p=h.shift(),m={};m.attribute_name=c,m.attribute_value=v,m.variation=p,o.push(m)}}}catch(t){d.e(t)}finally{d.f()}}}return o}},{key:"findMatchingVariations",value:function(t,e){for(var a=[],i=0;i<t.length;i++){var n=t[i];this.isMatch(n.attributes,e)&&a.push(n)}return a}},{key:"isMatch",value:function(t,e){var a=!0;for(var i in t)if(t.hasOwnProperty(i)){var n=t[i],o=e[i];void 0!==n&&void 0!==o&&0!==n.length&&0!==o.length&&n!==o&&(a=!1)}return a}},{key:"destroy",value:function(){this.$element.removeClass("wvs-loaded"),this.$element.removeData(this.name)}}])&&a(o.prototype,r),l&&a(o,l),Object.defineProperty(o,"prototype",{writable:!1}),t}()),c=function(e){return function(a,i){e.fn[a]=function(n){for(var o=this,r=arguments.length,s=new Array(r>1?r-1:0),l=1;l<r;l++)s[l-1]=arguments[l];return this.each((function(r,l){var c=e(l),u=c.data(a);if(u||(u=new i(c,e.extend({},n),a),c.data(a,u)),"string"==typeof n){if("object"===t(u[n]))return u[n];var d;if("function"==typeof u[n])return(d=u)[n].apply(d,s)}return o}))},e.fn[a].Constructor=i,e[a]=function(t){for(var i,n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];return(i=e({}))[a].apply(i,[t].concat(o))},e.fn[a].noConflict=function(){return e.fn[a]}}}(jQuery);c("WooVariationSwatches",l)}(window)}(),jQuery((function(t){try{t(document).on("woo_variation_swatches_init",(function(){t(".variations_form:not(.wvs-loaded)").WooVariationSwatches(),t(".woo_variation_swatches_variations_form:not(.wvs-loaded)").WooVariationSwatches(),t(".ywcp_inner_selected_container:not(.wvs-loaded)").WooVariationSwatches()}))}catch(t){window.console.log("Variation Swatches:",t)}t(document).on("wc_variation_form.wvs",(function(e){t(document).trigger("woo_variation_swatches_init")})),t(document).ajaxComplete((function(e,a,i){_.delay((function(){t(".variations_form:not(.wvs-loaded)").each((function(){t(this).wc_variation_form()}))}),1e3)})),t(document.body).on("wc-composite-initializing",".composite_data",(function(e,a){a.actions.add_action("component_options_state_changed",(function(e){t(e.$component_content).find(".variations_form").WooVariationSwatches("destroy")}))}))}));
assets/js/wp-color-picker-alpha.js CHANGED
@@ -2,7 +2,7 @@
2
  * Variation Swatches for WooCommerce
3
  *
4
  * Author: Emran Ahmed ( emran.bd.08@gmail.com )
5
- * Date: 9/29/2022, 5:01:11 PM
6
  * Released under the GPLv3 license.
7
  */
8
  /******/ (function() { // webpackBootstrap
2
  * Variation Swatches for WooCommerce
3
  *
4
  * Author: Emran Ahmed ( emran.bd.08@gmail.com )
5
+ * Date: 11/2/2022, 6:55:15 PM
6
  * Released under the GPLv3 license.
7
  */
8
  /******/ (function() { // webpackBootstrap
includes/class-woo-variation-swatches-manage-cache.php CHANGED
@@ -67,6 +67,8 @@
67
  WC_Cache_Helper::invalidate_cache_group( 'wvs_variation_attribute_options_html' );
68
  WC_Cache_Helper::invalidate_cache_group( 'wvs_rest_single_product' );
69
  WC_Cache_Helper::invalidate_cache_group( 'wvs_rest_archive_product' );
 
 
70
  }
71
  }
72
  }
67
  WC_Cache_Helper::invalidate_cache_group( 'wvs_variation_attribute_options_html' );
68
  WC_Cache_Helper::invalidate_cache_group( 'wvs_rest_single_product' );
69
  WC_Cache_Helper::invalidate_cache_group( 'wvs_rest_archive_product' );
70
+ WC_Cache_Helper::invalidate_cache_group( 'wvs_rest_archive_product_preview' );
71
+ WC_Cache_Helper::invalidate_cache_group( 'wvs_rest_single_product_preview' );
72
  }
73
  }
74
  }
includes/class-woo-variation-swatches-product-page.php CHANGED
@@ -204,7 +204,14 @@
204
 
205
  $this->add_inline_style();
206
 
207
- wp_register_script( 'woo-variation-swatches', woo_variation_swatches()->assets_url( "/js/frontend{$suffix}.js" ), array( 'jquery', 'wp-util', 'underscore', 'jquery-blockui', 'wp-api-request', 'wp-api-fetch', 'wp-polyfill' ), woo_variation_swatches()->assets_version( "/js/frontend{$suffix}.js" ), true );
 
 
 
 
 
 
 
208
 
209
  wp_localize_script( 'woo-variation-swatches', 'woo_variation_swatches_options', $this->js_options() );
210
 
@@ -355,24 +362,23 @@
355
  $option_slug = $data[ 'option_slug' ];
356
  $slug = $data[ 'slug' ];
357
 
358
-
359
  $is_term = wc_string_to_bool( $data[ 'is_term' ] );
360
 
361
- $css_class = implode( ' ', array_unique( array_values( apply_filters( 'woo_variation_swatches_variable_item_css_class', $this->get_item_css_classes( $data ), $data ) ) ) );
362
 
363
  $html_attributes = array(
364
  'aria-checked' => ( $is_selected ? 'true' : 'false' ),
365
  'tabindex' => ( wp_is_mobile() ? '2' : '0' ),
366
  );
367
 
368
- $html_attributes = wp_parse_args( $this->get_item_tooltip_attribute( $data ), $html_attributes );
369
 
370
- $html_attributes = apply_filters( 'woo_variation_swatches_variable_item_custom_attributes', $html_attributes, $attribute_type, $data );
371
 
372
  return sprintf( '<li %1$s class="variable-item %2$s-variable-item %2$s-variable-item-%3$s %4$s" title="%5$s" data-title="%5$s" data-value="%6$s" role="radio" tabindex="0"><div class="variable-item-contents">', wc_implode_html_attributes( $html_attributes ), esc_attr( $attribute_type ), esc_attr( $option_slug ), esc_attr( $css_class ), esc_html( $option_name ), esc_attr( $slug ) );
373
  }
374
 
375
- public function get_item_css_classes( $data ) {
376
 
377
  $css_classes = array();
378
 
@@ -385,7 +391,7 @@
385
  return $css_classes;
386
  }
387
 
388
- public function get_item_tooltip_attribute( $data ) {
389
 
390
  $html_attributes = array();
391
 
@@ -505,6 +511,19 @@
505
  return $assigned;
506
  }
507
 
 
 
 
 
 
 
 
 
 
 
 
 
 
508
  public function get_image_attribute( $data, $attribute_type, $variation_data = array() ) {
509
  if ( 'image' === $attribute_type ) {
510
 
204
 
205
  $this->add_inline_style();
206
 
207
+ wp_register_script( 'woo-variation-swatches', woo_variation_swatches()->assets_url( "/js/frontend{$suffix}.js" ), array( 'jquery', 'wp-util', 'underscore', 'jquery-blockui', 'wp-api-request', 'wp-api-fetch', 'wp-polyfill', 'wp-url' ), woo_variation_swatches()->assets_version( "/js/frontend{$suffix}.js" ), true );
208
+
209
+ $extra_params_for_rest_uri = apply_filters( 'woo_variation_swatches_rest_add_extra_params', array() );
210
+
211
+ if ( $extra_params_for_rest_uri ) {
212
+ $extra_params_for_rest_uri = map_deep( $extra_params_for_rest_uri, 'sanitize_text_field' );
213
+ wp_add_inline_script( 'woo-variation-swatches', sprintf( 'wp.apiFetch.use( window.createMiddlewareForExtraQueryParams(%s) )', wp_json_encode( $extra_params_for_rest_uri ) ) );
214
+ }
215
 
216
  wp_localize_script( 'woo-variation-swatches', 'woo_variation_swatches_options', $this->js_options() );
217
 
362
  $option_slug = $data[ 'option_slug' ];
363
  $slug = $data[ 'slug' ];
364
 
 
365
  $is_term = wc_string_to_bool( $data[ 'is_term' ] );
366
 
367
+ $css_class = implode( ' ', array_unique( array_values( apply_filters( 'woo_variation_swatches_variable_item_css_class', $this->get_item_css_classes( $data, $attribute_type, $variation_data ), $data, $attribute_type, $variation_data ) ) ) );
368
 
369
  $html_attributes = array(
370
  'aria-checked' => ( $is_selected ? 'true' : 'false' ),
371
  'tabindex' => ( wp_is_mobile() ? '2' : '0' ),
372
  );
373
 
374
+ $html_attributes = wp_parse_args( $this->get_item_tooltip_attribute( $data, $attribute_type, $variation_data ), $html_attributes );
375
 
376
+ $html_attributes = apply_filters( 'woo_variation_swatches_variable_item_custom_attributes', $html_attributes, $data, $attribute_type, $variation_data );
377
 
378
  return sprintf( '<li %1$s class="variable-item %2$s-variable-item %2$s-variable-item-%3$s %4$s" title="%5$s" data-title="%5$s" data-value="%6$s" role="radio" tabindex="0"><div class="variable-item-contents">', wc_implode_html_attributes( $html_attributes ), esc_attr( $attribute_type ), esc_attr( $option_slug ), esc_attr( $css_class ), esc_html( $option_name ), esc_attr( $slug ) );
379
  }
380
 
381
+ public function get_item_css_classes( $data, $attribute_type, $variation_data = array() ) {
382
 
383
  $css_classes = array();
384
 
391
  return $css_classes;
392
  }
393
 
394
+ public function get_item_tooltip_attribute( $data, $attribute_type, $variation_data = array() ) {
395
 
396
  $html_attributes = array();
397
 
511
  return $assigned;
512
  }
513
 
514
+ public function get_image_attribute_id( $data, $attribute_type, $variation_data = array() ) {
515
+ if ( 'image' === $attribute_type ) {
516
+
517
+ $term = $data[ 'item' ];
518
+
519
+ // Global
520
+ return apply_filters( 'woo_variation_swatches_global_product_attribute_image_id', absint( woo_variation_swatches()->get_frontend()->get_product_attribute_image( $term, $data ) ), $data );
521
+
522
+ }
523
+
524
+ return 0;
525
+ }
526
+
527
  public function get_image_attribute( $data, $attribute_type, $variation_data = array() ) {
528
  if ( 'image' === $attribute_type ) {
529
 
includes/class-woo-variation-swatches-term-meta.php CHANGED
@@ -31,7 +31,7 @@
31
  add_filter( "manage_edit-{$this->taxonomy}_columns", array( $this, 'taxonomy_columns' ) );
32
  add_filter( "manage_{$this->taxonomy}_custom_column", array( $this, 'taxonomy_column_preview' ), 10, 3 );
33
  add_filter( "manage_{$this->taxonomy}_custom_column", array( $this, 'taxonomy_column_group' ), 10, 3 );
34
-
35
  do_action( 'woo_variation_swatches_term_meta_loaded', $this );
36
  }
37
 
@@ -74,7 +74,6 @@
74
  return '';
75
  }
76
 
77
-
78
  public function image_preview( $attribute_type, $term_id, $key ) {
79
  if ( 'image' == $attribute_type ) {
80
  $attachment_id = absint( get_term_meta( $term_id, $key, true ) );
@@ -136,7 +135,6 @@
136
  return $columns;
137
  }
138
 
139
-
140
  public function delete_term( $term_id, $tt_id, $taxonomy, $deleted_term ) {
141
  global $wpdb;
142
 
@@ -230,7 +228,7 @@
230
 
231
  $field[ 'size' ] = isset( $field[ 'size' ] ) ? $field[ 'size' ] : '40';
232
  $field[ 'required' ] = ( isset( $field[ 'required' ] ) and $field[ 'required' ] == true ) ? ' aria-required="true"' : '';
233
- $field[ 'placeholder' ] = ( isset( $field[ 'placeholder' ] ) ) ? ' placeholder="' . $field[ 'placeholder' ] . '" data-placeholder="' . $field[ 'placeholder' ] . '"' : '';
234
  $field[ 'desc' ] = ( isset( $field[ 'desc' ] ) ) ? $field[ 'desc' ] : '';
235
 
236
  $field[ 'dependency' ] = ( isset( $field[ 'dependency' ] ) ) ? $field[ 'dependency' ] : array();
@@ -241,20 +239,20 @@
241
  case 'url':
242
  ob_start();
243
  ?>
244
- <input name="<?php echo $field[ 'id' ] ?>" id="<?php echo $field[ 'id' ] ?>"
245
- type="<?php echo $field[ 'type' ] ?>"
246
- value="<?php echo $field[ 'value' ] ?>"
247
- size="<?php echo $field[ 'size' ] ?>" <?php echo $field[ 'required' ] . $field[ 'placeholder' ] ?>>
248
  <?php
249
  echo ob_get_clean();
250
  break;
251
  case 'color':
252
  ob_start();
253
  ?>
254
- <input name="<?php echo $field[ 'id' ] ?>" id="<?php echo $field[ 'id' ] ?>" type="text"
255
- class="wvs-color-picker" value="<?php echo $field[ 'value' ] ?>"
256
- data-default-color="<?php echo $field[ 'value' ] ?>"
257
- size="<?php echo $field[ 'size' ] ?>" <?php echo $field[ 'required' ] . $field[ 'placeholder' ] ?>>
258
  <?php
259
  echo ob_get_clean();
260
  break;
@@ -287,11 +285,11 @@
287
 
288
  ob_start();
289
  ?>
290
- <select name="<?php echo $field[ 'id' ] ?>" id="<?php echo $field[ 'id' ] ?>"
291
- class="<?php echo $css_class ?>" <?php echo $field[ 'multiple' ] ?>>
292
  <?php
293
  foreach ( $field[ 'options' ] as $key => $option ) {
294
- echo '<option' . selected( $field[ 'value' ], $key, false ) . ' value="' . $key . '">' . $option . '</option>';
295
  }
296
  ?>
297
  </select>
@@ -308,8 +306,8 @@
308
  width="60px" height="60px"/>
309
  </div>
310
  <div class="button-wrapper">
311
- <input type="hidden" id="<?php echo $field[ 'id' ] ?>"
312
- name="<?php echo $field[ 'id' ] ?>"
313
  value="<?php echo esc_attr( $field[ 'value' ] ) ?>"/>
314
  <button type="button"
315
  class="wvs_upload_image_button button button-primary button-small"><?php esc_html_e( 'Upload / Add image', 'woo-variation-swatches' ); ?></button>
@@ -327,12 +325,12 @@
327
  ?>
328
  <label for="<?php echo esc_attr( $field[ 'id' ] ) ?>">
329
 
330
- <input name="<?php echo $field[ 'id' ] ?>" id="<?php echo $field[ 'id' ] ?>"
331
  <?php checked( $field[ 'value' ], 'yes' ) ?>
332
- type="<?php echo $field[ 'type' ] ?>"
333
  value="yes" <?php echo $field[ 'required' ] . $field[ 'placeholder' ] ?>>
334
 
335
- <?php echo $field[ 'label' ] ?></label>
336
  <?php
337
  echo ob_get_clean();
338
  break;
@@ -394,12 +392,12 @@
394
  ob_start();
395
  if ( ! $term ) {
396
  ?>
397
- <p><?php echo $field[ 'desc' ] ?></p>
398
  </div>
399
  <?php
400
  } else {
401
  ?>
402
- <p class="description"><?php echo $field[ 'desc' ] ?></p></td>
403
  </tr>
404
  <?php
405
  }
@@ -407,8 +405,6 @@
407
  }
408
 
409
  public function edit( $term ) {
410
-
411
-
412
  $this->generate_fields( $term );
413
  }
414
  }
31
  add_filter( "manage_edit-{$this->taxonomy}_columns", array( $this, 'taxonomy_columns' ) );
32
  add_filter( "manage_{$this->taxonomy}_custom_column", array( $this, 'taxonomy_column_preview' ), 10, 3 );
33
  add_filter( "manage_{$this->taxonomy}_custom_column", array( $this, 'taxonomy_column_group' ), 10, 3 );
34
+
35
  do_action( 'woo_variation_swatches_term_meta_loaded', $this );
36
  }
37
 
74
  return '';
75
  }
76
 
 
77
  public function image_preview( $attribute_type, $term_id, $key ) {
78
  if ( 'image' == $attribute_type ) {
79
  $attachment_id = absint( get_term_meta( $term_id, $key, true ) );
135
  return $columns;
136
  }
137
 
 
138
  public function delete_term( $term_id, $tt_id, $taxonomy, $deleted_term ) {
139
  global $wpdb;
140
 
228
 
229
  $field[ 'size' ] = isset( $field[ 'size' ] ) ? $field[ 'size' ] : '40';
230
  $field[ 'required' ] = ( isset( $field[ 'required' ] ) and $field[ 'required' ] == true ) ? ' aria-required="true"' : '';
231
+ $field[ 'placeholder' ] = ( isset( $field[ 'placeholder' ] ) ) ? ' placeholder="' . esc_attr( $field[ 'placeholder' ] ) . '" data-placeholder="' . esc_attr( $field[ 'placeholder' ] ) . '"' : '';
232
  $field[ 'desc' ] = ( isset( $field[ 'desc' ] ) ) ? $field[ 'desc' ] : '';
233
 
234
  $field[ 'dependency' ] = ( isset( $field[ 'dependency' ] ) ) ? $field[ 'dependency' ] : array();
239
  case 'url':
240
  ob_start();
241
  ?>
242
+ <input name="<?php echo esc_attr( $field[ 'id' ] ) ?>" id="<?php echo esc_attr( $field[ 'id' ] ) ?>"
243
+ type="<?php echo esc_attr( $field[ 'type' ] ) ?>"
244
+ value="<?php echo esc_attr( $field[ 'value' ] ) ?>"
245
+ size="<?php echo esc_attr( $field[ 'size' ] ) ?>" <?php echo $field[ 'required' ] . $field[ 'placeholder' ] ?>>
246
  <?php
247
  echo ob_get_clean();
248
  break;
249
  case 'color':
250
  ob_start();
251
  ?>
252
+ <input name="<?php echo esc_attr( $field[ 'id' ] ) ?>" id="<?php echo esc_attr( $field[ 'id' ] ) ?>" type="text"
253
+ class="wvs-color-picker" value="<?php echo esc_attr( $field[ 'value' ] ) ?>"
254
+ data-default-color="<?php echo esc_attr( $field[ 'value' ] ) ?>"
255
+ size="<?php echo esc_attr( $field[ 'size' ] ) ?>" <?php echo $field[ 'required' ] . $field[ 'placeholder' ] ?>>
256
  <?php
257
  echo ob_get_clean();
258
  break;
285
 
286
  ob_start();
287
  ?>
288
+ <select name="<?php echo esc_attr( $field[ 'id' ] ) ?>" id="<?php echo esc_attr( $field[ 'id' ] ) ?>"
289
+ class="<?php echo esc_attr( $css_class ) ?>" <?php echo $field[ 'multiple' ] ?>>
290
  <?php
291
  foreach ( $field[ 'options' ] as $key => $option ) {
292
+ echo '<option' . selected( $field[ 'value' ], $key, false ) . ' value="' . esc_attr( $key ) . '">' . esc_html( $option ) . '</option>';
293
  }
294
  ?>
295
  </select>
306
  width="60px" height="60px"/>
307
  </div>
308
  <div class="button-wrapper">
309
+ <input type="hidden" id="<?php echo esc_attr( $field[ 'id' ] ) ?>"
310
+ name="<?php echo esc_attr( $field[ 'id' ] ) ?>"
311
  value="<?php echo esc_attr( $field[ 'value' ] ) ?>"/>
312
  <button type="button"
313
  class="wvs_upload_image_button button button-primary button-small"><?php esc_html_e( 'Upload / Add image', 'woo-variation-swatches' ); ?></button>
325
  ?>
326
  <label for="<?php echo esc_attr( $field[ 'id' ] ) ?>">
327
 
328
+ <input name="<?php echo esc_attr( $field[ 'id' ] ) ?>" id="<?php echo esc_attr( $field[ 'id' ] ) ?>"
329
  <?php checked( $field[ 'value' ], 'yes' ) ?>
330
+ type="<?php echo esc_attr( $field[ 'type' ] ) ?>"
331
  value="yes" <?php echo $field[ 'required' ] . $field[ 'placeholder' ] ?>>
332
 
333
+ <?php echo esc_html( $field[ 'label' ] ) ?></label>
334
  <?php
335
  echo ob_get_clean();
336
  break;
392
  ob_start();
393
  if ( ! $term ) {
394
  ?>
395
+ <p><?php echo wp_kses_post( $field[ 'desc' ] ) ?></p>
396
  </div>
397
  <?php
398
  } else {
399
  ?>
400
+ <p class="description"><?php echo wp_kses_post( $field[ 'desc' ] ) ?></p></td>
401
  </tr>
402
  <?php
403
  }
405
  }
406
 
407
  public function edit( $term ) {
 
 
408
  $this->generate_fields( $term );
409
  }
410
  }
languages/woo-variation-swatches.pot CHANGED
@@ -7,7 +7,7 @@ msgstr ""
7
  "Content-Type: text/plain; charset=UTF-8\n"
8
  "Content-Transfer-Encoding: 8bit\n"
9
  "Language-Team: Emran Ahmed <emran.bd.08@gmail.com>\n"
10
- "POT-Creation-Date: 2022-09-29 11:01+0000\n"
11
  "X-Poedit-Basepath: ..\n"
12
  "X-Poedit-KeywordsList: __;_e;_ex:1,2c;_n:1,2;_n_noop:1,2;_nx:1,2,4c;_nx_noop:1,2,3c;_x:1,2c;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c\n"
13
  "X-Poedit-SearchPath-0: .\n"
@@ -201,7 +201,7 @@ msgstr ""
201
  msgid "%s left"
202
  msgstr ""
203
 
204
- #: ../includes/class-woo-variation-swatches-product-page.php:706, ../includes/class-woo-variation-swatches-product-page.php:732
205
  msgid "Choose an option"
206
  msgstr ""
207
 
@@ -333,7 +333,7 @@ msgstr ""
333
  msgid "Special Attributes"
334
  msgstr ""
335
 
336
- #: ../includes/class-woo-variation-swatches-settings.php:299, ../includes/class-woo-variation-swatches-term-meta.php:103
337
  msgid "Group"
338
  msgstr ""
339
 
@@ -701,11 +701,11 @@ msgstr ""
701
  msgid "Show Attribute taxonomies in large size."
702
  msgstr ""
703
 
704
- #: ../includes/class-woo-variation-swatches-term-meta.php:315
705
  msgid "Upload / Add image"
706
  msgstr ""
707
 
708
- #: ../includes/class-woo-variation-swatches-term-meta.php:318
709
  msgid "Remove image"
710
  msgstr ""
711
 
7
  "Content-Type: text/plain; charset=UTF-8\n"
8
  "Content-Transfer-Encoding: 8bit\n"
9
  "Language-Team: Emran Ahmed <emran.bd.08@gmail.com>\n"
10
+ "POT-Creation-Date: 2022-11-02 12:55+0000\n"
11
  "X-Poedit-Basepath: ..\n"
12
  "X-Poedit-KeywordsList: __;_e;_ex:1,2c;_n:1,2;_n_noop:1,2;_nx:1,2,4c;_nx_noop:1,2,3c;_x:1,2c;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c\n"
13
  "X-Poedit-SearchPath-0: .\n"
201
  msgid "%s left"
202
  msgstr ""
203
 
204
+ #: ../includes/class-woo-variation-swatches-product-page.php:725, ../includes/class-woo-variation-swatches-product-page.php:751
205
  msgid "Choose an option"
206
  msgstr ""
207
 
333
  msgid "Special Attributes"
334
  msgstr ""
335
 
336
+ #: ../includes/class-woo-variation-swatches-settings.php:299, ../includes/class-woo-variation-swatches-term-meta.php:102
337
  msgid "Group"
338
  msgstr ""
339
 
701
  msgid "Show Attribute taxonomies in large size."
702
  msgstr ""
703
 
704
+ #: ../includes/class-woo-variation-swatches-term-meta.php:313
705
  msgid "Upload / Add image"
706
  msgstr ""
707
 
708
+ #: ../includes/class-woo-variation-swatches-term-meta.php:316
709
  msgid "Remove image"
710
  msgstr ""
711
 
woo-variation-swatches.php CHANGED
@@ -4,13 +4,13 @@
4
  * Plugin URI: https://wordpress.org/plugins/woo-variation-swatches/
5
  * Description: Beautiful colors, images and buttons variation swatches for woocommerce product attributes. Requires WooCommerce 5.6+
6
  * Author: Emran Ahmed
7
- * Version: 2.0.11
8
  * Domain Path: /languages
9
  * Requires PHP: 7.0
10
  * Requires at least: 5.6
 
11
  * WC requires at least: 5.6
12
- * Tested up to: 6.0
13
- * WC tested up to: 6.9
14
  * Text Domain: woo-variation-swatches
15
  * Author URI: https://getwooplugins.com/
16
  */
@@ -18,7 +18,7 @@
18
  defined( 'ABSPATH' ) or die( 'Keep Silent' );
19
 
20
  if ( ! defined( 'WOO_VARIATION_SWATCHES_PLUGIN_VERSION' ) ) {
21
- define( 'WOO_VARIATION_SWATCHES_PLUGIN_VERSION', '2.0.11' );
22
  }
23
 
24
  if ( ! defined( 'WOO_VARIATION_SWATCHES_PLUGIN_FILE' ) ) {
@@ -35,13 +35,13 @@
35
 
36
  if ( ! class_exists( 'WooCommerce' ) ) {
37
  $text = esc_html__( 'WooCommerce', 'woo-variation-swatches' );
38
- $link = esc_url( add_query_arg( array(
39
- 'tab' => 'plugin-information',
40
- 'plugin' => 'woocommerce',
41
- 'TB_iframe' => 'true',
42
- 'width' => '640',
43
- 'height' => '500',
44
- ), admin_url( 'plugin-install.php' ) ) );
45
  $message = wp_kses( __( "<strong>Variation Swatches for WooCommerce</strong> is an add-on of ", 'woo-variation-swatches' ), array( 'strong' => array() ) );
46
 
47
  printf( '<div class="%1$s"><p>%2$s <a class="thickbox open-plugin-details-modal" href="%3$s"><strong>%4$s</strong></a></p></div>', 'notice notice-error', $message, $link, $text );
@@ -69,10 +69,16 @@
69
 
70
  add_action( 'plugins_loaded', 'woo_variation_swatches' );
71
 
 
 
 
 
 
 
72
  // Prevent activating pro old version
73
  function deactivate_woo_variation_swatches_pro() {
74
 
75
- if ( defined( 'WOO_VARIATION_SWATCHES_PRO_PLUGIN_FILE' ) ) {
76
  return;
77
  }
78
 
@@ -88,11 +94,11 @@
88
 
89
  function prevent_active_woo_variation_swatches_pro() {
90
 
91
- if ( defined( 'WOO_VARIATION_SWATCHES_PRO_PLUGIN_FILE' ) ) {
92
  return;
93
  }
94
 
95
- echo 'You are running older version of "Variation Swatches for WooCommerce - Pro". Please upgrade to 2.0.0 or upper and continue.';
96
  exit();
97
  }
98
 
4
  * Plugin URI: https://wordpress.org/plugins/woo-variation-swatches/
5
  * Description: Beautiful colors, images and buttons variation swatches for woocommerce product attributes. Requires WooCommerce 5.6+
6
  * Author: Emran Ahmed
7
+ * Version: 2.0.12
8
  * Domain Path: /languages
9
  * Requires PHP: 7.0
10
  * Requires at least: 5.6
11
+ * Tested up to: 6.1
12
  * WC requires at least: 5.6
13
+ * WC tested up to: 7.0
 
14
  * Text Domain: woo-variation-swatches
15
  * Author URI: https://getwooplugins.com/
16
  */
18
  defined( 'ABSPATH' ) or die( 'Keep Silent' );
19
 
20
  if ( ! defined( 'WOO_VARIATION_SWATCHES_PLUGIN_VERSION' ) ) {
21
+ define( 'WOO_VARIATION_SWATCHES_PLUGIN_VERSION', '2.0.12' );
22
  }
23
 
24
  if ( ! defined( 'WOO_VARIATION_SWATCHES_PLUGIN_FILE' ) ) {
35
 
36
  if ( ! class_exists( 'WooCommerce' ) ) {
37
  $text = esc_html__( 'WooCommerce', 'woo-variation-swatches' );
38
+ $link = esc_url( add_query_arg( array(
39
+ 'tab' => 'plugin-information',
40
+ 'plugin' => 'woocommerce',
41
+ 'TB_iframe' => 'true',
42
+ 'width' => '640',
43
+ 'height' => '500',
44
+ ), admin_url( 'plugin-install.php' ) ) );
45
  $message = wp_kses( __( "<strong>Variation Swatches for WooCommerce</strong> is an add-on of ", 'woo-variation-swatches' ), array( 'strong' => array() ) );
46
 
47
  printf( '<div class="%1$s"><p>%2$s <a class="thickbox open-plugin-details-modal" href="%3$s"><strong>%4$s</strong></a></p></div>', 'notice notice-error', $message, $link, $text );
69
 
70
  add_action( 'plugins_loaded', 'woo_variation_swatches' );
71
 
72
+
73
+ function is_using_correct_version_of_woo_variation_swatches_pro() {
74
+ // return defined( 'WOO_VARIATION_SWATCHES_PRO_PLUGIN_VERSION' ) && ( version_compare( WOO_VARIATION_SWATCHES_PRO_PLUGIN_VERSION, '2.0.12' ) >= 0 );
75
+ return defined( 'WOO_VARIATION_SWATCHES_PRO_PLUGIN_FILE' );
76
+ }
77
+
78
  // Prevent activating pro old version
79
  function deactivate_woo_variation_swatches_pro() {
80
 
81
+ if ( is_using_correct_version_of_woo_variation_swatches_pro() ) {
82
  return;
83
  }
84
 
94
 
95
  function prevent_active_woo_variation_swatches_pro() {
96
 
97
+ if ( is_using_correct_version_of_woo_variation_swatches_pro() ) {
98
  return;
99
  }
100
 
101
+ echo 'You are running older version of "Variation Swatches for WooCommerce - Pro". Please upgrade to 2.0.12 or upper and continue.';
102
  exit();
103
  }
104