Browse Source

Independent Publisher 2: Adds support for the 3.3+ new Customizer options (See #87)

Danny Dudzic 7 years ago
parent
commit
5ce51e9d4d

+ 36 - 6
independent-publisher-2/inc/woocommerce.php

@@ -16,10 +16,17 @@
  * @return void
  * @return void
  */
  */
 function ip_woocommerce_setup() {
 function ip_woocommerce_setup() {
-	add_theme_support( 'woocommerce', array(
-		'thumbnail_image_width' => 704,
+	add_theme_support( 'woocommerce', apply_filters( 'radcliffe_2_woocommerce_args', array(
 		'single_image_width'    => 740,
 		'single_image_width'    => 740,
-	) );
+		'thumbnail_image_width' => 370,
+		'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-zoom' );
 	add_theme_support( 'wc-product-gallery-lightbox' );
 	add_theme_support( 'wc-product-gallery-lightbox' );
 	add_theme_support( 'wc-product-gallery-slider' );
 	add_theme_support( 'wc-product-gallery-slider' );
@@ -87,7 +94,11 @@ add_filter( 'body_class', 'ip_woocommerce_active_body_class' );
 function ip_woocommerce_products_per_page() {
 function ip_woocommerce_products_per_page() {
 	return 12;
 	return 12;
 }
 }
-add_filter( 'loop_shop_per_page', 'ip_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', 'ip_woocommerce_products_per_page' );
+}
 
 
 /**
 /**
  * Product gallery thumnbail columns.
  * Product gallery thumnbail columns.
@@ -107,7 +118,11 @@ add_filter( 'woocommerce_product_thumbnails_columns', 'ip_woocommerce_thumbnail_
 function ip_woocommerce_loop_columns() {
 function ip_woocommerce_loop_columns() {
 	return 3;
 	return 3;
 }
 }
-add_filter( 'loop_shop_columns', 'ip_woocommerce_loop_columns' );
+
+// Legacy WooCommerce columns filter.
+if ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, '3.3', '<' ) ) {
+	add_filter( 'loop_shop_columns', 'ip_woocommerce_loop_columns' );
+}
 
 
 /**
 /**
  * Related Products Args.
  * Related Products Args.
@@ -134,12 +149,27 @@ if ( ! function_exists( 'ip_woocommerce_product_columns_wrapper' ) ) {
 	 * @return  void
 	 * @return  void
 	 */
 	 */
 	function ip_woocommerce_product_columns_wrapper() {
 	function ip_woocommerce_product_columns_wrapper() {
-		$columns = ip_woocommerce_loop_columns();
+		$columns = ip_loop_columns();
 		echo '<div class="columns-' . absint( $columns ) . '">';
 		echo '<div class="columns-' . absint( $columns ) . '">';
 	}
 	}
 }
 }
 add_action( 'woocommerce_before_shop_loop', 'ip_woocommerce_product_columns_wrapper', 40 );
 add_action( 'woocommerce_before_shop_loop', 'ip_woocommerce_product_columns_wrapper', 40 );
 
 
+if ( ! function_exists( 'ip_loop_columns' ) ) {
+	/**
+	 * Default loop columns on product archives
+	 *
+	 * @return integer products per row
+	 */
+	function ip_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( 'ip_loop_columns', $columns );
+	}
+}
+
 if ( ! function_exists( 'ip_woocommerce_product_columns_wrapper_close' ) ) {
 if ( ! function_exists( 'ip_woocommerce_product_columns_wrapper_close' ) ) {
 	/**
 	/**
 	 * Product columns wrapper close.
 	 * Product columns wrapper close.

+ 3 - 1
independent-publisher-2/woocommerce-rtl.css

@@ -198,7 +198,9 @@ ul.products {
     ul.products li.product .star-rating {
     ul.products li.product .star-rating {
       margin-bottom: .8em; }
       margin-bottom: .8em; }
     ul.products li.product img {
     ul.products li.product img {
-      display: block; }
+      display: block;
+      margin-right: 0;
+      margin-left: 0; }
     ul.products li.product .button {
     ul.products li.product .button {
       padding: 0.8em; }
       padding: 0.8em; }
       ul.products li.product .button:before, ul.products li.product .button:after {
       ul.products li.product .button:before, ul.products li.product .button:after {

+ 3 - 1
independent-publisher-2/woocommerce.css

@@ -198,7 +198,9 @@ ul.products {
     ul.products li.product .star-rating {
     ul.products li.product .star-rating {
       margin-bottom: .8em; }
       margin-bottom: .8em; }
     ul.products li.product img {
     ul.products li.product img {
-      display: block; }
+      display: block;
+      margin-right: 0;
+      margin-left: 0; }
     ul.products li.product .button {
     ul.products li.product .button {
       padding: 0.8em; }
       padding: 0.8em; }
       ul.products li.product .button:before, ul.products li.product .button:after {
       ul.products li.product .button:before, ul.products li.product .button:after {