<?php
/**
 * Add wrapper for jpanelmenu
 */

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

add_action( 'wp_footer', 'shrk_get_sidepanel_menu', 12 );





function shrk_get_sidepanel_menu() {
	global $shrk_options, $woocommerce;
	?>
	<div id="left-side-panel" class="side-panel-menu left">
		<div class="side-panel-widgets">
		<?php do_action( 'before_sidebar' ); ?>
		<?php if ( is_active_sidebar( 'sidepanel-left' ) ) : ?>
		
			<?php dynamic_sidebar( 'sidepanel-left' ); ?>
		
		<?php else: ?>
			<div class="side-panel-header clearfix">
				<?php if ( !empty( $shrk_options['sidepanel_left_logo']['url'] ) ) : ?>
					<a class="navbar-brand" href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">
						<img class='main-logo' src='<?php echo esc_url( $shrk_options['sidepanel_left_logo']['url'] ); ?>' alt='<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>' />
					</a>
				<?php endif; ?>
			</div>

			<div id="sidepanel-search-form-holder"></div>

			<?php wp_nav_menu(
				array(
					'theme_location'  => 'primary',
					'container_class' => 'main-menu clearfix',
					'menu_class'      => 'nav',
					'fallback_cb'     => 'shrk_fallback_menu',
					'menu_id'         => 'sidepanel-main-menu',
					'walker'          => shrk_get_menu_walker()
				)
			); ?>


			<?php wp_nav_menu(
				array(
					'theme_location'  => 'topbar-nav',
					'container_class' => 'secondary-menu clearfix',
					'menu_class'      => 'nav',
					'fallback_cb'     => 'shrk_no_menu_no_output',
					'menu_id'         => 'sidepanel-topbar',
					'walker'          => shrk_get_menu_walker()
				)
			); ?>
		<?php endif; ?>
		</div>
	</div>

	<?php if ( isset($shrk_options['woo_cart_display']) && ( $shrk_options['woo_cart_display'] == 'auto' || $shrk_options['woo_cart_display'] == 'side' ) ) { ?>
	<div id="right-side-panel" class="side-panel-menu right">
		<i class="close-side-panel ion-android-close ion"></i>
		<div class="side-panel-widgets">
		<?php do_action( 'before_sidebar' ); ?>
		<?php if ( is_active_sidebar( 'sidepanel-right' ) ) : ?>
		
			<?php dynamic_sidebar( 'sidepanel-right' ); ?>
		
		<?php elseif ( function_exists('WC') ) : ?>
			<?php the_widget( 'WC_Widget_Cart' ); ?> 
			<?php 
				if ( function_exists('woocommerce_cross_sell_display') ) {
					woocommerce_cross_sell_display(); 		
				}
			?>
		<?php endif; ?>
		</div>
	</div>
	<?php } ?>

	<div class="content-dim-overlay"></div>
	<?php
}

?>