Passed
Push — master ( 7d9e69...c84be7 )
by Fernando
02:24
created

woocommerce.php ➔ lsx_wc_disable_lsx_banner_plugin()   B

Complexity

Conditions 7
Paths 4

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
eloc 7
nc 4
nop 1
dl 0
loc 13
rs 8.2222
c 0
b 0
f 0
1
<?php
2
/**
3
 * LSX functions and definitions - WooCommerce.
4
 *
5
 * @package    lsx
6
 * @subpackage layout
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
	}
24
25
	add_action( 'after_setup_theme', 'lsx_wc_support' );
26
27
endif;
28
29
if ( ! function_exists( 'lsx_wc_scripts_add_styles' ) ) :
30
31
	/**
32
	 * WooCommerce enqueue styles.
33
	 *
34
	 * @package    lsx
35
	 * @subpackage woocommerce
36
	 */
37
	function lsx_wc_scripts_add_styles() {
38
		wp_enqueue_style( 'woocommerce-lsx', get_template_directory_uri() . '/assets/css/woocommerce.css', array( 'lsx_main' ), LSX_VERSION );
39
		wp_style_add_data( 'woocommerce-lsx', 'rtl', 'replace' );
40
41
		// Remove select2 added by WooCommerce
42
43
		if ( ! is_admin() ) {
44
			wp_dequeue_style( 'select2' );
45
			wp_deregister_style( 'select2' );
46
47
			wp_dequeue_script( 'select2' );
48
			//wp_deregister_script( 'select2' );
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
49
		}
50
	}
51
52
	add_action( 'wp_enqueue_scripts', 'lsx_wc_scripts_add_styles' );
53
54
endif;
55
56
if ( ! function_exists( 'lsx_wc_form_field_args' ) ) :
57
58
	/**
59
	 * WooCommerce form fields.
60
	 *
61
	 * @package    lsx
62
	 * @subpackage woocommerce
63
	 */
64
	function lsx_wc_form_field_args( $args, $key, $value ) {
0 ignored issues
show
Unused Code introduced by
The parameter $key is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $value is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
65
		$args['input_class'][] = 'form-control';
66
67
		return $args;
68
	}
69
70
	add_action( 'woocommerce_form_field_args', 'lsx_wc_form_field_args', 10, 3 );
71
72
endif;
73
74
if ( ! function_exists( 'lsx_wc_theme_wrapper_start' ) ) :
75
76
	/**
77
	 * WooCommerce wrapper start.
78
	 *
79
	 * @package    lsx
80
	 * @subpackage woocommerce
81
	 */
82
	function lsx_wc_theme_wrapper_start() {
83
		lsx_content_wrap_before();
84
		echo '<div id="primary" class="content-area ' . esc_attr( lsx_main_class() ) . '">';
85
		lsx_content_before();
86
		echo '<main id="main" class="site-main" role="main">';
87
		lsx_content_top();
88
	}
89
90
	remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
91
	add_action( 'woocommerce_before_main_content', 'lsx_wc_theme_wrapper_start' );
92
93
endif;
94
95
if ( ! function_exists( 'lsx_wc_theme_wrapper_end' ) ) :
96
97
	/**
98
	 * WooCommerce wrapper end.
99
	 *
100
	 * @package    lsx
101
	 * @subpackage woocommerce
102
	 */
103
	function lsx_wc_theme_wrapper_end() {
104
		lsx_content_bottom();
105
		echo '</main>';
106
		lsx_content_after();
107
		echo '</div>';
108
		lsx_content_wrap_after();
109
	}
110
111
	remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
112
	add_action( 'woocommerce_after_main_content', 'lsx_wc_theme_wrapper_end' );
113
114
endif;
115
116
if ( ! function_exists( 'lsx_wc_disable_lsx_banner_plugin' ) ) :
117
118
	/**
119
	 * Disable LSX Banners plugin in some WC pages.
120
	 *
121
	 * @package    lsx
122
	 * @subpackage woocommerce
123
	 */
