YITH WooCommerce Compare - Version 2.3.6

Version Description

Released on Nov 28, 2018

  • Update: Plugin Core.
  • Update: Language files.
  • Fix: Missing strings in pot and po files.
Download this release

Release Info

Developer yithemes
Plugin Icon 128x128 YITH WooCommerce Compare
Version 2.3.6
Comparing to
See all releases

Code changes from version 2.3.5 to 2.3.6

Files changed (64) hide show
  1. README.txt +320 -314
  2. assets/css/admin.css +28 -28
  3. assets/css/style.css +218 -218
  4. assets/css/widget.css +64 -64
  5. assets/js/woocompare-admin.js +18 -18
  6. includes/class.yith-woocompare-admin.php +476 -476
  7. includes/class.yith-woocompare-frontend.php +818 -818
  8. includes/class.yith-woocompare-helper.php +104 -104
  9. includes/class.yith-woocompare.php +144 -144
  10. init.php +121 -121
  11. languages/yith-woocommerce-compare-bg_BG.mo +0 -0
  12. languages/yith-woocommerce-compare-bg_BG.po +107 -86
  13. languages/yith-woocommerce-compare-es_ES.mo +0 -0
  14. languages/yith-woocommerce-compare-es_ES.po +107 -86
  15. languages/yith-woocommerce-compare-fa_IR.mo +0 -0
  16. languages/yith-woocommerce-compare-fa_IR.po +107 -86
  17. languages/yith-woocommerce-compare-fr_FR.mo +0 -0
  18. languages/yith-woocommerce-compare-fr_FR.po +107 -86
  19. languages/yith-woocommerce-compare-it_IT.mo +0 -0
  20. languages/yith-woocommerce-compare-it_IT.po +74 -56
  21. languages/yith-woocommerce-compare-nl_NL.mo +0 -0
  22. languages/yith-woocommerce-compare-nl_NL.po +136 -113
  23. languages/yith-woocommerce-compare-pt_BR.mo +0 -0
  24. languages/yith-woocommerce-compare-pt_BR.po +81 -62
  25. languages/yith-woocommerce-compare-ru_RU.mo +0 -0
  26. languages/yith-woocommerce-compare-ru_RU.po +83 -58
  27. languages/yith-woocommerce-compare-sk_SK.mo +0 -0
  28. languages/yith-woocommerce-compare-sk_SK.po +107 -86
  29. languages/yith-woocommerce-compare-sl_SI.mo +0 -0
  30. languages/yith-woocommerce-compare-sl_SI.po +81 -59
  31. languages/yith-woocommerce-compare-tr_TR.mo +0 -0
  32. languages/yith-woocommerce-compare-tr_TR.po +151 -84
  33. languages/yith-woocommerce-compare.pot +72 -57
  34. plugin-fw/assets/css/admin.css +12 -0
  35. plugin-fw/assets/css/metaboxes.css +19 -3
  36. plugin-fw/assets/images/yith-icon.svg +1 -0
  37. plugin-fw/assets/js/javascript-md5/md5.min.js +2 -0
  38. plugin-fw/assets/js/yith-gutenberg.js +208 -0
  39. plugin-fw/assets/js/yith-gutenberg.min.js +6 -0
  40. plugin-fw/init.php +2 -2
  41. plugin-fw/languages/yith-plugin-fw-es_ES.mo +0 -0
  42. plugin-fw/languages/yith-plugin-fw-es_ES.po +111 -92
  43. plugin-fw/languages/yith-plugin-fw-it_IT.mo +0 -0
  44. plugin-fw/languages/yith-plugin-fw-it_IT.po +146 -192
  45. plugin-fw/languages/yith-plugin-fw.pot +98 -88
  46. plugin-fw/lib/promo/yith-promo.php +146 -109
  47. plugin-fw/lib/yit-plugin-panel.php +1 -1
  48. plugin-fw/lib/yit-plugin-subpanel.php +1 -1
  49. plugin-fw/lib/yit-upgrade.php +35 -6
  50. plugin-fw/lib/yith-gutenberg.php +321 -0
  51. plugin-fw/licence/assets/js/yit-licence.js +30 -15
  52. plugin-fw/licence/assets/js/yit-licence.min.js +1 -10
  53. plugin-fw/licence/lib/yit-licence.php +84 -35
  54. plugin-fw/licence/lib/yit-plugin-licence.php +14 -5
  55. plugin-fw/licence/templates/panel/activation/activation-panel.php +1 -1
  56. plugin-fw/templates/privacy/html-policy-content.php +36 -36
  57. plugin-fw/yit-functions.php +66 -0
  58. plugin-fw/yit-plugin.php +6 -1
  59. plugin-options/general-options.php +145 -145
  60. plugin-options/premium-options.php +23 -23
  61. templates/admin/premium.php +454 -454
  62. templates/compare.php +284 -284
  63. widgets/class.yith-woocompare-widget.php +83 -83
  64. wpml-config.xml +5 -5
