<?php

add_action( 'cloudfw_woocommerce_ordering_before', 'cloudfw_woocommerce_view_switcher' );
function cloudfw_woocommerce_view_switcher(){
	if ( cloudfw_check_onoff( 'woocommerce_views', 'enable' ) ) {
		$current_view = isset( $_COOKIE[ PFIX . '_wc_view' ] ) ? $_COOKIE[ PFIX . '_wc_view' ] : 'grid';
		if ( empty( $current_view ) ) {
			$current_view = 'grid';
		}

		echo '<div class="ui--woocommere-view-switcher ui--custom-menu-bar ui--gradient ui--gradient-grey ui--box clearfix">';
			echo '<ul>';
				echo '<li class="first-item'. ( $current_view == 'grid' ? ' active-item' : '' ) .'"><a href='. esc_url( add_query_arg( array( 'wc_view' => 'grid' ) ) ) .'>'. cloudfw_make_icon( 'FontAwesome/fontawesome-th-large||size:18' ) .'</a></li>';
				echo '<li class="last-item'. ( $current_view == 'list' ? ' active-item' : '' ) .'"><a href='. esc_url( add_query_arg( array( 'wc_view' => 'list' ) ) ) .'>'. cloudfw_make_icon( 'FontAwesome/fontawesome-align-justify||size:18' ) .'</a></li>';
			echo '</ul>';
		echo '</div>';
	}
}