124
	function lsx_wc_disable_lsx_banner_plugin( $disabled ) {
125
		global $post;
126
127
		if ( is_cart() || is_checkout() || is_account_page() ) {
128
			$disabled = true;
129
		}
130
131
		if ( $post && class_exists( 'WC_Wishlists_Pages' ) && WC_Wishlists_Pages::is_wishlist_page( $post->post_name ) ) {
132
			$disabled = true;
133
		}
134
135
		return $disabled;
136
	}
137
138
	add_filter( 'lsx_banner_plugin_disable', 'lsx_wc_disable_lsx_banner_plugin' );
139
140
endif;
141
142
if ( ! function_exists( 'lsx_wc_disable_lsx_banner' ) ) :
143
144
	/**
145
	 * Disable LSX Banners banner in some WC pages.
146
	 *
147
	 * @package    lsx
148
	 * @subpackage woocommerce
149
	 */
150
	function lsx_wc_disable_lsx_banner( $disabled ) {
151
		if ( is_shop() || is_product_category() || is_product_tag() || is_product() ) {
152
			$disabled = true;
153
		}
154
155
		return $disabled;
156
	}
157
158
	add_filter( 'lsx_banner_disable', 'lsx_wc_disable_lsx_banner' );
159
160
endif;
161
162
if ( ! function_exists( 'lsx_wc_add_cart' ) ) :
163
164
	/**
165
	 * Adds WC cart to the header.
166
	 *
167
	 * @package    lsx
168
	 * @subpackage template-tags
169
	 */
170
	function lsx_wc_add_cart( $items, $args ) {
171
		$cart_menu_item_position = apply_filters( 'lsx_wc_cart_menu_item_position', 'primary' );
172
173
		if ( $cart_menu_item_position === $args->theme_location ) {
174
			$customizer_option  = get_theme_mod( 'lsx_header_wc_cart', false );
175
176
			if ( ! empty( $customizer_option ) ) {
177
				ob_start();
178
				the_widget( 'WC_Widget_Cart', 'title=' );
179
				$widget = ob_get_clean();
180
181
				if ( is_cart() ) {
182
					$item_class = 'current-menu-item';
0 ignored issues
show
Unused Code introduced by
$item_class is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
183
				} else {
184
					$item_class = '';
0 ignored issues
show
Unused Code introduced by
$item_class is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
185
				}
186
187
				$item_class = 'menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children dropdown lsx-wc-cart-menu-item ' . $class;
0 ignored issues
show
Bug introduced by
The variable $class does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
188
				$item_class = apply_filters( 'lsx_wc_cart_menu_item_class', $item_class );
189
190
				$item = '<li class="' . $item_class . '">' .
191
							'<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">' .
192
								'<span class="lsx-wc-cart-amount">' . wp_kses_data( WC()->cart->get_cart_subtotal() ) . '</span>' .
193
								/* Translators: %s: items quantity */
194
								'<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>' .
195
								( ! empty( WC()->cart->get_cart_contents_count() ) ? '<span class="lsx-wc-cart-count-badge">' . wp_kses_data( WC()->cart->get_cart_contents_count() ) . '</span>' : '' ) .
196
							'</a>' .
197
							'<ul role="menu" class=" dropdown-menu lsx-wc-cart-sub-menu">' .
198
								'<li>' .
199
									'<div class="lsx-wc-cart-dropdown">' . $widget . '</div>' .
200
								'</li>' .
201
							'</ul>' .
202
						'</li>';
203
204
				if ( 'top-menu' === $args->theme_location ) {
205
					$items = $item . $items;
206
				} else {
207
					$items = $items . $item;
208
				}
209
			}
210
		}
211
212
		return $items;
213
	}
214
215
	add_filter( 'wp_nav_menu_items', 'lsx_wc_add_cart', 10, 2 );
216
217
endif;
218
219
if ( ! function_exists( 'lsx_wc_products_widget_wrapper_before' ) ) :
220
221
	/**
222
	 * Change WC products widget wrapper (before).
223
	 *
224
	 * @package    lsx
225
	 * @subpackage woocommerce
226
	 */
227
	function lsx_wc_products_widget_wrapper_before( $html ) {
0 ignored issues
show
Unused Code introduced by
The parameter $html is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
228
		$html = '<div class="lsx-woocommerce-slider lsx-woocommerce-shortcode">';
229
		return $html;
230
	}
