YITH Essential Kit for WooCommerce #1 - Version 1.4.8

Version Description

  • Update: YITH Plugin Framework
  • Update: YITH WooCommerce Ajax Product Filter module
  • Update: YITH WooCommerce Advanced Reviews module
  • Update: YITH WooCommerce Ajax Search module
  • Update: YITH WooCommerce Cart Message module
  • Update: YITH WooCommerce Multi Vendor module
  • Update: YITH WooCommerce Review Reminder module
Download this release

Release Info

Developer yithemes
Plugin Icon 128x128 YITH Essential Kit for WooCommerce #1
Version 1.4.8
Comparing to
See all releases

Code changes from version 1.4.7 to 1.4.8

Files changed (38) hide show
  1. README.txt +11 -2
  2. init.php +1 -1
  3. modules/yith-woocommerce-advanced-reviews/class.yith-woocommerce-advanced-reviews.php +321 -346
  4. modules/yith-woocommerce-advanced-reviews/init.php +2 -2
  5. modules/yith-woocommerce-ajax-navigation/includes/class.yith-wcan-frontend.php +8 -1
  6. modules/yith-woocommerce-ajax-navigation/init.php +2 -2
  7. modules/yith-woocommerce-ajax-navigation/widgets/class.yith-wcan-navigation-widget.php +52 -8
  8. modules/yith-woocommerce-ajax-search/assets/js/frontend.js +1 -1
  9. modules/yith-woocommerce-ajax-search/assets/js/frontend.min.js +2 -2
  10. modules/yith-woocommerce-ajax-search/class.yith-wcas.php +11 -6
  11. modules/yith-woocommerce-ajax-search/init.php +3 -2
  12. modules/yith-woocommerce-cart-messages/class.yith-woocommerce-cart-messages.php +15 -12
  13. modules/yith-woocommerce-cart-messages/yith-cart-messages.php +3 -2
  14. modules/yith-woocommerce-product-vendors/assets/css/admin.css +104 -2
  15. modules/yith-woocommerce-product-vendors/assets/images/43-bg.png +0 -0
  16. modules/yith-woocommerce-product-vendors/assets/images/43-icon.png +0 -0
  17. modules/yith-woocommerce-product-vendors/assets/images/43.png +0 -0
  18. modules/yith-woocommerce-product-vendors/assets/images/vendor-commission-fee.png +0 -0
  19. modules/yith-woocommerce-product-vendors/includes/class.yith-commission.php +3 -1
  20. modules/yith-woocommerce-product-vendors/includes/class.yith-commissions.php +56 -92
  21. modules/yith-woocommerce-product-vendors/includes/class.yith-orders.php +43 -21
  22. modules/yith-woocommerce-product-vendors/includes/class.yith-vendor.php +7 -1
  23. modules/yith-woocommerce-product-vendors/includes/class.yith-vendors-admin.php +3 -3
  24. modules/yith-woocommerce-product-vendors/includes/class.yith-vendors-frontend.php +1 -1
  25. modules/yith-woocommerce-product-vendors/includes/class.yith-vendors.php +9 -1
  26. modules/yith-woocommerce-product-vendors/includes/functions.yith-update.php +15 -0
  27. modules/yith-woocommerce-product-vendors/includes/lib/class.yith-commissions-list-table.php +13 -6
  28. modules/yith-woocommerce-product-vendors/init.php +3 -3
  29. modules/yith-woocommerce-product-vendors/templates/admin/commission-view.php +163 -142
  30. modules/yith-woocommerce-product-vendors/templates/admin/premium.php +17 -1
  31. modules/yith-woocommerce-review-reminder/includes/class-ywrr-emails.php +7 -2
  32. modules/yith-woocommerce-review-reminder/includes/emails/class-ywrr-request-email.php +4 -2
  33. modules/yith-woocommerce-review-reminder/init.php +2 -2
  34. modules/yith-woocommerce-review-reminder/templates/emails/review-request.php +2 -0
  35. plugin-fw/init.php +1 -1
  36. plugin-fw/lib/yit-plugin-panel-wc.php +2 -0
  37. plugin-fw/lib/yit-plugin-panel.php +3 -1
  38. plugin-fw/yit-woocommerce-compatibility.php +41 -1
