Completed
Push — master ( 969fa9...3773e6 )
by Fernando
02:41
created
includes/woocommerce.php 1 patch
Spacing   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -6,11 +6,11 @@  discard block
 block discarded – undo
6 6
  * @subpackage layout
7 7
  */
8 8
 
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if ( ! defined('ABSPATH')) {
10 10
 	exit;
11 11
 }
12 12
 
13
-if ( ! function_exists( 'lsx_wc_support' ) ) :
13
+if ( ! function_exists('lsx_wc_support')) :
14 14
 
15 15
 	/**
16 16
 	 * WooCommerce support.
@@ -19,14 +19,14 @@  discard block
 block discarded – undo
19 19
 	 * @subpackage woocommerce
20 20
 	 */
21 21
 	function lsx_wc_support() {
22
-		add_theme_support( 'woocommerce' );
22
+		add_theme_support('woocommerce');
23 23
 	}
24 24
 
25
-	add_action( 'after_setup_theme', 'lsx_wc_support' );
25
+	add_action('after_setup_theme', 'lsx_wc_support');
26 26
 
27 27
 endif;
28 28
 
29
-if ( ! function_exists( 'lsx_wc_scripts_add_styles' ) ) :
29
+if ( ! function_exists('lsx_wc_scripts_add_styles')) :
30 30
 
31 31
 	/**
32 32
 	 * WooCommerce enqueue styles.
@@ -35,23 +35,23 @@  discard block
 block discarded – undo
35 35
 	 * @subpackage woocommerce
36 36
 	 */
37 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' );
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 40
 
41 41
 		// Remove select2 added by WooCommerce
42 42
 
43
-		wp_dequeue_style( 'select2' );
44
-		wp_deregister_style( 'select2' );
43
+		wp_dequeue_style('select2');
44
+		wp_deregister_style('select2');
45 45
 
46
-		wp_dequeue_script( 'select2' );
47
-		wp_deregister_script( 'select2' );
46
+		wp_dequeue_script('select2');
47
+		wp_deregister_script('select2');
48 48
 	}
49 49
 
50
-	add_action( 'wp_enqueue_scripts', 'lsx_wc_scripts_add_styles' );
50
+	add_action('wp_enqueue_scripts', 'lsx_wc_scripts_add_styles');
51 51
 
52 52
 endif;
53 53
 
54
-if ( ! function_exists( 'lsx_wc_form_field_args' ) ) :
54
+if ( ! function_exists('lsx_wc_form_field_args')) :
55 55
 
56 56
 	/**
57 57
 	 * WooCommerce form fields.
@@ -59,17 +59,17 @@  discard block
 block discarded – undo
59 59
 	 * @package    lsx
60 60
 	 * @subpackage woocommerce
61 61
 	 */
