<?php
/**
 * education functions and definitions
 *
 * @package Netbase
 */

/**
 * Define theme constants
 */
 
 if( !function_exists('nbfoody_default_options') ){
	function nbfoody_default_options()
	{
		return array(
			'nbcore_blog_archive_layout' => 'classic',
			'nbcore_blog_sidebar' => 'right-sidebar',
			'nbcore_excerpt_only' => true,
			'nbcore_excerpt_length' => '35',
			'nbcore_blog_single_sidebar' => 'right-sidebar',
			'nbcore_color_scheme' => 'scheme_1',
			'nbcore_primary_color' => '#73a802',
			'nbcore_secondary_color' => '#e5ebad',
			'nbcore_tertiary_color' => 'rgba(115, 168, 2, 0.3)',
			'nbcore_background_color' => '#ffffff',
			'nbcore_inner_background' => '#edf0f5',
			'nbcore_heading_color' => '#73a802',
			'nbcore_body_color' => '#888888',
			'nbcore_meta_color' => '#999999',
			'nbcore_link_color' => '#000000',
			'nbcore_link_hover_color' => '#444444',
			'nbcore_divider_color' => '#d7d7d7',
			'nbcore_header_style' => 'mid-stack-2',
			'nbcore_logo_upload' => '',
			'nbcore_logo_width' => '140',
			'nbcore_menu_resp' => '992',
			'nbcore_header_fixed' => false,
			'header_bgcolor' => '#ffffff',
			'nbcore_blog_width' => '70',
			'nbcore_blog_meta_date' => true,
			'nbcore_blog_meta_read_time' => true,
			'nbcore_blog_meta_author' => true,
			'nbcore_blog_meta_category' => true,
			'nbcore_blog_meta_tag' => true,
			'nbcore_blog_sticky_sidebar' => false,
			'nbcore_blog_meta_align' => 'center',
			'show_title_section' => true,
			'nbcore_page_title_image' => '',
			'nbcore_page_title_image_size' => 'auto',
			'nbcore_page_title_image_pos' => 'center',
			'nbcore_page_title_image_repeat' => 'repeat',
			'nbcore_page_title_padding' => '75',
			'nbcore_page_title_color' => '#323232',
			'body_font_family' => 'google,Open Sans',
			'body_font_style' => '400',
			'body_font_size' => '14',
			'heading_font_family' => 'google,Oswald',
			'heading_font_style' => '400',
			'heading_base_size' => '14',
			'subset_cyrillic' => false,
			'subset_greek' => false,
			'subset_vietnamese' => false,
			'nbcore_wc_breadcrumb' => true,
			'nbcore_wc_content_width' => '70',
			'nbcore_pa_swatch_style' => '',
			'nbcore_wc_attr' => false,
			'nbcore_shop_title' => esc_html__('Shop', 'nb-foody'),
			'nbcore_shop_action' => true,
			'nbcore_shop_sidebar' => 'right-sidebar',
            'nbcore_loop_columns' => 'three-columns',
			'nbcore_loop_columns_xl' => '2',
            'nbcore_loop_columns_lg' => '2',
            'nbcore_loop_columns_md' => '2',
            'nbcore_loop_columns_sm' => '1',
			'nbcore_products_per_page' => '12',
			'nbcore_product_list' => 'menu',
			'nbcore_shop_content_width' => '70',
			'nbcore_grid_product_description' => true,
			'nbcore_grid_product_description_limit'=>'15',
			'nbcore_pd_details_title' => true,
			'nbcore_pd_details_width' => '70',
			'nbcore_pd_details_sidebar' => 'right-sidebar',
			'nbcore_wc_sale' => 'style-1',
			'nbcore_pd_images_width' => '50',
			'nbcore_pd_thumb_pos' => 'bottom-thumb',
			'nbcore_pd_meta_layout' => 'left-images',
			'nbcore_pd_featured_autoplay' => false,
			'nbcore_info_style' => 'accordion-tabs',
			'nbcore_reviews_form' => 'full-width',
			'nbcore_reviews_round_avatar' => true,
			'nbcore_add_cart_style' => 'style-1',
			'nbcore_pd_show_social' => true,
			'nbcore_show_related' => true,
			'nbcore_pd_related_columns' => '2',
			'nbcore_show_upsells' => false,
			'nbcore_pd_upsells_columns' => '2',
			'nbcore_pb_background' => '#73a802',
			'nbcore_pb_background_hover' => '#73a601',
			'nbcore_pb_text' => '#ffffff',
			'nbcore_pb_text_hover' => '#ffffff',
			'nbcore_pb_border' => '#73a802',
			'nbcore_pb_border_hover' => '#73a601',
			'nbcore_sb_background' => 'transparent',
			'nbcore_sb_background_hover' => '#1e88e5',
			'nbcore_sb_text' => '#1e88e5',
			'nbcore_sb_text_hover' => '#ffffff',
			'nbcore_sb_border' => '#1e88e5',
			'nbcore_sb_border_hover' => '#1e88e5',
			'nbcore_tb_background' => 'rgba(255, 255, 255, 0.85)',
            'nbcore_tb_background_hover' => 'rgba(115, 168, 2, 0.85)',
            'nbcore_tb_text' => '#444444',
            'nbcore_tb_text_hover' => '#ffffff',
            'nbcore_tb_border' => 'rgba(255, 255, 255, 0.85)',
            'nbcore_tb_border_hover' => 'rgba(115, 168, 2, 0.85)',
			'nbcore_button_padding' => '30',
			'nbcore_button_border_radius' => '0',
			'nbcore_button_border_width' => '2',
			'nbcore_cart_layout' => 'cart-layout-2',
			'nbcore_show_cross_sells' => true,
			'nbcore_cross_sells_per_row' => '4',
			'nbcore_cross_sells_limit' => '6',
			'home_page_title_section' => false,
			'nbcore_footer_bg_img' => '',
			'nbcore_footer_bg_size' => 'auto',
			'nbcore_footer_bg_pos' => 'center',
			'nbcore_footer_bg_repeat' => 'repeat',
			'nbcore_show_footer_top' => false,
			'nbcore_footer_top_layout' => 'layout-9',
			'nbcore_footer_top_color' => '#cccccc',
			'nbcore_footer_top_hover_color' => '#73a802',
			'nbcore_footer_top_bg' => '#333333',
			'nbcore_footer_top_bor' => '#999999',
			'nbcore_show_footer_bot' => false,
			'nbcore_footer_bot_layout' => 'layout-9',
			'nbcore_footer_bot_color' => '#cccccc',
			'nbcore_footer_bot_hover_color' => '#73a802',
			'nbcore_footer_bot_bg' => '#333333',
			'nbcore_footer_bot_bor' => '#e6e6e6',
			'nbcore_footer_abs_color' => '#cccccc',
			'nbcore_footer_abs_hover_color' => '#73a802',
			'nbcore_footer_abs_bg' => '#333333',
			'nbcore_footer_abs_bor' => '#555555',
            'nbcore_footer_abs_padding' => '10',
			'nbcore_top_section_padding' => '10',
			'nbcore_middle_section_padding' => '20',
			'nbcore_bot_section_padding' => '30',
			'nbcore_header_top_bg' => '#282725',
			'nbcore_header_top_color' => '#e4e4e4',
			'nbcore_header_middle_bg' => '#ffffff',
			'nbcore_header_middle_color' => '#646464',
			'nbcore_header_middle_hover_color' => '#73a802',
			'nbcore_header_bot_bg' => '#fff',
			'nbcore_header_bot_color' => '#646464',
			'nbcore_header_bot_hover_color' => '#73a802',
			'nbcore_footer_top_heading' => '#999999',
			'nbcore_footer_bot_heading' => '#323232',
			'nbcore_blog_archive_comments' => true,
			'nbcore_blog_archive_summary' => true,
			'nbcore_blog_archive_post_style' => 'style-1',
			'nbcore_blog_single_title_position' => 'position-1',
			'nbcore_blog_single_show_thumb' => true,
			'nbcore_blog_single_title_size' => '50',
			'nbcore_blog_single_show_social' => true,
			'nbcore_blog_single_show_author' => true,
			'nbcore_blog_single_show_nav' => true,
			'nbcore_blog_single_show_comments' => true,
			'nbcore_page_title_size' => '50',
			'share_buttons_style' => 'style-1',
			'share_buttons_position' => 'inside-content',
			'pagination_style' => 'style-1',
			'show_back_top' => true,
			'back_top_shape' => 'square',
			'back_top_style' => 'light',
			'shop_sticky_sidebar' => false,
			'product_sticky_sidebar' => false,
			//meta
			'page_thumb' => 'no-thumb',
			'page_sidebar' => 'full-width',
			'page_content_width' => '70',
			'nbcore_blog_masonry_columns' => '2',
			'product_category_wishlist' => false,
            'product_category_quickview' => false,
            'nbcore_storelist_loop_columns_xl' => '3',
            'nbcore_storelist_loop_columns_lg' => '3',
            'nbcore_storelist_loop_columns_md' => '2',
            'nbcore_storelist_loop_columns_sm' => '2',
            'nbcore_vendors_per_page' => '9',
            'nbcore_vendors_list' => 'style-2',
            'nbcore_vendor_details_sidebar' => 'left-sidebar',
            'nbcore_vendor_details_width' => '75',
            'nbcore_vendor_sticky_sidebar' => false,
            'nbcore_vendor_loop_columns_xl' => '3',
            'nbcore_vendor_loop_columns_lg' => '3',
            'nbcore_vendor_loop_columns_md' => '2',
            'nbcore_vendor_loop_columns_sm' => '2',
			'nbcore_vendor_per_page' => '9',
			'nbcore_vendor_map_height' => '200',
			'nbcore_mp_loop_columns_xl' => '4',
			'nbcore_mp_loop_columns_lg' => '4',
			'nbcore_mp_loop_columns_md' => '3',
			'nbcore_mp_loop_columns_sm' => '2',
            'nbcore_dashboard_sidebar' => 'left-sidebar',
            'nbcore_dashboard_width' => '75',
            'nbcore_dashboard_style' => false,
            'nbcore_reviews_style' => 'default',
            'nbcore_page_title_image_attachment' => true,
            'nbcore_footer_bg_attachment' => true,
            'nbcore_product_addtocart' => true,
            'nbcore_header_top_hover_color'=>'',
            'nbcore_header_mainmn_bg'=>'',
            'nbcore_header_mainmn_color'=>'',
            'nbcore_header_mainmn_bor'=>'',
            'nbcore_header_mainmnhover_bg'=>'',
            'nbcore_header_mainmnhover_color'=>'',
            'nbcore_header_mainmnhover_bor'=>'',
            'nbcore_footer_bg_color'=>'',
            'nbcore_header_text_section'=>'',
            'nbcore_header_facebook'=>'',
            'nbcore_header_twitter'=>'',
            'nbcore_header_linkedin'=>'',
            'nbcore_header_instagram'=>'',
            'nbcore_header_blog'=>'',
            'nbcore_header_pinterest'=>'',
            'nbcore_header_ggplus'=>'',
            'nbcore_footer_abs_left_content'=>'',
            'nbcore_footer_abs_right_content'=>'',
            'nbcore_upsells_limit'=>'',
            'nbcore_header_trip'=>'',
            'nbcore_shop_banner'=>'',
			'nbcore_logo_upload2'=>'',
			'nbcore_show_to_shop'=>'',
			'nbcore_product_addtocart'=>true
		);
	}
}