231
232
	add_filter( 'woocommerce_before_widget_product_list', 'lsx_wc_products_widget_wrapper_before', 15 );
233
234
endif;
235
236
if ( ! function_exists( 'lsx_wc_products_widget_wrapper_after' ) ) :
237
238
	/**
239
	 * Change WC products widget wrapper (after).
240
	 *
241
	 * @package    lsx
242
	 * @subpackage woocommerce
243
	 */
244
	function lsx_wc_products_widget_wrapper_after( $html ) {
0 ignored issues
show
Unused Code introduced by
The parameter $html is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
245
		$html = '</div>';
246
		return $html;
247
	}
248
249
	add_filter( 'woocommerce_after_widget_product_list', 'lsx_wc_products_widget_wrapper_after', 15 );
250
251
endif;
252
253
if ( ! function_exists( 'lsx_wc_reviews_widget_override' ) ) :
254
255
	/**
256
	 * Override WC ewviews widget.
257
	 *
258
	 * @package    lsx
259
	 * @subpackage woocommerce
260
	 */
261
	function lsx_wc_reviews_widget_override() {
262
		if ( class_exists( 'WC_Widget_Recent_Reviews' ) ) {
263
			unregister_widget( 'WC_Widget_Recent_Reviews' );
264
			require get_template_directory() . '/includes/classes/class-lsx-wc-widget-recent-reviews.php';
265
			register_widget( 'LSX_WC_Widget_Recent_Reviews' );
266
		}
267
	}
268
269
	add_action( 'widgets_init', 'lsx_wc_reviews_widget_override', 15 );
270
271
endif;
272
273
if ( ! function_exists( 'lsx_wc_change_price_html' ) ) :
274
275
	/**
276
	 * Change WC ZERO price to "free".
277
	 *
278
	 * @package    lsx
279
	 * @subpackage woocommerce
280
	 */
281
	function lsx_wc_change_price_html( $price, $product ) {
282
		if ( empty( $product->get_price() ) ) {
283
			if ( $product->is_on_sale() && $product->get_regular_price() ) {
284
				$regular_price = wc_get_price_to_display( $product, array(
285
					'qty' => 1,
286
					'price' => $product->get_regular_price(),
287
				) );
288
289
				$price = wc_format_price_range( $regular_price, esc_html__( 'Free!', 'lsx' ) );
290
			} else {
291
				$price = '<span class="amount">' . esc_html__( 'Free!', 'lsx' ) . '</span>';
292
			}
293
		}
294
295
		return $price;
296
	}
297
298
	add_filter( 'woocommerce_get_price_html', 'lsx_wc_change_price_html', 15, 2 );
299
300
endif;
301
302
if ( ! function_exists( 'lsx_wc_cart_link_fragment' ) ) :
303
304
	/**
305
	 * Cart Fragments.
306
	 * Ensure cart contents update when products are added to the cart via AJAX.
307
	 *
308
	 * @package    lsx
309
	 * @subpackage woocommerce
310
	 */
311
	function lsx_wc_cart_link_fragment( $fragments ) {
312
		global $woocommerce;
313
314
		ob_start();
315
		lsx_wc_cart_link();
316
		$fragments['li.lsx-wc-cart-menu-item > a'] = ob_get_clean();
317
318
		ob_start();
319
		lsx_wc_items_counter();
320
		$items_counter = ob_get_clean();
321
322
		if ( ! empty( $items_counter ) ) {
323
			$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'] );
324
		}
325
326
		return $fragments;
327
	}
328
329
endif;
330
331
if ( ! function_exists( 'lsx_wc_cart_link' ) ) :
332
333
	/**
334
	 * Cart Link.
335
	 * Displayed a link to the cart including the number of items present and the cart total.
336
	 *
337
	 * @package    lsx
338
	 * @subpackage woocommerce
339
	 */
340
	function lsx_wc_cart_link() {
341
		?>
342
			<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">
343
				<span class="lsx-wc-cart-amount"><?php echo wp_kses_data( WC()->cart->get_cart_subtotal() ); ?></span>
344
345
				<?php /* Translators: %s: items quantity */ ?>
346
				<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>
347
348
				<?php if ( ! empty( WC()->cart->get_cart_contents_count() ) ) : ?>
349
					<span class="lsx-wc-cart-count-badge"><?php echo wp_kses_data( WC()->cart->get_cart_contents_count() );?></span>
350
				<?php endif; ?>
351
			</a>
352
		<?php
353
	}