README.txt CHANGED
@@ -3,8 +3,8 @@
3
Contributors: yithemes
4
Tags: woocommerce,yith woocommerce colors and labels variations,yith woocommerce zoom magnifier,yith woocommerce wishlist,yith woocommerce ajax product filter,yith woocommerce ajax search,yith woocommerce catalog mode,yith woocommerce advanced reviews, yith woocommerce badges management,yith woocommerce cart messages,yith woocommerce review reminder,yith woocommerce quick view,yith woocommerce mailchimp,yith woocommerce stripe,yith woocommerce request a quote,yith woocommerce tab manager,yith woocommerce multi vendor
5
Requires at least: 3.5.1
6
- Tested up to: 4.7.5
7
- Stable tag: 1.4.7
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
@@ -155,6 +155,15 @@ YITH Essential Kit for WooCommerce #1 will add a new submenu called "YITH Essent
155
156
== Changelog ==
157
158
= 1.4.7 =
159
* Update: YITH WooCommerce Multi Vendor module
160
* Update: YITH WooCommerce Mailchimp module
3
Contributors: yithemes
4
Tags: woocommerce,yith woocommerce colors and labels variations,yith woocommerce zoom magnifier,yith woocommerce wishlist,yith woocommerce ajax product filter,yith woocommerce ajax search,yith woocommerce catalog mode,yith woocommerce advanced reviews, yith woocommerce badges management,yith woocommerce cart messages,yith woocommerce review reminder,yith woocommerce quick view,yith woocommerce mailchimp,yith woocommerce stripe,yith woocommerce request a quote,yith woocommerce tab manager,yith woocommerce multi vendor
5
Requires at least: 3.5.1
6
+ Tested up to: 4.8.0
7
+ Stable tag: 1.4.8
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
155
156
== Changelog ==
157
158
+ = 1.4.8 =
159
+ * Update: YITH Plugin Framework
160
+ * Update: YITH WooCommerce Ajax Product Filter module
161
+ * Update: YITH WooCommerce Advanced Reviews module
162
+ * Update: YITH WooCommerce Ajax Search module
163
+ * Update: YITH WooCommerce Cart Message module
164
+ * Update: YITH WooCommerce Multi Vendor module
165
+ * Update: YITH WooCommerce Review Reminder module
166
+
167
= 1.4.7 =
168
* Update: YITH WooCommerce Multi Vendor module
169
* Update: YITH WooCommerce Mailchimp module
init.php CHANGED
@@ -7,7 +7,7 @@ Text Domain: yith-essential-kit-for-woocommerce-1
7
Domain Path: /languages/
8
Author: YIThemes
9
Author URI: http://yithemes.com/
10
- Version: 1.4.7
11
*/
12
13
if ( ! defined( 'ABSPATH' ) ) {
7
Domain Path: /languages/
8
Author: YIThemes
9
Author URI: http://yithemes.com/
10
+ Version: 1.4.8
11
*/
12
13
if ( ! defined( 'ABSPATH' ) ) {
modules/yith-woocommerce-advanced-reviews/class.yith-woocommerce-advanced-reviews.php CHANGED
@@ -4,7 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) {
4
}
5
6
if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
7
-
8
/**
9
* Implements features of FREE version of YWAR plugin
10
*
@@ -18,145 +18,145 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
18
* @var $_panel Panel Object
19
*/
20
protected $_panel;
21
-
22
/**
23
* @var $_premium string Premium tab template file name
24
*/
25
protected $_premium = 'premium.php';
26
-
27
/**
28
* @var string Premium version landing link
29
*/
30
protected $_premium_landing = 'http://yithemes.com/themes/plugins/yith-woocommerce-advanced-reviews/';
31
-
32
/**
33
* @var string Plugin official documentation
34
*/
35
protected $_official_documentation = 'http://yithemes.com/docs-plugins/yith-woocommerce-advanced-reviews/';
36
-
37
/**
38
* @var string Advanced Reviews panel page
39
*/
40
protected $_panel_page = 'yith_ywar_panel';
41
-
42
/**
43
* @var $enable_title Let users to add a title when writing a review
44
*/
45
protected $enable_title = 0;
46
-
47
/**
48
* @var $enable_attachments Let users to add attachments when submit a review
49
*/
50
protected $enable_attachments = 0;
51
-
52
/**
53
* @var $attachments_limit Set the maximum number of attachments a users can add when submit a review
54
*/
55
protected $attachments_limit = 0;
56
-
57
public $post_type_name = "ywar_reviews";
58
-
59
public $items_for_page = 10;
60
-
61
public $meta_key_rating = "_ywar_rating";
62
public $meta_key_product_id = "_ywar_product_id";
63
public $meta_key_imported = "_ywar_imported";
64
public $meta_key_approved = "_ywar_approved";
65
public $meta_key_thumb_ids = "_ywar_thumb_ids";
66
public $meta_key_comment_id = "_ywar_comment_id";
67
-
68
/**
69
* @var string meta_key used for saving data about segnalation of inappropriate content from users
70
*/
71
public $meta_key_inappropriate_list = "_ywar_inappropriate_list";
72
-
73
/**
74
* @var string meta_key used for saving data about inappropriate reviews
75
*/
76
public $meta_key_inappropriate_count = "_ywar_inappropriate_count";
77
-
78
/**
79
* @var string meta_key used for saving data about inappropriate reviews
80
*/
81
public $meta_key_featured = "_ywar_featured";
82
-
83
/**
84
* @var string meta_key used for saving data about upvotes
85
*/
86
public $meta_key_upvotes_count = "_ywar_upvotes_count";
87
-
88
/**
89
* @var string meta_key used for saving data about downvotes
90
*/
91
public $meta_key_downvotes_count = "_ywar_downvotes_count";
92
-
93
/**
94
* @var string meta_key used for saving data about reviews votes
95
*/
96
public $meta_key_votes = "_ywar_votes";
97
-
98
/**
99
* @var string meta_key used for saving data about replies status
100
*/
101
public $meta_key_stop_reply = "_ywar_stop_reply";
102
-
103
/**
104
* @var string meta_key used for saving review's user id
105
*/
106
public $meta_key_review_user_id = "_ywar_review_user_id";
107
-
108
/**
109
* @var string meta_key used for saving review's author
110
*/
111
public $meta_key_review_author = "_ywar_review_author";
112
-
113
/**
114
* @var string meta_key used for saving review author's email
115
*/
116
public $meta_key_review_author_email = "_ywar_review_author_email";
117
-
118
/**
119
* @var string meta_key used for saving review author's url
120
*/
121
public $meta_key_review_author_url = "_ywar_review_author_url";
122
-
123
/**
124
* @var string meta_key used for saving review author's IP
125
*/
126
public $meta_key_review_author_IP = "_ywar_review_author_IP";
127
-
128
public $custom_column_review = "review-text";
129
-
130
public $custom_column_rating = "review-rating";
131
-
132
public $custom_column_date = "review-date";
133
-
134
public $custom_column_author = "review-author";
135
-
136
public $custom_column_product = "product";
137
-
138
/**
139
* @var string action name for "approve" review
140
*/
141
protected $approve_review_action = "approve-review";
142
-
143
/**
144
* @var string action name for "untrash" review
145
*/
146
protected $untrash_review_action = "untrash";
147
-
148
/**
149
* @var string action name for "unapprove" review
150
*/
151
protected $unapprove_review_action = "unapprove-review";
152
-
153
/**
154
* Single instance of the class
155
*
156
* @since 1.0.0
157
*/
158
protected static $instance;
159
-
160
/**
161
* Returns single instance of the class
162
*
@@ -166,10 +166,10 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
166
if ( is_null( self::$instance ) ) {
167
self::$instance = new self();
168
}
169
-
170
return self::$instance;
171
}
172
-
173
/**
174
* Constructor
175
*
@@ -182,119 +182,105 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
182
if ( ! function_exists( 'WC' ) ) {
183
return;
184
}
185
-
186
add_action( 'admin_menu', array( $this, 'add_menu_item' ) );
187
-
188
add_action( 'init', array( $this, 'initialize_settings' ) );
189
-
190
- //region ******* YIT Plugin Framework *********
191
-
192
// Load Plugin Framework
193
add_action( 'plugins_loaded', array( $this, 'plugin_fw_loader' ), 15 );
194
-
195
-
196
// Add row meta
197
add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 4 );
198
-
199
// Add stylesheets and scripts files
200
add_action( 'admin_menu', array( $this, 'register_panel' ), 5 );
201
-
202
// register plugin pointer
203
add_action( 'admin_init', array( $this, 'register_pointer' ) );
204
-
205
// verify import reviews action request
206
add_action( "admin_init", array( $this, "check_import_actions" ) );
207
-
208
//Add action links
209
add_filter( 'plugin_action_links_' . plugin_basename( YITH_YWAR_DIR . '/' . basename( YITH_YWAR_FILE ) ), array(
210
$this,
211
'action_links'
212
) );
213
-
214
add_action( 'yith_advanced_reviews_premium', array( $this, 'premium_tab' ) );
215
-
216
- //endregion
217
-
218
- //region *********** Add stylesheets and scripts files ************
219
-
220
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
221
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) );
222
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles_scripts' ) );
223
-
224
- //endregion
225
-
226
- //region *********** Advanced reviews post type functionalities
227
-
228
add_action( 'init', array( $this, 'register_post_type' ) );
229
-
230
-
231
- //endregion
232
-
233
- //region *********** Review table
234
-
235
add_filter( 'yith_advanced_reviews_row_actions', array( $this, 'add_review_actions' ), 10, 2 );
236
-
237
add_filter( 'post_class', array( $this, 'add_review_table_class' ), 10, 3 );
238
-
239
/**
240
* intercept approve and unapprove actions
241
*/
242
add_action( "admin_action_{$this->approve_review_action}", array( $this, 'update_review_attributes' ) );
243
add_action( "admin_action_{$this->unapprove_review_action}", array( $this, 'update_review_attributes' ) );
244
add_action( "admin_action_{$this->untrash_review_action}", array( $this, 'update_review_attributes' ) );
245
-
246
- //endregion ******************************************
247
-
248
// Load reviews template
249
add_filter( 'comments_template', array( $this, 'show_advanced_reviews_template' ), 99 );
250
-
251
// Save additional comment fields on comment submit
252
add_action( 'comment_post', array( $this, 'submit_review' ) );
253
-
254
// redirect to product page on comment submitted
255
add_filter( 'comment_post_redirect', array( $this, 'redirect_after_submit_review' ), 10, 2 );
256
-
257
add_filter( 'woocommerce_product_review_comment_form_args', array( $this, 'add_fields_to_comment_form' ) );
258
-
259
// Add custom fields "Title" on top of comment form
260
add_action( 'comment_form_logged_in_after', array( $this, 'add_custom_fields_on_comment_form' ) );
261
add_action( 'comment_form_after_fields', array( $this, 'add_custom_fields_on_comment_form' ) );
262
-
263
add_filter( 'yith_advanced_reviews_review_content', array( $this, 'show_expanded_review_content' ) );
264
-
265
add_filter( 'woocommerce_product_tabs', array( $this, 'update_tab_reviews_count' ), 20 );
266
-
267
/**
268
* Add summary bars for product rating
269
*/
270
add_action( 'yith_advanced_reviews_before_reviews', array( $this, 'load_reviews_summary' ) );
271
-
272
// Show details with average rating for the current product
273
add_action( 'ywar_summary_prepend', array( $this, 'add_reviews_average_info' ) );
274
-
275
add_filter( 'wc_get_template', array( $this, 'wc_get_template' ), 99, 5 );
276
-
277
add_filter( 'woocommerce_product_get_rating_html', array( $this, 'get_product_rating_html' ), 99, 2 );
278
-
279
- //region ***************** Show, edit and save back-end review metabox
280
// Add a new metabox for editing and saving title comment in meta_comment table
281
add_action( 'add_meta_boxes', array( $this, 'add_plugin_metabox' ), 1 );
282
-
283
// save the custom fields
284
add_action( 'save_post', array( $this, 'save_plugin_metabox' ), 1, 2 );
285
-
286
add_action( 'admin_menu', array( $this, 'remove_unwanted_custom_post_type_features' ), 5 );
287
add_action( 'admin_head', array( $this, 'hide_unwanted_custom_post_type_features' ) );
288
- //endregion
289
-
290
add_action( 'woocommerce_admin_field_ywar_import_previous_reviews', array(
291
$this,
292
'show_import_reviews_button'
293
), 10, 1 );
294
-
295
add_action( 'wp_ajax_convert_reviews', array( $this, 'convert_reviews_callback' ) );
296
}
297
-
298
/**
299
* Add the Commissions menu item in dashboard menu
300
*
@@ -304,7 +290,7 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
304
* @see wp-admin\includes\plugin.php -> add_menu_page()
305
*/
306
public function add_menu_item() {
307
-
308
$args = apply_filters( 'yith_wc_product_vendors_commissions_menu_items', array(
309
'page_title' => __( 'Reviews', 'yith-woocommerce-advanced-reviews' ),
310
'menu_title' => __( 'Reviews', 'yith-woocommerce-advanced-reviews' ),
@@ -315,12 +301,12 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
315
'position' => 8 /* After WC Products */
316
)
317
);
318
-
319
extract( $args );
320
-
321
add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon, $position );
322
}
323
-
324
/**
325
* Show the reviews table
326
*
@@ -333,74 +319,74 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
333
if ( ! class_exists( 'WP_Posts_List_Table' ) ) {
334
require_once( ABSPATH . 'wp-admin/includes/class-wp-posts-list-table.php' );
335
}
336
-
337
require_once( YITH_YWAR_DIR . 'lib/class.yith-advanced-reviews-list-table.php' );
338
-
339
$product_reviews = new YITH_Advanced_Reviews_List_Table();
340
$product_reviews->prepare_items();
341
-
342
wc_get_template( 'ywar-product-reviews-table.php', array( 'product_reviews' => $product_reviews ), YITH_YWAR_TEMPLATES_DIR, YITH_YWAR_TEMPLATES_DIR );
343
}
344
-
345
/**
346
* Intercept review action url and do the requested job
347
*/
348
public function update_review_attributes() {
349
-
350
if ( ! isset( $_GET["review_id"] ) ) {
351
return;
352
}
353
-
354
$review_id = $_GET["review_id"];
355
-
356
$current_filter = current_filter();
357
-
358
switch ( $current_filter ) {
359
case "admin_action_{$this->approve_review_action}" :
360
update_post_meta( $review_id, $this->meta_key_approved, 1 );
361
-
362
break;
363
-
364
case "admin_action_{$this->unapprove_review_action}" :
365
update_post_meta( $review_id, $this->meta_key_approved, 0 );
366
-
367
break;
368
-
369
case "admin_action_{$this->untrash_review_action}" :
370
$my_post = array(
371
'ID' => $review_id,
372
'post_status' => 'publish',
373
);
374
-
375
// Update the post into the database
376
wp_update_post( $my_post );
377
-
378
break;
379
}
380
-
381
wp_redirect( esc_url_raw( remove_query_arg( array( 'action', 'action2' ), $_SERVER['HTTP_REFERER'] ) ) );
382
}
383
-
384
public function add_review_table_class( $classes, $class, $post_id ) {
385
-
386
if ( $this->post_type_name != get_post_type( $post_id ) ) {
387
return $classes;
388
}
389
-
390
unset( $classes["review-unapproved"] );
391
unset( $classes["review-approved"] );
392
-
393
$approve = get_post_meta( $post_id, $this->meta_key_approved, true );
394
-
395
if ( 1 == $approve ) {
396
$classes[] = "review-approved";
397
} elseif ( 0 == $approve ) {
398
$classes[] = "review-unapproved";
399
}
400
-
401
return apply_filters( 'yith_advanced_reviews_table_class', $classes, $post_id );
402
}
403
-
404
/**
405
* Build a url to be using as action url in row actions
406
*
@@ -412,7 +398,7 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
412
public function review_action_url( $action, $post_id ) {
413
return admin_url( "admin.php?action=$action&post_type={$this->post_type_name}&review_id=$post_id" );
414
}
415
-
416
/**
417
* Build an "untrash" action url
418
*
@@ -423,7 +409,7 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
423
public function untrash_review_url( $review ) {
424
return $this->review_action_url( $this->untrash_review_action, $review->ID );
425
}
426
-
427
/**
428
* Build an "approve" action url
429
*
@@ -434,7 +420,7 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
434
public function approve_review_url( $review ) {
435
return $this->review_action_url( $this->approve_review_action, $review->ID );
436
}
437
-
438
/**
439
* Build an "unapprove" action url
440
*
@@ -445,69 +431,71 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
445
public function unapprove_review_url( $review ) {
446
return $this->review_action_url( $this->unapprove_review_action, $review->ID );
447
}
448
-
449
public function add_review_actions( $actions, $post ) {
450
-
451
if ( $post->post_type != $this->post_type_name ) {
452
return $actions;
453
}
454
-
455
$approved = get_post_meta( $post->ID, $this->meta_key_approved, true );
456
-
457
unset( $actions['view'] );
458
unset( $actions['inline hide-if-no-js'] );
459
-
460
if ( ! $approved ) {
461
$actions['approve-review'] = '<a href="' . $this->approve_review_url( $post ) . '" title="' . esc_attr( __( 'Approve review', 'yith-woocommerce-advanced-reviews' ) ) . '" rel="permalink">' . __( 'Approve', 'yith-woocommerce-advanced-reviews' ) . '</a>';
462
} elseif ( $approved ) {
463
$actions['unapprove-review'] = '<a href="' . $this->unapprove_review_url( $post ) . '" title="' . esc_attr( __( 'Unapprove review', 'yith-woocommerce-advanced-reviews' ) ) . '" rel="permalink">' . __( 'Unapprove', 'yith-woocommerce-advanced-reviews' ) . '</a>';
464
}
465
-
466
return apply_filters( 'yith_advanced_reviews_review_actions', $actions, $post );
467
}
468
-
469
public function get_average_rating( $product_id ) {
470
global $wpdb;
471
-
472
$query = $wpdb->prepare( "
473
select avg(meta_value)
474
from {$wpdb->prefix}postmeta pm
475
where meta_key = '{$this->meta_key_rating}' and post_id in
476
(select post_id from {$wpdb->prefix}postmeta where meta_key = '{$this->meta_key_product_id}' and meta_value = %d and post_id IN
477
(select post_id from {$wpdb->prefix}postmeta where meta_key = '{$this->meta_key_approved}' and meta_value = 1))", $product_id );
478
-
479
$count = $wpdb->get_var( $query );
480
-
481
return number_format( $count, 2 );
482
}
483
-
484
/**
485
* @param WC_Product $product
486
*/
487
public function add_reviews_average_info( $product ) {
488
-
489
if ( get_option( 'woocommerce_enable_review_rating' ) === 'no' ) {
490
return;
491
}
492
-
493
$product_id = yit_get_prop( $product, 'id' );
494
$average = $this->get_average_rating( $product_id );
495
-
496
- $count = count( $this->get_product_reviews_by_rating( $product_id ) );
497
-
498
- if ( $count > 0 ) {
499
- echo '<div class="woocommerce-product-rating">
500
- <div class="star-rating" title="' . sprintf( __( 'Rated %s out of 5', 'yith-woocommerce-advanced-reviews' ), $average ) . '">
501
- <span style="width:' . ( ( $average / 5 ) * 100 ) . '%"></span>
502
- </div>
503
- <span class="ywar_review_count">' . sprintf( "%d %s", $count, _n( " review", " reviews", $count, 'yith-woocommerce-advanced-reviews' ) ) . '</span><span class="review-rating-value"> ' . esc_html( $average ) . ' ' . __( "out of 5 stars", 'yith-woocommerce-advanced-reviews' ) . '</span>
504
- </div>';
505
}
506
}
507
-
508
- //region *********** YIT Plugin Framework ****************
509
-
510
-
511
/**
512
*
513
* @since 1.0
@@ -516,7 +504,7 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
516
* @author Andrea Grillo <andrea.grillo@yithemes.com>
517
*/
518
public function plugin_fw_loader() {
519
-
520
if ( ! defined( 'YIT_CORE_PLUGIN' ) ) {
521
global $plugin_fw_data;
522
if ( ! empty( $plugin_fw_data ) ) {
@@ -525,7 +513,7 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
525
}
526
}
527
}
528
-
529
/**
530
* plugin_row_meta
531
*
@@ -547,10 +535,10 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
547
) {
548
$plugin_meta[] = '<a href="' . $this->_official_documentation . '" target="_blank">' . __( 'Plugin Documentation', 'yith-woocommerce-advanced-reviews' ) . '</a>';
549
}
550
-
551
return $plugin_meta;
552
}
553
-
554
/**
555
* Action Links
556
*
@@ -565,26 +553,26 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
565
* @use plugin_action_links_{$plugin_file_name}
566
*/
567
public function action_links( $links ) {
568
-
569
$links[] = '<a href="' . admin_url( "admin.php?page={$this->_panel_page}" ) . '">' . __( 'Settings', 'yith-woocommerce-advanced-reviews' ) . '</a>';
570
-
571
if ( defined( 'YITH_YWAR_FREE_INIT' ) ) {
572
$links[] = '<a href="' . $this->get_premium_landing_uri() . '" target="_blank">' . __( 'Premium Version', 'yith-woocommerce-advanced-reviews' ) . '</a>';
573
}
574
-
575
return $links;
576
}
577
-
578
public function register_pointer() {
579
if ( ! class_exists( 'YIT_Pointers' ) ) {
580
include_once( 'plugin-fw/lib/yit-pointers.php' );
581
}
582
-
583
$premium_message = defined( 'YITH_YWAR_PREMIUM' )
584
? ''
585
: __( 'YITH WooCommerce Advanced Reviews is available in an outstanding PREMIUM version with many new options, discover it now.', 'yith-woocommerce-advanced-reviews' ) .
586
' <a href="' . $this->get_premium_landing_uri() . '">' . __( 'Premium version', 'yith-woocommerce-advanced-reviews' ) . '</a>';
587
-
588
$args[] = array(
589
'screen_id' => 'plugins',
590
'pointer_id' => 'yith_ywar_panel',
@@ -596,7 +584,7 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
596
'position' => array( 'edge' => 'left', 'align' => 'center' ),
597
'init' => defined( 'YITH_YWAR_PREMIUM' ) ? YITH_YWAR_INIT : YITH_YWAR_FREE_INIT,
598
);
599
-
600
$args[] = array(
601
'screen_id' => 'update',
602
'pointer_id' => 'yith_ywar_panel',
@@ -608,10 +596,10 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
608
'position' => array( 'edge' => 'left', 'align' => 'center' ),
609
'init' => defined( 'YITH_YWAR_PREMIUM' ) ? YITH_YWAR_INIT : YITH_YWAR_FREE_INIT,
610
);
611
-
612
YIT_Pointers()->register( $args );
613
}
614
-
615
/**
616
* Get the premium landing uri
617
*
@@ -622,7 +610,7 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
622
public function get_premium_landing_uri() {
623
return defined( 'YITH_REFER_ID' ) ? $this->_premium_landing . '?refer_id=' . YITH_REFER_ID : $this->_premium_landing . '?refer_id=1030585';
624
}
625
-
626
/**
627
* Add a panel under YITH Plugins tab
628
*
@@ -633,22 +621,22 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
633
* @see plugin-fw/lib/yit-plugin-panel.php
634
*/
635
public function register_panel() {
636
-
637
if ( ! empty( $this->_panel ) ) {
638
return;
639
}
640
-
641
$admin_tabs = array(
642
'general' => __( 'General', 'yith-woocommerce-advanced-reviews' ),
643
'layout' => __( 'Layout', 'yith-woocommerce-advanced-reviews' ),
644
);
645
-
646
if ( defined( 'YITH_YWAR_PREMIUM' ) ) {
647
$admin_tabs['premium'] = __( 'Voting/Review settings', 'yith-woocommerce-advanced-reviews' );
648
} else {
649
$admin_tabs['premium-landing'] = __( 'Premium Version', 'yith-woocommerce-advanced-reviews' );
650
}
651
-
652
$args = array(
653
'create_menu_page' => true,
654
'parent_slug' => '',
@@ -661,15 +649,15 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
661
'admin-tabs' => $admin_tabs,
662
'options-path' => YITH_YWAR_DIR . '/plugin-options',
663
);
664
-
665
/* === Fixed: not updated theme === */
666
if ( ! class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
667
require_once( 'plugin-fw/lib/yit-plugin-panel-wc.php' );
668
}
669
-
670
$this->_panel = new YIT_Plugin_Panel_WooCommerce( $args );
671
}
672
-
673
/**
674
* Premium Tab Template
675
*
@@ -686,11 +674,8 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
686
include_once( $premium_tab_template );
687
}
688
}
689
-
690
- //endregion
691
-
692
- //region *********** Add stylesheets and scripts files ************
693
-
694
/**
695
* Add scripts
696
*
@@ -700,13 +685,13 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
700
public function enqueue_scripts() {
701
// register and enqueue ajax calls related script file
702
wp_register_script( "attachments-script", YITH_YWAR_URL . 'assets/js/ywar-attachments.js', array( 'jquery' ) );
703
-
704
wp_localize_script( 'attachments-script', 'attach', array(
705
'limit_multiple_upload' => $this->attachments_limit,
706
) );
707
wp_enqueue_script( 'attachments-script' );
708
}
709
-
710
/**
711
* Enqueue css file
712
*
@@ -716,7 +701,7 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
716
public function enqueue_styles() {
717
wp_enqueue_style( 'yit-style', YITH_YWAR_ASSETS_URL . '/css/yit-advanced-reviews.css' );
718
}
719
-
720
/**
721
* Enqueue scripts on administration comment page
722
*
@@ -726,35 +711,32 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
726
if ( 'toplevel_page_Reviews' != get_current_screen()->id ) {
727
return;
728
}
729
-
730
/** Add Woocommerce.css file */
731
$styles = (array) WC_Frontend_Scripts::get_styles();
732
-
733
if ( array_key_exists( 'woocommerce-general', $styles ) ) {
734
wp_enqueue_style( 'woocommerce-general', $styles['woocommerce-general']['src'] );
735
}
736
-
737
wp_enqueue_style( 'yit-style', YITH_YWAR_ASSETS_URL . '/css/yit-advanced-reviews.css' );
738
-
739
wp_register_script( "ajax-back-end-script", YITH_YWAR_URL . 'assets/js/ywar-back-end.js', array(
740
'jquery',
741
'jquery-blockui',
742
) );
743
-
744
$loader = apply_filters( 'yith_advanced_reviews_loader_gif', YITH_YWAR_ASSETS_URL . '/images/loading.gif' );
745
-
746
wp_localize_script( 'ajax-back-end-script', 'ywar', array(
747
'loader' => $loader,
748
'ajax_url' => admin_url( 'admin-ajax.php' ),
749
) );
750
-
751
wp_enqueue_script( "ajax-back-end-script" );
752
}
753
-
754
- //endregion
755
-
756
- //region *********** Advanced reviews post type functionalities
757
-
758
/**
759
* Register advanced reviews post type
760
*/
@@ -777,7 +759,7 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
777
);
778
779
// Set other options for Custom Post Type
780
-
781
$args = array(
782
'label' => __( 'YIT Product reviews', 'yith-woocommerce-advanced-reviews' ),
783
'description' => __( 'Advanced WooCommerce product reviews', 'yith-woocommerce-advanced-reviews' ),
@@ -810,11 +792,11 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
810
811
// Registering your Custom Post Type
812
register_post_type( $this->post_type_name, $args );
813
-
814
-
815
}
816
-
817
-
818
/**
819
* Default query arguments to be used where querying to review custom post type
820
*
@@ -848,27 +830,27 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
848
),
849
);
850
}
851
-
852
/**
853
* Retrieve reviews for a product
854
*
855
* @param $product_id product id for whose retrieve the reviews
856
*/
857
public function get_product_reviews( $product_id = null, $args = null ) {
858
-
859
if ( $args == null ) {
860
$args = $this->default_query_args( $product_id );
861
}
862
-
863
// if $product_id is null, retrieve all reviews without filters
864
if ( is_null( $product_id ) ) {
865
unset( $args['meta_query'] );
866
}
867
-
868
return get_posts( $args );
869
}
870
-
871
-
872
/**
873
* Return the number of reviews for a specific product
874
*
@@ -884,11 +866,11 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
884
'type' => 'numeric',
885
);
886
}
887
-
888
return $this->get_product_reviews( $product_id, $args );
889
}
890
-
891
-
892
/**
893
* Show the reviews for a specific product
894
*
@@ -896,12 +878,12 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
896
*/
897
public function reviews_list( $product_id, $args = null ) {
898
$reviews = $this->get_product_reviews( $product_id, $args );
899
-
900
foreach ( $reviews as $review ) {
901
$this->show_review( $review );
902
}
903
}
904
-
905
/**
906
* Call the review template and show the review
907
*
@@ -916,9 +898,8 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
916
'classes' => $classes,
917
), '', YITH_YWAR_TEMPLATES_DIR );
918
}
919
-
920
- //endregion
921
-
922
/**
923
* Initialize plugin options
924
*
@@ -933,7 +914,7 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
933
$this->enable_attachments = get_option( 'ywar_enable_attachments' ) === 'yes';
934
$this->attachments_limit = get_option( 'ywar_max_attachments' );
935
}
936
-
937
/**
938
* Return the right path to the reviews template file
939
*
@@ -942,15 +923,15 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
942
* @return mixed|void new template path, only for product comments page
943
*/
944
public function show_advanced_reviews_template( $template ) {
945
-
946
if ( get_post_type() === 'product' ) {
947
// return apply_filters( 'ywar_show_advanced_reviews_template', YITH_YWAR_TEMPLATES_DIR . "ywar-product-reviews.php" );
948
return wc_locate_template( "ywar-product-reviews.php", '', YITH_YWAR_TEMPLATES_DIR );
949
}
950
-
951
return $template;
952
}
953
-
954
/**
955
* Create new Advanced Review post type when a comment is saved to database
956
*
@@ -961,13 +942,13 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
961
if ( ! isset( $_POST ) ) {
962
return;
963
}
964
-
965
$review_title = $this->enable_title && isset( $_POST["title"] ) ? wp_strip_all_tags( $_POST["title"] ) : '';
966
-
967
$post_parent = apply_filters( 'yith_advanced_reviews_post_parent', $_POST["comment_parent"] );
968
-
969
$comment = get_comment( $comment_id );
970
-
971
// Create post object
972
$my_post = array(
973
'post_author' => $comment->user_id,
@@ -987,13 +968,13 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
987
'review_author_IP' => $comment->comment_author_IP,
988
'review_author_url' => $comment->comment_author_url,
989
);
990
-
991
// Insert the post into the database
992
$review_id = $this->insert_review( $my_post );
993
-
994
$this->submit_attachments( $review_id );
995
}
996
-
997
public function insert_review( $args ) {
998
// Create post object
999
$defaults = array(
@@ -1021,53 +1002,53 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
1021
'review_author_url' => '',
1022
'review_author_IP' => '',
1023
);
1024
-
1025
$args = wp_parse_args( $args, $defaults );
1026
-
1027
// Insert the post into the database
1028
$review_id = wp_insert_post( $args );
1029
-
1030
// Set rating only for top level reviews, not for replies
1031
if ( 0 != $args["post_parent"] ) {
1032
update_post_meta( $review_id, $this->meta_key_rating, 0 );
1033
} else {
1034
update_post_meta( $review_id, $this->meta_key_rating, $args["review_rating"] );
1035
}
1036
-
1037
update_post_meta( $review_id, $this->meta_key_rating, $args["review_rating"] );
1038
update_post_meta( $review_id, $this->meta_key_approved, $args["review_approved"] );
1039
update_post_meta( $review_id, $this->meta_key_product_id, $args["review_product_id"] );
1040
update_post_meta( $review_id, $this->meta_key_comment_id, $args["review_comment_id"] );
1041
update_post_meta( $review_id, $this->meta_key_thumb_ids, $args["review_thumbnails"] );
1042
-
1043
update_post_meta( $review_id, $this->meta_key_upvotes_count, $args["review_upvotes"] );
1044
update_post_meta( $review_id, $this->meta_key_downvotes_count, $args["review_downvotes"] );
1045
update_post_meta( $review_id, $this->meta_key_votes, $args["review_votes"] );
1046
-
1047
update_post_meta( $review_id, $this->meta_key_inappropriate_list, $args["review_inappropriate_list"] );
1048
update_post_meta( $review_id, $this->meta_key_inappropriate_count, $args["review_inappropriate_count"] );
1049
update_post_meta( $review_id, $this->meta_key_featured, $args["review_is_featured"] );
1050
update_post_meta( $review_id, $this->meta_key_stop_reply, $args["review_is_reply_blocked"] );
1051
-
1052
update_post_meta( $review_id, $this->meta_key_review_user_id, $args["review_user_id"] );
1053
update_post_meta( $review_id, $this->meta_key_review_author, $args["review_author"] );
1054
update_post_meta( $review_id, $this->meta_key_review_author_email, $args["review_author_email"] );
1055
update_post_meta( $review_id, $this->meta_key_review_author_url, $args["review_author_url"] );
1056
update_post_meta( $review_id, $this->meta_key_review_author_IP, $args["review_author_IP"] );
1057
-
1058
return $review_id;
1059
}
1060
-
1061
/**
1062
* redirect to product page on comment submitted
1063
*/
1064
public function redirect_after_submit_review( $location, $comment ) {
1065
// Set the new comment as imported so it will not imported when clicking on "convert reviews", creating duplicated entries
1066
update_comment_meta( $comment->comment_ID, $this->meta_key_imported, 1 );
1067
-
1068
return get_permalink( $comment->comment_post_ID );
1069
}
1070
-
1071
/**
1072
* Add custom field "Title" on top of comment form
1073
*
@@ -1079,18 +1060,17 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
1079
* @author Lorenzo Giuffrida
1080
*/
1081
public function add_custom_fields_on_comment_form() {
1082
-
1083
if ( ! is_product() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
1084
return;
1085
}
1086
-
1087
if ( $this->enable_title ) {
1088
echo '<p class="comment-form-title"><label for="title">' . __( 'Review title', 'yith-woocommerce-advanced-reviews' ) . '</label><input type="text" name="title" id="title"/></p>';
1089
}
1090
}
1091
-
1092
- //region *********** attachments ********************
1093
-
1094
/**
1095
* Submit attachments from a comment form
1096
*
@@ -1108,18 +1088,18 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
1108
if ( ! $this->enable_attachments ) {
1109
return;
1110
}
1111
-
1112
if ( $_FILES ) {
1113
$files = $_FILES["ywar-uploadFile"];
1114
$files_count = count( $files['name'] );
1115
-
1116
// check for attachments limits
1117
if ( ( $this->attachments_limit > 0 ) && ( $files_count > $this->attachments_limit ) ) {
1118
return;
1119
}
1120
-
1121
$attacchments_array = array();
1122
-
1123
foreach ( $files['name'] as $key => $value ) {
1124
if ( $files['name'][ $key ] ) {
1125
$file = array(
@@ -1130,21 +1110,21 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
1130
'size' => $files['size'][ $key ],
1131
);
1132
$_FILES = array( "ywar-uploadFile" => $file );
1133
-
1134
foreach ( $_FILES as $file => $array ) {
1135
$attachId = $this->insert_attachment( $file, $review_id );
1136
-
1137
// enqueue attachments to current comment
1138
array_push( $attacchments_array, $attachId );
1139
}
1140
}
1141
}
1142
-
1143
// save review with attachments array
1144
update_post_meta( $review_id, $this->meta_key_thumb_ids, $attacchments_array );
1145
}
1146
}
1147
-
1148
/**
1149
* Add attachment to media library
1150
*
@@ -1160,14 +1140,14 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
1160
if ( $_FILES[ $fileHandler ]['error'] !== UPLOAD_ERR_OK ) {
1161
__return_false();
1162
}
1163
-
1164
require_once( ABSPATH . "wp-admin" . '/includes/image.php' );
1165
require_once( ABSPATH . "wp-admin" . '/includes/file.php' );
1166
require_once( ABSPATH . "wp-admin" . '/includes/media.php' );
1167
-
1168
return media_handle_upload( $fileHandler, $postId );
1169
}
1170
-
1171
/**
1172
* Append attachment fields on comment form
1173
*
@@ -1180,11 +1160,11 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
1180
*/
1181
public function add_fields_to_comment_form( $comment_form ) {
1182
$current_content = $comment_form['comment_field'];
1183
-
1184
// In case of a page refresh following a reply request, don't add additional fields
1185
$hide_rating = isset( $_REQUEST["replytocom"] ) ? "hide-rating" : '';
1186
$selected = isset( $_REQUEST["replytocom"] ) ? "selected" : '';
1187
-
1188
if ( get_option( 'woocommerce_enable_review_rating' ) === 'yes' ) {
1189
$comment_form['comment_field'] = '<p class="' . $hide_rating . ' comment-form-rating">
1190
<label for="rating">' . __( 'Your Rate', 'yith-woocommerce-advanced-reviews' ) . '</label>
@@ -1195,10 +1175,10 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
1195
<option value="3">' . __( 'Average', 'yith-woocommerce-advanced-reviews' ) . '</option>
1196
<option value="2">' . __( 'Not that bad', 'yith-woocommerce-advanced-reviews' ) . '</option>
1197
<option value="1" ' . $selected . '>' . __( 'Very Poor', 'yith-woocommerce-advanced-reviews' ) . '</option>';
1198
-
1199
$comment_form['comment_field'] .= '</select></p>' . $current_content;
1200
}
1201
-
1202
if ( $this->enable_attachments ) {
1203
$comment_form['comment_field'] .= '<p class="upload_section ' . $hide_rating . '" >
1204
<label for="ywar-uploadFile" > ' . __( 'Attachments', 'yith-woocommerce-advanced-reviews' ) . ' </label >
@@ -1209,12 +1189,11 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
1209
<ul id = "uploadFileList" ></ul>
1210
</p> ';
1211
}
1212
-
1213
return $comment_form;
1214
}
1215
-
1216
- //endregion
1217
-
1218
/**
1219
* Display a customized comment content
1220
*
@@ -1226,24 +1205,24 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
1226
* @author Lorenzo Giuffrida
1227
*/
1228
public function show_expanded_review_content( $review ) {
1229
-
1230
if ( ! is_product() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
1231
return $review->post_content;
1232
}
1233
-
1234
$review_title = '';
1235
$thumbnail_div = $this->get_thumbnails( $review );
1236
-
1237
if ( $this->enable_title ) {
1238
// Add review title before review content text
1239
if ( ! empty( $review->post_title ) ) {
1240
$review_title = '<span class="review_title"> ' . esc_attr( $review->post_title ) . '</span> ';
1241
}
1242
}
1243
-
1244
return apply_filters( "yith_advanced_reviews_review_content_elements", $review_title . $review->post_content . $thumbnail_div, $review_title, $review->post_content, $thumbnail_div );
1245
}
1246
-
1247
/**
1248
* Get an HTML formatted attachment section
1249
*
@@ -1254,26 +1233,26 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
1254
public function get_thumbnails( $review ) {
1255
$is_toplevel = ( 0 == $review->post_parent );
1256
$thumbnail_div = '';
1257
-
1258
if ( $is_toplevel && $this->enable_attachments ) {
1259
-
1260
if ( $thumbs = get_post_meta( $review->ID, $this->meta_key_thumb_ids, true ) ) {
1261
-
1262
$thumbnail_div = '<div class="review_thumbnail horizontalRule"> ';
1263
-
1264
foreach ( $thumbs as $thumb_id ) {
1265
$file_url = wp_get_attachment_url( $thumb_id );
1266
$image_thumb = wp_get_attachment_image_src( $thumb_id, array( 100, 100 ), true );
1267
-
1268
$thumbnail_div .= "<a href='$file_url' data-rel = \"prettyPhoto[review-gallery-$review->ID]\"><img class=\"ywar_thumbnail\" src='{$image_thumb[0]}' width='70px' height='70px'></a>";
1269
}
1270
$thumbnail_div .= ' </div> ';
1271
}
1272
}
1273
-
1274
return $thumbnail_div;
1275
}
1276
-
1277
/**
1278
* Alter text on tab reviews, fixing wrong count of reviews(even replies to reviews were used
1279
*
@@ -1283,15 +1262,15 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
1283
*/
1284
public function update_tab_reviews_count( $tabs ) {
1285
global $product;
1286
-
1287
if ( isset( $tabs['reviews'] ) ) {
1288
$product_id = yit_get_prop( $product, 'id' );
1289
$tabs['reviews']['title'] = sprintf( __( 'Reviews(%d)', 'yith-woocommerce-advanced-reviews' ), count( $this->get_product_reviews_by_rating( $product_id ) ) );
1290
}
1291
-
1292
return $tabs;
1293
}
1294
-
1295
/**
1296
* Collect data about reviews rating and show a summary grouped by stars
1297
*
@@ -1306,10 +1285,10 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
1306
if ( ! is_product() ) {
1307
return $template;
1308
}
1309
-
1310
global $product;
1311
global $review_stats;
1312
-
1313
$product_id = yit_get_prop( $product, 'id' );
1314
$review_stats = array(
1315
'1' => count( $this->get_product_reviews_by_rating( $product_id, 1 ) ),
@@ -1319,10 +1298,10 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
1319
'5' => count( $this->get_product_reviews_by_rating( $product_id, 5 ) ),
1320
'total' => count( $this->get_product_reviews_by_rating( $product_id ) ),
1321
);
1322
-
1323
wc_get_template( 'ywar-single-product-reviews.php', null, '', YITH_YWAR_TEMPLATES_DIR );
1324
}
1325
-
1326
/**
1327
* Add a metabox on review page for review's title
1328
*
@@ -1337,7 +1316,7 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
1337
'display_plugin_metabox',
1338
), $this->post_type_name, 'normal', 'high' );
1339
}
1340
-
1341
/**
1342
* Display a meta box with additional review data, like title and thumbnails
1343
*
@@ -1348,10 +1327,10 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
1348
*/
1349
public function display_plugin_metabox() {
1350
global $post;
1351
-
1352
$rating_div = '';
1353
$thumbnail_div = '';
1354
-
1355
$current = get_post_meta( $post->ID, $this->meta_key_rating, true );
1356
?>
1357
<select name="rating" id="rating">
@@ -1359,29 +1338,29 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
1359
echo sprintf( '<option value="%1$s"%2$s>%1$s</option>', $rating, selected( $current, $rating, false ) );
1360
} ?>
1361
</select>
1362
-
1363
<?php
1364
// Generate a hidden nonce used for verifying if a request to update the following values came from here
1365
echo '<input type="hidden" name="review_metabox_nonce" id="review_metabox_nonce" value="' .
1366
wp_create_nonce( plugin_basename( __FILE__ ) ) . '" />';
1367
-
1368
$review_thumbnails = get_post_meta( $post->ID, $this->meta_key_thumb_ids, true );
1369
-
1370
if ( isset ( $review_thumbnails ) && is_array( $review_thumbnails ) ) {
1371
$thumbnail_div = '<div style = "padding-top: 10px;padding-bottom: 10px;overflow:hidden"> ';
1372
foreach ( $review_thumbnails as $thumb_id ) {
1373
$file_url = wp_get_attachment_url( $thumb_id );
1374
// $image_thumb = wp_get_attachment_image($thumb_id, array(100, 100), true );
1375
$image_thumb = wp_get_attachment_image_src( $thumb_id, array( 100, 100 ), true );
1376
-
1377
$thumbnail_div .= "<a href='$file_url'><img src='{$image_thumb[0]}' width='{$image_thumb[1]}' height='{$image_thumb[2]}'></a>";
1378
}
1379
$thumbnail_div .= '</div >';
1380
}
1381
-
1382
echo $thumbnail_div;
1383
}
1384
-
1385
/**
1386
* Save the Metabox Data
1387
*
@@ -1391,42 +1370,42 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
1391
* @return mixed
1392
*/
1393
function save_plugin_metabox( $post_id, $post ) {
1394
-
1395
if ( ! isset( $_POST['review_metabox_nonce'] ) ) {
1396
return $post->ID;
1397
}
1398
-
1399
// verify the save request started from review edit page...
1400
if ( ! wp_verify_nonce( $_POST['review_metabox_nonce'], plugin_basename( __FILE__ ) ) ) {
1401
return $post->ID;
1402
}
1403
-
1404
// Check for authorization
1405
if ( ! current_user_can( 'edit_post', $post->ID ) ) {
1406
return $post->ID;
1407
}
1408
-
1409
// OK, we're authenticated: we need to find and save the data
1410
// We'll put it into an array to make it easier to loop though.
1411
if ( isset( $_POST['rating'] ) ) {
1412
$rating = $_POST['rating'];
1413
-
1414
if ( is_numeric( $rating ) && ( $rating > 0 ) && ( $rating <= 5 ) ) {
1415
update_post_meta( $post_id, $this->meta_key_rating, $rating );
1416
}
1417
}
1418
}
1419
-
1420
/**
1421
* Remove features for the review custom post type
1422
*/
1423
public function remove_unwanted_custom_post_type_features() {
1424
global $submenu;
1425
-
1426
// Remove Add new for review custom post type
1427
unset( $submenu["edit.php?post_type={$this->post_type_name}"][10] );
1428
}
1429
-
1430
public function hide_unwanted_custom_post_type_features() {
1431
if ( $this->post_type_name == get_post_type() ) {
1432
echo '<style type="text/css">
@@ -1438,9 +1417,8 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
1438
</style>';
1439
}
1440
}
1441
-
1442
- //region ******* Retrieve postmeta values
1443
-
1444
/**
1445
* Retrieve value for the "rating" meta_key for a specific review
1446
*
@@ -1451,7 +1429,7 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
1451
function get_meta_value_rating( $review_id ) {
1452
return get_post_meta( $review_id, $this->meta_key_rating, true );
1453
}
1454
-
1455
/**
1456
* Retrieve value for the "approved" meta_key for a specific review
1457
*
@@ -1462,7 +1440,7 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
1462
function get_meta_value_approved( $review_id ) {
1463
return get_post_meta( $review_id, $this->meta_key_approved, true );
1464
}
1465
-
1466
/**
1467
* Retrieve value for the "product_id" meta_key for a specific review
1468
*
@@ -1473,7 +1451,7 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
1473
function get_meta_value_product_id( $review_id ) {
1474
return get_post_meta( $review_id, $this->meta_key_product_id, true );
1475
}
1476
-
1477
/**
1478
* Retrieve information about the review author
1479
*
@@ -1490,46 +1468,44 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
1490
'review_author_IP' => get_post_meta( $review_id, $this->meta_key_review_author_IP, true ),
1491
);
1492
}
1493
-
1494
- //endregion
1495
-
1496
public function wc_get_template( $located, $template_name, $args, $template_path, $default_path ) {
1497
if ( "single-product/rating.php" != $template_name ) {
1498
return $located;
1499
}
1500
-
1501
$located = wc_locate_template( "ywar-rating.php", $template_path, $default_path );
1502
-
1503
if ( file_exists( $located ) ) {
1504
return $located;
1505
}
1506
-
1507
return YITH_YWAR_TEMPLATES_DIR . 'ywar-rating.php';
1508
}
1509
-
1510
public function get_product_rating_html( $rating_html, $rating ) {
1511
global $product;
1512
$rating_html = '';
1513
-
1514
if ( ! $product ) {
1515
return $rating_html;
1516
}
1517
$rating = $this->get_average_rating( yit_get_prop( $product, 'id' ) );
1518
-
1519
if ( $rating > 0 ) {
1520
-
1521
$rating_html = '<div class="star-rating" title="' . sprintf( __( 'Rated %s out of 5', 'yith-woocommerce-advanced-reviews' ), $rating ) . '">';
1522
-
1523
$rating_html .= '<span style="width:' . ( ( $rating / 5 ) * 100 ) . '%"><strong class="rating">' . $rating . '</strong> ' . __( 'out of 5', 'yith-woocommerce-advanced-reviews' ) . '</span>';
1524
-
1525
$rating_html .= '</div>';
1526
}
1527
-
1528
return $rating_html;
1529
}
1530
-
1531
- //region *********** Convert reviews from standard system to YITH Advanced reviews
1532
-
1533
/**
1534
* Show import button for starting convertion from standard system to YITH Advanced reviews
1535
*
@@ -1540,18 +1516,18 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
1540
$args['value'] = ( get_option( $args['id'] ) ) ? get_option( $args['id'] ) : '';
1541
extract( $args );
1542
}
1543
-
1544
?>
1545
<tr valign="top">
1546
<th scope="row">
1547
-
1548
</th>
1549
-
1550
<td class="forminp forminp-color plugin-option">
1551
<div class="convert-reviews">
1552
<a href="<?php echo esc_url( add_query_arg( "convert-reviews", "start" ) ); ?>"
1553
class="button convert-reviews"><?php _e( "Convert reviews", "yith-woocommerce-advanced-reviews" ); ?></a>
1554
-
1555
<div style="display: inline-block; width: 65%; margin-left: 15px;"><span
1556
class="description"><?php _e( "If this is the first time you install the YITH Advanced Reviews plugin, or if you are using an older version prior to the 1.1.0, first you have to convert the older reviews if you want to use them.", "yith-woocommerce-advanced-reviews" ); ?></span>
1557
</div>
@@ -1560,7 +1536,7 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
1560
</tr>
1561
<?php
1562
}
1563
-
1564
/**
1565
* Convert previous reviews into new YITH Advanced review type
1566
*
@@ -1568,19 +1544,19 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
1568
* @author Lorenzo Giuffrida
1569
*/
1570
public function convert_reviews_callback() {
1571
-
1572
$review_converted = $this->import_previous_reviews();
1573
$response = '';
1574
-
1575
if ( $review_converted ) {
1576
$response = sprintf( __( 'Task completed. %d reviews have been processed and converted.', 'yith-woocommerce-advanced-reviews' ), $review_converted );
1577
} else {
1578
$response = __( 'Task completed. No review to convert has been found.', 'yith-woocommerce-advanced-reviews' );
1579
}
1580
-
1581
wp_send_json( array( "value" => $response ) );
1582
}
1583
-
1584
/**
1585
* Set a maximum execution time
1586
*
@@ -1592,32 +1568,32 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
1592
@set_time_limit( $seconds );
1593
}
1594
}
1595
-
1596
/**
1597
* Read and convert previous reviews into new advanced reviews using custom post type
1598
*/
1599
public function import_previous_reviews() {
1600
global $wpdb;
1601
-
1602
$review_converted = 0;
1603
-
1604
$query = "SELECT *
1605
FROM {$wpdb->prefix}comments as co left join {$wpdb->prefix}commentmeta as cm
1606
on co.comment_ID = cm.comment_id
1607
where ((co.comment_approved = '0') or (co.comment_approved = '1')) and cm.meta_key = 'rating'";
1608
-
1609
$results = $wpdb->get_results( $query );
1610
-
1611
// manage parent relationship and update all reviews when import ends
1612
$review_ids = array();
1613
$parent_review = array();
1614
-
1615
foreach ( $results as $comment ) {
1616
-
1617
// Check if comment_meta exists for previous reviews and is not still imported
1618
if ( "1" === get_comment_meta( $comment->comment_ID, $this->meta_key_imported, true ) ) {
1619
// comment still imported, update only author data (Fix for upgrade from 1.1.2 to 1.2.3 then skip it!
1620
-
1621
// Retrieve review(post) id linked to current comment
1622
$args = array(
1623
'post_type' => 'ywar_reviews',
@@ -1631,10 +1607,10 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
1631
),
1632
);
1633
$reviews = get_posts( $args );
1634
-
1635
if ( ! empty( $reviews ) ) {
1636
$review = $reviews[0];
1637
-
1638
// Update review meta
1639
update_post_meta( $review->ID, $this->meta_key_review_user_id, $comment->user_id );
1640
update_post_meta( $review->ID, $this->meta_key_review_author, $comment->comment_author );
@@ -1642,35 +1618,35 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
1642
update_post_meta( $review->ID, $this->meta_key_review_author_url, $comment->comment_author_url );
1643
update_post_meta( $review->ID, $this->meta_key_review_author_IP, $comment->comment_author_IP );
1644
}
1645
-
1646
continue;
1647
}
1648
-
1649
// Set execution time
1650
$this->set_time_limit( 30 );
1651
-
1652
$val = get_comment_meta( $comment->comment_ID, "title", true );
1653
$title = $val ? $val : '';
1654
-
1655
$val = get_comment_meta( $comment->comment_ID, "thumb_ids", true );
1656
$thumb_ids = $val ? $val : array();
1657
-
1658
$val = get_comment_meta( $comment->comment_ID, "rating", true );
1659
$rating = $val ? $val : 0;
1660
-
1661
// Import previous settings for "stop reply" from the comment
1662
$val = get_comment_meta( $comment->comment_ID, "no_reply", true );
1663
$no_reply = $val ? $val : 0;
1664
-
1665
// Import previous settings for "votes" from the comment
1666
$val = get_comment_meta( $comment->comment_ID, "votes", true );
1667
$votes = $val ? $val : array();
1668
-
1669
// Extract upvotes and downvotes count
1670
$votes_grouped = array_count_values( array_values( $votes ) );
1671
$yes_votes = isset( $votes_grouped['1'] ) && is_numeric( $votes_grouped['1'] ) ? $votes_grouped['1'] : 0;
1672
$no_votes = isset( $votes_grouped['-1'] ) && is_numeric( $votes_grouped['-1'] ) ? $votes_grouped['-1'] : 0;
1673
-
1674
// Create post object
1675
$args = array(
1676
'post_author' => $comment->user_id,
@@ -1693,51 +1669,50 @@ if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
1693
'review_author_url' => $comment->comment_author_url,
1694
'review_author_IP' => $comment->comment_author_IP,
1695
);
1696
-
1697
// Insert the post into the database
1698
$review_id = $this->insert_review( $args );
1699
-
1700
$review_ids[ $comment->comment_ID ] = $review_id;
1701
-
1702
// If current comment have parent, store it and update all relationship when the import ends
1703
if ( $comment->comment_parent > 0 ) {
1704
$parent_review[ $review_id ] = $comment->comment_parent;
1705
}
1706
-
1707
// set current comment as imported
1708
update_comment_meta( $comment->comment_ID, $this->meta_key_imported, 1 );
1709
$review_converted ++;
1710
}
1711
-
1712
// if some hierarchical comment was found, update the review created
1713
foreach ( $parent_review as $key => $value ) {
1714
if ( isset( $review_ids[ $value ] ) ) {
1715
-
1716
//update the post which id is in $key, setting parent to $review_ids[$value]
1717
$args = array(
1718
'ID' => $key,
1719
'post_parent' => $review_ids[ $value ],
1720
);
1721
-
1722
// Update the post into the database
1723
wp_update_post( $args );
1724
}
1725
}
1726
-
1727
return $review_converted;
1728
}
1729
-
1730
/**
1731
* On plugin init check query vars for commands to convert previous reviews
1732
*/
1733
function check_import_actions() {
1734
if ( isset( $_GET["convert-reviews"] ) ) {
1735
-
1736
$this->import_previous_reviews();
1737
-
1738
wp_redirect( esc_url( remove_query_arg( "convert-reviews" ) ) );
1739
}
1740
}
1741
- //endregion
1742
}
1743
}
4
}
5
6
if ( ! class_exists( 'YITH_WooCommerce_Advanced_Reviews' ) ) {
7
+
8
/**
9
* Implements features of FREE version of YWAR plugin
10
*
18
* @var $_panel Panel Object
19
*/
20
protected $_panel;
21
+
22
/**
23
* @var $_premium string Premium tab template file name
24
*/
25
protected $_premium = 'premium.php';
26
+
27
/**
28
* @var string Premium version landing link
29
*/
30
protected $_premium_landing = 'http://yithemes.com/themes/plugins/yith-woocommerce-advanced-reviews/';
31
+
32
/**
33
* @var string Plugin official documentation
34
*/
35
protected $_official_documentation = 'http://yithemes.com/docs-plugins/yith-woocommerce-advanced-reviews/';
36
+
37
/**
38
* @var string Advanced Reviews panel page
39
*/
40
protected $_panel_page = 'yith_ywar_panel';
41
+
42
/**
43
* @var $enable_title Let users to add a title when writing a review
44
*/
45
protected $enable_title = 0;
46
+
47
/**
48
* @var $enable_attachments Let users to add attachments when submit a review
49
*/
50
protected $enable_attachments = 0;
51
+
52
/**
53
* @var $attachments_limit Set the maximum number of attachments a users can add when submit a review
54
*/
55
protected $attachments_limit = 0;
56
+
57
public $post_type_name = "ywar_reviews";
58
+
59
public $items_for_page = 10;
60
+
61
public $meta_key_rating = "_ywar_rating";
62
public $meta_key_product_id = "_ywar_product_id";
63
public $meta_key_imported = "_ywar_imported";
64
public $meta_key_approved = "_ywar_approved";
65
public $meta_key_thumb_ids = "_ywar_thumb_ids";
66
public $meta_key_comment_id = "_ywar_comment_id";
67
+
68
/**
69
* @var string meta_key used for saving data about segnalation of inappropriate content from users
70
*/
71
public $meta_key_inappropriate_list = "_ywar_inappropriate_list";
72
+
73
/**
74
* @var string meta_key used for saving data about inappropriate reviews
75
*/
76
public $meta_key_inappropriate_count = "_ywar_inappropriate_count";
77
+
78
/**
79
* @var string meta_key used for saving data about inappropriate reviews
80
*/
81
public $meta_key_featured = "_ywar_featured";
82
+
83
/**
84
* @var string meta_key used for saving data about upvotes
85
*/
86
public $meta_key_upvotes_count = "_ywar_upvotes_count";
87
+
88
/**
89
* @var string meta_key used for saving data about downvotes
90
*/
91
public $meta_key_downvotes_count = "_ywar_downvotes_count";
92
+
93
/**
94
* @var string meta_key used for saving data about reviews votes
95
*/
96
public $meta_key_votes = "_ywar_votes";
97
+
98
/**
99
* @var string meta_key used for saving data about replies status
100
*/
101
public $meta_key_stop_reply = "_ywar_stop_reply";
102
+
103
/**
104
* @var string meta_key used for saving review's user id
105
*/
106
public $meta_key_review_user_id = "_ywar_review_user_id";
107
+
108
/**
109
* @var string meta_key used for saving review's author
110
*/
111
public $meta_key_review_author = "_ywar_review_author";
112
+
113
/**
114
* @var string meta_key used for saving review author's email
115
*/
116
public $meta_key_review_author_email = "_ywar_review_author_email";
117
+
118
/**
119
* @var string meta_key used for saving review author's url
120
*/
121
public $meta_key_review_author_url = "_ywar_review_author_url";
122
+
123
/**
124
* @var string meta_key used for saving review author's IP
125
*/
126
public $meta_key_review_author_IP = "_ywar_review_author_IP";
127
+
128
public $custom_column_review = "review-text";
129
+
130
public $custom_column_rating = "review-rating";
131
+
132
public $custom_column_date = "review-date";
133
+
134
public $custom_column_author = "review-author";
135
+
136
public $custom_column_product = "product";
137
+
138
/**
139
* @var string action name for "approve" review
140
*/
141
protected $approve_review_action = "approve-review";
142
+
143
/**
144
* @var string action name for "untrash" review
145
*/
146
protected $untrash_review_action = "untrash";
147
+
148
/**
149
* @var string action name for "unapprove" review
150
*/
151
protected $unapprove_review_action = "unapprove-review";
152
+
153
/**
154
* Single instance of the class
155
*
156
* @since 1.0.0
157
*/
158
protected static $instance;
159
+
160
/**
161
* Returns single instance of the class
162
*
166
if ( is_null( self::$instance ) ) {
167
self::$instance = new self();
168
}
169
+
170
return self::$instance;
171
}
172
+
173
/**
174
* Constructor
175
*
182
if ( ! function_exists( 'WC' ) ) {
183
return;
184
}
185
+
186
add_action( 'admin_menu', array( $this, 'add_menu_item' ) );
187
+
188
add_action( 'init', array( $this, 'initialize_settings' ) );
189
+
190
+
191
// Load Plugin Framework
192
add_action( 'plugins_loaded', array( $this, 'plugin_fw_loader' ), 15 );
193
+
194
+
195
// Add row meta
196
add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 4 );
197
+
198
// Add stylesheets and scripts files
199
add_action( 'admin_menu', array( $this, 'register_panel' ), 5 );
200
+
201
// register plugin pointer
202
add_action( 'admin_init', array( $this, 'register_pointer' ) );
203
+
204
// verify import reviews action request
205
add_action( "admin_init", array( $this, "check_import_actions" ) );
206
+
207
//Add action links
208
add_filter( 'plugin_action_links_' . plugin_basename( YITH_YWAR_DIR . '/' . basename( YITH_YWAR_FILE ) ), array(
209
$this,
210
'action_links'
211
) );
212
+
213
add_action( 'yith_advanced_reviews_premium', array( $this, 'premium_tab' ) );
214
+
215
+
216
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
217
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) );
218
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles_scripts' ) );
219
+
220
+
221
add_action( 'init', array( $this, 'register_post_type' ) );
222
+
223
+
224
add_filter( 'yith_advanced_reviews_row_actions', array( $this, 'add_review_actions' ), 10, 2 );
225
+
226
add_filter( 'post_class', array( $this, 'add_review_table_class' ), 10, 3 );
227
+
228
/**
229
* intercept approve and unapprove actions
230
*/
231
add_action( "admin_action_{$this->approve_review_action}", array( $this, 'update_review_attributes' ) );
232
add_action( "admin_action_{$this->unapprove_review_action}", array( $this, 'update_review_attributes' ) );
233
add_action( "admin_action_{$this->untrash_review_action}", array( $this, 'update_review_attributes' ) );
234
+
235
+
236
// Load reviews template
237
add_filter( 'comments_template', array( $this, 'show_advanced_reviews_template' ), 99 );
238
+
239
// Save additional comment fields on comment submit
240
add_action( 'comment_post', array( $this, 'submit_review' ) );
241
+
242
// redirect to product page on comment submitted
243
add_filter( 'comment_post_redirect', array( $this, 'redirect_after_submit_review' ), 10, 2 );
244
+
245
add_filter( 'woocommerce_product_review_comment_form_args', array( $this, 'add_fields_to_comment_form' ) );
246
+
247
// Add custom fields "Title" on top of comment form
248
add_action( 'comment_form_logged_in_after', array( $this, 'add_custom_fields_on_comment_form' ) );
249
add_action( 'comment_form_after_fields', array( $this, 'add_custom_fields_on_comment_form' ) );
250
+
251
add_filter( 'yith_advanced_reviews_review_content', array( $this, 'show_expanded_review_content' ) );
252
+
253
add_filter( 'woocommerce_product_tabs', array( $this, 'update_tab_reviews_count' ), 20 );
254
+
255
/**
256
* Add summary bars for product rating
257
*/
258
add_action( 'yith_advanced_reviews_before_reviews', array( $this, 'load_reviews_summary' ) );
259
+
260
// Show details with average rating for the current product
261
add_action( 'ywar_summary_prepend', array( $this, 'add_reviews_average_info' ) );
262
+
263
add_filter( 'wc_get_template', array( $this, 'wc_get_template' ), 99, 5 );
264
+
265
add_filter( 'woocommerce_product_get_rating_html', array( $this, 'get_product_rating_html' ), 99, 2 );
266
+
267
// Add a new metabox for editing and saving title comment in meta_comment table
268
add_action( 'add_meta_boxes', array( $this, 'add_plugin_metabox' ), 1 );
269
+
270
// save the custom fields
271
add_action( 'save_post', array( $this, 'save_plugin_metabox' ), 1, 2 );
272
+
273
add_action( 'admin_menu', array( $this, 'remove_unwanted_custom_post_type_features' ), 5 );
274
add_action( 'admin_head', array( $this, 'hide_unwanted_custom_post_type_features' ) );
275
+
276
add_action( 'woocommerce_admin_field_ywar_import_previous_reviews', array(
277
$this,
278
'show_import_reviews_button'
279
), 10, 1 );
280
+
281
add_action( 'wp_ajax_convert_reviews', array( $this, 'convert_reviews_callback' ) );
282
}
283
+
284
/**
285
* Add the Commissions menu item in dashboard menu
286
*
290
* @see wp-admin\includes\plugin.php -> add_menu_page()
291
*/
292
public function add_menu_item() {
293
+
294
$args = apply_filters( 'yith_wc_product_vendors_commissions_menu_items', array(
295
'page_title' => __( 'Reviews', 'yith-woocommerce-advanced-reviews' ),
296
'menu_title' => __( 'Reviews', 'yith-woocommerce-advanced-reviews' ),
301
'position' => 8 /* After WC Products */
302
)
303
);
304
+
305
extract( $args );
306
+
307
add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon, $position );
308
}
309
+
310
/**
311
* Show the reviews table
312
*
319
if ( ! class_exists( 'WP_Posts_List_Table' ) ) {
320
require_once( ABSPATH . 'wp-admin/includes/class-wp-posts-list-table.php' );
321
}
322
+
323
require_once( YITH_YWAR_DIR . 'lib/class.yith-advanced-reviews-list-table.php' );
324
+
325
$product_reviews = new YITH_Advanced_Reviews_List_Table();
326
$product_reviews->prepare_items();
327
+
328
wc_get_template( 'ywar-product-reviews-table.php', array( 'product_reviews' => $product_reviews ), YITH_YWAR_TEMPLATES_DIR, YITH_YWAR_TEMPLATES_DIR );
329
}
330
+
331
/**
332
* Intercept review action url and do the requested job
333
*/
334
public function update_review_attributes() {
335
+
336
if ( ! isset( $_GET["review_id"] ) ) {
337
return;
338
}
339
+
340
$review_id = $_GET["review_id"];
341
+
342
$current_filter = current_filter();
343
+
344
switch ( $current_filter ) {
345
case "admin_action_{$this->approve_review_action}" :
346
update_post_meta( $review_id, $this->meta_key_approved, 1 );
347
+
348
break;
349
+
350
case "admin_action_{$this->unapprove_review_action}" :
351
update_post_meta( $review_id, $this->meta_key_approved, 0 );
352
+
353
break;
354
+
355
case "admin_action_{$this->untrash_review_action}" :
356
$my_post = array(
357
'ID' => $review_id,
358
'post_status' => 'publish',
359
);
360
+
361
// Update the post into the database
362
wp_update_post( $my_post );
363
+
364
break;
365
}
366
+
367
wp_redirect( esc_url_raw( remove_query_arg( array( 'action', 'action2' ), $_SERVER['HTTP_REFERER'] ) ) );
368
}
369
+
370
public function add_review_table_class( $classes, $class, $post_id ) {
371
+
372
if ( $this->post_type_name != get_post_type( $post_id ) ) {
373
return $classes;
374
}
375
+
376
unset( $classes["review-unapproved"] );
377
unset( $classes["review-approved"] );
378
+
379
$approve = get_post_meta( $post_id, $this->meta_key_approved, true );
380
+
381
if ( 1 == $approve ) {
382
$classes[] = "review-approved";
383
} elseif ( 0 == $approve ) {
384
$classes[] = "review-unapproved";
385
}
386
+
387
return apply_filters( 'yith_advanced_reviews_table_class', $classes, $post_id );
388
}
389
+
390
/**
391
* Build a url to be using as action url in row actions
392
*
398
public function review_action_url( $action, $post_id ) {
399
return admin_url( "admin.php?action=$action&post_type={$this->post_type_name}&review_id=$post_id" );
400
}
401
+
402
/**
403
* Build an "untrash" action url
404
*
409
public function untrash_review_url( $review ) {
410
return $this->review_action_url( $this->untrash_review_action, $review->ID );
411
}
412
+
413
/**
414
* Build an "approve" action url
415
*
420
public function approve_review_url( $review ) {
421
return $this->review_action_url( $this->approve_review_action, $review->ID );
422
}
423
+
424
/**
425
* Build an "unapprove" action url
426
*
431
public function unapprove_review_url( $review ) {
432
return $this->review_action_url( $this->unapprove_review_action, $review->ID );
433
}
434
+
435
public function add_review_actions( $actions, $post ) {
436
+
437
if ( $post->post_type != $this->post_type_name ) {
438
return $actions;
439
}
440
+
441
$approved = get_post_meta( $post->ID, $this->meta_key_approved, true );
442
+
443
unset( $actions['view'] );
444
unset( $actions['inline hide-if-no-js'] );
445
+
446
if ( ! $approved ) {
447
$actions['approve-review'] = '<a href="' . $this->approve_review_url( $post ) . '" title="' . esc_attr( __( 'Approve review', 'yith-woocommerce-advanced-reviews' ) ) . '" rel="permalink">' . __( 'Approve', 'yith-woocommerce-advanced-reviews' ) . '</a>';
448
} elseif ( $approved ) {
449
$actions['unapprove-review'] = '<a href="' . $this->unapprove_review_url( $post ) . '" title="' . esc_attr( __( 'Unapprove review', 'yith-woocommerce-advanced-reviews' ) ) . '" rel="permalink">' . __( 'Unapprove', 'yith-woocommerce-advanced-reviews' ) . '</a>';
450
}
451
+
452
return apply_filters( 'yith_advanced_reviews_review_actions', $actions, $post );
453
}
454
+
455
public function get_average_rating( $product_id ) {
456
global $wpdb;
457
+
458
$query = $wpdb->prepare( "
459
select avg(meta_value)
460
from {$wpdb->prefix}postmeta pm
461
where meta_key = '{$this->meta_key_rating}' and post_id in
462
(select post_id from {$wpdb->prefix}postmeta where meta_key = '{$this->meta_key_product_id}' and meta_value = %d and post_id IN
463
(select post_id from {$wpdb->prefix}postmeta where meta_key = '{$this->meta_key_approved}' and meta_value = 1))", $product_id );
464
+
465
$count = $wpdb->get_var( $query );
466
+
467
return number_format( $count, 2 );
468
}
469
+
470
/**
471
* @param WC_Product $product
472
*/
473
public function add_reviews_average_info( $product ) {
474
+
475
if ( get_option( 'woocommerce_enable_review_rating' ) === 'no' ) {
476
return;
477
}
478
+
479
$product_id = yit_get_prop( $product, 'id' );
480
$average = $this->get_average_rating( $product_id );
481
+
482
+ $count = count( $this->get_product_reviews_by_rating( $product_id ) );
483
+ $rated_text = sprintf( __( 'Rated %s out of 5 stars', 'yith-woocommerce-advanced-reviews' ), esc_html( $average ) );
484
+
485
+ if ( $count > 0 ) { ?>
486
+ <div class="woocommerce-product-rating">
487
+ <div class="star-rating" title="<?php $rated_text; ?>">
488
+ <span style="width:<?php echo( ( $average / 5 ) * 100 ); ?>%">
489
+ <span class="review-rating-value"><?php echo $rated_text; ?></span>
490
+ </span>
491
+ </div>
492
+ <span class="ywar_review_count"><?php printf( "%d %s", $count, _n( " review", " reviews", $count, 'yith-woocommerce-advanced-reviews' ) ); ?></span>
493
+ </div>
494
+ <?php
495
}
496
}
497
+
498
+
499
/**
500
*
501
* @since 1.0
504
* @author Andrea Grillo <andrea.grillo@yithemes.com>
505
*/
506
public function plugin_fw_loader() {
507
+
508
if ( ! defined( 'YIT_CORE_PLUGIN' ) ) {
509
global $plugin_fw_data;
510
if ( ! empty( $plugin_fw_data ) ) {
513
}
514
}
515
}
516
+
517
/**
518
* plugin_row_meta
519
*
535
) {
536
$plugin_meta[] = '<a href="' . $this->_official_documentation . '" target="_blank">' . __( 'Plugin Documentation', 'yith-woocommerce-advanced-reviews' ) . '</a>';
537
}
538
+
539
return $plugin_meta;
540
}
541
+
542
/**
543
* Action Links
544
*
553
* @use plugin_action_links_{$plugin_file_name}
554
*/
555
public function action_links( $links ) {
556
+
557
$links[] = '<a href="' . admin_url( "admin.php?page={$this->_panel_page}" ) . '">' . __( 'Settings', 'yith-woocommerce-advanced-reviews' ) . '</a>';
558
+
559
if ( defined( 'YITH_YWAR_FREE_INIT' ) ) {
560
$links[] = '<a href="' . $this->get_premium_landing_uri() . '" target="_blank">' . __( 'Premium Version', 'yith-woocommerce-advanced-reviews' ) . '</a>';
561
}
562
+
563
return $links;
564
}
565
+
566
public function register_pointer() {
567
if ( ! class_exists( 'YIT_Pointers' ) ) {
568
include_once( 'plugin-fw/lib/yit-pointers.php' );
569
}
570
+
571
$premium_message = defined( 'YITH_YWAR_PREMIUM' )
572
? ''
573
: __( 'YITH WooCommerce Advanced Reviews is available in an outstanding PREMIUM version with many new options, discover it now.', 'yith-woocommerce-advanced-reviews' ) .
574
' <a href="' . $this->get_premium_landing_uri() . '">' . __( 'Premium version', 'yith-woocommerce-advanced-reviews' ) . '</a>';
575
+
576
$args[] = array(
577
'screen_id' => 'plugins',
578
'pointer_id' => 'yith_ywar_panel',
584
'position' => array( 'edge' => 'left', 'align' => 'center' ),
585
'init' => defined( 'YITH_YWAR_PREMIUM' ) ? YITH_YWAR_INIT : YITH_YWAR_FREE_INIT,
586
);
587
+
588
$args[] = array(
589
'screen_id' => 'update',
590
'pointer_id' => 'yith_ywar_panel',
596
'position' => array( 'edge' => 'left', 'align' => 'center' ),
597
'init' => defined( 'YITH_YWAR_PREMIUM' ) ? YITH_YWAR_INIT : YITH_YWAR_FREE_INIT,
598
);
599
+
600
YIT_Pointers()->register( $args );
601
}
602
+
603
/**
604
* Get the premium landing uri
605
*
610
public function get_premium_landing_uri() {
611
return defined( 'YITH_REFER_ID' ) ? $this->_premium_landing . '?refer_id=' . YITH_REFER_ID : $this->_premium_landing . '?refer_id=1030585';
612
}
613
+
614
/**
615
* Add a panel under YITH Plugins tab
616
*
621
* @see plugin-fw/lib/yit-plugin-panel.php
622
*/
623
public function register_panel() {
624
+
625
if ( ! empty( $this->_panel ) ) {
626
return;
627
}
628
+
629
$admin_tabs = array(
630
'general' => __( 'General', 'yith-woocommerce-advanced-reviews' ),
631
'layout' => __( 'Layout', 'yith-woocommerce-advanced-reviews' ),
632
);
633
+
634
if ( defined( 'YITH_YWAR_PREMIUM' ) ) {
635
$admin_tabs['premium'] = __( 'Voting/Review settings', 'yith-woocommerce-advanced-reviews' );
636
} else {
637
$admin_tabs['premium-landing'] = __( 'Premium Version', 'yith-woocommerce-advanced-reviews' );
638
}
639
+
640
$args = array(
641
'create_menu_page' => true,
642
'parent_slug' => '',
649
'admin-tabs' => $admin_tabs,
650
'options-path' => YITH_YWAR_DIR . '/plugin-options',
651
);
652
+
653
/* === Fixed: not updated theme === */
654
if ( ! class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
655
require_once( 'plugin-fw/lib/yit-plugin-panel-wc.php' );
656
}
657
+
658
$this->_panel = new YIT_Plugin_Panel_WooCommerce( $args );
659
}
660
+
661
/**
662
* Premium Tab Template
663
*
674
include_once( $premium_tab_template );
675
}
676
}
677
+
678
+
679
/**
680
* Add scripts
681
*
685
public function enqueue_scripts() {
686
// register and enqueue ajax calls related script file
687
wp_register_script( "attachments-script", YITH_YWAR_URL . 'assets/js/ywar-attachments.js', array( 'jquery' ) );
688
+
689
wp_localize_script( 'attachments-script', 'attach', array(
690
'limit_multiple_upload' => $this->attachments_limit,
691
) );
692
wp_enqueue_script( 'attachments-script' );
693
}
694
+
695
/**
696
* Enqueue css file
697
*
701
public function enqueue_styles() {
702
wp_enqueue_style( 'yit-style', YITH_YWAR_ASSETS_URL . '/css/yit-advanced-reviews.css' );
703
}
704
+
705
/**
706
* Enqueue scripts on administration comment page
707
*
711
if ( 'toplevel_page_Reviews' != get_current_screen()->id ) {
712
return;
713
}
714
+
715
/** Add Woocommerce.css file */
716
$styles = (array) WC_Frontend_Scripts::get_styles();
717
+
718
if ( array_key_exists( 'woocommerce-general', $styles ) ) {
719
wp_enqueue_style( 'woocommerce-general', $styles['woocommerce-general']['src'] );
720
}
721
+
722
wp_enqueue_style( 'yit-style', YITH_YWAR_ASSETS_URL . '/css/yit-advanced-reviews.css' );
723
+
724
wp_register_script( "ajax-back-end-script", YITH_YWAR_URL . 'assets/js/ywar-back-end.js', array(
725
'jquery',
726
'jquery-blockui',
727
) );
728
+
729
$loader = apply_filters( 'yith_advanced_reviews_loader_gif', YITH_YWAR_ASSETS_URL . '/images/loading.gif' );
730
+
731
wp_localize_script( 'ajax-back-end-script', 'ywar', array(
732
'loader' => $loader,
733
'ajax_url' => admin_url( 'admin-ajax.php' ),
734
) );
735
+
736
wp_enqueue_script( "ajax-back-end-script" );
737
}
738
+
739
+
740
/**
741
* Register advanced reviews post type
742
*/
759
);
760
761
// Set other options for Custom Post Type
762
+
763
$args = array(
764
'label' => __( 'YIT Product reviews', 'yith-woocommerce-advanced-reviews' ),
765
'description' => __( 'Advanced WooCommerce product reviews', 'yith-woocommerce-advanced-reviews' ),
792
793
// Registering your Custom Post Type
794
register_post_type( $this->post_type_name, $args );
795
+
796
+
797
}
798
+
799
+
800
/**
801
* Default query arguments to be used where querying to review custom post type
802
*
830
),
831
);
832
}
833
+
834
/**
835
* Retrieve reviews for a product
836
*
837
* @param $product_id product id for whose retrieve the reviews
838
*/
839
public function get_product_reviews( $product_id = null, $args = null ) {
840
+
841
if ( $args == null ) {
842
$args = $this->default_query_args( $product_id );
843
}
844
+
845
// if $product_id is null, retrieve all reviews without filters
846
if ( is_null( $product_id ) ) {
847
unset( $args['meta_query'] );
848
}
849
+
850
return get_posts( $args );
851
}
852
+
853
+
854
/**
855
* Return the number of reviews for a specific product
856
*
866
'type' => 'numeric',
867
);
868
}
869
+
870
return $this->get_product_reviews( $product_id, $args );
871
}
872
+
873
+
874
/**
875
* Show the reviews for a specific product
876
*
878
*/
879
public function reviews_list( $product_id, $args = null ) {
880
$reviews = $this->get_product_reviews( $product_id, $args );
881
+
882
foreach ( $reviews as $review ) {
883
$this->show_review( $review );
884
}
885
}
886
+
887
/**
888
* Call the review template and show the review
889
*
898
'classes' => $classes,
899
), '', YITH_YWAR_TEMPLATES_DIR );
900
}
901
+
902
+
903
/**
904
* Initialize plugin options
905
*
914
$this->enable_attachments = get_option( 'ywar_enable_attachments' ) === 'yes';
915
$this->attachments_limit = get_option( 'ywar_max_attachments' );
916
}
917
+
918
/**
919
* Return the right path to the reviews template file
920
*
923
* @return mixed|void new template path, only for product comments page
924
*/
925
public function show_advanced_reviews_template( $template ) {
926
+
927
if ( get_post_type() === 'product' ) {
928
// return apply_filters( 'ywar_show_advanced_reviews_template', YITH_YWAR_TEMPLATES_DIR . "ywar-product-reviews.php" );
929
return wc_locate_template( "ywar-product-reviews.php", '', YITH_YWAR_TEMPLATES_DIR );
930
}
931
+
932
return $template;
933
}
934
+
935
/**
936
* Create new Advanced Review post type when a comment is saved to database
937
*
942
if ( ! isset( $_POST ) ) {
943
return;
944
}
945
+
946
$review_title = $this->enable_title && isset( $_POST["title"] ) ? wp_strip_all_tags( $_POST["title"] ) : '';
947
+
948
$post_parent = apply_filters( 'yith_advanced_reviews_post_parent', $_POST["comment_parent"] );
949
+
950
$comment = get_comment( $comment_id );
951
+
952
// Create post object
953
$my_post = array(
954
'post_author' => $comment->user_id,
968
'review_author_IP' => $comment->comment_author_IP,
969
'review_author_url' => $comment->comment_author_url,
970
);
971
+
972
// Insert the post into the database
973
$review_id = $this->insert_review( $my_post );
974
+
975
$this->submit_attachments( $review_id );
976
}
977
+
978
public function insert_review( $args ) {
979
// Create post object
980
$defaults = array(
1002
'review_author_url' => '',
1003
'review_author_IP' => '',
1004
);
1005
+
1006
$args = wp_parse_args( $args, $defaults );
1007
+
1008
// Insert the post into the database
1009
$review_id = wp_insert_post( $args );
1010
+
1011
// Set rating only for top level reviews, not for replies
1012
if ( 0 != $args["post_parent"] ) {
1013
update_post_meta( $review_id, $this->meta_key_rating, 0 );
1014
} else {
1015
update_post_meta( $review_id, $this->meta_key_rating, $args["review_rating"] );
1016
}
1017
+
1018
update_post_meta( $review_id, $this->meta_key_rating, $args["review_rating"] );
1019
update_post_meta( $review_id, $this->meta_key_approved, $args["review_approved"] );
1020
update_post_meta( $review_id, $this->meta_key_product_id, $args["review_product_id"] );
1021
update_post_meta( $review_id, $this->meta_key_comment_id, $args["review_comment_id"] );
1022
update_post_meta( $review_id, $this->meta_key_thumb_ids, $args["review_thumbnails"] );
1023
+
1024
update_post_meta( $review_id, $this->meta_key_upvotes_count, $args["review_upvotes"] );
1025
update_post_meta( $review_id, $this->meta_key_downvotes_count, $args["review_downvotes"] );
1026
update_post_meta( $review_id, $this->meta_key_votes, $args["review_votes"] );
1027
+
1028
update_post_meta( $review_id, $this->meta_key_inappropriate_list, $args["review_inappropriate_list"] );
1029
update_post_meta( $review_id, $this->meta_key_inappropriate_count, $args["review_inappropriate_count"] );
1030
update_post_meta( $review_id, $this->meta_key_featured, $args["review_is_featured"] );
1031
update_post_meta( $review_id, $this->meta_key_stop_reply, $args["review_is_reply_blocked"] );
1032
+
1033
update_post_meta( $review_id, $this->meta_key_review_user_id, $args["review_user_id"] );
1034
update_post_meta( $review_id, $this->meta_key_review_author, $args["review_author"] );
1035
update_post_meta( $review_id, $this->meta_key_review_author_email, $args["review_author_email"] );
1036
update_post_meta( $review_id, $this->meta_key_review_author_url, $args["review_author_url"] );
1037
update_post_meta( $review_id, $this->meta_key_review_author_IP, $args["review_author_IP"] );
1038
+
1039
return $review_id;
1040
}
1041
+
1042
/**
1043
* redirect to product page on comment submitted
1044
*/
1045
public function redirect_after_submit_review( $location, $comment ) {
1046
// Set the new comment as imported so it will not imported when clicking on "convert reviews", creating duplicated entries
1047
update_comment_meta( $comment->comment_ID, $this->meta_key_imported, 1 );
1048
+
1049
return get_permalink( $comment->comment_post_ID );
1050
}
1051
+
1052
/**
1053
* Add custom field "Title" on top of comment form
1054
*
1060
* @author Lorenzo Giuffrida
1061
*/
1062
public function add_custom_fields_on_comment_form() {
1063
+
1064
if ( ! is_product() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
1065
return;
1066
}
1067
+
1068
if ( $this->enable_title ) {
1069
echo '<p class="comment-form-title"><label for="title">' . __( 'Review title', 'yith-woocommerce-advanced-reviews' ) . '</label><input type="text" name="title" id="title"/></p>';
1070
}
1071
}
1072
+
1073
+
1074
/**
1075
* Submit attachments from a comment form
1076
*
1088
if ( ! $this->enable_attachments ) {
1089
return;
1090
}
1091
+
1092
if ( $_FILES ) {
1093
$files = $_FILES["ywar-uploadFile"];
1094
$files_count = count( $files['name'] );
1095
+
1096
// check for attachments limits
1097
if ( ( $this->attachments_limit > 0 ) && ( $files_count > $this->attachments_limit ) ) {
1098
return;
1099
}
1100
+
1101
$attacchments_array = array();
1102
+
1103
foreach ( $files['name'] as $key => $value ) {
1104
if ( $files['name'][ $key ] ) {
1105
$file = array(
1110
'size' => $files['size'][ $key ],
1111
);
1112
$_FILES = array( "ywar-uploadFile" => $file );
1113
+
1114
foreach ( $_FILES as $file => $array ) {
1115
$attachId = $this->insert_attachment( $file, $review_id );
1116
+
1117
// enqueue attachments to current comment
1118
array_push( $attacchments_array, $attachId );
1119
}
1120
}
1121
}
1122
+
1123
// save review with attachments array
1124
update_post_meta( $review_id, $this->meta_key_thumb_ids, $attacchments_array );
1125
}
1126
}
1127
+
1128
/**
1129
* Add attachment to media library
1130
*
1140
if ( $_FILES[ $fileHandler ]['error'] !== UPLOAD_ERR_OK ) {
1141
__return_false();
1142
}
1143
+
1144
require_once( ABSPATH . "wp-admin" . '/includes/image.php' );
1145
require_once( ABSPATH . "wp-admin" . '/includes/file.php' );
1146
require_once( ABSPATH . "wp-admin" . '/includes/media.php' );
1147
+
1148
return media_handle_upload( $fileHandler, $postId );
1149
}
1150
+
1151
/**
1152
* Append attachment fields on comment form
1153
*
1160
*/
1161
public function add_fields_to_comment_form( $comment_form ) {
1162
$current_content = $comment_form['comment_field'];
1163
+
1164
// In case of a page refresh following a reply request, don't add additional fields
1165
$hide_rating = isset( $_REQUEST["replytocom"] ) ? "hide-rating" : '';
1166
$selected = isset( $_REQUEST["replytocom"] ) ? "selected" : '';
1167
+
1168
if ( get_option( 'woocommerce_enable_review_rating' ) === 'yes' ) {
1169
$comment_form['comment_field'] = '<p class="' . $hide_rating . ' comment-form-rating">
1170
<label for="rating">' . __( 'Your Rate', 'yith-woocommerce-advanced-reviews' ) . '</label>
1175
<option value="3">' . __( 'Average', 'yith-woocommerce-advanced-reviews' ) . '</option>
1176
<option value="2">' . __( 'Not that bad', 'yith-woocommerce-advanced-reviews' ) . '</option>
1177
<option value="1" ' . $selected . '>' . __( 'Very Poor', 'yith-woocommerce-advanced-reviews' ) . '</option>';
1178
+
1179
$comment_form['comment_field'] .= '</select></p>' . $current_content;
1180
}
1181
+
1182
if ( $this->enable_attachments ) {
1183
$comment_form['comment_field'] .= '<p class="upload_section ' . $hide_rating . '" >
1184
<label for="ywar-uploadFile" > ' . __( 'Attachments', 'yith-woocommerce-advanced-reviews' ) . ' </label >
1189
<ul id = "uploadFileList" ></ul>
1190
</p> ';
1191
}
1192
+
1193
return $comment_form;
1194
}
1195
+
1196
+
1197
/**
1198
* Display a customized comment content
1199
*
1205
* @author Lorenzo Giuffrida
1206
*/
1207
public function show_expanded_review_content( $review ) {
1208
+
1209
if ( ! is_product() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
1210
return $review->post_content;
1211
}
1212
+
1213
$review_title = '';
1214
$thumbnail_div = $this->get_thumbnails( $review );
1215
+
1216
if ( $this->enable_title ) {
1217
// Add review title before review content text
1218
if ( ! empty( $review->post_title ) ) {
1219
$review_title = '<span class="review_title"> ' . esc_attr( $review->post_title ) . '</span> ';
1220
}
1221
}
1222
+
1223
return apply_filters( "yith_advanced_reviews_review_content_elements", $review_title . $review->post_content . $thumbnail_div, $review_title, $review->post_content, $thumbnail_div );
1224
}
1225
+
1226
/**
1227
* Get an HTML formatted attachment section
1228
*
1233
public function get_thumbnails( $review ) {
1234
$is_toplevel = ( 0 == $review->post_parent );
1235
$thumbnail_div = '';
1236
+
1237
if ( $is_toplevel && $this->enable_attachments ) {
1238
+
1239
if ( $thumbs = get_post_meta( $review->ID, $this->meta_key_thumb_ids, true ) ) {
1240
+
1241
$thumbnail_div = '<div class="review_thumbnail horizontalRule"> ';
1242
+
1243
foreach ( $thumbs as $thumb_id ) {
1244
$file_url = wp_get_attachment_url( $thumb_id );
1245
$image_thumb = wp_get_attachment_image_src( $thumb_id, array( 100, 100 ), true );
1246
+
1247
$thumbnail_div .= "<a href='$file_url' data-rel = \"prettyPhoto[review-gallery-$review->ID]\"><img class=\"ywar_thumbnail\" src='{$image_thumb[0]}' width='70px' height='70px'></a>";
1248
}
1249
$thumbnail_div .= ' </div> ';
1250
}
1251
}
1252
+
1253
return $thumbnail_div;
1254
}
1255
+
1256
/**
1257
* Alter text on tab reviews, fixing wrong count of reviews(even replies to reviews were used
1258
*
1262
*/
1263
public function update_tab_reviews_count( $tabs ) {
1264
global $product;
1265
+
1266
if ( isset( $tabs['reviews'] ) ) {
1267
$product_id = yit_get_prop( $product, 'id' );
1268
$tabs['reviews']['title'] = sprintf( __( 'Reviews(%d)', 'yith-woocommerce-advanced-reviews' ), count( $this->get_product_reviews_by_rating( $product_id ) ) );
1269
}
1270
+
1271
return $tabs;
1272
}
1273
+
1274
/**
1275
* Collect data about reviews rating and show a summary grouped by stars
1276
*
1285
if ( ! is_product() ) {
1286
return $template;
1287
}
1288
+
1289
global $product;
1290
global $review_stats;
1291
+
1292
$product_id = yit_get_prop( $product, 'id' );
1293
$review_stats = array(
1294
'1' => count( $this->get_product_reviews_by_rating( $product_id, 1 ) ),
1298
'5' => count( $this->get_product_reviews_by_rating( $product_id, 5 ) ),
1299
'total' => count( $this->get_product_reviews_by_rating( $product_id ) ),
1300
);
1301
+
1302
wc_get_template( 'ywar-single-product-reviews.php', null, '', YITH_YWAR_TEMPLATES_DIR );
1303
}
1304
+
1305
/**
1306
* Add a metabox on review page for review's title
1307
*
1316
'display_plugin_metabox',
1317
), $this->post_type_name, 'normal', 'high' );
1318
}
1319
+
1320
/**
1321
* Display a meta box with additional review data, like title and thumbnails
1322
*
1327
*/
1328
public function display_plugin_metabox() {
1329
global $post;
1330
+
1331
$rating_div = '';
1332
$thumbnail_div = '';
1333
+
1334
$current = get_post_meta( $post->ID, $this->meta_key_rating, true );
1335
?>
1336
<select name="rating" id="rating">
1338
echo sprintf( '<option value="%1$s"%2$s>%1$s</option>', $rating, selected( $current, $rating, false ) );
1339
} ?>
1340
</select>
1341
+
1342
<?php
1343
// Generate a hidden nonce used for verifying if a request to update the following values came from here
1344
echo '<input type="hidden" name="review_metabox_nonce" id="review_metabox_nonce" value="' .
1345
wp_create_nonce( plugin_basename( __FILE__ ) ) . '" />';
1346
+
1347
$review_thumbnails = get_post_meta( $post->ID, $this->meta_key_thumb_ids, true );
1348
+
1349
if ( isset ( $review_thumbnails ) && is_array( $review_thumbnails ) ) {
1350
$thumbnail_div = '<div style = "padding-top: 10px;padding-bottom: 10px;overflow:hidden"> ';
1351
foreach ( $review_thumbnails as $thumb_id ) {
1352
$file_url = wp_get_attachment_url( $thumb_id );
1353
// $image_thumb = wp_get_attachment_image($thumb_id, array(100, 100), true );
1354
$image_thumb = wp_get_attachment_image_src( $thumb_id, array( 100, 100 ), true );
1355
+
1356
$thumbnail_div .= "<a href='$file_url'><img src='{$image_thumb[0]}' width='{$image_thumb[1]}' height='{$image_thumb[2]}'></a>";
1357
}
1358
$thumbnail_div .= '</div >';
1359
}
1360
+
1361
echo $thumbnail_div;
1362
}
1363
+
1364
/**
1365
* Save the Metabox Data
1366
*
1370
* @return mixed
1371
*/
1372
function save_plugin_metabox( $post_id, $post ) {
1373
+
1374
if ( ! isset( $_POST['review_metabox_nonce'] ) ) {
1375
return $post->ID;
1376
}
1377
+
1378
// verify the save request started from review edit page...
1379
if ( ! wp_verify_nonce( $_POST['review_metabox_nonce'], plugin_basename( __FILE__ ) ) ) {
1380
return $post->ID;
1381
}
1382
+
1383
// Check for authorization
1384
if ( ! current_user_can( 'edit_post', $post->ID ) ) {
1385
return $post->ID;
1386
}
1387
+
1388
// OK, we're authenticated: we need to find and save the data
1389
// We'll put it into an array to make it easier to loop though.
1390
if ( isset( $_POST['rating'] ) ) {
1391
$rating = $_POST['rating'];
1392
+
1393
if ( is_numeric( $rating ) && ( $rating > 0 ) && ( $rating <= 5 ) ) {
1394
update_post_meta( $post_id, $this->meta_key_rating, $rating );
1395
}
1396
}
1397
}
1398
+
1399
/**
1400
* Remove features for the review custom post type
1401
*/
1402
public function remove_unwanted_custom_post_type_features() {
1403
global $submenu;
1404
+
1405
// Remove Add new for review custom post type
1406
unset( $submenu["edit.php?post_type={$this->post_type_name}"][10] );
1407
}
1408
+
1409
public function hide_unwanted_custom_post_type_features() {
1410
if ( $this->post_type_name == get_post_type() ) {
1411
echo '<style type="text/css">
1417
</style>';
1418
}
1419
}
1420
+
1421
+
1422
/**
1423
* Retrieve value for the "rating" meta_key for a specific review
1424
*
1429
function get_meta_value_rating( $review_id ) {
1430
return get_post_meta( $review_id, $this->meta_key_rating, true );
1431
}
1432
+
1433
/**
1434
* Retrieve value for the "approved" meta_key for a specific review
1435
*
1440
function get_meta_value_approved( $review_id ) {
1441
return get_post_meta( $review_id, $this->meta_key_approved, true );
1442
}
1443
+
1444
/**
1445
* Retrieve value for the "product_id" meta_key for a specific review
1446
*
1451
function get_meta_value_product_id( $review_id ) {
1452
return get_post_meta( $review_id, $this->meta_key_product_id, true );
1453
}
1454
+
1455
/**
1456
* Retrieve information about the review author
1457
*
1468
'review_author_IP' => get_post_meta( $review_id, $this->meta_key_review_author_IP, true ),
1469
);
1470
}
1471
+
1472
+
1473
public function wc_get_template( $located, $template_name, $args, $template_path, $default_path ) {
1474
if ( "single-product/rating.php" != $template_name ) {
1475
return $located;
1476
}
1477
+
1478
$located = wc_locate_template( "ywar-rating.php", $template_path, $default_path );
1479
+
1480
if ( file_exists( $located ) ) {
1481
return $located;
1482
}
1483
+
1484
return YITH_YWAR_TEMPLATES_DIR . 'ywar-rating.php';
1485
}
1486
+
1487
public function get_product_rating_html( $rating_html, $rating ) {
1488
global $product;
1489
$rating_html = '';
1490
+
1491
if ( ! $product ) {
1492
return $rating_html;
1493
}
1494
$rating = $this->get_average_rating( yit_get_prop( $product, 'id' ) );
1495
+
1496
if ( $rating > 0 ) {
1497
+
1498
$rating_html = '<div class="star-rating" title="' . sprintf( __( 'Rated %s out of 5', 'yith-woocommerce-advanced-reviews' ), $rating ) . '">';
1499
+
1500
$rating_html .= '<span style="width:' . ( ( $rating / 5 ) * 100 ) . '%"><strong class="rating">' . $rating . '</strong> ' . __( 'out of 5', 'yith-woocommerce-advanced-reviews' ) . '</span>';
1501
+
1502
$rating_html .= '</div>';
1503
}
1504
+
1505
return $rating_html;
1506
}
1507
+
1508
+
1509
/**
1510
* Show import button for starting convertion from standard system to YITH Advanced reviews
1511
*
1516
$args['value'] = ( get_option( $args['id'] ) ) ? get_option( $args['id'] ) : '';
1517
extract( $args );
1518
}
1519
+
1520
?>
1521
<tr valign="top">
1522
<th scope="row">
1523
+
1524
</th>
1525
+
1526
<td class="forminp forminp-color plugin-option">
1527
<div class="convert-reviews">
1528
<a href="<?php echo esc_url( add_query_arg( "convert-reviews", "start" ) ); ?>"
1529
class="button convert-reviews"><?php _e( "Convert reviews", "yith-woocommerce-advanced-reviews" ); ?></a>
1530
+
1531
<div style="display: inline-block; width: 65%; margin-left: 15px;"><span
1532
class="description"><?php _e( "If this is the first time you install the YITH Advanced Reviews plugin, or if you are using an older version prior to the 1.1.0, first you have to convert the older reviews if you want to use them.", "yith-woocommerce-advanced-reviews" ); ?></span>
1533
</div>
1536
</tr>
1537
<?php
1538
}
1539
+
1540
/**
1541
* Convert previous reviews into new YITH Advanced review type
1542
*
1544
* @author Lorenzo Giuffrida
1545
*/
1546
public function convert_reviews_callback() {
1547
+
1548
$review_converted = $this->import_previous_reviews();
1549
$response = '';
1550
+
1551
if ( $review_converted ) {
1552
$response = sprintf( __( 'Task completed. %d reviews have been processed and converted.', 'yith-woocommerce-advanced-reviews' ), $review_converted );
1553
} else {
1554
$response = __( 'Task completed. No review to convert has been found.', 'yith-woocommerce-advanced-reviews' );
1555
}
1556
+
1557
wp_send_json( array( "value" => $response ) );
1558
}
1559
+
1560
/**
1561
* Set a maximum execution time
1562
*
1568
@set_time_limit( $seconds );
1569
}
1570
}
1571
+
1572
/**
1573
* Read and convert previous reviews into new advanced reviews using custom post type
1574
*/
1575
public function import_previous_reviews() {
1576
global $wpdb;
1577
+
1578
$review_converted = 0;
1579
+
1580
$query = "SELECT *
1581
FROM {$wpdb->prefix}comments as co left join {$wpdb->prefix}commentmeta as cm
1582
on co.comment_ID = cm.comment_id
1583
where ((co.comment_approved = '0') or (co.comment_approved = '1')) and cm.meta_key = 'rating'";
1584
+
1585
$results = $wpdb->get_results( $query );
1586
+
1587
// manage parent relationship and update all reviews when import ends
1588
$review_ids = array();
1589
$parent_review = array();
1590
+
1591
foreach ( $results as $comment ) {
1592
+
1593
// Check if comment_meta exists for previous reviews and is not still imported
1594
if ( "1" === get_comment_meta( $comment->comment_ID, $this->meta_key_imported, true ) ) {
1595
// comment still imported, update only author data (Fix for upgrade from 1.1.2 to 1.2.3 then skip it!
1596
+
1597
// Retrieve review(post) id linked to current comment
1598
$args = array(
1599
'post_type' => 'ywar_reviews',
1607
),
1608
);
1609
$reviews = get_posts( $args );
1610
+
1611
if ( ! empty( $reviews ) ) {
1612
$review = $reviews[0];
1613
+
1614
// Update review meta
1615
update_post_meta( $review->ID, $this->meta_key_review_user_id, $comment->user_id );
1616
update_post_meta( $review->ID, $this->meta_key_review_author, $comment->comment_author );
1618
update_post_meta( $review->ID, $this->meta_key_review_author_url, $comment->comment_author_url );
1619
update_post_meta( $review->ID, $this->meta_key_review_author_IP, $comment->comment_author_IP );
1620
}
1621
+
1622
continue;
1623
}
1624
+
1625
// Set execution time
1626
$this->set_time_limit( 30 );
1627
+
1628
$val = get_comment_meta( $comment->comment_ID, "title", true );
1629
$title = $val ? $val : '';
1630
+
1631
$val = get_comment_meta( $comment->comment_ID, "thumb_ids", true );
1632
$thumb_ids = $val ? $val : array();
1633
+
1634
$val = get_comment_meta( $comment->comment_ID, "rating", true );
1635
$rating = $val ? $val : 0;
1636
+
1637
// Import previous settings for "stop reply" from the comment
1638
$val = get_comment_meta( $comment->comment_ID, "no_reply", true );
1639
$no_reply = $val ? $val : 0;
1640
+
1641
// Import previous settings for "votes" from the comment
1642
$val = get_comment_meta( $comment->comment_ID, "votes", true );
1643
$votes = $val ? $val : array();
1644
+
1645
// Extract upvotes and downvotes count
1646
$votes_grouped = array_count_values( array_values( $votes ) );
1647
$yes_votes = isset( $votes_grouped['1'] ) && is_numeric( $votes_grouped['1'] ) ? $votes_grouped['1'] : 0;
1648
$no_votes = isset( $votes_grouped['-1'] ) && is_numeric( $votes_grouped['-1'] ) ? $votes_grouped['-1'] : 0;
1649
+
1650
// Create post object
1651
$args = array(
1652
'post_author' => $comment->user_id,
1669
'review_author_url' => $comment->comment_author_url,
1670
'review_author_IP' => $comment->comment_author_IP,
1671
);
1672
+
1673
// Insert the post into the database
1674
$review_id = $this->insert_review( $args );
1675
+
1676
$review_ids[ $comment->comment_ID ] = $review_id;
1677
+
1678
// If current comment have parent, store it and update all relationship when the import ends
1679
if ( $comment->comment_parent > 0 ) {
1680
$parent_review[ $review_id ] = $comment->comment_parent;
1681
}
1682
+
1683
// set current comment as imported
1684
update_comment_meta( $comment->comment_ID, $this->meta_key_imported, 1 );
1685
$review_converted ++;
1686
}
1687
+
1688
// if some hierarchical comment was found, update the review created
1689
foreach ( $parent_review as $key => $value ) {
1690
if ( isset( $review_ids[ $value ] ) ) {
1691
+
1692
//update the post which id is in $key, setting parent to $review_ids[$value]
1693
$args = array(
1694
'ID' => $key,
1695
'post_parent' => $review_ids[ $value ],
1696
);
1697
+
1698
// Update the post into the database
1699
wp_update_post( $args );
1700
}
1701
}
1702
+
1703
return $review_converted;
1704
}
1705
+
1706
/**
1707
* On plugin init check query vars for commands to convert previous reviews
1708
*/
1709
function check_import_actions() {
1710
if ( isset( $_GET["convert-reviews"] ) ) {
1711
+
1712
$this->import_previous_reviews();
1713
+
1714
wp_redirect( esc_url( remove_query_arg( "convert-reviews" ) ) );
1715
}
1716
}
1717
}
1718
}
modules/yith-woocommerce-advanced-reviews/init.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://yithemes.com/themes/plugins/yith-woocommerce-advanced-reviews
5
Description: Extends the basic functionality of woocommerce reviews and add a histogram table to the reviews of your products, such as you see in most trendy e-commerce sites.
6
Author: YITHEMES
7
Text Domain: yith-woocommerce-advanced-reviews
8
- Version: 1.2.7
9
Author URI: http://yithemes.com/
10
*/
11
@@ -45,7 +45,7 @@ register_activation_hook ( __FILE__, 'yith_plugin_registration_hook' );
45
46
require_once ( plugin_dir_path ( __FILE__ ) . 'functions.php' );
47
yith_define ( 'YITH_YWAR_FREE_INIT', plugin_basename ( __FILE__ ) );
48
- yith_define ( 'YITH_YWAR_VERSION', '1.2.7' );
49
yith_define ( 'YITH_YWAR_FILE', __FILE__ );
50
yith_define ( 'YITH_YWAR_DIR', plugin_dir_path ( __FILE__ ) );
51
yith_define ( 'YITH_YWAR_URL', plugins_url ( '/', __FILE__ ) );
5
Description: Extends the basic functionality of woocommerce reviews and add a histogram table to the reviews of your products, such as you see in most trendy e-commerce sites.
6
Author: YITHEMES
7
Text Domain: yith-woocommerce-advanced-reviews
8
+ Version: 1.2.8
9
Author URI: http://yithemes.com/
10
*/
11
45
46
require_once ( plugin_dir_path ( __FILE__ ) . 'functions.php' );
47
yith_define ( 'YITH_YWAR_FREE_INIT', plugin_basename ( __FILE__ ) );
48
+ yith_define ( 'YITH_YWAR_VERSION', '1.2.8' );
49
yith_define ( 'YITH_YWAR_FILE', __FILE__ );
50
yith_define ( 'YITH_YWAR_DIR', plugin_dir_path ( __FILE__ ) );
51
yith_define ( 'YITH_YWAR_URL', plugins_url ( '/', __FILE__ ) );
modules/yith-woocommerce-ajax-navigation/includes/class.yith-wcan-frontend.php CHANGED
@@ -121,7 +121,14 @@ if ( ! class_exists( 'YITH_WCAN_Frontend' ) ) {
121
$filtered_posts = array();
122
$queried_post_ids = array();
123
124
- if( class_exists( 'QTX_Translator' ) && defined('YIT_CORE_VERSION') && '1.0.0' == YIT_CORE_VERSION ){
125
add_filter( 'yith_wcan_skip_layered_nav_query', '__return_true' );
126
}
127
121
$filtered_posts = array();
122
$queried_post_ids = array();
123
124
+ $problematic_theme = array(
125
+ 'basel'
126
+ );
127
+
128
+ $is_qTranslateX_and_yit_core_1_0_0 = class_exists( 'QTX_Translator' ) && defined('YIT_CORE_VERSION') && '1.0.0' == YIT_CORE_VERSION;
129
+ $is_problematic_theme = in_array( wp_get_theme()->get_template(), $problematic_theme );
130
+
131
+ if( $is_qTranslateX_and_yit_core_1_0_0 || $is_problematic_theme ){
132
add_filter( 'yith_wcan_skip_layered_nav_query', '__return_true' );
133
}
134
modules/yith-woocommerce-ajax-navigation/init.php CHANGED
@@ -3,7 +3,7 @@
3
* Plugin Name: YITH WooCommerce Ajax Product Filter
4
* Plugin URI: http://yithemes.com/
5
* Description: YITH WooCommerce Ajax Product Filter offers the perfect way to filter all the products of your shop.
6
- * Version: 3.4.1
7
* Author: YITHEMES
8
* Author URI: http://yithemes.com/
9
* Text Domain: yith-woocommerce-ajax-navigation
@@ -64,7 +64,7 @@ load_plugin_textdomain( 'yith-woocommerce-ajax-navigation', false, dirname( plug
64
! defined( 'YITH_WCAN' ) && define( 'YITH_WCAN', true );
65
! defined( 'YITH_WCAN_URL' ) && define( 'YITH_WCAN_URL', plugin_dir_url( __FILE__ ) );
66
! defined( 'YITH_WCAN_DIR' ) && define( 'YITH_WCAN_DIR', plugin_dir_path( __FILE__ ) );
67
- ! defined( 'YITH_WCAN_VERSION' ) && define( 'YITH_WCAN_VERSION', '3.4.1' );
68
! defined( 'YITH_WCAN_FREE_INIT') && define( 'YITH_WCAN_FREE_INIT', plugin_basename( __FILE__ ) );
69
! defined( 'YITH_WCAN_FILE' ) && define( 'YITH_WCAN_FILE', __FILE__ );
70
3
* Plugin Name: YITH WooCommerce Ajax Product Filter
4
* Plugin URI: http://yithemes.com/
5
* Description: YITH WooCommerce Ajax Product Filter offers the perfect way to filter all the products of your shop.
6
+ * Version: 3.4.2
7
* Author: YITHEMES
8
* Author URI: http://yithemes.com/
9
* Text Domain: yith-woocommerce-ajax-navigation
64
! defined( 'YITH_WCAN' ) && define( 'YITH_WCAN', true );
65
! defined( 'YITH_WCAN_URL' ) && define( 'YITH_WCAN_URL', plugin_dir_url( __FILE__ ) );
66
! defined( 'YITH_WCAN_DIR' ) && define( 'YITH_WCAN_DIR', plugin_dir_path( __FILE__ ) );
67
+ ! defined( 'YITH_WCAN_VERSION' ) && define( 'YITH_WCAN_VERSION', '3.4.2' );
68
! defined( 'YITH_WCAN_FREE_INIT') && define( 'YITH_WCAN_FREE_INIT', plugin_basename( __FILE__ ) );
69
! defined( 'YITH_WCAN_FILE' ) && define( 'YITH_WCAN_FILE', __FILE__ );
70
modules/yith-woocommerce-ajax-navigation/widgets/class.yith-wcan-navigation-widget.php CHANGED
@@ -293,7 +293,13 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
293
}
294
295
if( is_product_taxonomy() && ! yit_is_filtered_uri() && $term->term_id != $queried_object->term_id ){
296
- $link = add_query_arg( array( 'source_id' => $queried_object->term_id, 'source_tax' => $queried_object->taxonomy ), $link );
297
}
298
299
if ( isset( $_GET['source_id'] ) && isset( $_GET['source_tax'] ) ) {
@@ -306,10 +312,18 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
306
}
307
308
if( $add_source_id ) {
309
- $link = add_query_arg( array( 'source_id' => $_GET['source_id'], 'source_tax' => $_GET['source_tax'] ), $link );
310
}
311
}
312
313
// Current Filter = this widget
314
if ( isset( $_chosen_attributes[$taxonomy] ) && is_array( $_chosen_attributes[$taxonomy]['terms'] ) && $in_array_function( $term->$filter_term_field, $_chosen_attributes[$taxonomy]['terms'] ) ) {
315
@@ -499,7 +513,12 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
499
}
500
501
if( is_product_taxonomy() && ! yit_is_filtered_uri() && $term->term_id != $queried_object->term_id ){
502
- $link = add_query_arg( array( 'source_id' => $queried_object->term_id, 'source_tax' => $queried_object->taxonomy ), $link );
503
}
504
505
if ( isset( $_GET['source_id'] ) && isset( $_GET['source_tax'] ) ) {
@@ -512,10 +531,15 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
512
}
513
514
if( $add_source_id ) {
515
- $link = add_query_arg( array( 'source_id' => $_GET['source_id'], 'source_tax' => $_GET['source_tax'] ), $link );
516
}
517
}
518
519
// Current Filter = this widget
520
if ( isset( $_chosen_attributes[$taxonomy] ) && is_array( $_chosen_attributes[$taxonomy]['terms'] ) && $in_array_function( $term->$filter_term_field, $_chosen_attributes[$taxonomy]['terms'] ) ) {
521
@@ -704,7 +728,12 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
704
}
705
706
if( is_product_taxonomy() && ! yit_is_filtered_uri() && $term->term_id != $queried_object->term_id ){
707
- $link = add_query_arg( array( 'source_id' => $queried_object->term_id, 'source_tax' => $queried_object->taxonomy ), $link );
708
}
709
710
if ( isset( $_GET['source_id'] ) && isset( $_GET['source_tax'] ) ) {
@@ -717,10 +746,15 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {