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 | 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
- README.txt +11 -2
- init.php +1 -1
- modules/yith-woocommerce-advanced-reviews/class.yith-woocommerce-advanced-reviews.php +321 -346
- modules/yith-woocommerce-advanced-reviews/init.php +2 -2
- modules/yith-woocommerce-ajax-navigation/includes/class.yith-wcan-frontend.php +8 -1
- modules/yith-woocommerce-ajax-navigation/init.php +2 -2
- modules/yith-woocommerce-ajax-navigation/widgets/class.yith-wcan-navigation-widget.php +52 -8
- modules/yith-woocommerce-ajax-search/assets/js/frontend.js +1 -1
- modules/yith-woocommerce-ajax-search/assets/js/frontend.min.js +2 -2
- modules/yith-woocommerce-ajax-search/class.yith-wcas.php +11 -6
- modules/yith-woocommerce-ajax-search/init.php +3 -2
- modules/yith-woocommerce-cart-messages/class.yith-woocommerce-cart-messages.php +15 -12
- modules/yith-woocommerce-cart-messages/yith-cart-messages.php +3 -2
- modules/yith-woocommerce-product-vendors/assets/css/admin.css +104 -2
- modules/yith-woocommerce-product-vendors/assets/images/43-bg.png +0 -0
- modules/yith-woocommerce-product-vendors/assets/images/43-icon.png +0 -0
- modules/yith-woocommerce-product-vendors/assets/images/43.png +0 -0
- modules/yith-woocommerce-product-vendors/assets/images/vendor-commission-fee.png +0 -0
- modules/yith-woocommerce-product-vendors/includes/class.yith-commission.php +3 -1
- modules/yith-woocommerce-product-vendors/includes/class.yith-commissions.php +56 -92
- modules/yith-woocommerce-product-vendors/includes/class.yith-orders.php +43 -21
- modules/yith-woocommerce-product-vendors/includes/class.yith-vendor.php +7 -1
- modules/yith-woocommerce-product-vendors/includes/class.yith-vendors-admin.php +3 -3
- modules/yith-woocommerce-product-vendors/includes/class.yith-vendors-frontend.php +1 -1
- modules/yith-woocommerce-product-vendors/includes/class.yith-vendors.php +9 -1
- modules/yith-woocommerce-product-vendors/includes/functions.yith-update.php +15 -0
- modules/yith-woocommerce-product-vendors/includes/lib/class.yith-commissions-list-table.php +13 -6
- modules/yith-woocommerce-product-vendors/init.php +3 -3
- modules/yith-woocommerce-product-vendors/templates/admin/commission-view.php +163 -142
- modules/yith-woocommerce-product-vendors/templates/admin/premium.php +17 -1
- modules/yith-woocommerce-review-reminder/includes/class-ywrr-emails.php +7 -2
- modules/yith-woocommerce-review-reminder/includes/emails/class-ywrr-request-email.php +4 -2
- modules/yith-woocommerce-review-reminder/init.php +2 -2
- modules/yith-woocommerce-review-reminder/templates/emails/review-request.php +2 -0
- plugin-fw/init.php +1 -1
- plugin-fw/lib/yit-plugin-panel-wc.php +2 -0
- plugin-fw/lib/yit-plugin-panel.php +3 -1
- 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 |
-
Stable tag: 1.4.
|
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.
|
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 |
-
|
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 |
-
|
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 |
-
|
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 |
-
|
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 |
-
|
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
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
|
|
|
|
|
|
|
|
505 |
}
|
506 |
}
|
507 |
-
|
508 |
-
|
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 |
-
|
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 |
-
|
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 |
-
|
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 |
-
|
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 |
-
|
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 |
-
|
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 |
-
|
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 |
-
|
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.
|
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.
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.
|
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.
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
-
$
|
|
|
|
|
|
|
|
|
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(
|
|
|
|
|
|
|
|
|
|
|
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 |
-
$
|
|
|
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(
|
|
|
|
|
|
|
|
|
|
|
708 |
}
|
709 |
|
710 |
if ( isset( $_GET['source_id'] ) && isset( $_GET['source_tax'] ) ) {
|
@@ -717,10 +746,15 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
|
|
717 |
}
|
718 |
|
719 |
if( $add_source_id ) {
|
720 |
-
$
|
|
|
721 |
}
|
722 |
}
|
723 |
|
|
|
|
|
|
|
|
|
724 |
// Current Filter = this widget
|
725 |
if ( isset( $_chosen_attributes[$taxonomy] ) && is_array( $_chosen_attributes[$taxonomy]['terms'] ) && $in_array_function( $term->$filter_term_field, $_chosen_attributes[$taxonomy]['terms'] ) ) {
|
726 |
|
@@ -1098,10 +1132,15 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
|
|
1098 |
}
|
1099 |
|
1100 |
if( $add_source_id ) {
|
1101 |
-
$
|
|
|
1102 |
}
|
1103 |
}
|
1104 |
|
|
|
|
|
|
|
|
|
1105 |
if (isset($_GET['product_cat'])) {
|
1106 |
$categories_filter_operator = 'and' == $query_type ? '+' : ',';
|
1107 |
$_chosen_categories = explode($categories_filter_operator, urlencode($_GET['product_cat']));
|
@@ -1118,7 +1157,12 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
|
|
1118 |
}
|
1119 |
|
1120 |
if( is_product_taxonomy() && ! yit_is_filtered_uri() && $term->term_id != $queried_object->term_id ){
|
1121 |
-
$link = add_query_arg(
|
|
|
|
|
|
|
|
|
|
|
1122 |
}
|
1123 |
|
1124 |
$check_for_current_widget = isset($_chosen_attributes[$taxonomy]) && is_array($_chosen_attributes[$taxonomy]['terms']) && $in_array_function($term->$filter_term_field, $_chosen_attributes[$taxonomy]['terms']);
|
293 |
}
|
294 |
|
295 |
if( is_product_taxonomy() && ! yit_is_filtered_uri() && $term->term_id != $queried_object->term_id ){
|
296 |
+
|
297 |
+
$link = add_query_arg(
|
298 |
+
array(
|
299 |
+
'source_id' => $queried_object->term_id,
|
300 |
+
'source_tax' => $queried_object->taxonomy,
|
301 |
+
$queried_object->taxonomy => $queried_object->slug
|
302 |
+
), $link );
|
303 |
}
|
304 |
|
305 |
if ( isset( $_GET['source_id'] ) && isset( $_GET['source_tax'] ) ) {
|
312 |
}
|
313 |
|
314 |
if( $add_source_id ) {
|
315 |
+
$args = array( 'source_id' => $_GET['source_id'], 'source_tax' => $_GET['source_tax'] );
|
316 |
+
if( isset( $_GET[ $queried_object->taxonomy ] ) ){
|
317 |
+
$args[ $queried_object->taxonomy ] = $_GET[ $queried_object->taxonomy ];
|
318 |
+
}
|
319 |
+
$link = add_query_arg( $args, $link );
|
320 |
}
|
321 |
}
|
322 |
|
323 |
+
if( isset( $_GET['yith_shop_vendor'] ) ){
|
324 |
+
$link = add_query_arg( array( 'yith_shop_vendor' => $_GET['yith_shop_vendor'] ), $link );
|
325 |
+
}
|
326 |
+
|
327 |
// Current Filter = this widget
|
328 |
if ( isset( $_chosen_attributes[$taxonomy] ) && is_array( $_chosen_attributes[$taxonomy]['terms'] ) && $in_array_function( $term->$filter_term_field, $_chosen_attributes[$taxonomy]['terms'] ) ) {
|
329 |
|
513 |
}
|
514 |
|
515 |
if( is_product_taxonomy() && ! yit_is_filtered_uri() && $term->term_id != $queried_object->term_id ){
|
516 |
+
$link = add_query_arg(
|
517 |
+
array(
|
518 |
+
'source_id' => $queried_object->term_id,
|
519 |
+
'source_tax' => $queried_object->taxonomy,
|
520 |
+
$queried_object->taxonomy => $queried_object->slug
|
521 |
+
), $link );
|
522 |
}
|
523 |
|
524 |
if ( isset( $_GET['source_id'] ) && isset( $_GET['source_tax'] ) ) {
|
531 |
}
|
532 |
|
533 |
if( $add_source_id ) {
|
534 |
+
$args = array( 'source_id' => $_GET['source_id'], 'source_tax' => $_GET['source_tax'] );
|
535 |
+
$link = add_query_arg( $args, $link );
|
536 |
}
|
537 |
}
|
538 |
|
539 |
+
if( isset( $_GET['yith_shop_vendor'] ) ){
|
540 |
+
$link = add_query_arg( array( 'yith_shop_vendor' => $_GET['yith_shop_vendor'] ), $link );
|
541 |
+
}
|
542 |
+
|
543 |
// Current Filter = this widget
|
544 |
if ( isset( $_chosen_attributes[$taxonomy] ) && is_array( $_chosen_attributes[$taxonomy]['terms'] ) && $in_array_function( $term->$filter_term_field, $_chosen_attributes[$taxonomy]['terms'] ) ) {
|
545 |
|
728 |
}
|
729 |
|
730 |
if( is_product_taxonomy() && ! yit_is_filtered_uri() && $term->term_id != $queried_object->term_id ){
|
731 |
+
$link = add_query_arg(
|
732 |
+
array(
|
733 |
+
'source_id' => $queried_object->term_id,
|
734 |
+
'source_tax' => $queried_object->taxonomy,
|
735 |
+
$queried_object->taxonomy => $queried_object->slug
|
736 |
+
), $link );
|
737 |
}
|
738 |
|
739 |
if ( isset( $_GET['source_id'] ) && isset( $_GET['source_tax'] ) ) {
|
746 |
}
|
747 |
|
748 |
if( $add_source_id ) {
|
749 |
+
$args = array( 'source_id' => $_GET['source_id'], 'source_tax' => $_GET['source_tax'] );
|
750 |
+
$link = add_query_arg( $args, $link );
|
751 |
}
|
752 |
}
|
753 |
|
754 |
+
if( isset( $_GET['yith_shop_vendor'] ) ){
|
755 |
+
$link = add_query_arg( array( 'yith_shop_vendor' => $_GET['yith_shop_vendor'] ), $link );
|
756 |
+
}
|
757 |
+
|
758 |
// Current Filter = this widget
|
759 |
if ( isset( $_chosen_attributes[$taxonomy] ) && is_array( $_chosen_attributes[$taxonomy]['terms'] ) && $in_array_function( $term->$filter_term_field, $_chosen_attributes[$taxonomy]['terms'] ) ) {
|
760 |
|
1132 |
}
|
1133 |
|
1134 |
if( $add_source_id ) {
|
1135 |
+
$args = array( 'source_id' => $_GET['source_id'], 'source_tax' => $_GET['source_tax'] );
|
1136 |
+
$link = add_query_arg( $args, $link );
|
1137 |
}
|
1138 |
}
|
1139 |
|
1140 |
+
if( isset( $_GET['yith_shop_vendor'] ) ){
|
1141 |
+
$link = add_query_arg( array( 'yith_shop_vendor' => $_GET['yith_shop_vendor'] ), $link );
|
1142 |
+
}
|
1143 |
+
|
1144 |
if (isset($_GET['product_cat'])) {
|
1145 |
$categories_filter_operator = 'and' == $query_type ? '+' : ',';
|
1146 |
$_chosen_categories = explode($categories_filter_operator, urlencode($_GET['product_cat']));
|
1157 |
}
|
1158 |
|
1159 |
if( is_product_taxonomy() && ! yit_is_filtered_uri() && $term->term_id != $queried_object->term_id ){
|
1160 |
+
$link = add_query_arg(
|
1161 |
+
array(
|
1162 |
+
'source_id' => $queried_object->term_id,
|
1163 |
+
'source_tax' => $queried_object->taxonomy,
|
1164 |
+
$queried_object->taxonomy => $queried_object->slug
|
1165 |
+
), $link );
|
1166 |
}
|
1167 |
|
1168 |
$check_for_current_widget = isset($_chosen_attributes[$taxonomy]) && is_array($_chosen_attributes[$taxonomy]['terms']) && $in_array_function($term->$filter_term_field, $_chosen_attributes[$taxonomy]['terms']);
|
modules/yith-woocommerce-ajax-search/assets/js/frontend.js
CHANGED
@@ -27,7 +27,7 @@ jQuery(document).ready(function ($) {
|
|
27 |
|
28 |
el.each(function () {
|
29 |
var $t = $(this),
|
30 |
-
append_to = ( typeof $t.data('append-to') == 'undefined') ? $t.closest('.yith-ajaxsearchform-container') : $t.data('append-to');
|
31 |
|
32 |
$t.yithautocomplete({
|
33 |
minChars : min_chars,
|
27 |
|
28 |
el.each(function () {
|
29 |
var $t = $(this),
|
30 |
+
append_to = ( typeof $t.data('append-to') == 'undefined') ? $t.closest('.yith-ajaxsearchform-container') : $t.closest( $t.data('append-to') );
|
31 |
|
32 |
$t.yithautocomplete({
|
33 |
minChars : min_chars,
|
modules/yith-woocommerce-ajax-search/assets/js/frontend.min.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
jQuery(document).ready(function(
|
2 |
-
|
1 |
+
jQuery(document).ready(function(c){var a=c(".yith-s"),d="undefined"!=typeof woocommerce_params&&"undefined"!=typeof woocommerce_params.ajax_loader_url?woocommerce_params.ajax_loader_url:yith_wcas_params.loading,e=""==a.data("loader-icon")?d:a.data("loader-icon"),d=c("#yith-searchsubmit"),f=a.data("min-chars");d.on("click",function(){return""==c(this).closest("form").find(".yith-s").val()?!1:!0});0==a.length&&(a=c("#yith-s"));a.each(function(){var b=c(this),a="undefined"==typeof b.data("append-to")?
|
2 |
+
b.closest(".yith-ajaxsearchform-container"):b.closest(b.data("append-to"));b.yithautocomplete({minChars:f,appendTo:a,triggerSelectOnValidInput:!1,serviceUrl:yith_wcas_params.ajax_url+"?action=yith_ajax_search_products",onSearchStart:function(){b.css({"background-image":"url("+e+")","background-repeat":"no-repeat","background-position":"center right"})},onSelect:function(a){-1!=a.id&&(window.location.href=a.url)},onSearchComplete:function(){b.css("background-image","none")}})})});
|
modules/yith-woocommerce-ajax-search/class.yith-wcas.php
CHANGED
@@ -54,12 +54,17 @@ if ( !class_exists( 'YITH_WCAS' ) ) {
|
|
54 |
}else {
|
55 |
$this->obj = new YITH_WCAS_Frontend( $this->version );
|
56 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
}
|
58 |
-
|
59 |
-
|
60 |
-
} else {
|
61 |
-
include_once( YITH_WCAS_DIR . 'plugin-fw/yit-woocommerce-compatibility.php' );
|
62 |
-
}
|
63 |
// actions
|
64 |
add_action( 'widgets_init', array( $this, 'registerWidgets' ) );
|
65 |
|
@@ -218,4 +223,4 @@ if ( !class_exists( 'YITH_WCAS' ) ) {
|
|
218 |
|
219 |
|
220 |
}
|
221 |
-
}
|
54 |
}else {
|
55 |
$this->obj = new YITH_WCAS_Frontend( $this->version );
|
56 |
}
|
57 |
+
}else{
|
58 |
+
if ( class_exists( 'YITH_JetPack' ) ) {
|
59 |
+
include_once( YJP_DIR . 'plugin-fw/yit-woocommerce-compatibility.php' );
|
60 |
+
} else {
|
61 |
+
global $plugin_fw_data;
|
62 |
+
$plugin_fw_file = array_shift( $plugin_fw_data );
|
63 |
+
require_once( plugin_dir_path( $plugin_fw_file ) . 'yit-woocommerce-compatibility.php' );
|
64 |
+
}
|
65 |
}
|
66 |
+
|
67 |
+
|
|
|
|
|
|
|
68 |
// actions
|
69 |
add_action( 'widgets_init', array( $this, 'registerWidgets' ) );
|
70 |
|
223 |
|
224 |
|
225 |
}
|
226 |
+
}
|
modules/yith-woocommerce-ajax-search/init.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: YITH WooCommerce Ajax Search
|
4 |
* Plugin URI: http://yithemes.com/
|
5 |
* Description: YITH WooCommerce Ajax Search allows your users to search products in real time.
|
6 |
-
* Version: 1.5.
|
7 |
* Author: YITHEMES
|
8 |
* Author URI: http://yithemes.com/
|
9 |
* Text Domain: yith-woocommerce-ajax-search
|
@@ -33,6 +33,7 @@ if ( ! defined( 'YITH_WCAS_DIR' ) ) {
|
|
33 |
}
|
34 |
|
35 |
|
|
|
36 |
if ( defined( 'YITH_WCAS_PREMIUM' ) ) {
|
37 |
function yith_wcas_install_free_admin_notice() {
|
38 |
?>
|
@@ -59,7 +60,7 @@ register_activation_hook( __FILE__, 'yith_plugin_registration_hook' );
|
|
59 |
if ( defined( 'YITH_WCAS_VERSION' ) ){
|
60 |
return;
|
61 |
}else{
|
62 |
-
define( 'YITH_WCAS_VERSION', '1.5.
|
63 |
}
|
64 |
|
65 |
if ( ! defined( 'YITH_WCAS_FREE_INIT' ) ) {
|
3 |
* Plugin Name: YITH WooCommerce Ajax Search
|
4 |
* Plugin URI: http://yithemes.com/
|
5 |
* Description: YITH WooCommerce Ajax Search allows your users to search products in real time.
|
6 |
+
* Version: 1.5.3
|
7 |
* Author: YITHEMES
|
8 |
* Author URI: http://yithemes.com/
|
9 |
* Text Domain: yith-woocommerce-ajax-search
|
33 |
}
|
34 |
|
35 |
|
36 |
+
|
37 |
if ( defined( 'YITH_WCAS_PREMIUM' ) ) {
|
38 |
function yith_wcas_install_free_admin_notice() {
|
39 |
?>
|
60 |
if ( defined( 'YITH_WCAS_VERSION' ) ){
|
61 |
return;
|
62 |
}else{
|
63 |
+
define( 'YITH_WCAS_VERSION', '1.5.3' );
|
64 |
}
|
65 |
|
66 |
if ( ! defined( 'YITH_WCAS_FREE_INIT' ) ) {
|
modules/yith-woocommerce-cart-messages/class.yith-woocommerce-cart-messages.php
CHANGED
@@ -316,22 +316,23 @@ if ( !class_exists( 'YWCM_Cart_Messages' ) ) {
|
|
316 |
$products_in_cart = array();
|
317 |
$products_in_cart_titles = array();
|
318 |
|
319 |
-
|
320 |
-
foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) {
|
321 |
-
$product = $values['data'];
|
322 |
-
$product_id = $product->get_id();
|
323 |
-
$parent_id = yit_get_base_product_id( $product );
|
324 |
|
325 |
-
|
|
|
|
|
|
|
326 |
|
327 |
-
$products_in_cart[] = $product;
|
328 |
-
$products_in_cart_titles[ $product_id ] = $product->get_title();
|
329 |
-
$product_in_cart_quantity += $values['quantity'];
|
330 |
-
}
|
331 |
|
332 |
-
|
333 |
-
|
|
|
|
|
|
|
|
|
334 |
|
|
|
|
|
335 |
|
336 |
if( empty($products_in_cart_titles) ) {
|
337 |
return false;
|
@@ -392,6 +393,7 @@ if ( !class_exists( 'YWCM_Cart_Messages' ) ) {
|
|
392 |
$category_in_cart = array();
|
393 |
|
394 |
foreach ( $categories as $category ) {
|
|
|
395 |
if( WC()->cart ){
|
396 |
foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) {
|
397 |
$product = $values['data'];
|
@@ -405,6 +407,7 @@ if ( !class_exists( 'YWCM_Cart_Messages' ) ) {
|
|
405 |
}
|
406 |
}
|
407 |
}
|
|
|
408 |
}
|
409 |
|
410 |
if ( empty( $category_in_cart ) ) {
|
316 |
$products_in_cart = array();
|
317 |
$products_in_cart_titles = array();
|
318 |
|
319 |
+
if ( WC()->cart ) {
|
|
|
|
|
|
|
|
|
320 |
|
321 |
+
foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) {
|
322 |
+
$product = $values['data'];
|
323 |
+
$product_id = $product->get_id();
|
324 |
+
$parent_id = yit_get_base_product_id( $product );
|
325 |
|
|
|
|
|
|
|
|
|
326 |
|
327 |
+
if ( in_array( $product_id, $products ) || in_array( $parent_id, $products ) ) {
|
328 |
+
$products_in_cart[] = $values['data'];
|
329 |
+
|
330 |
+
$products_in_cart_titles[ $product_id ] = $product->get_title();
|
331 |
+
$product_in_cart_quantity += $values['quantity'];
|
332 |
+
}
|
333 |
|
334 |
+
}
|
335 |
+
}
|
336 |
|
337 |
if( empty($products_in_cart_titles) ) {
|
338 |
return false;
|
393 |
$category_in_cart = array();
|
394 |
|
395 |
foreach ( $categories as $category ) {
|
396 |
+
|
397 |
if( WC()->cart ){
|
398 |
foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) {
|
399 |
$product = $values['data'];
|
407 |
}
|
408 |
}
|
409 |
}
|
410 |
+
|
411 |
}
|
412 |
|
413 |
if ( empty( $category_in_cart ) ) {
|
modules/yith-woocommerce-cart-messages/yith-cart-messages.php
CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://yithemes.com/themes/plugins/yith-woocommerce-cart-messages
|
|
5 |
Description: WooCommerce plugin for add custom messages to your customers
|
6 |
Author: YITHEMES
|
7 |
Text Domain: yith-woocommerce-cart-messages
|
8 |
-
Version: 1.2.
|
9 |
Author URI: http://yithemes.com/
|
10 |
*/
|
11 |
|
@@ -49,8 +49,9 @@ register_activation_hook( __FILE__, 'yith_plugin_registration_hook' );
|
|
49 |
if ( defined( 'YITH_YWCM_VERSION' ) ) {
|
50 |
return;
|
51 |
}else{
|
52 |
-
define( 'YITH_YWCM_VERSION', '1.2.
|
53 |
}
|
|
|
54 |
if ( ! defined( 'YITH_YWCM_SUFFIX' ) ) {
|
55 |
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
56 |
define( 'YITH_YWCM_SUFFIX', $suffix );
|
5 |
Description: WooCommerce plugin for add custom messages to your customers
|
6 |
Author: YITHEMES
|
7 |
Text Domain: yith-woocommerce-cart-messages
|
8 |
+
Version: 1.2.1
|
9 |
Author URI: http://yithemes.com/
|
10 |
*/
|
11 |
|
49 |
if ( defined( 'YITH_YWCM_VERSION' ) ) {
|
50 |
return;
|
51 |
}else{
|
52 |
+
define( 'YITH_YWCM_VERSION', '1.2.1' );
|
53 |
}
|
54 |
+
|
55 |
if ( ! defined( 'YITH_YWCM_SUFFIX' ) ) {
|
56 |
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
57 |
define( 'YITH_YWCM_SUFFIX', $suffix );
|
modules/yith-woocommerce-product-vendors/assets/css/admin.css
CHANGED
@@ -335,7 +335,8 @@ small.yith-wcmv-suborder-owner:not(.single-order) {
|
|
335 |
border: none;
|
336 |
}
|
337 |
|
338 |
-
#vendor-details input[type=text]
|
|
|
339 |
width: 40%;
|
340 |
margin-bottom: 10px;
|
341 |
}
|
@@ -598,12 +599,112 @@ span.vacation-date-field {
|
|
598 |
display: none;
|
599 |
}
|
600 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
601 |
/* WC 2.7 fix */
|
602 |
.woocommerce.toplevel_page_yith_vendor_commissions .form-field .select2-container,
|
603 |
.post-type-product.taxonomy-yith_shop_vendor .form-field .select2-container {
|
604 |
width: 100%!important;
|
605 |
}
|
606 |
|
|
|
607 |
/* Responsive */
|
608 |
@media (max-width: 1200px) {
|
609 |
#vendor-details .form-field textarea:not(.wp-editor-area) {
|
@@ -613,7 +714,8 @@ span.vacation-date-field {
|
|
613 |
|
614 |
@media screen and (max-width: 782px) {
|
615 |
#s2id_yith_vendor_admins,
|
616 |
-
#vendor-details input[type=text]
|
|
|
617 |
width: 100%;
|
618 |
}
|
619 |
}
|
335 |
border: none;
|
336 |
}
|
337 |
|
338 |
+
#vendor-details input[type=text],
|
339 |
+
#vendor-details input[type=number] {
|
340 |
width: 40%;
|
341 |
margin-bottom: 10px;
|
342 |
}
|
599 |
display: none;
|
600 |
}
|
601 |
|
602 |
+
|
603 |
+
/* shipping */
|
604 |
+
|
605 |
+
.vendor_limited_access.woocommerce.toplevel_page_yith_vendor_settings .wc-backbone-modal .wc-backbone-modal-content {
|
606 |
+
width: initial;
|
607 |
+
}
|
608 |
+
|
609 |
+
.yith-wpv-shipping-methods-add.add_shipping_method{
|
610 |
+
position: relative;
|
611 |
+
}
|
612 |
+
|
613 |
+
.yith-vendor-admin-wrap .yith_admin_vendor_shipping .form-field span.description {
|
614 |
+
display: block;
|
615 |
+
}
|
616 |
+
|
617 |
+
.yith-vendor-admin-wrap .yith_admin_vendor_shipping .form-field.checkbox span.description {
|
618 |
+
display: inline-block;
|
619 |
+
}
|
620 |
+
|
621 |
+
.yith-vendor-admin-wrap .yith_admin_vendor_shipping .button-secondary {
|
622 |
+
float: right;
|
623 |
+
}
|
624 |
+
|
625 |
+
.vendor_limited_access.woocommerce.toplevel_page_yith_vendor_settings .yith-wpv-shipping-method-form-container {
|
626 |
+
display: none;
|
627 |
+
}
|
628 |
+
|
629 |
+
.yith-vendor-admin-wrap .wc-shipping-zone-postcodes {
|
630 |
+
display: none;
|
631 |
+
margin-top: 10px;
|
632 |
+
}
|
633 |
+
|
634 |
+
.vendor_limited_access.woocommerce.toplevel_page_yith_vendor_settings .wc-shipping-zone-method-remove {
|
635 |
+
display: inline-block;
|
636 |
+
width: 14px;
|
637 |
+
height: 13px;
|
638 |
+
background-repeat: no-repeat;
|
639 |
+
background-image: url(../images/remove_shipping_method.png);
|
640 |
+
margin: 0 5px;
|
641 |
+
margin-bottom: -1px;
|
642 |
+
cursor: pointer;
|
643 |
+
}
|
644 |
+
|
645 |
+
.vendor_limited_access.woocommerce.toplevel_page_yith_vendor_settings .wc-backbone-modal-edit-shipping-mode .woocommerce-help-tip,
|
646 |
+
.vendor_limited_access.woocommerce.toplevel_page_yith_vendor_settings .wc-backbone-modal-edit-shipping-mode .select2-container {
|
647 |
+
display: none !important;
|
648 |
+
}
|
649 |
+
|
650 |
+
.vendor_limited_access.woocommerce.toplevel_page_yith_vendor_settings .wc-backbone-modal-edit-shipping-mode select {
|
651 |
+
display: block !important;
|
652 |
+
width: 100%;
|
653 |
+
}
|
654 |
+
|
655 |
+
.vendor_limited_access.woocommerce.toplevel_page_yith_vendor_settings .yith-wpdv-wc-shipping-zone-postcodes-toggle {
|
656 |
+
display: inline-block;
|
657 |
+
}
|
658 |
+
|
659 |
+
.vendor_limited_access.woocommerce.toplevel_page_yith_vendor_settings table.wc-shipping-classes td.wc-shipping-zone-methods ul li::before,
|
660 |
+
.vendor_limited_access.woocommerce.toplevel_page_yith_vendor_settings table.wc-shipping-zone-methods td.wc-shipping-zone-methods ul li::before,
|
661 |
+
.vendor_limited_access.woocommerce.toplevel_page_yith_vendor_settings table.wc-shipping-zones td.wc-shipping-zone-methods ul li::before {
|
662 |
+
content: "";
|
663 |
+
}
|
664 |
+
|
665 |
+
.vendor_limited_access.woocommerce.toplevel_page_yith_vendor_settings table.wc-shipping-classes td.wc-shipping-zone-methods ul li,
|
666 |
+
.vendor_limited_access.woocommerce.toplevel_page_yith_vendor_settings table.wc-shipping-zone-methods td.wc-shipping-zone-methods ul li,
|
667 |
+
.vendor_limited_access.woocommerce.toplevel_page_yith_vendor_settings table.wc-shipping-zones td.wc-shipping-zone-methods ul li {
|
668 |
+
margin-left: 5px;
|
669 |
+
display: block;
|
670 |
+
}
|
671 |
+
|
672 |
+
h2.commission-details-shipping:before{
|
673 |
+
display: inline-block;
|
674 |
+
width:30px;
|
675 |
+
height:23px;
|
676 |
+
background-image: url(../images/vendor-shipping-fee.png);
|
677 |
+
background-repeat: no-repeat;
|
678 |
+
content: '';
|
679 |
+
margin:-3px 10px -3px 0;
|
680 |
+
}
|
681 |
+
|
682 |
+
h2.commission-details-product:before{
|
683 |
+
display: inline-block;
|
684 |
+
width:30px;
|
685 |
+
height:23px;
|
686 |
+
background-image: url(../images/vendor-commission-fee.png);
|
687 |
+
background-repeat: no-repeat;
|
688 |
+
content: '';
|
689 |
+
margin:-3px 10px -3px 0;
|
690 |
+
}
|
691 |
+
|
692 |
+
/* === Edit Vendor === */
|
693 |
+
label[for=yith_vendor_social_live-chat] small em {
|
694 |
+
font-weight: bold;
|
695 |
+
}
|
696 |
+
|
697 |
+
label[for=yith_vendor_social_live-chat] small {
|
698 |
+
font-weight: 400;
|
699 |
+
}
|
700 |
+
|
701 |
/* WC 2.7 fix */
|
702 |
.woocommerce.toplevel_page_yith_vendor_commissions .form-field .select2-container,
|
703 |
.post-type-product.taxonomy-yith_shop_vendor .form-field .select2-container {
|
704 |
width: 100%!important;
|
705 |
}
|
706 |
|
707 |
+
|
708 |
/* Responsive */
|
709 |
@media (max-width: 1200px) {
|
710 |
#vendor-details .form-field textarea:not(.wp-editor-area) {
|
714 |
|
715 |
@media screen and (max-width: 782px) {
|
716 |
#s2id_yith_vendor_admins,
|
717 |
+
#vendor-details input[type=text],
|
718 |
+
#vendor-details input[type=number] {
|
719 |
width: 100%;
|
720 |
}
|
721 |
}
|
modules/yith-woocommerce-product-vendors/assets/images/43-bg.png
ADDED
Binary file
|
modules/yith-woocommerce-product-vendors/assets/images/43-icon.png
ADDED
Binary file
|
modules/yith-woocommerce-product-vendors/assets/images/43.png
ADDED
Binary file
|
modules/yith-woocommerce-product-vendors/assets/images/vendor-commission-fee.png
ADDED
Binary file
|
modules/yith-woocommerce-product-vendors/includes/class.yith-commission.php
CHANGED
@@ -30,6 +30,7 @@ if ( ! class_exists( 'YITH_Commission' ) ) {
|
|
30 |
* @property float $rate The rate commission to assign
|
31 |
* @property float $amount The amount payed to $user_id
|
32 |
* @property string $status The status of commission (one between 'pending', 'unpaid' and 'paid')
|
|
|
33 |
* @property string $last_edit When was the last update
|
34 |
* @property string $last_edit_gmt When was the last update
|
35 |
*/
|
@@ -206,7 +207,8 @@ if ( ! class_exists( 'YITH_Commission' ) ) {
|
|
206 |
'vendor_id' => 0,
|
207 |
'rate' => YITH_Vendors()->get_base_commission(),
|
208 |
'amount' => 0,
|
209 |
-
'status' => 'pending'
|
|
|
210 |
);
|
211 |
|
212 |
// set commission by vendor
|
30 |
* @property float $rate The rate commission to assign
|
31 |
* @property float $amount The amount payed to $user_id
|
32 |
* @property string $status The status of commission (one between 'pending', 'unpaid' and 'paid')
|
33 |
+
* @property string $type The commission type (one between 'product' or 'shipping')
|
34 |
* @property string $last_edit When was the last update
|
35 |
* @property string $last_edit_gmt When was the last update
|
36 |
*/
|
207 |
'vendor_id' => 0,
|
208 |
'rate' => YITH_Vendors()->get_base_commission(),
|
209 |
'amount' => 0,
|
210 |
+
'status' => 'pending',
|
211 |
+
'type' => 'product'
|
212 |
);
|
213 |
|
214 |
// set commission by vendor
|
modules/yith-woocommerce-product-vendors/includes/class.yith-commissions.php
CHANGED
@@ -454,6 +454,7 @@ if ( ! class_exists( 'YITH_Commissions' ) ) {
|
|
454 |
rate decimal(5,4) NOT NULL,
|
455 |
amount double(15,4) NOT NULL,
|
456 |
status varchar(100) NOT NULL,
|
|
|
457 |
last_edit DATETIME NOT NULL DEFAULT '000-00-00 00:00:00',
|
458 |
last_edit_gmt DATETIME NOT NULL DEFAULT '000-00-00 00:00:00',
|
459 |
PRIMARY KEY (ID)
|
@@ -577,12 +578,6 @@ if ( ! class_exists( 'YITH_Commissions' ) ) {
|
|
577 |
'fields' => 'ids'
|
578 |
);
|
579 |
|
580 |
-
foreach ( array( 'order_id', 'vendor_id', 'status', 'paged', 'm', 's', 'orderby', 'order', 'product_id' ) as $key ) {
|
581 |
-
if ( isset( $_REQUEST[ $key ] ) ) {
|
582 |
-
//$default_args[ $key ] = $_REQUEST[ $key ];
|
583 |
-
}
|
584 |
-
}
|
585 |
-
|
586 |
$q = wp_parse_args( $q, $default_args );
|
587 |
|
588 |
// Fairly insane upper bound for search string lengths.
|
@@ -618,6 +613,9 @@ if ( ! class_exists( 'YITH_Commissions' ) ) {
|
|
618 |
if ( ! empty( $q['vendor_id'] ) ) {
|
619 |
$where .= $wpdb->prepare( " AND c.vendor_id = %d", $q['vendor_id'] );
|
620 |
}
|
|
|
|
|
|
|
621 |
if ( ! empty( $q['status'] ) && 'all' != $q['status'] ) {
|
622 |
if ( is_array( $q['status'] ) ) {
|
623 |
$q['status'] = implode( "', '", $q['status'] );
|
@@ -835,8 +833,7 @@ if ( ! class_exists( 'YITH_Commissions' ) ) {
|
|
835 |
* @since 1.0
|
836 |
*/
|
837 |
public function register_commissions( $order_id ) {
|
838 |
-
|
839 |
-
// Only process commissions once
|
840 |
$processed = get_post_meta( $order_id, '_commissions_processed', true );
|
841 |
if ( $processed && $processed == 'yes' ) {
|
842 |
return;
|
@@ -891,7 +888,7 @@ if ( ! class_exists( 'YITH_Commissions' ) ) {
|
|
891 |
$commission_included_tax = 'yes' == get_option( 'yith_wpv_include_tax', 'no' );
|
892 |
$commission_included_coupon = 'yes' == get_option( 'yith_wpv_include_coupon', 'no' );
|
893 |
|
894 |
-
if(! empty( $commission_id ) ){
|
895 |
//Add note to commission to know if the commission have benne calculated included or escluded tax and coupon
|
896 |
$tax = $commission_included_tax ? _x( 'included', 'means: Vendor commission have been calculated: tax included', 'yith-woocommerce-product-vendors' ) : _x( 'excluded', 'means: Vendor commission have been calculated: tax excluded', 'yith-woocommerce-product-vendors' );
|
897 |
$coupon = $commission_included_coupon ? _x( 'included', 'means: Vendor commission have been calculated: tax included', 'yith-woocommerce-product-vendors' ) : _x( 'excluded', 'means: Vendor commission have been calculated: tax excluded', 'yith-woocommerce-product-vendors' );
|
@@ -1031,6 +1028,40 @@ if ( ! class_exists( 'YITH_Commissions' ) ) {
|
|
1031 |
}
|
1032 |
}
|
1033 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1034 |
/**
|
1035 |
* Register the commission as unpaid when the order is completed
|
1036 |
*
|
@@ -1039,25 +1070,7 @@ if ( ! class_exists( 'YITH_Commissions' ) ) {
|
|
1039 |
* @since 1.0
|
1040 |
*/
|
1041 |
public function register_commissions_unpaid( $order_id ) {
|
1042 |
-
|
1043 |
-
// Ensure the order have commissions processed
|
1044 |
-
$processed = get_post_meta( $order_id, '_commissions_processed', true );
|
1045 |
-
if ( $processed && $processed == 'yes' ) {
|
1046 |
-
$order = wc_get_order( $order_id );
|
1047 |
-
|
1048 |
-
foreach ( $order->get_items() as $item_id => $item ) {
|
1049 |
-
if ( empty( $item['commission_id'] ) ) {
|
1050 |
-
continue;
|
1051 |
-
}
|
1052 |
-
|
1053 |
-
// retrieve commission
|
1054 |
-
$commission = YITH_Commission( intval( $item['commission_id'] ) );
|
1055 |
-
|
1056 |
-
// set commission as unpaid, ready to be paid
|
1057 |
-
$commission->update_status( 'unpaid' );
|
1058 |
-
$commission->save_data();
|
1059 |
-
}
|
1060 |
-
}
|
1061 |
}
|
1062 |
|
1063 |
/**
|
@@ -1068,30 +1081,15 @@ if ( ! class_exists( 'YITH_Commissions' ) ) {
|
|
1068 |
* @since 1.0
|
1069 |
*/
|
1070 |
public function register_commissions_refunded( $order_id ) {
|
|
|
1071 |
|
1072 |
-
|
1073 |
-
|
1074 |
-
$refunded = get_post_meta( $order_id, '_commissions_refunded', true );
|
1075 |
-
|
1076 |
-
if ( $processed && $processed == 'yes' && ( empty( $refunded ) || $refunded != 'no' ) ) {
|
1077 |
-
$order = wc_get_order( $order_id );
|
1078 |
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
// retrieve commission
|
1085 |
-
$commission = YITH_Commission( intval( $item['commission_id'] ) );
|
1086 |
-
|
1087 |
-
// set commission as refunded
|
1088 |
-
$commission->update_status( 'refunded' );
|
1089 |
-
$commission->save_data();
|
1090 |
-
|
1091 |
-
// Mark commissions as processed
|
1092 |
-
update_post_meta( $order_id, '_commissions_refunded', 'yes' );
|
1093 |
-
}
|
1094 |
-
}
|
1095 |
}
|
1096 |
|
1097 |
/**
|
@@ -1102,30 +1100,15 @@ if ( ! class_exists( 'YITH_Commissions' ) ) {
|
|
1102 |
* @since 1.0
|
1103 |
*/
|
1104 |
public function register_commissions_cancelled( $order_id ) {
|
|
|
1105 |
|
1106 |
-
|
1107 |
-
|
1108 |
-
$cancelled = get_post_meta( $order_id, '_commissions_cancelled', true );
|
1109 |
-
|
1110 |
-
if ( $processed && $processed == 'yes' && ( empty( $cancelled ) || $cancelled != 'no' ) ) {
|
1111 |
-
$order = wc_get_order( $order_id );
|
1112 |
-
|
1113 |
-
foreach ( $order->get_items() as $item_id => $item ) {
|
1114 |
-
if ( empty( $item['commission_id'] ) ) {
|
1115 |
-
continue;
|
1116 |
-
}
|
1117 |
-
|
1118 |
-
// retrieve commission
|
1119 |
-
$commission = YITH_Commission( intval( $item['commission_id'] ) );
|
1120 |
-
|
1121 |
-
// set commission as refunded
|
1122 |
-
$commission->update_status( 'cancelled' );
|
1123 |
-
$commission->save_data();
|
1124 |
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
}
|
1130 |
|
1131 |
/**
|
@@ -1136,26 +1119,7 @@ if ( ! class_exists( 'YITH_Commissions' ) ) {
|
|
1136 |
* @since 1.0
|
1137 |
*/
|
1138 |
public function register_commissions_pending( $order_id ) {
|
1139 |
-
|
1140 |
-
// Ensure the order have commissions processed
|
1141 |
-
$processed = get_post_meta( $order_id, '_commissions_processed', true );
|
1142 |
-
|
1143 |
-
if ( $processed && $processed == 'yes' ) {
|
1144 |
-
$order = wc_get_order( $order_id );
|
1145 |
-
|
1146 |
-
foreach ( $order->get_items() as $item_id => $item ) {
|
1147 |
-
if ( empty( $item['commission_id'] ) ) {
|
1148 |
-
continue;
|
1149 |
-
}
|
1150 |
-
|
1151 |
-
// retrieve commission
|
1152 |
-
$commission = YITH_Commission( intval( $item['commission_id'] ) );
|
1153 |
-
|
1154 |
-
// set commission as refunded
|
1155 |
-
$commission->update_status( 'pending' );
|
1156 |
-
$commission->save_data();
|
1157 |
-
}
|
1158 |
-
}
|
1159 |
}
|
1160 |
|
1161 |
/**
|
454 |
rate decimal(5,4) NOT NULL,
|
455 |
amount double(15,4) NOT NULL,
|
456 |
status varchar(100) NOT NULL,
|
457 |
+
type VARCHAR(30) NOT NULL DEFAULT 'product'
|
458 |
last_edit DATETIME NOT NULL DEFAULT '000-00-00 00:00:00',
|
459 |
last_edit_gmt DATETIME NOT NULL DEFAULT '000-00-00 00:00:00',
|
460 |
PRIMARY KEY (ID)
|
578 |
'fields' => 'ids'
|
579 |
);
|
580 |
|
|
|
|
|
|
|
|
|
|
|
|
|
581 |
$q = wp_parse_args( $q, $default_args );
|
582 |
|
583 |
// Fairly insane upper bound for search string lengths.
|
613 |
if ( ! empty( $q['vendor_id'] ) ) {
|
614 |
$where .= $wpdb->prepare( " AND c.vendor_id = %d", $q['vendor_id'] );
|
615 |
}
|
616 |
+
if ( ! empty( $q['type'] ) && 'all' != $q['type'] ) {
|
617 |
+
$where .= $wpdb->prepare( " AND c.type = %s", $q['type'] );
|
618 |
+
}
|
619 |
if ( ! empty( $q['status'] ) && 'all' != $q['status'] ) {
|
620 |
if ( is_array( $q['status'] ) ) {
|
621 |
$q['status'] = implode( "', '", $q['status'] );
|
833 |
* @since 1.0
|
834 |
*/
|
835 |
public function register_commissions( $order_id ) {
|
836 |
+
// Only process commissions once
|
|
|
837 |
$processed = get_post_meta( $order_id, '_commissions_processed', true );
|
838 |
if ( $processed && $processed == 'yes' ) {
|
839 |
return;
|
888 |
$commission_included_tax = 'yes' == get_option( 'yith_wpv_include_tax', 'no' );
|
889 |
$commission_included_coupon = 'yes' == get_option( 'yith_wpv_include_coupon', 'no' );
|
890 |
|
891 |
+
if( ! empty( $commission_id ) ){
|
892 |
//Add note to commission to know if the commission have benne calculated included or escluded tax and coupon
|
893 |
$tax = $commission_included_tax ? _x( 'included', 'means: Vendor commission have been calculated: tax included', 'yith-woocommerce-product-vendors' ) : _x( 'excluded', 'means: Vendor commission have been calculated: tax excluded', 'yith-woocommerce-product-vendors' );
|
894 |
$coupon = $commission_included_coupon ? _x( 'included', 'means: Vendor commission have been calculated: tax included', 'yith-woocommerce-product-vendors' ) : _x( 'excluded', 'means: Vendor commission have been calculated: tax excluded', 'yith-woocommerce-product-vendors' );
|
1028 |
}
|
1029 |
}
|
1030 |
|
1031 |
+
public function register_commissions_status( $order_id, $status ){
|
1032 |
+
// Ensure the order have commissions processed
|
1033 |
+
$processed = get_post_meta( $order_id, '_commissions_processed', true );
|
1034 |
+
$commission_processed = false;
|
1035 |
+
|
1036 |
+
if ( $processed && $processed == 'yes' ) {
|
1037 |
+
$order = wc_get_order( $order_id );
|
1038 |
+
|
1039 |
+
$commission_ids = array();
|
1040 |
+
|
1041 |
+
foreach ( $order->get_items() as $item_id => $item ){
|
1042 |
+
if ( ! empty( $item['commission_id'] ) ) {
|
1043 |
+
$commission_ids[] = $item['commission_id'];
|
1044 |
+
}
|
1045 |
+
}
|
1046 |
+
|
1047 |
+
$commission_ids = apply_filters( 'yith_wcmv_register_commissions_status', $commission_ids, $order_id, $status );
|
1048 |
+
|
1049 |
+
foreach ( $commission_ids as $commission_id ) {
|
1050 |
+
|
1051 |
+
$commission_processed = true;
|
1052 |
+
|
1053 |
+
// retrieve commission
|
1054 |
+
$commission = YITH_Commission( intval( $commission_id ) );
|
1055 |
+
|
1056 |
+
// set commission as unpaid, ready to be paid
|
1057 |
+
$commission->update_status( $status );
|
1058 |
+
$commission->save_data();
|
1059 |
+
}
|
1060 |
+
}
|
1061 |
+
|
1062 |
+
return $commission_processed;
|
1063 |
+
}
|
1064 |
+
|
1065 |
/**
|
1066 |
* Register the commission as unpaid when the order is completed
|
1067 |
*
|
1070 |
* @since 1.0
|
1071 |
*/
|
1072 |
public function register_commissions_unpaid( $order_id ) {
|
1073 |
+
$this->register_commissions_status( $order_id, 'unpaid' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1074 |
}
|
1075 |
|
1076 |
/**
|
1081 |
* @since 1.0
|
1082 |
*/
|
1083 |
public function register_commissions_refunded( $order_id ) {
|
1084 |
+
$refunded = get_post_meta( $order_id, '_commissions_refunded', true );
|
1085 |
|
1086 |
+
if( ( empty( $refunded ) || $refunded != 'no' ) ){
|
1087 |
+
$processed = $this->register_commissions_status( $order_id, 'refunded' );
|
|
|
|
|
|
|
|
|
1088 |
|
1089 |
+
if( $processed ){
|
1090 |
+
update_post_meta( $order_id, '_commissions_refunded', 'yes' );
|
1091 |
+
}
|
1092 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1093 |
}
|
1094 |
|
1095 |
/**
|
1100 |
* @since 1.0
|
1101 |
*/
|
1102 |
public function register_commissions_cancelled( $order_id ) {
|
1103 |
+
$cancelled = get_post_meta( $order_id, '_commissions_cancelled', true );
|
1104 |
|
1105 |
+
if( ( empty( $cancelled ) || $cancelled != 'no' ) ){
|
1106 |
+
$processed = $this->register_commissions_status( $order_id, 'cancelled' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1107 |
|
1108 |
+
if( $processed ){
|
1109 |
+
update_post_meta( $order_id, '_commissions_cancelled', 'yes' );
|
1110 |
+
}
|
1111 |
+
}
|
1112 |
}
|
1113 |
|
1114 |
/**
|
1119 |
* @since 1.0
|
1120 |
*/
|
1121 |
public function register_commissions_pending( $order_id ) {
|
1122 |
+
$this->register_commissions_status( $order_id, 'pending' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1123 |
}
|
1124 |
|
1125 |
/**
|
modules/yith-woocommerce-product-vendors/includes/class.yith-orders.php
CHANGED
@@ -206,6 +206,7 @@ if ( ! class_exists ( 'YITH_Orders' ) ) {
|
|
206 |
* @return void
|
207 |
*/
|
208 |
public function create_suborder ( $parent_order, $vendor_id, $vendor_products, $posted ) {
|
|
|
209 |
/** @var $parent_order WC_Order */
|
210 |
$vendor = yith_get_vendor ( $vendor_id, 'vendor' );
|
211 |
$parent_order_id = yit_get_prop( $parent_order, 'id' );
|
@@ -363,9 +364,25 @@ if ( ! class_exists ( 'YITH_Orders' ) ) {
|
|
363 |
}
|
364 |
}
|
365 |
|
366 |
-
//Shipping
|
367 |
-
|
368 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
369 |
|
370 |
//Coupons
|
371 |
$order_coupons = $parent_order->get_used_coupons ();
|
@@ -1032,12 +1049,13 @@ if ( ! class_exists ( 'YITH_Orders' ) ) {
|
|
1032 |
$item_to_add = array();
|
1033 |
|
1034 |
if( ! empty( $_POST[ 'item_to_add' ] ) ){
|
1035 |
-
|
1036 |
-
|
|
|
1037 |
}
|
1038 |
|
1039 |
else {
|
1040 |
-
$item_to_add = sanitize_text_field ( $
|
1041 |
}
|
1042 |
}
|
1043 |
|
@@ -1606,7 +1624,13 @@ if ( ! class_exists ( 'YITH_Orders' ) ) {
|
|
1606 |
*/
|
1607 |
public function commissions_attribute_label ( $attribute_label, $meta_key, $product = false ) {
|
1608 |
global $pagenow;
|
1609 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1610 |
$line_items = $order->get_items ( 'line_item' );
|
1611 |
$item_meta_key = wp_get_post_parent_id ( yit_get_prop( $order, 'id' ) ) ? '_commission_id' : '_child__commission_id';
|
1612 |
$is_variable_product = $product instanceof WC_Product_Variation;
|
@@ -1618,14 +1642,15 @@ if ( ! class_exists ( 'YITH_Orders' ) ) {
|
|
1618 |
$check = $line_item[ 'variation_id' ] == yit_get_prop( $product, YITH_Vendors()->is_wc_2_7_or_greather ? 'id' : 'variation_id' );
|
1619 |
}
|
1620 |
|
1621 |
-
|
1622 |
$check = $line_item[ 'product_id' ] == yit_get_prop( $product, 'id' );
|
1623 |
}
|
1624 |
|
1625 |
if ( $check ) {
|
1626 |
$commission_id = wc_get_order_item_meta ( $line_item_id, $item_meta_key, true );
|
1627 |
$commission = YITH_Commission( $commission_id );
|
1628 |
-
$admin_url =
|
|
|
1629 |
$url_attribute_label = sprintf (
|
1630 |
"<a href='%s' class='%s'>%s</a> <small>(%s: <strong>%s</strong>)</small>",
|
1631 |
$admin_url,
|
@@ -1942,7 +1967,7 @@ if ( ! class_exists ( 'YITH_Orders' ) ) {
|
|
1942 |
$is_ajax = defined ( 'DOING_AJAX' ) && DOING_AJAX;
|
1943 |
$is_order_details = is_admin () && 'shop_order' == get_current_screen ()->id;
|
1944 |
|
1945 |
-
return $vendor->is_valid () && $vendor->has_limited_access() && $is_order_details && ! $is_ajax;
|
1946 |
}
|
1947 |
|
1948 |
/**
|
@@ -2105,21 +2130,19 @@ if ( ! class_exists ( 'YITH_Orders' ) ) {
|
|
2105 |
|
2106 |
$wpdb->hide_errors();
|
2107 |
|
2108 |
-
$order_id
|
2109 |
-
$product_ids
|
2110 |
-
$loop
|
2111 |
-
$file_counter
|
|
|
2112 |
|
2113 |
-
|
2114 |
-
$parent_order_id = 0;
|
2115 |
if( wp_get_post_parent_id( $order_id) ){
|
2116 |
-
$order
|
2117 |
$parent_order_id = get_post_field( 'post_parent', $order_id );
|
2118 |
}
|
2119 |
|
2120 |
$suborders = self::get_suborder( $order_id );
|
2121 |
|
2122 |
-
|
2123 |
if ( ! is_array( $product_ids ) ) {
|
2124 |
$product_ids = array( $product_ids );
|
2125 |
}
|
@@ -2135,7 +2158,6 @@ if ( ! class_exists ( 'YITH_Orders' ) ) {
|
|
2135 |
$vendor_orders = $vendor->get_orders();
|
2136 |
$suborder_id = array_intersect( $vendor_orders, $suborders );
|
2137 |
|
2138 |
-
|
2139 |
if( count( $suborder_id ) == 1 ) {
|
2140 |
$suborder_id = implode( '', $suborder_id );
|
2141 |
$order = wc_get_order( $suborder_id );
|
@@ -2144,10 +2166,10 @@ if ( ! class_exists ( 'YITH_Orders' ) ) {
|
|
2144 |
$order = wc_get_order( $parent_order_id );
|
2145 |
}
|
2146 |
|
2147 |
-
$billing_email = yit_get_prop( $order, 'billing_email' );
|
2148 |
|
2149 |
if ( ! $billing_email ) {
|
2150 |
-
|
2151 |
}
|
2152 |
|
2153 |
|
206 |
* @return void
|
207 |
*/
|
208 |
public function create_suborder ( $parent_order, $vendor_id, $vendor_products, $posted ) {
|
209 |
+
|
210 |
/** @var $parent_order WC_Order */
|
211 |
$vendor = yith_get_vendor ( $vendor_id, 'vendor' );
|
212 |
$parent_order_id = yit_get_prop( $parent_order, 'id' );
|
364 |
}
|
365 |
}
|
366 |
|
367 |
+
//Shipping: Store shipping for all packages
|
368 |
+
$shipping_cost = 0;
|
369 |
+
$wc_checkout = WC()->checkout();
|
370 |
+
|
371 |
+
foreach ( WC()->shipping->get_packages() as $package_key => $package ) {
|
372 |
+
if( ! empty( $package['yith-vendor'] ) && $package['yith-vendor'] instanceof YITH_Vendor && $package['yith-vendor']->id == $vendor_id ){
|
373 |
+
if ( isset( $package['rates'][ $wc_checkout->shipping_methods[ $package_key ] ] ) ) {
|
374 |
+
$shipping_item_id = $suborder->add_shipping( $package['rates'][ $wc_checkout->shipping_methods[ $package_key ] ] );
|
375 |
+
$shipping_cost += $package['rates'][ $wc_checkout->shipping_methods[ $package_key ] ]->cost;
|
376 |
+
|
377 |
+
if ( ! $shipping_item_id ) {
|
378 |
+
throw new Exception( sprintf( __( 'Error %d: Unable to create order. Please try again.', 'woocommerce' ), 527 ) );
|
379 |
+
}
|
380 |
+
|
381 |
+
// Allows plugins to add order item meta to shipping
|
382 |
+
do_action( 'yith_wcmv_add_shipping_order_item', $suborder_id, $shipping_item_id, $package_key );
|
383 |
+
}
|
384 |
+
}
|
385 |
+
}
|
386 |
|
387 |
//Coupons
|
388 |
$order_coupons = $parent_order->get_used_coupons ();
|
1049 |
$item_to_add = array();
|
1050 |
|
1051 |
if( ! empty( $_POST[ 'item_to_add' ] ) ){
|
1052 |
+
$item_to_add = $_POST[ 'item_to_add' ];
|
1053 |
+
if( is_array( $item_to_add ) ){
|
1054 |
+
$item_to_add = sanitize_text_field( array_shift ( $item_to_add ) );
|
1055 |
}
|
1056 |
|
1057 |
else {
|
1058 |
+
$item_to_add = sanitize_text_field ( $item_to_add );
|
1059 |
}
|
1060 |
}
|
1061 |
|
1624 |
*/
|
1625 |
public function commissions_attribute_label ( $attribute_label, $meta_key, $product = false ) {
|
1626 |
global $pagenow;
|
1627 |
+
|
1628 |
+
$order = ! empty( $_GET[ 'post' ] ) ? wc_get_order ( $_GET[ 'post' ] ) : false;
|
1629 |
+
$order = apply_filters( 'yith_wcmv_commissions_attribute_label_order_object', $order );
|
1630 |
+
|
1631 |
+
$is_edit_order_page = apply_filters( 'yith_wcmv_commissions_attribute_label_is_edit_order_page', $product && 'post.php' == $pagenow );
|
1632 |
+
|
1633 |
+
if ( $is_edit_order_page && $order ) {
|
1634 |
$line_items = $order->get_items ( 'line_item' );
|
1635 |
$item_meta_key = wp_get_post_parent_id ( yit_get_prop( $order, 'id' ) ) ? '_commission_id' : '_child__commission_id';
|
1636 |
$is_variable_product = $product instanceof WC_Product_Variation;
|
1642 |
$check = $line_item[ 'variation_id' ] == yit_get_prop( $product, YITH_Vendors()->is_wc_2_7_or_greather ? 'id' : 'variation_id' );
|
1643 |
}
|
1644 |
|
1645 |
+
elseif( $product instanceof WC_Product ) {
|
1646 |
$check = $line_item[ 'product_id' ] == yit_get_prop( $product, 'id' );
|
1647 |
}
|
1648 |
|
1649 |
if ( $check ) {
|
1650 |
$commission_id = wc_get_order_item_meta ( $line_item_id, $item_meta_key, true );
|
1651 |
$commission = YITH_Commission( $commission_id );
|
1652 |
+
$admin_url = apply_filters( 'yith_wcmv_commissions_list_table_commission_url', $commission->get_view_url ( 'admin' ), $commission );
|
1653 |
+
|
1654 |
$url_attribute_label = sprintf (
|
1655 |
"<a href='%s' class='%s'>%s</a> <small>(%s: <strong>%s</strong>)</small>",
|
1656 |
$admin_url,
|
1967 |
$is_ajax = defined ( 'DOING_AJAX' ) && DOING_AJAX;
|
1968 |
$is_order_details = is_admin () && 'shop_order' == get_current_screen ()->id;
|
1969 |
|
1970 |
+
return apply_filters( 'yith_wcmv_is_vendor_order_details_page', $vendor->is_valid () && $vendor->has_limited_access() && $is_order_details && ! $is_ajax );
|
1971 |
}
|
1972 |
|
1973 |
/**
|
2130 |
|
2131 |
$wpdb->hide_errors();
|
2132 |
|
2133 |
+
$order_id = intval( $_POST['order_id'] );
|
2134 |
+
$product_ids = $_POST['product_ids'];
|
2135 |
+
$loop = intval( $_POST['loop'] );
|
2136 |
+
$file_counter = 0;
|
2137 |
+
$parent_order_id = 0;
|
2138 |
|
|
|
|
|
2139 |
if( wp_get_post_parent_id( $order_id) ){
|
2140 |
+
$order = wc_get_order( $order_id );
|
2141 |
$parent_order_id = get_post_field( 'post_parent', $order_id );
|
2142 |
}
|
2143 |
|
2144 |
$suborders = self::get_suborder( $order_id );
|
2145 |
|
|
|
2146 |
if ( ! is_array( $product_ids ) ) {
|
2147 |
$product_ids = array( $product_ids );
|
2148 |
}
|
2158 |
$vendor_orders = $vendor->get_orders();
|
2159 |
$suborder_id = array_intersect( $vendor_orders, $suborders );
|
2160 |
|
|
|
2161 |
if( count( $suborder_id ) == 1 ) {
|
2162 |
$suborder_id = implode( '', $suborder_id );
|
2163 |
$order = wc_get_order( $suborder_id );
|
2166 |
$order = wc_get_order( $parent_order_id );
|
2167 |
}
|
2168 |
|
2169 |
+
$billing_email = ! empty( $order ) ? yit_get_prop( $order, 'billing_email' ) : false;
|
2170 |
|
2171 |
if ( ! $billing_email ) {
|
2172 |
+
return;
|
2173 |
}
|
2174 |
|
2175 |
|
modules/yith-woocommerce-product-vendors/includes/class.yith-vendor.php
CHANGED
@@ -13,6 +13,8 @@ if ( ! defined ( 'ABSPATH' ) ) {
|
|
13 |
|
14 |
if ( ! class_exists ( 'YITH_Vendor' ) ) {
|
15 |
|
|
|
|
|
16 |
/**
|
17 |
* The main class for the Vendor
|
18 |
*
|
@@ -121,7 +123,7 @@ if ( ! class_exists ( 'YITH_Vendor' ) ) {
|
|
121 |
|
122 |
$terms = wp_get_post_terms ( $vendor, self::$taxonomy );
|
123 |
|
124 |
-
if ( empty( $terms ) ) {
|
125 |
return self::_instance ();
|
126 |
}
|
127 |
|
@@ -772,6 +774,10 @@ if ( ! class_exists ( 'YITH_Vendor' ) ) {
|
|
772 |
* @return array The review average and the product with reviews count
|
773 |
*/
|
774 |
public function get_reviews_average_and_product () {
|
|
|
|
|
|
|
|
|
775 |
$response = apply_filters ( 'yith_wcmv_reviews_average_and_product', array (), $this );
|
776 |
|
777 |
if ( ! empty( $response ) ) {
|
13 |
|
14 |
if ( ! class_exists ( 'YITH_Vendor' ) ) {
|
15 |
|
16 |
+
//@TODO: Add shipping property
|
17 |
+
|
18 |
/**
|
19 |
* The main class for the Vendor
|
20 |
*
|
123 |
|
124 |
$terms = wp_get_post_terms ( $vendor, self::$taxonomy );
|
125 |
|
126 |
+
if ( empty( $terms ) || is_wp_error( $terms ) ) {
|
127 |
return self::_instance ();
|
128 |
}
|
129 |
|
774 |
* @return array The review average and the product with reviews count
|
775 |
*/
|
776 |
public function get_reviews_average_and_product () {
|
777 |
+
if( 'no' == get_option( 'yith_wpv_vendor_show_average_ratings' ) ){
|
778 |
+
return array();
|
779 |
+
}
|
780 |
+
|
781 |
$response = apply_filters ( 'yith_wcmv_reviews_average_and_product', array (), $this );
|
782 |
|
783 |
if ( ! empty( $response ) ) {
|
modules/yith-woocommerce-product-vendors/includes/class.yith-vendors-admin.php
CHANGED
@@ -107,7 +107,7 @@ if ( !class_exists( 'YITH_Vendors_Admin' ) ) {
|
|
107 |
|
108 |
/* Vendor products management */
|
109 |
add_filter( 'request', array( $this, 'filter_list' ) );
|
110 |
-
add_filter( 'wp_count_posts',
|
111 |
add_action( 'save_post', array( $this, 'add_vendor_taxonomy_to_product' ), 10, 2 );
|
112 |
add_action( 'current_screen', array( $this, 'disabled_manage_other_vendors_posts' ) );
|
113 |
|
@@ -298,7 +298,7 @@ if ( !class_exists( 'YITH_Vendors_Admin' ) ) {
|
|
298 |
* @since 1.0
|
299 |
* @use wp_post_count action
|
300 |
*/
|
301 |
-
public function vendor_count_posts( $counts, $type, $perm ) {
|
302 |
$vendor = yith_get_vendor( 'current', 'user' );
|
303 |
|
304 |
if ( ! $vendor->is_valid() || ! in_array( $type, array( 'product', 'shop_order' ) ) || $vendor->is_super_user() || ! $vendor->is_user_admin() ) {
|
@@ -1231,7 +1231,7 @@ if ( !class_exists( 'YITH_Vendors_Admin' ) ) {
|
|
1231 |
global $post;
|
1232 |
$vendor = yith_get_vendor( 'current', 'user' );
|
1233 |
$is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
|
1234 |
-
$is_order_details =
|
1235 |
$refund_management = 'yes' == get_option( 'yith_wpv_vendors_option_order_refund_synchronization', 'no' );
|
1236 |
$quote_management = 'yes' == get_option( 'yith_wpv_vendors_enable_request_quote', 'no' );
|
1237 |
|
107 |
|
108 |
/* Vendor products management */
|
109 |
add_filter( 'request', array( $this, 'filter_list' ) );
|
110 |
+
add_filter( 'wp_count_posts', 'YITH_Vendors_Admin::vendor_count_posts', 10, 3 );
|
111 |
add_action( 'save_post', array( $this, 'add_vendor_taxonomy_to_product' ), 10, 2 );
|
112 |
add_action( 'current_screen', array( $this, 'disabled_manage_other_vendors_posts' ) );
|
113 |
|
298 |
* @since 1.0
|
299 |
* @use wp_post_count action
|
300 |
*/
|
301 |
+
public static function vendor_count_posts( $counts, $type, $perm ) {
|
302 |
$vendor = yith_get_vendor( 'current', 'user' );
|
303 |
|
304 |
if ( ! $vendor->is_valid() || ! in_array( $type, array( 'product', 'shop_order' ) ) || $vendor->is_super_user() || ! $vendor->is_user_admin() ) {
|
1231 |
global $post;
|
1232 |
$vendor = yith_get_vendor( 'current', 'user' );
|
1233 |
$is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
|
1234 |
+
$is_order_details = YITH_Vendors()->orders->is_vendor_order_details_page();
|
1235 |
$refund_management = 'yes' == get_option( 'yith_wpv_vendors_option_order_refund_synchronization', 'no' );
|
1236 |
$quote_management = 'yes' == get_option( 'yith_wpv_vendors_enable_request_quote', 'no' );
|
1237 |
|
modules/yith-woocommerce-product-vendors/includes/class.yith-vendors-frontend.php
CHANGED
@@ -78,7 +78,7 @@ if ( ! class_exists( 'YITH_Vendors_Frontend' ) ) {
|
|
78 |
* @author Andrea Grillo <andrea.grillo@yithemes.com>
|
79 |
*/
|
80 |
public function is_vendor_page() {
|
81 |
-
return is_tax( YITH_Vendors()->get_taxonomy_name() );
|
82 |
}
|
83 |
|
84 |
/**
|
78 |
* @author Andrea Grillo <andrea.grillo@yithemes.com>
|
79 |
*/
|
80 |
public function is_vendor_page() {
|
81 |
+
return apply_filters( 'yith_wcmv_is_vendor_page', is_tax( YITH_Vendors()->get_taxonomy_name() ) );
|
82 |
}
|
83 |
|
84 |
/**
|
modules/yith-woocommerce-product-vendors/includes/class.yith-vendors.php
CHANGED
@@ -97,6 +97,14 @@ if ( ! class_exists( 'YITH_Vendors' ) ) {
|
|
97 |
*/
|
98 |
public $orders = null;
|
99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
/**
|
101 |
* Required classes
|
102 |
*
|
@@ -170,7 +178,7 @@ if ( ! class_exists( 'YITH_Vendors' ) ) {
|
|
170 |
*/
|
171 |
public function __construct() {
|
172 |
/* === Main Classes to Load === */
|
173 |
-
$require = apply_filters( 'yith_wcpv_require_class',
|
174 |
array(
|
175 |
'common' => array(
|
176 |
'includes/functions.yith-update.php',
|
97 |
*/
|
98 |
public $orders = null;
|
99 |
|
100 |
+
/**
|
101 |
+
* Main Shipping Class
|
102 |
+
*
|
103 |
+
* @var YITH_Vendor_Shipping
|
104 |
+
* @since 1.9.17
|
105 |
+
*/
|
106 |
+
public $shipping = null;
|
107 |
+
|
108 |
/**
|
109 |
* Required classes
|
110 |
*
|
178 |
*/
|
179 |
public function __construct() {
|
180 |
/* === Main Classes to Load === */
|
181 |
+
$this->require = $require = apply_filters( 'yith_wcpv_require_class',
|
182 |
array(
|
183 |
'common' => array(
|
184 |
'includes/functions.yith-update.php',
|
modules/yith-woocommerce-product-vendors/includes/functions.yith-update.php
CHANGED
@@ -183,9 +183,23 @@ function yith_vendors_update_db_1_0_9() {
|
|
183 |
}
|
184 |
update_option( 'yith_product_vendors_db_version', '1.0.9' );
|
185 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
|
|
|
|
|
|
|
|
|
|
|
187 |
}
|
188 |
|
|
|
189 |
add_action( 'admin_init', 'yith_vendors_update_db_1_0_1' );
|
190 |
add_action( 'admin_init', 'yith_vendors_update_db_1_0_2' );
|
191 |
add_action( 'admin_init', 'yith_vendors_update_db_1_0_3' );
|
@@ -195,6 +209,7 @@ add_action( 'admin_init', 'yith_vendors_update_db_1_0_6' );
|
|
195 |
add_action( 'admin_init', 'yith_vendors_update_db_1_0_7' );
|
196 |
add_action( 'admin_init', 'yith_vendors_update_db_1_0_8' );
|
197 |
add_action( 'admin_init', 'yith_vendors_update_db_1_0_9' );
|
|
|
198 |
|
199 |
/**
|
200 |
* Plugin Version Update
|
183 |
}
|
184 |
update_option( 'yith_product_vendors_db_version', '1.0.9' );
|
185 |
}
|
186 |
+
}
|
187 |
+
|
188 |
+
//ALTER TABLE `wp_yith_vendors_payments` ;
|
189 |
+
//Add support to shipping module
|
190 |
+
function yith_vendors_update_db_1_1_0() {
|
191 |
+
$vendors_db_option = get_option( 'yith_product_vendors_db_version', '1.0.0' );
|
192 |
+
if ( $vendors_db_option && version_compare( $vendors_db_option, '1.1.0', '<' ) ) {
|
193 |
+
global $wpdb;
|
194 |
|
195 |
+
$sql = "ALTER TABLE `{$wpdb->prefix}yith_vendors_commissions` ADD `type` VARCHAR(30) NOT NULL DEFAULT 'product' AFTER `status`";
|
196 |
+
$wpdb->query( $sql );
|
197 |
+
|
198 |
+
update_option( 'yith_product_vendors_db_version', '1.1.0' );
|
199 |
+
}
|
200 |
}
|
201 |
|
202 |
+
|
203 |
add_action( 'admin_init', 'yith_vendors_update_db_1_0_1' );
|
204 |
add_action( 'admin_init', 'yith_vendors_update_db_1_0_2' );
|
205 |
add_action( 'admin_init', 'yith_vendors_update_db_1_0_3' );
|
209 |
add_action( 'admin_init', 'yith_vendors_update_db_1_0_7' );
|
210 |
add_action( 'admin_init', 'yith_vendors_update_db_1_0_8' );
|
211 |
add_action( 'admin_init', 'yith_vendors_update_db_1_0_9' );
|
212 |
+
add_action( 'admin_init', 'yith_vendors_update_db_1_1_0' );
|
213 |
|
214 |
/**
|
215 |
* Plugin Version Update
|
modules/yith-woocommerce-product-vendors/includes/lib/class.yith-commissions-list-table.php
CHANGED
@@ -289,14 +289,21 @@ if ( ! class_exists( 'YITH_Commissions_List_Table' ) ) {
|
|
289 |
break;
|
290 |
|
291 |
case 'line_item':
|
292 |
-
$
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
}
|
297 |
|
298 |
-
|
299 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
300 |
break;
|
301 |
|
302 |
case 'rate':
|
289 |
break;
|
290 |
|
291 |
case 'line_item':
|
292 |
+
$to_return = '<small class="meta">-</small>';
|
293 |
+
if( 'shipping' == $rec->type ){
|
294 |
+
$shipping_fee = _x( 'Shipping fee', '[admin]: commission type', 'yith-woocommerce-product-vendors' );
|
295 |
+
$to_return = "<strong>{$shipping_fee}</strong>";
|
296 |
}
|
297 |
|
298 |
+
else {
|
299 |
+
$product = $rec->get_item();
|
300 |
+
|
301 |
+
if( $product ){
|
302 |
+
$product_url = apply_filters( 'yith_wcmv_commissions_list_table_product_url', get_edit_post_link( $product['product_id'] ), $product, $rec );
|
303 |
+
$to_return = ! empty( $product_url ) ? "<a target='_blank' href='{$product_url}'><strong>{$product['name']}</strong></a>" : "<strong>{$product['name']}</strong>";;
|
304 |
+
}
|
305 |
+
}
|
306 |
+
return $to_return;
|
307 |
break;
|
308 |
|
309 |
case 'rate':
|
modules/yith-woocommerce-product-vendors/init.php
CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://yithemes.com/themes/plugins/yith-woocommerce-product-vendors/
|
|
5 |
Description: YITH WooCommerce Multi Vendor is a plugin explicitly developed to switch your website into a platform hosting more than one shop.
|
6 |
Author: YITHEMES
|
7 |
Text Domain: yith-woocommerce-product-vendors
|
8 |
-
Version:
|
9 |
Author URI: http://yithemes.com/
|
10 |
*/
|
11 |
|
@@ -46,11 +46,11 @@ if ( ! function_exists( 'WC' ) ) {
|
|
46 |
if ( defined( 'YITH_WPV_VERSION' ) ) {
|
47 |
return;
|
48 |
} else {
|
49 |
-
define( 'YITH_WPV_VERSION', '
|
50 |
}
|
51 |
|
52 |
if ( ! defined( 'YITH_WPV_DB_VERSION' ) ) {
|
53 |
-
define( 'YITH_WPV_DB_VERSION', '1.0
|
54 |
}
|
55 |
|
56 |
/* Load YWCM text domain */
|
5 |
Description: YITH WooCommerce Multi Vendor is a plugin explicitly developed to switch your website into a platform hosting more than one shop.
|
6 |
Author: YITHEMES
|
7 |
Text Domain: yith-woocommerce-product-vendors
|
8 |
+
Version: 2.0.0
|
9 |
Author URI: http://yithemes.com/
|
10 |
*/
|
11 |
|
46 |
if ( defined( 'YITH_WPV_VERSION' ) ) {
|
47 |
return;
|
48 |
} else {
|
49 |
+
define( 'YITH_WPV_VERSION', '2.0.0' );
|
50 |
}
|
51 |
|
52 |
if ( ! defined( 'YITH_WPV_DB_VERSION' ) ) {
|
53 |
+
define( 'YITH_WPV_DB_VERSION', '1.1.0' );
|
54 |
}
|
55 |
|
56 |
/* Load YWCM text domain */
|
modules/yith-woocommerce-product-vendors/templates/admin/commission-view.php
CHANGED
@@ -12,21 +12,25 @@
|
|
12 |
* @var YITH_Commission $commission
|
13 |
*/
|
14 |
|
15 |
-
|
16 |
-
$
|
17 |
-
$
|
18 |
-
$
|
19 |
-
$
|
20 |
-
$
|
21 |
-
$
|
22 |
-
$
|
|
|
|
|
|
|
|
|
23 |
|
24 |
?>
|
25 |
|
26 |
<div class="wrap">
|
27 |
<h2>
|
28 |
<?php _e( 'View Commission', 'yith-woocommerce-product-vendors' ) ?>
|
29 |
-
<a href="<?php echo
|
30 |
</h2>
|
31 |
|
32 |
<?php YITH_Commissions()->admin_notice(); ?>
|
@@ -99,8 +103,11 @@ $order_taxes = $order->get_taxes();
|
|
99 |
|
100 |
<div class="panel-wrap woocommerce">
|
101 |
<div id="order_data" class="yith-commission panel">
|
102 |
-
<h2
|
103 |
-
|
|
|
|
|
|
|
104 |
<?php
|
105 |
$user_info = $commission->get_user();
|
106 |
|
@@ -135,7 +142,7 @@ $order_taxes = $order->get_taxes();
|
|
135 |
|
136 |
$order_id = yit_get_prop( $order, 'id' );
|
137 |
$order_number = '<strong>#' . esc_attr( $order->get_order_number() ) . '</strong>';
|
138 |
-
$order_uri = sprintf( '<a href="%s">#%d</a>', 'post.php?post=' . absint( $order_id ) . '&action=edit', $order->get_order_number() );
|
139 |
$order_info = $vendor->is_super_user() ? $order_uri : $order_number;
|
140 |
|
141 |
if( $vendor->is_super_user() ){
|
@@ -282,16 +289,17 @@ $order_taxes = $order->get_taxes();
|
|
282 |
|
283 |
</div>
|
284 |
</div>
|
|
|
|
|
|
|
285 |
|
286 |
-
|
287 |
-
|
288 |
-
<div class="inside">
|
289 |
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
<th class="item sortable" colspan="2"><?php _e( 'Item', 'woocommerce' ) ?></th>
|
295 |
<?php do_action( 'yith_wcmv_admin_order_item_headers', $order, $item, $item_id ); ?>
|
296 |
<th class="item_cost sortable"><?php _e( 'Cost', 'woocommerce' ) ?></th>
|
297 |
<th class="quantity sortable"><?php _e( 'Qty', 'woocommerce' ) ?></th>
|
@@ -313,47 +321,49 @@ $order_taxes = $order->get_taxes();
|
|
313 |
endforeach;
|
314 |
endif;
|
315 |
?>
|
316 |
-
|
317 |
-
|
318 |
|
319 |
-
|
320 |
-
|
321 |
|
322 |
<td class="thumb">
|
|
|
323 |
<?php if ( $product ) : ?>
|
324 |
<?php $product_id = yit_get_prop( $product, 'id' ); ?>
|
325 |
-
|
|
|
326 |
|
327 |
-
|
328 |
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
//TODO: Testare
|
339 |
-
|
340 |
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
|
351 |
-
|
352 |
|
353 |
-
|
354 |
|
355 |
<?php if ( $product ) : ?>
|
356 |
-
<a target="_blank" href="<?php echo esc_url(
|
357 |
<?php echo esc_html( $item['name'] ); ?>
|
358 |
</a>
|
359 |
<?php else : ?>
|
@@ -365,7 +375,7 @@ $order_taxes = $order->get_taxes();
|
|
365 |
$metadata = false;
|
366 |
|
367 |
if( YITH_Vendors()->is_wc_2_7_or_greather ){
|
368 |
-
$metadata = $item->get_meta_data();
|
369 |
}
|
370 |
|
371 |
else {
|
@@ -415,24 +425,22 @@ $order_taxes = $order->get_taxes();
|
|
415 |
}
|
416 |
?>
|
417 |
</div>
|
418 |
-
|
419 |
|
420 |
<?php do_action( 'yith_wcmv_admin_order_item_values', $product, $item, absint( $item_id ) ); ?>
|
421 |
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
</div>
|
435 |
-
</td>
|
436 |
|
437 |
<td class="quantity" width="1%">
|
438 |
<div class="view">
|
@@ -509,50 +517,51 @@ $order_taxes = $order->get_taxes();
|
|
509 |
}
|
510 |
}
|
511 |
?>
|
512 |
-
|
513 |
-
|
|
|
514 |
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
|
520 |
-
|
521 |
<?php $refund_reason = YITH_Vendors()->is_wc_2_7_or_greather ? 'refund_reason' : 'get_refund_reasons'; ?>
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
|
528 |
-
|
529 |
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
|
541 |
-
|
542 |
-
|
543 |
|
544 |
-
|
545 |
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
|
557 |
$link_before = $link_after = '';
|
558 |
if ( current_user_can( 'manage_woocommerce' ) ) {
|
@@ -561,52 +570,64 @@ $order_taxes = $order->get_taxes();
|
|
561 |
$link_after = '</a>';
|
562 |
}
|
563 |
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
</tr>
|
588 |
-
|
589 |
-
<?php if ( $commission->get_refunds() ) : ?>
|
590 |
-
<tr>
|
591 |
-
<td class="label refunded-total"><?php printf( '%s:', __( 'Refunded', 'yith-woocommerce-product-vendors' ) ) ?></td>
|
592 |
-
<td class="total refunded-total"><?php echo $commission->get_refund_amount( 'display' ) ?></td>
|
593 |
-
<td width="1%"></td>
|
594 |
-
</tr>
|
595 |
-
<?php endif; ?>
|
596 |
-
|
597 |
-
<tr>
|
598 |
-
<td class="label"><?php printf( '%s:', __( 'Total', 'yith-woocommerce-product-vendors' ) ); ?></td>
|
599 |
-
<td class="total"><?php echo $commission->get_amount( 'display', $currency ) ?></td>
|
600 |
-
<td width="1%"></td>
|
601 |
-
</tr>
|
602 |
-
|
603 |
-
</tbody>
|
604 |
-
</table>
|
605 |
-
<div class="clear"></div>
|
606 |
-
</div>
|
607 |
|
608 |
-
|
609 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
610 |
</div>
|
611 |
</div>
|
612 |
|
12 |
* @var YITH_Commission $commission
|
13 |
*/
|
14 |
|
15 |
+
//string added @version 1.14.1 - ALL FILE
|
16 |
+
$order = $commission->get_order();
|
17 |
+
$user = $commission->get_user();
|
18 |
+
$vendor = $commission->get_vendor();
|
19 |
+
$product = $commission->get_product();
|
20 |
+
$item = $commission->get_item();
|
21 |
+
$item_id = $commission->line_item_id;
|
22 |
+
$tax_data = empty( $legacy_order ) && wc_tax_enabled() ? maybe_unserialize( isset( $item['line_tax_data'] ) ? $item['line_tax_data'] : '' ) : false;
|
23 |
+
$order_taxes = $order->get_taxes();
|
24 |
+
$back_url = isset( $back_url ) ? $back_url : remove_query_arg( 'view' );
|
25 |
+
$line_items_shipping = $order->get_items( 'shipping' );
|
26 |
+
$currency = array( 'currency' => yith_wcmv_get_order_currency( $order ) );
|
27 |
|
28 |
?>
|
29 |
|
30 |
<div class="wrap">
|
31 |
<h2>
|
32 |
<?php _e( 'View Commission', 'yith-woocommerce-product-vendors' ) ?>
|
33 |
+
<a href="<?php echo apply_filters( 'yith_wcmv_back_to_commissions_list_url', esc_url( $back_url ) ) ?>" class="add-new-h2"><?php _e( 'Back', 'yith-woocommerce-product-vendors' ) ?></a>
|
34 |
</h2>
|
35 |
|
36 |
<?php YITH_Commissions()->admin_notice(); ?>
|
103 |
|
104 |
<div class="panel-wrap woocommerce">
|
105 |
<div id="order_data" class="yith-commission panel">
|
106 |
+
<h2 class="commission-details-<?php echo $commission->type ?>">
|
107 |
+
<?php $commission_title_label = 'product' == $commission->type ? _x( 'Commission', '[admin] part of commission details', 'yith-woocommerce-product-vendors' ) : _x( 'Shipping fee', '[admin] part of shipping fee details', 'yith-woocommerce-product-vendors' ); ?>
|
108 |
+
<?php printf( '%s #%s %s', $commission_title_label, $commission->id, _x( 'details', '[admin] part of commission details', 'yith-woocommerce-product-vendors' ) ); ?>
|
109 |
+
</h2>
|
110 |
+
<p class="order_number">
|
111 |
<?php
|
112 |
$user_info = $commission->get_user();
|
113 |
|
142 |
|
143 |
$order_id = yit_get_prop( $order, 'id' );
|
144 |
$order_number = '<strong>#' . esc_attr( $order->get_order_number() ) . '</strong>';
|
145 |
+
$order_uri = sprintf( '<a href="%s">#%d</a>', apply_filters( 'yith_wcmv_commission_get_order_uri', 'post.php?post=' . absint( $order_id ) . '&action=edit', $order_id, $order ), $order->get_order_number() );
|
146 |
$order_info = $vendor->is_super_user() ? $order_uri : $order_number;
|
147 |
|
148 |
if( $vendor->is_super_user() ){
|
289 |
|
290 |
</div>
|
291 |
</div>
|
292 |
+
<div id="woocommerce-order-items" class="postbox">
|
293 |
+
<h3 class="hndle ui-sortable-handle"><span><?php _e( 'Item data', 'yith-woocommerce-product-vendors' ) ?></span></h3>
|
294 |
+
<div class="inside">
|
295 |
|
296 |
+
<div class="woocommerce_order_items_wrapper wc-order-items-editable">
|
297 |
+
<table cellpadding="0" cellspacing="0" class="woocommerce_order_items">
|
|
|
298 |
|
299 |
+
<?php if ( 'product' == $commission->type ) : ?>
|
300 |
+
<thead>
|
301 |
+
<tr>
|
302 |
+
<th class="item sortable" colspan="2"><?php _e( 'Item', 'woocommerce' ) ?></th>
|
|
|
303 |
<?php do_action( 'yith_wcmv_admin_order_item_headers', $order, $item, $item_id ); ?>
|
304 |
<th class="item_cost sortable"><?php _e( 'Cost', 'woocommerce' ) ?></th>
|
305 |
<th class="quantity sortable"><?php _e( 'Qty', 'woocommerce' ) ?></th>
|
321 |
endforeach;
|
322 |
endif;
|
323 |
?>
|
324 |
+
</tr>
|
325 |
+
</thead>
|
326 |
|
327 |
+
<tbody id="order_line_items">
|
328 |
+
<tr class="item Zero Rate" data-order_item_id="<?php echo $item_id ?>">
|
329 |
|
330 |
<td class="thumb">
|
331 |
+
<?php $product_id = $product_uri = ''; ?>
|
332 |
<?php if ( $product ) : ?>
|
333 |
<?php $product_id = yit_get_prop( $product, 'id' ); ?>
|
334 |
+
<?php $product_uri = apply_filters( 'yith_wcmv_commission_get_product_uri', admin_url( 'post.php?post=' . absint( $product_id ) . '&action=edit' ), $product_id ); ?>
|
335 |
+
<a href="<?php echo esc_url( $product_uri ); ?>" class="tips" data-tip="<?php
|
336 |
|
337 |
+
echo '<strong>' . __( 'Product ID:', 'woocommerce' ) . '</strong> ' . absint( $item['product_id'] );
|
338 |
|
339 |
+
if ( $item['variation_id'] && 'product_variation' === get_post_type( $item['variation_id'] ) ) {
|
340 |
+
echo '<br/><strong>' . __( 'Variation ID:', 'woocommerce' ) . '</strong> ' . absint( $item['variation_id'] );
|
341 |
+
} elseif ( $item['variation_id'] ) {
|
342 |
+
echo '<br/><strong>' . __( 'Variation ID:', 'woocommerce' ) . '</strong> ' . absint( $item['variation_id'] ) . ' (' . __( 'No longer exists', 'woocommerce' ) . ')';
|
343 |
+
}
|
344 |
|
345 |
+
if ( $product && $product->get_sku() ) {
|
346 |
+
echo '<br/><strong>' . __( 'Product SKU:', 'woocommerce' ).'</strong> ' . esc_html( $product->get_sku() );
|
347 |
+
}
|
348 |
//TODO: Testare
|
349 |
+
$variation_data = $product->get_attributes();
|
350 |
|
351 |
+
if ( $product && isset( $variation_data ) ) {
|
352 |
+
echo '<br/>' . wc_get_formatted_variation( $variation_data, true );
|
353 |
+
}
|
354 |
|
355 |
+
?>"><?php echo $product->get_image( 'shop_thumbnail', array( 'title' => '' ) ); ?></a>
|
356 |
+
<?php else : ?>
|
357 |
+
<?php echo wc_placeholder_img( 'shop_thumbnail' ); ?>
|
358 |
+
<?php endif; ?>
|
359 |
+
</td>
|
360 |
|
361 |
+
<td class="name">
|
362 |
|
363 |
+
<?php echo ( $product && $product->get_sku() ) ? esc_html( $product->get_sku() ) . ' – ' : ''; ?>
|
364 |
|
365 |
<?php if ( $product ) : ?>
|
366 |
+
<a target="_blank" href="<?php echo esc_url( $product_uri ); ?>">
|
367 |
<?php echo esc_html( $item['name'] ); ?>
|
368 |
</a>
|
369 |
<?php else : ?>
|
375 |
$metadata = false;
|
376 |
|
377 |
if( YITH_Vendors()->is_wc_2_7_or_greather ){
|
378 |
+
$metadata = ! empty( $item ) ? $item->get_meta_data() : null;
|
379 |
}
|
380 |
|
381 |
else {
|
425 |
}
|
426 |
?>
|
427 |
</div>
|
428 |
+
</td>
|
429 |
|
430 |
<?php do_action( 'yith_wcmv_admin_order_item_values', $product, $item, absint( $item_id ) ); ?>
|
431 |
|
432 |
+
<td class="item_cost" width="1%">
|
433 |
+
<div class="view">
|
434 |
+
<?php
|
435 |
+
if ( isset( $item['line_total'] ) ) {
|
436 |
+
if ( isset( $item['line_subtotal'] ) && $item['line_subtotal'] != $item['line_total'] ) {
|
437 |
+
echo '<del>' . wc_price( $order->get_item_subtotal( $item, false, true ), $currency ) . '</del> ';
|
438 |
+
}
|
439 |
+
echo wc_price( $order->get_item_total( $item, false, true ), $currency );
|
440 |
+
}
|
441 |
+
?>
|
442 |
+
</div>
|
443 |
+
</td>
|
|
|
|
|
444 |
|
445 |
<td class="quantity" width="1%">
|
446 |
<div class="view">
|
517 |
}
|
518 |
}
|
519 |
?>
|
520 |
+
</tr>
|
521 |
+
</tbody>
|
522 |
+
<?php endif; ?>
|
523 |
|
524 |
+
<tbody id="order_refunds">
|
525 |
+
<?php foreach ( $commission->get_refunds() as $refund_id => $amount ) : $refund = new WC_Order_Refund( $refund_id ) ?>
|
526 |
+
<tr class="refund Zero Rate">
|
527 |
+
<td class="thumb"><div></div></td>
|
528 |
|
529 |
+
<td class="name">
|
530 |
<?php $refund_reason = YITH_Vendors()->is_wc_2_7_or_greather ? 'refund_reason' : 'get_refund_reasons'; ?>
|
531 |
+
<?php echo esc_attr__( 'Refund', 'woocommerce' ) . ' #' . absint( yit_get_prop( $refund, 'id' ) ) . ' - ' . esc_attr( date_i18n( get_option( 'date_format' ) . ', ' . get_option( 'time_format' ), yit_get_prop( $refund, 'date_created' ) ) ); ?>
|
532 |
+
<?php if ( $refund->$refund_reason() ) : ?>
|
533 |
+
<p class="description"><?php echo esc_html( $refund->$refund_reason() ); ?></p>
|
534 |
+
<?php endif; ?>
|
535 |
+
</td>
|
536 |
|
537 |
+
<td class="quantity" width="1%"> </td>
|
538 |
|
539 |
+
<td class="line_cost" width="1%">
|
540 |
+
<div class="view">
|
541 |
+
<?php echo wc_price( $amount ) ?>
|
542 |
+
</div>
|
543 |
+
</td>
|
544 |
|
545 |
+
<td class="line_tax" width="1%"></td>
|
546 |
+
</tr>
|
547 |
+
<?php endforeach; ?>
|
548 |
+
</tbody>
|
549 |
|
550 |
+
</table>
|
551 |
+
</div>
|
552 |
|
553 |
+
<div class="wc-order-data-row wc-order-totals-items wc-order-items-editable">
|
554 |
|
555 |
+
<?php
|
556 |
+
$coupons = $order->get_items( array( 'coupon' ) );
|
557 |
+
if ( $coupons ) {
|
558 |
+
?>
|
559 |
+
<div class="wc-used-coupons">
|
560 |
+
<ul class="wc_coupon_list"><?php
|
561 |
+
echo '<li><strong>' . __( 'Coupon(s) Used', 'woocommerce' ) . '</strong></li>';
|
562 |
+
foreach ( $coupons as $item_id => $item ) {
|
563 |
+
global $wpdb;
|
564 |
+
$post_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_title = %s AND post_type = 'shop_coupon' AND post_status = 'publish' LIMIT 1;", $item['name'] ) );
|
565 |
|
566 |
$link_before = $link_after = '';
|
567 |
if ( current_user_can( 'manage_woocommerce' ) ) {
|
570 |
$link_after = '</a>';
|
571 |
}
|
572 |
|
573 |
+
printf( '<li class="code">%s<span>' . esc_html( $item['name'] ). '</span>%s</li>', $link_before, $link_after );
|
574 |
+
}
|
575 |
+
?></ul>
|
576 |
+
</div>
|
577 |
+
<?php
|
578 |
+
}
|
579 |
+
?>
|
580 |
+
|
581 |
+
<table class="wc-order-totals">
|
582 |
+
<tbody>
|
583 |
+
|
584 |
+
<tr>
|
585 |
+
<td class="label"><?php _e( 'Rate', 'yith-woocommerce-product-vendors' ) ?>:</td>
|
586 |
+
<td class="total"><?php echo $commission->get_rate( 'display' ) ?></td>
|
587 |
+
<td width="1%"></td>
|
588 |
+
</tr>
|
589 |
+
|
590 |
+
<tr>
|
591 |
+
<?php $commission_label = '';
|
592 |
+
|
593 |
+
if( 'product' == $commission->type ){
|
594 |
+
$commission_label = __( 'Commission', 'yith-woocommerce-product-vendors' );
|
595 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
596 |
|
597 |
+
elseif( 'shipping' == $commission->type ) {
|
598 |
+
$shipping_method = isset( $line_items_shipping[ $commission->line_item_id ] ) ? $line_items_shipping[ $commission->line_item_id ] : null;
|
599 |
+
if( ! empty( $shipping_method ) ){
|
600 |
+
/** @var $shipping_method WC_Order_Item_Shipping */
|
601 |
+
$commission_label = $shipping_method->get_name();
|
602 |
+
}
|
603 |
+
} ?>
|
604 |
+
<td class="label"><?php echo $commission_label; ?>:</td>
|
605 |
+
<td class="total">
|
606 |
+
<?php echo str_replace( array( '<span class="amount">', '</span>' ), '', wc_price( $commission->get_amount() + abs( $commission->get_refund_amount() ), $currency ) ) ?>
|
607 |
+
</td>
|
608 |
+
<td width="1%"></td>
|
609 |
+
</tr>
|
610 |
+
|
611 |
+
<?php if ( $commission->get_refunds() ) : ?>
|
612 |
+
<tr>
|
613 |
+
<td class="label refunded-total"><?php printf( '%s:', __( 'Refunded', 'yith-woocommerce-product-vendors' ) ) ?></td>
|
614 |
+
<td class="total refunded-total"><?php echo $commission->get_refund_amount( 'display' ) ?></td>
|
615 |
+
<td width="1%"></td>
|
616 |
+
</tr>
|
617 |
+
<?php endif; ?>
|
618 |
+
|
619 |
+
<tr>
|
620 |
+
<td class="label"><?php printf( '%s:', __( 'Total', 'yith-woocommerce-product-vendors' ) ); ?></td>
|
621 |
+
<td class="total"><?php echo $commission->get_amount( 'display', $currency ) ?></td>
|
622 |
+
<td width="1%"></td>
|
623 |
+
</tr>
|
624 |
+
|
625 |
+
</tbody>
|
626 |
+
</table>
|
627 |
+
<div class="clear"></div>
|
628 |
+
</div>
|
629 |
+
</div>
|
630 |
+
</div>
|
631 |
</div>
|
632 |
</div>
|
633 |
|
modules/yith-woocommerce-product-vendors/templates/admin/premium.php
CHANGED
@@ -8,7 +8,7 @@
|
|
8 |
* http://www.gnu.org/licenses/gpl-3.0.txt
|
9 |
*/
|
10 |
?>
|
11 |
-
|
12 |
<style>
|
13 |
.section {
|
14 |
margin-left: -20px;
|
@@ -935,6 +935,22 @@
|
|
935 |
</div>
|
936 |
</div>
|
937 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
938 |
|
939 |
<div class="section section-cta section-odd">
|
940 |
<div class="landing-container">
|
8 |
* http://www.gnu.org/licenses/gpl-3.0.txt
|
9 |
*/
|
10 |
?>
|
11 |
+
ciao
|
12 |
<style>
|
13 |
.section {
|
14 |
margin-left: -20px;
|
935 |
</div>
|
936 |
</div>
|
937 |
</div>
|
938 |
+
<div class="section section-even clear"style="background: url(<?php echo YITH_WPV_URL ?>assets/images/43-bg.png) no-repeat #fff; background-position: 85% 100%">
|
939 |
+
<div class="landing-container">
|
940 |
+
<div class="col-1">
|
941 |
+
<img src="<?php echo YITH_WPV_URL ?>assets/images/43.png" alt="Screenshot"/>
|
942 |
+
</div>
|
943 |
+
<div class="col-2">
|
944 |
+
<div class="section-title">
|
945 |
+
<img src="<?php echo YITH_WPV_URL ?>assets/images/43-icon.png" alt="icon"/>
|
946 |
+
<h2><?php _e('User switch','yith_wc_product_vendors'); ?></h2>
|
947 |
+
</div>
|
948 |
+
<p>
|
949 |
+
<?php _e( 'Thanks to this feature, you can access the dashboard of your site as a vendor. This allows having the same view vendors registered on your store have and verifying any notified issue ','yith_wc_product_vendors' )?>
|
950 |
+
</p>
|
951 |
+
</div>
|
952 |
+
</div>
|
953 |
+
</div>
|
954 |
|
955 |
<div class="section section-cta section-odd">
|
956 |
<div class="landing-container">
|
modules/yith-woocommerce-review-reminder/includes/class-ywrr-emails.php
CHANGED
@@ -129,11 +129,15 @@ if ( ! class_exists( 'YWRR_Emails' ) ) {
|
|
129 |
|
130 |
$items = array();
|
131 |
|
|
|
|
|
|
|
|
|
132 |
$line_items = $wpdb->get_results( $wpdb->prepare( "
|
133 |
SELECT a.order_item_name,
|
134 |
MAX(CASE WHEN b.meta_key = '_product_id' THEN b.meta_value ELSE NULL END) AS product_id
|
135 |
FROM {$wpdb->prefix}woocommerce_order_items a INNER JOIN {$wpdb->prefix}woocommerce_order_itemmeta b ON a.order_item_id = b.order_item_id INNER JOIN {$wpdb->prefix}posts c ON b.meta_value = c.ID
|
136 |
-
WHERE a.order_id = %d AND a.order_item_type = 'line_item'
|
137 |
GROUP BY a.order_item_name
|
138 |
ORDER BY a.order_item_id ASC
|
139 |
", $order_id ) );
|
@@ -163,8 +167,9 @@ if ( ! class_exists( 'YWRR_Emails' ) ) {
|
|
163 |
public function items_has_comments_closed( $product_id ) {
|
164 |
|
165 |
$product = get_post( $product_id );
|
|
|
166 |
|
167 |
-
return
|
168 |
|
169 |
}
|
170 |
|
129 |
|
130 |
$items = array();
|
131 |
|
132 |
+
if ( apply_filters( 'ywrr_comment_status', true ) ) {
|
133 |
+
$comment_status = "AND c.comment_status = 'open'";
|
134 |
+
}
|
135 |
+
|
136 |
$line_items = $wpdb->get_results( $wpdb->prepare( "
|
137 |
SELECT a.order_item_name,
|
138 |
MAX(CASE WHEN b.meta_key = '_product_id' THEN b.meta_value ELSE NULL END) AS product_id
|
139 |
FROM {$wpdb->prefix}woocommerce_order_items a INNER JOIN {$wpdb->prefix}woocommerce_order_itemmeta b ON a.order_item_id = b.order_item_id INNER JOIN {$wpdb->prefix}posts c ON b.meta_value = c.ID
|
140 |
+
WHERE a.order_id = %d AND a.order_item_type = 'line_item' {$comment_status}
|
141 |
GROUP BY a.order_item_name
|
142 |
ORDER BY a.order_item_id ASC
|
143 |
", $order_id ) );
|
167 |
public function items_has_comments_closed( $product_id ) {
|
168 |
|
169 |
$product = get_post( $product_id );
|
170 |
+
$closed = is_object( $product ) ? ( $product->comment_status == 'closed' ) : false;
|
171 |
|
172 |
+
return apply_filters( 'ywrr_comment_status', $closed );
|
173 |
|
174 |
}
|
175 |
|
modules/yith-woocommerce-review-reminder/includes/emails/class-ywrr-request-email.php
CHANGED
@@ -82,7 +82,8 @@ if ( ! class_exists( 'YWRR_Request_Mail' ) ) {
|
|
82 |
*/
|
83 |
public function trigger( $order_id, $item_list, $days_ago, $test_email = '', $template = false ) {
|
84 |
|
85 |
-
$
|
|
|
86 |
|
87 |
$this->email_type = get_option( 'ywrr_mail_type' );
|
88 |
$this->heading = apply_filters( 'wpml_translate_single_string', get_option( 'ywrr_mail_subject' ), 'admin_texts_ywrr_mail_subject', 'ywrr_mail_subject', $lang );
|
@@ -93,10 +94,11 @@ if ( ! class_exists( 'YWRR_Request_Mail' ) ) {
|
|
93 |
|
94 |
$this->find['site-title'] = '{site_title}';
|
95 |
$this->replace['site-title'] = $this->get_blogname();
|
|
|
|
|
96 |
|
97 |
if ( $order_id ) {
|
98 |
|
99 |
-
$this->object = wc_get_order( $order_id );
|
100 |
$this->recipient = yit_get_prop( $this->object, 'billing_email' );
|
101 |
|
102 |
} else {
|
82 |
*/
|
83 |
public function trigger( $order_id, $item_list, $days_ago, $test_email = '', $template = false ) {
|
84 |
|
85 |
+
$this->object = wc_get_order( $order_id );
|
86 |
+
$lang = yit_get_prop( $this->object, 'wpml_language', true );
|
87 |
|
88 |
$this->email_type = get_option( 'ywrr_mail_type' );
|
89 |
$this->heading = apply_filters( 'wpml_translate_single_string', get_option( 'ywrr_mail_subject' ), 'admin_texts_ywrr_mail_subject', 'ywrr_mail_subject', $lang );
|
94 |
|
95 |
$this->find['site-title'] = '{site_title}';
|
96 |
$this->replace['site-title'] = $this->get_blogname();
|
97 |
+
$this->find['order-id'] = '{order_id}';
|
98 |
+
$this->replace['order-id'] = $order_id;
|
99 |
|
100 |
if ( $order_id ) {
|
101 |
|
|
|
102 |
$this->recipient = yit_get_prop( $this->object, 'billing_email' );
|
103 |
|
104 |
} else {
|
modules/yith-woocommerce-review-reminder/init.php
CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://yithemes.com/themes/plugins/yith-woocommerce-review-reminder
|
|
5 |
Description: Send a review reminder to the customers over WooCommerce.
|
6 |
Author: YITHEMES
|
7 |
Text Domain: yith-woocommerce-review-reminder
|
8 |
-
Version: 1.3.
|
9 |
Author URI: http://yithemes.com/
|
10 |
*/
|
11 |
|
@@ -34,7 +34,7 @@ function ywrr_install_free_admin_notice() {
|
|
34 |
}
|
35 |
|
36 |
if ( !defined( 'YWRR_VERSION' ) ) {
|
37 |
-
define( 'YWRR_VERSION', '1.3.
|
38 |
}
|
39 |
|
40 |
if ( !defined( 'YWRR_FREE_INIT' ) ) {
|
5 |
Description: Send a review reminder to the customers over WooCommerce.
|
6 |
Author: YITHEMES
|
7 |
Text Domain: yith-woocommerce-review-reminder
|
8 |
+
Version: 1.3.1
|
9 |
Author URI: http://yithemes.com/
|
10 |
*/
|
11 |
|
34 |
}
|
35 |
|
36 |
if ( !defined( 'YWRR_VERSION' ) ) {
|
37 |
+
define( 'YWRR_VERSION', '1.3.1' );
|
38 |
}
|
39 |
|
40 |
if ( !defined( 'YWRR_FREE_INIT' ) ) {
|
modules/yith-woocommerce-review-reminder/templates/emails/review-request.php
CHANGED
@@ -61,6 +61,7 @@ $find = array(
|
|
61 |
'{customer_name}',
|
62 |
'{customer_email}',
|
63 |
'{site_title}',
|
|
|
64 |
'{order_id}',
|
65 |
'{order_date}',
|
66 |
'{order_date_completed}',
|
@@ -73,6 +74,7 @@ $replace = array(
|
|
73 |
'<b>' . $billing_first_name . '</b>',
|
74 |
'<b>' . $billing_email . '</b>',
|
75 |
'<b>' . get_option( 'blogname' ) . '</b>',
|
|
|
76 |
'<b>' . $order_id . '</b>',
|
77 |
'<b>' . YITH_WRR()->format_date( date( 'Y-m-d H:i:s', yit_datetime_to_timestamp( $order_date ) ) ) . '</b>',
|
78 |
'<b>' . YITH_WRR()->format_date( date( 'Y-m-d H:i:s', yit_datetime_to_timestamp( $modified_date ) ) ) . '</b>',
|
61 |
'{customer_name}',
|
62 |
'{customer_email}',
|
63 |
'{site_title}',
|
64 |
+
'{order_id_flat}',
|
65 |
'{order_id}',
|
66 |
'{order_date}',
|
67 |
'{order_date_completed}',
|
74 |
'<b>' . $billing_first_name . '</b>',
|
75 |
'<b>' . $billing_email . '</b>',
|
76 |
'<b>' . get_option( 'blogname' ) . '</b>',
|
77 |
+
$order_id,
|
78 |
'<b>' . $order_id . '</b>',
|
79 |
'<b>' . YITH_WRR()->format_date( date( 'Y-m-d H:i:s', yit_datetime_to_timestamp( $order_date ) ) ) . '</b>',
|
80 |
'<b>' . YITH_WRR()->format_date( date( 'Y-m-d H:i:s', yit_datetime_to_timestamp( $modified_date ) ) ) . '</b>',
|
plugin-fw/init.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* Framework Name: YIT Plugin Framework
|
4 |
-
* Version: 2.9.
|
5 |
* Author: Yithemes
|
6 |
* Text Domain: yith-plugin-fw
|
7 |
* Domain Path: /languages/
|
1 |
<?php
|
2 |
/**
|
3 |
* Framework Name: YIT Plugin Framework
|
4 |
+
* Version: 2.9.68
|
5 |
* Author: Yithemes
|
6 |
* Text Domain: yith-plugin-fw
|
7 |
* Domain Path: /languages/
|
plugin-fw/lib/yit-plugin-panel-wc.php
CHANGED
@@ -64,6 +64,8 @@ if ( ! class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
|
|
64 |
'image_width'
|
65 |
);
|
66 |
|
|
|
|
|
67 |
if ( ! empty( $args ) ) {
|
68 |
$this->settings = $args;
|
69 |
$this->_tabs_path_files = $this->get_tabs_path_files();
|
64 |
'image_width'
|
65 |
);
|
66 |
|
67 |
+
$args = apply_filters( 'yit_plugin_fw_wc_panel_option_args', $args );
|
68 |
+
|
69 |
if ( ! empty( $args ) ) {
|
70 |
$this->settings = $args;
|
71 |
$this->_tabs_path_files = $this->get_tabs_path_files();
|
plugin-fw/lib/yit-plugin-panel.php
CHANGED
@@ -77,7 +77,9 @@ if ( ! class_exists( 'YIT_Plugin_Panel' ) ) {
|
|
77 |
'position' => null
|
78 |
);
|
79 |
|
80 |
-
$
|
|
|
|
|
81 |
$this->_tabs_path_files = $this->get_tabs_path_files();
|
82 |
|
83 |
if ( isset( $this->settings['create_menu_page'] ) && $this->settings['create_menu_page'] ) {
|
77 |
'position' => null
|
78 |
);
|
79 |
|
80 |
+
$args = apply_filters( 'yit_plugin_fw_panel_option_args', wp_parse_args( $args, $default_args ) );
|
81 |
+
|
82 |
+
$this->settings = $args;
|
83 |
$this->_tabs_path_files = $this->get_tabs_path_files();
|
84 |
|
85 |
if ( isset( $this->settings['create_menu_page'] ) && $this->settings['create_menu_page'] ) {
|
plugin-fw/yit-woocommerce-compatibility.php
CHANGED
@@ -570,6 +570,44 @@ if ( !function_exists( 'yit_get_refund_amount' ) ) {
|
|
570 |
}
|
571 |
}
|
572 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
573 |
if ( !function_exists( 'yit_add_select2_fields' ) ) {
|
574 |
/**
|
575 |
* Add select 2
|
@@ -664,7 +702,9 @@ if ( !function_exists( 'yit_product_visibility_meta' ) ) {
|
|
664 |
if ( version_compare( WC()->version, '2.7.0', '<' ) ) {
|
665 |
$args[ 'meta_query' ] = isset( $args[ 'meta_query' ] ) ? $args[ 'meta_query' ] : array();
|
666 |
$args[ 'meta_query' ][] = WC()->query->visibility_meta_query();
|
667 |
-
}
|
|
|
|
|
668 |
$product_visibility_term_ids = wc_get_product_visibility_term_ids();
|
669 |
$args[ 'tax_query' ] = isset( $args[ 'tax_query' ] ) ? $args[ 'tax_query' ] : array();
|
670 |
$args[ 'tax_query' ][] = array(
|
570 |
}
|
571 |
}
|
572 |
|
573 |
+
if ( !function_exists( 'yit_set_refund_amount' ) ){
|
574 |
+
/**
|
575 |
+
* @param $refund \WC_Order_Refund
|
576 |
+
* @param $amount float
|
577 |
+
*
|
578 |
+
* @return float
|
579 |
+
*/
|
580 |
+
function yit_set_refund_amount( $refund, $amount ){
|
581 |
+
$is_wc_data = $refund instanceof WC_Data;
|
582 |
+
|
583 |
+
if( $is_wc_data ){
|
584 |
+
$refund->set_amount( $amount );
|
585 |
+
}
|
586 |
+
else{
|
587 |
+
$refund->refund_amount = $amount;
|
588 |
+
}
|
589 |
+
}
|
590 |
+
}
|
591 |
+
|
592 |
+
if ( !function_exists( 'yit_get_refund_reason' ) ){
|
593 |
+
/**
|
594 |
+
* @param $refund \WC_Order_Refund
|
595 |
+
* @param $amount float
|
596 |
+
*
|
597 |
+
* @return float
|
598 |
+
*/
|
599 |
+
function yit_get_refund_reason( $refund ){
|
600 |
+
$is_wc_data = $refund instanceof WC_Data;
|
601 |
+
|
602 |
+
if( $is_wc_data ){
|
603 |
+
return $refund->get_reason();
|
604 |
+
}
|
605 |
+
else{
|
606 |
+
return $refund->get_refund_reason();
|
607 |
+
}
|
608 |
+
}
|
609 |
+
}
|
610 |
+
|
611 |
if ( !function_exists( 'yit_add_select2_fields' ) ) {
|
612 |
/**
|
613 |
* Add select 2
|
702 |
if ( version_compare( WC()->version, '2.7.0', '<' ) ) {
|
703 |
$args[ 'meta_query' ] = isset( $args[ 'meta_query' ] ) ? $args[ 'meta_query' ] : array();
|
704 |
$args[ 'meta_query' ][] = WC()->query->visibility_meta_query();
|
705 |
+
}
|
706 |
+
|
707 |
+
elseif( taxonomy_exists( 'product_visibility' ) ) {
|
708 |
$product_visibility_term_ids = wc_get_product_visibility_term_ids();
|
709 |
$args[ 'tax_query' ] = isset( $args[ 'tax_query' ] ) ? $args[ 'tax_query' ] : array();
|
710 |
$args[ 'tax_query' ][] = array(
|