354
355
endif;
356
357
if ( ! function_exists( 'lsx_wc_items_counter' ) ) :
358
359
	/**
360
	 * Add car item hidden items counter.
361
	 *
362
	 * @package    lsx
363
	 * @subpackage woocommerce
364
	 */
365
	function lsx_wc_items_counter() {
366
		$count = (int) WC()->cart->get_cart_contents_count();
367
		$items_counter = '';
368
369
		if ( ! empty( $count ) ) {
370
			$count -= 3;
371
372
			if ( 1 === $count ) {
373
				$items_counter = esc_html__( '1 other item in cart', 'lsx' );
374
			} elseif ( $count > 1 ) {
375
				/* Translators: %s: items counter */
376
				$items_counter = sprintf( esc_html__( '%s other items in cart', 'lsx' ), $count );
377
			}
378
		}
379
380
		if ( ! empty( $items_counter ) ) :
381
			?>
382
				<li class="woocommerce-mini-cart-item mini_cart_item" style="display: block;">
383
					<a href="<?php echo esc_url( WC()->cart->get_cart_url() ); ?>"><?php echo esc_html( $items_counter ); ?></a>
384
				</li>
385
			<?php
386
		endif;
387
	}
388
389
endif;
390
391
if ( ! function_exists( 'lsx_wc_loop_shop_per_page' ) ) :
392
393
	/**
394
	 * Changes the number of products to display on shop.
395
	 *
396
	 * @package    lsx
397
	 * @subpackage woocommerce
398
	 */
399
	function lsx_wc_loop_shop_per_page( $items ) {
0 ignored issues
show
Unused Code introduced by
The parameter $items is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
400
		$items = 20;
401
		return $items;
402
	}
403
404
	add_filter( 'loop_shop_per_page', 'lsx_wc_loop_shop_per_page', 20 );
405
406
endif;
407
408
if ( ! function_exists( 'lsx_wc_add_to_cart_message_html' ) ) :
409
410
	/**
411
	 * Changes the "added to cart" message HTML.
412
	 *
413
	 * @package    lsx
414
	 * @subpackage woocommerce
415
	 */
416
	function lsx_wc_add_to_cart_message_html( $message, $products ) {
0 ignored issues
show
Unused Code introduced by
The parameter $products is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
417
		$message = '<div class="woocommerce-message-added-to-cart">' . $message . '</div>';
418
		return $message;
419
	}
420
421
	add_filter( 'wc_add_to_cart_message_html', 'lsx_wc_add_to_cart_message_html', 20, 2 );
422
423
endif;
424
425
if ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, '2.3', '>=' ) ) {
426
	add_filter( 'woocommerce_add_to_cart_fragments', 'lsx_wc_cart_link_fragment' );
427
} else {
428
	add_filter( 'add_to_cart_fragments', 'lsx_wc_cart_link_fragment' );
429
}
430
431
remove_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 10 );
432
433
add_action( 'woocommerce_after_shop_loop', 'lsx_wc_sorting_wrapper', 9 );
434
add_action( 'woocommerce_after_shop_loop', 'woocommerce_catalog_ordering', 10 );
435
add_action( 'woocommerce_after_shop_loop', 'woocommerce_result_count', 20 );
436
add_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 30 );
437
add_action( 'woocommerce_after_shop_loop', 'lsx_wc_sorting_wrapper_close', 31 );
438
439
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 );
440
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
441
442
add_action( 'woocommerce_before_shop_loop', 'lsx_wc_sorting_wrapper', 9 );
443
add_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 10 );
444
add_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 );
445
add_action( 'woocommerce_before_shop_loop', 'lsx_wc_woocommerce_pagination', 30 );
446
add_action( 'woocommerce_before_shop_loop', 'lsx_wc_sorting_wrapper_close', 31 );
447
448
if ( ! function_exists( 'lsx_wc_sorting_wrapper' ) ) :
449
450
	/**
451
	 * Sorting wrapper.
452
	 *
453
	 * @package    lsx
454
	 * @subpackage woocommerce
455
	 */
