Browse Source

Pique: Adds support for the 3.3+ new WC Customizer options (See #87)

Danny Dudzic 7 năm trước cách đây
mục cha
commit
60b614f852
3 tập tin đã thay đổi với 44 bổ sung12 xóa
  1. 40 9
      pique/inc/woocommerce.php
  2. 1 1
      pique/style.css
  3. 3 2
      pique/woocommerce.css

+ 40 - 9
pique/inc/woocommerce.php

@@ -16,10 +16,18 @@
  * @return void
  */
 function pique_woocommerce_setup() {
-	add_theme_support( 'woocommerce', array(
-		'thumbnail_image_width' => 726,
-		'single_image_width'    => 700,
-	) );
+	add_theme_support( 'woocommerce', apply_filters( 'pique_woocommerce_args', array(
+		'single_image_width'    => 942,
+		'thumbnail_image_width' => 350,
+		'product_grid'          => array(
+			'default_columns' => 3,
+			'default_rows'    => 4,
+			'min_columns'     => 1,
+			'max_columns'     => 6,
+			'min_rows'        => 1
+		)
+	) ) );
+
 	add_theme_support( 'wc-product-gallery-zoom' );
 	add_theme_support( 'wc-product-gallery-lightbox' );
 	add_theme_support( 'wc-product-gallery-slider' );
@@ -65,8 +73,8 @@ function pique_woocommerce_image_dimensions() {
 	}
 
 	$single = array(
-		'width'  => '700',   // px
-		'height' => '700',   // px
+		'width'  => '942',   // px
+		'height' => '942',   // px
 		'crop'   => false    // true
 	);
 
@@ -106,7 +114,11 @@ add_filter( 'body_class', 'pique_woocommerce_active_body_class' );
 function pique_woocommerce_products_per_page() {
 	return 12;
 }
-add_filter( 'loop_shop_per_page', 'pique_woocommerce_products_per_page' );
+
+// Legacy WooCommerce products per page filter.
+if ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, '3.3', '<' ) ) {
+	add_filter( 'loop_shop_per_page', 'pique_woocommerce_products_per_page' );
+}
 
 /**
  * Product gallery thumnbail columns.
@@ -126,7 +138,11 @@ add_filter( 'woocommerce_product_thumbnails_columns', 'pique_woocommerce_thumbna
 function pique_woocommerce_loop_columns() {
 	return 3;
 }
-add_filter( 'loop_shop_columns', 'pique_woocommerce_loop_columns' );
+
+// Legacy WooCommerce columns filter.
+if ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, '3.3', '<' ) ) {
+	add_filter( 'loop_shop_columns', 'pique_woocommerce_loop_columns' );
+}
 
 /**
  * Related Products Args.
@@ -153,12 +169,27 @@ if ( ! function_exists( 'pique_woocommerce_product_columns_wrapper' ) ) {
 	 * @return  void
 	 */
 	function pique_woocommerce_product_columns_wrapper() {
-		$columns = pique_woocommerce_loop_columns();
+		$columns = pique_loop_columns();
 		echo '<div class="columns-' . absint( $columns ) . '">';
 	}
 }
 add_action( 'woocommerce_before_shop_loop', 'pique_woocommerce_product_columns_wrapper', 40 );
 
+if ( ! function_exists( 'pique_loop_columns' ) ) {
+	/**
+	 * Default loop columns on product archives
+	 *
+	 * @return integer products per row
+	 */
+	function pique_loop_columns() {
+		$columns = 3; // 3 products per row
+		if ( function_exists( 'wc_get_default_products_per_row' ) ) {
+			$columns = wc_get_default_products_per_row();
+		}
+		return apply_filters( 'pique_loop_columns', $columns );
+	}
+}
+
 if ( ! function_exists( 'pique_woocommerce_product_columns_wrapper_close' ) ) {
 	/**
 	 * Product columns wrapper close.

+ 1 - 1
pique/style.css

@@ -4,7 +4,7 @@ Theme URI: https://wordpress.com/themes/pique/
 Author: Automattic
 Author URI: http://wordpress.com/themes/
 Description: A one-page scrolling theme for small businesses.
-Version: 1.4.3-wpcom
+Version: 1.4.4-wpcom
 License: GNU General Public License v2 or later
 License URI: http://www.gnu.org/licenses/gpl-2.0.html
 Text Domain: pique

+ 3 - 2
pique/woocommerce.css

@@ -33,7 +33,6 @@ WooCommerce styles override
 	}
 
 	.woocommerce-page .site-content .content-area {
-		float: right;
 		padding: 20px 20px 20px 40px;
 		width: 66%;
 	}
@@ -289,6 +288,7 @@ ul.products li.product .woocommerce-loop-product__link {
 ul.products li.product .button {
 	display: inline-block;
 	margin: 0 auto;
+	max-width: 100%;
 }
 
 ul.products li.product .added_to_cart {
@@ -389,7 +389,7 @@ ul.products li.product .added_to_cart:hover {
 	content: "";
 	display: block;
 	margin: 0 auto;
-	max-width: 700px;
+	max-width: 100%;
 	position: relative;
 }
 
@@ -404,6 +404,7 @@ ul.products li.product .added_to_cart:hover {
 
 .single-product div.product .woocommerce-product-gallery {
 	position: relative;
+	max-width: 100%;
 }
 
 .single-product div.product .woocommerce-product-gallery .woocommerce-product-gallery__trigger {