Version Description
- Initial release
=
Download this release
Release Info
Developer | EmranAhmed |
Plugin | WooCommerce Variation Swatches |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- README.txt +102 -0
- assets/css/admin.css +50 -0
- assets/css/admin.min.css +8 -0
- assets/css/frontend.css +73 -0
- assets/css/frontend.min.css +8 -0
- assets/js/admin.js +242 -0
- assets/js/admin.min.js +1 -0
- assets/js/form-field-dependency.js +815 -0
- assets/js/form-field-dependency.min.js +1 -0
- assets/js/frontend.js +244 -0
- assets/js/frontend.min.js +1 -0
- images/placeholder.png +0 -0
- includes/class-wvs-term-meta.php +265 -0
- includes/functions.php +410 -0
- includes/hooks.php +11 -0
- languages/woo-variation-swatches.pot +57 -0
- package.json +28 -0
- webpack.mix.js +79 -0
- woo-variation-swatches.php +262 -0
README.txt
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Woo Variation Swatches ===
|
2 |
+
Contributors: EmranAhmed, wpeshaan
|
3 |
+
Tags: woocommerce, variation swatches, product attributes, product color, product size, variable product attributes, variation product swatches, color variation swatch, image variation swatch
|
4 |
+
Requires at least: 4.8
|
5 |
+
Tested up to: 4.9
|
6 |
+
Requires PHP: 5.6
|
7 |
+
Stable tag: trunk
|
8 |
+
License: GPLv3
|
9 |
+
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
+
|
11 |
+
Beautiful Color, Image and Buttons Variation Swatches For WooCommerce Product Attributes
|
12 |
+
|
13 |
+
== Description ==
|
14 |
+
|
15 |
+
[youtube https://www.youtube.com/watch?v=nO3Ui90SixE]
|
16 |
+
|
17 |
+
Woo Variation Swatches is easy to use WooCommerce product variation swatches plugin. It offers an aesthetic and professional experience to select attributes for variation products. It turns the product variation select options fields into radio images, colors, and label. It means with the help of this powerful WooCommerce color or image variation swatches plugin, you can show product variation items in images, colors, and label. So, you can say goodbye to dropdown product attribute fields.
|
18 |
+
|
19 |
+
Woo Variation Swatches not only offers the color, image and label attributes in the single WooCommerce product. It also enables them in product quick view. If you're using WooCommerce themes like Flatsome that comes with default Quick View option, you don’t need to hassle to load color and image swatches for variable product attributes in quick view separately.
|
20 |
+
|
21 |
+
= Key Feature Comes with this Plugin =
|
22 |
+
|
23 |
+
* Work on variable product
|
24 |
+
* Work on variable product quick view
|
25 |
+
* Enable attributes into images swatches
|
26 |
+
* Enable attributes into color swatches
|
27 |
+
* Enable attributes into label/text/button swatches
|
28 |
+
* Control attribute setting globally.
|
29 |
+
* No extra option and no conclusion.
|
30 |
+
|
31 |
+
= Links =
|
32 |
+
* [Facebook User Group](https://www.facebook.com/groups/GetWooPlugins/)
|
33 |
+
* [Website](https://getwooplugins.com/?utm_source=wordpress.org&utm_campaign=Woo+Variation+Swatches)
|
34 |
+
* [Github](https://github.com/EmranAhmed/woo-variation-swatches/?utm_source=wordpress.org&utm_campaign=Woo+Variation+Swatches)
|
35 |
+
|
36 |
+
== Installation ==
|
37 |
+
|
38 |
+
### Automatic Install From WordPress Dashboard
|
39 |
+
|
40 |
+
1. Login to your the admin panel
|
41 |
+
2. Navigate to Plugins -> Add New
|
42 |
+
3. Search **Woo Variation Switcher**
|
43 |
+
4. Click install and activate respectively.
|
44 |
+
|
45 |
+
### Manual Install From WordPress Dashboard
|
46 |
+
|
47 |
+
If your server is not connected to the Internet, then you can use this method-
|
48 |
+
|
49 |
+
1. Download the plugin by clicking on the red button above. A ZIP file will be downloaded.
|
50 |
+
2. Login to your site's admin panel and navigate to Plugins -> Add New -> Upload.
|
51 |
+
3. Click choose file, select the plugin file and click install
|
52 |
+
|
53 |
+
### Install Using FTP
|
54 |
+
|
55 |
+
If you are unable to use any of the methods due to internet connectivity and file permission issues, then you can use this method-
|
56 |
+
|
57 |
+
1. Download the plugin by clicking on the red button above. A ZIP file will be downloaded.
|
58 |
+
2. Unzip the file.
|
59 |
+
3. Launch your favorite FTP client. Such as FileZilla, FireFTP, CyberDuck etc. If you are a more advanced user, then you can use SSH too.
|
60 |
+
4. Upload the folder to `wp-content/plugins/`
|
61 |
+
5. Log in to your WordPress dashboard.
|
62 |
+
6. Navigate to Plugins -> Installed
|
63 |
+
7. Activate the plugin
|
64 |
+
|
65 |
+
== Frequently Asked Questions ==
|
66 |
+
|
67 |
+
= How can I configure attributes? =
|
68 |
+
|
69 |
+
Even this plugin has been installed and activated on your site, variable products will still show dropdowns if you’ve not configured product attributes.
|
70 |
+
|
71 |
+
1. Log in to your WordPress dashboard, navigate to the Products menu and click Attributes.
|
72 |
+
2. Click to attribute name to edit an exists attribute or in the Add New Attribute form you will see the default Type selector.
|
73 |
+
3. Click to that Type selector to change attribute’s type. Besides default options Select and Text, there are more 3 options Color, Image, Button/Label to choose.
|
74 |
+
4. Select the suitable type for your attribute and click Save Change/Add attribute
|
75 |
+
5. Go back to manage attributes screen. Click the cog icon on the right side of attribute to start editing terms.
|
76 |
+
6. Start adding new terms or editing exists terms. There is will be a new option at the end of form that let you choose the color, upload image or choose as a button for those terms.
|
77 |
+
|
78 |
+
= Is it compatible with Any kinds of WooCommerce Theme? =
|
79 |
+
|
80 |
+
Yes, it's compatible with woocommerce theme including Flatsome. But sometimes it may require small css tweak.
|
81 |
+
|
82 |
+
= Does it show in product QuickView? =
|
83 |
+
|
84 |
+
Yes, it supports any kinds of product quick view.
|
85 |
+
|
86 |
+
== Screenshots ==
|
87 |
+
|
88 |
+
1. Single Product variation page
|
89 |
+
2. Product QuickView
|
90 |
+
3. Available Attribute Options
|
91 |
+
4. Attribute Image Type Preview
|
92 |
+
5. Attribute Color Type Preview
|
93 |
+
6. Attribute Button / Label Type Preview
|
94 |
+
7. Variation Product Edit view
|
95 |
+
|
96 |
+
== Changelog ==
|
97 |
+
|
98 |
+
= 1.0.0 =
|
99 |
+
|
100 |
+
* Initial release
|
101 |
+
|
102 |
+
== Upgrade Notice ==
|
assets/css/admin.css
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*!
|
2 |
+
* Woo Variation Swatches v1.0.0
|
3 |
+
*
|
4 |
+
* Author: Emran Ahmed ( emran.bd.08@gmail.com )
|
5 |
+
* Date: 2017-12-20 17:41:58
|
6 |
+
* Released under the GPLv3 license.
|
7 |
+
*/
|
8 |
+
.button.button-danger {
|
9 |
+
color: #FFFFFF;
|
10 |
+
background-color: #AF2D2B;
|
11 |
+
border-color: #A62D2B;
|
12 |
+
-webkit-box-shadow: 0 1px 0 #A72D2B;
|
13 |
+
box-shadow: 0 1px 0 #A72D2B;
|
14 |
+
vertical-align: top;
|
15 |
+
}
|
16 |
+
|
17 |
+
.button.button-danger:hover,
|
18 |
+
.button.button-danger:focus,
|
19 |
+
.button.button-danger:active,
|
20 |
+
.button.button-danger.active {
|
21 |
+
color: #FFFFFF;
|
22 |
+
background: #C9302C;
|
23 |
+
}
|
24 |
+
|
25 |
+
[data-depends].has-dependent-data {
|
26 |
+
display: none;
|
27 |
+
}
|
28 |
+
|
29 |
+
.meta-image-field-wrapper {
|
30 |
+
display: table;
|
31 |
+
}
|
32 |
+
|
33 |
+
.meta-image-field-wrapper .button {
|
34 |
+
margin: 5px 0;
|
35 |
+
display: block;
|
36 |
+
}
|
37 |
+
|
38 |
+
.meta-image-field-wrapper .image-preview {
|
39 |
+
display: table-cell;
|
40 |
+
width: 60px;
|
41 |
+
padding-right: 10px;
|
42 |
+
}
|
43 |
+
|
44 |
+
.meta-image-field-wrapper .button-wrapper {
|
45 |
+
display: table-cell;
|
46 |
+
vertical-align: top;
|
47 |
+
}
|
48 |
+
|
49 |
+
|
50 |
+
/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXNzZXRzL2Nzcy9hZG1pbi5jc3MiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vLi9zcmMvc2Nzcy9zcmMvc2Nzcy9iYWNrZW5kLnNjc3MiLCJ3ZWJwYWNrOi8vLy4vYmFja2VuZC5zY3NzIiwid2VicGFjazovLy8uL3NyYy9zY3NzL2JhY2tlbmQuc2NzcyJdLCJzb3VyY2VzQ29udGVudCI6WyIuYnV0dG9uLmJ1dHRvbi1kYW5nZXIge1xuICBjb2xvciAgICAgICAgICAgIDogI0ZGRkZGRjtcbiAgYmFja2dyb3VuZC1jb2xvciA6ICNBRjJEMkI7XG4gIGJvcmRlci1jb2xvciAgICAgOiAjQTYyRDJCO1xuICBib3gtc2hhZG93ICAgICAgIDogMCAxcHggMCAjQTcyRDJCO1xuICB2ZXJ0aWNhbC1hbGlnbiAgIDogdG9wO1xuICAmOmhvdmVyLCAmOmZvY3VzLCAmOmFjdGl2ZSwgJi5hY3RpdmUge1xuICAgIGNvbG9yICAgICAgOiAjRkZGRkZGO1xuICAgIGJhY2tncm91bmQgOiAjQzkzMDJDO1xuICAgIH1cbiAgfVxuXG5bZGF0YS1kZXBlbmRzXS5oYXMtZGVwZW5kZW50LWRhdGEge1xuICBkaXN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VZCUVVjc1IwRkJSenREUVVOdVFpSjkgKi9cblxuXG4vLyBXRUJQQUNLIEZPT1RFUiAvL1xuLy8gLi9zcmMvc2Nzcy9iYWNrZW5kLnNjc3MiXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQUE7QUFDQTtBQ0NBO0FBQ0E7QUREQTs7OztBQUNBO0FBQ0E7QUNNQTtBQUNBO0FDRkE7QUZBQTtBQ0tBO0FBQ0E7QURIQTtBQUNBO0FDS0E7QUFDQTtBRExBO0FBQ0E7QUFDQTtBQ09BO0FBQ0E7QUROQTtBQUNBO0FBQ0E7QUFDQTtBQ1FBO0FBQ0E7QURQQTtBQUNBO0FBQ0E7QUNTQTtBQUNBOyIsInNvdXJjZVJvb3QiOiIifQ==*/
|
assets/css/admin.min.css
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*!
|
2 |
+
* Woo Variation Swatches v1.0.0
|
3 |
+
*
|
4 |
+
* Author: Emran Ahmed ( emran.bd.08@gmail.com )
|
5 |
+
* Date: 2017-12-20 17:42:04
|
6 |
+
* Released under the GPLv3 license.
|
7 |
+
*/
|
8 |
+
.button.button-danger{color:#fff;background-color:#af2d2b;border-color:#a62d2b;-webkit-box-shadow:0 1px 0 #a72d2b;box-shadow:0 1px 0 #a72d2b;vertical-align:top}.button.button-danger.active,.button.button-danger:active,.button.button-danger:focus,.button.button-danger:hover{color:#fff;background:#c9302c}[data-depends].has-dependent-data{display:none}.meta-image-field-wrapper{display:table}.meta-image-field-wrapper .button{margin:5px 0;display:block}.meta-image-field-wrapper .image-preview{display:table-cell;width:60px;padding-right:10px}.meta-image-field-wrapper .button-wrapper{display:table-cell;vertical-align:top}
|
assets/css/frontend.css
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*!
|
2 |
+
* Woo Variation Swatches v1.0.0
|
3 |
+
*
|
4 |
+
* Author: Emran Ahmed ( emran.bd.08@gmail.com )
|
5 |
+
* Date: 2017-12-20 17:41:58
|
6 |
+
* Released under the GPLv3 license.
|
7 |
+
*/
|
8 |
+
.variable-items-wrapper {
|
9 |
+
display: -webkit-box;
|
10 |
+
display: -ms-flexbox;
|
11 |
+
display: flex;
|
12 |
+
-ms-flex-wrap: wrap;
|
13 |
+
flex-wrap: wrap;
|
14 |
+
}
|
15 |
+
|
16 |
+
.variable-items-wrapper .variable-item {
|
17 |
+
-webkit-box-sizing: border-box;
|
18 |
+
box-sizing: border-box;
|
19 |
+
list-style: none;
|
20 |
+
padding: 2px;
|
21 |
+
margin: 2px;
|
22 |
+
cursor: pointer;
|
23 |
+
border: 1px solid rgba(0, 0, 0, 0.2);
|
24 |
+
width: 30px;
|
25 |
+
height: 30px;
|
26 |
+
overflow: hidden;
|
27 |
+
display: -webkit-box;
|
28 |
+
display: -ms-flexbox;
|
29 |
+
display: flex;
|
30 |
+
-webkit-box-pack: center;
|
31 |
+
-ms-flex-pack: center;
|
32 |
+
justify-content: center;
|
33 |
+
-webkit-box-align: center;
|
34 |
+
-ms-flex-align: center;
|
35 |
+
align-items: center;
|
36 |
+
}
|
37 |
+
|
38 |
+
.variable-items-wrapper .variable-item.color-variable-item,
|
39 |
+
.variable-items-wrapper .variable-item.button-variable-item {
|
40 |
+
border-radius: 50%;
|
41 |
+
}
|
42 |
+
|
43 |
+
.variable-items-wrapper .variable-item.color-variable-item span,
|
44 |
+
.variable-items-wrapper .variable-item.button-variable-item span {
|
45 |
+
border-radius: 50%;
|
46 |
+
}
|
47 |
+
|
48 |
+
.variable-items-wrapper .variable-item span {
|
49 |
+
padding: 10px;
|
50 |
+
font-size: small;
|
51 |
+
}
|
52 |
+
|
53 |
+
.variable-items-wrapper .variable-item:last-of-type {
|
54 |
+
margin-right: 0;
|
55 |
+
}
|
56 |
+
|
57 |
+
.variable-items-wrapper .variable-item:hover {
|
58 |
+
border: 1px solid #000000;
|
59 |
+
}
|
60 |
+
|
61 |
+
.variable-items-wrapper .variable-item.selected,
|
62 |
+
.variable-items-wrapper .variable-item.selected:hover {
|
63 |
+
border: 1px solid #000000;
|
64 |
+
}
|
65 |
+
|
66 |
+
.variable-items-wrapper .variable-item.disabled,
|
67 |
+
.variable-items-wrapper .variable-item.disabled:hover {
|
68 |
+
cursor: not-allowed;
|
69 |
+
opacity: 0.5;
|
70 |
+
}
|
71 |
+
|
72 |
+
|
73 |
+
/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXNzZXRzL2Nzcy9mcm9udGVuZC5jc3MiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vLi9zcmMvc2Nzcy9zcmMvc2Nzcy9mcm9udGVuZC5zY3NzIiwid2VicGFjazovLy8uL2Zyb250ZW5kLnNjc3MiXSwic291cmNlc0NvbnRlbnQiOlsiLnZhcmlhYmxlLWl0ZW1zLXdyYXBwZXIge1xuICBkaXNwbGF5ICAgOiBmbGV4O1xuICBmbGV4LXdyYXAgOiB3cmFwO1xuXG4gIC52YXJpYWJsZS1pdGVtIHtcbiAgICBib3gtc2l6aW5nICAgICAgOiBib3JkZXItYm94O1xuICAgIGxpc3Qtc3R5bGUgICAgICA6IG5vbmU7XG4gICAgcGFkZGluZyAgICAgICAgIDogMnB4O1xuICAgIG1hcmdpbiAgICAgICAgICA6IDJweDtcbiAgICBjdXJzb3IgICAgICAgICAg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1Q0E7QUNPQTtBQUNBO0FEL0NBOztBQTJDQTtBQUNBO0FDUUE7QUFDQTsiLCJzb3VyY2VSb290IjoiIn0=*/
|
assets/css/frontend.min.css
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*!
|
2 |
+
* Woo Variation Swatches v1.0.0
|
3 |
+
*
|
4 |
+
* Author: Emran Ahmed ( emran.bd.08@gmail.com )
|
5 |
+
* Date: 2017-12-20 17:42:04
|
6 |
+
* Released under the GPLv3 license.
|
7 |
+
*/
|
8 |
+
.variable-items-wrapper{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap}.variable-items-wrapper .variable-item{-webkit-box-sizing:border-box;box-sizing:border-box;list-style:none;padding:2px;margin:2px;cursor:pointer;border:1px solid rgba(0,0,0,.2);width:30px;height:30px;overflow:hidden;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.variable-items-wrapper .variable-item.button-variable-item,.variable-items-wrapper .variable-item.button-variable-item span,.variable-items-wrapper .variable-item.color-variable-item,.variable-items-wrapper .variable-item.color-variable-item span{border-radius:50%}.variable-items-wrapper .variable-item span{padding:10px;font-size:small}.variable-items-wrapper .variable-item:last-of-type{margin-right:0}.variable-items-wrapper .variable-item.selected,.variable-items-wrapper .variable-item.selected:hover,.variable-items-wrapper .variable-item:hover{border:1px solid #000}.variable-items-wrapper .variable-item.disabled,.variable-items-wrapper .variable-item.disabled:hover{cursor:not-allowed;opacity:.5}
|
assets/js/admin.js
ADDED
@@ -0,0 +1,242 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*!
|
2 |
+
* Woo Variation Swatches v1.0.0
|
3 |
+
*
|
4 |
+
* Author: Emran Ahmed ( emran.bd.08@gmail.com )
|
5 |
+
* Date: 2017-12-20 17:41:58
|
6 |
+
* Released under the GPLv3 license.
|
7 |
+
*/
|
8 |
+
/******/ (function(modules) { // webpackBootstrap
|
9 |
+
/******/ // The module cache
|
10 |
+
/******/ var installedModules = {};
|
11 |
+
/******/
|
12 |
+
/******/ // The require function
|
13 |
+
/******/ function __webpack_require__(moduleId) {
|
14 |
+
/******/
|
15 |
+
/******/ // Check if module is in cache
|
16 |
+
/******/ if(installedModules[moduleId]) {
|
17 |
+
/******/ return installedModules[moduleId].exports;
|
18 |
+
/******/ }
|
19 |
+
/******/ // Create a new module (and put it into the cache)
|
20 |
+
/******/ var module = installedModules[moduleId] = {
|
21 |
+
/******/ i: moduleId,
|
22 |
+
/******/ l: false,
|
23 |
+
/******/ exports: {}
|
24 |
+
/******/ };
|
25 |
+
/******/
|
26 |
+
/******/ // Execute the module function
|
27 |
+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
28 |
+
/******/
|
29 |
+
/******/ // Flag the module as loaded
|
30 |
+
/******/ module.l = true;
|
31 |
+
/******/
|
32 |
+
/******/ // Return the exports of the module
|
33 |
+
/******/ return module.exports;
|
34 |
+
/******/ }
|
35 |
+
/******/
|
36 |
+
/******/
|
37 |
+
/******/ // expose the modules object (__webpack_modules__)
|
38 |
+
/******/ __webpack_require__.m = modules;
|
39 |
+
/******/
|
40 |
+
/******/ // expose the module cache
|
41 |
+
/******/ __webpack_require__.c = installedModules;
|
42 |
+
/******/
|
43 |
+
/******/ // define getter function for harmony exports
|
44 |
+
/******/ __webpack_require__.d = function(exports, name, getter) {
|
45 |
+
/******/ if(!__webpack_require__.o(exports, name)) {
|
46 |
+
/******/ Object.defineProperty(exports, name, {
|
47 |
+
/******/ configurable: false,
|
48 |
+
/******/ enumerable: true,
|
49 |
+
/******/ get: getter
|
50 |
+
/******/ });
|
51 |
+
/******/ }
|
52 |
+
/******/ };
|
53 |
+
/******/
|
54 |
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
55 |
+
/******/ __webpack_require__.n = function(module) {
|
56 |
+
/******/ var getter = module && module.__esModule ?
|
57 |
+
/******/ function getDefault() { return module['default']; } :
|
58 |
+
/******/ function getModuleExports() { return module; };
|
59 |
+
/******/ __webpack_require__.d(getter, 'a', getter);
|
60 |
+
/******/ return getter;
|
61 |
+
/******/ };
|
62 |
+
/******/
|
63 |
+
/******/ // Object.prototype.hasOwnProperty.call
|
64 |
+
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
65 |
+
/******/
|
66 |
+
/******/ // __webpack_public_path__
|
67 |
+
/******/ __webpack_require__.p = "";
|
68 |
+
/******/
|
69 |
+
/******/ // Load entry module and return exports
|
70 |
+
/******/ return __webpack_require__(__webpack_require__.s = 0);
|
71 |
+
/******/ })
|
72 |
+
/************************************************************************/
|
73 |
+
/******/ ([
|
74 |
+
/* 0 */
|
75 |
+
/***/ (function(module, exports, __webpack_require__) {
|
76 |
+
|
77 |
+
__webpack_require__(1);
|
78 |
+
__webpack_require__(3);
|
79 |
+
module.exports = __webpack_require__(4);
|
80 |
+
|
81 |
+
|
82 |
+
/***/ }),
|
83 |
+
/* 1 */
|
84 |
+
/***/ (function(module, exports, __webpack_require__) {
|
85 |
+
|
86 |
+
jQuery(function ($) {
|
87 |
+
Promise.resolve().then(function () {
|
88 |
+
return __webpack_require__(2);
|
89 |
+
}).then(function (_ref) {
|
90 |
+
var PluginHelper = _ref.PluginHelper;
|
91 |
+
|
92 |
+
PluginHelper.SelectWoo();
|
93 |
+
PluginHelper.ColorPicker();
|
94 |
+
PluginHelper.FieldDependency();
|
95 |
+
PluginHelper.ImageUploader();
|
96 |
+
});
|
97 |
+
}); // end of jquery main wrapper
|
98 |
+
|
99 |
+
/***/ }),
|
100 |
+
/* 2 */
|
101 |
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
102 |
+
|
103 |
+
"use strict";
|
104 |
+
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
105 |
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PluginHelper", function() { return PluginHelper; });
|
106 |
+
var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
107 |
+
|
108 |
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
109 |
+
|
110 |
+
/*global WVSPluginObject, wp*/
|
111 |
+
|
112 |
+
var PluginHelper = function ($) {
|
113 |
+
var PluginHelper = function () {
|
114 |
+
function PluginHelper() {
|
115 |
+
_classCallCheck(this, PluginHelper);
|
116 |
+
}
|
117 |
+
|
118 |
+
_createClass(PluginHelper, null, [{
|
119 |
+
key: 'ImageUploader',
|
120 |
+
value: function ImageUploader() {
|
121 |
+
$(document).off('click', 'button.wvs_upload_image_button');
|
122 |
+
$(document).on('click', 'button.wvs_upload_image_button', this.AddImage);
|
123 |
+
$(document).on('click', 'button.wvs_remove_image_button', this.RemoveImage);
|
124 |
+
}
|
125 |
+
}, {
|
126 |
+
key: 'AddImage',
|
127 |
+
value: function AddImage(event) {
|
128 |
+
var _this = this;
|
129 |
+
|
130 |
+
event.preventDefault();
|
131 |
+
event.stopPropagation();
|
132 |
+
|
133 |
+
var file_frame = void 0;
|
134 |
+
|
135 |
+
if (typeof wp !== 'undefined' && wp.media && wp.media.editor) {
|
136 |
+
|
137 |
+
// If the media frame already exists, reopen it.
|
138 |
+
if (file_frame) {
|
139 |
+
file_frame.open();
|
140 |
+
return;
|
141 |
+
}
|
142 |
+
|
143 |
+
// Create the media frame.
|
144 |
+
file_frame = wp.media.frames.select_image = wp.media({
|
145 |
+
title: WVSPluginObject.media_title,
|
146 |
+
button: {
|
147 |
+
text: WVSPluginObject.button_title
|
148 |
+
},
|
149 |
+
multiple: false
|
150 |
+
});
|
151 |
+
|
152 |
+
// When an image is selected, run a callback.
|
153 |
+
file_frame.on('select', function () {
|
154 |
+
var attachment = file_frame.state().get('selection').first().toJSON();
|
155 |
+
|
156 |
+
if ($.trim(attachment.id) !== '') {
|
157 |
+
|
158 |
+
var url = typeof attachment.sizes.thumbnail === 'undefined' ? attachment.sizes.full.url : attachment.sizes.thumbnail.url;
|
159 |
+
|
160 |
+
$(_this).prev().val(attachment.id);
|
161 |
+
$(_this).closest('.meta-image-field-wrapper').find('img').attr('src', url);
|
162 |
+
$(_this).next().show();
|
163 |
+
}
|
164 |
+
//file_frame.close();
|
165 |
+
});
|
166 |
+
|
167 |
+
// When open select selected
|
168 |
+
file_frame.on('open', function () {
|
169 |
+
|
170 |
+
// Grab our attachment selection and construct a JSON representation of the model.
|
171 |
+
var selection = file_frame.state().get('selection');
|
172 |
+
var current = $(_this).prev().val();
|
173 |
+
var attachment = wp.media.attachment(current);
|
174 |
+
attachment.fetch();
|
175 |
+
selection.add(attachment ? [attachment] : []);
|
176 |
+
});
|
177 |
+
|
178 |
+
// Finally, open the modal.
|
179 |
+
file_frame.open();
|
180 |
+
}
|
181 |
+
}
|
182 |
+
}, {
|
183 |
+
key: 'RemoveImage',
|
184 |
+
value: function RemoveImage(event) {
|
185 |
+
|
186 |
+
event.preventDefault();
|
187 |
+
event.stopPropagation();
|
188 |
+
|
189 |
+
var placeholder = $(this).closest('.meta-image-field-wrapper').find('img').data('placeholder');
|
190 |
+
$(this).closest('.meta-image-field-wrapper').find('img').attr('src', placeholder);
|
191 |
+
$(this).prev().prev().val('');
|
192 |
+
$(this).hide();
|
193 |
+
return false;
|
194 |
+
}
|
195 |
+
}, {
|
196 |
+
key: 'SelectWoo',
|
197 |
+
value: function SelectWoo() {
|
198 |
+
var selector = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'select.wvs-selectwoo';
|
199 |
+
|
200 |
+
$(selector).selectWoo({
|
201 |
+
allowClear: true
|
202 |
+
});
|
203 |
+
}
|
204 |
+
}, {
|
205 |
+
key: 'ColorPicker',
|
206 |
+
value: function ColorPicker() {
|
207 |
+
var selector = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'input.wvs-color-picker';
|
208 |
+
|
209 |
+
$(selector).wpColorPicker();
|
210 |
+
}
|
211 |
+
}, {
|
212 |
+
key: 'FieldDependency',
|
213 |
+
value: function FieldDependency() {
|
214 |
+
var selector = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '[data-depends]';
|
215 |
+
|
216 |
+
$(selector).FormFieldDependency();
|
217 |
+
}
|
218 |
+
}]);
|
219 |
+
|
220 |
+
return PluginHelper;
|
221 |
+
}();
|
222 |
+
|
223 |
+
return PluginHelper;
|
224 |
+
}(jQuery);
|
225 |
+
|
226 |
+
|
227 |
+
|
228 |
+
/***/ }),
|
229 |
+
/* 3 */
|
230 |
+
/***/ (function(module, exports) {
|
231 |
+
|
232 |
+
// removed by extract-text-webpack-plugin
|
233 |
+
|
234 |
+
/***/ }),
|
235 |
+
/* 4 */
|
236 |
+
/***/ (function(module, exports) {
|
237 |
+
|
238 |
+
// removed by extract-text-webpack-plugin
|
239 |
+
|
240 |
+
/***/ })
|
241 |
+
/******/ ]);
|
242 |
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXNzZXRzL2pzL2FkbWluLmpzIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8vL3dlYnBhY2svYm9vdHN0cmFwIDMzMGUxNTQ1Nzg2NGJmZDhlZmM2Iiwid2VicGFjazovLy9zcmMvanMvYmFja2VuZC5qcyIsIndlYnBhY2s6Ly8vc3JjL2pzL1BsdWdpbkhlbHBlci5qcyIsIndlYnBhY2s6Ly8vLi9zcmMvc2Nzcy9iYWNrZW5kLnNjc3M/YmU2MSIsIndlYnBhY2s6Ly8vLi9zcmMvc2Nzcy9mcm9udGVuZC5zY3NzIl0sInNvdXJjZXNDb250ZW50IjpbIiBcdC8vIFRoZSBtb2R1bGUgY2FjaGVcbiBcdHZhciBpbnN0YWxsZWRNb2R1bGVzID0ge307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XG4gICAgICAgICAgICAkKGRvY3VtZW50KS5vZmYoJ2NsaWNrJywgJ2J1dHRvbi53dnNfdXBsb2FkX2ltYWdlX2J1dHRvbicpO1xuICAgICAgICAgICAgJChkb2N1bWVudCkub24oJ2NsaWNrJywgJ2J1dHRvbi53dnNfdXBsb2FkX2ltYWdlX2J1dHRvbicsIHRoaXMuQWRkSW1hZ2UpO1xuICAgICAgICAgICAgJChkb2N1bWVudCkub24oJ2NsaWNrJywgJ2J1dHRvbi53dnNfcmVtb3ZlX2ltYWdlX2J1dHRvbicsIHRoaXMuUmVtb3ZlSW1hZ2UpO1xuICAgICAgICB9XG5cbiAgICAgICAgc3RhdGljIEFkZEltYWdlKGV2ZW50KSB7XG5cbiAgICAgICAgICAgIGV2ZW50LnByZXZlbnREZWZhdWx0KCk7XG4gICAgICAgICAgICBldmVudC5zdG9wUHJvcGFnYXRpb24oKTtcblxuICAgICAgICAgICAgbGV0IGZpbGVfZnJhbWU7XG5cbiAgICAgICAgICAgIGlmICh0eXBlb2Ygd3AgIT09ICd1bmRlZmluZWQnICYmIHdwLm1lZGlhICYmIHdwLm1lZGlhLmVkaXRvcikge1xuXG4gICAgICAgICAgICAgICAgLy8gSWYgdGhlIG1lZGlhIGZyYW1lIGFscmVhZHkgZXhpc3RzLCByZW9wZW4gaXQuXG4gICAgICAgICAgICAgICAgaWYgKGZpbGVfZnJhbWUpIHtcbiAgICAgICAgICAgICAgICAgICAgZmlsZV9mcmFtZS5vcGVuKCk7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAvLyBDcmVhdGUgdGhlIG1lZGlhIGZyYW1lLlxuICAgICAgICAgICAgICAgIGZpbGVfZnJhbWUgPSB3cC5tZWRpYS5mcmFtZXMuc2VsZWN0X2ltYWdlID0gd3AubWVkaWEoe1xuICAgICAgICAgICAgICAgICAgICB0aXRsZSAgICA6IFdWU1BsdWdpbk9iamVjdC5tZWRpYV90aXRsZSxcbiAgICAgICAgICAgICAgICAgICAgYnV0dG9uICAgOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0ZXh0IDogV1ZTUGx1Z2luT2JqZWN0LmJ1dHRvbl90aXRsZVxuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICBtdWx0aXBsZSA6IGZhbHNlLFxuICAgICAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICAgICAgLy8gV2hlbiBhbiBpbWFnZSBpcyBzZWxlY3RlZCwgcnVuIGEgY2FsbGJhY2suXG4gICAgICAgICAgICAgICAgZmlsZV9mcmFtZS5vbignc2VsZWN0JywgKCkgPT4ge1xuICAgICAgICAgICAgICAgICAgICBsZXQgYXR0YWNobWVudCA9IGZpbGVfZnJhbWUuc3RhdGUoKS5nZXQoJ3NlbGVjdGlvbicpLmZpcnN0KCkudG9KU09OKCk7XG5cbiAgICAgICAgICAgICAgICAgICAgaWYgKCQudHJpbShhdHRhY2htZW50LmlkKSAhPT0gJycpIHtcblxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHVybCA9ICggdHlwZW9mKGF0dGFjaG1lbnQuc2l6ZXMudGh1bWJuYWlsKSA9PT0gJ3VuZGVmaW5lZCcgKSA/IGF0dGFjaG1lbnQuc2l6ZXMuZnVsbC51cmwgOiBhdHRhY2htZW50LnNpemVzLnRodW1ibmFpbC51cmw7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICQodGhpcykucHJldigpLnZhbChhdHRhY2htZW50LmlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICQodGhpcykuY2xvc2VzdCgnLm1ldGEtaW1hZ2UtZmllbGQtd3JhcHBlcicpLmZpbmQoJ2ltZycpLmF0dHIoJ3NyYycsIHVybCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAkKHRoaXMpLm5leHQoKS5zaG93KCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgLy9maWxlX2ZyYW1lLmNsb3NlKCk7XG4gICAgICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgICAgICAvLyBXaGVuIG9wZW4gc2VsZWN0IHNlbGVjdGVkXG4gICAgICAgICAgICAgICAgZmlsZV9mcmFtZS5vbignb3BlbicsICgpID0+IHtcblxuICAgICAgICAgICAgICAgICAgICAvLyBHcmFiIG91ciBhdHRhY2htZW50IHNlbGVjdGlvbiBhbmQgY29uc3RydWN0IGEgSlNPTiByZXByZXNlbnRhdGlvbiBvZiB0aGUgbW9kZWwuXG4gICAgICAgICAgICAgICAgICAgIGxldCBzZWxlY3Rpb24gID0gZmlsZV9mcmFtZS5zdGF0ZSgpLmdldCgnc2VsZWN0aW9uJyk7XG4gICAgICAgICAgICAgICAgICAgIGxldCBjdXJyZW50ICAgID0gJCh0aGlzKS5wcmV2KCkudmFsKCk7XG4gICAgICAgICAgICAgICAgICAgIGxldCBhdHRhY2htZW50ID0gd3AubWVkaWEuYXR0YWNobWVudChjdXJyZW50KTtcbiAgICAgICAgICAgICAgICAgICAgYXR0YWNobWVudC5mZXRjaCgpO1xuICAgICAgICAgICAgICAgICAgICBzZWxlY3Rpb24uYWRkKGF0dGFjaG1lbnQgPyBbYXR0YWNobWVudF0gOiBbXSk7XG4gICAgICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgICAgICAvLyBGaW5hbGx5LCBvcGVuIHRoZSBtb2RhbC5cbiAgICAgICAgICAgICAgICBmaWxlX2ZyYW1lLm9wZW4oKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIHN0YXRpYyBSZW1vdmVJbWFnZShldmVudCkge1xuXG4gICAgICAgICAgICBldmVudC5wcmV2ZW50RGVmYXVsdCgpO1xuICAgICAgICAgICAgZXZlbnQuc3RvcFByb3BhZ2F0aW9uKCk7XG5cbiAgICAgICAgICAgIGxldCBwbGFjZWhvbGRlciA9ICQodGhpcykuY2xvc2VzdCgnLm1ldGEtaW1hZ2UtZmllbGQtd3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TtBQUNBO0FBQ0E7QUFQQTtBQUFBO0FBQUE7QUFTQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBREE7QUFHQTtBQUxBO0FBQ0E7QUFPQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUE5REE7QUFBQTtBQUFBO0FBQ0E7QUFpRUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBMUVBO0FBQUE7QUFBQTtBQTRFQTtBQUNBO0FBQUE7QUFDQTtBQURBO0FBR0E7QUFoRkE7QUFBQTtBQUFBO0FBa0ZBO0FBQ0E7QUFBQTtBQUNBO0FBcEZBO0FBQUE7QUFBQTtBQXNGQTtBQUNBO0FBQUE7QUFDQTtBQXhGQTtBQUNBO0FBREE7QUFBQTtBQUNBO0FBMEZBO0FBQ0E7QUFDQTs7Ozs7OztBQy9GQTs7Ozs7O0FDQUE7OztBIiwic291cmNlUm9vdCI6IiJ9
|
assets/js/admin.min.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
!function(e){function t(o){if(n[o])return n[o].exports;var i=n[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,n){n(1),n(3),e.exports=n(4)},function(e,t,n){jQuery(function(e){Promise.resolve().then(function(){return n(2)}).then(function(e){var t=e.PluginHelper;t.SelectWoo(),t.ColorPicker(),t.FieldDependency(),t.ImageUploader()})})},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0}),n.d(t,"PluginHelper",function(){return r});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),r=function(e){return function(){function t(){o(this,t)}return i(t,null,[{key:"ImageUploader",value:function(){e(document).off("click","button.wvs_upload_image_button"),e(document).on("click","button.wvs_upload_image_button",this.AddImage),e(document).on("click","button.wvs_remove_image_button",this.RemoveImage)}},{key:"AddImage",value:function(t){var n=this;t.preventDefault(),t.stopPropagation();var o=void 0;if("undefined"!=typeof wp&&wp.media&&wp.media.editor){if(o)return void o.open();o=wp.media.frames.select_image=wp.media({title:WVSPluginObject.media_title,button:{text:WVSPluginObject.button_title},multiple:!1}),o.on("select",function(){var t=o.state().get("selection").first().toJSON();if(""!==e.trim(t.id)){var i=void 0===t.sizes.thumbnail?t.sizes.full.url:t.sizes.thumbnail.url;e(n).prev().val(t.id),e(n).closest(".meta-image-field-wrapper").find("img").attr("src",i),e(n).next().show()}}),o.on("open",function(){var t=o.state().get("selection"),i=e(n).prev().val(),r=wp.media.attachment(i);r.fetch(),t.add(r?[r]:[])}),o.open()}}},{key:"RemoveImage",value:function(t){t.preventDefault(),t.stopPropagation();var n=e(this).closest(".meta-image-field-wrapper").find("img").data("placeholder");return e(this).closest(".meta-image-field-wrapper").find("img").attr("src",n),e(this).prev().prev().val(""),e(this).hide(),!1}},{key:"SelectWoo",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"select.wvs-selectwoo";e(t).selectWoo({allowClear:!0})}},{key:"ColorPicker",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"input.wvs-color-picker";e(t).wpColorPicker()}},{key:"FieldDependency",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"[data-depends]";e(t).FormFieldDependency()}}]),t}()}(jQuery)},function(e,t){},function(e,t){}]);
|
assets/js/form-field-dependency.js
ADDED
@@ -0,0 +1,815 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
2 |
+
|
3 |
+
(function ($) {
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Use on your css file
|
7 |
+
* [data-depends].has-dependent-data {
|
8 |
+
* display : none;
|
9 |
+
* }
|
10 |
+
* @param options
|
11 |
+
* @constructor
|
12 |
+
*/
|
13 |
+
$.fn.FormFieldDependency = function (options) {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Plugin Settings
|
17 |
+
* @type {void|*}
|
18 |
+
*/
|
19 |
+
var settings = $.extend({
|
20 |
+
'attribute': 'depends', // data-depends="[...]"
|
21 |
+
'rules': {}
|
22 |
+
}, options);
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Check array exists on array
|
26 |
+
* @param needleArray
|
27 |
+
* @param haystackArray
|
28 |
+
* @param strict
|
29 |
+
* @returns {boolean}
|
30 |
+
*/
|
31 |
+
var arrayInArraysHelper = function arrayInArraysHelper(needleArray, haystackArray, strict) {
|
32 |
+
|
33 |
+
if (typeof strict == 'undefined') {
|
34 |
+
strict = false;
|
35 |
+
}
|
36 |
+
|
37 |
+
if (needleArray == null) {
|
38 |
+
needleArray = [];
|
39 |
+
}
|
40 |
+
|
41 |
+
if (strict == true) {
|
42 |
+
return needleArray.sort().join(',').toLowerCase() == haystackArray.sort().join(',').toLowerCase();
|
43 |
+
} else {
|
44 |
+
for (var i = 0; i < needleArray.length; i++) {
|
45 |
+
if (haystackArray.indexOf(needleArray[i]) >= 0) {
|
46 |
+
return true;
|
47 |
+
}
|
48 |
+
}
|
49 |
+
return false;
|
50 |
+
}
|
51 |
+
};
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Check string exist on array value
|
55 |
+
* @param needleString
|
56 |
+
* @param haystackArray
|
57 |
+
* @returns {boolean}
|
58 |
+
*/
|
59 |
+
var stringInArraysHelper = function stringInArraysHelper(needleString, haystackArray) {
|
60 |
+
return $.inArray(needleString, haystackArray) >= 0 && $.isArray(haystackArray);
|
61 |
+
};
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Check value is empty or not
|
65 |
+
* @param value
|
66 |
+
* @returns {boolean}
|
67 |
+
*/
|
68 |
+
|
69 |
+
var isEmpty = function isEmpty(value) {
|
70 |
+
|
71 |
+
if (typeof value == 'null' || typeof value == 'undefined') {
|
72 |
+
return true;
|
73 |
+
}
|
74 |
+
|
75 |
+
if (typeof value == 'string') {
|
76 |
+
return $.trim(value) == '';
|
77 |
+
}
|
78 |
+
|
79 |
+
if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) == 'object') {
|
80 |
+
if ($.isArray(value)) {
|
81 |
+
var _tmp = $.map(value, function (val, i) {
|
82 |
+
return $.trim(val) == '' ? null : val;
|
83 |
+
});
|
84 |
+
return $.isEmptyObject(_tmp);
|
85 |
+
} else {
|
86 |
+
return $.isEmptyObject(value);
|
87 |
+
}
|
88 |
+
}
|
89 |
+
};
|
90 |
+
|
91 |
+
/**
|
92 |
+
* For Regular Expression Dependency
|
93 |
+
* @param element
|
94 |
+
* @param depObject
|
95 |
+
* @param parent
|
96 |
+
* @param useEvent
|
97 |
+
*/
|
98 |
+
var typeRegExpDependency = function typeRegExpDependency(element, depObject, parent, useEvent) {
|
99 |
+
|
100 |
+
if (typeof useEvent == 'undefined') {
|
101 |
+
useEvent = false;
|
102 |
+
}
|
103 |
+
|
104 |
+
if (typeof $(parent).prop("tagName") == 'undefined') {
|
105 |
+
return false;
|
106 |
+
}
|
107 |
+
|
108 |
+
var tag = $(parent).prop("tagName").toLowerCase();
|
109 |
+
var type = $(parent).prop("type").toLowerCase();
|
110 |
+
var name = tag + ':' + type;
|
111 |
+
var value = $.trim($(parent).val());
|
112 |
+
|
113 |
+
switch (name) {
|
114 |
+
case "input:text":
|
115 |
+
case "input:password":
|
116 |
+
case "input:number":
|
117 |
+
case "input:date":
|
118 |
+
case "input:email":
|
119 |
+
case "input:url":
|
120 |
+
case "input:tel":
|
121 |
+
case "textarea:textarea":
|
122 |
+
|
123 |
+
var modifier = typeof depObject.modifier == 'undefined' ? '' : depObject.modifier;
|
124 |
+
var pattern = new RegExp(depObject.pattern, modifier);
|
125 |
+
|
126 |
+
if (pattern.test(value)) {
|
127 |
+
$(element).show();
|
128 |
+
} else {
|
129 |
+
$(element).hide();
|
130 |
+
}
|
131 |
+
break;
|
132 |
+
}
|
133 |
+
|
134 |
+
if (useEvent) {
|
135 |
+
$(document.body).on('input', $(parent), function (e) {
|
136 |
+
e.stopPropagation();
|
137 |
+
typeRegExpDependency(element, depObject, parent, false);
|
138 |
+
});
|
139 |
+
}
|
140 |
+
};
|
141 |
+
|
142 |
+
/**
|
143 |
+
* For Empty TextBox
|
144 |
+
* @param element
|
145 |
+
* @param depObject
|
146 |
+
* @param parent
|
147 |
+
* @param useEvent
|
148 |
+
*/
|
149 |
+
var typeEmptyDependency = function typeEmptyDependency(element, depObject, parent, useEvent) {
|
150 |
+
|
151 |
+
if (typeof useEvent == 'undefined') {
|
152 |
+
useEvent = false;
|
153 |
+
}
|
154 |
+
|
155 |
+
if (typeof $(parent).prop("tagName") == 'undefined') {
|
156 |
+
return false;
|
157 |
+
}
|
158 |
+
|
159 |
+
var tag = $(parent).prop("tagName").toLowerCase();
|
160 |
+
var type = $(parent).prop("type").toLowerCase();
|
161 |
+
var name = tag + ':' + type;
|
162 |
+
var value = $(parent).val();
|
163 |
+
|
164 |
+
switch (name) {
|
165 |
+
case "input:text":
|
166 |
+
case "input:password":
|
167 |
+
case "input:number":
|
168 |
+
case "input:date":
|
169 |
+
case "input:email":
|
170 |
+
case "input:url":
|
171 |
+
case "input:tel":
|
172 |
+
case "textarea:textarea":
|
173 |
+
case "select:select-one":
|
174 |
+
|
175 |
+
if ($.trim(value) == '') {
|
176 |
+
$(element).show();
|
177 |
+
} else {
|
178 |
+
$(element).hide();
|
179 |
+
}
|
180 |
+
break;
|
181 |
+
|
182 |
+
case "input:checkbox":
|
183 |
+
if ($(parent).is(':checked') && $.trim(value) != '') {
|
184 |
+
$(element).hide();
|
185 |
+
} else {
|
186 |
+
$(element).show();
|
187 |
+
}
|
188 |
+
break;
|
189 |
+
|
190 |
+
case "select:select-multiple":
|
191 |
+
|
192 |
+
if (isEmpty(value)) {
|
193 |
+
$(element).show();
|
194 |
+
} else {
|
195 |
+
$(element).hide();
|
196 |
+
}
|
197 |
+
|
198 |
+
break;
|
199 |
+
}
|
200 |
+
|
201 |
+
if (useEvent) {
|
202 |
+
$(document.body).on('input change', $(parent), function (e) {
|
203 |
+
e.stopPropagation();
|
204 |
+
typeEmptyDependency(element, depObject, parent, false);
|
205 |
+
});
|
206 |
+
}
|
207 |
+
};
|
208 |
+
|
209 |
+
/**
|
210 |
+
* For non empty TextBox
|
211 |
+
* @param element
|
212 |
+
* @param depObject
|
213 |
+
* @param parent
|
214 |
+
* @param useEvent
|
215 |
+
*/
|
216 |
+
var typeNotEmptyDependency = function typeNotEmptyDependency(element, depObject, parent, useEvent) {
|
217 |
+
|
218 |
+
if (typeof useEvent == 'undefined') {
|
219 |
+
useEvent = false;
|
220 |
+
}
|
221 |
+
|
222 |
+
if (typeof $(parent).prop("tagName") == 'undefined') {
|
223 |
+
return false;
|
224 |
+
}
|
225 |
+
|
226 |
+
var tag = $(parent).prop("tagName").toLowerCase();
|
227 |
+
var type = $(parent).prop("type").toLowerCase();
|
228 |
+
var name = tag + ':' + type;
|
229 |
+
var value = $(parent).val();
|
230 |
+
|
231 |
+
switch (name) {
|
232 |
+
case "input:text":
|
233 |
+
case "input:password":
|
234 |
+
case "input:number":
|
235 |
+
case "input:date":
|
236 |
+
case "input:email":
|
237 |
+
case "input:url":
|
238 |
+
case "input:tel":
|
239 |
+
case "textarea:textarea":
|
240 |
+
case "select:select-one":
|
241 |
+
|
242 |
+
if ($.trim(value) != '') {
|
243 |
+
$(element).show();
|
244 |
+
} else {
|
245 |
+
$(element).hide();
|
246 |
+
}
|
247 |
+
break;
|
248 |
+
|
249 |
+
case "input:checkbox":
|
250 |
+
if ($(parent).is(':checked') && $.trim(value) != '') {
|
251 |
+
$(element).show();
|
252 |
+
} else {
|
253 |
+
$(element).hide();
|
254 |
+
}
|
255 |
+
break;
|
256 |
+
|
257 |
+
case "select:select-multiple":
|
258 |
+
|
259 |
+
if (isEmpty(value)) {
|
260 |
+
$(element).hide();
|
261 |
+
} else {
|
262 |
+
$(element).show();
|
263 |
+
}
|
264 |
+
|
265 |
+
break;
|
266 |
+
}
|
267 |
+
|
268 |
+
if (useEvent) {
|
269 |
+
$(document.body).on('input change', $(parent), function (e) {
|
270 |
+
e.stopPropagation();
|
271 |
+
typeNotEmptyDependency(element, depObject, parent, false);
|
272 |
+
});
|
273 |
+
}
|
274 |
+
};
|
275 |
+
|
276 |
+
/**
|
277 |
+
* TextBox value matched with value or with array values
|
278 |
+
* @param element
|
279 |
+
* @param depObject
|
280 |
+
* @param parent
|
281 |
+
* @param useEvent
|
282 |
+
*/
|
283 |
+
var typeEqualDependency = function typeEqualDependency(element, depObject, parent, useEvent) {
|
284 |
+
|
285 |
+
if (typeof useEvent == 'undefined') {
|
286 |
+
useEvent = false;
|
287 |
+
}
|
288 |
+
|
289 |
+
if (typeof $(parent).prop("tagName") == 'undefined') {
|
290 |
+
return false;
|
291 |
+
}
|
292 |
+
|
293 |
+
var tag = $(parent).prop("tagName").toLowerCase();
|
294 |
+
var type = $(parent).prop("type").toLowerCase();
|
295 |
+
var name = tag + ':' + type;
|
296 |
+
var value = $(parent).val();
|
297 |
+
|
298 |
+
var equalLike = typeof depObject.like == 'undefined' ? false : true;
|
299 |
+
|
300 |
+
// show if empty?. default false
|
301 |
+
depObject.empty = typeof depObject.empty == 'undefined' ? false : depObject.empty;
|
302 |
+
|
303 |
+
depObject.strict = typeof depObject.strict == 'undefined' ? false : depObject.strict;
|
304 |
+
|
305 |
+
if (equalLike) {
|
306 |
+
|
307 |
+
var eqtag = $(depObject.like).prop("tagName").toLowerCase();
|
308 |
+
var eqtype = $(depObject.like).prop("type").toLowerCase();
|
309 |
+
var eqname = eqtag + ':' + eqtype;
|
310 |
+
|
311 |
+
if (eqname == 'input:checkbox' || eqname == 'input:radio') {
|
312 |
+
depObject.value = $(depObject.like + ':checked').map(function () {
|
313 |
+
return this.value;
|
314 |
+
}).get();
|
315 |
+
} else {
|
316 |
+
|
317 |
+
depObject.value = $(depObject.like).val();
|
318 |
+
|
319 |
+
if (!showOnEmptyValue) {
|
320 |
+
depObject.value = $.trim($(depObject.like).val()) == '' ? null : $(depObject.like).val();
|
321 |
+
}
|
322 |
+
}
|
323 |
+
}
|
324 |
+
|
325 |
+
switch (name) {
|
326 |
+
case "input:text":
|
327 |
+
case "input:password":
|
328 |
+
case "input:number":
|
329 |
+
case "input:date":
|
330 |
+
case "input:email":
|
331 |
+
case "input:url":
|
332 |
+
case "input:tel":
|
333 |
+
case "textarea:textarea":
|
334 |
+
case "select:select-one":
|
335 |
+
|
336 |
+
if ($.trim(value) == depObject.value) {
|
337 |
+
$(element).show();
|
338 |
+
} else if (stringInArraysHelper(value, depObject.value)) {
|
339 |
+
$(element).show();
|
340 |
+
} else {
|
341 |
+
if ($.trim(value) == '' && depObject.empty) {
|
342 |
+
$(element).show();
|
343 |
+
} else {
|
344 |
+
$(element).hide();
|
345 |
+
}
|
346 |
+
}
|
347 |
+
break;
|
348 |
+
|
349 |
+
case "input:checkbox":
|
350 |
+
case "input:radio":
|
351 |
+
|
352 |
+
var value = $(parent + ':checked').map(function () {
|
353 |
+
return this.value;
|
354 |
+
}).get();
|
355 |
+
|
356 |
+
if (value == depObject.value) {
|
357 |
+
$(element).show();
|
358 |
+
} else if (stringInArraysHelper(value, depObject.value)) {
|
359 |
+
$(element).show();
|
360 |
+
} else if (arrayInArraysHelper(value, depObject.value, depObject.strict)) {
|
361 |
+
$(element).show();
|
362 |
+
} else {
|
363 |
+
if (isEmpty(value) && depObject.empty) {
|
364 |
+
$(element).show();
|
365 |
+
} else {
|
366 |
+
$(element).hide();
|
367 |
+
}
|
368 |
+
}
|
369 |
+
break;
|
370 |
+
|
371 |
+
case "select:select-multiple":
|
372 |
+
|
373 |
+
if (arrayInArraysHelper(value, depObject.value, depObject.strict)) {
|
374 |
+
$(element).show();
|
375 |
+
} else {
|
376 |
+
|
377 |
+
if (value == null && depObject.empty) {
|
378 |
+
$(element).show();
|
379 |
+
} else {
|
380 |
+
$(element).hide();
|
381 |
+
}
|
382 |
+
}
|
383 |
+
break;
|
384 |
+
}
|
385 |
+
|
386 |
+
if (useEvent) {
|
387 |
+
$(document.body).on('input change', $(parent), function (e) {
|
388 |
+
e.stopPropagation();
|
389 |
+
typeEqualDependency(element, depObject, parent, false);
|
390 |
+
});
|
391 |
+
}
|
392 |
+
};
|
393 |
+
|
394 |
+
/**
|
395 |
+
* TextBox value not equal with value or with array values
|
396 |
+
* @param element
|
397 |
+
* @param depObject
|
398 |
+
* @param parent
|
399 |
+
* @param useEvent
|
400 |
+
*/
|
401 |
+
var typeNotEqualDependency = function typeNotEqualDependency(element, depObject, parent, useEvent) {
|
402 |
+
|
403 |
+
if (typeof useEvent == 'undefined') {
|
404 |
+
useEvent = false;
|
405 |
+
}
|
406 |
+
|
407 |
+
if (typeof $(parent).prop("tagName") == 'undefined') {
|
408 |
+
return false;
|
409 |
+
}
|
410 |
+
|
411 |
+
var tag = $(parent).prop("tagName").toLowerCase();
|
412 |
+
var type = $(parent).prop("type").toLowerCase();
|
413 |
+
var name = tag + ':' + type;
|
414 |
+
var value = $(parent).val();
|
415 |
+
|
416 |
+
var equalLike = typeof depObject.like == 'undefined' ? false : true;
|
417 |
+
depObject.strict = typeof depObject.strict == 'undefined' ? false : depObject.strict;
|
418 |
+
|
419 |
+
// show if empty? default is true
|
420 |
+
depObject.empty = typeof depObject.empty == 'undefined' ? true : depObject.empty;
|
421 |
+
|
422 |
+
if (equalLike) {
|
423 |
+
|
424 |
+
var eqtag = $(depObject.like).prop("tagName").toLowerCase();
|
425 |
+
var eqtype = $(depObject.like).prop("type").toLowerCase();
|
426 |
+
var eqname = eqtag + ':' + eqtype;
|
427 |
+
|
428 |
+
if (eqname == 'input:checkbox' || eqname == 'input:radio') {
|
429 |
+
depObject.value = $(depObject.like + ':checked').map(function () {
|
430 |
+
return this.value;
|
431 |
+
}).get();
|
432 |
+
} else {
|
433 |
+
|
434 |
+
depObject.value = $(depObject.like).val();
|
435 |
+
|
436 |
+
if (!showOnEmptyValue) {
|
437 |
+
depObject.value = $.trim($(depObject.like).val()) == '' ? null : $(depObject.like).val();
|
438 |
+
}
|
439 |
+
}
|
440 |
+
}
|
441 |
+
|
442 |
+
switch (name) {
|
443 |
+
case "input:text":
|
444 |
+
case "input:password":
|
445 |
+
case "input:number":
|
446 |
+
case "input:date":
|
447 |
+
case "input:email":
|
448 |
+
case "input:url":
|
449 |
+
case "input:tel":
|
450 |
+
case "textarea:textarea":
|
451 |
+
case "select:select-one":
|
452 |
+
|
453 |
+
if (value == depObject.value) {
|
454 |
+
$(element).hide();
|
455 |
+
} else if (stringInArraysHelper(value, depObject.value)) {
|
456 |
+
$(element).hide();
|
457 |
+
} else {
|
458 |
+
if ($.trim(value) == '' && !depObject.empty) {
|
459 |
+
$(element).hide();
|
460 |
+
} else {
|
461 |
+
$(element).show();
|
462 |
+
}
|
463 |
+
}
|
464 |
+
break;
|
465 |
+
|
466 |
+
case "input:checkbox":
|
467 |
+
case "input:radio":
|
468 |
+
|
469 |
+
value = $(parent + ':checked').map(function () {
|
470 |
+
return this.value;
|
471 |
+
}).get();
|
472 |
+
|
473 |
+
if (typeof depObject.strict == 'undefined') {
|
474 |
+
depObject.strict = false;
|
475 |
+
}
|
476 |
+
|
477 |
+
if (value == depObject.value) {
|
478 |
+
|
479 |
+
$(element).hide();
|
480 |
+
} else if (stringInArraysHelper(value, depObject.value)) {
|
481 |
+
|
482 |
+
$(element).hide();
|
483 |
+
} else if (arrayInArraysHelper(value, depObject.value, depObject.strict)) {
|
484 |
+
|
485 |
+
$(element).hide();
|
486 |
+
} else {
|
487 |
+
if (isEmpty(value) && !depObject.empty) {
|
488 |
+
$(element).hide();
|
489 |
+
} else {
|
490 |
+
$(element).show();
|
491 |
+
}
|
492 |
+
}
|
493 |
+
|
494 |
+
break;
|
495 |
+
|
496 |
+
case "select:select-multiple":
|
497 |
+
|
498 |
+
if (arrayInArraysHelper(value, depObject.value, depObject.strict)) {
|
499 |
+
$(element).hide();
|
500 |
+
} else {
|
501 |
+
if (value == null && !depObject.empty) {
|
502 |
+
$(element).hide();
|
503 |
+
} else {
|
504 |
+
$(element).show();
|
505 |
+
}
|
506 |
+
}
|
507 |
+
|
508 |
+
break;
|
509 |
+
}
|
510 |
+
|
511 |
+
if (useEvent) {
|
512 |
+
$(document.body).on('input change', $(parent), function (e) {
|
513 |
+
e.stopPropagation();
|
514 |
+
typeNotEqualDependency(element, depObject, parent, false);
|
515 |
+
});
|
516 |
+
}
|
517 |
+
};
|
518 |
+
|
519 |
+
/**
|
520 |
+
* TextBox value compare
|
521 |
+
* @param element
|
522 |
+
* @param depObject
|
523 |
+
* @param parent
|
524 |
+
* @param useEvent
|
525 |
+
*/
|
526 |
+
var typeCompareDependency = function typeCompareDependency(element, depObject, parent, useEvent) {
|
527 |
+
|
528 |
+
if (typeof useEvent == 'undefined') {
|
529 |
+
useEvent = false;
|
530 |
+
}
|
531 |
+
|
532 |
+
if (typeof $(parent).prop("tagName") == 'undefined') {
|
533 |
+
return false;
|
534 |
+
}
|
535 |
+
|
536 |
+
var tag = $(parent).prop("tagName").toLowerCase();
|
537 |
+
var type = $(parent).prop("type").toLowerCase();
|
538 |
+
var name = tag + ':' + type;
|
539 |
+
var value = parseInt($(parent).val());
|
540 |
+
depObject.value = parseInt(depObject.value);
|
541 |
+
|
542 |
+
switch (depObject.sign) {
|
543 |
+
case "<":
|
544 |
+
case "lt":
|
545 |
+
case "lessthen":
|
546 |
+
case "less-then":
|
547 |
+
case "LessThen":
|
548 |
+
if (value < depObject.value) {
|
549 |
+
$(element).show();
|
550 |
+
} else {
|
551 |
+
$(element).hide();
|
552 |
+
}
|
553 |
+
break;
|
554 |
+
|
555 |
+
case "<=":
|
556 |
+
case "lteq":
|
557 |
+
case "lessthenequal":
|
558 |
+
case "less-then-equal":
|
559 |
+
case "LessThenEqual":
|
560 |
+
case "eqlt":
|
561 |
+
if (value <= depObject.value) {
|
562 |
+
$(element).show();
|
563 |
+
} else {
|
564 |
+
$(element).hide();
|
565 |
+
}
|
566 |
+
break;
|
567 |
+
|
568 |
+
case ">=":
|
569 |
+
case "gteq":
|
570 |
+
case "greaterthenequal":
|
571 |
+
case "greater-then-equal":
|
572 |
+
case "GreaterThenEqual":
|
573 |
+
case "eqgt":
|
574 |
+
if (value >= depObject.value) {
|
575 |
+
$(element).show();
|
576 |
+
} else {
|
577 |
+
$(element).hide();
|
578 |
+
}
|
579 |
+
break;
|
580 |
+
|
581 |
+
case ">":
|
582 |
+
case "gt":
|
583 |
+
case "greaterthen":
|
584 |
+
case "greater-then":
|
585 |
+
case "GreaterThen":
|
586 |
+
if (value > depObject.value) {
|
587 |
+
$(element).show();
|
588 |
+
} else {
|
589 |
+
$(element).hide();
|
590 |
+
}
|
591 |
+
break;
|
592 |
+
|
593 |
+
}
|
594 |
+
|
595 |
+
if (useEvent) {
|
596 |
+
$(document.body).on('input change', $(parent), function (e) {
|
597 |
+
e.stopPropagation();
|
598 |
+
typeCompareDependency(element, depObject, parent, false);
|
599 |
+
});
|
600 |
+
}
|
601 |
+
};
|
602 |
+
|
603 |
+
/**
|
604 |
+
* TextBox value range
|
605 |
+
* @param element
|
606 |
+
* @param depObject
|
607 |
+
* @param parent
|
608 |
+
* @param useEvent
|
609 |
+
*/
|
610 |
+
var typeRangeDependency = function typeRangeDependency(element, depObject, parent, useEvent) {
|
611 |
+
|
612 |
+
if (typeof useEvent == 'undefined') {
|
613 |
+
useEvent = false;
|
614 |
+
}
|
615 |
+
|
616 |
+
if (typeof $(parent).prop("tagName") == 'undefined') {
|
617 |
+
return false;
|
618 |
+
}
|
619 |
+
|
620 |
+
var tag = $(parent).prop("tagName").toLowerCase();
|
621 |
+
var type = $(parent).prop("type").toLowerCase();
|
622 |
+
var name = tag + ':' + type;
|
623 |
+
var value = parseInt($(parent).val());
|
624 |
+
var min, max;
|
625 |
+
|
626 |
+
// value = [50, 100]
|
627 |
+
|
628 |
+
if ($.isArray(depObject.value)) {
|
629 |
+
min = parseInt(depObject.value[0]);
|
630 |
+
max = parseInt(depObject.value[1]);
|
631 |
+
}
|
632 |
+
|
633 |
+
if (typeof depObject.value == 'undefined') {
|
634 |
+
min = parseInt(depObject.min);
|
635 |
+
max = parseInt(depObject.max);
|
636 |
+
}
|
637 |
+
|
638 |
+
if (min < value && value < max) {
|
639 |
+
$(element).show();
|
640 |
+
} else {
|
641 |
+
$(element).hide();
|
642 |
+
}
|
643 |
+
|
644 |
+
if (useEvent) {
|
645 |
+
$(document.body).on('input change', $(parent), function (e) {
|
646 |
+
e.stopPropagation();
|
647 |
+
typeRangeDependency(element, depObject, parent, false);
|
648 |
+
});
|
649 |
+
}
|
650 |
+
};
|
651 |
+
|
652 |
+
/**
|
653 |
+
* TextBox value length
|
654 |
+
* @param element
|
655 |
+
* @param depObject
|
656 |
+
* @param parent
|
657 |
+
* @param useEvent
|
658 |
+
*/
|
659 |
+
var typeLengthDependency = function typeLengthDependency(element, depObject, parent, useEvent) {
|
660 |
+
|
661 |
+
if (typeof useEvent == 'undefined') {
|
662 |
+
useEvent = false;
|
663 |
+
}
|
664 |
+
|
665 |
+
if (typeof $(parent).prop("tagName") == 'undefined') {
|
666 |
+
return false;
|
667 |
+
}
|
668 |
+
|
669 |
+
var tag = $(parent).prop("tagName").toLowerCase();
|
670 |
+
var type = $(parent).prop("type").toLowerCase();
|
671 |
+
var name = tag + ':' + type;
|
672 |
+
var value = $(parent).val().length;
|
673 |
+
depObject.value = parseInt(depObject.value);
|
674 |
+
|
675 |
+
switch (depObject.sign) {
|
676 |
+
case "<":
|
677 |
+
case "lt":
|
678 |
+
case "lessthen":
|
679 |
+
case "less-then":
|
680 |
+
case "LessThen":
|
681 |
+
if (value < depObject.value) {
|
682 |
+
$(element).show();
|
683 |
+
} else {
|
684 |
+
$(element).hide();
|
685 |
+
}
|
686 |
+
break;
|
687 |
+
|
688 |
+
case "<=":
|
689 |
+
case "lteq":
|
690 |
+
case "lessthenequal":
|
691 |
+
case "less-then-equal":
|
692 |
+
case "LessThenEqual":
|
693 |
+
case "eqlt":
|
694 |
+
if (value <= depObject.value) {
|
695 |
+
$(element).show();
|
696 |
+
} else {
|
697 |
+
$(element).hide();
|
698 |
+
}
|
699 |
+
break;
|
700 |
+
|
701 |
+
case ">=":
|
702 |
+
case "gteq":
|
703 |
+
case "greaterthenequal":
|
704 |
+
case "greater-then-equal":
|
705 |
+
case "GreaterThenEqual":
|
706 |
+
case "eqgt":
|
707 |
+
if (value >= depObject.value) {
|
708 |
+
$(element).show();
|
709 |
+
} else {
|
710 |
+
$(element).hide();
|
711 |
+
}
|
712 |
+
break;
|
713 |
+
|
714 |
+
case ">":
|
715 |
+
case "gt":
|
716 |
+
case "greaterthen":
|
717 |
+
case "greater-then":
|
718 |
+
case "GreaterThen":
|
719 |
+
if (value > depObject.value) {
|
720 |
+
$(element).show();
|
721 |
+
} else {
|
722 |
+
$(element).hide();
|
723 |
+
}
|
724 |
+
break;
|
725 |
+
|
726 |
+
}
|
727 |
+
|
728 |
+
if (useEvent) {
|
729 |
+
$(document.body).on('input change', $(parent), function (e) {
|
730 |
+
e.stopPropagation();
|
731 |
+
typeLengthDependency(element, depObject, parent, false);
|
732 |
+
});
|
733 |
+
}
|
734 |
+
};
|
735 |
+
|
736 |
+
/**
|
737 |
+
* Using Types
|
738 |
+
* @param $el
|
739 |
+
* @param $data
|
740 |
+
*/
|
741 |
+
var useTypes = function useTypes($el, $data) {
|
742 |
+
$.each($data, function (selector, depObject) {
|
743 |
+
|
744 |
+
switch (depObject.type) {
|
745 |
+
case "empty":
|
746 |
+
typeEmptyDependency($el, depObject, selector, true);
|
747 |
+
break;
|
748 |
+
|
749 |
+
case "notempty":
|
750 |
+
case "not-empty":
|
751 |
+
case "notEmpty":
|
752 |
+
case "!empty":
|
753 |
+
typeNotEmptyDependency($el, depObject, selector, true);
|
754 |
+
break;
|
755 |
+
|
756 |
+
case "equal":
|
757 |
+
case "==":
|
758 |
+
case "=":
|
759 |
+
typeEqualDependency($el, depObject, selector, true);
|
760 |
+
break;
|
761 |
+
|
762 |
+
case "!equal":
|
763 |
+
case "notequal":
|
764 |
+
case "!=":
|
765 |
+
case "not-equal":
|
766 |
+
case "notEqual":
|
767 |
+
typeNotEqualDependency($el, depObject, selector, true);
|
768 |
+
break;
|
769 |
+
|
770 |
+
case "regexp":
|
771 |
+
case "expression":
|
772 |
+
case "reg":
|
773 |
+
case "exp":
|
774 |
+
typeRegExpDependency($el, depObject, selector, true);
|
775 |
+
break;
|
776 |
+
|
777 |
+
case "compare":
|
778 |
+
case "comp":
|
779 |
+
typeCompareDependency($el, depObject, selector, true);
|
780 |
+
break;
|
781 |
+
|
782 |
+
case "length":
|
783 |
+
case "lng":
|
784 |
+
typeLengthDependency($el, depObject, selector, true);
|
785 |
+
break;
|
786 |
+
|
787 |
+
case "range":
|
788 |
+
typeRangeDependency($el, depObject, selector, true);
|
789 |
+
break;
|
790 |
+
|
791 |
+
}
|
792 |
+
});
|
793 |
+
};
|
794 |
+
|
795 |
+
(function ($data) {
|
796 |
+
$.each($data, function ($el, depObject) {
|
797 |
+
useTypes($($el), depObject);
|
798 |
+
});
|
799 |
+
})(settings.rules);
|
800 |
+
|
801 |
+
return this.each(function () {
|
802 |
+
// var $data = $(this).data('depends');
|
803 |
+
var $data = $(this).data(settings.attribute.replace('data-', '').trim());
|
804 |
+
|
805 |
+
if ($data) {
|
806 |
+
|
807 |
+
$(this).addClass('has-dependent-data');
|
808 |
+
|
809 |
+
$.each($data, function (el, obj) {
|
810 |
+
useTypes($(this), obj);
|
811 |
+
}.bind(this));
|
812 |
+
}
|
813 |
+
});
|
814 |
+
};
|
815 |
+
})(jQuery);
|
assets/js/form-field-dependency.min.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(e){e.fn.FormFieldDependency=function(t){var a=e.extend({attribute:"depends",rules:{}},t),s=function(e,t,a){if(void 0===a&&(a=!1),null==e&&(e=[]),1==a)return e.sort().join(",").toLowerCase()==t.sort().join(",").toLowerCase();for(var s=0;s<e.length;s++)if(t.indexOf(e[s])>=0)return!0;return!1},o=function(t,a){return e.inArray(t,a)>=0&&e.isArray(a)},i=function(t){if("null"==typeof t||void 0===t)return!0;if("string"==typeof t)return""==e.trim(t);if("object"==(void 0===t?"undefined":_typeof(t))){if(e.isArray(t)){var a=e.map(t,function(t,a){return""==e.trim(t)?null:t});return e.isEmptyObject(a)}return e.isEmptyObject(t)}},n=function t(a,s,o,i){if(void 0===i&&(i=!1),void 0===e(o).prop("tagName"))return!1;var n=e(o).prop("tagName").toLowerCase(),r=e(o).prop("type").toLowerCase(),c=n+":"+r,u=e.trim(e(o).val());switch(c){case"input:text":case"input:password":case"input:number":case"input:date":case"input:email":case"input:url":case"input:tel":case"textarea:textarea":var p=void 0===s.modifier?"":s.modifier;new RegExp(s.pattern,p).test(u)?e(a).show():e(a).hide()}i&&e(document.body).on("input",e(o),function(e){e.stopPropagation(),t(a,s,o,!1)})},r=function t(a,s,o,n){if(void 0===n&&(n=!1),void 0===e(o).prop("tagName"))return!1;var r=e(o).prop("tagName").toLowerCase(),c=e(o).prop("type").toLowerCase(),u=r+":"+c,p=e(o).val();switch(u){case"input:text":case"input:password":case"input:number":case"input:date":case"input:email":case"input:url":case"input:tel":case"textarea:textarea":case"select:select-one":""==e.trim(p)?e(a).show():e(a).hide();break;case"input:checkbox":e(o).is(":checked")&&""!=e.trim(p)?e(a).hide():e(a).show();break;case"select:select-multiple":i(p)?e(a).show():e(a).hide()}n&&e(document.body).on("input change",e(o),function(e){e.stopPropagation(),t(a,s,o,!1)})},c=function t(a,s,o,n){if(void 0===n&&(n=!1),void 0===e(o).prop("tagName"))return!1;var r=e(o).prop("tagName").toLowerCase(),c=e(o).prop("type").toLowerCase(),u=r+":"+c,p=e(o).val();switch(u){case"input:text":case"input:password":case"input:number":case"input:date":case"input:email":case"input:url":case"input:tel":case"textarea:textarea":case"select:select-one":""!=e.trim(p)?e(a).show():e(a).hide();break;case"input:checkbox":e(o).is(":checked")&&""!=e.trim(p)?e(a).show():e(a).hide();break;case"select:select-multiple":i(p)?e(a).hide():e(a).show()}n&&e(document.body).on("input change",e(o),function(e){e.stopPropagation(),t(a,s,o,!1)})},u=function t(a,n,r,c){if(void 0===c&&(c=!1),void 0===e(r).prop("tagName"))return!1;var u=e(r).prop("tagName").toLowerCase(),p=e(r).prop("type").toLowerCase(),l=u+":"+p,h=e(r).val(),d=void 0!==n.like;if(n.empty=void 0!==n.empty&&n.empty,n.strict=void 0!==n.strict&&n.strict,d){var v=e(n.like).prop("tagName").toLowerCase(),m=e(n.like).prop("type").toLowerCase(),f=v+":"+m;"input:checkbox"==f||"input:radio"==f?n.value=e(n.like+":checked").map(function(){return this.value}).get():(n.value=e(n.like).val(),showOnEmptyValue||(n.value=""==e.trim(e(n.like).val())?null:e(n.like).val()))}switch(l){case"input:text":case"input:password":case"input:number":case"input:date":case"input:email":case"input:url":case"input:tel":case"textarea:textarea":case"select:select-one":e.trim(h)==n.value?e(a).show():o(h,n.value)?e(a).show():""==e.trim(h)&&n.empty?e(a).show():e(a).hide();break;case"input:checkbox":case"input:radio":var h=e(r+":checked").map(function(){return this.value}).get();h==n.value?e(a).show():o(h,n.value)?e(a).show():s(h,n.value,n.strict)?e(a).show():i(h)&&n.empty?e(a).show():e(a).hide();break;case"select:select-multiple":s(h,n.value,n.strict)?e(a).show():null==h&&n.empty?e(a).show():e(a).hide()}c&&e(document.body).on("input change",e(r),function(e){e.stopPropagation(),t(a,n,r,!1)})},p=function t(a,n,r,c){if(void 0===c&&(c=!1),void 0===e(r).prop("tagName"))return!1;var u=e(r).prop("tagName").toLowerCase(),p=e(r).prop("type").toLowerCase(),l=u+":"+p,h=e(r).val(),d=void 0!==n.like;if(n.strict=void 0!==n.strict&&n.strict,n.empty=void 0===n.empty||n.empty,d){var v=e(n.like).prop("tagName").toLowerCase(),m=e(n.like).prop("type").toLowerCase(),f=v+":"+m;"input:checkbox"==f||"input:radio"==f?n.value=e(n.like+":checked").map(function(){return this.value}).get():(n.value=e(n.like).val(),showOnEmptyValue||(n.value=""==e.trim(e(n.like).val())?null:e(n.like).val()))}switch(l){case"input:text":case"input:password":case"input:number":case"input:date":case"input:email":case"input:url":case"input:tel":case"textarea:textarea":case"select:select-one":h==n.value?e(a).hide():o(h,n.value)?e(a).hide():""!=e.trim(h)||n.empty?e(a).show():e(a).hide();break;case"input:checkbox":case"input:radio":h=e(r+":checked").map(function(){return this.value}).get(),void 0===n.strict&&(n.strict=!1),h==n.value?e(a).hide():o(h,n.value)?e(a).hide():s(h,n.value,n.strict)?e(a).hide():i(h)&&!n.empty?e(a).hide():e(a).show();break;case"select:select-multiple":s(h,n.value,n.strict)?e(a).hide():null!=h||n.empty?e(a).show():e(a).hide()}c&&e(document.body).on("input change",e(r),function(e){e.stopPropagation(),t(a,n,r,!1)})},l=function t(a,s,o,i){if(void 0===i&&(i=!1),void 0===e(o).prop("tagName"))return!1;var n=(e(o).prop("tagName").toLowerCase(),e(o).prop("type").toLowerCase(),parseInt(e(o).val()));switch(s.value=parseInt(s.value),s.sign){case"<":case"lt":case"lessthen":case"less-then":case"LessThen":n<s.value?e(a).show():e(a).hide();break;case"<=":case"lteq":case"lessthenequal":case"less-then-equal":case"LessThenEqual":case"eqlt":n<=s.value?e(a).show():e(a).hide();break;case">=":case"gteq":case"greaterthenequal":case"greater-then-equal":case"GreaterThenEqual":case"eqgt":n>=s.value?e(a).show():e(a).hide();break;case">":case"gt":case"greaterthen":case"greater-then":case"GreaterThen":n>s.value?e(a).show():e(a).hide()}i&&e(document.body).on("input change",e(o),function(e){e.stopPropagation(),t(a,s,o,!1)})},h=function t(a,s,o,i){if(void 0===i&&(i=!1),void 0===e(o).prop("tagName"))return!1;var n,r,c=(e(o).prop("tagName").toLowerCase(),e(o).prop("type").toLowerCase(),parseInt(e(o).val()));e.isArray(s.value)&&(n=parseInt(s.value[0]),r=parseInt(s.value[1])),void 0===s.value&&(n=parseInt(s.min),r=parseInt(s.max)),n<c&&c<r?e(a).show():e(a).hide(),i&&e(document.body).on("input change",e(o),function(e){e.stopPropagation(),t(a,s,o,!1)})},d=function t(a,s,o,i){if(void 0===i&&(i=!1),void 0===e(o).prop("tagName"))return!1;var n=(e(o).prop("tagName").toLowerCase(),e(o).prop("type").toLowerCase(),e(o).val().length);switch(s.value=parseInt(s.value),s.sign){case"<":case"lt":case"lessthen":case"less-then":case"LessThen":n<s.value?e(a).show():e(a).hide();break;case"<=":case"lteq":case"lessthenequal":case"less-then-equal":case"LessThenEqual":case"eqlt":n<=s.value?e(a).show():e(a).hide();break;case">=":case"gteq":case"greaterthenequal":case"greater-then-equal":case"GreaterThenEqual":case"eqgt":n>=s.value?e(a).show():e(a).hide();break;case">":case"gt":case"greaterthen":case"greater-then":case"GreaterThen":n>s.value?e(a).show():e(a).hide()}i&&e(document.body).on("input change",e(o),function(e){e.stopPropagation(),t(a,s,o,!1)})},v=function(t,a){e.each(a,function(e,a){switch(a.type){case"empty":r(t,a,e,!0);break;case"notempty":case"not-empty":case"notEmpty":case"!empty":c(t,a,e,!0);break;case"equal":case"==":case"=":u(t,a,e,!0);break;case"!equal":case"notequal":case"!=":case"not-equal":case"notEqual":p(t,a,e,!0);break;case"regexp":case"expression":case"reg":case"exp":n(t,a,e,!0);break;case"compare":case"comp":l(t,a,e,!0);break;case"length":case"lng":d(t,a,e,!0);break;case"range":h(t,a,e,!0)}})};return function(t){e.each(t,function(t,a){v(e(t),a)})}(a.rules),this.each(function(){var t=e(this).data(a.attribute.replace("data-","").trim());t&&(e(this).addClass("has-dependent-data"),e.each(t,function(t,a){v(e(this),a)}.bind(this)))})}}(jQuery);
|
assets/js/frontend.js
ADDED
@@ -0,0 +1,244 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*!
|
2 |
+
* Woo Variation Swatches v1.0.0
|
3 |
+
*
|
4 |
+
* Author: Emran Ahmed ( emran.bd.08@gmail.com )
|
5 |
+
* Date: 2017-12-20 17:41:58
|
6 |
+
* Released under the GPLv3 license.
|
7 |
+
*/
|
8 |
+
/******/ (function(modules) { // webpackBootstrap
|
9 |
+
/******/ // The module cache
|
10 |
+
/******/ var installedModules = {};
|
11 |
+
/******/
|
12 |
+
/******/ // The require function
|
13 |
+
/******/ function __webpack_require__(moduleId) {
|
14 |
+
/******/
|
15 |
+
/******/ // Check if module is in cache
|
16 |
+
/******/ if(installedModules[moduleId]) {
|
17 |
+
/******/ return installedModules[moduleId].exports;
|
18 |
+
/******/ }
|
19 |
+
/******/ // Create a new module (and put it into the cache)
|
20 |
+
/******/ var module = installedModules[moduleId] = {
|
21 |
+
/******/ i: moduleId,
|
22 |
+
/******/ l: false,
|
23 |
+
/******/ exports: {}
|
24 |
+
/******/ };
|
25 |
+
/******/
|
26 |
+
/******/ // Execute the module function
|
27 |
+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
28 |
+
/******/
|
29 |
+
/******/ // Flag the module as loaded
|
30 |
+
/******/ module.l = true;
|
31 |
+
/******/
|
32 |
+
/******/ // Return the exports of the module
|
33 |
+
/******/ return module.exports;
|
34 |
+
/******/ }
|
35 |
+
/******/
|
36 |
+
/******/
|
37 |
+
/******/ // expose the modules object (__webpack_modules__)
|
38 |
+
/******/ __webpack_require__.m = modules;
|
39 |
+
/******/
|
40 |
+
/******/ // expose the module cache
|
41 |
+
/******/ __webpack_require__.c = installedModules;
|
42 |
+
/******/
|
43 |
+
/******/ // define getter function for harmony exports
|
44 |
+
/******/ __webpack_require__.d = function(exports, name, getter) {
|
45 |
+
/******/ if(!__webpack_require__.o(exports, name)) {
|
46 |
+
/******/ Object.defineProperty(exports, name, {
|
47 |
+
/******/ configurable: false,
|
48 |
+
/******/ enumerable: true,
|
49 |
+
/******/ get: getter
|
50 |
+
/******/ });
|
51 |
+
/******/ }
|
52 |
+
/******/ };
|
53 |
+
/******/
|
54 |
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
55 |
+
/******/ __webpack_require__.n = function(module) {
|
56 |
+
/******/ var getter = module && module.__esModule ?
|
57 |
+
/******/ function getDefault() { return module['default']; } :
|
58 |
+
/******/ function getModuleExports() { return module; };
|
59 |
+
/******/ __webpack_require__.d(getter, 'a', getter);
|
60 |
+
/******/ return getter;
|
61 |
+
/******/ };
|
62 |
+
/******/
|
63 |
+
/******/ // Object.prototype.hasOwnProperty.call
|
64 |
+
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
65 |
+
/******/
|
66 |
+
/******/ // __webpack_public_path__
|
67 |
+
/******/ __webpack_require__.p = "";
|
68 |
+
/******/
|
69 |
+
/******/ // Load entry module and return exports
|
70 |
+
/******/ return __webpack_require__(__webpack_require__.s = 5);
|
71 |
+
/******/ })
|
72 |
+
/************************************************************************/
|
73 |
+
/******/ ([
|
74 |
+
/* 0 */,
|
75 |
+
/* 1 */,
|
76 |
+
/* 2 */,
|
77 |
+
/* 3 */,
|
78 |
+
/* 4 */,
|
79 |
+
/* 5 */
|
80 |
+
/***/ (function(module, exports, __webpack_require__) {
|
81 |
+
|
82 |
+
module.exports = __webpack_require__(6);
|
83 |
+
|
84 |
+
|
85 |
+
/***/ }),
|
86 |
+
/* 6 */
|
87 |
+
/***/ (function(module, exports, __webpack_require__) {
|
88 |
+
|
89 |
+
jQuery(function ($) {
|
90 |
+
Promise.resolve().then(function () {
|
91 |
+
return __webpack_require__(7);
|
92 |
+
}).then(function () {
|
93 |
+
// Init on Ajax Popup :)
|
94 |
+
$(document).on('wc_variation_form', '.variations_form', function () {
|
95 |
+
$(this).CustomVariationSelect();
|
96 |
+
});
|
97 |
+
});
|
98 |
+
}); // end of jquery main wrapper
|
99 |
+
|
100 |
+
/***/ }),
|
101 |
+
/* 7 */
|
102 |
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
103 |
+
|
104 |
+
"use strict";
|
105 |
+
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
106 |
+
var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
107 |
+
|
108 |
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
109 |
+
|
110 |
+
// ================================================================
|
111 |
+
// WooCommerce Variation Change
|
112 |
+
// ================================================================
|
113 |
+
|
114 |
+
var CustomVariationSelect = function ($) {
|
115 |
+
|
116 |
+
var Default = {};
|
117 |
+
|
118 |
+
var CustomVariationSelect = function () {
|
119 |
+
function CustomVariationSelect(element, config) {
|
120 |
+
_classCallCheck(this, CustomVariationSelect);
|
121 |
+
|
122 |
+
// Assign
|
123 |
+
this._element = $(element);
|
124 |
+
this._config = $.extend({}, Default, config);
|
125 |
+
|
126 |
+
// Call
|
127 |
+
//this.addInputMarkup();
|
128 |
+
this.wrapperAction();
|
129 |
+
this.resetDataAction();
|
130 |
+
this.updateVariationValueAction();
|
131 |
+
|
132 |
+
$(document).trigger('custom_variation_select');
|
133 |
+
}
|
134 |
+
|
135 |
+
_createClass(CustomVariationSelect, [{
|
136 |
+
key: 'wrapperAction',
|
137 |
+
value: function wrapperAction() {
|
138 |
+
this._element.find('ul.variable-items-wrapper').each(function (i, el) {
|
139 |
+
|
140 |
+
var select = $(this).prev('select'),
|
141 |
+
li = $(this).find('li');
|
142 |
+
|
143 |
+
$(this).on('click', 'li', function (e) {
|
144 |
+
e.preventDefault();
|
145 |
+
e.stopPropagation();
|
146 |
+
var value = $(this).data('value');
|
147 |
+
select.val(value).trigger('change');
|
148 |
+
select.trigger('click');
|
149 |
+
select.trigger('focusin');
|
150 |
+
select.trigger('touchstart');
|
151 |
+
});
|
152 |
+
});
|
153 |
+
}
|
154 |
+
}, {
|
155 |
+
key: 'resetDataAction',
|
156 |
+
value: function resetDataAction() {
|
157 |
+
this._element.on('reset_data', function (event) {
|
158 |
+
$(this).find('ul.variable-items-wrapper').each(function () {
|
159 |
+
|
160 |
+
var li = $(this).find('li');
|
161 |
+
li.each(function () {
|
162 |
+
$(this).removeClass('selected');
|
163 |
+
$(this).removeClass('disabled');
|
164 |
+
});
|
165 |
+
});
|
166 |
+
});
|
167 |
+
}
|
168 |
+
}, {
|
169 |
+
key: 'updateVariationValueAction',
|
170 |
+
value: function updateVariationValueAction() {
|
171 |
+
this._element.on('woocommerce_update_variation_values', function (event) {
|
172 |
+
$(this).find('ul.variable-items-wrapper').each(function () {
|
173 |
+
|
174 |
+
var selected = '',
|
175 |
+
options = $(this).prev('select').find('option'),
|
176 |
+
current = $(this).prev('select').find('option:selected'),
|
177 |
+
eq = $(this).prev('select').find('option').eq(1),
|
178 |
+
li = $(this).find('li'),
|
179 |
+
selects = [];
|
180 |
+
|
181 |
+
options.each(function () {
|
182 |
+
if ($(this).val() !== '') {
|
183 |
+
selects.push($(this).val());
|
184 |
+
selected = current ? current.val() : eq.val();
|
185 |
+
}
|
186 |
+
});
|
187 |
+
|
188 |
+
_.delay(function () {
|
189 |
+
li.each(function () {
|
190 |
+
var value = $(this).data('value');
|
191 |
+
$(this).removeClass('selected disabled');
|
192 |
+
if (_.contains(selects, value)) {
|
193 |
+
$(this).removeClass('disabled');
|
194 |
+
|
195 |
+
if (value === selected) {
|
196 |
+
$(this).addClass('selected');
|
197 |
+
}
|
198 |
+
} else {
|
199 |
+
$(this).addClass('disabled');
|
200 |
+
}
|
201 |
+
});
|
202 |
+
}, 1);
|
203 |
+
});
|
204 |
+
});
|
205 |
+
}
|
206 |
+
}], [{
|
207 |
+
key: '_jQueryInterface',
|
208 |
+
value: function _jQueryInterface(config) {
|
209 |
+
return this.each(function () {
|
210 |
+
new CustomVariationSelect(this, config);
|
211 |
+
});
|
212 |
+
}
|
213 |
+
}]);
|
214 |
+
|
215 |
+
return CustomVariationSelect;
|
216 |
+
}();
|
217 |
+
|
218 |
+
/**
|
219 |
+
* ------------------------------------------------------------------------
|
220 |
+
* Data Api implementation
|
221 |
+
* ------------------------------------------------------------------------
|
222 |
+
*/
|
223 |
+
|
224 |
+
/**
|
225 |
+
* ------------------------------------------------------------------------
|
226 |
+
* jQuery
|
227 |
+
* ------------------------------------------------------------------------
|
228 |
+
*/
|
229 |
+
|
230 |
+
$.fn['CustomVariationSelect'] = CustomVariationSelect._jQueryInterface;
|
231 |
+
$.fn['CustomVariationSelect'].Constructor = CustomVariationSelect;
|
232 |
+
$.fn['CustomVariationSelect'].noConflict = function () {
|
233 |
+
$.fn['CustomVariationSelect'] = $.fn['CustomVariationSelect'];
|
234 |
+
return CustomVariationSelect._jQueryInterface;
|
235 |
+
};
|
236 |
+
|
237 |
+
return CustomVariationSelect;
|
238 |
+
}(jQuery);
|
239 |
+
|
240 |
+
/* harmony default export */ __webpack_exports__["default"] = (CustomVariationSelect);
|
241 |
+
|
242 |
+
/***/ })
|
243 |
+
/******/ ]);
|
244 |
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXNzZXRzL2pzL2Zyb250ZW5kLmpzIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8vL3dlYnBhY2svYm9vdHN0cmFwIDMzMGUxNTQ1Nzg2NGJmZDhlZmM2Iiwid2VicGFjazovLy9zcmMvanMvZnJvbnRlbmQuanMiLCJ3ZWJwYWNrOi8vL3NyYy9qcy9DdXN0b21WYXJpYXRpb25TZWxlY3QuanMiXSwic291cmNlc0NvbnRlbnQiOlsiIFx0Ly8gVGhlIG1vZHVsZSBjYWNoZVxuIFx0dmFyIGluc3RhbGxlZE1vZHVsZXMgPSB7fTtcblxuIFx0Ly8gVGhlIHJlcXVpcmUgZnVuY3Rpb25cbiBcdGZ1bmN0aW9uIF9fd2VicGFja19yZXF1aXJlX18obW9kdWxlSWQpIHtcblxuIFx0XHQvLyBDaGVjayBpZiBtb2R1bGUgaXMgaW4gY2FjaGVcbiBcdFx0aWYoaW5zdGFsbGVkTW9kdWxlc1ttb2R1bGVJZF0pIHtcbiBcdFx0XHRyZXR1cm4gaW5zdGFsbGVkTW9kdWxlc1ttb2R1bGVJZF0uZXhwb3J0cztcbiBcdFx0fVxuIFx0XHQvLyBDcmVhdGUgYSBuZXcgbW9kdWxlIChhbmQgcHV0IGl0IGludG8gdGhlIGNhY2hlKVxuIFx0XHR2YXIgbW9kdWxlID0gaW5zdGFsbGVkTW9kdWxlc1ttb2R1bGVJZF0gPSB7XG4gXHRcdFx0aTogbW9kdWxl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oJCA9PiB7XG4gICAgaW1wb3J0KCcuL0N1c3RvbVZhcmlhdGlvblNlbGVjdCcpLnRoZW4oKCkgPT4ge1xuICAgICAgICAvLyBJbml0IG9uIEFqYXggUG9wdXAgOilcbiAgICAgICAgJChkb2N1bWVudCkub24oJ3djX3ZhcmlhdGlvbl9mb3JtJywgJy52YXJpYXRpb25zX2Zvcm0nLCBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAkKHRoaXMpLkN1c3RvbVZhcmlhdGlvblNlbGVjdCgpO1xuICAgICAgICB9KTtcbiAgICB9KTtcbn0pOyAgLy8gZW5kIG9mIGpxdWVyeSBtYWluIHdyYXBwZXJcblxuXG4vLyBXRUJQQUNLIEZPT1RFUiAvL1xuLy8gc3JjL2pzL2Zyb250ZW5kLmpzIiwiLy8gPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PVxuLy8gV29vQ29tbWVyY2UgVmFyaWF0aW9uIENoYW5nZVxuLy8gPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PVxuXG5jb25zdCBDdXN0b21WYXJpYXRpb25TZWxlY3QgPSAoKCQpID0+IHtcblxuICAgIGNvbnN0IERlZmF1bHQgPSB7fTtcblxuICAgIGNsYXNzIEN1c3RvbVZhcmlhdGlvblNlbGVjdCB7XG5cbiAgICAgICAgY29uc3RydWN0b3IoZWxlbWVudCwgY29uZmlnKSB7XG5cbiAgICAgICAgICAgIC8vIEFzc2lnblxuICAgICAgICAgICAgdGhpcy5fZWxlbWVudCA9ICQoZWxlbWVudCk7XG4gICAgICAgICAgICB0aGlzLl9jb25maWcgID0gJC5leHRlbmQoe30sIERlZmF1bHQsIGNvbmZpZyk7XG5cbiAgICAgICAgICAgIC8vIENhbGxcbiAgICAgICAgICAgIC8vdGhpcy5hZGRJbnB1dE1hcmt1cCgpO1xuICAgICAgICAgICAgdGhpcy53cmFwcGVyQWN0aW9uKCk7XG4gICAgICAgICAgICB0aGlzLnJlc2V0RGF0YUFjdGlvbigpO1xuICAgICAgICAgICAgdGhpcy51cGRhdGVWYXJpYXRpb25WYWx1ZUFjdGlvbigpO1xuXG4gICAgICAgICAgICAkKGRvY3VtZW50KS50cmlnZ2VyKCdjdXN0b21fdmFyaWF0aW9uX3NlbGVjdCcpO1xuICAgICAgICB9XG5cbiAgICAgICAgc3RhdGljIF9qUXVlcnlJbnRlcmZhY2UoY29uZmlnKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5lYWNoKGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICBuZXcgQ3VzdG9tVmFyaWF0aW9uU2VsZWN0KHRoaXMsIGNvbmZpZylcbiAgICAgICAgICAgIH0pXG4gICAgICAgIH1cblxuICAgICAgICB3cmFwcGVyQWN0aW9uKCkge1xuICAgICAgICAgICAgdGhpcy5fZWxlbWVudC5maW5kKCd1bC52YXJpYWJsZS1pdGVtcy13cmFwcGVyJykuZWFjaChmdW5jdGlvbiAoaSwgZWwpIHtcblxuICAgICAgICAgICAgICAgIGxldCBzZWxlY3QgPSAkKHRoaXMpLnByZXYoJ3NlbGVjdCcpLFxuICAgICAgICAgICAgICAgICAgICBsaSAgICAgPSAkKHRoaXMpLmZpbmQoJ2xpJyk7XG5cbiAgICAgICAgICAgICAgICAkKHRoaXMpLm9uKCdjbGljaycsICdsaScsIGZ1bmN0aW9uIChlKSB7XG4gICAgICAgICAgICAgICAgICAgIGUucHJldmVudERlZmF1bHQoKTtcbiAgICAgICAgICAgICAgICAgICAgZS5zdG9wUHJvcGFnYXRpb24oKTtcbiAgICAgICAgICAgICAgICAgICAgbGV0IHZhbHVlID0gJCh0aGlzKS5kYXRhKCd2YWx1ZScpO1xuICAgICAgICAgICAgICAgICAgICBzZWxlY3QudmFsKHZhbHVlKS50cmlnZ2VyKCdjaGFuZ2UnKTtcbiAgICAgICAgICAgICAgICAgICAgc2VsZWN0LnRyaWdnZXIoJ2NsaWNrJyk7XG4gICAgICAgICAgICAgICAgICAgIHNlbGVjdC50cmlnZ2VyKCdmb2N1c2luJyk7XG4gICAgICAgICAgICAgICAgICAgIHNlbGVjdC50cmlnZ2VyKCd0b3VjaHN0YXJ0Jyk7XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJlc2V0RGF0YUFjdGlvbigpIHtcbiAgICAgICAgICAgIHRoaXMuX2VsZW1lbnQub24oJ3Jlc2V0X2RhdGEnLCBmdW5jdGlvbiAoZXZlbnQpIHtcbiAgICAgICAgICAgICAgICAkKHRoaXMpLmZpbmQoJ3VsLnZhcmlhYmxlLWl0ZW1zLXdyYXBwZXInKS5lYWNoKGZ1bmN0aW9uICgpIHtcblxuICAgICAgICAgICAgICAgICAgICBsZXQgbGkgPSAkKHRoaXMpLmZpbmQoJ2xpJyk7XG4gICAgICAgICAgICAgICAgICAgIGxpLmVhY2goZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgJCh0aGlzKS5yZW1vdmVDbGFzcygnc2VsZWN0ZWQnKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICQodGhpcykucmVtb3ZlQ2xhc3MoJ2Rpc2FibGVkJyk7XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cblxuICAgICAgICB1cGRhdGVWYXJpYXRpb25WYWx1ZUFjdGlvbigpIHtcbiAgICAgICAgICAgIHRoaXMuX2VsZW1lbnQub24oJ3dvb2NvbW1lcmNlX3VwZGF0ZV92YXJpYXRpb25fdmFsdWVzJywgZnVuY3Rpb24gKGV2ZW50KSB7XG4gICAgICAgICAgICAgICAgJCh0aGlzKS5maW5kKCd1bC52YXJpYWJsZS1pdGVtcy13cmFwcGVyJykuZWFjaChmdW5jdGlvbiAoKSB7XG5cbiAgICAgICAgICAgICAgICAgICAgbGV0IHNlbGVjdGVkID0gJycsXG4gICAgICAgICAgICAgICAgICAgICAgICBvcHRpb25zICA9ICQodGhpcykucHJldignc2VsZWN0JykuZmluZCgnb3B0aW9uJyksXG4gICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50ICA9ICQodGhpcykucHJldignc2VsZWN0JykuZmluZCgnb3B0aW9uOnNlbGVjdGVkJyksXG4gICAgICAgICAgICAgICAgICAgICAgICBlcSAgICAgICA9ICQodGhpcykucHJldignc2VsZWN0JykuZmluZCgnb3B0aW9uJykuZXEoMSksXG4gICAgICAgICAgICAgICAgICAgICAgICBsaSAgICAgICA9ICQodGhpcykuZmluZCgnbGknKSxcbiAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdHMgID0gW107XG5cbiAgICAgICAgICAgICAgICAgICAgb3B0aW9ucy5lYWNoKGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICgkKHRoaXMpLnZhbCgpICE9PSAnJykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdHMucHVzaCgkKHRoaXMpLnZhbCgpKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RlZCA9IGN1cnJlbnQgPyBjdXJyZW50LnZhbCgpIDogZXEudmFsKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICAgICAgICAgIF8uZGVsYXkoZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgbGkuZWFjaChmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHZhbHVlID0gJCh0aGlzKS5kYXRhKCd2YWx1ZScpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICQodGhpcykucmVtb3ZlQ2xhc3MoJ3NlbGVjdGVkIGRpc2FibGVkJyk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF8uY29udGFpbnMoc2VsZWN0cywgdmFsdWUpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICQodGhpcykucmVtb3ZlQ2xhc3MoJ2Rpc2FibGVkJyk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlID09PSBzZWxlY3RlZCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJCh0aGlzKS5hZGRDbGFzcygnc2VsZWN0ZWQnKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJCh0aGlzKS5hZGRDbGFzcygnZGlzYWJsZWQnKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgfSwgMSk7XG5cbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tXG4gICAgICogRGF0YSBBcGkgaW1wbGVtZW50YXRpb25cbiAgICAgKiAtLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS1cbiAgICAgKi9cblxuICAgIC8qKlxuICAgICAqIC0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLVxuICAgICAqIGpRdWVyeVxuICAgICAqIC0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tBQUNBO0FBREE7QUFBQTtBQUNBO0FBaUdBOzs7Ozs7QUFNQTs7Ozs7O0FBTUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUVBO0FBQ0E7QUFDQTs7O0EiLCJzb3VyY2VSb290IjoiIn0=
|
assets/js/frontend.min.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
!function(e){function t(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,i){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:i})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=5)}([,,,,,function(e,t,n){e.exports=n(6)},function(e,t,n){jQuery(function(e){Promise.resolve().then(function(){return n(7)}).then(function(){e(document).on("wc_variation_form",".variations_form",function(){e(this).CustomVariationSelect()})})})},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),a=function(e){var t={},n=function(){function n(r,a){i(this,n),this._element=e(r),this._config=e.extend({},t,a),this.wrapperAction(),this.resetDataAction(),this.updateVariationValueAction(),e(document).trigger("custom_variation_select")}return r(n,[{key:"wrapperAction",value:function(){this._element.find("ul.variable-items-wrapper").each(function(t,n){var i=e(this).prev("select");e(this).find("li");e(this).on("click","li",function(t){t.preventDefault(),t.stopPropagation();var n=e(this).data("value");i.val(n).trigger("change"),i.trigger("click"),i.trigger("focusin"),i.trigger("touchstart")})})}},{key:"resetDataAction",value:function(){this._element.on("reset_data",function(t){e(this).find("ul.variable-items-wrapper").each(function(){e(this).find("li").each(function(){e(this).removeClass("selected"),e(this).removeClass("disabled")})})})}},{key:"updateVariationValueAction",value:function(){this._element.on("woocommerce_update_variation_values",function(t){e(this).find("ul.variable-items-wrapper").each(function(){var t="",n=e(this).prev("select").find("option"),i=e(this).prev("select").find("option:selected"),r=e(this).prev("select").find("option").eq(1),a=e(this).find("li"),o=[];n.each(function(){""!==e(this).val()&&(o.push(e(this).val()),t=i?i.val():r.val())}),_.delay(function(){a.each(function(){var n=e(this).data("value");e(this).removeClass("selected disabled"),_.contains(o,n)?(e(this).removeClass("disabled"),n===t&&e(this).addClass("selected")):e(this).addClass("disabled")})},1)})})}}],[{key:"_jQueryInterface",value:function(e){return this.each(function(){new n(this,e)})}}]),n}();return e.fn.CustomVariationSelect=n._jQueryInterface,e.fn.CustomVariationSelect.Constructor=n,e.fn.CustomVariationSelect.noConflict=function(){return e.fn.CustomVariationSelect=e.fn.CustomVariationSelect,n._jQueryInterface},n}(jQuery);t.default=a}]);
|
images/placeholder.png
ADDED
Binary file
|
includes/class-wvs-term-meta.php
ADDED
@@ -0,0 +1,265 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
defined( 'ABSPATH' ) or die( 'Keep Silent' );
|
4 |
+
|
5 |
+
if ( ! class_exists( 'WVS_Term_Meta' ) ):
|
6 |
+
class WVS_Term_Meta {
|
7 |
+
|
8 |
+
private $taxonomy;
|
9 |
+
private $post_type;
|
10 |
+
private $fields = array();
|
11 |
+
|
12 |
+
public function __construct( $taxonomy, $post_type, $fields = array() ) {
|
13 |
+
|
14 |
+
$this->taxonomy = $taxonomy;
|
15 |
+
$this->post_type = $post_type;
|
16 |
+
$this->fields = $fields;
|
17 |
+
|
18 |
+
// Category/term ordering
|
19 |
+
//add_action( 'create_term', array( $this, 'create_term' ), 5, 3 );
|
20 |
+
|
21 |
+
add_action( 'delete_term', array( $this, 'delete_term' ), 5, 4 );
|
22 |
+
|
23 |
+
// Add form
|
24 |
+
add_action( "{$this->taxonomy}_add_form_fields", array( $this, 'add' ) );
|
25 |
+
add_action( "{$this->taxonomy}_edit_form_fields", array( $this, 'edit' ), 10 );
|
26 |
+
add_action( "created_term", array( $this, 'save' ), 10, 3 );
|
27 |
+
add_action( "edit_term", array( $this, 'save' ), 10, 3 );
|
28 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
29 |
+
|
30 |
+
// Add columns
|
31 |
+
//add_filter( 'manage_edit-product_cat_columns', array( $this, 'product_cat_columns' ) );
|
32 |
+
//add_filter( 'manage_product_cat_custom_column', array( $this, 'product_cat_column' ), 10, 3 );
|
33 |
+
|
34 |
+
}
|
35 |
+
|
36 |
+
public function delete_term( $term_id, $tt_id, $taxonomy, $deleted_term ) {
|
37 |
+
global $wpdb;
|
38 |
+
|
39 |
+
$term_id = absint( $term_id );
|
40 |
+
if ( $term_id and $taxonomy == $this->taxonomy ) {
|
41 |
+
$wpdb->delete( $wpdb->termmeta, array( 'term_id' => $term_id ), array( '%d' ) );
|
42 |
+
}
|
43 |
+
}
|
44 |
+
|
45 |
+
public function enqueue_scripts() {
|
46 |
+
wp_enqueue_media();
|
47 |
+
wp_enqueue_style( 'wp-color-picker' );
|
48 |
+
wp_enqueue_script( 'wp-color-picker' );
|
49 |
+
}
|
50 |
+
|
51 |
+
public function save( $term_id, $tt_id = '', $taxonomy = '' ) {
|
52 |
+
|
53 |
+
if ( $taxonomy == $this->taxonomy ) {
|
54 |
+
foreach ( $this->fields as $field ) {
|
55 |
+
foreach ( $_POST as $post_key => $post_value ) {
|
56 |
+
if ( $field[ 'id' ] == $post_key ) {
|
57 |
+
switch ( $field[ 'type' ] ) {
|
58 |
+
case 'text':
|
59 |
+
case 'color':
|
60 |
+
$post_value = esc_html( $post_value );
|
61 |
+
break;
|
62 |
+
case 'url':
|
63 |
+
$post_value = esc_url( $post_value );
|
64 |
+
break;
|
65 |
+
case 'image':
|
66 |
+
$post_value = absint( $post_value );
|
67 |
+
break;
|
68 |
+
case 'textarea':
|
69 |
+
$post_value = esc_textarea( $post_value );
|
70 |
+
break;
|
71 |
+
case 'editor':
|
72 |
+
$post_value = wp_kses_post( $post_value );
|
73 |
+
break;
|
74 |
+
case 'select':
|
75 |
+
case 'select2':
|
76 |
+
$post_value = sanitize_key( $post_value );
|
77 |
+
break;
|
78 |
+
default:
|
79 |
+
do_action( 'wvs_save_term_meta', $term_id, $field, $post_value, $taxonomy );
|
80 |
+
break;
|
81 |
+
}
|
82 |
+
update_term_meta( $term_id, $field[ 'id' ], $post_value );
|
83 |
+
}
|
84 |
+
}
|
85 |
+
}
|
86 |
+
do_action( 'wvs_after_term_meta_saved', $term_id, $taxonomy );
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
public function add() {
|
91 |
+
$this->generate_fields();
|
92 |
+
}
|
93 |
+
|
94 |
+
private function generate_fields( $term = FALSE ) {
|
95 |
+
|
96 |
+
$screen = get_current_screen();
|
97 |
+
|
98 |
+
if ( ( $screen->post_type == $this->post_type ) and ( $screen->taxonomy == $this->taxonomy ) ) {
|
99 |
+
$this->generate_form_fields( $term );
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
private function generate_form_fields( $term ) {
|
104 |
+
|
105 |
+
$fields = apply_filters( 'wvs_term_meta_fields', $this->fields, $term );
|
106 |
+
|
107 |
+
foreach ( $fields as $field ) {
|
108 |
+
|
109 |
+
$field = apply_filters( 'wvs_term_meta_field', $field, $term );
|
110 |
+
|
111 |
+
$field[ 'id' ] = esc_html( $field[ 'id' ] );
|
112 |
+
|
113 |
+
if ( ! $term ) {
|
114 |
+
$field[ 'value' ] = isset( $field[ 'default' ] ) ? $field[ 'default' ] : '';
|
115 |
+
} else {
|
116 |
+
$field[ 'value' ] = get_term_meta( $term->term_id, $field[ 'id' ], TRUE );
|
117 |
+
}
|
118 |
+
|
119 |
+
$field[ 'size' ] = isset( $field[ 'size' ] ) ? $field[ 'size' ] : '40';
|
120 |
+
$field[ 'required' ] = ( isset( $field[ 'required' ] ) and $field[ 'required' ] == TRUE ) ? ' aria-required="true"' : '';
|
121 |
+
$field[ 'placeholder' ] = ( isset( $field[ 'placeholder' ] ) ) ? ' placeholder="' . $field[ 'placeholder' ] . '" data-placeholder="' . $field[ 'placeholder' ] . '"' : '';
|
122 |
+
$field[ 'desc' ] = ( isset( $field[ 'desc' ] ) ) ? $field[ 'desc' ] : '';
|
123 |
+
|
124 |
+
$field[ 'dependency' ] = ( isset( $field[ 'dependency' ] ) ) ? $field[ 'dependency' ] : array();
|
125 |
+
|
126 |
+
$this->field_start( $field, $term );
|
127 |
+
switch ( $field[ 'type' ] ) {
|
128 |
+
case 'text':
|
129 |
+
case 'url':
|
130 |
+
ob_start();
|
131 |
+
?>
|
132 |
+
<input name="<?php echo $field[ 'id' ] ?>" id="<?php echo $field[ 'id' ] ?>"
|
133 |
+
type="<?php echo $field[ 'type' ] ?>"
|
134 |
+
value="<?php echo $field[ 'value' ] ?>"
|
135 |
+
size="<?php echo $field[ 'size' ] ?>" <?php echo $field[ 'required' ] . $field[ 'placeholder' ] ?>>
|
136 |
+
<?php
|
137 |
+
echo ob_get_clean();
|
138 |
+
break;
|
139 |
+
case 'color':
|
140 |
+
ob_start();
|
141 |
+
?>
|
142 |
+
<input name="<?php echo $field[ 'id' ] ?>" id="<?php echo $field[ 'id' ] ?>" type="text" class="wvs-color-picker" value="<?php echo $field[ 'value' ] ?>" size="<?php echo $field[ 'size' ] ?>" <?php echo $field[ 'required' ] . $field[ 'placeholder' ] ?>>
|
143 |
+
<?php
|
144 |
+
echo ob_get_clean();
|
145 |
+
break;
|
146 |
+
case 'textarea':
|
147 |
+
ob_start();
|
148 |
+
?>
|
149 |
+
<textarea name="<?php echo $field[ 'id' ] ?>" id="<?php echo $field[ 'id' ] ?>" rows="5" cols="<?php echo $field[ 'size' ] ?>" <?php echo $field[ 'required' ] . $field[ 'placeholder' ] ?>><?php echo $field[ 'value' ] ?></textarea>
|
150 |
+
<?php
|
151 |
+
echo ob_get_clean();
|
152 |
+
break;
|
153 |
+
case 'editor':
|
154 |
+
$field[ 'settings' ] = isset( $field[ 'settings' ] )
|
155 |
+
? $field[ 'settings' ]
|
156 |
+
: array(
|
157 |
+
'textarea_rows' => 8,
|
158 |
+
'quicktags' => FALSE,
|
159 |
+
'media_buttons' => FALSE
|
160 |
+
);
|
161 |
+
ob_start();
|
162 |
+
wp_editor( $field[ 'value' ], $field[ 'id' ], $field[ 'settings' ] );
|
163 |
+
echo ob_get_clean();
|
164 |
+
break;
|
165 |
+
case 'select':
|
166 |
+
case 'select2':
|
167 |
+
|
168 |
+
$field[ 'options' ] = isset( $field[ 'options' ] ) ? $field[ 'options' ] : array();
|
169 |
+
$field[ 'multiple' ] = isset( $field[ 'multiple' ] ) ? ' multiple="multiple"' : '';
|
170 |
+
$css_class = ( $field[ 'type' ] == 'select2' ) ? 'wvs-selectwoo' : '';
|
171 |
+
|
172 |
+
ob_start();
|
173 |
+
?>
|
174 |
+
<select name="<?php echo $field[ 'id' ] ?>" id="<?php echo $field[ 'id' ] ?>" class="<?php echo $css_class ?>" <?php echo $field[ 'multiple' ] ?>>
|
175 |
+
<?php
|
176 |
+
foreach ( $field[ 'options' ] as $key => $option ) {
|
177 |
+
echo '<option' . selected( $field[ 'value' ], $key, FALSE ) . ' value="' . $key . '">' . $option . '</option>';
|
178 |
+
}
|
179 |
+
?>
|
180 |
+
</select>
|
181 |
+
<?php
|
182 |
+
echo ob_get_clean();
|
183 |
+
break;
|
184 |
+
case 'image':
|
185 |
+
ob_start();
|
186 |
+
?>
|
187 |
+
<div class="meta-image-field-wrapper">
|
188 |
+
<div class="image-preview">
|
189 |
+
<img data-placeholder="<?php echo esc_url( $this->placeholder_img_src() ); ?>" src="<?php echo esc_url( $this->get_img_src( $field[ 'value' ] ) ); ?>" width="60px" height="60px"/>
|
190 |
+
</div>
|
191 |
+
<div class="button-wrapper">
|
192 |
+
<input type="hidden" id="<?php echo $field[ 'id' ] ?>" name="<?php echo $field[ 'id' ] ?>" value="<?php echo esc_attr( $field[ 'value' ] ) ?>"/>
|
193 |
+
<button type="button" class="wvs_upload_image_button button button-primary button-small"><?php esc_html_e( 'Upload / Add image', 'hippo-theme-plugin' ); ?></button>
|
194 |
+
<button type="button" style="<?php echo( empty( $field[ 'value' ] ) ? 'display:none' : '' ) ?>" class="wvs_remove_image_button button button-danger button-small"><?php esc_html_e( 'Remove image', 'hippo-theme-plugin' ); ?></button>
|
195 |
+
</div>
|
196 |
+
</div>
|
197 |
+
<?php
|
198 |
+
echo ob_get_clean();
|
199 |
+
break;
|
200 |
+
default:
|
201 |
+
do_action( 'wvs_term_meta_field', $field, $term );
|
202 |
+
break;
|
203 |
+
|
204 |
+
}
|
205 |
+
$this->field_end( $field, $term );
|
206 |
+
|
207 |
+
}
|
208 |
+
}
|
209 |
+
|
210 |
+
private function field_start( $field, $term ) {
|
211 |
+
|
212 |
+
$depends = empty( $field[ 'dependency' ] ) ? '' : "data-depends='" . wp_json_encode( $field[ 'dependency' ] ) . "'";
|
213 |
+
|
214 |
+
ob_start();
|
215 |
+
if ( ! $term ) {
|
216 |
+
?>
|
217 |
+
<div <?php echo $depends ?> class="form-field <?php echo esc_attr( $field[ 'id' ] ) ?> <?php echo empty( $field[ 'required' ] ) ? '' : 'form-required' ?>">
|
218 |
+
<label for="<?php echo esc_attr( $field[ 'id' ] ) ?>"><?php echo $field[ 'label' ] ?></label>
|
219 |
+
<?php
|
220 |
+
} else {
|
221 |
+
?>
|
222 |
+
<tr <?php echo $depends ?> class="form-field <?php echo esc_attr( $field[ 'id' ] ) ?> <?php echo empty( $field[ 'required' ] ) ? '' : 'form-required' ?>"">
|
223 |
+
<th scope="row"><label for="<?php echo esc_attr( $field[ 'id' ] ) ?>"><?php echo $field[ 'label' ] ?></label></th>
|
224 |
+
<td>
|
225 |
+
<?php
|
226 |
+
}
|
227 |
+
echo ob_get_clean();
|
228 |
+
}
|
229 |
+
|
230 |
+
public function get_img_src( $thumbnail_id = FALSE ) {
|
231 |
+
if ( ! empty( $thumbnail_id ) ) {
|
232 |
+
$image = wp_get_attachment_thumb_url( $thumbnail_id );
|
233 |
+
} else {
|
234 |
+
$image = $this->placeholder_img_src();
|
235 |
+
}
|
236 |
+
|
237 |
+
return $image;
|
238 |
+
}
|
239 |
+
|
240 |
+
public function placeholder_img_src() {
|
241 |
+
return woo_variation_swatches()->images_uri( 'placeholder.png' );
|
242 |
+
}
|
243 |
+
|
244 |
+
private function field_end( $field, $term ) {
|
245 |
+
|
246 |
+
ob_start();
|
247 |
+
if ( ! $term ) {
|
248 |
+
?>
|
249 |
+
<p><?php echo $field[ 'desc' ] ?></p>
|
250 |
+
</div>
|
251 |
+
<?php
|
252 |
+
} else {
|
253 |
+
?>
|
254 |
+
<p class="description"><?php echo $field[ 'desc' ] ?></p></td>
|
255 |
+
</tr>
|
256 |
+
<?php
|
257 |
+
}
|
258 |
+
echo ob_get_clean();
|
259 |
+
}
|
260 |
+
|
261 |
+
public function edit( $term ) {
|
262 |
+
$this->generate_fields( $term );
|
263 |
+
}
|
264 |
+
}
|
265 |
+
endif;
|
includes/functions.php
ADDED
@@ -0,0 +1,410 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
defined( 'ABSPATH' ) or die( 'Keep Quit' );
|
4 |
+
|
5 |
+
//-------------------------------------------------------------------------------
|
6 |
+
// Add attribute types on WooCommerce taxonomy
|
7 |
+
//-------------------------------------------------------------------------------
|
8 |
+
|
9 |
+
if ( ! function_exists( 'wvs_product_attributes_types' ) ):
|
10 |
+
function wvs_product_attributes_types( $selector ) {
|
11 |
+
$selector[ 'color' ] = esc_html__( 'Color', 'woo-variation-swatches' );
|
12 |
+
$selector[ 'image' ] = esc_html__( 'Image', 'woo-variation-swatches' );
|
13 |
+
$selector[ 'button' ] = esc_html__( 'Button', 'woo-variation-swatches' );
|
14 |
+
|
15 |
+
return $selector;
|
16 |
+
}
|
17 |
+
|
18 |
+
endif;
|
19 |
+
|
20 |
+
//-------------------------------------------------------------------------------
|
21 |
+
// Add WooCommerce taxonomy Meta
|
22 |
+
//-------------------------------------------------------------------------------
|
23 |
+
|
24 |
+
if ( ! function_exists( 'wvs_add_product_taxonomy_meta' ) ) {
|
25 |
+
|
26 |
+
function wvs_add_product_taxonomy_meta() {
|
27 |
+
$fields = array();
|
28 |
+
|
29 |
+
$fields[ 'color' ] = array(
|
30 |
+
array(
|
31 |
+
'label' => esc_html__( 'Color', 'woo-variation-swatches' ), // <label>
|
32 |
+
'desc' => esc_html__( 'Choose a color', 'woo-variation-swatches' ), // description
|
33 |
+
'id' => 'product_attribute_color', // name of field
|
34 |
+
'type' => 'color'
|
35 |
+
)
|
36 |
+
);
|
37 |
+
|
38 |
+
$fields[ 'image' ] = array(
|
39 |
+
array(
|
40 |
+
'label' => esc_html__( 'Image', 'woo-variation-swatches' ), // <label>
|
41 |
+
'desc' => esc_html__( 'Choose an Image', 'woo-variation-swatches' ), // description
|
42 |
+
'id' => 'product_attribute_image', // name of field
|
43 |
+
'type' => 'image'
|
44 |
+
)
|
45 |
+
);
|
46 |
+
|
47 |
+
if ( function_exists( 'wc_get_attribute_taxonomies' ) ):
|
48 |
+
|
49 |
+
$attribute_taxonomies = wc_get_attribute_taxonomies();
|
50 |
+
if ( $attribute_taxonomies ) :
|
51 |
+
foreach ( $attribute_taxonomies as $tax ) :
|
52 |
+
$product_attr = wc_attribute_taxonomy_name( $tax->attribute_name );
|
53 |
+
$product_attr_type = $tax->attribute_type;
|
54 |
+
if ( in_array( $product_attr_type, array( 'color', 'image' ) ) ) :
|
55 |
+
woo_variation_swatches()->add_term_meta( $product_attr, 'product', $fields[ $product_attr_type ] );
|
56 |
+
|
57 |
+
do_action( 'wvs_wc_attribute_taxonomy_meta_added', $product_attr, $product_attr_type );
|
58 |
+
endif; // in_array( $product_attr_type, array( 'color', 'image' ) )
|
59 |
+
endforeach; // $attribute_taxonomies
|
60 |
+
endif; // $attribute_taxonomies
|
61 |
+
endif; // function_exists( 'wc_get_attribute_taxonomies' )
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
//-------------------------------------------------------------------------------
|
66 |
+
// Extra Product Option Terms
|
67 |
+
//-------------------------------------------------------------------------------
|
68 |
+
|
69 |
+
if ( ! function_exists( 'wvs_product_option_terms' ) ) :
|
70 |
+
function wvs_product_option_terms( $tax, $i ) {
|
71 |
+
global $thepostid;
|
72 |
+
if ( in_array( $tax->attribute_type, array( 'color', 'image', 'button' ) ) ) {
|
73 |
+
|
74 |
+
$taxonomy = wc_attribute_taxonomy_name( $tax->attribute_name );
|
75 |
+
|
76 |
+
$args = array(
|
77 |
+
'orderby' => 'name',
|
78 |
+
'hide_empty' => 0,
|
79 |
+
);
|
80 |
+
?>
|
81 |
+
<select multiple="multiple" data-placeholder="<?php esc_attr_e( 'Select terms', 'woo-variation-swatches' ); ?>" class="multiselect attribute_values wc-enhanced-select" name="attribute_values[<?php echo $i; ?>][]">
|
82 |
+
<?php
|
83 |
+
$all_terms = get_terms( $taxonomy, apply_filters( 'woocommerce_product_attribute_terms', $args ) );
|
84 |
+
if ( $all_terms ) :
|
85 |
+
foreach ( $all_terms as $term ) :
|
86 |
+
echo '<option value="' . esc_attr( $term->term_id ) . '" ' . selected( has_term( absint( $term->term_id ), $taxonomy, $thepostid ), TRUE, FALSE ) . '>' . esc_attr( apply_filters( 'woocommerce_product_attribute_term_name', $term->name, $term ) ) . '</option>';
|
87 |
+
endforeach;
|
88 |
+
endif;
|
89 |
+
?>
|
90 |
+
</select>
|
91 |
+
<button class="button plus select_all_attributes"><?php esc_html_e( 'Select all', 'woo-variation-swatches' ); ?></button>
|
92 |
+
<button class="button minus select_no_attributes"><?php esc_html_e( 'Select none', 'woo-variation-swatches' ); ?></button>
|
93 |
+
<button class="button fr plus add_new_attribute"><?php esc_html_e( 'Add new', 'woo-variation-swatches' ); ?></button>
|
94 |
+
<?php
|
95 |
+
}
|
96 |
+
}
|
97 |
+
endif;
|
98 |
+
|
99 |
+
//-------------------------------------------------------------------------------
|
100 |
+
// Color Variation Attribute Options
|
101 |
+
//-------------------------------------------------------------------------------
|
102 |
+
|
103 |
+
if ( ! function_exists( 'wvs_color_variation_attribute_options' ) ) :
|
104 |
+
|
105 |
+
function wvs_color_variation_attribute_options( $args = array() ) {
|
106 |
+
|
107 |
+
$args = wp_parse_args( $args, array(
|
108 |
+
'options' => FALSE,
|
109 |
+
'attribute' => FALSE,
|
110 |
+
'product' => FALSE,
|
111 |
+
'selected' => FALSE,
|
112 |
+
'name' => '',
|
113 |
+
'id' => '',
|
114 |
+
'class' => '',
|
115 |
+
'show_option_none' => esc_html__( 'Choose an option', 'woo-variation-swatches' )
|
116 |
+
) );
|
117 |
+
|
118 |
+
$options = $args[ 'options' ];
|
119 |
+
$product = $args[ 'product' ];
|
120 |
+
$attribute = $args[ 'attribute' ];
|
121 |
+
$name = $args[ 'name' ] ? $args[ 'name' ] : wc_variation_attribute_name( $attribute );
|
122 |
+
$id = $args[ 'id' ] ? $args[ 'id' ] : sanitize_title( $attribute ) . $product->get_id();
|
123 |
+
$class = $args[ 'class' ];
|
124 |
+
$show_option_none = $args[ 'show_option_none' ] ? TRUE : FALSE;
|
125 |
+
$show_option_none_text = $args[ 'show_option_none' ] ? $args[ 'show_option_none' ] : esc_html__( 'Choose an option', 'woocommerce' ); // We'll do our best to hide the placeholder, but we'll need to show something when resetting options.
|
126 |
+
|
127 |
+
if ( empty( $options ) && ! empty( $product ) && ! empty( $attribute ) ) {
|
128 |
+
$attributes = $product->get_variation_attributes();
|
129 |
+
$options = $attributes[ $attribute ];
|
130 |
+
}
|
131 |
+
|
132 |
+
echo '<select id="' . esc_attr( $id ) . '" class="' . esc_attr( $class ) . ' hide" style="display:none" name="' . esc_attr( $name ) . '" data-attribute_name="' . esc_attr( wc_variation_attribute_name( $attribute ) ) . '" data-show_option_none="' . ( $show_option_none ? 'yes' : 'no' ) . '">';
|
133 |
+
|
134 |
+
if ( $args[ 'show_option_none' ] ) {
|
135 |
+
echo '<option value="">' . esc_html( $show_option_none_text ) . '</option>';
|
136 |
+
}
|
137 |
+
|
138 |
+
if ( ! empty( $options ) ) {
|
139 |
+
if ( $product && taxonomy_exists( $attribute ) ) {
|
140 |
+
// Get terms if this is a taxonomy - ordered. We need the names too.
|
141 |
+
$terms = wc_get_product_terms( $product->get_id(), $attribute, array( 'fields' => 'all' ) );
|
142 |
+
|
143 |
+
foreach ( $terms as $term ) {
|
144 |
+
if ( in_array( $term->slug, $options ) ) {
|
145 |
+
echo '<option value="' . esc_attr( $term->slug ) . '" ' . selected( sanitize_title( $args[ 'selected' ] ), $term->slug, FALSE ) . '>' . apply_filters( 'woocommerce_variation_option_name', $term->name ) . '</option>';
|
146 |
+
}
|
147 |
+
}
|
148 |
+
}
|
149 |
+
}
|
150 |
+
|
151 |
+
echo '</select>';
|
152 |
+
|
153 |
+
echo '<ul class="list-inline variable-items-wrapper color-variable-wrapper">';
|
154 |
+
if ( ! empty( $options ) ) {
|
155 |
+
if ( $product && taxonomy_exists( $attribute ) ) {
|
156 |
+
$terms = wc_get_product_terms( $product->get_id(), $attribute, array( 'fields' => 'all' ) );
|
157 |
+
|
158 |
+
foreach ( $terms as $term ) {
|
159 |
+
if ( in_array( $term->slug, $options ) ) {
|
160 |
+
$get_term_meta = sanitize_hex_color( get_term_meta( $term->term_id, 'product_attribute_color', TRUE ) );
|
161 |
+
$selected_class = ( sanitize_title( $args[ 'selected' ] ) == $term->slug ) ? 'selected' : '';
|
162 |
+
?>
|
163 |
+
<li data-toggle="tooltip" data-placement="top" class="variable-item color-variable-item color-variable-item-<?php echo $term->slug ?> <?php echo $selected_class ?>" title="<?php echo esc_html( $term->name ) ?>" data-value="<?php echo esc_attr( $term->slug ) ?>"><span style="background-color:<?php echo esc_attr( $get_term_meta ) ?>;"></span></li>
|
164 |
+
<?php
|
165 |
+
}
|
166 |
+
}
|
167 |
+
}
|
168 |
+
}
|
169 |
+
echo '</ul>';
|
170 |
+
}
|
171 |
+
|
172 |
+
endif;
|
173 |
+
|
174 |
+
//-------------------------------------------------------------------------------
|
175 |
+
// Image Variation Attribute Options
|
176 |
+
//-------------------------------------------------------------------------------
|
177 |
+
|
178 |
+
if ( ! function_exists( 'wvs_image_variation_attribute_options' ) ) :
|
179 |
+
|
180 |
+
function wvs_image_variation_attribute_options( $args = array() ) {
|
181 |
+
|
182 |
+
$args = wp_parse_args( $args, array(
|
183 |
+
'options' => FALSE,
|
184 |
+
'attribute' => FALSE,
|
185 |
+
'product' => FALSE,
|
186 |
+
'selected' => FALSE,
|
187 |
+
'name' => '',
|
188 |
+
'id' => '',
|
189 |
+
'class' => '',
|
190 |
+
'show_option_none' => esc_html__( 'Choose an option', 'woo-variation-swatches' )
|
191 |
+
) );
|
192 |
+
|
193 |
+
$options = $args[ 'options' ];
|
194 |
+
$product = $args[ 'product' ];
|
195 |
+
$attribute = $args[ 'attribute' ];
|
196 |
+
$name = $args[ 'name' ] ? $args[ 'name' ] : wc_variation_attribute_name( $attribute );
|
197 |
+
$id = $args[ 'id' ] ? $args[ 'id' ] : sanitize_title( $attribute ) . $product->get_id();
|
198 |
+
$class = $args[ 'class' ];
|
199 |
+
$show_option_none = $args[ 'show_option_none' ] ? TRUE : FALSE;
|
200 |
+
$show_option_none_text = $args[ 'show_option_none' ] ? $args[ 'show_option_none' ] : esc_html__( 'Choose an option', 'woocommerce' ); // We'll do our best to hide the placeholder, but we'll need to show something when resetting options.
|
201 |
+
|
202 |
+
if ( empty( $options ) && ! empty( $product ) && ! empty( $attribute ) ) {
|
203 |
+
$attributes = $product->get_variation_attributes();
|
204 |
+
$options = $attributes[ $attribute ];
|
205 |
+
}
|
206 |
+
|
207 |
+
echo '<select id="' . esc_attr( $id ) . '" class="' . esc_attr( $class ) . ' hide" style="display:none" name="' . esc_attr( $name ) . '" data-attribute_name="' . esc_attr( wc_variation_attribute_name( $attribute ) ) . '" data-show_option_none="' . ( $show_option_none ? 'yes' : 'no' ) . '">';
|
208 |
+
|
209 |
+
if ( $args[ 'show_option_none' ] ) {
|
210 |
+
echo '<option value="">' . esc_html( $show_option_none_text ) . '</option>';
|
211 |
+
}
|
212 |
+
|
213 |
+
if ( ! empty( $options ) ) {
|
214 |
+
if ( $product && taxonomy_exists( $attribute ) ) {
|
215 |
+
// Get terms if this is a taxonomy - ordered. We need the names too.
|
216 |
+
$terms = wc_get_product_terms( $product->get_id(), $attribute, array( 'fields' => 'all' ) );
|
217 |
+
|
218 |
+
foreach ( $terms as $term ) {
|
219 |
+
if ( in_array( $term->slug, $options ) ) {
|
220 |
+
echo '<option value="' . esc_attr( $term->slug ) . '" ' . selected( sanitize_title( $args[ 'selected' ] ), $term->slug, FALSE ) . '>' . apply_filters( 'woocommerce_variation_option_name', $term->name ) . '</option>';
|
221 |
+
}
|
222 |
+
}
|
223 |
+
}
|
224 |
+
}
|
225 |
+
|
226 |
+
echo '</select>';
|
227 |
+
|
228 |
+
echo '<ul class="list-inline variable-items-wrapper image-variable-wrapper">';
|
229 |
+
if ( ! empty( $options ) ) {
|
230 |
+
if ( $product && taxonomy_exists( $attribute ) ) {
|
231 |
+
$terms = wc_get_product_terms( $product->get_id(), $attribute, array( 'fields' => 'all' ) );
|
232 |
+
|
233 |
+
foreach ( $terms as $term ) {
|
234 |
+
if ( in_array( $term->slug, $options ) ) {
|
235 |
+
$attachment_id = absint( get_term_meta( $term->term_id, 'product_attribute_image', TRUE ) );
|
236 |
+
$image = wp_get_attachment_image_url( $attachment_id );
|
237 |
+
$selected_class = ( sanitize_title( $args[ 'selected' ] ) == $term->slug ) ? 'selected' : '';
|
238 |
+
?>
|
239 |
+
<li data-toggle="tooltip" data-placement="top" class="variable-item image-variable-item image-variable-item-<?php echo $term->slug ?> <?php echo $selected_class ?>" title="<?php echo esc_html( $term->name ) ?>" data-value="<?php echo esc_attr( $term->slug ) ?>"><img alt="<?php echo esc_html( $term->name ) ?>" src="<?php echo esc_url( $image ) ?>"></li>
|
240 |
+
<?php
|
241 |
+
}
|
242 |
+
}
|
243 |
+
}
|
244 |
+
}
|
245 |
+
echo '</ul>';
|
246 |
+
}
|
247 |
+
endif;
|
248 |
+
|
249 |
+
//-------------------------------------------------------------------------------
|
250 |
+
// Button Variation Attribute Options
|
251 |
+
//-------------------------------------------------------------------------------
|
252 |
+
|
253 |
+
if ( ! function_exists( 'wvs_button_variation_attribute_options' ) ) :
|
254 |
+
|
255 |
+
function wvs_button_variation_attribute_options( $args = array() ) {
|
256 |
+
|
257 |
+
$args = wp_parse_args( $args, array(
|
258 |
+
'options' => FALSE,
|
259 |
+
'attribute' => FALSE,
|
260 |
+
'product' => FALSE,
|
261 |
+
'selected' => FALSE,
|
262 |
+
'name' => '',
|
263 |
+
'id' => '',
|
264 |
+
'class' => '',
|
265 |
+
'show_option_none' => esc_html__( 'Choose an option', 'woo-variation-swatches' )
|
266 |
+
) );
|
267 |
+
|
268 |
+
$options = $args[ 'options' ];
|
269 |
+
$product = $args[ 'product' ];
|
270 |
+
$attribute = $args[ 'attribute' ];
|
271 |
+
$name = $args[ 'name' ] ? $args[ 'name' ] : wc_variation_attribute_name( $attribute );
|
272 |
+
$id = $args[ 'id' ] ? $args[ 'id' ] : sanitize_title( $attribute ) . $product->get_id();
|
273 |
+
$class = $args[ 'class' ];
|
274 |
+
$show_option_none = $args[ 'show_option_none' ] ? TRUE : FALSE;
|
275 |
+
$show_option_none_text = $args[ 'show_option_none' ] ? $args[ 'show_option_none' ] : esc_html__( 'Choose an option', 'woocommerce' ); // We'll do our best to hide the placeholder, but we'll need to show something when resetting options.
|
276 |
+
|
277 |
+
if ( empty( $options ) && ! empty( $product ) && ! empty( $attribute ) ) {
|
278 |
+
$attributes = $product->get_variation_attributes();
|
279 |
+
$options = $attributes[ $attribute ];
|
280 |
+
}
|
281 |
+
|
282 |
+
echo '<select id="' . esc_attr( $id ) . '" class="' . esc_attr( $class ) . ' hide" style="display:none" name="' . esc_attr( $name ) . '" data-attribute_name="' . esc_attr( wc_variation_attribute_name( $attribute ) ) . '" data-show_option_none="' . ( $show_option_none ? 'yes' : 'no' ) . '">';
|
283 |
+
|
284 |
+
if ( $args[ 'show_option_none' ] ) {
|
285 |
+
echo '<option value="">' . esc_html( $show_option_none_text ) . '</option>';
|
286 |
+
}
|
287 |
+
|
288 |
+
if ( ! empty( $options ) ) {
|
289 |
+
if ( $product && taxonomy_exists( $attribute ) ) {
|
290 |
+
// Get terms if this is a taxonomy - ordered. We need the names too.
|
291 |
+
$terms = wc_get_product_terms( $product->get_id(), $attribute, array( 'fields' => 'all' ) );
|
292 |
+
|
293 |
+
foreach ( $terms as $term ) {
|
294 |
+
if ( in_array( $term->slug, $options ) ) {
|
295 |
+
echo '<option value="' . esc_attr( $term->slug ) . '" ' . selected( sanitize_title( $args[ 'selected' ] ), $term->slug, FALSE ) . '>' . apply_filters( 'woocommerce_variation_option_name', $term->name ) . '</option>';
|
296 |
+
}
|
297 |
+
}
|
298 |
+
}
|
299 |
+
}
|
300 |
+
|
301 |
+
echo '</select>';
|
302 |
+
|
303 |
+
echo '<ul class="list-inline variable-items-wrapper button-variable-wrapper">';
|
304 |
+
if ( ! empty( $options ) ) {
|
305 |
+
if ( $product && taxonomy_exists( $attribute ) ) {
|
306 |
+
$terms = wc_get_product_terms( $product->get_id(), $attribute, array( 'fields' => 'all' ) );
|
307 |
+
|
308 |
+
foreach ( $terms as $term ) {
|
309 |
+
if ( in_array( $term->slug, $options ) ) {
|
310 |
+
$selected_class = ( sanitize_title( $args[ 'selected' ] ) == $term->slug ) ? 'selected' : '';
|
311 |
+
?>
|
312 |
+
<li data-toggle="tooltip" data-placement="top" class="variable-item button-variable-item image-variable-item-<?php echo $term->slug ?> <?php echo $selected_class ?>" title="<?php echo esc_html( $term->name ) ?>" data-value="<?php echo esc_attr( $term->slug ) ?>"><span><?php echo esc_html( $term->name ) ?></span></li>
|
313 |
+
<?php
|
314 |
+
}
|
315 |
+
}
|
316 |
+
}
|
317 |
+
}
|
318 |
+
echo '</ul>';
|
319 |
+
}
|
320 |
+
endif;
|
321 |
+
|
322 |
+
//-------------------------------------------------------------------------------
|
323 |
+
// Get a Attribute taxonomy values
|
324 |
+
//-------------------------------------------------------------------------------
|
325 |
+
|
326 |
+
if ( ! function_exists( 'wvs_get_wc_attribute_taxonomy' ) ):
|
327 |
+
function wvs_get_wc_attribute_taxonomy( $attribute_name ) {
|
328 |
+
|
329 |
+
$transient = sprintf( 'wvs_get_wc_attribute_taxonomy_%s', $attribute_name );
|
330 |
+
|
331 |
+
if ( ( defined( 'WP_DEBUG' ) && WP_DEBUG ) || isset( $_GET[ 'wvs_clear' ] ) ) {
|
332 |
+
delete_transient( $transient );
|
333 |
+
}
|
334 |
+
|
335 |
+
if ( FALSE === ( $attribute_taxonomy = get_transient( $transient ) ) ) {
|
336 |
+
global $wpdb;
|
337 |
+
|
338 |
+
$attribute_name = str_replace( 'pa_', '', wc_sanitize_taxonomy_name( $attribute_name ) );
|
339 |
+
$attribute_taxonomy = $wpdb->get_row( "SELECT * FROM " . $wpdb->prefix . "woocommerce_attribute_taxonomies WHERE attribute_name='{$attribute_name}'" );
|
340 |
+
set_transient( $transient, $attribute_taxonomy );
|
341 |
+
}
|
342 |
+
|
343 |
+
return apply_filters( 'wvs_get_wc_attribute_taxonomy', $attribute_taxonomy, $attribute_name );
|
344 |
+
}
|
345 |
+
endif;
|
346 |
+
|
347 |
+
// Clean transient
|
348 |
+
add_action( 'woocommerce_attribute_updated', function ( $attribute_id, $attribute, $old_attribute_name ) {
|
349 |
+
|
350 |
+
$transient = sprintf( 'wvs_get_wc_attribute_taxonomy_%s', wc_attribute_taxonomy_name( $attribute[ 'attribute_name' ] ) );
|
351 |
+
$old_transient = sprintf( 'wvs_get_wc_attribute_taxonomy_%s', wc_attribute_taxonomy_name( $old_attribute_name ) );
|
352 |
+
delete_transient( $transient );
|
353 |
+
delete_transient( $old_transient );
|
354 |
+
}, 20, 3 );
|
355 |
+
|
356 |
+
// Clean transient
|
357 |
+
add_action( 'woocommerce_attribute_deleted', function ( $attribute_id, $attribute_name, $taxonomy ) {
|
358 |
+
$transient = sprintf( 'wvs_get_wc_attribute_taxonomy_%s', $taxonomy );
|
359 |
+
delete_transient( $transient );
|
360 |
+
}, 20, 3 );
|
361 |
+
|
362 |
+
//-------------------------------------------------------------------------------
|
363 |
+
// Check has attribute type like color or image etc.
|
364 |
+
//-------------------------------------------------------------------------------
|
365 |
+
if ( ! function_exists( 'wvs_wc_product_has_attribute_type' ) ):
|
366 |
+
function wvs_wc_product_has_attribute_type( $type, $attribute_name ) {
|
367 |
+
$attribute = wvs_get_wc_attribute_taxonomy( $attribute_name );
|
368 |
+
|
369 |
+
return isset( $attribute->attribute_type ) && ( $attribute->attribute_type == $type );
|
370 |
+
}
|
371 |
+
endif;
|
372 |
+
|
373 |
+
//-------------------------------------------------------------------------------
|
374 |
+
// Generate Option HTML
|
375 |
+
//-------------------------------------------------------------------------------
|
376 |
+
|
377 |
+
if ( ! function_exists( 'wvs_variation_attribute_options_html' ) ):
|
378 |
+
function wvs_variation_attribute_options_html( $html, $args ) {
|
379 |
+
ob_start();
|
380 |
+
if ( wvs_wc_product_has_attribute_type( 'color', $args[ 'attribute' ] ) ):
|
381 |
+
|
382 |
+
wvs_color_variation_attribute_options( array(
|
383 |
+
'options' => $args[ 'options' ],
|
384 |
+
'attribute' => $args[ 'attribute' ],
|
385 |
+
'product' => $args[ 'product' ],
|
386 |
+
'selected' => $args[ 'selected' ]
|
387 |
+
) );
|
388 |
+
|
389 |
+
elseif ( wvs_wc_product_has_attribute_type( 'image', $args[ 'attribute' ] ) ):
|
390 |
+
|
391 |
+
wvs_image_variation_attribute_options( array(
|
392 |
+
'options' => $args[ 'options' ],
|
393 |
+
'attribute' => $args[ 'attribute' ],
|
394 |
+
'product' => $args[ 'product' ],
|
395 |
+
'selected' => $args[ 'selected' ]
|
396 |
+
) );
|
397 |
+
|
398 |
+
elseif ( wvs_wc_product_has_attribute_type( 'button', $args[ 'attribute' ] ) ):
|
399 |
+
|
400 |
+
wvs_button_variation_attribute_options( array(
|
401 |
+
'options' => $args[ 'options' ],
|
402 |
+
'attribute' => $args[ 'attribute' ],
|
403 |
+
'product' => $args[ 'product' ],
|
404 |
+
'selected' => $args[ 'selected' ]
|
405 |
+
) );
|
406 |
+
endif;
|
407 |
+
|
408 |
+
return ob_get_clean();
|
409 |
+
}
|
410 |
+
endif;
|
includes/hooks.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) or die( 'Keep Quit' );
|
3 |
+
|
4 |
+
add_filter( 'product_attributes_type_selector', 'wvs_product_attributes_types' );
|
5 |
+
|
6 |
+
add_action( 'admin_init', 'wvs_add_product_taxonomy_meta' );
|
7 |
+
|
8 |
+
add_action( 'woocommerce_product_option_terms', 'wvs_product_option_terms', 10, 2 );
|
9 |
+
|
10 |
+
add_filter( 'woocommerce_dropdown_variation_attribute_options_html', 'wvs_variation_attribute_options_html', 200, 2 );
|
11 |
+
|
languages/woo-variation-swatches.pot
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright (C) 2017 Woo Variation Swatches
|
2 |
+
# This file is distributed under the same license as the Woo Variation Swatches package.
|
3 |
+
msgid ""
|
4 |
+
msgstr ""
|
5 |
+
"Project-Id-Version: Woo Variation Swatches\n"
|
6 |
+
"MIME-Version: 1.0\n"
|
7 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
8 |
+
"Content-Transfer-Encoding: 8bit\n"
|
9 |
+
"Language-Team: ThemeHippo <themehippo@gmail.com>\n"
|
10 |
+
"Last-Translator: Emran Ahmed <emran.bd.08@gmail.com>\n"
|
11 |
+
"Report-Msgid-Bugs-To: https://github.com/EmranAhmed/woo-variation-swatches/issues\n"
|
12 |
+
"X-Poedit-Basepath: ..\n"
|
13 |
+
"X-Poedit-KeywordsList: __;_e;_ex:1,2c;_n:1,2;_n_noop:1,2;_nx:1,2,4c;_nx_noop:1,2,3c;_x:1,2c;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c\n"
|
14 |
+
"X-Poedit-SearchPath-0: .\n"
|
15 |
+
"X-Poedit-SearchPathExcluded-0: *.js\n"
|
16 |
+
"X-Poedit-SourceCharset: UTF-8\n"
|
17 |
+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
18 |
+
|
19 |
+
#: ../woo-variation-swatches.php:105
|
20 |
+
msgid "Choose an Image"
|
21 |
+
msgstr ""
|
22 |
+
|
23 |
+
#: ../woo-variation-swatches.php:106
|
24 |
+
msgid "Use Image"
|
25 |
+
msgstr ""
|
26 |
+
|
27 |
+
#: ../woo-variation-swatches.php:107
|
28 |
+
msgid "Add Media"
|
29 |
+
msgstr ""
|
30 |
+
|
31 |
+
#: ../woo-variation-swatches.php:152
|
32 |
+
msgid "View Documentation"
|
33 |
+
msgstr ""
|
34 |
+
|
35 |
+
#: ../woo-variation-swatches.php:152
|
36 |
+
msgid "Documentation"
|
37 |
+
msgstr ""
|
38 |
+
|
39 |
+
#: ../woo-variation-swatches.php:153, ../woo-variation-swatches.php:153
|
40 |
+
msgid "Support"
|
41 |
+
msgstr ""
|
42 |
+
|
43 |
+
#: ../woo-variation-swatches.php:184
|
44 |
+
msgid "Please check PHP version requirement."
|
45 |
+
msgstr ""
|
46 |
+
|
47 |
+
#: ../woo-variation-swatches.php:186
|
48 |
+
msgid "It's required to use latest version of PHP to use <strong>Woo Variation Swatches</strong>."
|
49 |
+
msgstr ""
|
50 |
+
|
51 |
+
#: ../woo-variation-swatches.php:196
|
52 |
+
msgid "WooCommerce"
|
53 |
+
msgstr ""
|
54 |
+
|
55 |
+
#: ../woo-variation-swatches.php:198
|
56 |
+
msgid "<strong>Woo Variation Switcher</strong> is an add-on of "
|
57 |
+
msgstr ""
|
package.json
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"package": "Woo Variation Swatches",
|
3 |
+
"name": "woo-variation-swatches",
|
4 |
+
"version": "1.0.0",
|
5 |
+
"author": "Emran Ahmed <emran.bd.08@gmail.com>",
|
6 |
+
"contact": "emran.bd.08@gmail.com",
|
7 |
+
"license": "GNU General Public License v3",
|
8 |
+
"private": true,
|
9 |
+
"scripts": {
|
10 |
+
"webpack": "cross-env NODE_ENV=development node_modules/.bin/webpack --progress --hide-modules --config=node_modules/wp-mix/setup/webpack.config.js",
|
11 |
+
"dev": "npm run webpack -- --watch",
|
12 |
+
"build": "cross-env NODE_ENV=production node_modules/.bin/webpack --progress --hide-modules --config=node_modules/wp-mix/setup/webpack.config.js",
|
13 |
+
"bundle": "npm run webpack && npm run build",
|
14 |
+
"package:bundle": "cross-env NODE_ENV=package node_modules/.bin/webpack --progress --hide-modules --config=node_modules/wp-mix/setup/webpack.config.js",
|
15 |
+
"package": "npm run bundle && npm run package:bundle"
|
16 |
+
},
|
17 |
+
"devDependencies": {
|
18 |
+
"cli-color": "^1.2.0",
|
19 |
+
"emojic": "^1.1.12",
|
20 |
+
"extend": "^3.0.1",
|
21 |
+
"fs-extra": "^5.0.0",
|
22 |
+
"sanitize-html": "^1.16.3",
|
23 |
+
"sprintf-js": "^1.1.1"
|
24 |
+
},
|
25 |
+
"dependencies": {
|
26 |
+
"wp-mix": "^1.0.5"
|
27 |
+
}
|
28 |
+
}
|
webpack.mix.js
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const mix = require('wp-mix');
|
2 |
+
const fsExtra = require("fs-extra");
|
3 |
+
const path = require("path");
|
4 |
+
const cliColor = require("cli-color");
|
5 |
+
const emojic = require("emojic");
|
6 |
+
const min = Mix.inProduction() ? '.min' : '';
|
7 |
+
|
8 |
+
const PackageFile = JSON.parse(File.find(Mix.paths.root('package.json')).read());
|
9 |
+
|
10 |
+
if (process.env.NODE_ENV === 'package') {
|
11 |
+
|
12 |
+
mix.then(function () {
|
13 |
+
|
14 |
+
let bundledir = path.basename(path.resolve(__dirname));
|
15 |
+
let copyfrom = path.resolve(__dirname);
|
16 |
+
let copyto = path.resolve(`${bundledir}`);
|
17 |
+
// Select All file then paste on list
|
18 |
+
let list = `assets
|
19 |
+
woo-variation-swatches.php
|
20 |
+
images
|
21 |
+
includes
|
22 |
+
languages
|
23 |
+
package.json
|
24 |
+
README.txt
|
25 |
+
webpack.mix.js`;
|
26 |
+
|
27 |
+
let includes = list.split("\n");
|
28 |
+
fsExtra.ensureDir(copyto, function (err) {
|
29 |
+
if (err) return console.error(err)
|
30 |
+
|
31 |
+
includes.map(include => {
|
32 |
+
|
33 |
+
fsExtra.copy(`${copyfrom}/${include}`, `${copyto}/${include}`, function (err) {
|
34 |
+
if (err) return console.error(err)
|
35 |
+
|
36 |
+
console.log(cliColor.white(`=> ${emojic.smiley} ${include} copied...`));
|
37 |
+
|
38 |
+
/*if (include == 'assets') {
|
39 |
+
// Just Removed SCSS Dir
|
40 |
+
fsExtra.removeSync(`${copyto}/${include}/scss`);
|
41 |
+
}*/
|
42 |
+
})
|
43 |
+
});
|
44 |
+
|
45 |
+
console.log(cliColor.white(`=> ${emojic.whiteCheckMark} Build directory created`));
|
46 |
+
})
|
47 |
+
});
|
48 |
+
|
49 |
+
return;
|
50 |
+
}
|
51 |
+
|
52 |
+
if (Mix.inProduction()) {
|
53 |
+
mix.generatePot({
|
54 |
+
package : 'Woo Variation Swatches',
|
55 |
+
bugReport : 'https://github.com/EmranAhmed/woo-variation-swatches/issues',
|
56 |
+
src : '*.php',
|
57 |
+
domain : 'woo-variation-swatches',
|
58 |
+
destFile : `languages/woo-variation-swatches.pot`
|
59 |
+
});
|
60 |
+
}
|
61 |
+
|
62 |
+
mix.banner({
|
63 |
+
banner : "Woo Variation Swatches v1.0.0 \n\nAuthor: Emran Ahmed ( emran.bd.08@gmail.com ) \nDate: " + new Date().toLocaleString() + "\nReleased under the GPLv3 license."
|
64 |
+
});
|
65 |
+
|
66 |
+
mix.notification({
|
67 |
+
title : 'Woo Variation Swatches',
|
68 |
+
// contentImage : Mix.paths.root('images/logo.png')
|
69 |
+
});
|
70 |
+
|
71 |
+
if (!Mix.inProduction()) {
|
72 |
+
mix.sourceMaps();
|
73 |
+
}
|
74 |
+
|
75 |
+
mix.js(`src/js/backend.js`, `assets/js/admin${min}.js`);
|
76 |
+
mix.js(`src/js/frontend.js`, `assets/js/frontend${min}.js`);
|
77 |
+
mix.babel(`src/js/FormFieldDependency.js`, `assets/js/form-field-dependency${min}.js`);
|
78 |
+
mix.sass(`src/scss/backend.scss`, `assets/css/admin${min}.css`);
|
79 |
+
mix.sass(`src/scss/frontend.scss`, `assets/css/frontend${min}.css`);
|
woo-variation-swatches.php
ADDED
@@ -0,0 +1,262 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Plugin Name: Woo Variation Swatches
|
4 |
+
* Plugin URI: https://wordpress.org/plugins/woo-variation-swatches/
|
5 |
+
* Description: WooCommerce Product Variation Swatches
|
6 |
+
* Author: Emran Ahmed
|
7 |
+
* Version: 1.0.0
|
8 |
+
* Domain Path: /languages
|
9 |
+
* Requires at least: 4.8
|
10 |
+
* Tested up to: 4.9
|
11 |
+
* WC requires at least: 3.2.0
|
12 |
+
* WC tested up to: 3.2.6
|
13 |
+
* Text Domain: woo-variation-swatches
|
14 |
+
* Author URI: https://getwooplugins.com/
|
15 |
+
*/
|
16 |
+
|
17 |
+
defined( 'ABSPATH' ) or die( 'Keep Silent' );
|
18 |
+
|
19 |
+
if ( ! class_exists( 'Woo_Variation_Swatches' ) ):
|
20 |
+
|
21 |
+
class Woo_Variation_Swatches {
|
22 |
+
|
23 |
+
protected $_version = '1.0.0';
|
24 |
+
|
25 |
+
protected static $_instance = NULL;
|
26 |
+
|
27 |
+
public static function init() {
|
28 |
+
if ( is_null( self::$_instance ) ) {
|
29 |
+
self::$_instance = new self();
|
30 |
+
}
|
31 |
+
|
32 |
+
return self::$_instance;
|
33 |
+
}
|
34 |
+
|
35 |
+
public function __construct() {
|
36 |
+
|
37 |
+
$this->constants();
|
38 |
+
$this->includes();
|
39 |
+
$this->hooks();
|
40 |
+
do_action( 'woo_variation_swatches_loaded', $this );
|
41 |
+
}
|
42 |
+
|
43 |
+
public function constants() {
|
44 |
+
|
45 |
+
$this->define( 'WVS_PLUGIN_VERSION', esc_attr( $this->_version ) );
|
46 |
+
$this->define( 'WVS_PLUGIN_URI', plugin_dir_url( __FILE__ ) );
|
47 |
+
$this->define( 'WVS_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
|
48 |
+
|
49 |
+
$this->define( 'WVS_PLUGIN_INCLUDE_PATH', trailingslashit( plugin_dir_path( __FILE__ ) . 'includes' ) );
|
50 |
+
$this->define( 'WVS_PLUGIN_TEMPLATES_PATH', trailingslashit( plugin_dir_path( __FILE__ ) . 'templates' ) );
|
51 |
+
$this->define( 'WVS_PLUGIN_TEMPLATES_URI', trailingslashit( plugin_dir_url( __FILE__ ) . 'templates' ) );
|
52 |
+
|
53 |
+
$this->define( 'WVS_PLUGIN_DIRNAME', dirname( plugin_basename( __FILE__ ) ) );
|
54 |
+
$this->define( 'WVS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
|
55 |
+
$this->define( 'WVS_PLUGIN_FILE', __FILE__ );
|
56 |
+
$this->define( 'WVS_IMAGES_URI', trailingslashit( plugin_dir_url( __FILE__ ) . 'images' ) );
|
57 |
+
$this->define( 'WVS_ASSETS_URI', trailingslashit( plugin_dir_url( __FILE__ ) . 'assets' ) );
|
58 |
+
}
|
59 |
+
|
60 |
+
public function includes() {
|
61 |
+
if ( $this->is_required_php_version() ) {
|
62 |
+
require_once $this->include_path( 'class-wvs-term-meta.php' );
|
63 |
+
require_once $this->include_path( 'functions.php' );
|
64 |
+
require_once $this->include_path( 'hooks.php' );
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
public function define( $name, $value, $case_insensitive = FALSE ) {
|
69 |
+
if ( ! defined( $name ) ) {
|
70 |
+
define( $name, $value, $case_insensitive );
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
+
public function include_path( $file ) {
|
75 |
+
$file = ltrim( $file, '/' );
|
76 |
+
|
77 |
+
return WVS_PLUGIN_INCLUDE_PATH . $file;
|
78 |
+
}
|
79 |
+
|
80 |
+
public function hooks() {
|
81 |
+
add_action( 'admin_notices', array( $this, 'php_requirement_notice' ) );
|
82 |
+
add_action( 'admin_notices', array( $this, 'wc_requirement_notice' ) );
|
83 |
+
add_action( 'init', array( $this, 'language' ) );
|
84 |
+
add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
|
85 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
|
86 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
87 |
+
}
|
88 |
+
|
89 |
+
public function enqueue_scripts() {
|
90 |
+
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
91 |
+
wp_enqueue_script( 'woo-variation-swatches', $this->assets_uri( "/js/frontend{$suffix}.js" ), array( 'jquery' ), $this->version(), TRUE );
|
92 |
+
wp_enqueue_style( 'woo-variation-swatches', $this->assets_uri( "/css/frontend{$suffix}.css" ), array(), $this->version() );
|
93 |
+
}
|
94 |
+
|
95 |
+
public function admin_enqueue_scripts() {
|
96 |
+
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
97 |
+
wp_enqueue_script( 'form-field-dependency', $this->assets_uri( "/js/form-field-dependency{$suffix}.js" ), array( 'jquery' ), $this->version(), TRUE );
|
98 |
+
wp_enqueue_script( 'woo-variation-swatches-admin', $this->assets_uri( "/js/admin{$suffix}.js" ), array( 'jquery' ), $this->version(), TRUE );
|
99 |
+
wp_enqueue_style( 'woo-variation-swatches-admin', $this->assets_uri( "/css/admin{$suffix}.css" ), array(), $this->version() );
|
100 |
+
|
101 |
+
// wp_enqueue_script( 'selectWoo' );
|
102 |
+
// wp_enqueue_style( 'select2' );
|
103 |
+
|
104 |
+
wp_localize_script( 'woo-variation-swatches-admin', 'WVSPluginObject', array(
|
105 |
+
'media_title' => esc_html__( 'Choose an Image', 'woo-variation-swatches' ),
|
106 |
+
'button_title' => esc_html__( 'Use Image', 'woo-variation-swatches' ),
|
107 |
+
'add_media' => esc_html__( 'Add Media', 'woo-variation-swatches' ),
|
108 |
+
'ajaxurl' => esc_url( admin_url( 'admin-ajax.php', 'relative' ) ),
|
109 |
+
'nonce' => wp_create_nonce( 'wvs_plugin_nonce' ),
|
110 |
+
) );
|
111 |
+
}
|
112 |
+
|
113 |
+
public function add_setting( $tab_id, $tab_title, $tab_sections, $active = FALSE ) {
|
114 |
+
// Example:
|
115 |
+
|
116 |
+
// fn(tab_id, tab_title, [
|
117 |
+
// [
|
118 |
+
// 'id'=>'',
|
119 |
+
// 'title'=>'',
|
120 |
+
// 'desc'=>'',
|
121 |
+
// 'fields'=>[
|
122 |
+
// [
|
123 |
+
// 'id'=>'',
|
124 |
+
// 'type'=>'',
|
125 |
+
// 'title'=>'',
|
126 |
+
// 'desc'=>'',
|
127 |
+
// 'value'=>''
|
128 |
+
// ]
|
129 |
+
// ] // fields end
|
130 |
+
// ]
|
131 |
+
//])
|
132 |
+
|
133 |
+
add_filter( 'wvs_settings', function ( $fields ) use ( $tab_id, $tab_title, $tab_sections, $active ) {
|
134 |
+
array_push( $fields, array(
|
135 |
+
'id' => $tab_id,
|
136 |
+
'title' => esc_html( $tab_title ),
|
137 |
+
'active' => $active,
|
138 |
+
'sections' => $tab_sections
|
139 |
+
) );
|
140 |
+
|
141 |
+
return $fields;
|
142 |
+
} );
|
143 |
+
}
|
144 |
+
|
145 |
+
public function add_term_meta( $taxonomy, $post_type, $fields ) {
|
146 |
+
return new WVS_Term_Meta( $taxonomy, $post_type, $fields );
|
147 |
+
}
|
148 |
+
|
149 |
+
public function plugin_row_meta( $links, $file ) {
|
150 |
+
if ( $file == $this->basename() ) {
|
151 |
+
$row_meta = array(
|
152 |
+
'documentation' => '<a href="' . esc_url( apply_filters( 'wvs_documentation_url', '#' ) ) . '" title="' . esc_attr( esc_html__( 'View Documentation', 'woo-variation-swatches' ) ) . '">' . esc_html__( 'Documentation', 'woo-variation-swatches' ) . '</a>',
|
153 |
+
'support' => '<a href="' . esc_url( apply_filters( 'wvs_support_url', 'https://wordpress.org/support/plugin/woo-variation-swatches/' ) ) . '" title="' . esc_attr( esc_html__( 'Support', 'woo-variation-swatches' ) ) . '">' . esc_html__( 'Support', 'woo-variation-swatches' ) . '</a>',
|
154 |
+
);
|
155 |
+
|
156 |
+
return array_merge( $links, $row_meta );
|
157 |
+
}
|
158 |
+
|
159 |
+
return (array) $links;
|
160 |
+
}
|
161 |
+
|
162 |
+
public function plugin_action_links( $links ) {
|
163 |
+
$action_links = array(// 'settings' => '<a href="' . admin_url( 'admin.php?page=upb-settings' ) . '" title="' . esc_attr__( 'View Settings', 'woo-variation-swatches' ) . '">' . esc_html__( 'Settings', 'woo-variation-swatches' ) . '</a>',
|
164 |
+
);
|
165 |
+
|
166 |
+
return array_merge( $action_links, $links );
|
167 |
+
}
|
168 |
+
|
169 |
+
public function get_theme_name() {
|
170 |
+
return wp_get_theme()->get( 'Name' );
|
171 |
+
}
|
172 |
+
|
173 |
+
public function get_theme_version() {
|
174 |
+
return wp_get_theme()->get( 'Version' );
|
175 |
+
}
|
176 |
+
|
177 |
+
public function is_required_php_version() {
|
178 |
+
return version_compare( PHP_VERSION, '5.6.0', '>=' );
|
179 |
+
}
|
180 |
+
|
181 |
+
public function php_requirement_notice() {
|
182 |
+
if ( ! $this->is_required_php_version() ) {
|
183 |
+
$class = 'notice notice-error';
|
184 |
+
$text = esc_html__( 'Please check PHP version requirement.', 'woo-variation-swatches' );
|
185 |
+
$link = esc_url( 'https://docs.woocommerce.com/document/server-requirements/' );
|
186 |
+
$message = wp_kses( __( "It's required to use latest version of PHP to use <strong>Woo Variation Swatches</strong>.", 'woo-variation-swatches' ), array( 'strong' => array() ) );
|
187 |
+
|
188 |
+
printf( '<div class="%1$s"><p>%2$s <a target="_blank" href="%3$s">%4$s</a></p></div>', $class, $message, $link, $text );
|
189 |
+
}
|
190 |
+
}
|
191 |
+
|
192 |
+
public function wc_requirement_notice() {
|
193 |
+
if ( ! $this->is_wc_active() ) {
|
194 |
+
$class = 'notice notice-error';
|
195 |
+
|
196 |
+
$text = esc_html__( 'WooCommerce', 'woo-variation-swatches' );
|
197 |
+
$link = esc_url( 'https://wordpress.org/plugins/woocommerce/' );
|
198 |
+
$message = wp_kses( __( "<strong>Woo Variation Switcher</strong> is an add-on of ", 'woo-variation-swatches' ), array( 'strong' => array() ) );
|
199 |
+
|
200 |
+
printf( '<div class="%1$s"><p>%2$s <a target="_blank" href="%3$s"><strong>%4$s</strong></a></p></div>', $class, $message, $link, $text );
|
201 |
+
}
|
202 |
+
}
|
203 |
+
|
204 |
+
public function language() {
|
205 |
+
load_plugin_textdomain( 'woo-variation-swatches', FALSE, trailingslashit( WVS_PLUGIN_DIRNAME ) . 'languages' );
|
206 |
+
}
|
207 |
+
|
208 |
+
public function is_wc_active() {
|
209 |
+
return in_array( 'woocommerce/woocommerce.php', get_option( 'active_plugins' ) );
|
210 |
+
}
|
211 |
+
|
212 |
+
public function basename() {
|
213 |
+
return WVS_PLUGIN_BASENAME;
|
214 |
+
}
|
215 |
+
|
216 |
+
public function dirname() {
|
217 |
+
return WVS_PLUGIN_DIRNAME;
|
218 |
+
}
|
219 |
+
|
220 |
+
public function version() {
|
221 |
+
return WVS_PLUGIN_VERSION;
|
222 |
+
}
|
223 |
+
|
224 |
+
public function plugin_path() {
|
225 |
+
return untrailingslashit( plugin_dir_path( __FILE__ ) );
|
226 |
+
}
|
227 |
+
|
228 |
+
public function plugin_uri() {
|
229 |
+
return untrailingslashit( plugins_url( '/', __FILE__ ) );
|
230 |
+
}
|
231 |
+
|
232 |
+
public function images_uri( $file ) {
|
233 |
+
$file = ltrim( $file, '/' );
|
234 |
+
|
235 |
+
return WVS_IMAGES_URI . $file;
|
236 |
+
}
|
237 |
+
|
238 |
+
public function assets_uri( $file ) {
|
239 |
+
$file = ltrim( $file, '/' );
|
240 |
+
|
241 |
+
return WVS_ASSETS_URI . $file;
|
242 |
+
}
|
243 |
+
|
244 |
+
public function template_override_dir() {
|
245 |
+
return apply_filters( 'wvs_override_dir', 'woo-variation-swatches' );
|
246 |
+
}
|
247 |
+
|
248 |
+
public function template_path() {
|
249 |
+
return apply_filters( 'wvs_template_path', untrailingslashit( $this->plugin_path() ) . '/templates' );
|
250 |
+
}
|
251 |
+
|
252 |
+
public function template_uri() {
|
253 |
+
return apply_filters( 'wvs_template_uri', untrailingslashit( $this->plugin_uri() ) . '/templates' );
|
254 |
+
}
|
255 |
+
}
|
256 |
+
|
257 |
+
function woo_variation_swatches() {
|
258 |
+
return Woo_Variation_Swatches::init();
|
259 |
+
}
|
260 |
+
|
261 |
+
add_action( 'plugins_loaded', 'woo_variation_swatches' );
|
262 |
+
endif;
|