456
	function lsx_wc_sorting_wrapper() {
457
		echo '<div class="lsx-wc-sorting">';
458
	}
459
460
endif;
461
462
if ( ! function_exists( 'lsx_wc_sorting_wrapper_close' ) ) :
463
464
	/**
465
	 * Sorting wrapper close.
466
	 *
467
	 * @package    lsx
468
	 * @subpackage woocommerce
469
	 */
470
	function lsx_wc_sorting_wrapper_close() {
471
		echo '</div>';
472
	}
473
474
endif;
475
476
if ( ! function_exists( 'lsx_wc_product_columns_wrapper_close' ) ) :
477
478
	/**
479
	 * Product columns wrapper close.
480
	 *
481
	 * @package    lsx
482
	 * @subpackage woocommerce
483
	 */
484
	function lsx_wc_product_columns_wrapper_close() {
485
		echo '</div>';
486
	}
487
488
endif;
489
490
if ( ! function_exists( 'lsx_wc_woocommerce_pagination' ) ) :
491
492
	/**
493
	 * LSX WooCommerce Pagination
494
	 * WooCommerce disables the product pagination inside the woocommerce_product_subcategories() function
495
	 * but since LSX adds pagination before that function is excuted we need a separate function to
496
	 * determine whether or not to display the pagination.
497
	 *
498
	 * @package    lsx
499
	 * @subpackage woocommerce
500
	 */
501
	function lsx_wc_woocommerce_pagination() {
502
		if ( woocommerce_products_will_display() ) {
503
			woocommerce_pagination();
504
		}
505
	}
506
507
endif;
508
509
if ( ! function_exists( 'lsx_customizer_wc_controls' ) ) :
510
511
	/**
512
	 * Returns an array of the core panel.
513
	 *
514
	 * @package    lsx
515
	 * @subpackage customizer
516
	 *
517
	 * @return $lsx_controls array()
0 ignored issues
show
Documentation introduced by
The doc-type $lsx_controls could not be parsed: Unknown type name "$lsx_controls" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
518
	 */
519
	function lsx_customizer_wc_controls( $lsx_controls ) {
520
		$lsx_controls['panels']['lsx-wc'] = array(
521
			'title'       => esc_html__( 'WooCommerce', 'lsx' ),
522
			'description' => esc_html__( 'Change the WooCommerce settings.', 'lsx' ),
523
			'priority'    => 23,
524
		);
525
526
		/**
527
		 * Global.
528
		 */
529
530
		$lsx_controls['sections']['lsx-wc-global'] = array(
531
			'title'       => esc_html__( 'Global', 'lsx' ),
532
			'description' => esc_html__( 'Change the WooCommerce global settings.', 'lsx' ),
533
			'panel'       => 'lsx-wc',
534
			'priority'    => 1,
535
		);
536
537
		$lsx_controls['settings']['lsx_wc_mobile_footer_bar_status'] = array(
538
			'default'           => '1',
539
			'sanitize_callback' => 'lsx_sanitize_checkbox',
540
		);
541
542
		$lsx_controls['fields']['lsx_wc_mobile_footer_bar_status'] = array(
543
			'label'       => esc_html__( 'Footer Bar', 'lsx' ),
544
			'description' => esc_html__( 'Enable the mobile footer bar.', 'lsx' ),
545
			'section'     => 'lsx-wc-global',
546
			'type'        => 'checkbox',
547
			'priority'    => 1,
548
		);
549
550
		/**
551
		 * Cart.
552
		 */
553
554
		$lsx_controls['sections']['lsx-wc-cart'] = array(
555
			'title'       => esc_html__( 'Cart', 'lsx' ),
556
			'description' => esc_html__( 'Change the WooCommerce cart settings.', 'lsx' ),
557
			'panel'       => 'lsx-wc',
558
			'priority'    => 2,
559
		);
560
561
		$lsx_controls['settings']['lsx_header_wc_cart'] = array(
562
			'default'           => false,
563
			'sanitize_callback' => 'lsx_sanitize_checkbox',
564
		);
565
566
		$lsx_controls['fields']['lsx_header_wc_cart'] = array(
567
			'label'       => esc_html__( 'Menu Item', 'lsx' ),
568
			'description' => esc_html__( 'Enable the cart menu item.', 'lsx' ),
569
			'section'     => 'lsx-wc-cart',
570
			'type'        => 'checkbox',
571
			'priority'    => 1,
572
		);
573
574
		return $lsx_controls;
575
	}