README.txt CHANGED
@@ -1,314 +1,320 @@
1
- === YITH WooCommerce Compare ===
2
-
3
- Contributors: yithemes
4
- Tags: yith, woocommerce compare, compare products, product compare, product comparison
5
- Requires at least: 3.5.1
6
- Tested up to: 4.9
7
- Stable tag: 2.3.5
8
- License: GPLv2 or later
9
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
-
11
- YITH WooCommerce Compare allows you to compare more products of your shop in one complete table.
12
- WooCommerce Compatible up to 3.5
13
-
14
- == Description ==
15
-
16
- YITH WooCommerce Compare plugin is an extension of WooCommerce plugin that allow your users to compare some products of your shop.
17
- All products are saved in one complete table where the user can see the difference between the products. Each product features can be
18
- set with the woocommerce attributes in the product configuration.
19
- You can also add a simple widget with the list of products the users have added, where you can manage them.
20
- Also you can simply customize the compare table with your style, by editing the specific template.
21
-
22
- Full documentation is available [here](http://yithemes.com/docs-plugins/yith-woocommerce-compare).
23
-
24
- This plugin is 100% compatible with [WPML](http://wpml.org/?aid=24889&affiliate_key=Qn1wDeBNTcZV)
25
-
26
-
27
- = Installation =
28
-
29
- 1. Unzip the downloaded zip file.
30
- 2. Upload the plugin folder into the `wp-content/plugins/` directory of your WordPress site.
31
- 3. Activate `YITH WooCommerce Compare` from Plugins page
32
-
33
- = Configuration =
34
-
35
- 1. Add the features in each product by setting the attributes in prouct configuration;
36
- 2. Configure the options in YIT Plugin -> Compare;
37
- 3. The user of your shop will click in the "Compare" button located in the single product page;
38
- 4. Will be open a popup with the compare table inside.
39
-
40
- You can also add the widget with the product list of compare table, in Appearance -> Widgets and adding the widget "YITH WooCommerce Compare Widget".
41
-
42
- == Frequently Asked Questions ==
43
-
44
- = Can I customize the compare table? =
45
- Yes, you can copy the template from the plugin folder and paste it inside the folder "woocommerce" of your theme folder.
46
-
47
- = Can I select what fields show inside the compare table? =
48
- Yes, you can choose what fields to show in the compare table. You can do it in YIT Plugins -> Compare.
49
-
50
- = Can I order the fields in the compare table? =
51
- Yes, you can sort the fields in the compare table. You can do it in YIT Plugins -> Compare.
52
-
53
- = What are the main changes in plugin translation? =
54
- Recently YITH WooCommerce Compare has been selected to be included in the "translate.wordpress.org" translate programme.
55
- In order to import correctly the plugin strings in the new system, we had to change the text domain form 'yit' to 'yith-woocommerce-compare'.
56
- Once the plugin will be imported in the translate.wordpress.org system, the translations of other languages will be downloaded directly from WordPress, without using any .po and .mo files. Moreover, users will be able to participate in a more direct way to plugin translations, suggesting texts in their languages in the dedicated tab on translate.wordpress.org.
57
- During this transition step, .po and .mo files will be used as always, but in order to be recognized by WordPress, they will need to have a new nomenclature, renaming them in:
58
- yith-woocommerce-compare-<WORDPRESS LOCALE>.po
59
- yith-woocommerce-compare-<WORDPRESS LOCALE >.mo
60
-
61
- == Screenshots ==
62
-
63
- 1. The popup with compare table.
64
- 2. The button compare.
65
- 3. The settings of plugin
66
-
67
- == Changelog ==
68
-
69
- = 2.3.5 = Released on Oct 23, 2018
70
-
71
- * New: Support to WooCommerce 3.5.0.
72
- * Update: Plugin Core.
73
- * Fix: Product placeholder image and image size.
74
-
75
- = 2.3.4 = Released on Oct 01, 2018
76
-
77
- * New: Support to WooCommerce 3.5.0 RC1.
78
- * Update: Plugin Core.
79
-
80
- = 2.3.3 = Released on Sep 20, 2018
81
-
82
- * Fix: Compatibility issue with WPML and RTL languages.
83
-
84
- = 2.3.2 = Released on Sep 10, 2018
85
-
86
- * New: Support to WooCommerce 3.4.5.
87
- * New: Support to WordPress 4.9.8.
88
- * Update: Plugin Core.
89
- * Update: All external scripts to latest available version.
90
- * Update: Compare table template (compare.php) to version 2.3.2.
91
- * Update: Compare table style.
92
- * Fix: Check product status before add it to compare list.
93
-
94
- = 2.3.1 = Released on Jun 5, 2018
95
-
96
- * New: Support to WooCommerce 3.4.1.
97
- * New: Support to WordPress 4.9.6.
98
- * Update: Plugin Core.
99
- * Fix: WPML table fields translation.
100
-
101
- = 2.3.0 = Released on Feb 2, 2018
102
-
103
- * New: Support to WooCommerce 3.3.0.
104
- * New: Support to WordPress 4.9.2.
105
- * Update: Plugin Core.
106
-
107
- = 2.2.3 = Released on Dec 21, 2017
108
-
109
- * New: Support to WooCommerce 3.2.6.
110
- * New: Support to WordPress 4.9.1.
111
- * New: Product SKU field in compare table.
112
- * Update: Plugin Core.
113
- * Update: Language Files.
114
- * Dev: New filter yith_woocompare_standard_fields_array to filter standard compare fields.
115
-
116
- = 2.2.2 = Released on Oct 24, 2017
117
-
118
- * New: Support to WooCommerce 3.2.1.
119
- * New: Support to WordPress 4.8.2.
120
- * Update: Plugin Core.
121
- * Update: Language Files.
122
-
123
- = 2.2.1 = Released on Jul 05, 2017
124
-
125
- * New: Support to WooCommerce 3.1.
126
- * New: Support to WordPress 4.8.
127
- * New: Russian Translation.
128
- * New: Slovenian Translation.
129
- * Update: Plugin Core.
130
- * Update: Language Files.
131
- * Fix: WPML and Add to cart action from popup.
132
-
133
- = 2.2.0 = Released on Mar 29, 2017
134
-
135
- * New: Support to WooCommerce 3.0.0 RC2.
136
- * New: Support to WordPress 4.7.3
137
- * Update: Plugin Core.
138
- * Update: Language Files.
139
-
140
- = 2.1.0 = Released on Oct 19, 2016
141
-
142
- * New: Support to WooCommerce 2.6.4
143
- * New: Support to WordPress 4.6
144
- * New: Auto remove from compare list for products that are private or were cancelled.
145
- * New: Add as default fields Weight and Dimensions.
146
- * Update: Plugin Core.
147
- * Update: Language Files.
148
- * Fix: Uncaught ReferenceError "redirect_to_cart is not defined" error on "add to cart" action.
149
- * Fix: Compatibility issue with NextGen Gallery plugin.
150
-
151
- = 2.0.9 = Released on Jun 13, 2016
152
-
153
- * New: Support to WooCommerce 2.6 RC1
154
- * Update: Plugin Core.
155
-
156
- = 2.0.8 = Released on Apr 19, 2016
157
-
158
- * New: Compatibility with WordPress 4.5
159
- * Update: Plugin Core.
160
- * Fix: Fatal error call to undefined method WC_AJAX::get_endpoint() for WooCommerce version older then 2.4
161
-
162
- = 2.0.7 = Released on Apr 01, 2016
163
-
164
- * Update: Plugin template compare.php
165
- * Update: Plugin Core.
166
- * Update: Language file.
167
- * Fix: Product status now updates automatically when the product is removed from the compare widget.
168
- * Fix: Redirect correctly to cart page after "Add to cart" is clicked if "Redirect to the cart page after successful addition" option is enabled.
169
- * Fix: Redirect correctly to product page after "Add to cart" is clicked when "Enable AJAX add to cart buttons on archives" option is disabled.
170
-
171
- = 2.0.6 = Released on Jan 11, 2016
172
-
173
- * New: Compatibility with WooCommerce 2.5 RC
174
- * Update: Change ajax call fron admin-ajax to wc-ajax
175
- * Update: Plugin template compare.php
176
- * Update: Plugin Core
177
-
178
- = 2.0.5 = Released on Oct 30, 2015
179
-
180
- * Update: Plugin Core
181
- * Fix: After you remove product from compare, you can re-add it without reload page
182
-
183
- = 2.0.4 = Released on Sep 22, 2015
184
-
185
- * Update: Changed Text Domain from 'yith-wcmp' to 'yith-woocommerce-compare'
186
- * Update: Plugin Core Framework
187
- * Fix: JS error when loading compare window
188
-
189
- = 2.0.3 = Released on Aug 21, 2015
190
-
191
- * New: Compatibility with WooPress 4.3
192
-
193
- = 2.0.2 = Released on Aug 12, 2015
194
-
195
- * New: Compatibility with WooCommerce 2.4
196
- * Update: Core plugin
197
-
198
- = 2.0.1 = Released on Aug 10, 2015
199
-
200
- * Update: Core plugin
201
- * Fix: Compare table layout
202
- * Fix: undefined function unblock() in main js
203
-
204
- = 2.0.0 = Released on Jul 15, 2015
205
-
206
- * New: New plugin core
207
- * Update: Language files
208
- * Removed: old default.po catalog language file
209
- * Fix: Error in class yith-woocompare-fontend
210
- * Fix: Lightbox doesn't close after click view cart
211
- * Fix: minor bug fix
212
-
213
- = 1.2.3 = Released on Feb 13, 2015
214
-
215
- * New: Bulgarian Translation by Joanna Mikova
216
- * New: Spanish Translation by Rodoslav Angelov and Mariano Rivas
217
-
218
- = 1.2.2 = Released on Dec 03, 2014
219
-
220
- * Fix: Shortcode compare
221
-
222
- = 1.2.1 = Released on Sep 17, 2014
223
-
224
- * New: Support to WC 2.2.3
225
-
226
- = 1.2.0 = Released on Sep 16, 2014
227
-
228
- * New: Support to WC 2.2.2
229
- * Update: Compare Template
230
- * Update: Plugin Core Framework
231
- * Fix: Fields orders
232
- * Tweek: WPML Support improved
233
-
234
- = 1.1.4 = Released on Jun 30, 2014
235
-
236
- * Update: Colorbox Library Version 1.5.10
237
- * Fix: Horizontal scroll bar issue: show at the end of iframe
238
-
239
- = 1.1.3 = Released on Jun 05, 2014
240
-
241
- * New: RTL Support
242
-
243
- = 1.1.2 = Released on Mar 21, 2014
244
-
245
- * Fix: WPML Support on Compare Widget
246
-
247
- = 1.1.1 = Released on Feb 19, 2014
248
-
249
- * Fix: Add to cart Button on Compare page
250
-
251
- = 1.1.0 = Released on Feb 13, 2014
252
-
253
- * New: Support to WooCommerce 2.1.X
254
- * New: French translation by Paumo
255
-
256
- = 1.0.5 = Released on Oct 14, 2013
257
-
258
- * New: Persian translation by Khalil Delavaran
259
- * New: Compare table title option
260
- * New: Compatibility with WPML plugin
261
- * New: Brazilian Portuguese translation by hotelwww
262
- * Fix: Responsive features
263
- * Fix: Dequeued wrong JS scripts
264
- * Update: Dutch translation by Frans Pronk
265
-
266
- = 1.0.4 = Released on Sep 04, 2013
267
-
268
- * New: complete Dutch translation. Thanks to Frans Pronk
269
- * Fix: Sortable scripts included only in the plugin admin page
270
- * Fix: products list in popup don't update after have added a product
271
-
272
- = 1.0.3 = Released on Jul 31, 2013
273
-
274
- * Minor bugs fixes
275
-
276
- = 1.0.2 = Released on Jul 20, 2013
277
-
278
- * Tweak: trigger in javascript file for add to compare event
279
-
280
- = 1.0.1 = Released on Jun 27, 2013
281
-
282
- * New: Link/Button text option in plugin options
283
- * New: ability to add a link in the menu top open the popup
284
- * Fix: bug with attributes added after installation
285
- * Fix: bug with plugin activated but not working for multisites
286
-
287
- = 1.0.0 = Released on Jun 24, 2013
288
-
289
- * Initial release
290
-
291
- == Suggestions ==
292
-
293
- If you have suggestions about how to improve YITH WooCommerce Compare, you can [write us](mailto:plugins@yithemes.com "Your Inspiration Themes") so we can bundle them into YITH WooCommerce Compare.
294
-
295
- == Translators ==
296
-
297
- = Available Languages =
298
- * English (Default)
299
- * Italiano
300
-
301
- If you can't find this plugin in your language and want to translate it, use the dedicated tool at [Translating WordPress](https://translate.wordpress.org/locale/it/default/wp-plugins/yith-woocommerce-compare "Translating WordPress").
302
- Or, if you have created your own language pack, or have an update for an existing one, you can send it as an email attachment from our [Contacts page](http://yithemes.com/contact/ "Your Inspiration Themes") and we will bundle into YITH WooCommerce Compare.
303
-
304
- == Documentation ==
305
-
306
- Full documentation is available [here](http://yithemes.com/docs-plugins/yith-woocommerce-compare).
307
-
308
- == Upgrade notice ==
309
-
310
- = 2.3.5 = Released on Oct 23, 2018
311
-
312
- * New: Support to WooCommerce 3.5.0.
313
- * Update: Plugin Core.
314
- * Fix: Product placeholder image and image size.
1
+ === YITH WooCommerce Compare ===
2
+
3
+ Contributors: yithemes
4
+ Tags: yith, woocommerce compare, compare products, product compare, product comparison
5
+ Requires at least: 3.5.1
6
+ Tested up to: 4.9
7
+ Stable tag: 2.3.6
8
+ License: GPLv2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
+
11
+ YITH WooCommerce Compare allows you to compare more products of your shop in one complete table.
12
+ WooCommerce Compatible up to 3.5
13
+
14
+ == Description ==
15
+
16
+ YITH WooCommerce Compare plugin is an extension of WooCommerce plugin that allow your users to compare some products of your shop.
17
+ All products are saved in one complete table where the user can see the difference between the products. Each product features can be
18
+ set with the woocommerce attributes in the product configuration.
19
+ You can also add a simple widget with the list of products the users have added, where you can manage them.
20
+ Also you can simply customize the compare table with your style, by editing the specific template.
21
+
22
+ Full documentation is available [here](http://yithemes.com/docs-plugins/yith-woocommerce-compare).
23
+
24
+ This plugin is 100% compatible with [WPML](http://wpml.org/?aid=24889&affiliate_key=Qn1wDeBNTcZV)
25
+
26
+
27
+ = Installation =
28
+
29
+ 1. Unzip the downloaded zip file.
30
+ 2. Upload the plugin folder into the `wp-content/plugins/` directory of your WordPress site.
31
+ 3. Activate `YITH WooCommerce Compare` from Plugins page
32
+
33
+ = Configuration =
34
+
35
+ 1. Add the features in each product by setting the attributes in prouct configuration;
36
+ 2. Configure the options in YIT Plugin -> Compare;
37
+ 3. The user of your shop will click in the "Compare" button located in the single product page;
38
+ 4. Will be open a popup with the compare table inside.
39
+
40
+ You can also add the widget with the product list of compare table, in Appearance -> Widgets and adding the widget "YITH WooCommerce Compare Widget".
41
+
42
+ == Frequently Asked Questions ==
43
+
44
+ = Can I customize the compare table? =
45
+ Yes, you can copy the template from the plugin folder and paste it inside the folder "woocommerce" of your theme folder.
46
+
47
+ = Can I select what fields show inside the compare table? =
48
+ Yes, you can choose what fields to show in the compare table. You can do it in YIT Plugins -> Compare.
49
+
50
+ = Can I order the fields in the compare table? =
51
+ Yes, you can sort the fields in the compare table. You can do it in YIT Plugins -> Compare.
52
+
53
+ = What are the main changes in plugin translation? =
54
+ Recently YITH WooCommerce Compare has been selected to be included in the "translate.wordpress.org" translate programme.
55
+ In order to import correctly the plugin strings in the new system, we had to change the text domain form 'yit' to 'yith-woocommerce-compare'.
56
+ Once the plugin will be imported in the translate.wordpress.org system, the translations of other languages will be downloaded directly from WordPress, without using any .po and .mo files. Moreover, users will be able to participate in a more direct way to plugin translations, suggesting texts in their languages in the dedicated tab on translate.wordpress.org.
57
+ During this transition step, .po and .mo files will be used as always, but in order to be recognized by WordPress, they will need to have a new nomenclature, renaming them in:
58
+ yith-woocommerce-compare-<WORDPRESS LOCALE>.po
59
+ yith-woocommerce-compare-<WORDPRESS LOCALE >.mo
60
+
61
+ == Screenshots ==
62
+
63
+ 1. The popup with compare table.
64
+ 2. The button compare.
65
+ 3. The settings of plugin
66
+
67
+ == Changelog ==
68
+
69
+ = 2.3.6 = Released on Nov 28, 2018
70
+
71
+ * Update: Plugin Core.
72
+ * Update: Language files.
73
+ * Fix: Missing strings in pot and po files.
74
+
75
+ = 2.3.5 = Released on Oct 23, 2018
76
+
77
+ * New: Support to WooCommerce 3.5.0.
78
+ * Update: Plugin Core.
79
+ * Fix: Product placeholder image and image size.
80
+
81
+ = 2.3.4 = Released on Oct 01, 2018
82
+
83
+ * New: Support to WooCommerce 3.5.0 RC1.
84
+ * Update: Plugin Core.
85
+
86
+ = 2.3.3 = Released on Sep 20, 2018
87
+
88
+ * Fix: Compatibility issue with WPML and RTL languages.
89
+
90
+ = 2.3.2 = Released on Sep 10, 2018
91
+
92
+ * New: Support to WooCommerce 3.4.5.
93
+ * New: Support to WordPress 4.9.8.
94
+ * Update: Plugin Core.
95
+ * Update: All external scripts to latest available version.
96
+ * Update: Compare table template (compare.php) to version 2.3.2.
97
+ * Update: Compare table style.
98
+ * Fix: Check product status before add it to compare list.
99
+
100
+ = 2.3.1 = Released on Jun 5, 2018
101
+
102
+ * New: Support to WooCommerce 3.4.1.
103
+ * New: Support to WordPress 4.9.6.
104
+ * Update: Plugin Core.
105
+ * Fix: WPML table fields translation.
106
+
107
+ = 2.3.0 = Released on Feb 2, 2018
108
+
109
+ * New: Support to WooCommerce 3.3.0.
110
+ * New: Support to WordPress 4.9.2.
111
+ * Update: Plugin Core.
112
+
113
+ = 2.2.3 = Released on Dec 21, 2017
114
+
115
+ * New: Support to WooCommerce 3.2.6.
116
+ * New: Support to WordPress 4.9.1.
117
+ * New: Product SKU field in compare table.
118
+ * Update: Plugin Core.
119
+ * Update: Language Files.
120
+ * Dev: New filter yith_woocompare_standard_fields_array to filter standard compare fields.
121
+
122
+ = 2.2.2 = Released on Oct 24, 2017
123
+
124
+ * New: Support to WooCommerce 3.2.1.
125
+ * New: Support to WordPress 4.8.2.
126
+ * Update: Plugin Core.
127
+ * Update: Language Files.
128
+
129
+ = 2.2.1 = Released on Jul 05, 2017
130
+
131
+ * New: Support to WooCommerce 3.1.
132
+ * New: Support to WordPress 4.8.
133
+ * New: Russian Translation.
134
+ * New: Slovenian Translation.
135
+ * Update: Plugin Core.
136
+ * Update: Language Files.
137
+ * Fix: WPML and Add to cart action from popup.
138
+
139
+ = 2.2.0 = Released on Mar 29, 2017
140
+
141
+ * New: Support to WooCommerce 3.0.0 RC2.
142
+ * New: Support to WordPress 4.7.3
143
+ * Update: Plugin Core.
144
+ * Update: Language Files.
145
+
146
+ = 2.1.0 = Released on Oct 19, 2016
147
+
148
+ * New: Support to WooCommerce 2.6.4
149
+ * New: Support to WordPress 4.6
150
+ * New: Auto remove from compare list for products that are private or were cancelled.
151
+ * New: Add as default fields Weight and Dimensions.
152
+ * Update: Plugin Core.
153
+ * Update: Language Files.
154
+ * Fix: Uncaught ReferenceError "redirect_to_cart is not defined" error on "add to cart" action.
155
+ * Fix: Compatibility issue with NextGen Gallery plugin.
156
+
157
+ = 2.0.9 = Released on Jun 13, 2016
158
+
159
+ * New: Support to WooCommerce 2.6 RC1
160
+ * Update: Plugin Core.
161
+
162
+ = 2.0.8 = Released on Apr 19, 2016
163
+
164
+ * New: Compatibility with WordPress 4.5
165
+ * Update: Plugin Core.
166
+ * Fix: Fatal error call to undefined method WC_AJAX::get_endpoint() for WooCommerce version older then 2.4
167
+
168
+ = 2.0.7 = Released on Apr 01, 2016
169
+
170
+ * Update: Plugin template compare.php
171
+ * Update: Plugin Core.
172
+ * Update: Language file.
173
+ * Fix: Product status now updates automatically when the product is removed from the compare widget.
174
+ * Fix: Redirect correctly to cart page after "Add to cart" is clicked if "Redirect to the cart page after successful addition" option is enabled.
175
+ * Fix: Redirect correctly to product page after "Add to cart" is clicked when "Enable AJAX add to cart buttons on archives" option is disabled.
176
+
177
+ = 2.0.6 = Released on Jan 11, 2016
178
+
179
+ * New: Compatibility with WooCommerce 2.5 RC
180
+ * Update: Change ajax call fron admin-ajax to wc-ajax
181
+ * Update: Plugin template compare.php
182
+ * Update: Plugin Core
183
+
184
+ = 2.0.5 = Released on Oct 30, 2015
185
+
186
+ * Update: Plugin Core
187
+ * Fix: After you remove product from compare, you can re-add it without reload page
188
+
189
+ = 2.0.4 = Released on Sep 22, 2015
190
+
191
+ * Update: Changed Text Domain from 'yith-wcmp' to 'yith-woocommerce-compare'
192
+ * Update: Plugin Core Framework
193
+ * Fix: JS error when loading compare window
194
+
195
+ = 2.0.3 = Released on Aug 21, 2015
196
+
197
+ * New: Compatibility with WooPress 4.3
198
+
199
+ = 2.0.2 = Released on Aug 12, 2015
200
+
201
+ * New: Compatibility with WooCommerce 2.4
202
+ * Update: Core plugin
203
+
204
+ = 2.0.1 = Released on Aug 10, 2015
205
+
206
+ * Update: Core plugin
207
+ * Fix: Compare table layout
208
+ * Fix: undefined function unblock() in main js
209
+
210
+ = 2.0.0 = Released on Jul 15, 2015
211
+
212
+ * New: New plugin core
213
+ * Update: Language files
214
+ * Removed: old default.po catalog language file
215
+ * Fix: Error in class yith-woocompare-fontend
216
+ * Fix: Lightbox doesn't close after click view cart
217
+ * Fix: minor bug fix
218
+
219
+ = 1.2.3 = Released on Feb 13, 2015
220
+
221
+ * New: Bulgarian Translation by Joanna Mikova
222
+ * New: Spanish Translation by Rodoslav Angelov and Mariano Rivas
223
+
224
+ = 1.2.2 = Released on Dec 03, 2014
225
+
226
+ * Fix: Shortcode compare
227
+
228
+ = 1.2.1 = Released on Sep 17, 2014
229
+
230
+ * New: Support to WC 2.2.3
231
+
232
+ = 1.2.0 = Released on Sep 16, 2014
233
+
234
+ * New: Support to WC 2.2.2
235
+ * Update: Compare Template
236
+ * Update: Plugin Core Framework
237
+ * Fix: Fields orders
238
+ * Tweek: WPML Support improved
239
+
240
+ = 1.1.4 = Released on Jun 30, 2014
241
+
242
+ * Update: Colorbox Library Version 1.5.10
243
+ * Fix: Horizontal scroll bar issue: show at the end of iframe
244
+
245
+ = 1.1.3 = Released on Jun 05, 2014
246
+
247
+ * New: RTL Support
248
+
249
+ = 1.1.2 = Released on Mar 21, 2014
250
+
251
+ * Fix: WPML Support on Compare Widget
252
+
253
+ = 1.1.1 = Released on Feb 19, 2014
254
+
255
+ * Fix: Add to cart Button on Compare page
256
+
257
+ = 1.1.0 = Released on Feb 13, 2014
258
+
259
+ * New: Support to WooCommerce 2.1.X
260
+ * New: French translation by Paumo
261
+
262
+ = 1.0.5 = Released on Oct 14, 2013
263
+
264
+ * New: Persian translation by Khalil Delavaran
265
+ * New: Compare table title option
266
+ * New: Compatibility with WPML plugin
267
+ * New: Brazilian Portuguese translation by hotelwww
268
+ * Fix: Responsive features
269
+ * Fix: Dequeued wrong JS scripts
270
+ * Update: Dutch translation by Frans Pronk
271
+
272
+ = 1.0.4 = Released on Sep 04, 2013
273
+
274
+ * New: complete Dutch translation. Thanks to Frans Pronk
275
+ * Fix: Sortable scripts included only in the plugin admin page
276
+ * Fix: products list in popup don't update after have added a product
277
+
278
+ = 1.0.3 = Released on Jul 31, 2013
279
+
280
+ * Minor bugs fixes
281
+
282
+ = 1.0.2 = Released on Jul 20, 2013
283
+
284
+ * Tweak: trigger in javascript file for add to compare event
285
+
286
+ = 1.0.1 = Released on Jun 27, 2013
287
+
288
+ * New: Link/Button text option in plugin options
289
+ * New: ability to add a link in the menu top open the popup
290
+ * Fix: bug with attributes added after installation
291
+ * Fix: bug with plugin activated but not working for multisites
292
+
293
+ = 1.0.0 = Released on Jun 24, 2013
294
+
295
+ * Initial release
296
+
297
+ == Suggestions ==
298
+
299
+ If you have suggestions about how to improve YITH WooCommerce Compare, you can [write us](mailto:plugins@yithemes.com "Your Inspiration Themes") so we can bundle them into YITH WooCommerce Compare.
300
+
301
+ == Translators ==
302
+
303
+ = Available Languages =
304
+ * English (Default)
305
+ * Italiano
306
+
307
+ If you can't find this plugin in your language and want to translate it, use the dedicated tool at [Translating WordPress](https://translate.wordpress.org/locale/it/default/wp-plugins/yith-woocommerce-compare "Translating WordPress").
308
+ Or, if you have created your own language pack, or have an update for an existing one, you can send it as an email attachment from our [Contacts page](http://yithemes.com/contact/ "Your Inspiration Themes") and we will bundle into YITH WooCommerce Compare.
309
+
310
+ == Documentation ==
311
+
312
+ Full documentation is available [here](http://yithemes.com/docs-plugins/yith-woocommerce-compare).
313
+
314
+ == Upgrade notice ==
315
+
316
+ = 2.3.6 = Released on Nov 28, 2018
317
+
318
+ * Update: Plugin Core.
319
+ * Update: Language files.
320
+ * Fix: Missing strings in pot and po files.
assets/css/admin.css CHANGED
@@ -1,28 +1,28 @@
1
- .yith_woocommerce_slider {
2
- width: 300px;
3
- float: left
4
- }
5
- .yith_woocommerce_slider_value {
6
- margin-top: -5px;
7
- margin-left: 10px;
8
- width: 50px;
9
- float: left;
10
- text-align: center;
11
- font-weight: bold;
12
- }
13
-
14
- .attributes li {
15
- margin-bottom: 0;
16
- }
17
-
18
- .attributes .ui-sortable-placeholder {
19
- background: #f9f9f9;
20
- border: 1px dashed #d4d4d4;
21
- -webkit-border-radius: 3px;
22
- -moz-border-radius: 3px;
23
- border-radius: 3px;
24
- visibility: visible !important;
25
- box-sizing: border-box;
26
- -moz-box-sizing: border-box;
27
- margin-bottom: -2px;
28
- }
1
+ .yith_woocommerce_slider {
2
+ width: 300px;
3
+ float: left
4
+ }
5
+ .yith_woocommerce_slider_value {
6
+ margin-top: -5px;
7
+ margin-left: 10px;
8
+ width: 50px;
9
+ float: left;
10
+ text-align: center;
11
+ font-weight: bold;
12
+ }
13
+
14
+ .attributes li {
15
+ margin-bottom: 0;
16
+ }
17
+
18
+ .attributes .ui-sortable-placeholder {
19
+ background: #f9f9f9;
20
+ border: 1px dashed #d4d4d4;
21
+ -webkit-border-radius: 3px;
22
+ -moz-border-radius: 3px;
23
+ border-radius: 3px;
24
+ visibility: visible !important;
25
+ box-sizing: border-box;
26
+ -moz-box-sizing: border-box;
27
+ margin-bottom: -2px;
28
+ }
assets/css/style.css CHANGED
@@ -1,219 +1,219 @@
1
- /**
2
- * The style of the woocommerce compare products
3
- */
4
-
5
- /* ###############
6
- FIXED COLUMNS
7
- ##############*/
8
-
9
- table.DTFC_Cloned thead, table.DTFC_Cloned tfoot{
10
- background-color:white;
11
- }
12
- div.DTFC_Blocker{
13
- background-color:white;
14
- }
15
- div.DTFC_LeftWrapper table.dataTable,
16
- div.DTFC_RightWrapper table.dataTable{
17
- margin-bottom:0;
18
- z-index:2;
19
- }
20
- div.DTFC_LeftWrapper table.dataTable.no-footer,
21
- div.DTFC_RightWrapper table.dataTable.no-footer{
22
- border-bottom:none;
23
- }
24
-
25
- /*############################
26
- * COMPARE
27
- #############################*/
28
-
29
- body {
30
- font-family: 'Open Sans', san-serif;
31
- font-size: 13px;
32
- line-height: 1.51em;
33
- color: #747373;
34
- background: none !important;
35
- margin: 0;
36
- }
37
-
38
- body h1 {
39
- background: #4F4F4F;
40
- color: #fff;
41
- font-weight: 800;
42
- padding: 10px;
43
- border-bottom: 2px solid #fff;
44
- display: block;
45
- text-transform: uppercase;
46
- font-size: 1.076em;
47
- margin: 0;
48
- text-align: center;
49
- }
50
-
51
- body #yith-woocompare {
52
- padding: 10px;
53
- }
54
-
55
- table.dataTable.compare-list thead th,
56
- table.dataTable.compare-list thead td,
57
- table.dataTable.compare-list tfoot td,
58
- table.dataTable.compare-list tfoot th {
59
- border: 0;
60
- vertical-align: middle;
61
- }
62
- .DTFC_LeftFootWrapper table.compare-list,
63
- .DTFC_LeftHeadWrapper table.compare-list {
64
- border: 0;
65
- }
66
-
67
- table.compare-list td {
68
- width: 220px;
69
- max-width: 220px;
70
- min-width: 220px;
71
- text-align: center;
72
- vertical-align: middle;
73
- }
74
-
75
- table.compare-list {
76
- width: 100%;
77
- border-bottom: 0;
78
- border-top: 0;
79
- margin: 0;
80
- table-layout: auto;
81
- }
82
-
83
- table.compare-list tbody th {
84
- width: 150px;
85
- max-width: 150px;
86
- min-width: 150px;
87
- overflow: hidden;
88
- text-align: left;
89
- color: #333333;
90
- background-color: #f2f2f2;
91
- text-transform: uppercase;
92
- font-weight: 700;
93
- font-size: 14px;
94
- }
95
-
96
- .rtl table.compare-list tbody th {
97
- text-align: right;
98
- }
99
-
100
- table.dataTable.compare-list tbody th,
101
- table.dataTable.compare-list tbody td {
102
- border-right: 1px solid #e7e7e7;
103
- border-top: 1px solid #e7e7e7;
104
- border-bottom: none;
105
- border-left: none;
106
- padding: 10px;
107
- vertical-align: middle;
108
- }
109
- table.dataTable.compare-list tbody tr:last-child th,
110
- table.dataTable.compare-list tbody tr:last-child td {
111
- border-bottom: 1px solid #e7e7e7;
112
- }
113
-
114
- table.compare-list tbody td.last-column {
115
- width: auto;
116
- border-right: 0;
117
- }
118
-
119
- table.compare-list tr.image td,
120
- table.compare-list tr.image th {
121
- border-top: 0;
122
- }
123
-
124
- #yith-woocompare-table_wrapper {
125
- margin: 10px 0;
126
- }
127
-
128
- table.dataTable.compare-list tbody .product_info td {
129
- vertical-align: top;
130
- }
131
-
132
- table.compare-list thead th a.close, h1 a.close {
133
- float: right;
134
- margin-right: 10px;
135
- font-weight: 600;
136
- font-size: 0.9em;
137
- color: #fff;
138
- text-decoration: none;
139
- }
140
-
141
- table.compare-list .remove td a {
142
- color: #747373;
143
- text-decoration: none;
144
- }
145
-
146
- table.compare-list .remove td a:hover {
147
- color: #333333;
148
- }
149
-
150
- table.compare-list .remove td a .remove {
151
- border-radius: 100% 100% 100% 100%;
152
- color: red;
153
- display: inline-block;
154
- font-size: 1em;
155
- font-weight: 600;
156
- height: 1em;
157
- line-height: 0.81em;
158
- text-align: center;
159
- text-decoration: none;
160
- width: 1em;
161
- }
162
-
163
- .yith-woocompare-widget ul.products-list a.remove {
164
- float: left;
165
- }
166
-
167
- table.compare-list .remove td a:hover .remove {
168
- background-color: red;
169
- color: #ffffff;
170
- }
171
-
172
- table.compare-list .add-to-cart td a {
173
- display: inline-block;
174
- margin: 10px 0;
175
- background-color: #4F4F4F;
176
- border: 0 none;
177
- color: #FFFFFF;
178
- font-weight: normal;
179
- line-height: normal;
180
- padding: 5px 20px;
181
- text-decoration: none;
182
- text-transform: uppercase;
183
- cursor: pointer;
184
- }
185
-
186
- table.compare-list .add-to-cart td a:hover {
187
- background: #868686;
188
- color: #fff;
189
- }
190
-
191
- table.compare-list .stock td span {
192
- color: #009900;
193
- }
194
-
195
- table.compare-list .stock td span.out-of-stock {
196
- color: #990000;
197
- }
198
-
199
- table.compare-list .price td {
200
- text-decoration: underline;
201
- }
202
-
203
- table.compare-list td.odd {
204
- background: #F7F7F7;
205
- }
206
-
207
- table.compare-list td.even {
208
- background: #fff;
209
- }
210
-
211
- table.compare-list td img {
212
- background: none repeat scroll 0 0 #FFFFFF;
213
- border: 1px solid #DADADA;
214
- height: auto;
215
- max-width: 100%;
216
- padding: 3px;
217
- margin-bottom: 20px;
218
- max-width: none;
219
}
1
+ /**
2
+ * The style of the woocommerce compare products
3
+ */
4
+
5
+ /* ###############
6
+ FIXED COLUMNS
7
+ ##############*/
8
+
9
+ table.DTFC_Cloned thead, table.DTFC_Cloned tfoot{
10
+ background-color:white;
11
+ }
12
+ div.DTFC_Blocker{
13
+ background-color:white;
14
+ }
15
+ div.DTFC_LeftWrapper table.dataTable,
16
+ div.DTFC_RightWrapper table.dataTable{
17
+ margin-bottom:0;
18
+ z-index:2;
19
+ }
20
+ div.DTFC_LeftWrapper table.dataTable.no-footer,
21
+ div.DTFC_RightWrapper table.dataTable.no-footer{
22
+ border-bottom:none;
23
+ }
24
+
25
+ /*############################
26
+ * COMPARE
27
+ #############################*/
28
+
29
+ body {
30
+ font-family: 'Open Sans', san-serif;
31
+ font-size: 13px;
32
+ line-height: 1.51em;
33
+ color: #747373;
34
+ background: none !important;
35
+ margin: 0;
36
+ }
37
+
38
+ body h1 {
39
+ background: #4F4F4F;
40
+ color: #fff;
41
+ font-weight: 800;
42
+ padding: 10px;
43
+ border-bottom: 2px solid #fff;
44
+ display: block;
45
+ text-transform: uppercase;
46
+ font-size: 1.076em;
47
+ margin: 0;
48
+ text-align: center;
49
+ }
50
+
51
+ body #yith-woocompare {
52
+ padding: 10px;
53
+ }
54
+
55
+ table.dataTable.compare-list thead th,
56
+ table.dataTable.compare-list thead td,
57
+ table.dataTable.compare-list tfoot td,
58
+ table.dataTable.compare-list tfoot th {
59
+ border: 0;
60
+ vertical-align: middle;
61
+ }
62
+ .DTFC_LeftFootWrapper table.compare-list,
63
+ .DTFC_LeftHeadWrapper table.compare-list {
64
+ border: 0;
65
+ }
66
+
67
+ table.compare-list td {
68
+ width: 220px;
69
+ max-width: 220px;
70
+ min-width: 220px;
71
+ text-align: center;
72
+ vertical-align: middle;
73
+ }
74
+
75
+ table.compare-list {
76
+ width: 100%;
77
+ border-bottom: 0;
78
+ border-top: 0;
79
+ margin: 0;
80
+ table-layout: auto;
81
+ }
82
+
83
+ table.compare-list tbody th {
84
+ width: 150px;
85
+ max-width: 150px;
86
+ min-width: 150px;
87
+ overflow: hidden;
88
+ text-align: left;
89
+ color: #333333;
90
+ background-color: #f2f2f2;
91
+ text-transform: uppercase;
92
+ font-weight: 700;
93
+ font-size: 14px;
94
+ }
95
+
96
+ .rtl table.compare-list tbody th {
97
+ text-align: right;
98
+ }
99
+
100
+ table.dataTable.compare-list tbody th,
101
+ table.dataTable.compare-list tbody td {
102
+ border-right: 1px solid #e7e7e7;
103
+ border-top: 1px solid #e7e7e7;
104
+ border-bottom: none;
105
+ border-left: none;
106
+ padding: 10px;
107
+ vertical-align: middle;
108
+ }
109
+ table.dataTable.compare-list tbody tr:last-child th,
110
+ table.dataTable.compare-list tbody tr:last-child td {
111
+ border-bottom: 1px solid #e7e7e7;
112
+ }
113
+
114
+ table.compare-list tbody td.last-column {
115
+ width: auto;
116
+ border-right: 0;
117
+ }
118
+
119
+ table.compare-list tr.image td,
120
+ table.compare-list tr.image th {
121
+ border-top: 0;
122
+ }
123
+
124
+ #yith-woocompare-table_wrapper {
125
+ margin: 10px 0;
126
+ }
127
+
128
+ table.dataTable.compare-list tbody .product_info td {
129
+ vertical-align: top;
130
+ }
131
+
132
+ table.compare-list thead th a.close, h1 a.close {
133
+ float: right;
134
+ margin-right: 10px;
135
+ font-weight: 600;
136
+ font-size: 0.9em;
137
+ color: #fff;
138
+ text-decoration: none;
139
+ }
140
+
141
+ table.compare-list .remove td a {
142
+ color: #747373;
143
+ text-decoration: none;
144
+ }
145
+
146
+ table.compare-list .remove td a:hover {
147
+ color: #333333;
148
+ }
149
+
150
+ table.compare-list .remove td a .remove {
151
+ border-radius: 100% 100% 100% 100%;
152
+ color: red;
153
+ display: inline-block;
154
+ font-size: 1em;
155
+ font-weight: 600;
156
+ height: 1em;
157
+ line-height: 0.81em;
158
+ text-align: center;
159
+ text-decoration: none;
160
+ width: 1em;
161
+ }
162
+
163
+ .yith-woocompare-widget ul.products-list a.remove {
164
+ float: left;
165
+ }
166
+
167
+ table.compare-list .remove td a:hover .remove {
168
+ background-color: red;
169
+ color: #ffffff;
170
+ }
171
+
172
+ table.compare-list .add-to-cart td a {
173
+ display: inline-block;
174
+ margin: 10px 0;
175
+ background-color: #4F4F4F;
176
+ border: 0 none;
177
+ color: #FFFFFF;
178
+ font-weight: normal;
179
+ line-height: normal;
180
+ padding: 5px 20px;
181
+ text-decoration: none;
182
+ text-transform: uppercase;
183
+ cursor: pointer;
184
+ }
185
+
186
+ table.compare-list .add-to-cart td a:hover {
187
+ background: #868686;
188
+ color: #fff;
189
+ }
190
+
191
+ table.compare-list .stock td span {
192
+ color: #009900;
193
+ }
194
+
195
+ table.compare-list .stock td span.out-of-stock {
196
+ color: #990000;
197
+ }
198
+
199
+ table.compare-list .price td {
200
+ text-decoration: underline;
201
+ }
202
+
203
+ table.compare-list td.odd {
204
+ background: #F7F7F7;
205
+ }
206
+
207
+ table.compare-list td.even {
208
+ background: #fff;
209
+ }
210
+
211
+ table.compare-list td img {
212
+ background: none repeat scroll 0 0 #FFFFFF;
213
+ border: 1px solid #DADADA;
214
+ height: auto;
215
+ max-width: 100%;
216
+ padding: 3px;
217
+ margin-bottom: 20px;
218
+ max-width: none;
219
}
assets/css/widget.css CHANGED
@@ -1,65 +1,65 @@
1
- .yith-woocompare-widget ul.products-list {
2
- list-style: none;
3
- margin: 0 0 15px;
4
- }
5
-
6
- .yith-woocompare-widget ul.products-list li:not( .list_empty ) {
7
- position: relative;
8
- padding: 5px 0 5px 30px;
9
- border-bottom: 1px solid #dfdfdf;
10
- }
11
-
12
- .yith-woocompare-widget ul.products-list li .remove {
13
- position: absolute;
14
- left: 3px;
15
- color: #ff0000;
16
- font-weight: 400;
17
- font-size: 1.2em;
18
- line-height: 1.2;
19
- height: 1.2em;
20
- width: 1.2em;
21
- border-radius: 50%;
22
- text-align: center;
23
- cursor: pointer;
24
- outline: none;
25
- }
26
-
27
- .yith-woocompare-widget ul.products-list li .remove:hover {
28
- background-color: #ff0000;
29
- color: #ffffff;
30
- }
31
-
32
- .yith-woocompare-widget ul.products-list li .title {
33
- cursor: pointer;
34
- text-transform: uppercase;
35
- font-size: 12px;
36
- font-weight: 400;
37
- display: block;
38
- outline: none;
39
- }
40
-
41
- .yith-woocompare-widget a.compare {
42
- float: right;
43
- float: right;
44
- line-height: 1;
45
- cursor: pointer;
46
- padding: 8px 10px;
47
- font-size: 13px;
48
- text-transform: uppercase;
49
- font-weight: 700;
50
- border-radius: 3px;
51
- border: 0;
52
- white-space: nowrap;
53
- display: inline-block;
54
- color: #ffffff;
55
- background-color: #b2b2b2;
56
- }
57
-
58
- .yith-woocompare-widget a.compare:hover {
59
- background-color: #303030;
60
- }
61
-
62
- .yith-woocompare-widget a.clear-all {
63
- outline: none;
64
- font-size: 12px;
65
}
1
+ .yith-woocompare-widget ul.products-list {
2
+ list-style: none;
3
+ margin: 0 0 15px;
4
+ }
5
+
6
+ .yith-woocompare-widget ul.products-list li:not( .list_empty ) {
7
+ position: relative;
8
+ padding: 5px 0 5px 30px;
9
+ border-bottom: 1px solid #dfdfdf;
10
+ }
11
+
12
+ .yith-woocompare-widget ul.products-list li .remove {
13
+ position: absolute;
14
+ left: 3px;
15
+ color: #ff0000;
16
+ font-weight: 400;
17
+ font-size: 1.2em;
18
+ line-height: 1.2;
19
+ height: 1.2em;
20
+ width: 1.2em;
21
+ border-radius: 50%;
22
+ text-align: center;
23
+ cursor: pointer;
24
+ outline: none;
25
+ }
26
+
27
+ .yith-woocompare-widget ul.products-list li .remove:hover {
28
+ background-color: #ff0000;
29
+ color: #ffffff;
30
+ }
31
+
32
+ .yith-woocompare-widget ul.products-list li .title {
33
+ cursor: pointer;
34
+ text-transform: uppercase;
35
+ font-size: 12px;
36
+ font-weight: 400;
37
+ display: block;
38
+ outline: none;
39
+ }
40
+
41
+ .yith-woocompare-widget a.compare {
42
+ float: right;
43
+ float: right;
44
+ line-height: 1;
45
+ cursor: pointer;
46
+ padding: 8px 10px;
47
+ font-size: 13px;
48
+ text-transform: uppercase;
49
+ font-weight: 700;
50
+ border-radius: 3px;
51
+ border: 0;
52
+ white-space: nowrap;
53
+ display: inline-block;
54
+ color: #ffffff;
55
+ background-color: #b2b2b2;
56
+ }
57
+
58
+ .yith-woocompare-widget a.compare:hover {
59
+ background-color: #303030;
60
+ }
61
+
62
+ .yith-woocompare-widget a.clear-all {
63
+ outline: none;
64
+ font-size: 12px;
65
}
assets/js/woocompare-admin.js CHANGED
@@ -1,19 +1,19 @@
1
- jQuery(document).ready(function($) {
2
-
3
- $( ".attributes .fields" ).sortable({
4
- cursor: "move",
5
- scrollSensitivity: 10,
6
- tolerance: "pointer",
7
- axis: "y",
8
- stop: function(event, ui) {
9
- var list = ui.item.parents('.fields'),
10
- fields = new Array();
11
- $('input[type="checkbox"]', list).each(function(i){
12
- fields[i] = $(this).val();
13
- });
14
-
15
- list.next().val( fields.join(',') );
16
- }
17
- });
18
-
19
});
1
+ jQuery(document).ready(function($) {
2
+
3
+ $( ".attributes .fields" ).sortable({
4
+ cursor: "move",
5
+ scrollSensitivity: 10,
6
+ tolerance: "pointer",
7
+ axis: "y",
8
+ stop: function(event, ui) {
9
+ var list = ui.item.parents('.fields'),
10
+ fields = new Array();
11
+ $('input[type="checkbox"]', list).each(function(i){
12
+ fields[i] = $(this).val();
13
+ });
14
+
15
+ list.next().val( fields.join(',') );
16
+ }
17
+ });
18
+
19
});
includes/class.yith-woocompare-admin.php CHANGED
@@ -1,476 +1,476 @@
1
- <?php
2
- /**
3
- * Admin class
4
- *
5
- * @author YITH
6
- * @package YITH WooCommerce Compare
7
- * @version 2.0.0
8
- */
9
-
10
- if ( ! defined( 'YITH_WOOCOMPARE' ) ) {
11
- exit;
12
- } // Exit if accessed directly
13
-
14
- if ( ! class_exists( 'YITH_Woocompare_Admin' ) ) {
15
- /**
16
- * Admin class.
17
- * The class manage all the admin behaviors.
18
- *
19
- * @since 1.0.0
20
- */
21
- class YITH_Woocompare_Admin {
22
-
23
-
24
- /**
25
- * Plugin options
26
- *
27
- * @var array
28
- * @access public
29
- * @since 1.0.0
30
- */
31
- public $options = array();
32
-
33
- /**
34
- * Plugin version
35
- *
36
- * @var string
37
- * @since 1.0.0
38
- */
39
- public $version = YITH_WOOCOMPARE_VERSION;
40
-
41
- /**
42
- * @var $_panel Panel Object
43
- */
44
- protected $_panel;
45
-
46
- /**
47
- * @var $_premium string Premium tab template file name
48
- */
49
- protected $_premium = 'premium.php';
50
-
51
- /**
52
- * @var string Premium version landing link
53
- */
54
- protected $_premium_landing = 'https://yithemes.com/themes/plugins/yith-woocommerce-compare';
55
-
56
- /**
57
- * @var string Compare panel page
58
- */
59
- protected $_panel_page = 'yith_woocompare_panel';
60
-
61
- /**
62
- * Various links
63
- *
64
- * @var string
65
- * @access public
66
- * @since 1.0.0
67
- */
68
- public $doc_url = 'http://yithemes.com/docs-plugins/yith-woocommerce-compare/';
69
-
70
- /**
71
- * Constructor
72
- *
73
- * @access public
74
- * @since 1.0.0
75
- */
76
- public function __construct() {
77
-
78
- add_action( 'admin_menu', array( $this, 'register_panel' ), 5) ;
79
-
80
- //Add action links
81
- add_filter( 'plugin_action_links_' . plugin_basename( YITH_WOOCOMPARE_DIR . '/' . basename( YITH_WOOCOMPARE_FILE ) ), array( $this, 'action_links' ) );
82
- add_filter( 'yith_show_plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 5 );
83
-
84
- add_action( 'yith_woocompare_premium', array( $this, 'premium_tab' ) );
85
-
86
- add_action( 'admin_init', array( $this, 'register_pointer' ) );
87
- add_action( 'admin_init', array( $this, 'default_options'), 99 );
88
-
89
- add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles_scripts' ), 20 );
90
-
91
- add_action( 'woocommerce_admin_field_woocompare_image_width', array( $this, 'admin_fields_woocompare_image_width' ) );
92
- add_action( 'woocommerce_admin_field_woocompare_attributes', array( $this, 'admin_fields_attributes' ), 10, 1 );
93
- if( version_compare( preg_replace( '/-beta-([0-9]+)/', '', WC()->version ), '2.4', '<' ) ) {
94
- add_action( 'woocommerce_update_option_woocompare_attributes', array( $this, 'admin_update_custom_option_pre_24' ), 10, 1 );
95
- }
96
- else {
97
- add_filter( 'woocommerce_admin_settings_sanitize_option_yith_woocompare_fields_attrs', array( $this, 'admin_update_custom_option' ), 10, 3 );
98
- }
99
-
100
- // YITH WCWL Loaded
101
- do_action( 'yith_woocompare_loaded' );
102
- }
103
-
104
- /**
105
- * Action Links
106
- *
107
- * add the action links to plugin admin page
108
- *
109
- * @param $links | links plugin array
110
- *
111
- * @return mixed Array
112
- * @since 1.0
113
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
114
- * @return mixed
115
- * @use plugin_action_links_{$plugin_file_name}
116
- */
117
- public function action_links( $links ) {
118
-
119
- $links[] = '<a href="' . admin_url( "admin.php?page={$this->_panel_page}" ) . '">' . __( 'Settings', 'yith-woocommerce-compare' ) . '</a>';
120
- if ( defined( 'YITH_WOOCOMPARE_PREMIUM' ) && YITH_WOOCOMPARE_PREMIUM ) {
121
- $links[] = '<a href="' . YIT_Plugin_Licence()->get_license_activation_url() . '" target="_blank">' . __( 'License', 'yith-woocommerce-compare' ) . '</a>';
122
- }
123
-
124
- return $links;
125
- }
126
-
127
- /**
128
- * Add a panel under YITH Plugins tab
129
- *
130
- * @return void
131
- * @since 1.0
132
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
133
- * @use /Yit_Plugin_Panel class
134
- * @see plugin-fw/lib/yit-plugin-panel.php
135
- */
136
- public function register_panel() {
137
-
138
- if ( ! empty( $this->_panel ) ) {
139
- return;
140
- }
141
-
142
- $admin_tabs = array(
143
- 'general' => __( 'Settings', 'yith-woocommerce-compare' ),
144
- );
145
-
146
- if ( ! ( defined( 'YITH_WOOCOMPARE_PREMIUM' ) && YITH_WOOCOMPARE_PREMIUM ) ) {
147
- $admin_tabs['premium'] = __( 'Premium Version', 'yith-woocommerce-compare' );
148
- }
149
-
150
- $args = array(
151
- 'create_menu_page' => true,
152
- 'parent_slug' => '',
153
- 'page_title' => _x( 'Compare', 'Admin Plugin Name', 'yith-woocommerce-compare' ),
154
- 'menu_title' => _x( 'Compare', 'Admin Plugin Name', 'yith-woocommerce-compare' ),
155
- 'capability' => 'manage_options',
156
- 'parent' => '',
157
- 'parent_page' => 'yith_plugin_panel',
158
- 'page' => $this->_panel_page,
159
- 'admin-tabs' => apply_filters( 'yith_woocompare_admin_tabs', $admin_tabs ),
160
- 'options-path' => YITH_WOOCOMPARE_DIR . '/plugin-options'
161
- );
162
-
163
-
164
- /* === Fixed: not updated theme === */
165
- if ( ! class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
166
- require_once( YITH_WOOCOMPARE_DIR . 'plugin-fw/lib/yit-plugin-panel-wc.php' );
167
- }
168
-
169
- $this->_panel = new YIT_Plugin_Panel_WooCommerce( $args );
170
- $this->options = $this->_panel->get_main_array_options();
171
- }
172
-
173
- /**
174
- * Set default custom options
175
- *
176
- */
177
- public function default_options() {
178
- $this->_default_options();
179
- }
180
-
181
- /**
182
- * Premium Tab Template
183
- *
184
- * Load the premium tab template on admin page
185
- *
186
- * @return void
187
- * @since 1.0
188
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
189
- * @return void
190
- */
191
- public function premium_tab() {
192
- $premium_tab_template = YITH_WOOCOMPARE_TEMPLATE_PATH . '/admin/' . $this->_premium;
193
- if ( file_exists( $premium_tab_template ) ) {
194
- include_once( $premium_tab_template );
195
- }
196
-
197
- }
198
-
199
- /**
200
- * plugin_row_meta
201
- *
202
- * add the action links to plugin admin page
203
- *
204
- * @param $plugin_meta
205
- * @param $plugin_file
206
- * @param $plugin_data
207
- * @param $status
208
- *
209
- * @return Array
210
- * @since 1.0
211
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
212
- * @use plugin_row_meta
213
- */
214
- public function plugin_row_meta( $new_row_meta_args, $plugin_meta, $plugin_file, $plugin_data, $status ) {
215
-
216
- if ( defined( 'YITH_WOOCOMPARE_INIT' ) && YITH_WOOCOMPARE_INIT == $plugin_file ) {
217
- $new_row_meta_args['slug'] = YITH_WOOCOMPARE_SLUG;
218
-
219
- if( defined( 'YITH_WOOCOMPARE_PREMIUM' ) ){
220
- $new_row_meta_args['is_premium'] = true;
221
- }
222
- }
223
-
224
- return $new_row_meta_args;
225
- }
226
-
227
- /**
228
- * Register Pointer
229
- */
230
- public function register_pointer(){
231
-
232
- if( ! class_exists( 'YIT_Pointers' ) ){
233
- include_once( 'plugin-fw/lib/yit-pointers.php' );
234
- }
235
-
236
- $args[] = array(
237
- 'screen_id' => 'plugins',
238
- 'pointer_id' => 'yith_woocompare_panel',
239
- 'target' => '#toplevel_page_yit_plugin_panel',
240
- 'content' => sprintf( '<h3> %s </h3> <p> %s </p>',
241
- __( 'YITH WooCommerce Compare Activated', 'yith-woocommerce-compare' ),
242
- apply_filters( 'yith_woocompare_activated_pointer_content', sprintf( __( 'In the YIT Plugin tab you can find the YITH WooCommerce Compare options. With this menu, you can access to all the settings of our plugins that you have activated. YITH WooCommerce Compare is available in an outstanding PREMIUM version with many new options, <a href="%s">discover it now</a>.', 'yith-woocommerce-compare' ), $this->get_premium_landing_uri() ) )
243
- ),
244
- 'position' => array( 'edge' => 'left', 'align' => 'center' ),
245
- 'init' => YITH_WOOCOMPARE_INIT
246
- );
247
-
248
- $args[] = array(
249
- 'screen_id' => 'update',
250
- 'pointer_id' => 'yith_woocompare_panel',
251
- 'target' => '#toplevel_page_yit_plugin_panel',
252
- 'content' => sprintf( '<h3> %s </h3> <p> %s </p>',
253
- __( 'YITH WooCommerce Compare Updated', 'yith-woocommerce-compare' ),
254
- apply_filters( 'yith_woocompare_updated_pointer_content', sprintf( __( 'From now on, you can find all the options of YITH WooCommerce Compare under YIT Plugin -> Compare instead of WooCommerce -> Settings -> Compare, as in the previous version. When one of our plugins is updated, a new voice will be added to this menu. YITH WooCommerce Compare has been updated with new available options, <a href="%s">discover the PREMIUM version.</a>', 'yith-woocommerce-compare' ), $this->get_premium_landing_uri() ) )
255
- ),
256
- 'position' => array( 'edge' => 'left', 'align' => 'center' ),
257
- 'init' => YITH_WOOCOMPARE_INIT
258
- );
259
-
260
- YIT_Pointers()->register( $args );
261
- }
262
-
263
- /**
264
- * Get the premium landing uri
265
- *
266
- * @since 1.0.0
267
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
268
- * @return string The premium landing link
269
- */
270
- public function get_premium_landing_uri() {
271
- return defined( 'YITH_REFER_ID' ) ? $this->_premium_landing . '?refer_id=' . YITH_REFER_ID : $this->_premium_landing.'?refer_id=1030585';
272
- }
273
-
274
- /**
275
- * Default options
276
- *
277
- * Sets up the default options used on the settings page
278
- *
279
- * @access protected
280
- * @return void
281
- * @since 1.0.0
282
- */
283
- protected function _default_options() {
284
-
285
- foreach ( $this->options as $section ) {
286
-
287
- foreach ( $section as $value ) {
288
-
289
- if ( isset( $value['std'] ) && isset( $value['id'] ) ) {
290
-
291
- if ( $value['type'] == 'image_width' ) {
292
- add_option( $value['id'], $value['std'] );
293
- } elseif ( $value['type'] == 'woocompare_attributes' ) {
294
-
295
- $value_id = str_replace( '_attrs', '', $value['id'] );
296
-
297
- $in_db = get_option( $value_id );
298
- $in_db_original = get_option( $value['id'] );
299
-
300
- // if options is already in db and not reset defaults continue
301
- if ( $in_db && $in_db_original != 'all' ) {
302
- continue;
303
- }
304
-
305
- if ( $value['default'] == 'all' ) {
306
- $fields = YITH_Woocompare_Helper::standard_fields();
307
- $all = array();
308
-
309
- foreach ( array_keys( $fields ) as $field ) {
310
- $all[ $field ] = true;
311
- }
312
-
313
- update_option( $value_id, $all );
314
- } else {
315
- update_option( $value_id, $value['std'] );
316
- }
317
- }
318
- }
319
- }
320
- }
321
- }
322
-
323
- /**
324
- * Create new Woocommerce admin field: checkboxes
325
- *
326
- * @access public
327
- * @param array $value
328
- * @return void
329
- * @since 1.0.0
330
- */
331
- public function admin_fields_attributes( $value ) {
332
- $fields = YITH_Woocompare_Helper::standard_fields();
333
- $all = array();
334
- $checked = get_option( str_replace( '_attrs', '', $value['id'] ), $value['default'] == 'all' ? $all : array() );
335
-
336
- foreach ( array_keys( $fields ) as $field ) {
337
- $all[ $field ] = true;
338
- }
339
- // then add fields that are not still saved
340
- foreach ( $checked as $k => $v ) {
341
- unset( $all[ $k ] );
342
- }
343
- $checkboxes = array_merge( $checked, $all );
344
-
345
-
346
- ?>
347
- <tr valign="top">
348
- <th scope="row" class="titledesc">
349
- <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo $value['name']; ?></label>
350
- </th>
351
-
352
- <td class="forminp attributes">
353
- <p class="description"><?php echo $value['desc'] ?></p>
354
- <ul class="fields">
355
- <?php foreach ( $checkboxes as $slug => $checked ) :
356
- if( ! isset( $fields[ $slug ] ) )
357
- continue;
358
- ?>
359
- <li>
360
- <label>
361
- <input type="checkbox" name="<?php echo $value['id'] ?>[]" id="<?php echo $value['id'] ?>_<?php echo $slug ?>" value="<?php echo $slug ?>"<?php checked( $checked ) ?> /> <?php echo $fields[ $slug ] ?>
362
- </label>
363
- </li>
364
- <?php
365
- endforeach;
366
- ?>
367
- </ul>
368
- <input type="hidden" name="<?php echo $value['id'] ?>_positions" value="<?php echo implode( ',', array_keys( $checkboxes ) ) ?>" />
369
- </td>
370
- </tr>
371
- <?php
372
- }
373
-
374
- /**
375
- * Create new Woocommerce admin field: yit_wc_image_width
376
- *
377
- * @access public
378
- * @param array $value
379
- * @return void
380
- * @since 1.0.0
381
- */
382
- public function admin_fields_woocompare_image_width( $value ) {
383
-
384
- $width = WC_Admin_Settings::get_option( $value['id'] . '[width]', $value['default']['width'] );
385
- $height = WC_Admin_Settings::get_option( $value['id'] . '[height]', $value['default']['height'] );
386
- $crop = WC_Admin_Settings::get_option( $value['id'] . '[crop]' );
387
- $crop = ( $crop == 'on' || $crop == '1' ) ? 1 : 0;
388
- $crop = checked( 1, $crop, false );
389
-
390
- ?>
391
- <tr valign="top">
392
- <th scope="row" class="titledesc"><?php echo esc_html( $value['title'] ) ?></th>
393
- <td class="forminp image_width_settings">
394
-
395
- <input name="<?php echo esc_attr( $value['id'] ); ?>[width]" id="<?php echo esc_attr( $value['id'] ); ?>-width" type="text" size="3" value="<?php echo $width; ?>" /> &times;
396
- <input name="<?php echo esc_attr( $value['id'] ); ?>[height]" id="<?php echo esc_attr( $value['id'] ); ?>-height" type="text" size="3" value="<?php echo $height; ?>" />px
397
-
398
- <label><input name="<?php echo esc_attr( $value['id'] ); ?>[crop]" id="<?php echo esc_attr( $value['id'] ); ?>-crop" type="checkbox" <?php echo $crop; ?> /> <?php _e( 'Do you want to hard crop the image?', 'yith-woocommerce-compare' ); ?>
399
- </label>
400
- <p class="description"><?php echo $value['desc'] ?></p>
401
-
402
- </td>
403
- </tr><?php
404
-
405
- }
406
-
407
- /**
408
- * Save the admin field: slider
409
- *
410
- * @access public
411
- * @param mixed $value
412
- * @param mixed $option
413
- * @param mixed $raw_value
414
- * @return mixed
415
- * @since 1.0.0
416
- */
417
- public function admin_update_custom_option( $value, $option, $raw_value ) {
418
-
419
- $val = array();
420
- $checked_fields = isset( $_POST[ $option['id'] ] ) ? maybe_unserialize( $_POST[ $option['id'] ] ) : array();
421
- $fields = array_map( 'trim', explode( ',', $_POST[ $option['id'] . '_positions' ] ) );
422
-
423
- foreach ( $fields as $field ) {
424
- $val[ $field ] = in_array( $field, $checked_fields );
425
- }
426
-
427
- update_option( str_replace( '_attrs', '', $option['id'] ), $val );
428
-
429
- return $value;
430
- }
431
-
432
- /**
433
- * Save the admin field: slider
434
- *
435
- * @access public
436
- * @param mixed $value
437
- * @return void
438
- * @since 1.0.0
439
- */
440
- public function admin_update_custom_option_pre_24( $value ) {
441
-
442
- $val = array();
443
- $checked_fields = isset( $_POST[ $value['id'] ] ) ? $_POST[ $value['id'] ] : array();
444
- $fields = array_map( 'trim', explode( ',', $_POST[ $value['id'] . '_positions' ] ) );
445
-
446
- foreach ( $fields as $field ) {
447
- $val[ $field ] = in_array( $field, $checked_fields );
448
- }
449
-
450
- update_option( str_replace( '_attrs', '', $value['id'] ), $val );
451
- }
452
-
453
- /**
454
- * Enqueue admin styles and scripts
455
- *
456
- * @access public
457
- * @return void
458
- * @since 1.0.0
459
- */
460
- public function enqueue_styles_scripts() {
461
-
462
- if ( isset( $_GET['page'] ) && $_GET['page'] == 'yith_woocompare_panel' ) {
463
- wp_enqueue_script( 'jquery-ui' );
464
- wp_enqueue_script( 'jquery-ui-core' );
465
- wp_enqueue_script( 'jquery-ui-mouse' );
466
- wp_enqueue_script( 'jquery-ui-slider' );
467
- wp_enqueue_script( 'jquery-ui-sortable' );
468
-
469
- wp_enqueue_style( 'yith_woocompare_admin', YITH_WOOCOMPARE_URL . 'assets/css/admin.css' );
470
- wp_enqueue_script( 'yith_woocompare', YITH_WOOCOMPARE_URL . 'assets/js/woocompare-admin.js', array( 'jquery', 'jquery-ui-sortable' ) );
471
- }
472
-
473
- do_action( 'yith_woocompare_enqueue_styles_scripts' );
474
- }
475
- }
476
- }
1
+ <?php
2
+ /**
3
+ * Admin class
4
+ *
5
+ * @author YITH
6
+ * @package YITH WooCommerce Compare
7
+ * @version 2.0.0
8
+ */
9
+
10
+ if ( ! defined( 'YITH_WOOCOMPARE' ) ) {
11
+ exit;
12
+ } // Exit if accessed directly
13
+
14
+ if ( ! class_exists( 'YITH_Woocompare_Admin' ) ) {
15
+ /**
16
+ * Admin class.
17
+ * The class manage all the admin behaviors.
18
+ *
19
+ * @since 1.0.0
20
+ */
21
+ class YITH_Woocompare_Admin {
22
+
23
+
24
+ /**
25
+ * Plugin options
26
+ *
27
+ * @var array
28
+ * @access public
29
+ * @since 1.0.0
30
+ */
31
+ public $options = array();
32
+
33
+ /**
34
+ * Plugin version
35
+ *
36
+ * @var string
37
+ * @since 1.0.0
38
+ */
39
+ public $version = YITH_WOOCOMPARE_VERSION;
40
+
41
+ /**
42
+ * @var $_panel Panel Object
43
+ */
44
+ protected $_panel;
45
+
46
+ /**
47
+ * @var $_premium string Premium tab template file name
48
+ */
49
+ protected $_premium = 'premium.php';
50
+
51
+ /**
52
+ * @var string Premium version landing link
53
+ */
54
+ protected $_premium_landing = 'https://yithemes.com/themes/plugins/yith-woocommerce-compare';
55
+
56
+ /**
57
+ * @var string Compare panel page
58
+ */
59
+ protected $_panel_page = 'yith_woocompare_panel';
60
+
61
+ /**
62
+ * Various links
63
+ *
64
+ * @var string
65
+ * @access public
66
+ * @since 1.0.0
67
+ */
68
+ public $doc_url = 'http://yithemes.com/docs-plugins/yith-woocommerce-compare/';
69
+
70
+ /**
71
+ * Constructor
72
+ *
73
+ * @access public
74
+ * @since 1.0.0
75
+ */
76
+ public function __construct() {
77
+
78
+ add_action( 'admin_menu', array( $this, 'register_panel' ), 5) ;
79
+
80
+ //Add action links
81
+ add_filter( 'plugin_action_links_' . plugin_basename( YITH_WOOCOMPARE_DIR . '/' . basename( YITH_WOOCOMPARE_FILE ) ), array( $this, 'action_links' ) );
82
+ add_filter( 'yith_show_plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 5 );
83
+
84
+ add_action( 'yith_woocompare_premium', array( $this, 'premium_tab' ) );
85
+
86
+ add_action( 'admin_init', array( $this, 'register_pointer' ) );
87
+ add_action( 'admin_init', array( $this, 'default_options'), 99 );
88
+
89
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles_scripts' ), 20 );
90
+
91
+ add_action( 'woocommerce_admin_field_woocompare_image_width', array( $this, 'admin_fields_woocompare_image_width' ) );
92
+ add_action( 'woocommerce_admin_field_woocompare_attributes', array( $this, 'admin_fields_attributes' ), 10, 1 );
93
+ if( version_compare( preg_replace( '/-beta-([0-9]+)/', '', WC()->version ), '2.4', '<' ) ) {
94
+ add_action( 'woocommerce_update_option_woocompare_attributes', array( $this, 'admin_update_custom_option_pre_24' ), 10, 1 );
95
+ }
96
+ else {
97
+ add_filter( 'woocommerce_admin_settings_sanitize_option_yith_woocompare_fields_attrs', array( $this, 'admin_update_custom_option' ), 10, 3 );
98
+ }
99
+
100
+ // YITH WCWL Loaded
101
+ do_action( 'yith_woocompare_loaded' );
102
+ }
103
+
104
+ /**
105
+ * Action Links
106
+ *
107
+ * add the action links to plugin admin page
108
+ *
109
+ * @param $links | links plugin array
110
+ *
111
+ * @return mixed Array
112
+ * @since 1.0
113
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
114
+ * @return mixed
115
+ * @use plugin_action_links_{$plugin_file_name}
116
+ */
117
+ public function action_links( $links ) {
118
+
119
+ $links[] = '<a href="' . admin_url( "admin.php?page={$this->_panel_page}" ) . '">' . __( 'Settings', 'yith-woocommerce-compare' ) . '</a>';
120
+ if ( defined( 'YITH_WOOCOMPARE_PREMIUM' ) && YITH_WOOCOMPARE_PREMIUM ) {
121
+ $links[] = '<a href="' . YIT_Plugin_Licence()->get_license_activation_url() . '" target="_blank">' . __( 'License', 'yith-woocommerce-compare' ) . '</a>';
122
+ }
123
+
124
+ return $links;
125
+ }
126
+
127
+ /**
128
+ * Add a panel under YITH Plugins tab
129
+ *
130
+ * @return void
131
+ * @since 1.0
132
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
133
+ * @use /Yit_Plugin_Panel class
134
+ * @see plugin-fw/lib/yit-plugin-panel.php
135
+ */
136
+ public function register_panel() {
137
+
138
+ if ( ! empty( $this->_panel ) ) {
139
+ return;
140
+ }
141
+
142
+ $admin_tabs = array(
143
+ 'general' => __( 'Settings', 'yith-woocommerce-compare' ),
144
+ );
145
+
146
+ if ( ! ( defined( 'YITH_WOOCOMPARE_PREMIUM' ) && YITH_WOOCOMPARE_PREMIUM ) ) {
147
+ $admin_tabs['premium'] = __( 'Premium Version', 'yith-woocommerce-compare' );
148
+ }
149
+
150
+ $args = array(
151
+ 'create_menu_page' => true,
152
+ 'parent_slug' => '',
153
+ 'page_title' => _x( 'Compare', 'Admin Plugin Name', 'yith-woocommerce-compare' ),
154
+ 'menu_title' => _x( 'Compare', 'Admin Plugin Name', 'yith-woocommerce-compare' ),
155
+ 'capability' => 'manage_options',
156
+ 'parent' => '',
157
+ 'parent_page' => 'yith_plugin_panel',
158
+ 'page' => $this->_panel_page,
159
+ 'admin-tabs' => apply_filters( 'yith_woocompare_admin_tabs', $admin_tabs ),
160
+ 'options-path' => YITH_WOOCOMPARE_DIR . '/plugin-options'
161
+ );
162
+
163
+
164
+ /* === Fixed: not updated theme === */
165
+ if ( ! class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
166
+ require_once( YITH_WOOCOMPARE_DIR . 'plugin-fw/lib/yit-plugin-panel-wc.php' );
167
+ }
168
+
169
+ $this->_panel = new YIT_Plugin_Panel_WooCommerce( $args );
170
+ $this->options = $this->_panel->get_main_array_options();
171
+ }
172
+
173
+ /**
174
+ * Set default custom options
175
+ *
176
+ */
177
+ public function default_options() {
178
+ $this->_default_options();
179
+ }
180
+
181
+ /**
182
+ * Premium Tab Template
183
+ *
184
+ * Load the premium tab template on admin page
185
+ *
186
+ * @return void
187
+ * @since 1.0
188
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
189
+ * @return void
190
+ */
191
+ public function premium_tab() {
192
+ $premium_tab_template = YITH_WOOCOMPARE_TEMPLATE_PATH . '/admin/' . $this->_premium;
193
+ if ( file_exists( $premium_tab_template ) ) {
194
+ include_once( $premium_tab_template );
195
+ }
196
+
197
+ }
198
+
199
+ /**
200
+ * plugin_row_meta
201
+ *
202
+ * add the action links to plugin admin page
203
+ *
204
+ * @param $plugin_meta
205
+ * @param $plugin_file
206
+ * @param $plugin_data
207
+ * @param $status
208
+ *
209
+ * @return Array
210
+ * @since 1.0
211
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
212
+ * @use plugin_row_meta
213
+ */
214
+ public function plugin_row_meta( $new_row_meta_args, $plugin_meta, $plugin_file, $plugin_data, $status ) {
215
+
216
+ if ( defined( 'YITH_WOOCOMPARE_INIT' ) && YITH_WOOCOMPARE_INIT == $plugin_file ) {
217
+ $new_row_meta_args['slug'] = YITH_WOOCOMPARE_SLUG;
218
+
219
+ if( defined( 'YITH_WOOCOMPARE_PREMIUM' ) ){
220
+ $new_row_meta_args['is_premium'] = true;
221
+ }
222
+ }
223
+
224
+ return $new_row_meta_args;
225
+ }
226
+
227
+ /**
228
+ * Register Pointer
229
+ */
230
+ public function register_pointer(){
231
+
232
+ if( ! class_exists( 'YIT_Pointers' ) ){
233
+ include_once( 'plugin-fw/lib/yit-pointers.php' );
234
+ }
235
+
236
+ $args[] = array(
237
+ 'screen_id' => 'plugins',
238
+ 'pointer_id' => 'yith_woocompare_panel',
239
+ 'target' => '#toplevel_page_yit_plugin_panel',
240
+ 'content' => sprintf( '<h3> %s </h3> <p> %s </p>',
241
+ __( 'YITH WooCommerce Compare Activated', 'yith-woocommerce-compare' ),
242
+ apply_filters( 'yith_woocompare_activated_pointer_content', sprintf( __( 'In the YIT Plugin tab you can find the YITH WooCommerce Compare options. With this menu, you can access to all the settings of our plugins that you have activated. YITH WooCommerce Compare is available in an outstanding PREMIUM version with many new options, <a href="%s">discover it now</a>.', 'yith-woocommerce-compare' ), $this->get_premium_landing_uri() ) )
243
+ ),
244
+ 'position' => array( 'edge' => 'left', 'align' => 'center' ),
245
+ 'init' => YITH_WOOCOMPARE_INIT
246
+ );
247
+
248
+ $args[] = array(
249
+ 'screen_id' => 'update',
250
+ 'pointer_id' => 'yith_woocompare_panel',
251
+ 'target' => '#toplevel_page_yit_plugin_panel',
252
+ 'content' => sprintf( '<h3> %s </h3> <p> %s </p>',
253
+ __( 'YITH WooCommerce Compare Updated', 'yith-woocommerce-compare' ),
254
+ apply_filters( 'yith_woocompare_updated_pointer_content', sprintf( __( 'From now on, you can find all the options of YITH WooCommerce Compare under YIT Plugin -> Compare instead of WooCommerce -> Settings -> Compare, as in the previous version. When one of our plugins is updated, a new voice will be added to this menu. YITH WooCommerce Compare has been updated with new available options, <a href="%s">discover the PREMIUM version.</a>', 'yith-woocommerce-compare' ), $this->get_premium_landing_uri() ) )
255
+ ),
256
+ 'position' => array( 'edge' => 'left', 'align' => 'center' ),
257
+ 'init' => YITH_WOOCOMPARE_INIT
258
+ );
259
+
260
+ YIT_Pointers()->register( $args );
261
+ }
262
+
263
+ /**
264
+ * Get the premium landing uri
265
+ *
266
+ * @since 1.0.0
267
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
268
+ * @return string The premium landing link
269
+ */
270
+ public function get_premium_landing_uri() {
271
+ return defined( 'YITH_REFER_ID' ) ? $this->_premium_landing . '?refer_id=' . YITH_REFER_ID : $this->_premium_landing.'?refer_id=1030585';
272
+ }
273
+
274
+ /**
275
+ * Default options
276
+ *
277
+ * Sets up the default options used on the settings page
278
+ *
279
+ * @access protected
280
+ * @return void
281
+ * @since 1.0.0
282
+ */
283
+ protected function _default_options() {
284
+
285
+ foreach ( $this->options as $section ) {
286
+
287
+ foreach ( $section as $value ) {
288
+
289
+ if ( isset( $value['std'] ) && isset( $value['id'] ) ) {
290
+
291
+ if ( $value['type'] == 'image_width' ) {
292
+ add_option( $value['id'], $value['std'] );
293
+ } elseif ( $value['type'] == 'woocompare_attributes' ) {
294
+
295
+ $value_id = str_replace( '_attrs', '', $value['id'] );
296
+
297
+ $in_db = get_option( $value_id );
298
+ $in_db_original = get_option( $value['id'] );
299
+
300
+ // if options is already in db and not reset defaults continue
301
+ if ( $in_db && $in_db_original != 'all' ) {
302
+ continue;
303
+ }
304
+
305
+ if ( $value['default'] == 'all' ) {
306
+ $fields = YITH_Woocompare_Helper::standard_fields();
307
+ $all = array();
308
+
309
+ foreach ( array_keys( $fields ) as $field ) {
310
+ $all[ $field ] = true;
311
+ }
312
+
313
+ update_option( $value_id, $all );
314
+ } else {
315
+ update_option( $value_id, $value['std'] );
316
+ }
317
+ }
318
+ }
319
+ }
320
+ }
321
+ }
322
+
323
+ /**
324
+ * Create new Woocommerce admin field: checkboxes
325
+ *
326
+ * @access public
327
+ * @param array $value
328
+ * @return void
329
+ * @since 1.0.0
330
+ */
331
+ public function admin_fields_attributes( $value ) {
332
+ $fields = YITH_Woocompare_Helper::standard_fields();
333
+ $all = array();
334
+ $checked = get_option( str_replace( '_attrs', '', $value['id'] ), $value['default'] == 'all' ? $all : array() );
335
+
336
+ foreach ( array_keys( $fields ) as $field ) {
337
+ $all[ $field ] = true;
338
+ }
339
+ // then add fields that are not still saved
340
+ foreach ( $checked as $k => $v ) {
341
+ unset( $all[ $k ] );
342
+ }
343
+ $checkboxes = array_merge( $checked, $all );
344
+
345
+
346
+ ?>
347
+ <tr valign="top">
348
+ <th scope="row" class="titledesc">
349
+ <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo $value['name']; ?></label>
350
+ </th>
351
+
352
+ <td class="forminp attributes">
353
+ <p class="description"><?php echo $value['desc'] ?></p>
354
+ <ul class="fields">
355
+ <?php foreach ( $checkboxes as $slug => $checked ) :
356
+ if( ! isset( $fields[ $slug ] ) )
357
+ continue;
358
+ ?>
359
+ <li>
360
+ <label>
361
+ <input type="checkbox" name="<?php echo $value['id'] ?>[]" id="<?php echo $value['id'] ?>_<?php echo $slug ?>" value="<?php echo $slug ?>"<?php checked( $checked ) ?> /> <?php echo $fields[ $slug ] ?>
362
+ </label>
363
+ </li>
364
+ <?php
365
+ endforeach;
366
+ ?>
367
+ </ul>
368
+ <input type="hidden" name="<?php echo $value['id'] ?>_positions" value="<?php echo implode( ',', array_keys( $checkboxes ) ) ?>" />
369
+ </td>
370
+ </tr>
371
+ <?php
372
+ }
373
+
374
+ /**
375
+ * Create new Woocommerce admin field: yit_wc_image_width
376
+ *
377
+ * @access public
378
+ * @param array $value
379
+ * @return void
380
+ * @since 1.0.0
381
+ */
382
+ public function admin_fields_woocompare_image_width( $value ) {
383
+
384
+ $width = WC_Admin_Settings::get_option( $value['id'] . '[width]', $value['default']['width'] );
385
+ $height = WC_Admin_Settings::get_option( $value['id'] . '[height]', $value['default']['height'] );
386
+ $crop = WC_Admin_Settings::get_option( $value['id'] . '[crop]' );
387
+ $crop = ( $crop == 'on' || $crop == '1' ) ? 1 : 0;
388
+ $crop = checked( 1, $crop, false );
389
+
390
+ ?>
391
+ <tr valign="top">
392
+ <th scope="row" class="titledesc"><?php echo esc_html( $value['title'] ) ?></th>
393
+ <td class="forminp image_width_settings">
394
+
395
+ <input name="<?php echo esc_attr( $value['id'] ); ?>[width]" id="<?php echo esc_attr( $value['id'] ); ?>-width" type="text" size="3" value="<?php echo $width; ?>" /> &times;
396
+ <input name="<?php echo esc_attr( $value['id'] ); ?>[height]" id="<?php echo esc_attr( $value['id'] ); ?>-height" type="text" size="3" value="<?php echo $height; ?>" />px
397
+
398
+ <label><input name="<?php echo esc_attr( $value['id'] ); ?>[crop]" id="<?php echo esc_attr( $value['id'] ); ?>-crop" type="checkbox" <?php echo $crop; ?> /> <?php _e( 'Do you want to hard crop the image?', 'yith-woocommerce-compare' ); ?>
399
+ </label>
400
+ <p class="description"><?php echo $value['desc'] ?></p>
401
+
402
+ </td>
403
+ </tr><?php
404
+
405
+ }
406
+
407
+ /**
408
+ * Save the admin field: slider
409
+ *
410
+ * @access public
411
+ * @param mixed $value
412
+ * @param mixed $option
413
+ * @param mixed $raw_value
414
+ * @return mixed
415
+ * @since 1.0.0
416
+ */
417
+ public function admin_update_custom_option( $value, $option, $raw_value ) {
418
+
419
+ $val = array();
420
+ $checked_fields = isset( $_POST[ $option['id'] ] ) ? maybe_unserialize( $_POST[ $option['id'] ] ) : array();
421
+ $fields = array_map( 'trim', explode( ',', $_POST[ $option['id'] . '_positions' ] ) );
422
+
423
+ foreach ( $fields as $field ) {
424
+ $val[ $field ] = in_array( $field, $checked_fields );
425
+ }
426
+
427
+ update_option( str_replace( '_attrs', '', $option['id'] ), $val );
428
+
429
+ return $value;
430
+ }
431
+
432
+ /**
433
+ * Save the admin field: slider
434
+ *
435
+ * @access public
436
+ * @param mixed $value
437
+ * @return void
438
+ * @since 1.0.0
439
+ */
440
+ public function admin_update_custom_option_pre_24( $value ) {
441
+
442
+ $val = array();
443
+ $checked_fields = isset( $_POST[ $value['id'] ] ) ? $_POST[ $value['id'] ] : array();
444
+ $fields = array_map( 'trim', explode( ',', $_POST[ $value['id'] . '_positions' ] ) );
445
+
446
+ foreach ( $fields as $field ) {
447
+ $val[ $field ] = in_array( $field, $checked_fields );
448
+ }
449
+
450
+ update_option( str_replace( '_attrs', '', $value['id'] ), $val );
451
+ }
452
+
453
+ /**
454
+ * Enqueue admin styles and scripts
455
+ *
456
+ * @access public
457
+ * @return void
458
+ * @since 1.0.0
459
+ */
460
+ public function enqueue_styles_scripts() {
461
+
462
+ if ( isset( $_GET['page'] ) && $_GET['page'] == 'yith_woocompare_panel' ) {
463
+ wp_enqueue_script( 'jquery-ui' );
464
+ wp_enqueue_script( 'jquery-ui-core' );
465
+ wp_enqueue_script( 'jquery-ui-mouse' );
466
+ wp_enqueue_script( 'jquery-ui-slider' );
467
+ wp_enqueue_script( 'jquery-ui-sortable' );
468
+
469
+ wp_enqueue_style( 'yith_woocompare_admin', YITH_WOOCOMPARE_URL . 'assets/css/admin.css' );
470
+ wp_enqueue_script( 'yith_woocompare', YITH_WOOCOMPARE_URL . 'assets/js/woocompare-admin.js', array( 'jquery', 'jquery-ui-sortable' ) );
471
+ }
472
+
473
+ do_action( 'yith_woocompare_enqueue_styles_scripts' );
474
+ }
475
+ }
476
+ }
includes/class.yith-woocompare-frontend.php CHANGED
@@ -1,819 +1,819 @@
1
- <?php
2
- /**
3
- * Main class
4
- *
5
- * @author YITH
6
- * @package YITH Woocommerce Compare
7
- * @version 1.1.4
8
- */
9
-
10
- if ( !defined( 'YITH_WOOCOMPARE' ) ) { exit; } // Exit if accessed directly
11
-
12
- if( !class_exists( 'YITH_Woocompare_Frontend' ) ) {
13
- /**
14
- * YITH Custom Login Frontend
15
- *
16
- * @since 1.0.0
17
- */
18
- class YITH_Woocompare_Frontend {
19
- /**
20
- * Plugin version
21
- *
22
- * @var string
23
- * @since 1.0.0
24
- */
25
- public $version = YITH_WOOCOMPARE_VERSION;
26
-
27
- /**
28
- * The list of products inside the comparison table
29
- *
30
- * @var array
31
- * @since 1.0.0
32
- */
33
- public $products_list = array();
34
-
35
- /**
36
- * Plugin version
37
- *
38
- * @var string
39
- * @since 1.0.0
40
- */
41
- public $template_file = 'compare.php';
42
-
43
- /**
44
- * Stylesheet file
45
- *
46
- * @var string
47
- * @since 2.1.0
48
- */
49
- public $stylesheet_file = 'compare.css';
50
-
51
- /**
52
- * The name of cookie name
53
- *
54
- * @var string
55
- * @since 1.0.0
56
- */
57
- public $cookie_name = 'yith_woocompare_list';
58
-
59
- /**
60
- * The action used to view the table comparison
61
- *
62
- * @var string
63
- * @since 1.0.0
64
- */
65
- public $action_view = 'yith-woocompare-view-table';
66
-
67
- /**
68
- * The action used to add the product to compare list
69
- *
70
- * @var string
71
- * @since 1.0.0
72
- */
73
- public $action_add = 'yith-woocompare-add-product';
74
-
75
- /**
76
- * The action used to add the product to compare list
77
- *
78
- * @var string
79
- * @since 1.0.0
80
- */
81
- public $action_remove = 'yith-woocompare-remove-product';
82
-
83
- /**
84
- * The action used to reload the compare list widget
85
- *
86
- * @var string
87
- * @since 1.0.0
88
- */
89
- public $action_reload = 'yith-woocompare-reload-product';
90
-
91
- /**
92
- * The standard fields
93
- *
94
- * @var array
95
- * @since 1.0.0
96
- */
97
- public $default_fields = array();
98
-
99
- /**
100
- * Constructor
101
- *
102
- * @return YITH_Woocompare_Frontend
103
- * @since 1.0.0
104
- */
105
- public function __construct() {
106
-
107
-
108
- add_action( 'init', array( $this, 'init_variables' ), 1 );
109
- add_action( 'init', array( $this, 'populate_products_list' ), 10 );
110
-
111
- // Add link or button in the products list or
112
- if ( get_option('yith_woocompare_compare_button_in_product_page') == 'yes' ) add_action( 'woocommerce_single_product_summary', array( $this, 'add_compare_link' ), 35 );
113
- if ( get_option('yith_woocompare_compare_button_in_products_list') == 'yes' ) add_action( 'woocommerce_after_shop_loop_item', array( $this, 'add_compare_link' ), 20 );
114
- add_action( 'init', array( $this, 'add_product_to_compare_action' ), 15 );
115
- add_action( 'init', array( $this, 'remove_product_from_compare_action' ), 15 );
116
- add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
117
- add_action( 'template_redirect', array( $this, 'compare_table_html' ) );
118
-
119
- // add the shortcode
120
- add_shortcode( 'yith_compare_button', array( $this, 'compare_button_sc' ) );
121
-
122
- // AJAX
123
- if( version_compare( WC()->version, '2.4', '>=' ) ){
124
- add_action( 'wc_ajax_' . $this->action_add, array( $this, 'add_product_to_compare_ajax' ) );
125
- add_action( 'wc_ajax_' . $this->action_remove, array( $this, 'remove_product_from_compare_ajax' ) );
126
- add_action( 'wc_ajax_' . $this->action_reload, array( $this, 'reload_widget_list_ajax' ) );
127
- }
128
- else {
129
- add_action( 'wp_ajax_' . $this->action_add, array( $this, 'add_product_to_compare_ajax' ) );
130
- add_action( 'wp_ajax_' . $this->action_remove, array( $this, 'remove_product_from_compare_ajax' ) );
131
- add_action( 'wp_ajax_' . $this->action_reload, array( $this, 'reload_widget_list_ajax' ) );
132
- }
133
- // no priv
134
- add_action( 'wp_ajax_nopriv_' . $this->action_add, array( $this, 'add_product_to_compare_ajax' ) );
135
- add_action( 'wp_ajax_nopriv_' . $this->action_remove, array( $this, 'remove_product_from_compare_ajax' ) );
136
- add_action( 'wp_ajax_nopriv_' . $this->action_reload, array( $this, 'reload_widget_list_ajax' ) );
137
-
138
- return $this;
139
- }
140
-
141
- /**
142
- * Init class variables
143
- *
144
- * @since 2.3.4
145
- * @author Francesco Licandro
146
- */
147
- public function init_variables(){
148
- global $sitepress;
149
-
150
- $lang = isset( $_REQUEST['lang'] ) ? $_REQUEST['lang'] : false;
151
-
152
- if( defined( 'ICL_LANGUAGE_CODE' ) && $lang && isset( $sitepress ) ) {
153
- $sitepress->switch_lang( $lang, true );
154
- }
155
-
156
- // set coookiename
157
- if ( is_multisite() ) $this->cookie_name .= '_' . get_current_blog_id();
158
-
159
- // populate default fields for the comparison table
160
- $this->default_fields = YITH_Woocompare_Helper::standard_fields();
161
- }
162
-
163
- /**
164
- * Populate the compare product list
165
- */
166
- public function populate_products_list(){
167
-
168
- global $sitepress;
169
-
170
- /**
171
- * WPML Support
172
- */
173
- $lang = isset( $_REQUEST['lang'] ) ? $_REQUEST['lang'] : false;
174
-
175
- // get cookie val
176
- $the_list = isset( $_COOKIE[ $this->cookie_name ] ) ? json_decode( $_COOKIE[ $this->cookie_name ] ) : array();
177
-
178
- // switch lang for WPML
179
- if( defined( 'ICL_LANGUAGE_CODE' ) && $lang && isset( $sitepress ) ) {
180
- $sitepress->switch_lang( $lang, true );
181
- }
182
-
183
- foreach( $the_list as $product_id ) {
184
- if( function_exists( 'wpml_object_id_filter' ) ) {
185
- $product_id_translated = wpml_object_id_filter( $product_id, 'product', false );
186
- // get all product of current lang
187
- if ( $product_id_translated !== $product_id ) {
188
- continue;
189
- }
190
- }
191
-
192
- // check for deleted|private products
193
- $product = wc_get_product( $product_id );
194
- if( ! $product || yit_get_prop( $product, 'post_status' ) !== 'publish' ) {
195
- continue;
196
- }
197
-
198
- $this->products_list[] = $product_id;
199
- }
200
-
201
- do_action( 'yith_woocompare_after_populate_product_list', $this->products_list );
202
- }
203
-
204
- /**
205
- * Enqueue the scripts and styles in the page
206
- */
207
- public function enqueue_scripts() {
208
-
209
- // scripts
210
- $min = ! ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '.min' : '';
211
- wp_register_script( 'yith-woocompare-main', YITH_WOOCOMPARE_ASSETS_URL . '/js/woocompare' . $min .'.js', array('jquery'), $this->version, true );
212
-
213
- // enqueue and add localize
214
- wp_enqueue_script( 'yith-woocompare-main' );
215
-
216
- // localize script args
217
- $args = apply_filters( 'yith_woocompare_main_script_localize_array', array(
218
- 'ajaxurl' => version_compare( WC()->version, '2.4', '>=' ) ? WC_AJAX::get_endpoint( "%%endpoint%%" ) : admin_url( 'admin-ajax.php', 'relative' ),
219
- 'actionadd' => $this->action_add,
220
- 'actionremove' => $this->action_remove,
221
- 'actionview' => $this->action_view,
222
- 'actionreload' => $this->action_reload,
223
- 'added_label' => apply_filters( 'yith_woocompare_compare_added_label', __( 'Added', 'yith-woocommerce-compare' ) ),
224
- 'table_title' => apply_filters( 'yith_woocompare_compare_table_title',__( 'Product Comparison', 'yith-woocommerce-compare' ) ),
225
- 'auto_open' => get_option( 'yith_woocompare_auto_open', 'yes' ),
226
- 'loader' => YITH_WOOCOMPARE_ASSETS_URL . '/images/loader.gif',
227
- 'button_text' => get_option('yith_woocompare_button_text'),
228
- 'cookie_name' => $this->cookie_name,
229
- 'close_label' => _x( 'Close', 'Label for popup close icon', 'yith-woocommerce-compare' )
230
- ));
231
-
232
- wp_localize_script( 'yith-woocompare-main', 'yith_woocompare', $args );
233
-
234
- // colorbox
235
- wp_enqueue_style( 'jquery-colorbox', YITH_WOOCOMPARE_ASSETS_URL . '/css/colorbox.css' );
236
- wp_enqueue_script( 'jquery-colorbox', YITH_WOOCOMPARE_ASSETS_URL . '/js/jquery.colorbox-min.js', array('jquery'), '1.4.21', true );
237
-
238
- // widget
239
- if ( is_active_widget( false, false, 'yith-woocompare-widget', true ) && ! is_admin() ) {
240
- wp_enqueue_style( 'yith-woocompare-widget', YITH_WOOCOMPARE_ASSETS_URL . '/css/widget.css' );
241
- }
242
- }
243
-
244
- /**
245
- * The fields to show in the table
246
- *
247
- * @param array $products
248
- * @return mixed|void
249
- * @since 1.0.0
250
- */
251
- public function fields( $products = array() ) {
252
-
253
- $fields = get_option( 'yith_woocompare_fields', array() );
254
-
255
- foreach ( $fields as $field => $show ) {
256
- if ( $show ) {
257
- if ( isset( $this->default_fields[$field] ) ) {
258
- $fields[$field] = $this->default_fields[$field];
259
- }
260
- else {
261
- if ( taxonomy_exists( $field ) ) {
262
- $fields[$field] = wc_attribute_label( $field );
263
- }
264
- }
265
- }
266
- else {
267
- unset( $fields[$field] );
268
- }
269
- }
270
-
271
- return apply_filters( 'yith_woocompare_filter_table_fields', $fields, $products );
272
- }
273
-
274
- /**
275
- * Render the maintenance page
276
- *
277
- */
278
- public function compare_table_html() {
279
-
280
- if ( ( ! defined('DOING_AJAX') || ! DOING_AJAX ) && ( ! isset( $_REQUEST['action'] ) || $_REQUEST['action'] != $this->action_view ) ) return;
281
-
282
- // check if is add to cart
283
- if( isset( $_REQUEST['add-to-cart'] ) ) {
284
- $product_id = intval( $_REQUEST['add-to-cart'] );
285
-
286
- wp_redirect( get_permalink( $product_id ) );
287
- exit;
288
- }
289
-
290
- global $woocommerce, $sitepress;
291
-
292
- /**
293
- * WPML Suppot: Localize Ajax Call
294
- */
295
- $lang = isset( $_REQUEST['lang'] ) ? $_REQUEST['lang'] : false;
296
-
297
- if( defined( 'ICL_LANGUAGE_CODE' ) && $lang && isset( $sitepress ) ) {
298
- $sitepress->switch_lang( $lang, true );
299
- }
300
-
301
- $args = $this->_vars();
302
- $args['fixed'] = false;
303
- $args['iframe'] = 'yes';
304
-
305
- //extract args
306
- extract( $args );
307
-
308
- // remove all styles from compare template
309
- add_action('wp_print_styles', array( $this, 'remove_all_styles' ), 100);
310
-
311
- // remove admin bar
312
- remove_action( 'wp_footer', 'wp_admin_bar_render', 1000 );
313
- remove_action( 'wp_head', '_admin_bar_bump_cb' );
314
-
315
- // remove filters before render compare popup
316
- add_action( 'wp_enqueue_scripts', array( $this, 'actions_before_load_popup' ), 99 );
317
-
318
- $plugin_path = YITH_WOOCOMPARE_TEMPLATE_PATH . '/' . $this->template_file;
319
-
320
- if ( defined('WC_TEMPLATE_PATH') ) {
321
-
322
- $template_path = get_template_directory() . '/' . WC_TEMPLATE_PATH . $this->template_file;
323
- $child_path = get_stylesheet_directory() . '/' . WC_TEMPLATE_PATH . $this->template_file;
324
- }
325
- else {
326
- $template_path = get_template_directory() . '/' . $woocommerce->template_url . $this->template_file;
327
- $child_path = get_stylesheet_directory() . '/' . $woocommerce->template_url . $this->template_file;
328
- }
329
-
330
- foreach ( array( 'child_path', 'template_path', 'plugin_path' ) as $var ) {
331
- if ( file_exists( ${$var} ) ) {
332
- include ${$var};
333
- exit();
334
- }
335
- }
336
- }
337
-
338
- /**
339
- * Return the array with all products and all attributes values
340
- *
341
- * @param mixed $products
342
- * @return array The complete list of products with all attributes value
343
- */
344
- public function get_products_list( $products = array() ) {
345
- $list = array();
346
-
347
- empty( $products ) && $products = $this->products_list;
348
- $products = apply_filters( 'yith_woocompare_exclude_products_from_list', $products );
349
-
350
- $fields = $this->fields( $products );
351
-
352
- foreach ( $products as $product_id ) {
353
-
354
- /**
355
- * @type object $product /WC_Product
356
- */
357
- $product = $this->wc_get_product( $product_id );
358
-
359
- if ( ! $product )
360
- continue;
361
-
362
- $product->fields = array();
363
-
364
- // custom attributes
365
- foreach ( $fields as $field => $name ) {
366
-
367
- switch( $field ) {
368
- case 'title':
369
- $product->fields[$field] = $product->get_title();
370
- break;
371
- case 'price':
372
- $product->fields[$field] = $product->get_price_html();
373
- break;
374
- case 'image':
375
- $product->fields[$field] = intval( get_post_thumbnail_id( $product_id ) );
376
- break;
377
- case 'description':
378
- $description = apply_filters( 'woocommerce_short_description', yit_get_prop( $product, 'post_excerpt' ) );
379
- $product->fields[$field] = apply_filters( 'yith_woocompare_products_description', $description );
380
- break;
381
- case 'stock':
382
- $availability = $product->get_availability();
383
- if ( empty( $availability['availability'] ) ) {
384
- $availability['availability'] = __( 'In stock', 'yith-woocommerce-compare' );
385
- }
386
- $product->fields[$field] = sprintf( '<span>%s</span>', esc_html( $availability['availability'] ) );
387
- break;
388
- case 'sku':
389
- $sku = $product->get_sku();
390
- ! $sku && $sku = '-';
391
- $product->fields[$field] = $sku;
392
- break;
393
- case 'weight':
394
- if( $weight = $product->get_weight() ){
395
- $weight = wc_format_localized_decimal( $weight ) . ' ' . esc_attr( get_option( 'woocommerce_weight_unit' ) );
396
- }
397
- else {
398
- $weight = '-';
399
- }
400
- $product->fields[$field] = sprintf( '<span>%s</span>', esc_html( $weight ) );
401
- break;
402
- case 'dimensions':
403
- $dimensions = function_exists( 'wc_format_dimensions' ) ? wc_format_dimensions( $product->get_dimensions(false) ) : $product->get_dimensions();
404
- ! $dimensions && $dimensions = '-';
405
-
406
- $product->fields[$field] = sprintf( '<span>%s</span>', esc_html( $dimensions ) );
407
- break;
408
- default:
409
- if ( taxonomy_exists( $field ) ) {
410
- $product->fields[$field] = array();
411
- $terms = get_the_terms( $product_id, $field );
412
- if ( ! empty( $terms ) ) {
413
- foreach ( $terms as $term ) {
414
- $term = sanitize_term( $term, $field );
415
- $product->fields[$field][] = $term->name;
416
- }
417
- }
418
- $product->fields[$field] = implode( ', ', $product->fields[$field] );
419
- }
420
- else {
421
- do_action_ref_array( 'yith_woocompare_field_' . $field, array( $product, &$product->fields ) );
422
- }
423
- break;
424
- }
425
- }
426
-
427
- $list[ $product_id ] = $product;
428
- }
429
-
430
- return $list;
431
- }
432
-
433
- /**
434
- * The URL of product comparison table
435
- *
436
- * @param bool | int $product_id
437
- * @return string The url to add the product in the comparison table
438
- */
439
- public function view_table_url( $product_id = false ) {
440
- $url_args = array(
441
- 'action' => $this->action_view,
442
- 'iframe' => 'yes'
443
- );
444
-
445
- $lang = defined( 'ICL_LANGUAGE_CODE' ) ? ICL_LANGUAGE_CODE : false;
446
- if( $lang ) {
447
- $url_args['lang'] = $lang;
448
- }
449
- // fix by WPML
450
- return apply_filters( 'yith_woocompare_view_table_url', esc_url_raw( add_query_arg( $url_args, remove_query_arg( 'wc-ajax' ) ) ), $product_id );
451
- }
452
-
453
- /**
454
- * The URL to add the product into the comparison table
455
- *
456
- * @param int $product_id ID of the product to add
457
- * @return string The url to add the product in the comparison table
458
- */
459
- public function add_product_url( $product_id ) {
460
- $url_args = array(
461
- 'action' => $this->action_add,
462
- 'id' => $product_id
463
- );
464
-
465
- $lang = defined( 'ICL_LANGUAGE_CODE' ) ? ICL_LANGUAGE_CODE : false;
466
- if( $lang ) {
467
- $url_args['lang'] = $lang;
468
- }
469
-
470
- return apply_filters( 'yith_woocompare_add_product_url', esc_url_raw( add_query_arg( $url_args, site_url() ) ), $this->action_add );
471
- }
472
-
473
- /**
474
- * The URL to remove the product into the comparison table
475
- *
476
- * @param string $product_id The ID of the product to remove
477
- * @return string The url to remove the product in the comparison table
478
- */
479
- public function remove_product_url( $product_id ) {
480
- $url_args = array(
481
- 'action' => $this->action_remove,
482
- 'id' => $product_id
483
- );
484
- return apply_filters( 'yith_woocompare_remove_product_url', esc_url_raw( add_query_arg( $url_args, site_url() ) ), $this->action_remove );
485
- }
486
-
487
- /**
488
- * Add the link to compare
489
- */
490
- public function add_compare_link( $product_id = false, $args = array() ) {
491
- extract( $args );
492
-
493
- if ( ! $product_id ) {
494
- global $product;
495
- $product_id = ! is_null( $product ) ? yit_get_prop( $product, 'id', true ) : 0;
496
- }
497
-
498
- // return if product doesn't exist
499
- if ( empty( $product_id ) || apply_filters( 'yith_woocompare_remove_compare_link_by_cat', false, $product_id ) )
500
- return;
501
-
502
- $is_button = ! isset( $button_or_link ) || ! $button_or_link ? get_option( 'yith_woocompare_is_button' ) : $button_or_link;
503
-
504
- if ( ! isset( $button_text ) || $button_text == 'default' ) {
505
- $button_text = get_option( 'yith_woocompare_button_text', __( 'Compare', 'yith-woocommerce-compare' ) );
506
- do_action ( 'wpml_register_single_string', 'Plugins', 'plugin_yit_compare_button_text', $button_text );
507
- $button_text = apply_filters( 'wpml_translate_single_string', $button_text, 'Plugins', 'plugin_yit_compare_button_text' );
508
- }
509
-
510
- printf( '<a href="%s" class="%s" data-product_id="%d" rel="nofollow">%s</a>', $this->add_product_url( $product_id ), 'compare' . ( $is_button == 'button' ? ' button' : '' ), $product_id, $button_text );
511
- }
512
-
513
- /**
514
- * Return the url of stylesheet position
515
- */
516
- public function stylesheet_url() {
517
- global $woocommerce;
518
-
519
- $filename = $this->stylesheet_file;
520
-
521
- $plugin_path = array( 'path' => YITH_WOOCOMPARE_DIR . '/assets/css/style.css', 'url' => YITH_WOOCOMPARE_ASSETS_URL . '/css/style.css' );
522
-
523
- if ( defined('WC_TEMPLATE_PATH') ) {
524
- $template_path = array( 'path' => get_template_directory() . '/' . WC_TEMPLATE_PATH . $filename, 'url' => get_template_directory_uri() . '/' . WC_TEMPLATE_PATH . $filename );
525
- $child_path = array( 'path' => get_stylesheet_directory() . '/' . WC_TEMPLATE_PATH . $filename, 'url' => get_stylesheet_directory_uri() . '/' . WC_TEMPLATE_PATH . $filename );
526
- }
527
- else {
528
- $template_path = array( 'path' => get_template_directory() . '/' . $woocommerce->template_url . $filename, 'url' => get_template_directory_uri() . '/' . $woocommerce->template_url . $filename );
529
- $child_path = array( 'path' => get_stylesheet_directory() . '/' . $woocommerce->template_url . $filename, 'url' => get_stylesheet_directory_uri() . '/' . $woocommerce->template_url . $filename );
530
- }
531
-
532
- foreach ( array( 'child_path', 'template_path', 'plugin_path' ) as $var ) {
533
- if ( file_exists( ${$var}['path'] ) ) {
534
- return ${$var}['url'];
535
- }
536
- }
537
- }
538
-
539
-
540
- /**
541
- * Generate template vars
542
- *
543
- * @return array
544
- * @since 1.0.0
545
- * @access protected
546
- */
547
- protected function _vars() {
548
- $vars = array(
549
- 'products' => $this->get_products_list(),
550
- 'fields' => $this->fields(),
551
- 'repeat_price' => get_option( 'yith_woocompare_price_end' ),
552
- 'repeat_add_to_cart' => get_option( 'yith_woocompare_add_to_cart_end' ),
553
- );
554
-
555
- return $vars;
556
- }
557
-
558
- /**
559
- * The action called by the query string
560
- */
561
- public function add_product_to_compare_action() {
562
- if ( defined( 'DOING_AJAX' ) && DOING_AJAX || ! isset( $_REQUEST['id'] ) || ! isset( $_REQUEST['action'] ) || $_REQUEST['action'] != $this->action_add ) {
563
- return;
564
- }
565
-
566
- $product_id = intval( $_REQUEST['id'] );
567
- $product = $this->wc_get_product( $product_id );
568
-
569
- // don't add the product if doesn't exist
570
- if ( isset( $product->id ) && ! in_array( $product_id, $this->products_list ) ) {
571
- $this->add_product_to_compare( $product_id );
572
- }
573
-
574
- wp_redirect( esc_url( remove_query_arg( array( 'id', 'action' ) ) ) );
575
- exit();
576
- }
577
-
578
- /**
579
- * The action called by AJAX
580
- */
581
- public function add_product_to_compare_ajax() {
582
-
583
- if( ! isset( $_REQUEST['id'] ) || ! isset( $_REQUEST['action'] ) || $_REQUEST['action'] != $this->action_add ){
584
- die();
585
- }
586
-
587
- $product_id = intval( $_REQUEST['id'] );
588
- $product = $this->wc_get_product( $product_id );
589
-
590
- // don't add the product if doesn't exist
591
- if ( isset( $product->id ) && ! in_array( $product_id, $this->products_list ) ) {
592
- $this->add_product_to_compare( $product_id );
593
- }
594
-
595
- do_action( 'yith_woocompare_add_product_action_ajax' );
596
-
597
- $json = apply_filters( 'yith_woocompare_add_product_action_json', array(
598
- 'table_url' => $this->view_table_url( $product_id ),
599
- 'widget_table' => $this->list_products_html(),
600
- ) );
601
-
602
- echo json_encode( $json );
603
- die();
604
- }
605
-
606
- /**
607
- * Add a product in the products comparison table
608
- *
609
- * @param int $product_id product ID to add in the comparison table
610
- */
611
- public function add_product_to_compare( $product_id ) {
612
-
613
- $this->products_list[] = $product_id;
614
- setcookie( $this->cookie_name, json_encode( $this->products_list ), 0, COOKIEPATH, COOKIE_DOMAIN, false, false );
615
-
616
- do_action( 'yith_woocompare_after_add_product', $product_id );
617
- }
618
-
619
- /**
620
- * The action called by the query string
621
- */
622
- public function remove_product_from_compare_action() {
623
- if ( defined( 'DOING_AJAX' ) && DOING_AJAX || ! isset( $_REQUEST['action'] ) || $_REQUEST['action'] != $this->action_remove ) {
624
- return;
625
- }
626
-
627
- $this->remove_product_from_compare( $_REQUEST['id'] );
628
-
629
- // redirect
630
- $redirect = esc_url( remove_query_arg( array( 'id', 'action' ) ) );
631
-
632
- if ( isset( $_REQUEST['redirect'] ) && $_REQUEST['redirect'] == 'view' )
633
- $redirect = esc_url( remove_query_arg( 'redirect', add_query_arg( 'action', $this->action_view, $redirect ) ) );
634
-
635
- wp_redirect( $redirect );
636
- exit();
637
- }
638
-
639
- /**
640
- * The action called by AJAX
641
- */
642
- public function remove_product_from_compare_ajax() {
643
-
644
- if ( ! isset( $_REQUEST['id'] ) || ! isset( $_REQUEST['action'] ) || $_REQUEST['action'] != $this->action_remove ){
645
- die();
646
- }
647
-
648
- $lang = isset( $_REQUEST['lang'] ) ? $_REQUEST['lang'] : false;
649
-
650
- $this->remove_product_from_compare( $_REQUEST['id'] );
651
-
652
- do_action( 'yith_woocompare_remove_product_action_ajax' );
653
-
654
- header('Content-Type: text/html; charset=utf-8');
655
-
656
- if ( isset( $_REQUEST['responseType'] ) && $_REQUEST['responseType'] == 'product_list' ) {
657
- echo $this->list_products_html( $lang );
658
- } else {
659
- $this->compare_table_html();
660
- }
661
-
662
- die();
663
- }
664
-
665
- /**
666
- * Return the list of widget table, used in AJAX
667
- */
668
- public function reload_widget_list_ajax() {
669
-
670
- if ( ! isset( $_REQUEST['action'] ) || $_REQUEST['action'] != $this->action_reload ){
671
- die();
672
- }
673
-
674
- $lang = isset( $_REQUEST['lang'] ) ? $_REQUEST['lang'] : false;
675
-
676
- echo $this->list_products_html( $lang );
677
- die();
678
- }
679
-
680
- /**
681
- * The list of products as HTML list
682
- */
683
- public function list_products_html( $lang = false ) {
684
- ob_start();
685
-
686
- /**
687
- * WPML Suppot: Localize Ajax Call
688
- */
689
- global $sitepress;
690
-
691
- if( defined( 'ICL_LANGUAGE_CODE' ) && $lang && isset( $sitepress )) {
692
- $sitepress->switch_lang( $lang, true );
693
- }
694
-
695
- if ( empty( $this->products_list ) ) {
696
- echo '<li class="list_empty">' . __( 'No products to compare', 'yith-woocommerce-compare' ) . '</li>';
697
- return ob_get_clean();
698
- }
699
-
700
- foreach ( $this->products_list as $product_id ) {
701
- /**
702
- * @type object $product /WC_Product
703
- */
704
- $product = $this->wc_get_product( $product_id );
705
- if ( ! $product )
706
- continue;
707
- ?>
708
- <li>
709
- <a href="<?php echo $this->remove_product_url( $product_id ) ?>" data-product_id="<?php echo $product_id; ?>" class="remove" title="<?php _e( 'Remove', 'yith-woocommerce-compare' ) ?>">x</a>
710
- <a class="title" href="<?php echo get_permalink( $product_id ) ?>"><?php echo $product->get_title() ?></a>
711
- </li>
712
- <?php
713
- }
714
-
715
- $return = ob_get_clean();
716
-
717
- return apply_filters( 'yith_woocompare_widget_products_html', $return, $this->products_list, $this );
718
- }
719
-
720
- /**
721
- * Remove a product from the comparison table
722
- *
723
- * @param $product_id The product ID to remove from the comparison table
724
- */
725
- public function remove_product_from_compare( $product_id ) {
726
-
727
- if( $product_id == 'all' ) {
728
- $this->products_list = array();
729
- }
730
- else {
731
- foreach ( $this->products_list as $k => $id ) {
732
- if ( intval( $product_id ) == $id ) {
733
- unset( $this->products_list[ $k ] );
734
- }
735
- }
736
- }
737
-
738
- setcookie( $this->cookie_name, json_encode( array_values( $this->products_list ) ), 0, COOKIEPATH, COOKIE_DOMAIN, false, false );
739
-
740
- do_action( 'yith_woocompare_after_remove_product', $product_id );
741
- }
742
-
743
- /**
744
- * Remove all styles from the compare template
745
- */
746
- public function remove_all_styles() {
747
- global $wp_styles;
748
- $wp_styles->queue = array();
749
- }
750
-
751
- /**
752
- * Show the html for the shortcode
753
- */
754
- public function compare_button_sc( $atts, $content = null ) {
755
- $atts = shortcode_atts(array(
756
- 'product' => false,
757
- 'type' => 'default',
758
- 'container' => 'yes'
759
- ), $atts);
760
-
761
- $product_id = 0;
762
-
763
- /**
764
- * Retrieve the product ID in these steps:
765