<?php

// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}






function woo_shrk_shop_columns_grid_css() {
	global $shrk_options;

	if ( isset($shrk_options['woo_shop_columns_grid']) && is_array($shrk_options['woo_shop_columns_grid']) ) {
		foreach ($shrk_options['woo_shop_columns_grid'] as $bp_rule) {

			$bp_t     = esc_attr( $bp_rule['opr'] );
			$bp_width = intval( $bp_rule['width'] );
			$cols     = intval( $bp_rule['cols'] );

			switch ($cols) {
				case 1:
					$width='100%';
					break;
				case 2:
					$width='50%';
					break;
				case 3:
					$width='33.33%';
					break;
				case 4:
					$width='25%';
					break;
				case 5:
					$width='20%';
					break;
				case 6:
					$width='16.66%';
					break;
				case 7:
					$width='14.28%';
					break;
				case 8:
					$width='12.5%';
					break;
				case 9:
					$width='11.11%';
					break;
				case 10:
					$width='10%';
					break;
				default:
					$width='10%';
					break;
			}
			
			$css = '
				@media (' . $bp_t . '-width: ' . $bp_width . 'px) { 
					.woocommerce ul.products li.product, .woocommerce-page ul.products li.product,
					.woocommerce .related ul.products li.product, 
					.woocommerce .related ul li.product, 
					.woocommerce .upsells.products ul.products li.product, 
					.woocommerce .upsells.products ul li.product, 
					.woocommerce-page .related ul.products li.product, 
					.woocommerce-page .related ul li.product, 
					.woocommerce-page .upsells.products ul.products li.product, 
					.woocommerce-page .upsells.products ul li.product {
						width: ' . $width . '	
					}
					.woocommerce ul.products li.product:nth-child(1n), 
					.woocommerce-page ul.products li.product:nth-child(1n),
					.woocommerce .related ul.products li.product:nth-child(1n), 
					.woocommerce .related ul li.product:nth-child(1n), 
					.woocommerce .upsells.products ul.products li.product:nth-child(1n), 
					.woocommerce .upsells.products ul li.product:nth-child(1n), 
					.woocommerce-page .related ul.products li.product:nth-child(1n), 
					.woocommerce-page .related ul li.product:nth-child(1n), 
					.woocommerce-page .upsells.products ul.products li.product:nth-child(1n), 
					.woocommerce-page .upsells.products ul li.product:nth-child(1n) {
						clear: none;
					}
					.woocommerce ul.products li.product:nth-child(' . $cols . 'n+1), 
					.woocommerce-page ul.products li.product:nth-child(' . $cols . 'n+1),
					.woocommerce .related ul.products li.product:nth-child(' . $cols . 'n+1), 
					.woocommerce .related ul li.product:nth-child(' . $cols . 'n+1), 
					.woocommerce .upsells.products ul.products li.product:nth-child(' . $cols . 'n+1), 
					.woocommerce .upsells.products ul li.product:nth-child(' . $cols . 'n+1), 
					.woocommerce-page .related ul.products li.product:nth-child(' . $cols . 'n+1), 
					.woocommerce-page .related ul li.product:nth-child(' . $cols . 'n+1), 
					.woocommerce-page .upsells.products ul.products li.product:nth-child(' . $cols . 'n+1), 
					.woocommerce-page .upsells.products ul li.product:nth-child(' . $cols . 'n+1) {
						clear: left;
					}
				}';
			echo shrk_simple_minify( $css );
		}
	}
}