if( !function_exists('nbcore_header_woo_section') ){
	function nbcore_header_woo_section($account=TRUE)
	{
		$header_style = nbfoody_get_options('nbcore_header_style');

		if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {
			if($account): ?>
				<div class="header-account-wrap">
					<?php if (is_user_logged_in()):
						if ('left-inline' == $header_style):?>
							<i class="icon-user-o"></i>
						<?php else: ?>
							<span class="account-text"><?php esc_html_e('My Account', 'nb-foody'); ?></span>
						<?php endif; ?>
						<div class="nb-account-dropdown">
							<?php wc_get_template('myaccount/navigation.php'); ?>
						</div>
					<?php else: ?>
						<a href="<?php echo get_permalink(get_option('woocommerce_myaccount_page_id')); ?>"
						   class="not-logged-in" title="<?php esc_attr_e('Login', 'nb-foody'); ?>">
							<?php if ('left-inline' == $header_style): ?>
								<i class="icon-text-height"></i>
							<?php else: ?>
								<span class="account-text"><?php esc_html_e('Login', 'nb-foody'); ?></span>
							<?php endif; ?>
						</a>
					<?php endif; ?>
				</div>
			<?php endif; ?>
			<div class="header-cart-wrap">
				<a class="nb-cart-section" href="<?php echo wc_get_cart_url(); ?>"
				   title="<?php esc_attr_e('View cart', 'nb-foody'); ?>">
					<i class="icon-bag"></i>
					<span><?php echo WC()->cart->get_cart_contents_count(); ?></span>
				</a>
				<div class="mini-cart-section">
					<div class="mini-cart-wrap">
						<?php woocommerce_mini_cart(); ?>
					</div>
				</div>
			</div>
		<?php }
	}
}