576
577
endif;
578
579
add_filter( 'lsx_customizer_controls', 'lsx_customizer_wc_controls' );
580
581
if ( ! function_exists( 'lsx_wc_footer_bar' ) ) :
582
583
	/**
584
	 * Display WC footer bar.
585
	 *
586
	 * @package    lsx
587
	 * @subpackage woocommerce
588
	 */
589
	function lsx_wc_footer_bar() {
590
		if ( ! empty( get_theme_mod( 'lsx_wc_mobile_footer_bar_status', '1' ) ) ) :
591
			?>
592
			<div class="lsx-wc-footer-bar">
593
				<form role="search" method="get" action="<?php echo esc_url( home_url() ); ?>" class="lsx-wc-footer-bar-form">
594
					<fieldset>
595
						<legend class="screen-reader-text"><?php esc_html_e( 'Search products', 'lsx' ); ?></legend>
596
						<input type="search" name="s" placeholder="<?php esc_attr_e( 'Search products…', 'lsx' ); ?>" class="form-control">
597
					</fieldset>
598
				</form>
599
600
				<ul class="lsx-wc-footer-bar-items">
601
					<li class="lsx-wc-footer-bar-item">
602
						<a href="<?php echo esc_url( home_url() ); ?>" class="lsx-wc-footer-bar-link">
603
							<i class="fa fa-home" aria-hidden="true"></i>
604
							<span><?php esc_html_e( 'Home', 'lsx' ); ?></span>
605
						</a>
606
					</li>
607
608
					<li class="lsx-wc-footer-bar-item">
609
						<a href="<?php echo esc_url( get_permalink( get_option( 'woocommerce_myaccount_page_id' ) ) ); ?>" class="lsx-wc-footer-bar-link">
610
							<i class="fa fa-user" aria-hidden="true"></i>
611
							<span><?php esc_html_e( 'Account', 'lsx' ); ?></span>
612
						</a>
613
					</li>
614
615
					<li class="lsx-wc-footer-bar-item">
616
						<a href="#" class="lsx-wc-footer-bar-link lsx-wc-footer-bar-link-toogle">
617
							<i class="fa fa-search" aria-hidden="true"></i>
618
							<span><?php esc_html_e( 'Search', 'lsx' ); ?></span>
619
						</a>
620
					</li>
621
622
					<li class="lsx-wc-footer-bar-item">
623
						<a href="<?php echo esc_url( WC()->cart->get_cart_url() ); ?>" class="lsx-wc-footer-bar-link">
624
							<i class="fa fa-shopping-basket" aria-hidden="true"></i>
625
							<?php $count = WC()->cart->get_cart_contents_count(); ?>
626
							<?php if ( ! empty( $count ) ) : ?>
627
								<span class="lsx-wc-footer-bar-count"><?php echo wp_kses_data( $count ); ?></span>
628
							<?php endif; ?>
629
							<span><?php esc_html_e( 'Cart', 'lsx' ); ?></span>
630
						</a>
631
					</li>
632
				</ul>
633
			</div>
634
			<?php
635
		endif;
636
	}
637
638
	add_action( 'lsx_body_bottom', 'lsx_wc_footer_bar', 15 );
639
640
endif;
641
642
if ( ! function_exists( 'lsx_wc_body_class' ) ) :
643
644
	/**
645
	 * Changes body class.
646
	 *
647
	 * @package    lsx
648
	 * @subpackage woocommerce
649
	 */
650
	function lsx_wc_body_class( $classes ) {
651
		global $post;
652
653
		if ( $post && class_exists( 'WC_Wishlists_Pages' ) && WC_Wishlists_Pages::is_wishlist_page( $post->post_name ) ) {
654
			$classes[] = 'woocommerce-page woocommerce-wishlist';
655
		}
656
657
		return $classes;
658
	}
659
660
	add_filter( 'body_class', 'lsx_wc_body_class', 2999 );
661
662
endif;
663