Pārlūkot izejas kodu

Merge pull request #95 from Automattic/87-libre-2-wc-customizer-options-fix

Libre 2: Adds support for the new WC 3.3+ Customizer options
Daniel Dudzic 7 gadi atpakaļ
vecāks
revīzija
83c4451f67
4 mainītis faili ar 107 papildinājumiem un 77 dzēšanām
  1. 0 1
      libre-2/inc/jetpack.php
  2. 36 6
      libre-2/inc/woocommerce.php
  3. 1 1
      libre-2/style.css
  4. 70 69
      libre-2/woocommerce.css

+ 0 - 1
libre-2/inc/jetpack.php

@@ -35,7 +35,6 @@ function libre_2_jetpack_setup() {
 		),
 		'featured-images' => array(
 			'archive'          => true, // enable or not the featured image check for archive pages: true or false
-			'archive-default'  => false, // the default setting of the featured image on archive pages, if it's enabled or not: true or false
 			'post'             => true, // enable or not the featured image check for single posts: true or false
 			'page'             => true, // enable or not the featured image check for single pages: true or false
 			'fallback'         => true,

+ 36 - 6
libre-2/inc/woocommerce.php

@@ -16,10 +16,17 @@
  * @return void
  */
 function libre_2_woocommerce_setup() {
-	add_theme_support( 'woocommerce', array(
-		'thumbnail_image_width' => 823,
+	add_theme_support( 'woocommerce', apply_filters( 'libre_2_woocommerce_args', array(
 		'single_image_width'    => 823,
-	) );
+		'thumbnail_image_width' => 450,
+		'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' );
@@ -84,7 +91,11 @@ add_filter( 'body_class', 'libre_2_woocommerce_active_body_class' );
 function libre_2_woocommerce_products_per_page() {
 	return 12;
 }
-add_filter( 'loop_shop_per_page', 'libre_2_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', 'libre_2_woocommerce_products_per_page' );
+}
 
 /**
  * Product gallery thumnbail columns.
@@ -104,7 +115,11 @@ add_filter( 'woocommerce_product_thumbnails_columns', 'libre_2_woocommerce_thumb
 function libre_2_woocommerce_loop_columns() {
 	return 3;
 }
-add_filter( 'loop_shop_columns', 'libre_2_woocommerce_loop_columns' );
+
+// Legacy WooCommerce columns filter.
+if ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, '3.3', '<' ) ) {
+	add_filter( 'loop_shop_columns', 'libre_2_woocommerce_loop_columns' );
+}
 
 /**
  * Related Products Args.
@@ -131,12 +146,27 @@ if ( ! function_exists( 'libre_2_woocommerce_product_columns_wrapper' ) ) {
 	 * @return  void
 	 */
 	function libre_2_woocommerce_product_columns_wrapper() {
-		$columns = libre_2_woocommerce_loop_columns();
+		$columns = libre_2_loop_columns();
 		echo '<div class="columns-' . absint( $columns ) . '">';
 	}
 }
 add_action( 'woocommerce_before_shop_loop', 'libre_2_woocommerce_product_columns_wrapper', 40 );
 
+if ( ! function_exists( 'libre_2_loop_columns' ) ) {
+	/**
+	 * Default loop columns on product archives
+	 *
+	 * @return integer products per row
+	 */
+	function libre_2_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( 'libre_2_loop_columns', $columns );
+	}
+}
+
 if ( ! function_exists( 'libre_2_woocommerce_product_columns_wrapper_close' ) ) {
 	/**
 	 * Product columns wrapper close.

+ 1 - 1
libre-2/style.css

@@ -4,7 +4,7 @@ Theme URI: http://wordpress.com/themes/libre-2/
 Author: Automattic
 Author URI: http://wordpress.com/themes/
 Description: A stylish, classic look for your personal blog or long-form writing site. The main navigation bar stays fixed to the top while your visitors read, keeping your most important content at hand, while three footer widget areas give your secondary content a comfortable home.
-Version: 2.2.1-wpcom
+Version: 2.2.2-wpcom
 License: GNU General Public License v2 or later
 License URI: http://www.gnu.org/licenses/gpl-2.0.html
 Text Domain: libre

+ 70 - 69
libre-2/woocommerce.css

@@ -16,7 +16,7 @@ WooCommerce styles override
 {
 	font-family: 'star';
 	font-weight: normal;
-	font-style: normal; 
+	font-style: normal;
 
 	src: url('../../plugins/woocommerce/assets/fonts/star.eot');
 	src: url('../../plugins/woocommerce/assets/fonts/star.eot?#iefix') format('embedded-opentype'), url('../../plugins/woocommerce/assets/fonts/star.woff') format('woff'), url('../../plugins/woocommerce/assets/fonts/star.ttf') format('truetype'), url('../../plugins/woocommerce/assets/fonts/star.svg#star') format('svg');
@@ -43,7 +43,7 @@ table.shop_table_responsive tr td
 {
 	border-bottom: 1px solid #ddd;
 	display: block;
-	clear: both; 
+	clear: both;
 
 	padding: .4em .8em;
 
@@ -51,7 +51,7 @@ table.shop_table_responsive tr td
 }
 table.shop_table_responsive tr td:before
 {
-	float: left; 
+	float: left;
 
 	content: attr(data-title) ': ';
 }
@@ -92,7 +92,7 @@ table.shop_table
 	margin: 0 0 1.75em;
 
 	table-layout: auto;
-	border-spacing: 0; 
+	border-spacing: 0;
 	border-collapse: separate;
 
 	text-align: left;
@@ -144,7 +144,7 @@ table.cart .product-remove a
 }
 table.cart .product-remove a:hover
 {
-	color: #fff; 
+	color: #fff;
 	background: red;
 }
 
@@ -280,7 +280,7 @@ ul.products
 ul.products:before,
 ul.products:after
 {
-	display: table; 
+	display: table;
 
 	content: '';
 }
@@ -292,7 +292,7 @@ ul.products li.product
 {
 	position: relative;
 
-	margin-bottom: 2em; 
+	margin-bottom: 2em;
 
 	list-style: none;
 }
@@ -413,7 +413,7 @@ ul.products li.product:hover {
 ul.products:before,
 ul.products:after
 {
-	display: table; 
+	display: table;
 
 	content: '';
 }
@@ -434,7 +434,7 @@ ul.products li.product img
 ul.products li.product .woocommerce-loop-product__title
 {
 	font-size: 18px;
-	font-size: 1rem; 
+	font-size: 1rem;
 
 	margin: 0;
 	padding: .5em 0;
@@ -492,7 +492,7 @@ ul.products li.product .added_to_cart
 .single-product div.product:before,
 .single-product div.product:after
 {
-	display: table; 
+	display: table;
 
 	content: '';
 }
@@ -511,7 +511,7 @@ ul.products li.product .added_to_cart
 .single-product div.product .woocommerce-product-gallery .woocommerce-product-gallery__trigger
 {
 	position: absolute;
-	z-index: 99; 
+	z-index: 99;
 	right: 0;
 
 	display: block;
@@ -532,14 +532,15 @@ ul.products li.product .added_to_cart
 	content: '\f402';
 
 	color: #fff;
-	border-radius: 100%; 
+	border-radius: 100%;
 	background: #000;
 }
 .single-product div.product .woocommerce-product-gallery .woocommerce-product-gallery__trigger img
 {
 	display: none !important;
 }
-.single-product div.product .woocommerce-product-gallery .flex-viewport
+.single-product div.product .woocommerce-product-gallery .flex-viewport,
+.single-product div.product .woocommerce-product-gallery .woocommerce-product-gallery__image--placeholder
 {
 	margin-bottom: 1em;
 }
@@ -551,7 +552,7 @@ ul.products li.product .added_to_cart
 .single-product div.product .woocommerce-product-gallery .flex-control-thumbs:before,
 .single-product div.product .woocommerce-product-gallery .flex-control-thumbs:after
 {
-	display: table; 
+	display: table;
 
 	content: '';
 }
@@ -563,7 +564,7 @@ ul.products li.product .added_to_cart
 {
 	float: left;
 
-	margin-bottom: 3.8%; 
+	margin-bottom: 3.8%;
 
 	list-style: none;
 
@@ -676,13 +677,13 @@ ul.products li.product .added_to_cart
 }
 .single-product div.product form.cart .variations td
 {
-	vertical-align: top; 
+	vertical-align: top;
 
 	border: 0;
 }
 .single-product div.product form.cart .variations td.label
 {
-	padding-top: .375em; 
+	padding-top: .375em;
 	padding-bottom: .375em;
 	width: 60px;
 }
@@ -751,7 +752,7 @@ ul.products li.product .added_to_cart
 .single-product div.product .woocommerce-tabs .woocommerce-Tabs-panel
 {
 	margin: -1px 0 1.75em;
-	padding: 1.75em 1.75em 0; 
+	padding: 1.75em 1.75em 0;
 
 	border: 1px solid #f3f3f3;
 }
@@ -789,7 +790,7 @@ ul.products li.product .added_to_cart
 #reviews #comments ol.commentlist:before,
 #reviews #comments ol.commentlist:after
 {
-	display: table; 
+	display: table;
 
 	content: '';
 }
@@ -806,7 +807,7 @@ ul.products li.product .added_to_cart
 #reviews #comments ol.commentlist li:before,
 #reviews #comments ol.commentlist li:after
 {
-	display: table; 
+	display: table;
 
 	content: '';
 }
@@ -839,7 +840,7 @@ ul.products li.product .added_to_cart
 #reviews #comments ol.commentlist li .comment-text
 {
 	margin: 0 0 0 70px;
-	padding: 1em 1em 0; 
+	padding: 1em 1em 0;
 
 	border: 1px solid #f3f3f3;
 	border-radius: 4px;
@@ -963,7 +964,7 @@ ul.products li.product .added_to_cart
 
 	display: inline-block;
 
-	margin-left: .5rem; 
+	margin-left: .5rem;
 
 	content: '\f420';
 	vertical-align: bottom;
@@ -996,7 +997,7 @@ ul.products li.product .added_to_cart
 
 	list-style: none;
 
-	border-width: 1px 1px 0 1px; 
+	border-width: 1px 1px 0 1px;
 	border-style: solid;
 	border-color: #f3f3f3;
 }
@@ -1028,7 +1029,7 @@ ul.products li.product .added_to_cart
 	line-height: 1.40625;
 
 	margin: .703125rem 0;
-	padding: .703125rem; 
+	padding: .703125rem;
 
 	background: #f3f3f3;
 }
@@ -1045,7 +1046,7 @@ ul.products li.product .added_to_cart
 .woocommerce #payment .form-row:before,
 .woocommerce #payment .form-row:after
 {
-	display: table; 
+	display: table;
 
 	content: '';
 }
@@ -1101,7 +1102,7 @@ ul#shipping_method
  */
 .widget.woocommerce ul
 {
-	margin-left: 0; 
+	margin-left: 0;
 
 	list-style: none;
 }
@@ -1113,7 +1114,7 @@ ul#shipping_method
 .widget.woocommerce ul.product_list_widget:before,
 .widget.woocommerce ul.product_list_widget:after
 {
-	display: table; 
+	display: table;
 
 	content: '';
 }
@@ -1123,7 +1124,7 @@ ul#shipping_method
 }
 .widget.woocommerce ul.product_list_widget li
 {
-	padding: .875em 0; 
+	padding: .875em 0;
 
 	border-top: 1px solid #f3f3f3;
 }
@@ -1133,7 +1134,7 @@ ul#shipping_method
 }
 .widget.woocommerce ul.product_list_widget li img
 {
-	float: right; 
+	float: right;
 
 	max-width: 2.617924em;
 }
