|
@@ -89,7 +89,10 @@ add_filter( 'body_class', 'libre_2_woocommerce_active_body_class' );
|
|
|
* @return integer number of products.
|
|
|
*/
|
|
|
function libre_2_woocommerce_products_per_page() {
|
|
|
- return 12;
|
|
|
+ return absint( apply_filters( 'libre_2_woocommerce_products_per_page', 12 ) );
|
|
|
+}
|
|
|
+if ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, '3.3', '<' ) ) {
|
|
|
+ add_filter( 'loop_shop_per_page', 'libre_2_woocommerce_products_per_page' );
|
|
|
}
|
|
|
|
|
|
// Legacy WooCommerce products per page filter.
|
|
@@ -103,7 +106,7 @@ if ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, '3.3', '<' ) ) {
|
|
|
* @return integer number of columns.
|
|
|
*/
|
|
|
function libre_2_woocommerce_thumbnail_columns() {
|
|
|
- return 4;
|
|
|
+ return absint( apply_filters( 'libre_2_woocommerce_product_thumbnail_columns', 4 ) );
|
|
|
}
|
|
|
add_filter( 'woocommerce_product_thumbnails_columns', 'libre_2_woocommerce_thumbnail_columns' );
|
|
|
|
|
@@ -113,7 +116,7 @@ add_filter( 'woocommerce_product_thumbnails_columns', 'libre_2_woocommerce_thumb
|
|
|
* @return integer products per row.
|
|
|
*/
|
|
|
function libre_2_woocommerce_loop_columns() {
|
|
|
- return 3;
|
|
|
+ return absint( apply_filters( 'libre_2_woocommerce_loop_columns', 3 ) );
|
|
|
}
|
|
|
|
|
|
// Legacy WooCommerce columns filter.
|
|
@@ -128,13 +131,11 @@ if ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, '3.3', '<' ) ) {
|
|
|
* @return array $args related products args.
|
|
|
*/
|
|
|
function libre_2_woocommerce_related_products_args( $args ) {
|
|
|
- $defaults = array(
|
|
|
+ $args = apply_filters( 'libre_2_woocommerce_related_products_args', array(
|
|
|
'posts_per_page' => 3,
|
|
|
'columns' => 3,
|
|
|
- );
|
|
|
-
|
|
|
- $args = wp_parse_args( $defaults, $args );
|
|
|
-
|
|
|
+ ) );
|
|
|
+
|
|
|
return $args;
|
|
|
}
|
|
|
add_filter( 'woocommerce_output_related_products_args', 'libre_2_woocommerce_related_products_args' );
|
|
@@ -179,6 +180,32 @@ if ( ! function_exists( 'libre_2_woocommerce_product_columns_wrapper_close' ) )
|
|
|
}
|
|
|
add_action( 'woocommerce_after_shop_loop', 'libre_2_woocommerce_product_columns_wrapper_close', 40 );
|
|
|
|
|
|
+add_action( 'woocommerce_before_shop_loop', 'libre_2_woocommerce_sorting_wrap', 3 );
|
|
|
+
|
|
|
+if ( ! function_exists( 'libre_2_woocommerce_sorting_wrap' ) ) {
|
|
|
+ /**
|
|
|
+ * Sorting wrapper
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ function libre_2_woocommerce_sorting_wrap() {
|
|
|
+ echo '<div class="woocommerce-sorting-wrap">';
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+add_action( 'woocommerce_before_shop_loop', 'libre_2_woocommerce_sorting_wrap_close', 30 );
|
|
|
+
|
|
|
+if ( ! function_exists( 'libre_2_woocommerce_sorting_wrap_close' ) ) {
|
|
|
+ /**
|
|
|
+ * Sorting wrapper close
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ function libre_2_woocommerce_sorting_wrap_close() {
|
|
|
+ echo '</div><!-- END .sorting-wrap -->';
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* Remove default WooCommerce wrapper.
|
|
|
*/
|
|
@@ -307,22 +334,6 @@ function libre_2_woocommerce_is_shop_page() {
|
|
|
return $is_shop_page;
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * Jetpack infinite scroll duplicates posts where orderby is anything other than modified or date
|
|
|
- * This filter offsets the products returned by however many are displayed per page
|
|
|
- *
|
|
|
- * @link https://github.com/Automattic/jetpack/issues/1135
|
|
|
- * @param array $args infinite scroll args.
|
|
|
- * @return array infinite scroll args.
|
|
|
- */
|
|
|
-function libre_2_woocommerce_jetpack_duplicate_products( $args ) {
|
|
|
- if ( ( isset( $args['post_type'] ) && 'product' === $args['post_type'] ) || ( isset( $args['taxonomy'] ) && 'product_cat' === $args['taxonomy'] ) ) {
|
|
|
- $args['offset'] = $args['posts_per_page'] * $args['paged'];
|
|
|
- }
|
|
|
- return $args;
|
|
|
-}
|
|
|
-add_filter( 'infinite_scroll_query_args', 'libre_2_woocommerce_jetpack_duplicate_products', 100 );
|
|
|
-
|
|
|
/**
|
|
|
* Override number of products per page in Jetpack infinite scroll.
|
|
|
*
|