@@ -6,11 +6,11 @@ discard block |
||
| 6 | 6 | * @subpackage woocommerce |
| 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,17 +19,17 @@ discard block |
||
| 19 | 19 | * @subpackage woocommerce |
| 20 | 20 | */ |
| 21 | 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' ); |
|
| 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 | 26 | } |
| 27 | 27 | |
| 28 | - add_action( 'after_setup_theme', 'lsx_wc_support' ); |
|
| 28 | + add_action('after_setup_theme', 'lsx_wc_support'); |
|
| 29 | 29 | |
| 30 | 30 | endif; |
| 31 | 31 | |
| 32 | -if ( ! function_exists( 'lsx_wc_scripts_add_styles' ) ) : |
|
| 32 | +if ( ! function_exists('lsx_wc_scripts_add_styles')) : |
|
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * WooCommerce enqueue styles. |
@@ -38,34 +38,34 @@ discard block |
||
| 38 | 38 | * @subpackage woocommerce |
| 39 | 39 | */ |
| 40 | 40 | function lsx_wc_scripts_add_styles() { |
| 41 | - wp_enqueue_style( 'woocommerce-lsx', get_template_directory_uri() . '/assets/css/woocommerce.css', array( 'lsx_main' ), LSX_VERSION ); |
|
| 42 | - wp_style_add_data( 'woocommerce-lsx', 'rtl', 'replace' ); |
|
| 41 | + wp_enqueue_style('woocommerce-lsx', get_template_directory_uri() . '/assets/css/woocommerce.css', array('lsx_main'), LSX_VERSION); |
|
| 42 | + wp_style_add_data('woocommerce-lsx', 'rtl', 'replace'); |
|
| 43 | 43 | |
| 44 | 44 | // Remove select2 added by WooCommerce |
| 45 | 45 | |
| 46 | - if ( ! is_admin() ) { |
|
| 47 | - wp_dequeue_style( 'select2' ); |
|
| 48 | - wp_deregister_style( 'select2' ); |
|
| 46 | + if ( ! is_admin()) { |
|
| 47 | + wp_dequeue_style('select2'); |
|
| 48 | + wp_deregister_style('select2'); |
|
| 49 | 49 | |
| 50 | - wp_dequeue_script( 'select2' ); |
|
| 50 | + wp_dequeue_script('select2'); |
|
| 51 | 51 | //wp_deregister_script( 'select2' ); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | // Adds select2 if on Cart or Checkout Page |
| 55 | 55 | |
| 56 | - if (!is_woocommerce() && !is_cart() && !is_checkout()) { |
|
| 57 | - wp_enqueue_script( 'select2' ); |
|
| 56 | + if ( ! is_woocommerce() && ! is_cart() && ! is_checkout()) { |
|
| 57 | + wp_enqueue_script('select2'); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | // Remove WC Shipping Multiple Addresses specific script causing issues on checkout |
| 61 | - wp_dequeue_script( 'wcms-country-select' ); |
|
| 61 | + wp_dequeue_script('wcms-country-select'); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - add_action( 'wp_enqueue_scripts', 'lsx_wc_scripts_add_styles' ); |
|
| 64 | + add_action('wp_enqueue_scripts', 'lsx_wc_scripts_add_styles'); |
|
| 65 | 65 | |
| 66 | 66 | endif; |
| 67 | 67 | |
| 68 | -if ( ! function_exists( 'lsx_wc_form_field_args' ) ) : |
|
| 68 | +if ( ! function_exists('lsx_wc_form_field_args')) : |
|
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | 71 | * WooCommerce form fields. |
@@ -73,17 +73,17 @@ discard block |
||
| 73 | 73 | * @package lsx |
| 74 | 74 | * @subpackage woocommerce |
| 75 | 75 | */ |
| 76 | - function lsx_wc_form_field_args( $args, $key, $value ) { |
|
| 76 | + function lsx_wc_form_field_args($args, $key, $value) { |
|
| 77 | 77 | $args['input_class'][] = 'form-control'; |
| 78 | 78 | |
| 79 | 79 | return $args; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - add_action( 'woocommerce_form_field_args', 'lsx_wc_form_field_args', 10, 3 ); |
|
| 82 | + add_action('woocommerce_form_field_args', 'lsx_wc_form_field_args', 10, 3); |
|
| 83 | 83 | |
| 84 | 84 | endif; |
| 85 | 85 | |
| 86 | -if ( ! function_exists( 'lsx_wc_theme_wrapper_start' ) ) : |
|
| 86 | +if ( ! function_exists('lsx_wc_theme_wrapper_start')) : |
|
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | 89 | * WooCommerce wrapper start. |
@@ -93,18 +93,18 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | function lsx_wc_theme_wrapper_start() { |
| 95 | 95 | lsx_content_wrap_before(); |
| 96 | - echo '<div id="primary" class="content-area ' . esc_attr( lsx_main_class() ) . '">'; |
|
| 96 | + echo '<div id="primary" class="content-area ' . esc_attr(lsx_main_class()) . '">'; |
|
| 97 | 97 | lsx_content_before(); |
| 98 | 98 | echo '<main id="main" class="site-main" role="main">'; |
| 99 | 99 | lsx_content_top(); |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 ); |
|
| 103 | - add_action( 'woocommerce_before_main_content', 'lsx_wc_theme_wrapper_start' ); |
|
| 102 | + remove_action('woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10); |
|
| 103 | + add_action('woocommerce_before_main_content', 'lsx_wc_theme_wrapper_start'); |
|
| 104 | 104 | |
| 105 | 105 | endif; |
| 106 | 106 | |
| 107 | -if ( ! function_exists( 'lsx_wc_theme_wrapper_end' ) ) : |
|
| 107 | +if ( ! function_exists('lsx_wc_theme_wrapper_end')) : |
|
| 108 | 108 | |
| 109 | 109 | /** |
| 110 | 110 | * WooCommerce wrapper end. |
@@ -120,12 +120,12 @@ discard block |
||
| 120 | 120 | lsx_content_wrap_after(); |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 ); |
|
| 124 | - add_action( 'woocommerce_after_main_content', 'lsx_wc_theme_wrapper_end' ); |
|
| 123 | + remove_action('woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10); |
|
| 124 | + add_action('woocommerce_after_main_content', 'lsx_wc_theme_wrapper_end'); |
|
| 125 | 125 | |
| 126 | 126 | endif; |
| 127 | 127 | |
| 128 | -if ( ! function_exists( 'lsx_wc_disable_lsx_banner_plugin' ) ) : |
|
| 128 | +if ( ! function_exists('lsx_wc_disable_lsx_banner_plugin')) : |
|
| 129 | 129 | |
| 130 | 130 | /** |
| 131 | 131 | * Disable LSX Banners plugin in some WC pages. |
@@ -133,25 +133,25 @@ discard block |
||
| 133 | 133 | * @package lsx |
| 134 | 134 | * @subpackage woocommerce |
| 135 | 135 | */ |
| 136 | - function lsx_wc_disable_lsx_banner_plugin( $disabled ) { |
|
| 136 | + function lsx_wc_disable_lsx_banner_plugin($disabled) { |
|
| 137 | 137 | global $post; |
| 138 | 138 | |
| 139 | - if ( is_cart() || is_checkout() || is_account_page() ) { |
|
| 139 | + if (is_cart() || is_checkout() || is_account_page()) { |
|
| 140 | 140 | $disabled = true; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - if ( $post && class_exists( 'WC_Wishlists_Pages' ) && WC_Wishlists_Pages::is_wishlist_page( $post->post_name ) ) { |
|
| 143 | + if ($post && class_exists('WC_Wishlists_Pages') && WC_Wishlists_Pages::is_wishlist_page($post->post_name)) { |
|
| 144 | 144 | $disabled = true; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | return $disabled; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - add_filter( 'lsx_banner_plugin_disable', 'lsx_wc_disable_lsx_banner_plugin' ); |
|
| 150 | + add_filter('lsx_banner_plugin_disable', 'lsx_wc_disable_lsx_banner_plugin'); |
|
| 151 | 151 | |
| 152 | 152 | endif; |
| 153 | 153 | |
| 154 | -if ( ! function_exists( 'lsx_wc_disable_lsx_banner' ) ) : |
|
| 154 | +if ( ! function_exists('lsx_wc_disable_lsx_banner')) : |
|
| 155 | 155 | |
| 156 | 156 | /** |
| 157 | 157 | * Disable LSX Banners banner in some WC pages. |
@@ -159,19 +159,19 @@ discard block |
||
| 159 | 159 | * @package lsx |
| 160 | 160 | * @subpackage woocommerce |
| 161 | 161 | */ |
| 162 | - function lsx_wc_disable_lsx_banner( $disabled ) { |
|
| 163 | - if ( is_shop() || is_product_category() || is_product_tag() || is_product() ) { |
|
| 162 | + function lsx_wc_disable_lsx_banner($disabled) { |
|
| 163 | + if (is_shop() || is_product_category() || is_product_tag() || is_product()) { |
|
| 164 | 164 | $disabled = true; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | return $disabled; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - add_filter( 'lsx_banner_disable', 'lsx_wc_disable_lsx_banner' ); |
|
| 170 | + add_filter('lsx_banner_disable', 'lsx_wc_disable_lsx_banner'); |
|
| 171 | 171 | |
| 172 | 172 | endif; |
| 173 | 173 | |
| 174 | -if ( ! function_exists( 'lsx_wc_add_cart' ) ) : |
|
| 174 | +if ( ! function_exists('lsx_wc_add_cart')) : |
|
| 175 | 175 | |
| 176 | 176 | /** |
| 177 | 177 | * Adds WC cart to the header. |
@@ -179,34 +179,34 @@ discard block |
||
| 179 | 179 | * @package lsx |
| 180 | 180 | * @subpackage template-tags |
| 181 | 181 | */ |
| 182 | - function lsx_wc_add_cart( $items, $args ) { |
|
| 183 | - $cart_menu_item_position = apply_filters( 'lsx_wc_cart_menu_item_position', 'primary' ); |
|
| 182 | + function lsx_wc_add_cart($items, $args) { |
|
| 183 | + $cart_menu_item_position = apply_filters('lsx_wc_cart_menu_item_position', 'primary'); |
|
| 184 | 184 | |
| 185 | 185 | $cart_logged_out_position = $cart_menu_item_position . '_logged_out'; |
| 186 | 186 | |
| 187 | - if ( $cart_menu_item_position === $args->theme_location || $cart_logged_out_position === $args->theme_location ) { |
|
| 188 | - $customizer_option = get_theme_mod( 'lsx_header_wc_cart', false ); |
|
| 187 | + if ($cart_menu_item_position === $args->theme_location || $cart_logged_out_position === $args->theme_location) { |
|
| 188 | + $customizer_option = get_theme_mod('lsx_header_wc_cart', false); |
|
| 189 | 189 | |
| 190 | - if ( ! empty( $customizer_option ) ) { |
|
| 190 | + if ( ! empty($customizer_option)) { |
|
| 191 | 191 | ob_start(); |
| 192 | - the_widget( 'WC_Widget_Cart', 'title=' ); |
|
| 192 | + the_widget('WC_Widget_Cart', 'title='); |
|
| 193 | 193 | $widget = ob_get_clean(); |
| 194 | 194 | |
| 195 | - if ( is_cart() ) { |
|
| 195 | + if (is_cart()) { |
|
| 196 | 196 | $class = 'current-menu-item'; |
| 197 | 197 | } else { |
| 198 | 198 | $class = ''; |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | $item_class = 'menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children dropdown lsx-wc-cart-menu-item ' . $class; |
| 202 | - $item_class = apply_filters( 'lsx_wc_cart_menu_item_class', $item_class ); |
|
| 202 | + $item_class = apply_filters('lsx_wc_cart_menu_item_class', $item_class); |
|
| 203 | 203 | |
| 204 | 204 | $item = '<li class="' . $item_class . '">' . |
| 205 | - '<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">' . |
|
| 206 | - '<span class="lsx-wc-cart-amount">' . wp_kses_data( WC()->cart->get_cart_subtotal() ) . '</span>' . |
|
| 205 | + '<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">' . |
|
| 206 | + '<span class="lsx-wc-cart-amount">' . wp_kses_data(WC()->cart->get_cart_subtotal()) . '</span>' . |
|
| 207 | 207 | /* Translators: %s: items quantity */ |
| 208 | - '<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>' . |
|
| 209 | - ( ! empty( WC()->cart->get_cart_contents_count() ) ? '<span class="lsx-wc-cart-count-badge">' . wp_kses_data( WC()->cart->get_cart_contents_count() ) . '</span>' : '' ) . |
|
| 208 | + '<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>' . |
|
| 209 | + ( ! empty(WC()->cart->get_cart_contents_count()) ? '<span class="lsx-wc-cart-count-badge">' . wp_kses_data(WC()->cart->get_cart_contents_count()) . '</span>' : '') . |
|
| 210 | 210 | '</a>' . |
| 211 | 211 | '<ul role="menu" class=" dropdown-menu lsx-wc-cart-sub-menu">' . |
| 212 | 212 | '<li>' . |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | '</ul>' . |
| 216 | 216 | '</li>'; |
| 217 | 217 | |
| 218 | - if ( 'top-menu' === $args->theme_location ) { |
|
| 218 | + if ('top-menu' === $args->theme_location) { |
|
| 219 | 219 | $items = $item . $items; |
| 220 | 220 | } else { |
| 221 | 221 | $items = $items . $item; |
@@ -226,11 +226,11 @@ discard block |
||
| 226 | 226 | return $items; |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - add_filter( 'wp_nav_menu_items', 'lsx_wc_add_cart', 10, 2 ); |
|
| 229 | + add_filter('wp_nav_menu_items', 'lsx_wc_add_cart', 10, 2); |
|
| 230 | 230 | |
| 231 | 231 | endif; |
| 232 | 232 | |
| 233 | -if ( ! function_exists( 'lsx_wc_products_widget_wrapper_before' ) ) : |
|
| 233 | +if ( ! function_exists('lsx_wc_products_widget_wrapper_before')) : |
|
| 234 | 234 | |
| 235 | 235 | /** |
| 236 | 236 | * Change WC products widget wrapper (before). |
@@ -238,16 +238,16 @@ discard block |
||
| 238 | 238 | * @package lsx |
| 239 | 239 | * @subpackage woocommerce |
| 240 | 240 | */ |
| 241 | - function lsx_wc_products_widget_wrapper_before( $html ) { |
|
| 241 | + function lsx_wc_products_widget_wrapper_before($html) { |
|
| 242 | 242 | $html = '<div class="lsx-woocommerce-slider lsx-woocommerce-shortcode">'; |
| 243 | 243 | return $html; |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - add_filter( 'woocommerce_before_widget_product_list', 'lsx_wc_products_widget_wrapper_before', 15 ); |
|
| 246 | + add_filter('woocommerce_before_widget_product_list', 'lsx_wc_products_widget_wrapper_before', 15); |
|
| 247 | 247 | |
| 248 | 248 | endif; |
| 249 | 249 | |
| 250 | -if ( ! function_exists( 'lsx_wc_products_widget_wrapper_after' ) ) : |
|
| 250 | +if ( ! function_exists('lsx_wc_products_widget_wrapper_after')) : |
|
| 251 | 251 | |
| 252 | 252 | /** |
| 253 | 253 | * Change WC products widget wrapper (after). |
@@ -255,16 +255,16 @@ discard block |
||
| 255 | 255 | * @package lsx |
| 256 | 256 | * @subpackage woocommerce |
| 257 | 257 | */ |
| 258 | - function lsx_wc_products_widget_wrapper_after( $html ) { |
|
| 258 | + function lsx_wc_products_widget_wrapper_after($html) { |
|
| 259 | 259 | $html = '</div>'; |
| 260 | 260 | return $html; |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | - add_filter( 'woocommerce_after_widget_product_list', 'lsx_wc_products_widget_wrapper_after', 15 ); |
|
| 263 | + add_filter('woocommerce_after_widget_product_list', 'lsx_wc_products_widget_wrapper_after', 15); |
|
| 264 | 264 | |
| 265 | 265 | endif; |
| 266 | 266 | |
| 267 | -if ( ! function_exists( 'lsx_wc_reviews_widget_override' ) ) : |
|
| 267 | +if ( ! function_exists('lsx_wc_reviews_widget_override')) : |
|
| 268 | 268 | |
| 269 | 269 | /** |
| 270 | 270 | * Override WC ewviews widget. |
@@ -273,18 +273,18 @@ discard block |
||
| 273 | 273 | * @subpackage woocommerce |
| 274 | 274 | */ |
| 275 | 275 | function lsx_wc_reviews_widget_override() { |
| 276 | - if ( class_exists( 'WC_Widget_Recent_Reviews' ) ) { |
|
| 277 | - unregister_widget( 'WC_Widget_Recent_Reviews' ); |
|
| 276 | + if (class_exists('WC_Widget_Recent_Reviews')) { |
|
| 277 | + unregister_widget('WC_Widget_Recent_Reviews'); |
|
| 278 | 278 | require get_template_directory() . '/includes/classes/class-lsx-wc-widget-recent-reviews.php'; |
| 279 | - register_widget( 'LSX_WC_Widget_Recent_Reviews' ); |
|
| 279 | + register_widget('LSX_WC_Widget_Recent_Reviews'); |
|
| 280 | 280 | } |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | - add_action( 'widgets_init', 'lsx_wc_reviews_widget_override', 15 ); |
|
| 283 | + add_action('widgets_init', 'lsx_wc_reviews_widget_override', 15); |
|
| 284 | 284 | |
| 285 | 285 | endif; |
| 286 | 286 | |
| 287 | -if ( ! function_exists( 'lsx_wc_change_price_html' ) ) : |
|
| 287 | +if ( ! function_exists('lsx_wc_change_price_html')) : |
|
| 288 | 288 | |
| 289 | 289 | /** |
| 290 | 290 | * Change WC ZERO price to "free". |
@@ -296,28 +296,28 @@ discard block |
||
| 296 | 296 | * @param $product WC_Product |
| 297 | 297 | * @return string |
| 298 | 298 | */ |
| 299 | - function lsx_wc_change_price_html( $price, $product ) { |
|
| 300 | - if ( empty( $product->get_price() ) ) { |
|
| 301 | - if ( $product->is_on_sale() && $product->get_regular_price() ) { |
|
| 302 | - $regular_price = wc_get_price_to_display( $product, array( |
|
| 299 | + function lsx_wc_change_price_html($price, $product) { |
|
| 300 | + if (empty($product->get_price())) { |
|
| 301 | + if ($product->is_on_sale() && $product->get_regular_price()) { |
|
| 302 | + $regular_price = wc_get_price_to_display($product, array( |
|
| 303 | 303 | 'qty' => 1, |
| 304 | 304 | 'price' => $product->get_regular_price(), |
| 305 | - ) ); |
|
| 305 | + )); |
|
| 306 | 306 | |
| 307 | - $price = wc_format_price_range( $regular_price, esc_html__( 'Free!', 'lsx' ) ); |
|
| 307 | + $price = wc_format_price_range($regular_price, esc_html__('Free!', 'lsx')); |
|
| 308 | 308 | } else { |
| 309 | - $price = '<span class="amount">' . esc_html__( 'Free!', 'lsx' ) . '</span>'; |
|
| 309 | + $price = '<span class="amount">' . esc_html__('Free!', 'lsx') . '</span>'; |
|
| 310 | 310 | } |
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | return $price; |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | - add_filter( 'woocommerce_get_price_html', 'lsx_wc_change_price_html', 15, 2 ); |
|
| 316 | + add_filter('woocommerce_get_price_html', 'lsx_wc_change_price_html', 15, 2); |
|
| 317 | 317 | |
| 318 | 318 | endif; |
| 319 | 319 | |
| 320 | -if ( ! function_exists( 'lsx_wc_cart_link_fragment' ) ) : |
|
| 320 | +if ( ! function_exists('lsx_wc_cart_link_fragment')) : |
|
| 321 | 321 | |
| 322 | 322 | /** |
| 323 | 323 | * Cart Fragments. |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | * @package lsx |
| 327 | 327 | * @subpackage woocommerce |
| 328 | 328 | */ |
| 329 | - function lsx_wc_cart_link_fragment( $fragments ) { |
|
| 329 | + function lsx_wc_cart_link_fragment($fragments) { |
|
| 330 | 330 | global $woocommerce; |
| 331 | 331 | |
| 332 | 332 | ob_start(); |
@@ -337,8 +337,8 @@ discard block |
||
| 337 | 337 | lsx_wc_items_counter(); |
| 338 | 338 | $items_counter = ob_get_clean(); |
| 339 | 339 | |
| 340 | - if ( ! empty( $items_counter ) ) { |
|
| 341 | - $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'] ); |
|
| 340 | + if ( ! empty($items_counter)) { |
|
| 341 | + $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']); |
|
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | return $fragments; |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | |
| 347 | 347 | endif; |
| 348 | 348 | |
| 349 | -if ( ! function_exists( 'lsx_wc_cart_link' ) ) : |
|
| 349 | +if ( ! function_exists('lsx_wc_cart_link')) : |
|
| 350 | 350 | |
| 351 | 351 | /** |
| 352 | 352 | * Cart Link. |
@@ -357,14 +357,14 @@ discard block |
||
| 357 | 357 | */ |
| 358 | 358 | function lsx_wc_cart_link() { |
| 359 | 359 | ?> |
| 360 | - <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"> |
|
| 361 | - <span class="lsx-wc-cart-amount"><?php echo wp_kses_data( WC()->cart->get_cart_subtotal() ); ?></span> |
|
| 360 | + <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"> |
|
| 361 | + <span class="lsx-wc-cart-amount"><?php echo wp_kses_data(WC()->cart->get_cart_subtotal()); ?></span> |
|
| 362 | 362 | |
| 363 | 363 | <?php /* Translators: %s: items quantity */ ?> |
| 364 | - <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> |
|
| 364 | + <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> |
|
| 365 | 365 | |
| 366 | - <?php if ( ! empty( WC()->cart->get_cart_contents_count() ) ) : ?> |
|
| 367 | - <span class="lsx-wc-cart-count-badge"><?php echo wp_kses_data( WC()->cart->get_cart_contents_count() );?></span> |
|
| 366 | + <?php if ( ! empty(WC()->cart->get_cart_contents_count())) : ?> |
|
| 367 | + <span class="lsx-wc-cart-count-badge"><?php echo wp_kses_data(WC()->cart->get_cart_contents_count()); ?></span> |
|
| 368 | 368 | <?php endif; ?> |
| 369 | 369 | </a> |
| 370 | 370 | <?php |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | |
| 373 | 373 | endif; |
| 374 | 374 | |
| 375 | -if ( ! function_exists( 'lsx_wc_items_counter' ) ) : |
|
| 375 | +if ( ! function_exists('lsx_wc_items_counter')) : |
|
| 376 | 376 | |
| 377 | 377 | /** |
| 378 | 378 | * Add car item hidden items counter. |
@@ -384,21 +384,21 @@ discard block |
||
| 384 | 384 | $count = (int) WC()->cart->get_cart_contents_count(); |
| 385 | 385 | $items_counter = ''; |
| 386 | 386 | |
| 387 | - if ( ! empty( $count ) ) { |
|
| 387 | + if ( ! empty($count)) { |
|
| 388 | 388 | $count -= 3; |
| 389 | 389 | |
| 390 | - if ( 1 === $count ) { |
|
| 391 | - $items_counter = esc_html__( '1 other item in cart', 'lsx' ); |
|
| 392 | - } elseif ( $count > 1 ) { |
|
| 390 | + if (1 === $count) { |
|
| 391 | + $items_counter = esc_html__('1 other item in cart', 'lsx'); |
|
| 392 | + } elseif ($count > 1) { |
|
| 393 | 393 | /* Translators: %s: items counter */ |
| 394 | - $items_counter = sprintf( esc_html__( '%s other items in cart', 'lsx' ), $count ); |
|
| 394 | + $items_counter = sprintf(esc_html__('%s other items in cart', 'lsx'), $count); |
|
| 395 | 395 | } |
| 396 | 396 | } |
| 397 | 397 | |
| 398 | - if ( ! empty( $items_counter ) ) : |
|
| 398 | + if ( ! empty($items_counter)) : |
|
| 399 | 399 | ?> |
| 400 | 400 | <li class="woocommerce-mini-cart-item mini_cart_item" style="display: block;"> |
| 401 | - <a href="<?php echo esc_url( WC()->cart->get_cart_url() ); ?>"><?php echo esc_html( $items_counter ); ?></a> |
|
| 401 | + <a href="<?php echo esc_url(WC()->cart->get_cart_url()); ?>"><?php echo esc_html($items_counter); ?></a> |
|
| 402 | 402 | </li> |
| 403 | 403 | <?php |
| 404 | 404 | endif; |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | |
| 407 | 407 | endif; |
| 408 | 408 | |
| 409 | -if ( ! function_exists( 'lsx_wc_loop_shop_per_page' ) ) : |
|
| 409 | +if ( ! function_exists('lsx_wc_loop_shop_per_page')) : |
|
| 410 | 410 | |
| 411 | 411 | /** |
| 412 | 412 | * Changes the number of products to display on shop. |
@@ -414,16 +414,16 @@ discard block |
||
| 414 | 414 | * @package lsx |
| 415 | 415 | * @subpackage woocommerce |
| 416 | 416 | */ |
| 417 | - function lsx_wc_loop_shop_per_page( $items ) { |
|
| 417 | + function lsx_wc_loop_shop_per_page($items) { |
|
| 418 | 418 | $items = 20; |
| 419 | 419 | return $items; |
| 420 | 420 | } |
| 421 | 421 | |
| 422 | - add_filter( 'loop_shop_per_page', 'lsx_wc_loop_shop_per_page', 20 ); |
|
| 422 | + add_filter('loop_shop_per_page', 'lsx_wc_loop_shop_per_page', 20); |
|
| 423 | 423 | |
| 424 | 424 | endif; |
| 425 | 425 | |
| 426 | -if ( ! function_exists( 'lsx_wc_add_to_cart_message_html' ) ) : |
|
| 426 | +if ( ! function_exists('lsx_wc_add_to_cart_message_html')) : |
|
| 427 | 427 | |
| 428 | 428 | /** |
| 429 | 429 | * Changes the "added to cart" message HTML. |
@@ -431,39 +431,39 @@ discard block |
||
| 431 | 431 | * @package lsx |
| 432 | 432 | * @subpackage woocommerce |
| 433 | 433 | */ |
| 434 | - function lsx_wc_add_to_cart_message_html( $message, $products ) { |
|
| 434 | + function lsx_wc_add_to_cart_message_html($message, $products) { |
|
| 435 | 435 | $message = '<div class="woocommerce-message-added-to-cart">' . $message . '</div>'; |
| 436 | 436 | return $message; |
| 437 | 437 | } |
| 438 | 438 | |
| 439 | - add_filter( 'wc_add_to_cart_message_html', 'lsx_wc_add_to_cart_message_html', 20, 2 ); |
|
| 439 | + add_filter('wc_add_to_cart_message_html', 'lsx_wc_add_to_cart_message_html', 20, 2); |
|
| 440 | 440 | |
| 441 | 441 | endif; |
| 442 | 442 | |
| 443 | -if ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, '2.3', '>=' ) ) { |
|
| 444 | - add_filter( 'woocommerce_add_to_cart_fragments', 'lsx_wc_cart_link_fragment' ); |
|
| 443 | +if (defined('WC_VERSION') && version_compare(WC_VERSION, '2.3', '>=')) { |
|
| 444 | + add_filter('woocommerce_add_to_cart_fragments', 'lsx_wc_cart_link_fragment'); |
|
| 445 | 445 | } else { |
| 446 | - add_filter( 'add_to_cart_fragments', 'lsx_wc_cart_link_fragment' ); |
|
| 446 | + add_filter('add_to_cart_fragments', 'lsx_wc_cart_link_fragment'); |
|
| 447 | 447 | } |
| 448 | 448 | |
| 449 | -remove_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 10 ); |
|
| 449 | +remove_action('woocommerce_after_shop_loop', 'woocommerce_pagination', 10); |
|
| 450 | 450 | |
| 451 | -add_action( 'woocommerce_after_shop_loop', 'lsx_wc_sorting_wrapper', 9 ); |
|
| 452 | -add_action( 'woocommerce_after_shop_loop', 'woocommerce_catalog_ordering', 10 ); |
|
| 453 | -add_action( 'woocommerce_after_shop_loop', 'woocommerce_result_count', 20 ); |
|
| 454 | -add_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 30 ); |
|
| 455 | -add_action( 'woocommerce_after_shop_loop', 'lsx_wc_sorting_wrapper_close', 31 ); |
|
| 451 | +add_action('woocommerce_after_shop_loop', 'lsx_wc_sorting_wrapper', 9); |
|
| 452 | +add_action('woocommerce_after_shop_loop', 'woocommerce_catalog_ordering', 10); |
|
| 453 | +add_action('woocommerce_after_shop_loop', 'woocommerce_result_count', 20); |
|
| 454 | +add_action('woocommerce_after_shop_loop', 'woocommerce_pagination', 30); |
|
| 455 | +add_action('woocommerce_after_shop_loop', 'lsx_wc_sorting_wrapper_close', 31); |
|
| 456 | 456 | |
| 457 | -remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 ); |
|
| 458 | -remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 ); |
|
| 457 | +remove_action('woocommerce_before_shop_loop', 'woocommerce_result_count', 20); |
|
| 458 | +remove_action('woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30); |
|
| 459 | 459 | |
| 460 | -add_action( 'woocommerce_before_shop_loop', 'lsx_wc_sorting_wrapper', 9 ); |
|
| 461 | -add_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 10 ); |
|
| 462 | -add_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 ); |
|
| 463 | -add_action( 'woocommerce_before_shop_loop', 'lsx_wc_woocommerce_pagination', 30 ); |
|
| 464 | -add_action( 'woocommerce_before_shop_loop', 'lsx_wc_sorting_wrapper_close', 31 ); |
|
| 460 | +add_action('woocommerce_before_shop_loop', 'lsx_wc_sorting_wrapper', 9); |
|
| 461 | +add_action('woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 10); |
|
| 462 | +add_action('woocommerce_before_shop_loop', 'woocommerce_result_count', 20); |
|
| 463 | +add_action('woocommerce_before_shop_loop', 'lsx_wc_woocommerce_pagination', 30); |
|
| 464 | +add_action('woocommerce_before_shop_loop', 'lsx_wc_sorting_wrapper_close', 31); |
|
| 465 | 465 | |
| 466 | -if ( ! function_exists( 'lsx_wc_sorting_wrapper' ) ) : |
|
| 466 | +if ( ! function_exists('lsx_wc_sorting_wrapper')) : |
|
| 467 | 467 | |
| 468 | 468 | /** |
| 469 | 469 | * Sorting wrapper. |
@@ -477,7 +477,7 @@ discard block |
||
| 477 | 477 | |
| 478 | 478 | endif; |
| 479 | 479 | |
| 480 | -if ( ! function_exists( 'lsx_wc_sorting_wrapper_close' ) ) : |
|
| 480 | +if ( ! function_exists('lsx_wc_sorting_wrapper_close')) : |
|
| 481 | 481 | |
| 482 | 482 | /** |
| 483 | 483 | * Sorting wrapper close. |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | |
| 492 | 492 | endif; |
| 493 | 493 | |
| 494 | -if ( ! function_exists( 'lsx_wc_product_columns_wrapper_close' ) ) : |
|
| 494 | +if ( ! function_exists('lsx_wc_product_columns_wrapper_close')) : |
|
| 495 | 495 | |
| 496 | 496 | /** |
| 497 | 497 | * Product columns wrapper close. |
@@ -505,7 +505,7 @@ discard block |
||
| 505 | 505 | |
| 506 | 506 | endif; |
| 507 | 507 | |
| 508 | -if ( ! function_exists( 'lsx_wc_woocommerce_pagination' ) ) : |
|
| 508 | +if ( ! function_exists('lsx_wc_woocommerce_pagination')) : |
|
| 509 | 509 | |
| 510 | 510 | /** |
| 511 | 511 | * LSX WooCommerce Pagination |
@@ -517,14 +517,14 @@ discard block |
||
| 517 | 517 | * @subpackage woocommerce |
| 518 | 518 | */ |
| 519 | 519 | function lsx_wc_woocommerce_pagination() { |
| 520 | - if ( woocommerce_products_will_display() ) { |
|
| 520 | + if (woocommerce_products_will_display()) { |
|
| 521 | 521 | woocommerce_pagination(); |
| 522 | 522 | } |
| 523 | 523 | } |
| 524 | 524 | |
| 525 | 525 | endif; |
| 526 | 526 | |
| 527 | -if ( ! function_exists( 'lsx_customizer_wc_controls' ) ) : |
|
| 527 | +if ( ! function_exists('lsx_customizer_wc_controls')) : |
|
| 528 | 528 | |
| 529 | 529 | /** |
| 530 | 530 | * Returns an array of the core panel. |
@@ -534,10 +534,10 @@ discard block |
||
| 534 | 534 | * |
| 535 | 535 | * @return $lsx_controls array() |
| 536 | 536 | */ |
| 537 | - function lsx_customizer_wc_controls( $lsx_controls ) { |
|
| 537 | + function lsx_customizer_wc_controls($lsx_controls) { |
|
| 538 | 538 | $lsx_controls['panels']['lsx-wc'] = array( |
| 539 | - 'title' => esc_html__( 'WooCommerce', 'lsx' ), |
|
| 540 | - 'description' => esc_html__( 'Change the WooCommerce settings.', 'lsx' ), |
|
| 539 | + 'title' => esc_html__('WooCommerce', 'lsx'), |
|
| 540 | + 'description' => esc_html__('Change the WooCommerce settings.', 'lsx'), |
|
| 541 | 541 | 'priority' => 23, |
| 542 | 542 | ); |
| 543 | 543 | |
@@ -546,8 +546,8 @@ discard block |
||
| 546 | 546 | */ |
| 547 | 547 | |
| 548 | 548 | $lsx_controls['sections']['lsx-wc-global'] = array( |
| 549 | - 'title' => esc_html__( 'Global', 'lsx' ), |
|
| 550 | - 'description' => esc_html__( 'Change the WooCommerce global settings.', 'lsx' ), |
|
| 549 | + 'title' => esc_html__('Global', 'lsx'), |
|
| 550 | + 'description' => esc_html__('Change the WooCommerce global settings.', 'lsx'), |
|
| 551 | 551 | 'panel' => 'lsx-wc', |
| 552 | 552 | 'priority' => 1, |
| 553 | 553 | ); |
@@ -558,8 +558,8 @@ discard block |
||
| 558 | 558 | ); |
| 559 | 559 | |
| 560 | 560 | $lsx_controls['fields']['lsx_wc_mobile_footer_bar_status'] = array( |
| 561 | - 'label' => esc_html__( 'Footer Bar', 'lsx' ), |
|
| 562 | - 'description' => esc_html__( 'Enable the mobile footer bar.', 'lsx' ), |
|
| 561 | + 'label' => esc_html__('Footer Bar', 'lsx'), |
|
| 562 | + 'description' => esc_html__('Enable the mobile footer bar.', 'lsx'), |
|
| 563 | 563 | 'section' => 'lsx-wc-global', |
| 564 | 564 | 'type' => 'checkbox', |
| 565 | 565 | 'priority' => 1, |
@@ -570,8 +570,8 @@ discard block |
||
| 570 | 570 | */ |
| 571 | 571 | |
| 572 | 572 | $lsx_controls['sections']['lsx-wc-cart'] = array( |
| 573 | - 'title' => esc_html__( 'Cart', 'lsx' ), |
|
| 574 | - 'description' => esc_html__( 'Change the WooCommerce cart settings.', 'lsx' ), |
|
| 573 | + 'title' => esc_html__('Cart', 'lsx'), |
|
| 574 | + 'description' => esc_html__('Change the WooCommerce cart settings.', 'lsx'), |
|
| 575 | 575 | 'panel' => 'lsx-wc', |
| 576 | 576 | 'priority' => 2, |
| 577 | 577 | ); |
@@ -582,8 +582,8 @@ discard block |
||
| 582 | 582 | ); |
| 583 | 583 | |
| 584 | 584 | $lsx_controls['fields']['lsx_header_wc_cart'] = array( |
| 585 | - 'label' => esc_html__( 'Menu Item', 'lsx' ), |
|
| 586 | - 'description' => esc_html__( 'Enable the cart menu item.', 'lsx' ), |
|
| 585 | + 'label' => esc_html__('Menu Item', 'lsx'), |
|
| 586 | + 'description' => esc_html__('Enable the cart menu item.', 'lsx'), |
|
| 587 | 587 | 'section' => 'lsx-wc-cart', |
| 588 | 588 | 'type' => 'checkbox', |
| 589 | 589 | 'priority' => 1, |
@@ -592,11 +592,11 @@ discard block |
||
| 592 | 592 | return $lsx_controls; |
| 593 | 593 | } |
| 594 | 594 | |
| 595 | - add_filter( 'lsx_customizer_controls', 'lsx_customizer_wc_controls' ); |
|
| 595 | + add_filter('lsx_customizer_controls', 'lsx_customizer_wc_controls'); |
|
| 596 | 596 | |
| 597 | 597 | endif; |
| 598 | 598 | |
| 599 | -if ( ! function_exists( 'lsx_wc_footer_bar' ) ) : |
|
| 599 | +if ( ! function_exists('lsx_wc_footer_bar')) : |
|
| 600 | 600 | |
| 601 | 601 | /** |
| 602 | 602 | * Display WC footer bar. |
@@ -605,46 +605,46 @@ discard block |
||
| 605 | 605 | * @subpackage woocommerce |
| 606 | 606 | */ |
| 607 | 607 | function lsx_wc_footer_bar() { |
| 608 | - if ( ! empty( get_theme_mod( 'lsx_wc_mobile_footer_bar_status', '1' ) ) ) : |
|
| 608 | + if ( ! empty(get_theme_mod('lsx_wc_mobile_footer_bar_status', '1'))) : |
|
| 609 | 609 | ?> |
| 610 | 610 | <div class="lsx-wc-footer-bar"> |
| 611 | - <form role="search" method="get" action="<?php echo esc_url( home_url() ); ?>" class="lsx-wc-footer-bar-form"> |
|
| 611 | + <form role="search" method="get" action="<?php echo esc_url(home_url()); ?>" class="lsx-wc-footer-bar-form"> |
|
| 612 | 612 | <fieldset> |
| 613 | - <legend class="screen-reader-text"><?php esc_html_e( 'Search products', 'lsx' ); ?></legend> |
|
| 614 | - <input type="search" name="s" placeholder="<?php esc_attr_e( 'Search products...', 'lsx' ); ?>" class="form-control"> |
|
| 613 | + <legend class="screen-reader-text"><?php esc_html_e('Search products', 'lsx'); ?></legend> |
|
| 614 | + <input type="search" name="s" placeholder="<?php esc_attr_e('Search products...', 'lsx'); ?>" class="form-control"> |
|
| 615 | 615 | </fieldset> |
| 616 | 616 | </form> |
| 617 | 617 | |
| 618 | 618 | <ul class="lsx-wc-footer-bar-items"> |
| 619 | 619 | <li class="lsx-wc-footer-bar-item"> |
| 620 | - <a href="<?php echo esc_url( home_url() ); ?>" class="lsx-wc-footer-bar-link"> |
|
| 620 | + <a href="<?php echo esc_url(home_url()); ?>" class="lsx-wc-footer-bar-link"> |
|
| 621 | 621 | <i class="fa fa-home" aria-hidden="true"></i> |
| 622 | - <span><?php esc_html_e( 'Home', 'lsx' ); ?></span> |
|
| 622 | + <span><?php esc_html_e('Home', 'lsx'); ?></span> |
|
| 623 | 623 | </a> |
| 624 | 624 | </li> |
| 625 | 625 | |
| 626 | 626 | <li class="lsx-wc-footer-bar-item"> |
| 627 | - <a href="<?php echo esc_url( get_permalink( get_option( 'woocommerce_myaccount_page_id' ) ) ); ?>" class="lsx-wc-footer-bar-link"> |
|
| 627 | + <a href="<?php echo esc_url(get_permalink(get_option('woocommerce_myaccount_page_id'))); ?>" class="lsx-wc-footer-bar-link"> |
|
| 628 | 628 | <i class="fa fa-user" aria-hidden="true"></i> |
| 629 | - <span><?php esc_html_e( 'Account', 'lsx' ); ?></span> |
|
| 629 | + <span><?php esc_html_e('Account', 'lsx'); ?></span> |
|
| 630 | 630 | </a> |
| 631 | 631 | </li> |
| 632 | 632 | |
| 633 | 633 | <li class="lsx-wc-footer-bar-item"> |
| 634 | 634 | <a href="#" class="lsx-wc-footer-bar-link lsx-wc-footer-bar-link-toogle"> |
| 635 | 635 | <i class="fa fa-search" aria-hidden="true"></i> |
| 636 | - <span><?php esc_html_e( 'Search', 'lsx' ); ?></span> |
|
| 636 | + <span><?php esc_html_e('Search', 'lsx'); ?></span> |
|
| 637 | 637 | </a> |
| 638 | 638 | </li> |
| 639 | 639 | |
| 640 | 640 | <li class="lsx-wc-footer-bar-item"> |
| 641 | - <a href="<?php echo esc_url( WC()->cart->get_cart_url() ); ?>" class="lsx-wc-footer-bar-link"> |
|
| 641 | + <a href="<?php echo esc_url(WC()->cart->get_cart_url()); ?>" class="lsx-wc-footer-bar-link"> |
|
| 642 | 642 | <i class="fa fa-shopping-basket" aria-hidden="true"></i> |
| 643 | 643 | <?php $count = WC()->cart->get_cart_contents_count(); ?> |
| 644 | - <?php if ( ! empty( $count ) ) : ?> |
|
| 645 | - <span class="lsx-wc-footer-bar-count"><?php echo wp_kses_data( $count ); ?></span> |
|
| 644 | + <?php if ( ! empty($count)) : ?> |
|
| 645 | + <span class="lsx-wc-footer-bar-count"><?php echo wp_kses_data($count); ?></span> |
|
| 646 | 646 | <?php endif; ?> |
| 647 | - <span><?php esc_html_e( 'Cart', 'lsx' ); ?></span> |
|
| 647 | + <span><?php esc_html_e('Cart', 'lsx'); ?></span> |
|
| 648 | 648 | </a> |
| 649 | 649 | </li> |
| 650 | 650 | </ul> |
@@ -653,11 +653,11 @@ discard block |
||
| 653 | 653 | endif; |
| 654 | 654 | } |
| 655 | 655 | |
| 656 | - add_action( 'lsx_body_bottom', 'lsx_wc_footer_bar', 15 ); |
|
| 656 | + add_action('lsx_body_bottom', 'lsx_wc_footer_bar', 15); |
|
| 657 | 657 | |
| 658 | 658 | endif; |
| 659 | 659 | |
| 660 | -if ( ! function_exists( 'lsx_wc_body_class' ) ) : |
|
| 660 | +if ( ! function_exists('lsx_wc_body_class')) : |
|
| 661 | 661 | |
| 662 | 662 | /** |
| 663 | 663 | * Changes body class. |
@@ -665,25 +665,25 @@ discard block |
||
| 665 | 665 | * @package lsx |
| 666 | 666 | * @subpackage woocommerce |
| 667 | 667 | */ |
| 668 | - function lsx_wc_body_class( $classes ) { |
|
| 668 | + function lsx_wc_body_class($classes) { |
|
| 669 | 669 | global $post; |
| 670 | 670 | |
| 671 | - if ( $post && class_exists( 'WC_Wishlists_Pages' ) && WC_Wishlists_Pages::is_wishlist_page( $post->post_name ) ) { |
|
| 671 | + if ($post && class_exists('WC_Wishlists_Pages') && WC_Wishlists_Pages::is_wishlist_page($post->post_name)) { |
|
| 672 | 672 | $classes[] = 'woocommerce-page woocommerce-wishlist'; |
| 673 | 673 | } |
| 674 | 674 | |
| 675 | - if ( ! empty( get_theme_mod( 'lsx_wc_mobile_footer_bar_status', '1' ) ) ) { |
|
| 675 | + if ( ! empty(get_theme_mod('lsx_wc_mobile_footer_bar_status', '1'))) { |
|
| 676 | 676 | $classes[] = 'lsx-wc-has-footer-bar'; |
| 677 | 677 | } |
| 678 | 678 | |
| 679 | 679 | return $classes; |
| 680 | 680 | } |
| 681 | 681 | |
| 682 | - add_filter( 'body_class', 'lsx_wc_body_class', 2999 ); |
|
| 682 | + add_filter('body_class', 'lsx_wc_body_class', 2999); |
|
| 683 | 683 | |
| 684 | 684 | endif; |
| 685 | 685 | |
| 686 | -if ( ! function_exists( 'lsx_wc_downloadable_products' ) ) : |
|
| 686 | +if ( ! function_exists('lsx_wc_downloadable_products')) : |
|
| 687 | 687 | |
| 688 | 688 | /** |
| 689 | 689 | * Changes downloads "download" button text. |
@@ -691,19 +691,19 @@ discard block |
||
| 691 | 691 | * @package lsx |
| 692 | 692 | * @subpackage woocommerce |
| 693 | 693 | */ |
| 694 | - function lsx_wc_downloadable_products( $downloads ) { |
|
| 695 | - foreach ( $downloads as $i => $download ) { |
|
| 696 | - $downloads[ $i ]['download_name'] = esc_html__( 'Download', 'lsx' ); |
|
| 694 | + function lsx_wc_downloadable_products($downloads) { |
|
| 695 | + foreach ($downloads as $i => $download) { |
|
| 696 | + $downloads[$i]['download_name'] = esc_html__('Download', 'lsx'); |
|
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | return $downloads; |
| 700 | 700 | } |
| 701 | 701 | |
| 702 | - add_filter( 'woocommerce_customer_get_downloadable_products', 'lsx_wc_downloadable_products', 2999 ); |
|
| 702 | + add_filter('woocommerce_customer_get_downloadable_products', 'lsx_wc_downloadable_products', 2999); |
|
| 703 | 703 | |
| 704 | 704 | endif; |
| 705 | 705 | |
| 706 | -if ( ! function_exists( 'lsx_wc_move_bundle_products' ) ) : |
|
| 706 | +if ( ! function_exists('lsx_wc_move_bundle_products')) : |
|
| 707 | 707 | |
| 708 | 708 | /** |
| 709 | 709 | * WooCommerce - Move the bundle products to a tab. |
@@ -711,46 +711,46 @@ discard block |
||
| 711 | 711 | * @package lsx |
| 712 | 712 | * @subpackage woocommerce |
| 713 | 713 | */ |
| 714 | - function lsx_wc_move_bundle_products( $tabs ) { |
|
| 714 | + function lsx_wc_move_bundle_products($tabs) { |
|
| 715 | 715 | global $product, $post; |
| 716 | 716 | |
| 717 | - if ( method_exists( $product , 'get_bundled_items' ) ) { |
|
| 717 | + if (method_exists($product, 'get_bundled_items')) { |
|
| 718 | 718 | $bundled_items = $product->get_bundled_items(); |
| 719 | 719 | |
| 720 | - if ( ! empty( $bundled_items ) ) { |
|
| 720 | + if ( ! empty($bundled_items)) { |
|
| 721 | 721 | $tabs['bundled_products'] = array( |
| 722 | - 'title' => __( 'Included Products', 'lsx' ), |
|
| 722 | + 'title' => __('Included Products', 'lsx'), |
|
| 723 | 723 | 'priority' => 10, |
| 724 | 724 | 'callback' => 'lsx_wc_bundle_products', |
| 725 | 725 | ); |
| 726 | 726 | } |
| 727 | 727 | } |
| 728 | 728 | |
| 729 | - if ( isset( $tabs['description'] ) ) { |
|
| 729 | + if (isset($tabs['description'])) { |
|
| 730 | 730 | $tabs['description']['priority'] = 5; |
| 731 | 731 | } |
| 732 | 732 | |
| 733 | - if ( isset( $tabs['reviews'] ) ) { |
|
| 733 | + if (isset($tabs['reviews'])) { |
|
| 734 | 734 | $tabs['reviews']['priority'] = 15; |
| 735 | 735 | } |
| 736 | 736 | |
| 737 | - if ( isset( $tabs['product_enquiry'] ) ) { |
|
| 737 | + if (isset($tabs['product_enquiry'])) { |
|
| 738 | 738 | $tabs['product_enquiry']['priority'] = 20; |
| 739 | 739 | } |
| 740 | 740 | |
| 741 | 741 | return $tabs; |
| 742 | 742 | } |
| 743 | 743 | |
| 744 | - add_action( 'woocommerce_product_tabs', 'lsx_wc_move_bundle_products', 50 ); |
|
| 744 | + add_action('woocommerce_product_tabs', 'lsx_wc_move_bundle_products', 50); |
|
| 745 | 745 | |
| 746 | 746 | endif; |
| 747 | 747 | |
| 748 | -if ( ! function_exists( 'lsx_wc_bundle_products' ) ) : |
|
| 748 | +if ( ! function_exists('lsx_wc_bundle_products')) : |
|
| 749 | 749 | |
| 750 | 750 | function lsx_wc_bundle_products() { |
| 751 | 751 | global $product, $post; |
| 752 | 752 | |
| 753 | - if ( method_exists( $product , 'get_bundled_items' ) ) { |
|
| 753 | + if (method_exists($product, 'get_bundled_items')) { |
|
| 754 | 754 | $bundled_items = $product->get_bundled_items(); |
| 755 | 755 | |
| 756 | 756 | // do_action( 'woocommerce_before_bundled_items', $product ); |
@@ -766,16 +766,16 @@ discard block |
||
| 766 | 766 | // $this->widget_start( $args, $instance ); |
| 767 | 767 | |
| 768 | 768 | // @codingStandardsIgnoreLine |
| 769 | - echo apply_filters( 'woocommerce_before_widget_product_list', '<ul class="product_list_widget">' ); |
|
| 769 | + echo apply_filters('woocommerce_before_widget_product_list', '<ul class="product_list_widget">'); |
|
| 770 | 770 | |
| 771 | - foreach ( $bundled_items as $bundled_item ) { |
|
| 772 | - $product = wc_get_product( $bundled_item->item_data['product_id'] ); |
|
| 773 | - wc_get_template( 'content-widget-product.php' ); |
|
| 771 | + foreach ($bundled_items as $bundled_item) { |
|
| 772 | + $product = wc_get_product($bundled_item->item_data['product_id']); |
|
| 773 | + wc_get_template('content-widget-product.php'); |
|
| 774 | 774 | $product = $product_original; |
| 775 | 775 | } |
| 776 | 776 | |
| 777 | 777 | // @codingStandardsIgnoreLine |
| 778 | - echo apply_filters( 'woocommerce_after_widget_product_list', '</ul>' ); |
|
| 778 | + echo apply_filters('woocommerce_after_widget_product_list', '</ul>'); |
|
| 779 | 779 | } |
| 780 | 780 | |
| 781 | 781 | // $this->widget_end( $args ); |
@@ -784,7 +784,7 @@ discard block |
||
| 784 | 784 | endif; |
| 785 | 785 | |
| 786 | 786 | |
| 787 | -if ( ! function_exists( 'lsx_wc_product_searchform' ) ) : |
|
| 787 | +if ( ! function_exists('lsx_wc_product_searchform')) : |
|
| 788 | 788 | /** |
| 789 | 789 | * woo_custom_product_searchform |
| 790 | 790 | * |
@@ -792,7 +792,7 @@ discard block |
||
| 792 | 792 | * @since 1.0 |
| 793 | 793 | * @return void |
| 794 | 794 | */ |
| 795 | - function lsx_wc_product_searchform( $form ) { |
|
| 795 | + function lsx_wc_product_searchform($form) { |
|
| 796 | 796 | |
| 797 | 797 | $form = ' |
| 798 | 798 | <form role="search" method="get" class="search-form form-inline" id="searchform" action="<?php echo esc_url( home_url( \'/\' ) ); ?>"> |
@@ -813,53 +813,53 @@ discard block |
||
| 813 | 813 | |
| 814 | 814 | } |
| 815 | 815 | endif; |
| 816 | -add_filter( 'get_product_search_form' , 'lsx_wc_product_searchform', 10, 1 ); |
|
| 816 | +add_filter('get_product_search_form', 'lsx_wc_product_searchform', 10, 1); |
|
| 817 | 817 | |
| 818 | 818 | /** |
| 819 | 819 | * Add in nav classes for the Product Tabs |
| 820 | 820 | */ |
| 821 | 821 | function woocommerce_output_product_data_tabs() { |
| 822 | - $html = wc_get_template_html( 'single-product/tabs/tabs.php' ); |
|
| 822 | + $html = wc_get_template_html('single-product/tabs/tabs.php'); |
|
| 823 | 823 | |
| 824 | 824 | //$html = str_replace( 'woocommerce-wc-tabs nav nav-tabs-wrapper', 'woocommerce-tabs wc-tabs-wrapper', $html ); |
| 825 | - $html = str_replace( '"tabs wc-tabs', '"nav nav-tabs wc-tabs', $html ); |
|
| 826 | - echo wp_kses_post( $html ); |
|
| 825 | + $html = str_replace('"tabs wc-tabs', '"nav nav-tabs wc-tabs', $html); |
|
| 826 | + echo wp_kses_post($html); |
|
| 827 | 827 | } |
| 828 | 828 | |
| 829 | 829 | /** |
| 830 | 830 | * Output the pagination. |
| 831 | 831 | */ |
| 832 | 832 | function woocommerce_pagination() { |
| 833 | - if ( ! wc_get_loop_prop( 'is_paginated' ) || ! woocommerce_products_will_display() ) { |
|
| 833 | + if ( ! wc_get_loop_prop('is_paginated') || ! woocommerce_products_will_display()) { |
|
| 834 | 834 | return; |
| 835 | 835 | } |
| 836 | 836 | $args = array( |
| 837 | - 'total' => wc_get_loop_prop( 'total_pages' ), |
|
| 838 | - 'current' => wc_get_loop_prop( 'current_page' ), |
|
| 837 | + 'total' => wc_get_loop_prop('total_pages'), |
|
| 838 | + 'current' => wc_get_loop_prop('current_page'), |
|
| 839 | 839 | ); |
| 840 | 840 | |
| 841 | - if ( wc_get_loop_prop( 'is_shortcode' ) ) { |
|
| 842 | - $args['base'] = esc_url_raw( add_query_arg( 'product-page', '%#%', false ) ); |
|
| 841 | + if (wc_get_loop_prop('is_shortcode')) { |
|
| 842 | + $args['base'] = esc_url_raw(add_query_arg('product-page', '%#%', false)); |
|
| 843 | 843 | $args['format'] = '?product-page = %#%'; |
| 844 | 844 | } else { |
| 845 | - $args['base'] = esc_url_raw( str_replace( 999999999, '%#%', remove_query_arg( 'add-to-cart', get_pagenum_link( 999999999, false ) ) ) ); |
|
| 845 | + $args['base'] = esc_url_raw(str_replace(999999999, '%#%', remove_query_arg('add-to-cart', get_pagenum_link(999999999, false)))); |
|
| 846 | 846 | $args['format'] = ''; |
| 847 | 847 | } |
| 848 | 848 | |
| 849 | - echo wp_kses_post( '<div class="lsx-pagination-wrapper">' ); |
|
| 850 | - $template = wc_get_template_html( 'loop/pagination.php', $args ); |
|
| 851 | - $template = str_replace( 'woocommerce-pagination', 'lsx-pagination', $template ); |
|
| 852 | - echo wp_kses_post( $template ); |
|
| 853 | - echo wp_kses_post( '</div>' ); |
|
| 849 | + echo wp_kses_post('<div class="lsx-pagination-wrapper">'); |
|
| 850 | + $template = wc_get_template_html('loop/pagination.php', $args); |
|
| 851 | + $template = str_replace('woocommerce-pagination', 'lsx-pagination', $template); |
|
| 852 | + echo wp_kses_post($template); |
|
| 853 | + echo wp_kses_post('</div>'); |
|
| 854 | 854 | } |
| 855 | 855 | |
| 856 | -function lsx_wc_pagination_args( $args ) { |
|
| 857 | - $args['prev_text'] = '<span class="meta-nav">←</span> ' . esc_html__( 'Previous', 'lsx' ); |
|
| 858 | - $args['next_text'] = esc_html__( 'Next', 'lsx' ) . ' <span class="meta-nav">→</span>'; |
|
| 859 | - $args['type'] = 'plain'; |
|
| 856 | +function lsx_wc_pagination_args($args) { |
|
| 857 | + $args['prev_text'] = '<span class="meta-nav">←</span> ' . esc_html__('Previous', 'lsx'); |
|
| 858 | + $args['next_text'] = esc_html__('Next', 'lsx') . ' <span class="meta-nav">→</span>'; |
|
| 859 | + $args['type'] = 'plain'; |
|
| 860 | 860 | return $args; |
| 861 | 861 | } |
| 862 | -add_filter( 'woocommerce_pagination_args', 'lsx_wc_pagination_args',10 ,1 ); |
|
| 862 | +add_filter('woocommerce_pagination_args', 'lsx_wc_pagination_args', 10, 1); |
|
| 863 | 863 | |
| 864 | 864 | |
| 865 | 865 | /** |
@@ -869,22 +869,22 @@ discard block |
||
| 869 | 869 | * |
| 870 | 870 | * @return array |
| 871 | 871 | */ |
| 872 | -function lsx_wc_product_widget_template( $located, $template_name ) { |
|
| 873 | - if ( 'content-widget-product.php' === $template_name || 'content-widget-review.php' === $template_name ) { |
|
| 872 | +function lsx_wc_product_widget_template($located, $template_name) { |
|
| 873 | + if ('content-widget-product.php' === $template_name || 'content-widget-review.php' === $template_name) { |
|
| 874 | 874 | |
| 875 | 875 | $new_location = get_stylesheet_directory() . '/partials/' . $template_name; |
| 876 | - if ( file_exists( $new_location ) ) { |
|
| 876 | + if (file_exists($new_location)) { |
|
| 877 | 877 | $located = $new_location; |
| 878 | 878 | } else { |
| 879 | 879 | $new_location = get_parent_theme_file_path() . '/partials/' . $template_name; |
| 880 | - if ( file_exists( $new_location ) ) { |
|
| 880 | + if (file_exists($new_location)) { |
|
| 881 | 881 | $located = $new_location; |
| 882 | 882 | } |
| 883 | 883 | } |
| 884 | 884 | } |
| 885 | 885 | return $located; |
| 886 | 886 | } |
| 887 | -add_filter( 'wc_get_template', 'lsx_wc_product_widget_template',90 ,2 ); |
|
| 887 | +add_filter('wc_get_template', 'lsx_wc_product_widget_template', 90, 2); |
|
| 888 | 888 | /* |
| 889 | 889 | |
| 890 | 890 | */ |