@@ -1146,7 +1147,7 @@ ul#shipping_method
 
 	width: 1em;
 	height: 1em;
-	margin: 1rem; 
+	margin: 1rem;
 
 	text-align: center;
 
@@ -1189,14 +1190,14 @@ ul#shipping_method
 }
 .widget_product_categories ul li
 {
-	padding: .875em 0; 
+	padding: .875em 0;
 
 	border-top: 1px solid #f3f3f3;
 }
 
 .widget_product_categories .children
 {
-	margin-top: .703125em; 
+	margin-top: .703125em;
 	margin-right: 0;
 	margin-bottom: -.703125em;
 	margin-left: 0;
@@ -1211,7 +1212,7 @@ ul#shipping_method
 .widget_rating_filter ul li:before,
 .widget_rating_filter ul li:after
 {
-	display: table; 
+	display: table;
 
 	content: '';
 }
@@ -1265,7 +1266,7 @@ ul#shipping_method
 	width: 1em;
 	height: 1em;
 	margin-top: -.25em;
-	margin-left: -1px; 
+	margin-left: -1px;
 
 	cursor: ew-resize;
 
@@ -1310,12 +1311,12 @@ ul#shipping_method
 {
 	.widget.woocommerce ul li
 	{
-		padding-top: .703125em; 
+		padding-top: .703125em;
 		padding-bottom: .703125em;
 	}
 	.widget_product_categories ul li
 	{
-		padding-top: .703125em; 
+		padding-top: .703125em;
 		padding-bottom: .703125em;
 	}
 }
@@ -1354,7 +1355,7 @@ ul#shipping_method
 .site-header-cart:before,
 .site-header-cart:after
 {
-	display: table; 
+	display: table;
 
 	content: '';
 }
@@ -1372,7 +1373,7 @@ ul#shipping_method
 
 	padding: .25em 0;
 
-	text-decoration: none; 
+	text-decoration: none;
 
 	color: #2c313f;
 }