if(!function_exists('nbcore_custome_query_search')){
    function nbcore_custome_query_search( $query ) {

        global $post;
        global $query_product_variation;

       $arr[] = array();
       if( $query->is_search() && $_GET['search_atr']=='1' ) :



           unset($_GET['s']);
           unset($_GET['search_atr']);
           $data_filter = isset($_GET) ? $_GET : null;
           if($data_filter !== null) {
                $tax_query = array();
               foreach($data_filter as $key => $value) {

                   if(empty($value)){
                       unset($data_filter[$key]);
                   }
               };
               foreach($data_filter as $key => $value){
                   if (strpos($key, 'pa_' ) !== false){
                       $tax_query[] = array(
                           'taxonomy'=> $key,
                           'field'           => 'term_id',
                           'terms'           => explode(",", $value),
                           'operator'        => 'IN',
                       );
                   }
               }
               $query->set('post_type', 'product');
               $query->set('tax_query',array_merge(array(
                       'relation' => 'AND'
                   ), $tax_query
               ));
           }

       endif;

    }
    wp_reset_postdata();
    add_action( 'pre_get_posts', 'nbcore_custome_query_search' );
}


if( !function_exists('nb_header_add_to_cart_fragment') ){
	function nb_header_add_to_cart_fragment($fragments)
	{
		global $woocommerce;

		ob_start();

		?>
		<a class="nb-cart-section" href="<?php echo wc_get_cart_url(); ?>"
		   title="<?php esc_attr_e('View cart', 'nb-foody'); ?>">
			<i class="icon-bag"></i>
			<span><?php echo WC()->cart->get_cart_contents_count(); ?></span>
		</a>
		<?php

		$fragments['a.nb-cart-section'] = ob_get_clean();

		return $fragments;

	}
	add_filter('woocommerce_add_to_cart_fragments', 'nb_header_add_to_cart_fragment');
}
function nbfoody_enqueue_script(){
    wp_enqueue_style('nbcore_front_style_child_maincss', get_stylesheet_directory_uri() . '/assets/netbase/css/main.css', array(), NBFoody_VER);
}
add_action('wp_enqueue_scripts','nbfoody_enqueue_script',9999);

