parent
2d99e060a1
commit
12dde04e16
|
@ -198,6 +198,45 @@ function wc_body_class( $classes ) {
|
|||
return array_unique( $classes );
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the classes for the product cat div.
|
||||
*
|
||||
* @since 2.4.0
|
||||
* @param string|array $class One or more classes to add to the class list.
|
||||
* @param object $category object Optional.
|
||||
*/
|
||||
function wc_product_cat_class( $class = '', $category = null ) {
|
||||
// Separates classes with a single space, collates classes for post DIV
|
||||
echo 'class="' . esc_attr( join( ' ', wc_get_product_cat_class( $class, $category ) ) ) . '"';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the classes for the product cat div.
|
||||
*
|
||||
* @since 2.4.0
|
||||
* @param string|array $class One or more classes to add to the class list.
|
||||
* @param object $category object Optional.
|
||||
*/
|
||||
function wc_get_product_cat_class( $class = '', $category = null ) {
|
||||
global $woocommerce_loop;
|
||||
|
||||
$classes = is_array( $class ) ? $class : array_map( 'trim', explode( ' ', $class ) );
|
||||
$classes[] = 'product-category';
|
||||
$classes[] = 'product';
|
||||
|
||||
if ( ( $woocommerce_loop['loop'] - 1 ) % $woocommerce_loop['columns'] == 0 || $woocommerce_loop['columns'] == 1 ) {
|
||||
$classes[] = 'first';
|
||||
}
|
||||
|
||||
if ( $woocommerce_loop['loop'] % $woocommerce_loop['columns'] == 0 ) {
|
||||
$classes[] = 'last';
|
||||
}
|
||||
|
||||
$classes = apply_filters( 'product_cat_class', $classes, $class, $category );
|
||||
|
||||
return array_unique( array_filter( $classes ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds extra post classes for products
|
||||
*
|
||||
|
|
|
@ -140,7 +140,9 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
|
|||
|
||||
* Feature - Show full category hierarchy in permalinks.
|
||||
* Fix - Ensure coupon taxes are reset when calculating totals.
|
||||
* Fix - Improve discount amount rounding.
|
||||
* Tweak - Base discounts on the undiscounted price. #5874
|
||||
* Tweak - Added wc_product_cat_class functions.
|
||||
|
||||
= 2.3.7 - 18/03/2015 =
|
||||
* Fix - Allow saving of empty download expiry date on orders.
|
||||
|
|
|
@ -6,33 +6,29 @@
|
|||
*
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @version 1.6.4
|
||||
* @version 2.4.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
exit;
|
||||
}
|
||||
|
||||
global $woocommerce_loop;
|
||||
|
||||
// Store loop count we're currently on
|
||||
if ( empty( $woocommerce_loop['loop'] ) )
|
||||
if ( empty( $woocommerce_loop['loop'] ) ) {
|
||||
$woocommerce_loop['loop'] = 0;
|
||||
}
|
||||
|
||||
// Store column count for displaying the grid
|
||||
if ( empty( $woocommerce_loop['columns'] ) )
|
||||
if ( empty( $woocommerce_loop['columns'] ) ) {
|
||||
$woocommerce_loop['columns'] = apply_filters( 'loop_shop_columns', 4 );
|
||||
}
|
||||
|
||||
// Increase loop count
|
||||
$woocommerce_loop['loop']++;
|
||||
$woocommerce_loop['loop'] ++;
|
||||
?>
|
||||
<li class="product-category product<?php
|
||||
if ( ( $woocommerce_loop['loop'] - 1 ) % $woocommerce_loop['columns'] == 0 || $woocommerce_loop['columns'] == 1 )
|
||||
echo ' first';
|
||||
if ( $woocommerce_loop['loop'] % $woocommerce_loop['columns'] == 0 )
|
||||
echo ' last';
|
||||
?>">
|
||||
|
||||
<li <?php wc_product_cat_class(); ?>>
|
||||
<?php do_action( 'woocommerce_before_subcategory', $category ); ?>
|
||||
|
||||
<a href="<?php echo get_term_link( $category->slug, 'product_cat' ); ?>">
|
||||
|
@ -65,5 +61,4 @@ $woocommerce_loop['loop']++;
|
|||
</a>
|
||||
|
||||
<?php do_action( 'woocommerce_after_subcategory', $category ); ?>
|
||||
|
||||
</li>
|
||||
|
|
Loading…
Reference in New Issue