1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* LSX functions and definitions - WooCommerce. |
4
|
|
|
* |
5
|
|
|
* @package lsx |
6
|
|
|
* @subpackage woocommerce |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
10
|
|
|
exit; |
11
|
|
|
} |
12
|
|
|
|
13
|
|
|
if ( ! function_exists( 'lsx_wc_support' ) ) : |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* WooCommerce support. |
17
|
|
|
* |
18
|
|
|
* @package lsx |
19
|
|
|
* @subpackage woocommerce |
20
|
|
|
*/ |
21
|
|
|
function lsx_wc_support() { |
22
|
|
|
add_theme_support( 'woocommerce' ); |
23
|
|
|
add_theme_support( 'wc-product-gallery-zoom' ); |
24
|
|
|
add_theme_support( 'wc-product-gallery-lightbox' ); |
25
|
|
|
add_theme_support( 'wc-product-gallery-slider' ); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
add_action( 'after_setup_theme', 'lsx_wc_support' ); |
29
|
|
|
|
30
|
|
|
endif; |
31
|
|
|
|
32
|
|
View Code Duplication |
if ( ! function_exists( 'lsx_wc_scripts_add_styles' ) ) : |
|
|
|
|
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* WooCommerce enqueue styles. |
36
|
|
|
* |
37
|
|
|
* @package lsx |
38
|
|
|
* @subpackage woocommerce |
39
|
|
|
*/ |
40
|
|
|
function lsx_wc_scripts_add_styles() { |
41
|
|
|
wp_enqueue_style( 'woocommerce-lsx', get_template_directory_uri() . '/assets/css/woocommerce/woocommerce.css', array( 'lsx_main' ), LSX_VERSION ); |
42
|
|
|
wp_style_add_data( 'woocommerce-lsx', 'rtl', 'replace' ); |
43
|
|
|
|
44
|
|
|
// Remove WC Shipping Multiple Addresses specific script causing issues on checkout. |
45
|
|
|
wp_dequeue_script( 'wcms-country-select' ); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
add_action( 'wp_enqueue_scripts', 'lsx_wc_scripts_add_styles' ); |
49
|
|
|
|
50
|
|
|
endif; |
51
|
|
|
|
52
|
|
|
if ( ! function_exists( 'lsx_wc_form_field_args' ) ) : |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* WooCommerce form fields. |
56
|
|
|
* |
57
|
|
|
* @package lsx |
58
|
|
|
* @subpackage woocommerce |
59
|
|
|
*/ |
60
|
|
|
function lsx_wc_form_field_args( $args, $key, $value ) { |
|
|
|
|
61
|
|
|
$args['input_class'][] = 'form-control'; |
62
|
|
|
|
63
|
|
|
return $args; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
add_action( 'woocommerce_form_field_args', 'lsx_wc_form_field_args', 10, 3 ); |
67
|
|
|
|
68
|
|
|
endif; |
69
|
|
|
|
70
|
|
View Code Duplication |
if ( ! function_exists( 'lsx_wc_theme_wrapper_start' ) ) : |
|
|
|
|
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* WooCommerce wrapper start. |
74
|
|
|
* |
75
|
|
|
* @package lsx |
76
|
|
|
* @subpackage woocommerce |
77
|
|
|
*/ |
78
|
|
|
function lsx_wc_theme_wrapper_start() { |
79
|
|
|
lsx_content_wrap_before(); |
80
|
|
|
echo '<div id="primary" class="content-area ' . esc_attr( lsx_main_class() ) . '">'; |
81
|
|
|
lsx_content_before(); |
82
|
|
|
echo '<main id="main" class="site-main" role="main">'; |
83
|
|
|
lsx_content_top(); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 ); |
87
|
|
|
add_action( 'woocommerce_before_main_content', 'lsx_wc_theme_wrapper_start' ); |
88
|
|
|
|
89
|
|
|
endif; |
90
|
|
|
|
91
|
|
View Code Duplication |
if ( ! function_exists( 'lsx_wc_theme_wrapper_end' ) ) : |
|
|
|
|
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* WooCommerce wrapper end. |
95
|
|
|
* |
96
|
|
|
* @package lsx |
97
|
|
|
* @subpackage woocommerce |
98
|
|
|
*/ |
99
|
|
|
function lsx_wc_theme_wrapper_end() { |
100
|
|
|
lsx_content_bottom(); |
101
|
|
|
echo '</main>'; |
102
|
|
|
lsx_content_after(); |
103
|
|
|
echo '</div>'; |
104
|
|
|
lsx_content_wrap_after(); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 ); |
108
|
|
|
add_action( 'woocommerce_after_main_content', 'lsx_wc_theme_wrapper_end' ); |
109
|
|
|
|
110
|
|
|
endif; |
111
|
|
|
|
112
|
|
|
if ( ! function_exists( 'lsx_wc_disable_lsx_banner_plugin' ) ) : |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* Disable LSX Banners plugin in some WC pages. |
116
|
|
|
* |
117
|
|
|
* @package lsx |
118
|
|
|
* @subpackage woocommerce |
119
|
|
|
*/ |
120
|
|
|
function lsx_wc_disable_lsx_banner_plugin( $disabled ) { |
121
|
|
|
global $post; |
122
|
|
|
|
123
|
|
|
if ( $post && class_exists( 'WC_Wishlists_Pages' ) && WC_Wishlists_Pages::is_wishlist_page( $post->post_name ) ) { |
124
|
|
|
$disabled = true; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
return $disabled; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
add_filter( 'lsx_banner_plugin_disable', 'lsx_wc_disable_lsx_banner_plugin' ); |
131
|
|
|
|
132
|
|
|
endif; |
133
|
|
|
|
134
|
|
|
if ( ! function_exists( 'lsx_wc_disable_lsx_banner' ) ) : |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* Disable LSX Banners banner in some WC pages. |
138
|
|
|
* |
139
|
|
|
* @package lsx |
140
|
|
|
* @subpackage woocommerce |
141
|
|
|
*/ |
142
|
|
|
function lsx_wc_disable_lsx_banner( $disabled ) { |
143
|
|
|
if ( is_shop() || is_product_category() || is_product_tag() || is_product() ) { |
144
|
|
|
$disabled = true; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
return $disabled; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
add_filter( 'lsx_banner_disable', 'lsx_wc_disable_lsx_banner' ); |
151
|
|
|
|
152
|
|
|
endif; |
153
|
|
|
|
154
|
|
|
if ( ! function_exists( 'lsx_wc_categories_breadcrumb_filter' ) ) : |
155
|
|
|
/** |
156
|
|
|
* Improves the category and taxonomy breadcrumbs for woocommerce. |
157
|
|
|
* |
158
|
|
|
* @package lsx |
159
|
|
|
* @subpackage woocommerce |
160
|
|
|
*/ |
161
|
|
|
function lsx_wc_categories_breadcrumb_filter( $crumbs ) { |
162
|
|
|
|
163
|
|
|
$shop_page_url = get_permalink( wc_get_page_id( 'shop' ) ); |
164
|
|
|
|
165
|
|
|
if ( is_product_category() || is_product_tag() ) { |
166
|
|
|
$new_crumbs = array(); |
167
|
|
|
$new_crumbs[0] = $crumbs[0]; |
168
|
|
|
|
169
|
|
|
if ( function_exists( 'woocommerce_breadcrumb' ) ) { |
170
|
|
|
$new_crumbs[1] = array( |
171
|
|
|
0 => __( 'Shop', 'lsx' ), |
172
|
|
|
1 => $shop_page_url, |
173
|
|
|
); |
174
|
|
|
} else { |
175
|
|
|
$new_crumbs[1] = array( |
176
|
|
|
'text' => __( 'Shop', 'lsx' ), |
177
|
|
|
'url' => $shop_page_url, |
178
|
|
|
); |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
$new_crumbs[2] = $crumbs[1]; |
182
|
|
|
|
183
|
|
|
$crumbs = $new_crumbs; |
184
|
|
|
} |
185
|
|
|
return $crumbs; |
186
|
|
|
} |
187
|
|
|
add_filter( 'wpseo_breadcrumb_links', 'lsx_wc_categories_breadcrumb_filter', 30, 1 ); |
188
|
|
|
add_filter( 'woocommerce_get_breadcrumb', 'lsx_wc_categories_breadcrumb_filter', 30, 1 ); |
189
|
|
|
|
190
|
|
|
endif; |
191
|
|
|
|
192
|
|
|
if ( ! function_exists( 'lsx_wc_add_cart' ) ) : |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* Adds WC cart to the header. |
196
|
|
|
* |
197
|
|
|
* @package lsx |
198
|
|
|
* @subpackage template-tags |
199
|
|
|
*/ |
200
|
|
|
function lsx_wc_add_cart( $items, $args ) { |
201
|
|
|
$cart_menu_item_position = apply_filters( 'lsx_wc_cart_menu_item_position', 'primary' ); |
202
|
|
|
|
203
|
|
|
$cart_logged_out_position = $cart_menu_item_position . '_logged_out'; |
204
|
|
|
|
205
|
|
|
if ( $cart_menu_item_position === $args->theme_location || $cart_logged_out_position === $args->theme_location ) { |
206
|
|
|
$customizer_option = get_theme_mod( 'lsx_header_wc_cart', false ); |
207
|
|
|
|
208
|
|
|
if ( ! empty( $customizer_option ) ) { |
209
|
|
|
ob_start(); |
210
|
|
|
the_widget( 'WC_Widget_Cart', 'title=' ); |
211
|
|
|
$widget = ob_get_clean(); |
212
|
|
|
|
213
|
|
|
if ( is_cart() ) { |
214
|
|
|
$class = 'current-menu-item'; |
215
|
|
|
} else { |
216
|
|
|
$class = ''; |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
$item_class = 'menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children dropdown lsx-wc-cart-menu-item ' . $class; |
220
|
|
|
$item_class = apply_filters( 'lsx_wc_cart_menu_item_class', $item_class ); |
221
|
|
|
|
222
|
|
|
$item = '<li class="' . $item_class . '">' . |
223
|
|
|
'<a title="' . esc_attr__( 'View your shopping cart', 'lsx' ) . '" href="' . esc_url( wc_get_cart_url() ) . '" data-toggle="dropdown" class="dropdown-toggle" aria-haspopup="true">' . |
224
|
|
|
'<span class="lsx-wc-cart-amount">' . wp_kses_data( WC()->cart->get_cart_subtotal() ) . '</span>' . |
225
|
|
|
/* Translators: %s: items quantity */ |
226
|
|
|
'<span class="lsx-wc-cart-count">' . wp_kses_data( sprintf( _n( '%d item', '%d items', WC()->cart->get_cart_contents_count(), 'lsx' ), WC()->cart->get_cart_contents_count() ) ) . '</span>' . |
227
|
|
|
( ! empty( WC()->cart->get_cart_contents_count() ) ? '<span class="lsx-wc-cart-count-badge">' . wp_kses_data( WC()->cart->get_cart_contents_count() ) . '</span>' : '' ) . |
228
|
|
|
'</a>' . |
229
|
|
|
'<ul role="menu" class=" dropdown-menu lsx-wc-cart-sub-menu">' . |
230
|
|
|
'<li>' . |
231
|
|
|
'<div class="lsx-wc-cart-dropdown">' . $widget . '</div>' . |
232
|
|
|
'</li>' . |
233
|
|
|
'</ul>' . |
234
|
|
|
'</li>'; |
235
|
|
|
|
236
|
|
|
if ( 'top-menu' === $args->theme_location ) { |
237
|
|
|
$items = $item . $items; |
238
|
|
|
} else { |
239
|
|
|
$items = $items . $item; |
240
|
|
|
} |
241
|
|
|
} |
242
|
|
|
} |
243
|
|
|
|
244
|
|
|
return $items; |
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
add_filter( 'wp_nav_menu_items', 'lsx_wc_add_cart', 10, 2 ); |
248
|
|
|
|
249
|
|
|
endif; |
250
|
|
|
|
251
|
|
|
if ( ! function_exists( 'lsx_wc_products_widget_wrapper_before' ) ) : |
252
|
|
|
|
253
|
|
|
/** |
254
|
|
|
* Change WC products widget wrapper (before). |
255
|
|
|
* |
256
|
|
|
* @package lsx |
257
|
|
|
* @subpackage woocommerce |
258
|
|
|
*/ |
259
|
|
|
function lsx_wc_products_widget_wrapper_before( $html ) { |
|
|
|
|
260
|
|
|
$html = '<div class="lsx-woocommerce-slider lsx-woocommerce-shortcode">'; |
261
|
|
|
return $html; |
262
|
|
|
} |
263
|
|
|
|
264
|
|
|
add_filter( 'woocommerce_before_widget_product_list', 'lsx_wc_products_widget_wrapper_before', 15 ); |
265
|
|
|
|
266
|
|
|
endif; |
267
|
|
|
|
268
|
|
|
if ( ! function_exists( 'lsx_wc_products_widget_wrapper_after' ) ) : |
269
|
|
|
|
270
|
|
|
/** |
271
|
|
|
* Change WC products widget wrapper (after). |
272
|
|
|
* |
273
|
|
|
* @package lsx |
274
|
|
|
* @subpackage woocommerce |
275
|
|
|
*/ |
276
|
|
|
function lsx_wc_products_widget_wrapper_after( $html ) { |
|
|
|
|
277
|
|
|
$html = '</div>'; |
278
|
|
|
return $html; |
279
|
|
|
} |
280
|
|
|
|
281
|
|
|
add_filter( 'woocommerce_after_widget_product_list', 'lsx_wc_products_widget_wrapper_after', 15 ); |
282
|
|
|
|
283
|
|
|
endif; |
284
|
|
|
|
285
|
|
|
if ( ! function_exists( 'lsx_wc_reviews_widget_override' ) ) : |
286
|
|
|
|
287
|
|
|
/** |
288
|
|
|
* Override WC ewviews widget. |
289
|
|
|
* |
290
|
|
|
* @package lsx |
291
|
|
|
* @subpackage woocommerce |
292
|
|
|
*/ |
293
|
|
|
function lsx_wc_reviews_widget_override() { |
294
|
|
|
if ( class_exists( 'WC_Widget_Recent_Reviews' ) ) { |
295
|
|
|
unregister_widget( 'WC_Widget_Recent_Reviews' ); |
296
|
|
|
require get_template_directory() . '/includes/classes/class-lsx-wc-widget-recent-reviews.php'; |
297
|
|
|
register_widget( 'LSX_WC_Widget_Recent_Reviews' ); |
298
|
|
|
} |
299
|
|
|
} |
300
|
|
|
|
301
|
|
|
add_action( 'widgets_init', 'lsx_wc_reviews_widget_override', 15 ); |
302
|
|
|
|
303
|
|
|
endif; |
304
|
|
|
|
305
|
|
|
if ( ! function_exists( 'lsx_wc_change_price_html' ) ) : |
306
|
|
|
|
307
|
|
|
/** |
308
|
|
|
* Change WC ZERO price to "free". |
309
|
|
|
* |
310
|
|
|
* @package lsx |
311
|
|
|
* @subpackage woocommerce |
312
|
|
|
* |
313
|
|
|
* @param $price string |
314
|
|
|
* @param $product WC_Product |
315
|
|
|
* @return string |
316
|
|
|
*/ |
317
|
|
|
function lsx_wc_change_price_html( $price, $product ) { |
318
|
|
|
if ( empty( $product->get_price() ) ) { |
319
|
|
|
if ( $product->is_on_sale() && $product->get_regular_price() ) { |
320
|
|
|
$regular_price = wc_get_price_to_display( $product, array( |
321
|
|
|
'qty' => 1, |
322
|
|
|
'price' => $product->get_regular_price(), |
323
|
|
|
) ); |
324
|
|
|
|
325
|
|
|
$price = wc_format_price_range( $regular_price, esc_html__( 'Free!', 'lsx' ) ); |
326
|
|
|
} else { |
327
|
|
|
$price = '<span class="amount">' . esc_html__( 'Free!', 'lsx' ) . '</span>'; |
328
|
|
|
} |
329
|
|
|
} |
330
|
|
|
|
331
|
|
|
return $price; |
332
|
|
|
} |
333
|
|
|
|
334
|
|
|
add_filter( 'woocommerce_get_price_html', 'lsx_wc_change_price_html', 15, 2 ); |
335
|
|
|
|
336
|
|
|
endif; |
337
|
|
|
|
338
|
|
|
if ( ! function_exists( 'lsx_wc_cart_link_fragment' ) ) : |
339
|
|
|
|
340
|
|
|
/** |
341
|
|
|
* Cart Fragments. |
342
|
|
|
* Ensure cart contents update when products are added to the cart via AJAX. |
343
|
|
|
* |
344
|
|
|
* @package lsx |
345
|
|
|
* @subpackage woocommerce |
346
|
|
|
*/ |
347
|
|
|
function lsx_wc_cart_link_fragment( $fragments ) { |
348
|
|
|
global $woocommerce; |
349
|
|
|
|
350
|
|
|
ob_start(); |
351
|
|
|
lsx_wc_cart_link(); |
352
|
|
|
$fragments['li.lsx-wc-cart-menu-item > a'] = ob_get_clean(); |
353
|
|
|
|
354
|
|
|
ob_start(); |
355
|
|
|
lsx_wc_items_counter(); |
356
|
|
|
$items_counter = ob_get_clean(); |
357
|
|
|
|
358
|
|
|
if ( ! empty( $items_counter ) ) { |
359
|
|
|
$fragments['div.widget_shopping_cart_content'] = preg_replace( '/(.+)(<\/ul>)[\s\n]*(<p class="woocommerce-mini-cart__total)(.+)/', '$1' . $items_counter . '$2$3$4', $fragments['div.widget_shopping_cart_content'] ); |
360
|
|
|
} |
361
|
|
|
|
362
|
|
|
return $fragments; |
363
|
|
|
} |
364
|
|
|
|
365
|
|
|
endif; |
366
|
|
|
|
367
|
|
|
if ( ! function_exists( 'lsx_wc_cart_link' ) ) : |
368
|
|
|
|
369
|
|
|
/** |
370
|
|
|
* Cart Link. |
371
|
|
|
* Displayed a link to the cart including the number of items present and the cart total. |
372
|
|
|
* |
373
|
|
|
* @package lsx |
374
|
|
|
* @subpackage woocommerce |
375
|
|
|
*/ |
376
|
|
|
function lsx_wc_cart_link() { |
377
|
|
|
?> |
378
|
|
|
<a title="<?php esc_attr_e( 'View your shopping cart', 'lsx' ); ?>" href="<?php echo esc_url( wc_get_cart_url() ); ?>" data-toggle="dropdown" class="dropdown-toggle" aria-haspopup="true"> |
379
|
|
|
<span class="lsx-wc-cart-amount"><?php echo wp_kses_data( WC()->cart->get_cart_subtotal() ); ?></span> |
380
|
|
|
|
381
|
|
|
<?php /* Translators: %s: items quantity */ ?> |
382
|
|
|
<span class="lsx-wc-cart-count"><?php echo wp_kses_data( sprintf( _n( '%d item', '%d items', WC()->cart->get_cart_contents_count(), 'lsx' ), WC()->cart->get_cart_contents_count() ) );?></span> |
383
|
|
|
|
384
|
|
|
<?php if ( ! empty( WC()->cart->get_cart_contents_count() ) ) : ?> |
385
|
|
|
<span class="lsx-wc-cart-count-badge"><?php echo wp_kses_data( WC()->cart->get_cart_contents_count() );?></span> |
386
|
|
|
<?php endif; ?> |
387
|
|
|
</a> |
388
|
|
|
<?php |
389
|
|
|
} |
390
|
|
|
|
391
|
|
|
endif; |
392
|
|
|
|
393
|
|
|
if ( ! function_exists( 'lsx_wc_items_counter' ) ) : |
394
|
|
|
|
395
|
|
|
/** |
396
|
|
|
* Add car item hidden items counter. |
397
|
|
|
* |
398
|
|
|
* @package lsx |
399
|
|
|
* @subpackage woocommerce |
400
|
|
|
*/ |
401
|
|
|
function lsx_wc_items_counter() { |
402
|
|
|
$count = (int) WC()->cart->get_cart_contents_count(); |
403
|
|
|
$items_counter = ''; |
404
|
|
|
|
405
|
|
|
if ( ! empty( $count ) ) { |
406
|
|
|
$count -= 3; |
407
|
|
|
|
408
|
|
|
if ( 1 === $count ) { |
409
|
|
|
$items_counter = esc_html__( '1 other item in cart', 'lsx' ); |
410
|
|
|
} elseif ( $count > 1 ) { |
411
|
|
|
/* Translators: %s: items counter */ |
412
|
|
|
$items_counter = sprintf( esc_html__( '%s other items in cart', 'lsx' ), $count ); |
413
|
|
|
} |
414
|
|
|
} |
415
|
|
|
$cart_url = function_exists( 'wc_get_cart_url' ) ? wc_get_cart_url() : WC()->cart->get_cart_url(); |
416
|
|
|
if ( ! empty( $items_counter ) ) : |
417
|
|
|
?> |
418
|
|
|
<li class="woocommerce-mini-cart-item mini_cart_item" style="display: block;"> |
419
|
|
|
<a href="<?php echo esc_url( $cart_url ); ?>"><?php echo esc_html( $items_counter ); ?></a> |
420
|
|
|
</li> |
421
|
|
|
<?php |
422
|
|
|
endif; |
423
|
|
|
} |
424
|
|
|
|
425
|
|
|
endif; |
426
|
|
|
|
427
|
|
|
if ( ! function_exists( 'lsx_wc_loop_shop_per_page' ) ) : |
428
|
|
|
|
429
|
|
|
/** |
430
|
|
|
* Changes the number of products to display on shop. |
431
|
|
|
* |
432
|
|
|
* @package lsx |
433
|
|
|
* @subpackage woocommerce |
434
|
|
|
*/ |
435
|
|
|
function lsx_wc_loop_shop_per_page( $items ) { |
|
|
|
|
436
|
|
|
$items = 20; |
437
|
|
|
return $items; |
438
|
|
|
} |
439
|
|
|
|
440
|
|
|
add_filter( 'loop_shop_per_page', 'lsx_wc_loop_shop_per_page', 20 ); |
441
|
|
|
|
442
|
|
|
endif; |
443
|
|
|
|
444
|
|
|
if ( ! function_exists( 'lsx_wc_add_to_cart_message_html' ) ) : |
445
|
|
|
|
446
|
|
|
/** |
447
|
|
|
* Changes the "added to cart" message HTML. |
448
|
|
|
* |
449
|
|
|
* @package lsx |
450
|
|
|
* @subpackage woocommerce |
451
|
|
|
*/ |
452
|
|
|
function lsx_wc_add_to_cart_message_html( $message, $products ) { |
|
|
|
|
453
|
|
|
$message = '<div class="woocommerce-message-added-to-cart">' . $message . '</div>'; |
454
|
|
|
return $message; |
455
|
|
|
} |
456
|
|
|
|
457
|
|
|
add_filter( 'wc_add_to_cart_message_html', 'lsx_wc_add_to_cart_message_html', 20, 2 ); |
458
|
|
|
|
459
|
|
|
endif; |
460
|
|
|
|
461
|
|
|
if ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, '2.3', '>=' ) ) { |
462
|
|
|
add_filter( 'woocommerce_add_to_cart_fragments', 'lsx_wc_cart_link_fragment' ); |
463
|
|
|
} else { |
464
|
|
|
add_filter( 'add_to_cart_fragments', 'lsx_wc_cart_link_fragment' ); |
465
|
|
|
} |
466
|
|
|
|
467
|
|
|
remove_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 10 ); |
468
|
|
|
|
469
|
|
|
add_action( 'woocommerce_after_shop_loop', 'lsx_wc_sorting_wrapper', 9 ); |
470
|
|
|
add_action( 'woocommerce_after_shop_loop', 'woocommerce_catalog_ordering', 10 ); |
471
|
|
|
add_action( 'woocommerce_after_shop_loop', 'woocommerce_result_count', 20 ); |
472
|
|
|
add_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 30 ); |
473
|
|
|
add_action( 'woocommerce_after_shop_loop', 'lsx_wc_sorting_wrapper_close', 31 ); |
474
|
|
|
|
475
|
|
|
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 ); |
476
|
|
|
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 ); |
477
|
|
|
|
478
|
|
|
add_action( 'woocommerce_before_shop_loop', 'lsx_wc_sorting_wrapper', 9 ); |
479
|
|
|
add_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 10 ); |
480
|
|
|
add_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 ); |
481
|
|
|
add_action( 'woocommerce_before_shop_loop', 'lsx_wc_woocommerce_pagination', 30 ); |
482
|
|
|
add_action( 'woocommerce_before_shop_loop', 'lsx_wc_sorting_wrapper_close', 31 ); |
483
|
|
|
|
484
|
|
|
if ( ! function_exists( 'lsx_wc_sorting_wrapper' ) ) : |
485
|
|
|
|
486
|
|
|
/** |
487
|
|
|
* Sorting wrapper. |
488
|
|
|
* |
489
|
|
|
* @package lsx |
490
|
|
|
* @subpackage woocommerce |
491
|
|
|
*/ |
492
|
|
|
function lsx_wc_sorting_wrapper() { |
493
|
|
|
echo '<div class="lsx-wc-sorting">'; |
494
|
|
|
} |
495
|
|
|
|
496
|
|
|
endif; |
497
|
|
|
|
498
|
|
|
if ( ! function_exists( 'lsx_wc_sorting_wrapper_close' ) ) : |
499
|
|
|
|
500
|
|
|
/** |
501
|
|
|
* Sorting wrapper close. |
502
|
|
|
* |
503
|
|
|
* @package lsx |
504
|
|
|
* @subpackage woocommerce |
505
|
|
|
*/ |
506
|
|
|
function lsx_wc_sorting_wrapper_close() { |
507
|
|
|
echo '</div>'; |
508
|
|
|
} |
509
|
|
|
|
510
|
|
|
endif; |
511
|
|
|
|
512
|
|
|
if ( ! function_exists( 'lsx_wc_product_columns_wrapper_close' ) ) : |
513
|
|
|
|
514
|
|
|
/** |
515
|
|
|
* Product columns wrapper close. |
516
|
|
|
* |
517
|
|
|
* @package lsx |
518
|
|
|
* @subpackage woocommerce |
519
|
|
|
*/ |
520
|
|
|
function lsx_wc_product_columns_wrapper_close() { |
521
|
|
|
echo '</div>'; |
522
|
|
|
} |
523
|
|
|
|
524
|
|
|
endif; |
525
|
|
|
|
526
|
|
|
if ( ! function_exists( 'lsx_wc_woocommerce_pagination' ) ) : |
527
|
|
|
|
528
|
|
|
/** |
529
|
|
|
* LSX WooCommerce Pagination |
530
|
|
|
* WooCommerce disables the product pagination inside the woocommerce_product_subcategories() function |
531
|
|
|
* but since LSX adds pagination before that function is excuted we need a separate function to |
532
|
|
|
* determine whether or not to display the pagination. |
533
|
|
|
* |
534
|
|
|
* @package lsx |
535
|
|
|
* @subpackage woocommerce |
536
|
|
|
*/ |
537
|
|
|
function lsx_wc_woocommerce_pagination() { |
538
|
|
|
if ( woocommerce_products_will_display() ) { |
539
|
|
|
woocommerce_pagination(); |
540
|
|
|
} |
541
|
|
|
} |
542
|
|
|
|
543
|
|
|
endif; |
544
|
|
|
|
545
|
|
|
if ( ! function_exists( 'lsx_customizer_wc_controls' ) ) : |
546
|
|
|
|
547
|
|
|
/** |
548
|
|
|
* Returns an array of the core panel. |
549
|
|
|
* |
550
|
|
|
* @package lsx |
551
|
|
|
* @subpackage customizer |
552
|
|
|
* |
553
|
|
|
* @return $lsx_controls array() |
|
|
|
|
554
|
|
|
*/ |
555
|
|
|
function lsx_customizer_wc_controls( $lsx_controls ) { |
556
|
|
|
$lsx_controls['panels']['lsx-wc'] = array( |
557
|
|
|
'title' => esc_html__( 'WooCommerce', 'lsx' ), |
558
|
|
|
'description' => esc_html__( 'Change the WooCommerce settings.', 'lsx' ), |
559
|
|
|
'priority' => 23, |
560
|
|
|
); |
561
|
|
|
|
562
|
|
|
/** |
563
|
|
|
* Global. |
564
|
|
|
*/ |
565
|
|
|
|
566
|
|
|
$lsx_controls['sections']['lsx-wc-global'] = array( |
567
|
|
|
'title' => esc_html__( 'Global', 'lsx' ), |
568
|
|
|
'description' => esc_html__( 'Change the WooCommerce global settings.', 'lsx' ), |
569
|
|
|
'panel' => 'lsx-wc', |
570
|
|
|
'priority' => 1, |
571
|
|
|
); |
572
|
|
|
|
573
|
|
|
$lsx_controls['settings']['lsx_wc_mobile_footer_bar_status'] = array( |
574
|
|
|
'default' => '1', |
575
|
|
|
'sanitize_callback' => 'lsx_sanitize_checkbox', |
576
|
|
|
); |
577
|
|
|
|
578
|
|
|
$lsx_controls['fields']['lsx_wc_mobile_footer_bar_status'] = array( |
579
|
|
|
'label' => esc_html__( 'Footer Bar', 'lsx' ), |
580
|
|
|
'description' => esc_html__( 'Enable the mobile footer bar.', 'lsx' ), |
581
|
|
|
'section' => 'lsx-wc-global', |
582
|
|
|
'type' => 'checkbox', |
583
|
|
|
'priority' => 1, |
584
|
|
|
); |
585
|
|
|
|
586
|
|
|
/** |
587
|
|
|
* Cart. |
588
|
|
|
*/ |
589
|
|
|
|
590
|
|
|
$lsx_controls['sections']['lsx-wc-cart'] = array( |
591
|
|
|
'title' => esc_html__( 'Cart', 'lsx' ), |
592
|
|
|
'description' => esc_html__( 'Change the WooCommerce cart settings.', 'lsx' ), |
593
|
|
|
'panel' => 'lsx-wc', |
594
|
|
|
'priority' => 2, |
595
|
|
|
); |
596
|
|
|
|
597
|
|
|
$lsx_controls['settings']['lsx_header_wc_cart'] = array( |
598
|
|
|
'default' => false, |
599
|
|
|
'sanitize_callback' => 'lsx_sanitize_checkbox', |
600
|
|
|
); |
601
|
|
|
|
602
|
|
|
$lsx_controls['fields']['lsx_header_wc_cart'] = array( |
603
|
|
|
'label' => esc_html__( 'Menu Item', 'lsx' ), |
604
|
|
|
'description' => esc_html__( 'Enable the cart menu item.', 'lsx' ), |
605
|
|
|
'section' => 'lsx-wc-cart', |
606
|
|
|
'type' => 'checkbox', |
607
|
|
|
'priority' => 1, |
608
|
|
|
); |
609
|
|
|
|
610
|
|
|
return $lsx_controls; |
611
|
|
|
} |
612
|
|
|
|
613
|
|
|
add_filter( 'lsx_customizer_controls', 'lsx_customizer_wc_controls' ); |
614
|
|
|
|
615
|
|
|
endif; |
616
|
|
|
|
617
|
|
|
if ( ! function_exists( 'lsx_wc_global_header_title' ) ) : |
618
|
|
|
|
619
|
|
|
/** |
620
|
|
|
* Move the shop title into the global header |
621
|
|
|
* |
622
|
|
|
* @package lsx |
623
|
|
|
* @subpackage the-events-calendar |
624
|
|
|
*/ |
625
|
|
|
function lsx_wc_global_header_title( $title ) { |
626
|
|
|
|
627
|
|
|
if ( is_woocommerce() && is_shop() ) { |
628
|
|
|
|
629
|
|
|
$title = __( 'Shop', 'lsx' ); |
630
|
|
|
} |
631
|
|
|
|
632
|
|
|
return $title; |
633
|
|
|
} |
634
|
|
|
add_filter( 'lsx_global_header_title', 'lsx_wc_global_header_title', 200, 1 ); |
635
|
|
|
|
636
|
|
|
endif; |
637
|
|
|
|
638
|
|
|
|
639
|
|
|
if ( ! function_exists( 'lsx_wc_footer_bar' ) ) : |
640
|
|
|
|
641
|
|
|
/** |
642
|
|
|
* Display WC footer bar. |
643
|
|
|
* |
644
|
|
|
* @package lsx |
645
|
|
|
* @subpackage woocommerce |
646
|
|
|
*/ |
647
|
|
|
function lsx_wc_footer_bar() { |
648
|
|
|
$cart_url = function_exists( 'wc_get_cart_url' ) ? wc_get_cart_url() : WC()->cart->get_cart_url(); |
649
|
|
|
if ( ! empty( get_theme_mod( 'lsx_wc_mobile_footer_bar_status', '1' ) ) ) : |
650
|
|
|
?> |
651
|
|
|
<div class="lsx-wc-footer-bar"> |
652
|
|
|
<form role="search" method="get" action="<?php echo esc_url( home_url() ); ?>" class="lsx-wc-footer-bar-form"> |
653
|
|
|
<fieldset> |
654
|
|
|
<legend class="screen-reader-text"><?php esc_html_e( 'Search products', 'lsx' ); ?></legend> |
655
|
|
|
<input type="search" name="s" placeholder="<?php esc_attr_e( 'Search products...', 'lsx' ); ?>" class="form-control"> |
656
|
|
|
</fieldset> |
657
|
|
|
</form> |
658
|
|
|
|
659
|
|
|
<ul class="lsx-wc-footer-bar-items"> |
660
|
|
|
<li class="lsx-wc-footer-bar-item"> |
661
|
|
|
<a href="<?php echo esc_url( home_url() ); ?>" class="lsx-wc-footer-bar-link"> |
662
|
|
|
<i class="fa fa-home" aria-hidden="true"></i> |
663
|
|
|
<span><?php esc_html_e( 'Home', 'lsx' ); ?></span> |
664
|
|
|
</a> |
665
|
|
|
</li> |
666
|
|
|
|
667
|
|
|
<li class="lsx-wc-footer-bar-item"> |
668
|
|
|
<a href="<?php echo esc_url( get_permalink( get_option( 'woocommerce_myaccount_page_id' ) ) ); ?>" class="lsx-wc-footer-bar-link"> |
669
|
|
|
<i class="fa fa-user" aria-hidden="true"></i> |
670
|
|
|
<span><?php esc_html_e( 'Account', 'lsx' ); ?></span> |
671
|
|
|
</a> |
672
|
|
|
</li> |
673
|
|
|
|
674
|
|
|
<li class="lsx-wc-footer-bar-item"> |
675
|
|
|
<a href="#" class="lsx-wc-footer-bar-link lsx-wc-footer-bar-link-toogle"> |
676
|
|
|
<i class="fa fa-search" aria-hidden="true"></i> |
677
|
|
|
<span><?php esc_html_e( 'Search', 'lsx' ); ?></span> |
678
|
|
|
</a> |
679
|
|
|
</li> |
680
|
|
|
|
681
|
|
|
<li class="lsx-wc-footer-bar-item"> |
682
|
|
|
<a href="<?php echo esc_url( $cart_url ); ?>" class="lsx-wc-footer-bar-link"> |
683
|
|
|
<i class="fa fa-shopping-basket" aria-hidden="true"></i> |
684
|
|
|
<?php $count = WC()->cart->get_cart_contents_count(); ?> |
685
|
|
|
<?php if ( ! empty( $count ) ) : ?> |
686
|
|
|
<span class="lsx-wc-footer-bar-count"><?php echo wp_kses_data( $count ); ?></span> |
687
|
|
|
<?php endif; ?> |
688
|
|
|
<span><?php esc_html_e( 'Cart', 'lsx' ); ?></span> |
689
|
|
|
</a> |
690
|
|
|
</li> |
691
|
|
|
</ul> |
692
|
|
|
</div> |
693
|
|
|
<?php |
694
|
|
|
endif; |
695
|
|
|
} |
696
|
|
|
|
697
|
|
|
add_action( 'lsx_body_bottom', 'lsx_wc_footer_bar', 15 ); |
698
|
|
|
|
699
|
|
|
endif; |
700
|
|
|
|
701
|
|
|
if ( ! function_exists( 'lsx_wc_body_class' ) ) : |
702
|
|
|
|
703
|
|
|
/** |
704
|
|
|
* Changes body class. |
705
|
|
|
* |
706
|
|
|
* @package lsx |
707
|
|
|
* @subpackage woocommerce |
708
|
|
|
*/ |
709
|
|
|
function lsx_wc_body_class( $classes ) { |
710
|
|
|
global $post; |
711
|
|
|
|
712
|
|
|
if ( $post && class_exists( 'WC_Wishlists_Pages' ) && WC_Wishlists_Pages::is_wishlist_page( $post->post_name ) ) { |
713
|
|
|
$classes[] = 'woocommerce-page woocommerce-wishlist'; |
714
|
|
|
} |
715
|
|
|
|
716
|
|
|
if ( ! empty( get_theme_mod( 'lsx_wc_mobile_footer_bar_status', '1' ) ) ) { |
717
|
|
|
$classes[] = 'lsx-wc-has-footer-bar'; |
718
|
|
|
} |
719
|
|
|
|
720
|
|
|
return $classes; |
721
|
|
|
} |
722
|
|
|
|
723
|
|
|
add_filter( 'body_class', 'lsx_wc_body_class', 2999 ); |
724
|
|
|
|
725
|
|
|
endif; |
726
|
|
|
|
727
|
|
|
if ( ! function_exists( 'lsx_wc_downloadable_products' ) ) : |
728
|
|
|
|
729
|
|
|
/** |
730
|
|
|
* Changes downloads "download" button text. |
731
|
|
|
* |
732
|
|
|
* @package lsx |
733
|
|
|
* @subpackage woocommerce |
734
|
|
|
*/ |
735
|
|
|
function lsx_wc_downloadable_products( $downloads ) { |
736
|
|
|
foreach ( $downloads as $i => $download ) { |
737
|
|
|
$downloads[ $i ]['download_name'] = esc_html__( 'Download', 'lsx' ); |
738
|
|
|
} |
739
|
|
|
|
740
|
|
|
return $downloads; |
741
|
|
|
} |
742
|
|
|
|
743
|
|
|
add_filter( 'woocommerce_customer_get_downloadable_products', 'lsx_wc_downloadable_products', 2999 ); |
744
|
|
|
|
745
|
|
|
endif; |
746
|
|
|
|
747
|
|
|
if ( ! function_exists( 'lsx_wc_move_bundle_products' ) ) : |
748
|
|
|
|
749
|
|
|
/** |
750
|
|
|
* WooCommerce - Move the bundle products to a tab. |
751
|
|
|
* |
752
|
|
|
* @package lsx |
753
|
|
|
* @subpackage woocommerce |
754
|
|
|
*/ |
755
|
|
|
function lsx_wc_move_bundle_products( $tabs ) { |
756
|
|
|
global $product, $post; |
757
|
|
|
|
758
|
|
|
if ( method_exists( $product , 'get_bundled_items' ) ) { |
759
|
|
|
$bundled_items = $product->get_bundled_items(); |
760
|
|
|
|
761
|
|
|
if ( ! empty( $bundled_items ) ) { |
762
|
|
|
$tabs['bundled_products'] = array( |
763
|
|
|
'title' => __( 'Included Products', 'lsx' ), |
764
|
|
|
'priority' => 10, |
765
|
|
|
'callback' => 'lsx_wc_bundle_products', |
766
|
|
|
); |
767
|
|
|
} |
768
|
|
|
} |
769
|
|
|
|
770
|
|
|
if ( isset( $tabs['description'] ) ) { |
771
|
|
|
$tabs['description']['priority'] = 5; |
772
|
|
|
} |
773
|
|
|
|
774
|
|
|
if ( isset( $tabs['reviews'] ) ) { |
775
|
|
|
$tabs['reviews']['priority'] = 15; |
776
|
|
|
} |
777
|
|
|
|
778
|
|
|
if ( isset( $tabs['product_enquiry'] ) ) { |
779
|
|
|
$tabs['product_enquiry']['priority'] = 20; |
780
|
|
|
} |
781
|
|
|
|
782
|
|
|
return $tabs; |
783
|
|
|
} |
784
|
|
|
|
785
|
|
|
add_action( 'woocommerce_product_tabs', 'lsx_wc_move_bundle_products', 50 ); |
786
|
|
|
|
787
|
|
|
endif; |
788
|
|
|
|
789
|
|
|
if ( ! function_exists( 'lsx_wc_bundle_products' ) ) : |
790
|
|
|
|
791
|
|
|
function lsx_wc_bundle_products() { |
792
|
|
|
global $product, $post; |
793
|
|
|
|
794
|
|
|
if ( method_exists( $product , 'get_bundled_items' ) ) { |
795
|
|
|
$bundled_items = $product->get_bundled_items(); |
796
|
|
|
|
797
|
|
|
// do_action( 'woocommerce_before_bundled_items', $product ); |
798
|
|
|
|
799
|
|
|
// foreach ( $bundled_items as $bundled_item ) { |
800
|
|
|
// do_action( 'woocommerce_bundled_item_details', $bundled_item, $product ); |
801
|
|
|
// } |
802
|
|
|
|
803
|
|
|
// do_action( 'woocommerce_after_bundled_items', $product ); |
804
|
|
|
|
805
|
|
|
$product_original = $product; |
806
|
|
|
|
807
|
|
|
// $this->widget_start( $args, $instance ); |
808
|
|
|
|
809
|
|
|
// @codingStandardsIgnoreLine |
810
|
|
|
echo apply_filters( 'woocommerce_before_widget_product_list', '<ul class="product_list_widget">' ); |
811
|
|
|
|
812
|
|
|
foreach ( $bundled_items as $bundled_item ) { |
813
|
|
|
$product = wc_get_product( $bundled_item->item_data['product_id'] ); |
814
|
|
|
wc_get_template( 'content-widget-product.php' ); |
815
|
|
|
$product = $product_original; |
816
|
|
|
} |
817
|
|
|
|
818
|
|
|
// @codingStandardsIgnoreLine |
819
|
|
|
echo apply_filters( 'woocommerce_after_widget_product_list', '</ul>' ); |
820
|
|
|
} |
821
|
|
|
|
822
|
|
|
// $this->widget_end( $args ); |
823
|
|
|
} |
824
|
|
|
|
825
|
|
|
endif; |
826
|
|
|
|
827
|
|
|
|
828
|
|
|
if ( ! function_exists( 'lsx_wc_product_searchform' ) ) : |
829
|
|
|
/** |
830
|
|
|
* woo_custom_product_searchform |
831
|
|
|
* |
832
|
|
|
* @access public |
833
|
|
|
* @since 1.0 |
834
|
|
|
* @return void |
835
|
|
|
*/ |
836
|
|
|
function lsx_wc_product_searchform( $form ) { |
|
|
|
|
837
|
|
|
|
838
|
|
|
$form = ' |
839
|
|
|
<form role="search" method="get" class="search-form form-inline" id="searchform" action="<?php echo esc_url( home_url( \'/\' ) ); ?>"> |
840
|
|
|
<div class="input-group"> |
841
|
|
|
<input type="search" value="<?php if ( is_search() ) { echo get_search_query(); } ?>" name="s" class="search-field form-control" placeholder="<?php esc_attr_e( \'Search\', \'lsx\' ); ?> <?php echo esc_attr( get_bloginfo( \'name\' ) ); ?>"> |
842
|
|
|
<label class="hide"><?php esc_attr_e( \'Search for:\', \'lsx\' ); ?></label> |
843
|
|
|
|
844
|
|
|
<span class="input-group-btn"> |
845
|
|
|
<button type="submit" class="search-submit btn btn-default"><span class="fa fa-search"></span></button> |
846
|
|
|
</span> |
847
|
|
|
</div> |
848
|
|
|
|
849
|
|
|
<input type="hidden" name="post_type" value="product" /> |
850
|
|
|
</form> |
851
|
|
|
'; |
852
|
|
|
|
853
|
|
|
return $form; |
854
|
|
|
|
855
|
|
|
} |
856
|
|
|
endif; |
857
|
|
|
add_filter( 'get_product_search_form' , 'lsx_wc_product_searchform', 10, 1 ); |
858
|
|
|
|
859
|
|
|
/** |
860
|
|
|
* Output the pagination. |
861
|
|
|
*/ |
862
|
|
|
function woocommerce_pagination() { |
863
|
|
|
if ( ! wc_get_loop_prop( 'is_paginated' ) || ! woocommerce_products_will_display() ) { |
864
|
|
|
return; |
865
|
|
|
} |
866
|
|
|
$args = array( |
867
|
|
|
'total' => wc_get_loop_prop( 'total_pages' ), |
868
|
|
|
'current' => wc_get_loop_prop( 'current_page' ), |
869
|
|
|
); |
870
|
|
|
|
871
|
|
|
if ( wc_get_loop_prop( 'is_shortcode' ) ) { |
872
|
|
|
$args['base'] = esc_url_raw( add_query_arg( 'product-page', '%#%', false ) ); |
873
|
|
|
$args['format'] = '?product-page = %#%'; |
874
|
|
|
} else { |
875
|
|
|
$args['base'] = esc_url_raw( str_replace( 999999999, '%#%', remove_query_arg( 'add-to-cart', get_pagenum_link( 999999999, false ) ) ) ); |
876
|
|
|
$args['format'] = ''; |
877
|
|
|
} |
878
|
|
|
|
879
|
|
|
echo wp_kses_post( '<div class="lsx-pagination-wrapper">' ); |
880
|
|
|
$template = wc_get_template_html( 'loop/pagination.php', $args ); |
881
|
|
|
$template = str_replace( 'woocommerce-pagination', 'lsx-pagination', $template ); |
882
|
|
|
echo wp_kses_post( $template ); |
883
|
|
|
echo wp_kses_post( '</div>' ); |
884
|
|
|
} |
885
|
|
|
|
886
|
|
|
function lsx_wc_pagination_args( $args ) { |
887
|
|
|
$args['prev_text'] = '<span class="meta-nav">←</span> ' . esc_html__( 'Previous', 'lsx' ); |
888
|
|
|
$args['next_text'] = esc_html__( 'Next', 'lsx' ) . ' <span class="meta-nav">→</span>'; |
889
|
|
|
$args['type'] = 'plain'; |
890
|
|
|
return $args; |
891
|
|
|
} |
892
|
|
|
add_filter( 'woocommerce_pagination_args', 'lsx_wc_pagination_args',10 ,1 ); |
893
|
|
|
|
894
|
|
|
|
895
|
|
|
/** |
896
|
|
|
* Returns the location of our product widget |
897
|
|
|
* @param $located |
898
|
|
|
* @param $template_name |
899
|
|
|
* |
900
|
|
|
* @return array |
901
|
|
|
*/ |
902
|
|
|
function lsx_wc_product_widget_template( $located, $template_name ) { |
903
|
|
|
if ( 'content-widget-product.php' === $template_name || 'content-widget-review.php' === $template_name ) { |
904
|
|
|
|
905
|
|
|
$new_location = get_stylesheet_directory() . '/partials/' . $template_name; |
906
|
|
|
if ( file_exists( $new_location ) ) { |
907
|
|
|
$located = $new_location; |
908
|
|
|
} else { |
909
|
|
|
$new_location = get_parent_theme_file_path() . '/partials/' . $template_name; |
910
|
|
|
if ( file_exists( $new_location ) ) { |
911
|
|
|
$located = $new_location; |
912
|
|
|
} |
913
|
|
|
} |
914
|
|
|
} |
915
|
|
|
return $located; |
916
|
|
|
} |
917
|
|
|
add_filter( 'wc_get_template', 'lsx_wc_product_widget_template',90 ,2 ); |
918
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.