62
-	function lsx_wc_form_field_args( $args, $key, $value ) {
62
+	function lsx_wc_form_field_args($args, $key, $value) {
63 63
 		$args['input_class'][] = 'form-control';
64 64
 
65 65
 		return $args;
66 66
 	}
67 67
 
68
-	add_action( 'woocommerce_form_field_args', 'lsx_wc_form_field_args', 10, 3 );
68
+	add_action('woocommerce_form_field_args', 'lsx_wc_form_field_args', 10, 3);
69 69
 
70 70
 endif;
71 71
 
72
-if ( ! function_exists( 'lsx_wc_theme_wrapper_start' ) ) :
72
+if ( ! function_exists('lsx_wc_theme_wrapper_start')) :
73 73
 
74 74
 	/**
75 75
 	 * WooCommerce wrapper start.
@@ -82,12 +82,12 @@  discard block
 block discarded – undo
82 82
 		echo '<main id="main" class="site-main" role="main">';
83 83
 	}
84 84
 
85
-	remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
86
-	add_action( 'woocommerce_before_main_content', 'lsx_wc_theme_wrapper_start' );
85
+	remove_action('woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10);
86
+	add_action('woocommerce_before_main_content', 'lsx_wc_theme_wrapper_start');
87 87
 
88 88
 endif;
89 89
 
90
-if ( ! function_exists( 'lsx_wc_theme_wrapper_end' ) ) :
90
+if ( ! function_exists('lsx_wc_theme_wrapper_end')) :
91 91
 
92 92
 	/**
93 93
 	 * WooCommerce wrapper end.
@@ -100,12 +100,12 @@  discard block
 block discarded – undo
100 100
 		echo '</div>';
101 101
 	}
102 102
 
103
-	remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
104
-	add_action( 'woocommerce_after_main_content', 'lsx_wc_theme_wrapper_end' );
103
+	remove_action('woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);
104
+	add_action('woocommerce_after_main_content', 'lsx_wc_theme_wrapper_end');
105 105
 
106 106
 endif;
107 107
 
108
-if ( ! function_exists( 'lsx_wc_disable_banner' ) ) :
108
+if ( ! function_exists('lsx_wc_disable_banner')) :
109 109
 
110 110
 	/**
111 111
 	 * Disable LSX Banners banner in some WC pages.
@@ -113,19 +113,19 @@  discard block
 block discarded – undo
113 113
 	 * @package    lsx
114 114
 	 * @subpackage woocommerce
115 115
 	 */
116
-	function lsx_wc_disable_lsx_banner( $disabled ) {
117
-		if ( is_cart() || is_checkout() || is_account_page() ) {
116
+	function lsx_wc_disable_lsx_banner($disabled) {
117
+		if (is_cart() || is_checkout() || is_account_page()) {
118 118
 			$disabled = true;
119 119
 		}
120 120
 
121 121
 		return $disabled;
122 122
 	}
123 123
 
124
-	add_filter( 'lsx_banner_disable', 'lsx_wc_disable_lsx_banner' );
124
+	add_filter('lsx_banner_disable', 'lsx_wc_disable_lsx_banner');
125 125
 
126 126
 endif;
127 127
 
128
-if ( ! function_exists( 'lsx_wc_add_cart' ) ) :
128
+if ( ! function_exists('lsx_wc_add_cart')) :
129 129
 
130 130
 	/**
131 131
 	 * Adds WC cart to the header.
@@ -133,25 +133,25 @@  discard block
 block discarded – undo
133 133
 	 * @package    lsx
134 134
 	 * @subpackage template-tags
135 135
 	 */
136
-	function lsx_wc_add_cart( $items, $args ) {
137
-		if ( 'primary' === $args->theme_location ) {
138
-			$customizer_option  = get_theme_mod( 'lsx_header_wc_cart', false );
136
+	function lsx_wc_add_cart($items, $args) {
137
+		if ('primary' === $args->theme_location) {
138
+			$customizer_option = get_theme_mod('lsx_header_wc_cart', false);
139 139
 
140
-			if ( ! empty( $customizer_option ) ) {
140
+			if ( ! empty($customizer_option)) {
141 141
 				ob_start();
142
-				the_widget( 'WC_Widget_Cart', 'title=' );
142
+				the_widget('WC_Widget_Cart', 'title=');
143 143
 				$widget = ob_get_clean();
144 144
 
145
-				if ( is_cart() ) {
145
+				if (is_cart()) {
146 146
 					$class = 'current-menu-item';
147 147
 				} else {
148 148
 					$class = '';
149 149
 				}
150 150
 
151 151
 				$item = '<li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children dropdown lsx-wc-cart-menu-item ' . $class . '">' .
152
-							'<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">' .
152
+							'<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">' .
153 153
 								/* Translators: %s: items quantity */
154
-								'<span class="lsx-wc-cart-amount">' . wp_kses_data( WC()->cart->get_cart_subtotal() ) . '</span> <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>' .
154
+								'<span class="lsx-wc-cart-amount">' . wp_kses_data(WC()->cart->get_cart_subtotal()) . '</span> <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>' .
155 155
 							'</a>' .
156 156
 							'<ul role="menu" class=" dropdown-menu lsx-wc-cart-sub-menu">' .
157 157
 								'<li>' .
@@ -167,11 +167,11 @@  discard block
 block discarded – undo
167 167
 		return $items;
168 168
 	}
169 169
 
170
-	add_filter( 'wp_nav_menu_items', 'lsx_wc_add_cart', 10, 2 );
170
+	add_filter('wp_nav_menu_items', 'lsx_wc_add_cart', 10, 2);
171 171
 
172 172
 endif;
173 173
 
174
-if ( ! function_exists( 'lsx_wc_products_widget_wrapper_before' ) ) :
174
+if ( ! function_exists('lsx_wc_products_widget_wrapper_before')) :
175 175
 
176 176
 	/**
177 177
 	 * Change WC products widget wrapper (before).
@@ -179,16 +179,16 @@  discard block
 block discarded – undo
179 179
 	 * @package    lsx
180 180
 	 * @subpackage woocommerce
181 181
 	 */
182
-	function lsx_wc_products_widget_wrapper_before( $html ) {
182
+	function lsx_wc_products_widget_wrapper_before($html) {
183 183
 		$html = '<div class="lsx-woocommerce-slider lsx-woocommerce-shortcode">';
184 184
 		return $html;
185 185
 	}
186 186
 
187
-	add_filter( 'woocommerce_before_widget_product_list', 'lsx_wc_products_widget_wrapper_before', 15 );
187
+	add_filter('woocommerce_before_widget_product_list', 'lsx_wc_products_widget_wrapper_before', 15);
188 188
 
189 189
 endif;
190 190
 
191
-if ( ! function_exists( 'lsx_wc_products_widget_wrapper_after' ) ) :
191
+if ( ! function_exists('lsx_wc_products_widget_wrapper_after')) :
192 192
 
193 193
 	/**
194 194
 	 * Change WC products widget wrapper (after).
@@ -196,16 +196,16 @@  discard block
 block discarded – undo
196 196
 	 * @package    lsx
197 197
 	 * @subpackage woocommerce
198 198
 	 */
199
-	function lsx_wc_products_widget_wrapper_after( $html ) {
199
+	function lsx_wc_products_widget_wrapper_after($html) {
200 200
 		$html = '</div>';
201 201
 		return $html;
202 202
 	}
203 203
 
204
-	add_filter( 'woocommerce_after_widget_product_list', 'lsx_wc_products_widget_wrapper_after', 15 );
204
+	add_filter('woocommerce_after_widget_product_list', 'lsx_wc_products_widget_wrapper_after', 15);
205 205
 
206 206
 endif;
207 207
 
208
-if ( ! function_exists( 'lsx_wc_reviews_widget_override' ) ) :
208
+if ( ! function_exists('lsx_wc_reviews_widget_override')) :
209 209
 
210 210
 	/**
211 211
 	 * Override WC ewviews widget.
@@ -214,18 +214,18 @@  discard block
 block discarded – undo
214 214
 	 * @subpackage woocommerce
215 215
 	 */
216 216
 	function lsx_wc_reviews_widget_override() {
217
-		if ( class_exists( 'WC_Widget_Recent_Reviews' ) ) {
218
-			unregister_widget( 'WC_Widget_Recent_Reviews' );
217
+		if (class_exists('WC_Widget_Recent_Reviews')) {
218
+			unregister_widget('WC_Widget_Recent_Reviews');
219 219
 			require get_template_directory() . '/includes/classes/class-lsx-wc-widget-recent-reviews.php';
220
-			register_widget( 'LSX_WC_Widget_Recent_Reviews' );
220
+			register_widget('LSX_WC_Widget_Recent_Reviews');
221 221
 		}
222 222
 	}
223 223
 
224
-	add_action( 'widgets_init', 'lsx_wc_reviews_widget_override', 15 );
224
+	add_action('widgets_init', 'lsx_wc_reviews_widget_override', 15);
225 225
 
226 226
 endif;
227 227
 
228
-if ( ! function_exists( 'lsx_wc_change_price_html' ) ) :
228
+if ( ! function_exists('lsx_wc_change_price_html')) :
229 229
 
230 230
 	/**
231 231
 	 * Change WC ZERO price to "free".
@@ -233,28 +233,28 @@  discard block
 block discarded – undo
233 233
 	 * @package    lsx
234 234
 	 * @subpackage woocommerce
235 235
 	 */
236
-	function lsx_wc_change_price_html( $price, $product ) {
237
-		if ( empty( $product->get_price() ) ) {
238
-			if ( $product->is_on_sale() && $product->get_regular_price() ) {
239
-				$regular_price = wc_get_price_to_display( $product, array(
236
+	function lsx_wc_change_price_html($price, $product) {
237
+		if (empty($product->get_price())) {
238
+			if ($product->is_on_sale() && $product->get_regular_price()) {
239
+				$regular_price = wc_get_price_to_display($product, array(
240 240
 					'qty' => 1,
241 241
 					'price' => $product->get_regular_price(),
242
-				) );
242
+				));
243 243
 
244
-				$price = wc_format_price_range( $regular_price, esc_html__( 'Free!', 'lsx' ) );
244
+				$price = wc_format_price_range($regular_price, esc_html__('Free!', 'lsx'));
245 245
 			} else {
246
-				$price = '<span class="amount">' . esc_html__( 'Free!', 'lsx' ) . '</span>';
246
+				$price = '<span class="amount">' . esc_html__('Free!', 'lsx') . '</span>';
247 247
 			}
248 248
 		}
249 249
 
250 250
 		return $price;
251 251
 	}
252 252
 
253
-	add_filter( 'woocommerce_get_price_html', 'lsx_wc_change_price_html', 15, 2 );
253
+	add_filter('woocommerce_get_price_html', 'lsx_wc_change_price_html', 15, 2);
254 254
 
255 255
 endif;
256 256
 
257
-if ( ! function_exists( 'lsx_wc_cart_link_fragment' ) ) :
257
+if ( ! function_exists('lsx_wc_cart_link_fragment')) :
258 258
 
259 259
 	/**
260 260
 	 * Cart Fragments.
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 	 * @package    lsx
264 264
 	 * @subpackage woocommerce
265 265
 	 */
266
-	function lsx_wc_cart_link_fragment( $fragments ) {
266
+	function lsx_wc_cart_link_fragment($fragments) {
267 267
 		global $woocommerce;
268 268
 
269 269
 		ob_start();
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 
276 276
 endif;
277 277
 
278
-if ( ! function_exists( 'lsx_wc_cart_link' ) ) :
278
+if ( ! function_exists('lsx_wc_cart_link')) :
279 279
 
280 280
 	/**
281 281
 	 * Cart Link.
@@ -286,16 +286,16 @@  discard block
 block discarded – undo
286 286
 	 */
287 287
 	function lsx_wc_cart_link() {
288 288
 		?>
289
-			<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">
289
+			<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">
290 290
 				<?php /* Translators: %s: items quantity */ ?>
291
-				<span class="lsx-wc-cart-amount"><?php echo wp_kses_data( WC()->cart->get_cart_subtotal() ); ?></span> <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>
291
+				<span class="lsx-wc-cart-amount"><?php echo wp_kses_data(WC()->cart->get_cart_subtotal()); ?></span> <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>
292 292
 			</a>
293 293
 		<?php
294 294
 	}
295 295
 
296 296
 endif;
297 297
 
298
-if ( ! function_exists( 'lsx_wc_loop_shop_per_page' ) ) :
298
+if ( ! function_exists('lsx_wc_loop_shop_per_page')) :
299 299
 
300 300
 	/**
301 301
 	 * Changes the number of products to display on shop.
@@ -303,39 +303,39 @@  discard block
 block discarded – undo
303 303
 	 * @package    lsx
304 304
 	 * @subpackage woocommerce
305 305
 	 */
306
-	function lsx_wc_loop_shop_per_page( $items ) {
306
+	function lsx_wc_loop_shop_per_page($items) {
307 307
 		$items = 20;
308 308
 		return $items;
309 309
 	}
310 310
 
311
-	add_filter( 'loop_shop_per_page', 'lsx_wc_loop_shop_per_page', 20 );
311
+	add_filter('loop_shop_per_page', 'lsx_wc_loop_shop_per_page', 20);
312 312
 
313 313
 endif;
314 314
 
315
-if ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, '2.3', '>=' ) ) {
316
-	add_filter( 'woocommerce_add_to_cart_fragments', 'lsx_wc_cart_link_fragment' );
315
+if (defined('WC_VERSION') && version_compare(WC_VERSION, '2.3', '>=')) {
316
+	add_filter('woocommerce_add_to_cart_fragments', 'lsx_wc_cart_link_fragment');
317 317
 } else {
318
-	add_filter( 'add_to_cart_fragments', 'lsx_wc_cart_link_fragment' );
318
+	add_filter('add_to_cart_fragments', 'lsx_wc_cart_link_fragment');
319 319
 }
320 320
 
321
-remove_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 10 );
321
+remove_action('woocommerce_after_shop_loop', 'woocommerce_pagination', 10);
322 322
 
323
-add_action( 'woocommerce_after_shop_loop', 'lsx_wc_sorting_wrapper', 9 );
324
-add_action( 'woocommerce_after_shop_loop', 'woocommerce_catalog_ordering', 10 );
325
-add_action( 'woocommerce_after_shop_loop', 'woocommerce_result_count', 20 );
326
-add_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 30 );
327
-add_action( 'woocommerce_after_shop_loop', 'lsx_wc_sorting_wrapper_close', 31 );
323
+add_action('woocommerce_after_shop_loop', 'lsx_wc_sorting_wrapper', 9);
324
+add_action('woocommerce_after_shop_loop', 'woocommerce_catalog_ordering', 10);
325
+add_action('woocommerce_after_shop_loop', 'woocommerce_result_count', 20);
326
+add_action('woocommerce_after_shop_loop', 'woocommerce_pagination', 30);
327
+add_action('woocommerce_after_shop_loop', 'lsx_wc_sorting_wrapper_close', 31);
328 328
 
329
-remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 );
330
-remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
329
+remove_action('woocommerce_before_shop_loop', 'woocommerce_result_count', 20);
330
+remove_action('woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30);
331 331
 
332
-add_action( 'woocommerce_before_shop_loop', 'lsx_wc_sorting_wrapper', 9 );
333
-add_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 10 );
334
-add_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 );
335
-add_action( 'woocommerce_before_shop_loop', 'lsx_wc_woocommerce_pagination', 30 );
336
-add_action( 'woocommerce_before_shop_loop', 'lsx_wc_sorting_wrapper_close', 31 );
332
+add_action('woocommerce_before_shop_loop', 'lsx_wc_sorting_wrapper', 9);
333
+add_action('woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 10);
334
+add_action('woocommerce_before_shop_loop', 'woocommerce_result_count', 20);
335
+add_action('woocommerce_before_shop_loop', 'lsx_wc_woocommerce_pagination', 30);
336
+add_action('woocommerce_before_shop_loop', 'lsx_wc_sorting_wrapper_close', 31);
337 337
 
338
-if ( ! function_exists( 'lsx_wc_sorting_wrapper' ) ) :
338
+if ( ! function_exists('lsx_wc_sorting_wrapper')) :
339 339
 
340 340
 	/**
341 341
 	 * Sorting wrapper.
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 
350 350
 endif;
351 351
 
352
-if ( ! function_exists( 'lsx_wc_sorting_wrapper_close' ) ) :
352
+if ( ! function_exists('lsx_wc_sorting_wrapper_close')) :
353 353
 
354 354
 	/**
355 355
 	 * Sorting wrapper close.
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 
364 364
 endif;
365 365
 
366
-if ( ! function_exists( 'lsx_wc_product_columns_wrapper_close' ) ) :
366
+if ( ! function_exists('lsx_wc_product_columns_wrapper_close')) :
367 367
 
368 368
 	/**
369 369
 	 * Product columns wrapper close.
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 
378 378
 endif;
379 379
 
380
-if ( ! function_exists( 'lsx_wc_woocommerce_pagination' ) ) :
380
+if ( ! function_exists('lsx_wc_woocommerce_pagination')) :
381 381
 
382 382
 	/**
383 383
 	 * LSX WooCommerce Pagination
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 	 * @subpackage woocommerce
390 390
 	 */
391 391
 	function lsx_wc_woocommerce_pagination() {
392
-		if ( woocommerce_products_will_display() ) {
392
+		if (woocommerce_products_will_display()) {
393 393
 			woocommerce_pagination();
394 394
 		}
395 395
 	}
Please login to merge, or discard this patch.