@@ -1389,7 +1390,7 @@ ul#shipping_method
 .site-header-cart .cart-contents:before
 {
 	font-family: Genericons;
-	line-height: 2.2; 
+	line-height: 2.2;
 
 	display: inline-block;
 
@@ -1466,7 +1467,7 @@ ul#shipping_method
 
 	width: 1.5rem;
 	height: 1.5rem;
-	margin: 0 .25rem .25rem 0; 
+	margin: 0 .25rem .25rem 0;
 
 	text-align: center;
 
@@ -1497,7 +1498,7 @@ ul#shipping_method
 {
 	float: right;
 
-	width: 100%; 
+	width: 100%;
 	margin: 0 0 1.75em;
 }
 .woocommerce-ordering select
@@ -1561,7 +1562,7 @@ ul#shipping_method
 	font-size: 1rem;
 
 	position: absolute;
-	z-index: 2; 
+	z-index: 2;
 	top: 0;
 	right: auto;
 	left: 0;
@@ -1579,7 +1580,7 @@ ul#shipping_method
 {
 	font-family: 'star';
 	font-size: 1em;
-	font-weight: 400; 
+	font-weight: 400;
 	line-height: 1.618;
 
 	position: relative;
@@ -1591,7 +1592,7 @@ ul#shipping_method
 }
 .star-rating:before
 {
-	position: absolute; 
+	position: absolute;
 	top: 0;
 	left: 0;
 
@@ -1625,7 +1626,7 @@ ul#shipping_method
 
 p.stars a
 {
-	font-weight: 400; 
+	font-weight: 400;
 
 	position: relative;
 
@@ -1655,14 +1656,14 @@ p.stars a:before
 	content: '\53';
 	text-indent: 0;
 
-	opacity: .25; 
+	opacity: .25;
 	color: #404040;
 }
 p.stars a:hover ~ a:before
 {
 	content: '\53';
 
-	opacity: .25; 
+	opacity: .25;
 	color: #404040;
 }
 
@@ -1670,7 +1671,7 @@ p.stars:hover a:before
 {
 	content: '\53';
 
-	opacity: 1; 
+	opacity: 1;
 	color: #000;
 }
 
@@ -1678,7 +1679,7 @@ p.stars.selected a.active:before
 {
 	content: '\53';
 
-	opacity: 1; 
+	opacity: 1;
 	color: #000;
 }
 
@@ -1686,7 +1687,7 @@ p.stars.selected a.active ~ a:before
 {
 	content: '\53';
 
-	opacity: .25; 
+	opacity: .25;
 	color: #404040;
 }
 
@@ -1694,7 +1695,7 @@ p.stars.selected a:not(.active):before
 {
 	content: '\53';
 
-	opacity: 1; 
+	opacity: 1;
 	color: #000;
 }
 
@@ -1712,7 +1713,7 @@ p.stars.selected a:not(.active):before
 }
 .woocommerce-tabs ul.tabs li
 {
-	position: relative; 
+	position: relative;
 
 	display: block;
 
@@ -1720,14 +1721,14 @@ p.stars.selected a:not(.active):before
 }
 .woocommerce-tabs ul.tabs li a
 {
-	display: block; 
+	display: block;
 
 	padding: 1em 0;
 }
 
 .woocommerce-tabs .panel h2:first-of-type
 {
-	font-size: 1em; 
+	font-size: 1em;
 
 	margin-bottom: 1em;
 }
@@ -1836,7 +1837,7 @@ p.stars.selected a:not(.active):before
 
 .required
 {
-	text-decoration: none; 
+	text-decoration: none;
 
 	color: red;
 }
@@ -1874,7 +1875,7 @@ p.no-comments
 	margin-left: 0;
 	padding: 1.75em 2em 1.75em 4em;
 
-	list-style: none; 
+	list-style: none;
 
 	color: inherit;
 	border: 2px solid #8fae1b;
@@ -1891,7 +1892,7 @@ p.no-comments
 p.no-comments:before,
 p.no-comments:after
 {
-	display: table; 
+	display: table;
 
 	content: '';
 }
@@ -1911,7 +1912,7 @@ p.no-comments .button
 {
 	float: right;
 
-	margin-left: 1em; 
+	margin-left: 1em;
 	padding: .1667em .6668em;
 }
 .woocommerce-message:before,
@@ -1972,7 +1973,7 @@ p.no-comments:before
 .demo_store
 {
 	position: fixed;
-	z-index: 9999; 
+	z-index: 9999;
 	right: 0;
 	bottom: 0;
 	left: 0;
@@ -2021,7 +2022,7 @@ input[type='submit']:disabled,
 .added_to_cart.disabled,
 .added_to_cart:disabled
 {
-	cursor: not-allowed; 
+	cursor: not-allowed;
 
 	opacity: .5;
 }
@@ -2086,14 +2087,14 @@ p.price
 {
 	display: block;
 
-	margin-bottom: .875em; 
+	margin-bottom: .875em;
 
 	color: #000;
 }
 span.price del,
 p.price del
 {
-	display: inline-block; 
+	display: inline-block;
 
 	opacity: .5;
 	color: inherit;
@@ -2101,7 +2102,7 @@ p.price del
 span.price ins,
 p.price ins
 {
-	font-weight: 700; 
+	font-weight: 700;
 
 	padding: 0;
 
@@ -2114,7 +2115,7 @@ p.price ins
  */
 .woocommerce-form-login input[name='rememberme']
 {
-	margin-right: .25em; 
+	margin-right: .25em;
 	margin-left: .65em;
 }
 
@@ -2166,7 +2167,7 @@ p.price ins
 	}
 	.site-header-cart .cart-contents
 	{
-		font-weight: bold; 
+		font-weight: bold;
 
 		padding: .25em 0;
 
@@ -2185,7 +2186,7 @@ p.price ins
 	.site-header-cart .cart-contents:before
 	{
 		font-family: Genericons;
-		line-height: 2.2; 
+		line-height: 2.2;
 
 		display: inline-block;
 
@@ -2205,7 +2206,7 @@ p.price ins
 		margin: 0;
 		padding: 0;
 
-		text-align: left; 
+		text-align: left;
 
 		border-radius: .35rem;
 		background: #fff;
@@ -2264,7 +2265,7 @@ p.price ins
 	}
 	.site-header-cart .widget_shopping_cart .woocommerce-mini-cart__buttons .button.checkout
 	{
-		margin-bottom: 0; 
+		margin-bottom: 0;
 		margin-left: 0;
 	}
 	.site-header-cart:hover .widget_shopping_cart,
@@ -2289,7 +2290,7 @@ p.price ins
 	{
 		line-height: 1.875em;
 
-		width: 1.875em; 
+		width: 1.875em;
 		height: 1.875em;
 		margin-right: .3125em;
 		margin-bottom: .3125em;