<?php

define('NBFoody_VER', '1.0.0');

class NBFoody_Core
{
    /**
     * Class prefix for autoload
     *
     * @var string
     */
    protected static $prefix = 'NBFoody_';

    /**
     * Variable hold the page options
     *
     * @var array
     */
    //protected static $page_options = array();

    public static $plugins;

    public function __construct()
    {
        require_once get_template_directory() . '/netbase-core/vendor/tgmpa/class-tgm-plugin-activation.php';

        spl_autoload_register(array($this, 'autoload'));

        new NBFoody_Customize();

        NBFoody_Helper::include_template_tags();

        if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
            new NBFoody_Extensions_Woocommerce();
        }
        require_once get_template_directory() . '/netbase-core/extensions/extras.php';

        // add_action('wp', array($this, 'get_options'));
        //add_action('customize_register', array('NBFoody_Customize', 'register'));

        add_action('after_setup_theme', array($this, 'theme_setup'));
        add_action('widgets_init', array($this, 'default_sidebars'));

        add_action('admin_enqueue_scripts', array($this, 'admin_scripts_enqueue'));
        // add_action('customize_controls_enqueue_scripts', array('NBFoody_Customize', 'customize_control_js'));
        // add_action('customize_preview_init', array('NBFoody_Customize', 'customize_preview_js'));
        // add_action('customize_controls_print_styles', array('NBFoody_Customize', 'customize_style'));
        //TODO make inline style below woocommerce.css.
        add_action('wp_enqueue_scripts', array($this, 'core_scripts_enqueue'), 9998);
        add_action('wp_enqueue_scripts', array($this, 'print_embed_style'), 9999);
        add_action('wp_enqueue_scripts', array($this, 'google_fonts_url'));

        add_filter('body_class', array('NBFoody_Helper', 'nbcore_body_classes'));
        add_action('wp_head', array('NBFoody_Helper', 'nbcore_pingback_header'));

        add_filter('show_recent_comments_widget_style', '__return_false');

        add_filter('upload_mimes', array($this, 'upload_mimes'));

        add_action( 'tgmpa_register', array($this, 'register_required_plugins') );
        add_action( 'admin_init', array($this, 'add_editor_styles') );

        $content_width = 1170;

        if(empty(get_transient('current_load_css'))) {
            set_transient('current_load_css', NBT_LOAD_CUSTOMIZE_FROM_HEAD, NBT_TIMEOUT_TRANSIENT_CUSTOMIZE);
        }


        add_filter( 'pt-ocdi/import_files', array($this, 'ocdi_import_files') );
        add_action( 'pt-ocdi/after_import', array($this, 'after_import') );


    }


    public static function autoload($class_name)
    {
        // Verify class prefix.
        if (0 !== strpos($class_name, self::$prefix)) {
            return false;
        }
        // Generate file path from class name.
        $base = get_template_directory() . '/netbase-core/';
        $path = strtolower(str_replace('_', '/', substr($class_name, strlen(self::$prefix))));

        // Check if class file exists.
        $standard = $path . '.php';
        $alternative = $path . '/' . current(array_slice(explode('/', str_replace('\\', '/', $path)), -1)) . '.php';

        while (true) {
            // Check if file exists in standard path.
            if (@is_file($base . $standard)) {
                $exists = $standard;

                break;
            }

            // Check if file exists in alternative path.
            if (@is_file($base . $alternative)) {
                $exists = $alternative;

                break;
            }

            // If there is no more alternative file, quit the loop.
            if (false === strrpos($standard, '/') || 0 === strrpos($standard, '/')) {
                break;
            }

            // Generate more alternative files.
            $standard = preg_replace('#/([^/]+)$#', '-\\1', $standard);
            $alternative = implode('/', array_slice(explode('/', str_replace('\\', '/', $standard)), 0, -1)) . '/' . substr(current(array_slice(explode('/', str_replace('\\', '/', $standard)), -1)), 0, -4) . '/' . current(array_slice(explode('/', str_replace('\\', '/', $standard)), -1));
        }

        // Include class declaration file if exists.
        if (isset($exists)) {
            return include_once $base . $exists;
        }

        return false;
    }




    public static function theme_setup()
    {
        /*
         * Make theme available for translation.
         * Translations can be filed in the /languages/ directory.
         * If you're building a theme based on nb-foody, use a find and replace
         * to change 'nb-foody' to the name of your theme in all the template files.
         */
        load_theme_textdomain('nb-foody', get_template_directory() . '/languages');

        // Add default posts and comments RSS feed links to head.
        add_theme_support('automatic-feed-links');

        /*
         * Let WordPress manage the document title.
         * By adding theme support, we declare that this theme does not use a
         * hard-coded <title> tag in the document head, and expect WordPress to
         * provide it for us.
         */
        add_theme_support('title-tag');

        /*
         * Enable support for Post Thumbnails on posts and pages.
         *
         * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
         */
        add_theme_support('post-thumbnails');

        // A theme must have at least one navbar, right?
        register_nav_menus(array(
            'primary' => esc_html__('Primary', 'nb-foody'),
            'header-sub' => esc_html__('Header sub menu', 'nb-foody'),
		));
		
		add_theme_support('post-formats', array(
            'standard',
            'image',
            'video',
            'gallery',
            'audio',
            'aside',
            'chat',
            'link',
            'quote',
            'status'
        ));

        /*
         * Switch default core markup for search form, comment form, and comments
         * to output valid HTML5.
         */
        add_theme_support('html5', array(
            'search-form',
            'comment-form',
            'comment-list',
            'gallery',
            'caption',
        ));

        /*
         * Enable support for Post Formats.
         * See https://developer.wordpress.org/themes/functionality/post-formats/
         */

        // Add theme support for selective refresh for widgets.
        add_theme_support('customize-selective-refresh-widgets');

        add_image_size('nbfoody-masonry', 450, 450, true);
		
		add_theme_support( 'woocommerce' );
		add_theme_support( 'custom-header', apply_filters( 'nbcore_custom_header_args', array(
			'width'                  => 1140,
			'height'                 => 280,
			'flex-height'            => true,
		) ) );
		add_theme_support( 'custom-background', apply_filters( 'nbcore_custom_background_args', array(
			'default-color' => nbfoody_get_options('nbcore_background_color'),
		) ) );
		
		$optboolean = ['nbcore_excerpt_only',
				'nbcore_header_fixed',
				'nbcore_blog_meta_date',
				'nbcore_blog_meta_read_time',
				'nbcore_blog_meta_author',
				'nbcore_blog_meta_category',
				'nbcore_blog_meta_tag',
				'nbcore_blog_sticky_sidebar',
				'show_title_section',
				'subset_cyrillic',
				'subset_greek',
				'subset_vietnamese',
				'nbcore_wc_breadcrumb',
				'nbcore_wc_attr',
				'nbcore_shop_action',
				'nbcore_grid_product_description',
				'nbcore_pd_details_title',
				'nbcore_pd_featured_autoplay',
				'nbcore_reviews_round_avatar',
				'nbcore_pd_show_social',
				'nbcore_show_related',
				'nbcore_show_upsells',
				'nbcore_show_cross_sells',
				'home_page_title_section',
				'nbcore_page_title_image_attachment',
				'nbcore_show_footer_top',
				'nbcore_show_footer_bot',
				'nbcore_footer_bg_attachment',
				'nbcore_blog_archive_comments',
				'nbcore_blog_archive_summary',
				'nbcore_blog_single_show_thumb',
				'nbcore_blog_single_show_social',
				'nbcore_blog_single_show_author',
				'nbcore_blog_single_show_nav',
				'nbcore_blog_single_show_comments',
				'show_back_top',
				'nbcore_product_addtocart',
				'shop_sticky_sidebar',
				'product_sticky_sidebar',
				'product_category_wishlist',
				'product_category_quickview',
				'nbcore_vendor_sticky_sidebar',
				'nbcore_dashboard_style'
			];
		foreach (nbfoody_default_options() as $k => $v){
			if (FALSE === get_theme_mod($k) && !in_array($k, $optboolean)){
				set_theme_mod($k,$v);
			}
		}
    }

    /**
     * Theme default sidebar.
     *
     * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
     */
    public static function default_sidebars()
    {
        register_sidebar(array(
            'name' => esc_html__('Default Sidebar', 'nb-foody'),
            'id' => 'default-sidebar',
            'description' => esc_html__('Add widgets here.', 'nb-foody'),
            'before_widget' => '<div id="%1$s" class="widget %2$s">',
            'after_widget' => '</div>',
            'before_title' => '<h3 class="widget-title">',
            'after_title' => '</h3>',
        ));

        if (class_exists('WooCommerce')) {
	        register_sidebar(array(
	            'name' => esc_html__('Shop Sidebar', 'nb-foody'),
	            'id' => 'shop-sidebar',
	            'description' => esc_html__('Add widgets for category page.', 'nb-foody'),
	            'before_widget' => '<div id="%1$s" class="widget %2$s">',
	            'after_widget' => '</div>',
	            'before_title' => '<h3 class="widget-title">',
	            'after_title' => '</h3>',
	        ));
	
	        register_sidebar(array(
	            'name' => esc_html__('Product Sidebar', 'nb-foody'),
	            'id' => 'product-sidebar',
	            'description' => esc_html__('Add widgets for product details page', 'nb-foody'),
	            'before_widget' => '<div id="%1$s" class="widget %2$s">',
	            'after_widget' => '</div>',
	            'before_title' => '<h3 class="widget-title">',
	            'after_title' => '</h3>',
	        ));
		}

        register_sidebar(array(
			'name' => esc_html__('Header Top #1', 'nb-foody'),
            'id' => 'header-top-1',
            'description' => esc_html__('For best display, please assign only one widget in this section.', 'nb-foody'),
            'before_widget' => '<div id="%1$s" class="widget %2$s">',
            'after_widget' => '</div>',
            'before_title' => '<h3 class="widget-title">',
            'after_title' => '</h3>',
        ));

        register_sidebar(array(
            'name' => esc_html__('Header Top #2', 'nb-foody'),
            'id' => 'header-top-2',
            'description' => esc_html__('For best display, please assign only one widget in this section.', 'nb-foody'),
            'before_widget' => '<div id="%1$s" class="widget %2$s">',
            'after_widget' => '</div>',
            'before_title' => '<h3 class="widget-title">',
            'after_title' => '</h3>',
        ));
        register_sidebar(array(
            'name' => esc_html__('Reversation', 'nb-foody'),
            'id' => 'nb-reversation',
            'description' => esc_html__('For best display, please assign only one widget in this section.', 'nb-foody'),
            'before_widget' => '<div id="%1$s" class="widget %2$s">',
            'after_widget' => '</div>',
            'before_title' => '<h3 class="widget-title">',
            'after_title' => '</h3>',
        ));

        register_sidebar(array(
            'name' => esc_html__('Footer Top #1', 'nb-foody'),
            'id' => 'footer-top-1',
            'description' => esc_html__('For best display, please assign only one widget in this section.', 'nb-foody'),
            'before_widget' => '<div id="%1$s" class="widget %2$s">',
            'after_widget' => '</div>',
            'before_title' => '<h3 class="widget-title">',
            'after_title' => '</h3>',
        ));

        register_sidebar(array(
            'name' => esc_html__('Footer Top #2', 'nb-foody'),
            'id' => 'footer-top-2',
            'description' => esc_html__('For best display, please assign only one widget in this section.', 'nb-foody'),
            'before_widget' => '<div id="%1$s" class="widget %2$s">',
            'after_widget' => '</div>',
            'before_title' => '<h3 class="widget-title">',
            'after_title' => '</h3>',
        ));

        register_sidebar(array(
            'name' => esc_html__('Footer Top #3', 'nb-foody'),
            'id' => 'footer-top-3',
            'description' => esc_html__('For best display, please assign only one widget in this section.', 'nb-foody'),
            'before_widget' => '<div id="%1$s" class="widget %2$s">',
            'after_widget' => '</div>',
            'before_title' => '<h3 class="widget-title">',
            'after_title' => '</h3>',
        ));

        register_sidebar(array(
            'name' => esc_html__('Footer Top #4', 'nb-foody'),
            'id' => 'footer-top-4',
            'description' => esc_html__('For best display, please assign only one widget in this section.', 'nb-foody'),
            'before_widget' => '<div id="%1$s" class="widget %2$s">',
            'after_widget' => '</div>',
            'before_title' => '<h3 class="widget-title">',
            'after_title' => '</h3>',
        ));

        register_sidebar(array(
            'name' => esc_html__('Footer Bottom #1', 'nb-foody'),
            'id' => 'footer-bot-1',
            'description' => esc_html__('For best display, please assign only one widget in this section.', 'nb-foody'),
            'before_widget' => '<div id="%1$s" class="widget %2$s">',
            'after_widget' => '</div>',
            'before_title' => '<h3 class="widget-title">',
            'after_title' => '</h3>',
        ));

        register_sidebar(array(
            'name' => esc_html__('Footer Bottom #2', 'nb-foody'),
            'id' => 'footer-bot-2',
            'description' => esc_html__('For best display, please assign only one widget in this section.', 'nb-foody'),
            'before_widget' => '<div id="%1$s" class="widget %2$s">',
            'after_widget' => '</div>',
            'before_title' => '<h3 class="widget-title">',
            'after_title' => '</h3>',
        ));

        register_sidebar(array(
            'name' => esc_html__('Footer Bottom #3', 'nb-foody'),
            'id' => 'footer-bot-3',
            'description' => esc_html__('For best display, please assign only one widget in this section.', 'nb-foody'),
            'before_widget' => '<div id="%1$s" class="widget %2$s">',
            'after_widget' => '</div>',
            'before_title' => '<h3 class="widget-title">',
            'after_title' => '</h3>',
        ));

        register_sidebar(array(
            'name' => esc_html__('Footer Bottom #4', 'nb-foody'),
            'id' => 'footer-bot-4',
            'description' => esc_html__('For best display, please assign only one widget in this section.', 'nb-foody'),
            'before_widget' => '<div id="%1$s" class="widget %2$s">',
            'after_widget' => '</div>',
            'before_title' => '<h3 class="widget-title">',
            'after_title' => '</h3>',
        ));
    }

    // Todo change to minified version and load conditional. Example: isotope is now always load
    public static function core_scripts_enqueue()
    {

        $handle = 'swiper';
        $list = 'enqueued';
        //TODO Remember this
        wp_dequeue_script('wc-cart');
        wp_enqueue_style('nbfoody_fontello', get_template_directory_uri() . '/assets/vendor/fontello/fontello.css', array(), NBFoody_VER);
		wp_enqueue_style( 'dashicons' );

        wp_enqueue_style('nbfoody_front_style', get_stylesheet_uri());

        wp_enqueue_style('nbcore_front_style_maincss', get_template_directory_uri() . '/assets/netbase/css/main.css', array(), NBFoody_VER);

		wp_enqueue_style('nbfoody_front_font', get_template_directory_uri() . '/assets/font/font.css', array(), NBFoody_VER);

        wp_enqueue_script('isotope', get_template_directory_uri() . '/assets/vendor/isotope/isotope.pkdg.min.js', array('jquery'), '3.0.3', true);

        wp_enqueue_style('magnific-popup', get_template_directory_uri() . '/assets/vendor/magnific-popup/magnific-popup.css', array(), '2.0.5');
        wp_enqueue_script('magnific-popup', get_template_directory_uri() . '/assets/vendor/magnific-popup/jquery.magnific-popup.min.js', array('jquery'), '2.0.5', true);
        
		if (!class_exists("WPBakeryShortCode")) {
			wp_register_style( 'prettyphoto', get_template_directory_uri() . '/assets/vendor/prettyphoto/css/prettyPhoto.min.css', array(), NBFoody_VER );
			wp_register_script( 'prettyphoto', get_template_directory_uri() . '/assets/vendor/prettyphoto/js/jquery.prettyPhoto.min.js', array( 'jquery' ), NBFoody_VER, true );
		}

        if(!wp_script_is( $handle, $list )){

            wp_enqueue_style('swiper', get_template_directory_uri() . '/assets/vendor/swiper/swiper.min.css', array(), '3.4.2');
            wp_enqueue_script('swiper', get_template_directory_uri() . '/assets/vendor/swiper/swiper.jquery.min.js', array('jquery'), '3.4.2', true);
        }

        if (is_singular() && comments_open() && get_option('thread_comments')) {
            wp_enqueue_script('comment-reply');
        }

        if (function_exists('is_product') && is_product() && 'accordion-tabs' == nbfoody_get_options('nbcore_info_style')) {
            wp_enqueue_script('jquery-ui-accordion');
        }

        if (nbfoody_get_options('nbcore_header_fixed')) {
            wp_enqueue_script('nbfoody_waypoints', get_template_directory_uri() . '/assets/vendor/waypoints/jquery.waypoints.min.js', array('jquery'), '4.0.1', true);
        }

        if (nbfoody_get_options('nbcore_blog_sticky_sidebar')) {
            wp_enqueue_script('sticky-kit', get_template_directory_uri() . '/assets/vendor/sticky-kit/jquery.sticky-kit.min.js', array('jquery'), '1.1.2', true);
        }

        wp_enqueue_script('nbfoody_front_script', get_template_directory_uri() . '/assets/netbase/js/main.js', array('jquery'), NBFoody_VER, true);

        //wp_enqueue_script('nbfoody_cart_script', get_template_directory_uri() . '/assets/netbase/js/cart.js', array('jquery'), NBFoody_VER, true);

        $localize_array = array(
            'ajaxurl'           => admin_url( 'admin-ajax.php', 'relative' ),
            'upsells_columns' => nbfoody_get_options('nbcore_pd_upsells_columns'),
            'related_columns' => nbfoody_get_options('nbcore_pd_related_columns'),
            'cross_sells_columns' => nbfoody_get_options('nbcore_cross_sells_per_row'),
            'thumb_pos' => nbfoody_get_options('nbcore_pd_thumb_pos'),
            'menu_resp' => nbfoody_get_options('nbcore_menu_resp'),
        );
		
		if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
            $version = version_compare( preg_replace( '/-beta-([0-9]+)/', '', WC()->version ), '2.3.0', '<' );   
            $localize_array['is2_2'] = $version;
        }
		
        wp_localize_script('nbfoody_front_script', 'nbfoody', $localize_array);

        wp_dequeue_script('yith-wcqv-frontend');
        wp_dequeue_style('yith-quick-view');
    }
	
	/**
	 *  Editor Style
	 */
	public static function add_editor_styles() {
		add_editor_style( 'css/editor-style.css' );
	}

    public static function admin_scripts_enqueue()
    {
        wp_enqueue_style('nbfoody_fontello', get_template_directory_uri() . '/assets/vendor/fontello/fontello.css', array(), NBFoody_VER);
    }

   /* public static function get_options()
    {
        static $prepared;

        if (!isset($prepared)) {
            // Get all customizer options
            $theme_mods = NBFoody_Customize::get_options();

            if ($theme_mods && is_array($theme_mods)) {
                self::$page_options = array_merge(self::$page_options, $theme_mods);
            }

            if (function_exists('get_fields')) {
                $page_id = get_the_ID();

                if ($page_id) {
                    // Todo replace acf ?
                    $post_meta = get_fields();
                    if ($post_meta) {
                        foreach ($post_meta as $k => $v) {
                            self::$page_options[$k] = maybe_unserialize($v);
                        }
                    }
                }

                if (isset(self::$page_options)) {
                    // Merge with theme options with higher priority.
                    self::$page_options = array_merge(
                        $theme_mods,
                        self::$page_options
                    );
                }
            }

            $prepared = true;
        }

        if (!doing_action('wp')) {
            // Prepare options to return.
            if (isset($page_id) && isset(self::$page_options[$page_id])) {
                $options = self::$page_options[$page_id];
            }

            return self::$page_options;
        }

    }*/

    //TODO optimize this(grouping and bring to css if can)
    //TODO early esc_
    public static function get_embed_style()
    {
        $bg_color = nbfoody_get_options('nbcore_background_color');
        $inner_bg = nbfoody_get_options('nbcore_inner_background');

        $top_padding = nbfoody_get_options('nbcore_top_section_padding');
        $top_bg = nbfoody_get_options('nbcore_header_top_bg');
        $top_color = nbfoody_get_options('nbcore_header_top_color');
		$top_hover_color = nbfoody_get_options('nbcore_header_top_hover_color');
        $middle_padding = nbfoody_get_options('nbcore_middle_section_padding');
        $middle_bg = nbfoody_get_options('nbcore_header_middle_bg');
        $middle_color = nbfoody_get_options('nbcore_header_middle_color');
		$middle_hover_color = nbfoody_get_options('nbcore_header_middle_hover_color');
        $bot_padding = nbfoody_get_options('nbcore_bot_section_padding');
        $bot_bg = nbfoody_get_options('nbcore_header_bot_bg');
        $bot_color = nbfoody_get_options('nbcore_header_bot_color');
		$bot_hover_color = nbfoody_get_options('nbcore_header_bot_hover_color');
        $menu_bg = nbfoody_get_options('nbcore_header_mainmn_bg');
        $menu_color = nbfoody_get_options('nbcore_header_mainmn_color');
        $menu_bor = nbfoody_get_options('nbcore_header_mainmn_bor');
        $menu_bg2 = nbfoody_get_options('nbcore_header_mainmnhover_bg');
        $menu_color2 = nbfoody_get_options('nbcore_header_mainmnhover_color');
        $menu_bor2 = nbfoody_get_options('nbcore_header_mainmnhover_bor');

        $logo_area_width = nbfoody_get_options('nbcore_logo_width');
        $blog_width = nbfoody_get_options('nbcore_blog_width');
        $primary_color = nbfoody_get_options('nbcore_primary_color');
        $secondary_color = nbfoody_get_options('nbcore_secondary_color');
		$tertiary_color = nbfoody_get_options('nbcore_tertiary_color');
        $divider_color = nbfoody_get_options('nbcore_divider_color');

        $heading_font_array = explode(",", nbfoody_get_options('heading_font_family'));
        $heading_family = end($heading_font_array);
        $heading_font_style = explode(",", nbfoody_get_options('heading_font_style'));
        $heading_weight = end($heading_font_style);
        $heading_color = nbfoody_get_options('nbcore_heading_color');

        $heading_base_size = nbfoody_get_options('heading_base_size');

        $body_family_array = explode(",", nbfoody_get_options('body_font_family'));
        $body_family = end($body_family_array);
        $body_style_array = explode(",", nbfoody_get_options('body_font_style'));
        $body_weight = end($body_style_array);
        $body_color = nbfoody_get_options('nbcore_body_color');
		$meta_color = nbfoody_get_options('nbcore_meta_color');
        $body_size = nbfoody_get_options('body_font_size');

        $link_color = nbfoody_get_options('nbcore_link_color');
        $link_hover_color = nbfoody_get_options('nbcore_link_hover_color');

        $blog_sidebar = nbfoody_get_options('nbcore_blog_sidebar');
        $page_title_padding = nbfoody_get_options('nbcore_page_title_padding');
        $page_title_color = nbfoody_get_options('nbcore_page_title_color');
		$page_title_img = nbfoody_get_options('nbcore_page_title_image');
        $page_title_img_size = nbfoody_get_options('nbcore_page_title_image_size');
        $page_title_img_pos = nbfoody_get_options('nbcore_page_title_image_pos');
        $page_title_img_repeat = nbfoody_get_options('nbcore_page_title_image_repeat');
        $page_title_img_attachment = (nbfoody_get_options('nbcore_page_title_image_attachment') ? 'scroll' : 'fixed');
		if ($page_title_img != '') {
			$page_title_img = wp_get_attachment_image_src( $page_title_img, 'full', false );
			$page_title_img = $page_title_img[0];
		}
		if ( class_exists( 'WooCommerce' ) ) {
			$wc_content_width = nbfoody_get_options('nbcore_shop_content_width');
			$shop_sidebar = nbfoody_get_options('nbcore_shop_sidebar');
			$pd_details_sidebar = nbfoody_get_options('nbcore_pd_details_sidebar');
			$pd_details_width = nbfoody_get_options('nbcore_pd_details_width');
			$pd_images_width = nbfoody_get_options('nbcore_pd_images_width');
		}

        $pb_bg = nbfoody_get_options('nbcore_pb_background');
        $pb_bg_hover = nbfoody_get_options('nbcore_pb_background_hover');
        $pb_text = nbfoody_get_options('nbcore_pb_text');
        $pb_text_hover = nbfoody_get_options('nbcore_pb_text_hover');
        $pb_border = nbfoody_get_options('nbcore_pb_border');
        $pb_border_hover = nbfoody_get_options('nbcore_pb_border_hover');
        $sb_bg = nbfoody_get_options('nbcore_sb_background');
        $sb_bg_hover = nbfoody_get_options('nbcore_sb_background_hover');
        $sb_text = nbfoody_get_options('nbcore_sb_text');
        $sb_text_hover = nbfoody_get_options('nbcore_sb_text_hover');
        $sb_border = nbfoody_get_options('nbcore_sb_border');
        $sb_border_hover = nbfoody_get_options('nbcore_sb_border_hover');
		$tb_bg = nbfoody_get_options('nbcore_tb_background');
        $tb_bg_hover = nbfoody_get_options('nbcore_tb_background_hover');
        $tb_text = nbfoody_get_options('nbcore_tb_text');
        $tb_text_hover = nbfoody_get_options('nbcore_tb_text_hover');
        $tb_border = nbfoody_get_options('nbcore_tb_border');
        $tb_border_hover = nbfoody_get_options('nbcore_tb_border_hover');
        $button_padding = nbfoody_get_options('nbcore_button_padding');
        $button_border_radius = nbfoody_get_options('nbcore_button_border_radius');
        $button_border_width = nbfoody_get_options('nbcore_button_border_width');

        $footer_top_heading = nbfoody_get_options('nbcore_footer_top_heading');
        $footer_top_color = nbfoody_get_options('nbcore_footer_top_color');
		$footer_top_hover_color = nbfoody_get_options('nbcore_footer_top_hover_color');
        $footer_top_bg = nbfoody_get_options('nbcore_footer_top_bg');
		$footer_top_bor = nbfoody_get_options('nbcore_footer_top_bor');
        $footer_bot_heading = nbfoody_get_options('nbcore_footer_bot_heading');
        $footer_bot_color = nbfoody_get_options('nbcore_footer_bot_color');
		$footer_bot_hover_color = nbfoody_get_options('nbcore_footer_bot_hover_color');
        $footer_bot_bg = nbfoody_get_options('nbcore_footer_bot_bg');
		$footer_bot_bor = nbfoody_get_options('nbcore_footer_bot_bor');
        $footer_abs_bg = nbfoody_get_options('nbcore_footer_abs_bg');
		$footer_abs_bor = nbfoody_get_options('nbcore_footer_abs_bor');
        $footer_abs_color = nbfoody_get_options('nbcore_footer_abs_color');
		$footer_abs_hover_color = nbfoody_get_options('nbcore_footer_abs_hover_color');
        $footer_bg = nbfoody_get_options('nbcore_footer_bg_color');
        $footer_bg_img = nbfoody_get_options('nbcore_footer_bg_img');
        $footer_bg_size = nbfoody_get_options('nbcore_footer_bg_size');
        $footer_bg_pos = nbfoody_get_options('nbcore_footer_bg_pos');
        $footer_bg_repeat = nbfoody_get_options('nbcore_footer_bg_repeat');
		$footer_bg_attachment = (nbfoody_get_options('nbcore_footer_bg_attachment') ? 'scroll' : 'fixed');
		if ($footer_bg_img != '') {
			$footer_bg_img = wp_get_attachment_image_src( $footer_bg_img, 'full', false );
			$footer_bg_img = $footer_bg_img[0];
		}

        $blog_title_size = nbfoody_get_options('nbcore_blog_single_title_size');
        $page_title_size = nbfoody_get_options('nbcore_page_title_size');

        $footer_abs_padding = nbfoody_get_options('nbcore_footer_abs_padding');

        $page_content_width = nbfoody_get_options('page_content_width');
        $page_sidebar = nbfoody_get_options('page_sidebar');
        $page_bg = wp_get_attachment_image_src(get_post_meta(get_the_ID(), 'page_bg_image', true), 'full');
        $page_bg_color = get_post_meta(get_the_ID(), 'page_bg_color', true);


        $css = "";

        if($body_family_array[0] === 'custom') {
            $body_custom_font_url = array_slice($body_family_array, 1, -1);
            $css .= "
            @font-face {
                font-family: '" . end($body_family_array) . "';            
            ";

            foreach($body_custom_font_url as $url) {
                $css .= "
                src: url('" . $url . "');
                ";
            }

            $css .= "
            }
            ";
        }
        if($heading_font_array[0] === 'custom') {
            $heading_custom_font_url = array_slice($heading_font_array, 1, -1);
            $css .= "
            @font-face {
                font-family: '" . end($heading_font_array) . "';            
            ";

            foreach($heading_custom_font_url as $url) {
                $css .= "
                src: url('" . $url . "');
                ";
            }

            $css .= "
            }
            ";
        }
        $css .= "
            body {
                background-color: " . esc_attr($bg_color) . ";
            }
            .nb-page-title-wrap,
            .single-blog .entry-author,
            .products .list-type-wrap,
            .shop-main.accordion-tabs .accordion-title-wrap,
            .woocommerce .woocommerce-message,
            .woocommerce .woocommerce-info,
            .woocommerce .woocommerce-error,
            .woocommerce-page .woocommerce-message,
            .woocommerce-page .woocommerce-info,
            .woocommerce-page .woocommerce-error,
            .cart-layout-2 .cart-totals-wrap,
            .blog.style-2 .post .entry-content,
            .comments-area,
            .blog .post .entry-cat a,
            .error404 main .text-wrap{
                background-color: " . esc_attr($inner_bg) . ";
            }
            .products.list-type .product .list-type-wrap .product-image:before {
                border-right-color: " . esc_attr($inner_bg) . ";
            }
            .main-logo {
                width: " . esc_attr($logo_area_width) . "px;
            }
            a,
            .widget ul li a:hover{
                color: " . esc_attr($link_color) . ";
            }
            a:hover, a:focus, a:active{
                color: " . esc_attr($link_hover_color) . ";
            }
            body,.wine_client .wine_guide .nb_testimonials .nb_testimonial-item .nb_testimonial-img-info .nb_testimonial-info .nb_testimonial-position,.coffee_service_1 .service_tab .vc_column-inner .vc_tta-container .vc_tta-style-nbstyle1 .vc_tta-tabs-container ul li {
                font-family: " . esc_attr($body_family) . "; 
                font-weight: " . esc_attr($body_weight) . ";
                font-size: " . esc_attr($body_size) . "px;
        ";
        if (in_array("italic", $body_style_array)) {
            $css .= "
                font-style: italic;
            ";
        }
        if (in_array("underline", $body_style_array)) {
            $css .= "
                text-decoration: underline;
            ";
        }
        if (in_array("uppercase", $body_style_array)) {
            $css .= "
                text-transform: uppercase;
            ";
        }
        $css .= "
            }
            .button, .nb-primary-button, .post-password-form input[type='submit'],
			.wpcf7-form input[type='submit'],
			.wine_category .vc_tta-style-nbstyle1 .vc_tta-panels-container .vc_tta-panel-body .vc_btn3-container .vc_general,
			.type-post:not(.sticky) .entry-block:before,
			.single-blog.blog_layout_classic .entry-block:before{
                color: " . esc_attr($pb_text) . ";
                background-color: " . esc_attr($pb_bg) . ";
                border-color: " . esc_attr($pb_border) . ";
            }
            .mini-cart-wrap .buttons .button {
                color: " . esc_attr($pb_text) . ";
            }
            
            .wine_find_product .nb_find_product .nb_find_product-item input:hover,
            .button:hover, .nb-primary-button:hover, .post-password-form input[type='submit']:hover, .button:focus, .nb-primary-button:focus,
            .wine_category .vc_tta-style-nbstyle1 .vc_tta-panels-container .vc_tta-panel-body .vc_btn3-container .vc_general:hover,
            .wpcf7-form input[type='submit']:hover {
                color: " . esc_attr($pb_text_hover) . ";
                background-color: " . esc_attr($pb_bg_hover) . ";
                border-color: " . esc_attr($pb_border_hover) . ";
            }
            .nb-secondary-button {
                color: " . esc_attr($sb_text) . ";
                background-color: " . esc_attr($sb_bg) . ";
                border-color: " . esc_attr($sb_border) . ";
            }
            .nb-secondary-button:hover, .nb-secondary-button:focus {
                color: " . esc_attr($sb_text_hover) . ";
                background-color: " . esc_attr($sb_bg_hover) . ";
                border-color: " . esc_attr($sb_border_hover) . ";
            }
            .filters-button-group .filter-btn{
				color: " . esc_attr($tb_text) . ";
                background-color: " . esc_attr($tb_bg) . ";
                border-color: " . esc_attr($tb_border) . ";
			}
			.filters-button-group .filter-btn.is-checked, .filters-button-group .filter-btn:hover{
				color: " . esc_attr($tb_text_hover) . ";
                background-color: " . esc_attr($tb_bg_hover) . ";
                border-color: " . esc_attr($tb_border_hover) . ";
			}
            .list-type .add_to_cart_button, .nb-primary-button, .nb-secondary-button, .single_add_to_cart_button, .post-password-form input[type='submit']{
                padding-left: " . esc_attr($button_padding) . "px;
                padding-right: " . esc_attr($button_padding) . "px;
                border-width: " . esc_attr($button_border_width) . "px;
            ";
        if ($button_border_radius) {
            $css .= "
                border-radius: " . esc_attr($button_border_radius) . "px;
            ";
        } else {
            $css .= "
                border-radius: 0px;
            ";
        }
        $css .= "
            }
            body,
            .widget ul li a,
            .woocommerce-breadcrumb a,
            .woocommerce-MyAccount-navigation-link a,
            .nb-social-icons > a,
            .wc-tabs > li:not(.active) a,
            .shop-main.accordion-tabs .accordion-title-wrap:not(.ui-state-active) a,
            .nb-account-dropdown a,
            .header-account-wrap .not-logged-in,
            .mid-inline .nb-account-dropdown a, 
            .mid-inline .mini-cart-section span, 
            .mid-inline .mini-cart-section a, 
            .mid-inline .mini-cart-section strong{
                color: " . esc_attr($body_color) . ";
            }
            .entry-meta,
            .entry-meta .byline a,
            .comments-link a{
                color: " . esc_attr($meta_color) . ";
            }
            h1 {
                font-size: " . esc_attr(intval($heading_base_size * 2.074)) . "px;
            }
            h2 {
                font-size: " . esc_attr(intval($heading_base_size * 1.728)) . "px;
            }
            h3 {
                font-size: " . esc_attr(intval($heading_base_size * 1.44)) . "px;
            }
            h4 {
                font-size: " . esc_attr(intval($heading_base_size * 1.2)) . "px;
            }
            h5 {
                font-size: " . esc_attr(intval($heading_base_size * 1)) . "px;
            }
            h6 {
                font-size: " . esc_attr(intval($heading_base_size * 0.833)) . "px;
            }
            h1, h2, h3, h4, h5, h6,
            .woocommerce-Reviews .comment-reply-title,
            .wine_category .vc_tta-style-nbstyle1 .vc_tta-tabs-container .vc_tta-tabs-list .vc_tta-tab a .vc_tta-title-text
            {
                font-family: " . esc_attr($heading_family) . "; 
                font-weight: " . esc_attr($heading_weight) . ";
                color: " . esc_attr($heading_color) . ";
        ";
        if (in_array("italic", $heading_font_style)) {
            $css .= "
                font-style: italic;
            ";
        }
        if (in_array("underline", $heading_font_style)) {
            $css .= "
                text-decoration: underline;
            ";
        }
        if (in_array("uppercase", $heading_font_style)) {
            $css .= "
                text-transform: uppercase;
            ";
        }
        //TODO after make inline below woocommerce.css remove these !important
        //TODO postMessage font-size .header-top-bar a
        $css .= "
            }
            h1 > a, h2 > a, h3 > a, h4 > a, h5 > a, h6 > a{
                color: " . esc_attr($heading_color) . ";
                ";
            if (in_array("underline", $heading_font_style)) {
                $css .= "
                    text-decoration: underline;
                ";
            }
        $css .= "
            }
            .site-header .top-section-wrap,.classic .top-section-wrap .top-section .flex-section,.header-1 .top-section-wrap .top-section{
                padding: " . esc_attr($top_padding) . "px 0;
                background-color: " . esc_attr($top_bg) . ";
            }
            .top-section-wrap, .top-section-wrap a, .top-section-wrap ul [class^='icon-']:before, .classic .top-section-wrap ul li a,.header-1 .top-section-wrap ul li a,
            .top-section-wrap .nb-header-sub-menu a {
                color: " . esc_attr($top_color) . ";
            }
            .top-section-wrap a:hover,.classic .top-section-wrap ul li a:hover,.header-1 .top-section-wrap ul li a:hover,.text-contact p a,.text-contact p,
            .top-section-wrap .nb-header-sub-menu a:hover {
                color: " . esc_attr($top_hover_color) . ";
            }
            .site-header.header-1 .top-section-wrap .top-section .icon-section .header-cart-wrap .nb-cart-section .count-item{
                 background-color: " . esc_attr($top_hover_color) . ";
            }
            .top-section-wrap .nb-header-sub-menu .sub-menu,.top-section-wrap .top-section .has-children .top-submenu{
                background-color: " . esc_attr($top_bg) . ";
            }
            .site-header .middle-section-wrap {
                padding: " . esc_attr($middle_padding) . "px 0;
                background-color: " . esc_attr($middle_bg) . ";
            }
            .middle-section-wrap,.middle-section-wrap a {
                color: " . esc_attr($middle_color) . ";
            }
             .header-1 .top-section-wrap ul.menu-top,.classic .top-section-wrap ul.menu-top,.classic .nbt_simplelogin ul.list-inline{
                 margin-top: -" . esc_attr($top_padding) . "px;
				margin-bottom: -" . esc_attr($top_padding) . "px;
            }
            .header-1 .top-section-wrap ul.menu-top > li,.classic .top-section-wrap ul.menu-top > li,.classic .nbt_simplelogin ul.list-inline > li{
                padding-top: " . esc_attr($top_padding) . "px;
				padding-bottom: " . esc_attr($top_padding) . "px;
            }

             .header-1.header-mobile .middle-section-wrap .middle-section{
                 bottom: ". esc_attr($top_padding) ."px;

            }
            .site-header.left-inline .middle-section-wrap .middle-section .main-desktop-navigation .nb-navbar,.site-header.header-1 .nb-navbar,
            .site-header.left-inline_1 .middle-section-wrap .middle-section .main-desktop-navigation ul.nb-navbar
            {
				margin-top: -" . esc_attr($middle_padding) . "px;
				margin-bottom: -" . esc_attr($middle_padding) . "px;
			}
            .site-header.left-inline .middle-section-wrap .middle-section .main-desktop-navigation .nb-navbar > li > a,
            .site-header.left-inline_1 .middle-section-wrap .middle-section .main-desktop-navigation ul.nb-navbar > li,
			.site-header.header-1 .nb-navbar > li,
			 .middle-section-wrap .header-cart-wrap{
				padding-top: " . esc_attr($middle_padding) . "px;
				padding-bottom: " . esc_attr($middle_padding) . "px;
			}
            .middle-section-wrap a:hover,
            .middle-section-wrap .nb-navbar .menu-item:hover > a,
            .site-header.header-1.site-header-customize .middle-section-wrap a:hover,
             .middle-section-wrap .nb-navbar .menu-item.current-menu-parent:hover > a, .middle-section-wrap .nb-navbar .menu-item.current-menu-item:hover > a, .middle-section-wrap .nb-navbar .menu-item.current-menu-ancestor:hover > a,
            .middle-section-wrap .nb-header-sub-menu .menu-item:hover > a, .middle-section-wrap .nb-header-sub-menu .menu-item.current-menu-parent > a, .middle-section-wrap .nb-header-sub-menu .menu-item.current-menu-item > a, .middle-section-wrap .nb-header-sub-menu .menu-item.current-menu-ancestor > a,
            .icon-header-wrap .nb-cart-section i,
            .middle-section-wrap .mini-cart-wrap .mini_cart_item .remove:hover{
                color: " . esc_attr($middle_hover_color) . ";
            }
            .site-header:not(.mid-stack) .bot-section-wrap {
                padding: " . esc_attr($bot_padding) . "px 0;                
            }
            .site-header.mid-stack .nb-navbar > .menu-item > a {
                padding: " . esc_attr($bot_padding) . "px 20px;                
            }
            .site-header .bot-section-wrap {
                background-color: " . esc_attr($bot_bg) . ";           
            }
            .bot-section-wrap, .bot-section-wrap a{
                color: " . esc_attr($bot_color) . ";
            }
            .bot-section-wrap a:hover{
                color: " . esc_attr($bot_hover_color) . ";
            }
            .nb-navbar .menu-item-has-children > a span:after,
            .icon-header-section .nb-cart-section,
            .nb-navbar .menu-item a,
            .nb-navbar .sub-menu > .menu-item:not(:last-child),
            .nb-header-sub-menu .sub-menu > .menu-item:not(:last-child),
            .widget .widget-title,
			.blog .classic .post:not(.sticky) .entry-content,
			.blog .classic .post:not(.sticky) .entry-image,
			.single-blog .entry-content,
            .blog .classic .post .entry-footer,
            .single-post .single-blog .entry-footer,
			.nb-social-icons,
            .nb-social-icons > a,
            .single-blog .entry-author-wrap,
            .shop-main:not(.wide) .single-product-wrap .product_meta,
			.shop-main:not(.wide) .single-product-wrap .cart,
            .shop-main.accordion-tabs .accordion-item .accordion-title-wrap,
            .shop-main.horizontal-tabs .wc-tabs-wrapper,
            .shop_table thead th,
            .shop_table th,
            .shop_table td,
            .mini-cart-wrap .total,
            .icon-header-wrap .nb-account-dropdown ul li:not(:last-of-type) a,
            .widget tbody th, .widget tbody td,
            .widget ul > li:not(:last-of-type),
			.widget.widget_nav_menu .sub-menu,
			.widget.widget_nav_menu .children,
			.widget.widget_product_categories .sub-menu,
			.widget.widget_product_categories .children,
            .blog .post .entry-image .entry-cat,
            .comment-list .comment,
            .paging-navigation.pagination-style-1 .page-numbers.current,
            .woocommerce-pagination.pagination-style-1 .page-numbers.current,
			.page-links.pagination-style-1 > span,
			.page-links.pagination-style-1 > a:hover,
			.woocommerce-account .woocommerce .woocommerce-MyAccount-navigation .woocommerce-MyAccount-navigation-link,
			.woocommerce-account .woocommerce .woocommerce-MyAccount-content,
			.woocommerce-account .woocommerce .woocommerce-MyAccount-content:before,
			.single-product-wrap .product-image .thumb-gallery .swiper-slide,
			.shop-main.horizontal-tabs .wc-tabs-wrapper .wc-tabs{
                border-color: " . esc_attr($divider_color) . ";
            }
            @media (max-width: 767px) {
                .shop_table.cart {
                    border: 1px solid " . esc_attr($divider_color) . ";
                }
                .shop_table.cart td {
                    border-bottom: 1px solid " . esc_attr($divider_color) . ";
                }
            }
            article.sticky,
            .product_list_widget > li > a:hover > img,.product_list_widget > li > a > img:hover,
            .product .product-image .onsale,
            .wc-tabs > li.active,
            .product .onsale.sale-style-2 .percent,
            .wc-tabs-wrapper .woocommerce-Reviews #review_form_wrapper .comment-respond,
            .site-header.mid-stack .main-navigation .nb-navbar > .menu-item:hover,
            .shop-main.accordion-tabs .accordion-item .accordion-title-wrap.ui-accordion-header-active,
            .variations ul.swatch li:hover span, .variations ul.swatch li.selected span,
            .widget .tagcloud a,
            .footer-top-section .widget .tagcloud a,
            .footer-bot-section .widget .tagcloud a,
            body>.loading.demo7 #loading-center #loading-center-absolute .object,
            body>.loading.demo3 #loading-center #loading-center-absolute .object,
            .cart-notice-wrap .cart-notice,.simplemodal-wrap #simplemodal-login-form .footer__right a,
			.owl-carousel[data-dotslayout='style_2'] .owl-dots .owl-dot,
			.owl-carousel[data-dotslayout='style_1'] .owl-dots .owl-dot,
			.nb-input-group .search-field:focus,
			.wine_find_product .nb_find_product .nb_find_product-item input,
			.wine_client .wine_guide .nb_testimonials .owl-dots .owl-dot,
			.wine_category .vc_tta-style-nbstyle1 .vc_tta-tabs-container .vc_tta-tabs-list .vc_tta-tab.vc_active:before,
			.wine_feature .wine_feature_category .vc_tta-panels .vc_tta-panel.vc_active .vc_tta-panel-heading .vc_tta-title-text:before,
			.nb_brand_carousel .swiper-pagination .swiper-pagination-bullet:before,
			.single-product-wrap .product-image .thumb-gallery .swiper-slide.swiper-slide-active
            {
                border-color: " . esc_attr($primary_color) . ";
            }
            body>.loading.demo14 #loading-center #loading-center-absolute .object{
                border-left-color: " . esc_attr($primary_color) . ";
                border-right-color: " . esc_attr($primary_color) . ";
            }
            body>.loading.demo15 #loading-center #loading-center-absolute .object{
                border-left-color: " . esc_attr($primary_color) . ";
                border-top-color: " . esc_attr($primary_color) . ";
            }
            .simplemodal-wrap #simplemodal-login-form .simplemodal-login-fields input:focus{
                border: 1px solid " . esc_attr($primary_color) . ";
            }
            .widget .widget-title:before,
            .paging-navigation.pagination-style-2 .current,
            .product .onsale.sale-style-1,
            .woocommerce-pagination.pagination-style-2 span.current,
            .page-links.pagination-style-2 > span,
            .page-links.pagination-style-2 > a:hover,
            .shop-main.right-dots .flickity-page-dots .dot,
            .wc-tabs-wrapper .form-submit input,
            .nb-input-group .search-button button,
            .widget .tagcloud a:hover,
            .nb-back-to-top-wrap a:hover,
            body>.loading #loading-center #loading-center-absolute #object,
            body>.loading #loading-center #loading-center-absolute .object,
            body>.loading #loading-center .object-one,
            body>.loading #loading-center .object-two,
            .single-product-wrap .yith-wcwl-add-to-wishlist,
			.swiper-pagination-bullet.swiper-pagination-bullet-active,
            .woocommerce .widget_price_filter .ui-slider .ui-slider-handle,
            .error404 main .home-link,
            #secondary .tagcloud a:hover,
            .nbt-primary-bg,
            .tp-bullets.custom .tp-bullet.selected,
            .tp-bullets.custom .tp-bullet:hover,
            .nb_brand_carousel .swiper-pagination .swiper-pagination-bullet.swiper-pagination-bullet-active,
            .nb_brand_carousel .swiper-pagination .swiper-pagination-bullet:hover,

            .owl-carousel[data-dotslayout='style_1'] .owl-dots .owl-dot.active span,
            .owl-carousel[data-dotslayout='style_1'] .owl-dots .owl-dot:hover span,
            .sushi_list_action .icon_list_item:hover .icon_list_icon:before,
			[data-slide='owl-carousel'] .owl-dots .owl-dot.active span,
			[data-slide='owl-carousel'] .owl-dots .owl-dot:hover span,
			 #simplemodal-login-container-education .simplemodal-wrap .submit input,
			.owl-carousel[data-dotslayout='style_2'] .owl-dots .owl-dot.active span,
			.owl-carousel[data-dotslayout='style_2'] .owl-dots .owl-dot:hover span{
                background-color: " . esc_attr($primary_color) . ";
            }
            article.sticky:before,
            .product .star-rating:before,
            .product .star-rating span,
            .nbt-product .product-content .product-title > a:hover,
            .single-product-wrap .price ins,
            .single-product-wrap .price > span.amount,
            .nbt-product .product-content .price .amount,
            .product_list_widget .product-title > a:hover,
            .product_list_widget span.amount,
            .wc-tabs > li.active a,
            .wc-tabs > li.active a:hover,
            .wc-tabs > li.active a:focus,
            .wc-tabs .ui-accordion-header-active a,
            .wc-tabs .ui-accordion-header-active a:focus,
            .wc-tabs .ui-accordion-header-active a:hover,
            .shop-main.accordion-tabs .ui-accordion-header-active:after,
            .shop_table .cart_item td .amount,
            .cart_totals .order-total .amount,
            .shop_table.woocommerce-checkout-review-order-table .order-total .amount,
            .woocommerce-order .woocommerce-thankyou-order-received,
            .woocommerce-order .woocommerce-table--order-details .amount,
            .paging-navigation.pagination-style-1 .current,
            .woocommerce-pagination.pagination-style-1 .page-numbers.current,
			.paging-navigation.pagination-style-1 .page-numbers:hover,
			.woocommerce-pagination.pagination-style-1 .page-numbers:hover,
			.page-links.pagination-style-1 > span,
			.page-links.pagination-style-1 > a:hover,
			.variations ul.swatch li:hover span, .variations ul.swatch li.selected span,
            .post a.more-link,
            .shop-main .woocommerce-Reviews #review_form_wrapper .stars:hover a:before,
            .shop-main .woocommerce-Reviews #review_form_wrapper .stars.selected a:before,
            .shop-main .woocommerce-Reviews #review_form_wrapper .stars.selected a.active:before,
            .woocommerce-wishlist.woocommerce #content table.wishlist_table.cart a.remove:hover,
			.woocommerce-MyAccount-navigation-link a:hover,
            .shop_table.cart td.product-name a:hover,
            .wpb-js-composer .vc_tta.vc_tta-style-nbstyle1.vc_tta-shape-none .vc_tta-tabs-container .vc_tta-tabs-list .vc_tta-tab:hover > a,
            .wpb-js-composer .vc_tta.vc_tta-style-nbstyle1.vc_tta-shape-none .vc_tta-tabs-container .vc_tta-tabs-list .vc_tta-tab.vc_active > a,
            .error404 main .pnf-heading,
            .contact-form .uavc-list .uavc-list-content a:hover,
            .contact-form .uavc-list .uavc-list-content .uavc-list-icon,
            .nb-input-group .search-button button:hover,.simplemodal-wrap #simplemodal-login-form .footer__right a,
            .widget .nb-input-group .search-button button:hover,
            .wine_category .vc_tta-style-nbstyle1 .vc_tta-tabs-container .vc_tta-tabs-list .vc_tta-tab.vc_active a .vc_tta-title-text,
            .wine_find_product .text_left span,.wine_find_product .text_left span a,
            .wine_find_product .text_right span,
            .wine_find_product .nb_find_product .nb_find_product-item > div:before,
            .wine_find_product .nb_find_product .nb_find_product-item input,

            .wine_feature .vc_tta-container .vc_tta-tabs-container .vc_tta-tab.vc_active,
            .wine_feature .vc_tta-container .vc_tta-tabs-container .vc_tta-tab:hover,
           
			.form-newsletter .input-group .btn:hover{
                color: " . esc_attr($primary_color) . ";                
            }
            #mega-menu-wrap-primary > ul#mega-menu-primary > li.mega-menu-item > a.mega-menu-link:hover:before,
            #mega-menu-wrap-primary > ul#mega-menu-primary > li.mega-menu-item.mega-current-menu-item > a.mega-menu-link:before{
                background-color: " . esc_attr($primary_color) . "; 
            }
            header .middle-section-wrap .nb_latest_post.nb_new_style .nb_latest_item .author a,
            #mega-menu-wrap-primary > ul#mega-menu-primary > li.mega-menu-item > ul.mega-sub-menu li.mega-menu-item a.mega-menu-link:hover,
            #mega-menu-wrap-primary > ul#mega-menu-primary > li.mega-menu-item > ul.mega-sub-menu > li.mega-menu-row li > ul.mega-sub-menu > li.mega-menu-item .product_item .item h2 a:hover,
            #mega-menu-wrap-primary ul.menu li.menu-item a:hover,
            .product_category .price,
            .featured_product .product_item .price,
            #mega-menu-wrap-primary > ul#mega-menu-primary > li.mega-menu-item > ul.mega-sub-menu li.pro_cat .product_category .product_content h2 a:hover,
            .activate .product_tab .tab{
                color:" . esc_attr($primary_color) . " !important;
            }
            #mega-menu-wrap-primary > ul#mega-menu-primary > li.mega-menu-item > ul.mega-sub-menu li.col-border.mega-menu-row > ul.mega-sub-menu li.mega-menu-column:not(:last-child),
            #mega-menu-wrap-primary > ul#mega-menu-primary > li.mega-menu-item > ul.mega-sub-menu,
            #mega-menu-wrap-primary > ul#mega-menu-primary > li.mega-menu-item > ul.mega-sub-menu > li.mega-menu-row li.col-menu > ul.mega-sub-menu > li.mega-menu-item h4.mega-block-title,
            #mega-menu-wrap-primary > ul#mega-menu-primary > li.mega-menu-item > ul.mega-sub-menu > li.mega-menu-row li > ul.mega-sub-menu > li.mega-menu-item h4.mega-block-title,
            #mega-menu-wrap-primary > ul#mega-menu-primary > li.mega-menu-item > ul.mega-sub-menu li.pro_cat .product_category .product_content{
                border-color: " . esc_attr($primary_color) . ";
            }
            .wine_process .bg_rotate .aio-icon-component .aio-icon:hover{
             color: " . esc_attr($primary_color) . "!important;
            }
			.post a.more-link:hover{
                color: " . esc_attr($secondary_color) . ";                
            }
            .nb-page-title-wrap {
                padding-top: " . esc_attr($page_title_padding) . "px;
                padding-bottom: " . esc_attr($page_title_padding) . "px;"
                . ($page_title_img != '' ? ("background-image: url(" . esc_url($page_title_img) . ");
                background-size: " . $page_title_img_size . ";
                background-position: " . $page_title_img_pos . ";
                background-repeat: " . $page_title_img_repeat . ";
                background-attachment: " . $page_title_img_attachment . ";") : "")
            . "}
            .nb-page-title-wrap a, .nb-page-title-wrap h2, .nb-page-title-wrap nav {
                color: " . esc_attr($page_title_color) . ";
            }            
            .nb-page-title-wrap h2 {
                font-size: " . esc_attr($page_title_size) . "px;
            }
            .woocommerce-page.wc-no-sidebar #primary {
                width: 100%;
            }
            .site-footer {
                background-color: " . $footer_bg . ";
        ";
        if ($footer_bg_img != ''){
            $css .= "
                background-image: url(" . esc_url($footer_bg_img) . ");
                background-size: " . $footer_bg_size . ";
                background-position: " . $footer_bg_pos . ";
                background-repeat: " . $footer_bg_repeat . ";
                background-attachment: " . $footer_bg_attachment . ";";
        }
        $css .= "
            }
            .footer-top-section {
                background-color: " . esc_attr($footer_top_bg) . ";
                border-color: " . esc_attr($footer_top_bor) . ";
            }
            .footer-top-section *, .footer-top-section .input-group .form-control, .footer-top-section .input-group .btn {
                border-color: " . esc_attr($footer_top_bor) . ";
            }
            .footer-top-section h1,
            .footer-top-section h2,
            .footer-top-section h3,
            .footer-top-section h4,
            .footer-top-section h5,
            .footer-top-section h6,
            .footer-top-section .widget-title a{
                color: " . esc_attr($footer_top_heading) . ";
            }
            .footer-top-section,
            .footer-top-section a,
            .footer-top-section .widget ul li a{
                color: " . esc_attr($footer_top_color) . ";
            }
            .footer-top-section a:hover,
            .footer-top-section .widget ul li a:hover{
                color: " . esc_attr($footer_top_hover_color) . ";
            }
            .footer-top-section .widget .tagcloud a{
                border-color: " . esc_attr($footer_top_color) . ";
            }
            .footer-top-section .widget .tagcloud a:hover{
                border-color: " . esc_attr($footer_top_hover_color) . ";
            }
            .footer-bot-section{
                background-color: " . esc_attr($footer_bot_bg) . ";
            }
            .footer-bot-section h1,
            .footer-bot-section h2,
            .footer-bot-section h3,
            .footer-bot-section h4,
            .footer-bot-section h5,
            .footer-bot-section h6,
            .footer-bot-section .widget-title a{
                color: " . esc_attr($footer_bot_heading) . ";
            }
            .footer-bot-section,
            .footer-bot-section a,
            .footer-bot-section .widget ul li a{
                color: " . esc_attr($footer_bot_color) . ";
            }
            .footer-bot-section a:hover,
            .footer-bot-section .widget ul li a:hover{
                color: " . esc_attr($footer_bot_hover_color) . ";
            }
            .footer-bot-section .widget .tagcloud a{
                border-color: " . esc_attr($footer_bot_color) . ";
            }
            .footer-bot-section .widget .tagcloud a:hover{
                border-color: " . esc_attr($footer_bot_hover_color) . ";
            }
            .footer-abs-section{
                color: " . esc_attr($footer_abs_color) . ";
                background-color: " . esc_attr($footer_abs_bg) . ";
                border-color: " . esc_attr($footer_abs_bor) . ";
                padding-top: " . esc_attr($footer_abs_padding) . "px;
                padding-bottom: " . esc_attr($footer_abs_padding) . "px;
            }
            .footer-abs-section a, .footer-abs-section p {
                color: " . esc_attr($footer_abs_color) . ";
            }
            .footer-abs-section a:hover {
                color: " . esc_attr($footer_abs_hover_color) . ";
            }
            .single-blog .nb-page-title .entry-title,
            .single-blog .entry-title{
                font-size: " . esc_attr($blog_title_size) . "px;
            }
            ";
        if ($page_bg_color) {
            $css .= "
                .page #site-wrapper {
                    background-color: " . esc_attr($page_bg_color) . ";
                }
                ";
        }
        if ($page_bg[0]) {
            $css .= "
                .page #site-wrapper {
                    background: url(" . esc_url($page_bg[0]) . ") repeat center center / cover; 
                }
            ";
        }
        $css .= "
            @media (min-width: 576px) {
                .shop-main:not(.wide) .single-product-wrap .product-image {
                    -webkit-box-flex: 0;
                    -ms-flex: 0 0 " . esc_attr($pd_images_width) . "%;
                    flex: 0 0 " . esc_attr($pd_images_width) . "%;                   
                    max-width: " . esc_attr($pd_images_width) . "%;
                }
                .shop-main:not(.wide) .single-product-wrap .entry-summary {
                    -webkit-box-flex: 0;
                    -ms-flex: 0 0 calc(100% - " . esc_attr($pd_images_width) . "%);
                    flex: 0 0 calc(100% - " . esc_attr($pd_images_width) . "%);                   
                    max-width: calc(100% - " . esc_attr($pd_images_width) . "%);
                }
            }
            @media (min-width: 992px) {
        ";

        if ('no-sidebar' !== $blog_sidebar) {
            $css .= "            
                .site-content .blog #primary,
                .site-content .single-blog #primary {
                    -webkit-box-flex: 0;
                    -ms-flex: 0 0 " . esc_attr($blog_width) . "%;
                    flex: 0 0 " . esc_attr($blog_width) . "%;
                    max-width: " . esc_attr($blog_width) . "%;
                } 
                .site-content .blog #secondary,
                .site-content .single-blog #secondary {
                    -webkit-box-flex: 0;
                    -ms-flex: 0 0 calc(100% - " . esc_attr($blog_width) . "%);
                    flex: 0 0 calc(100% - " . esc_attr($blog_width) . "%);
                    max-width: calc(100% - " . esc_attr($blog_width) . "%);
                }                                  
            ";
        }
        if ('left-sidebar' == $blog_sidebar) {
            $css .= "
                .single-blog #primary, .blog #primary {
                    order: 2;
                }
            ";
        }
        if ('left-sidebar' == $shop_sidebar) {
            $css .= "
                .archive.woocommerce .shop-main {
                    order: 2;
                }
            ";
        }

        if ('left-sidebar' == $pd_details_sidebar) {
            $css .= "
                .single-product .shop-main {
                    order: 2;
                }
            ";
        }
        if ('no-sidebar' !== $pd_details_sidebar) {
            $css .= "
                .single-product.wc-pd-has-sidebar .shop-main {
                    -webkit-box-flex: 0;
                    -ms-flex: 0 0 " . esc_attr($pd_details_width) . "%;
                    flex: 0 0 " . esc_attr($pd_details_width) . "%;
                    max-width: " . esc_attr($pd_details_width) . "%;
                }
                .single-product #secondary {
                    -webkit-box-flex: 0;
                    -ms-flex: 0 0 calc(100% - " . esc_attr($pd_details_width) . "%);
                    flex: 0 0 calc(100% - " . esc_attr($pd_details_width) . "%);
                    max-width: calc(100% - " . esc_attr($pd_details_width) . "%);
                }
            ";
        }
        // TODO check this for tag ... ?
        if ('no-sidebar' !== $shop_sidebar) {
            $css .= "
                .archive.woocommerce.wc-has-sidebar .shop-main{
                    -webkit-box-flex: 0;
                    -ms-flex: 0 0 " . esc_attr($wc_content_width) . "%;
                    flex: 0 0 " . esc_attr($wc_content_width) . "%;
                    max-width: " . esc_attr($wc_content_width) . "%;
                }
                .archive.woocommerce.wc-has-sidebar #secondary{
                    -webkit-box-flex: 0;
                    -ms-flex: 0 0 calc(100% - " . esc_attr($wc_content_width) . "%);
                    flex: 0 0 calc(100% - " . esc_attr($wc_content_width) . "%);
                    max-width: calc(100% - " . esc_attr($wc_content_width) . "%);
                }
            ";
        } else {
            $css .= "
                .site-content .shop-main {
                    -webkit-box-flex: 0;
                    -ms-flex: 0 0 100%;
                    flex: 0 0 100%;
                    max-width: 100%;
                }
            ";
        }
        if ('full-width' !== $page_sidebar) {
            $css .= "            
                .page #primary {
                    -webkit-box-flex: 0;
                    -ms-flex: 0 0 " . esc_attr($page_content_width) . "%;
                    flex: 0 0 " . esc_attr($page_content_width) . "%;                 
                    max-width: " . esc_attr($page_content_width) . "%;
                }
                .page #secondary {
                    -webkit-box-flex: 0;
                    -ms-flex: 0 0 calc(100% - " . esc_attr($page_content_width) . "%);
                    flex: 0 0 calc(100% - " . esc_attr($page_content_width) . "%);              
                    max-width: calc(100% - " . esc_attr($page_content_width) . "%);
                }
            ";
        }

        $css .= "
            }
        ";

        return $css;
    }

    public function print_style_head() {
        $style = $this->get_embed_style();

        $style = preg_replace('#/\*.*?\*/#s', '', $style);
        $style = preg_replace('/\s*([{}|:;,])\s+/', '$1', $style);
        $style = preg_replace('/\s\s+(.*)/', '$1', $style);

        wp_add_inline_style('nbfoody_front_font', $style);
    }
    function is_plugin_active_byme( $plugin ) {
        return in_array( $plugin, (array) get_option( 'active_plugins', array() ) );
    }


    public function print_embed_style()
    {
        if (class_exists( 'NetbaseCustomizeClass', false ) ) {
            if(!empty(get_transient('change_customize_css'))) {
                if(get_transient('change_customize_css')==1) {
                    set_transient('change_customize_css', 0, NBT_TIMEOUT_TRANSIENT_CUSTOMIZE);
                    $style = $this->get_embed_style();
                    $style = preg_replace('#/\*.*?\*/#s', '', $style);
                    $style = preg_replace('/\s*([{}|:;,])\s+/', '$1', $style);
                    $style = preg_replace('/\s\s+(.*)/', '$1', $style);
                    if(get_option('customize_save_css')==false) {
                        add_option( 'customize_save_css', $style, '', 'yes' );
                    } else {
                        update_option( 'customize_save_css', $style );
                    }
                    $cp = new NetbaseCustomizeClass();
                    $cp->save_css_customize();
                }
            }
        }
        $my_transient = get_transient('current_load_css');
        if(empty($my_transient) || !$this->is_plugin_active_byme('nb-fw/nb-fw.php')) {
            $this->print_style_head();
        } else {
            if($my_transient==NBT_LOAD_CUSTOMIZE_FROM_HEAD) {
                $this->print_style_head();
            } else {
                if($my_transient==NBT_LOAD_CUSTOMIZE_FROM_CSS_FILE && file_exists(NBT_REAL_PATH_TEMPLATE . NBT_CSS_CUSTOMIZE_PATH . NBT_CSS_CUSTOMIZE_NAME)) {
                    wp_enqueue_style('customize', get_template_directory_uri() . NBT_CSS_CUSTOMIZE_PATH . NBT_CSS_CUSTOMIZE_NAME, array(), NBFoody_VER);
                } else {
                    set_transient('current_load_css', NBT_LOAD_CUSTOMIZE_FROM_HEAD, NBT_TIMEOUT_TRANSIENT_CUSTOMIZE);
                    $this->print_style_head();
                }
            }
        }
    }


    public static function filter_fonts($font)
    {
        $font_args = explode(",", nbfoody_get_options($font));
        if($font_args[0] === 'google') {
            self::handle_google_font($font_args[1]);
        } elseif($font_args[0] === 'custom') {
            self::handle_custom_font($font_args[1]);
        } elseif($font_args[0] === 'standard') {
            self::handle_standard_font($font_args[1]);
        }
    }

    public static function handle_google_font($font_name)
    {
        $font_subset = 'latin,latin-ext';
        $font_families = array();
        $google_fonts = NBFoody_Helper::google_fonts();
        $font_parse = array();


        $font_weight = $google_fonts[$font_name];
        $font_families[$font_name] = isset($font_families[$font_name]) ? array_unique(array_merge($font_families[$font_name], $font_weight)) : $font_weight;

        foreach ($font_families as $font => $font_weight) {
            $font_parse[] = $font . ':' . implode(',', $font_weight);
        }

        if (nbfoody_get_options('subset_cyrillic')) {
            $font_subset .= ',cyrillic,cyrillic-ext';
        }
        if (nbfoody_get_options('subset_greek')) {
            $font_subset .= ',greek,greek-ext';
        }
        if (nbfoody_get_options('subset_vietnamese')) {
            $font_subset .= ',vietnamese';
        }

        $query_args = array(
            'family' => urldecode(implode('|', $font_parse)),
            'subset' => urldecode($font_subset),
        );

        $font_url = add_query_arg($query_args, 'https://fonts.googleapis.com/css');

        $enqueue = esc_url_raw($font_url);

        wp_enqueue_style('nbfoody-google-fonts', $enqueue);
    }

    public static function google_fonts_url()
    {
        $gg_font_arr = array();
        $gg_font_parse = array();
        $google_fonts = NBFoody_Helper::google_fonts();
        $gg_subset = 'latin,latin-ext';

        $body_font = explode(',', nbfoody_get_options('body_font_family'));
        $heading_font = explode(',', nbfoody_get_options('heading_font_family'));

        if($body_font[0] === 'google') {
            $body_name = $body_font[1];
            $body_weight = $google_fonts[$body_name];
            $gg_font_arr[$body_name] = isset($gg_font_arr[$body_name]) ? array_unique(array_merge($gg_font_arr[$body_name], $body_weight)) : $body_weight;
        }

        if($heading_font[0] === 'google') {
            $heading_name = $heading_font[1];
            $heading_weight = $google_fonts[$heading_name];
            $gg_font_arr[$heading_name] = isset($gg_font_arr[$heading_name]) ? array_unique(array_merge($gg_font_arr[$heading_name], $heading_weight)) : $heading_weight;
        }

        if(!empty($gg_font_arr)) {
            foreach ($gg_font_arr as $gg_font_name => $gg_font_weight) {
                $gg_font_parse[] = $gg_font_name . ':' . implode(',', $gg_font_weight);
            }

            if (nbfoody_get_options('subset_cyrillic')) {
                $gg_subset .= ',cyrillic,cyrillic-ext';
            }
            if (nbfoody_get_options('subset_greek')) {
                $gg_subset .= ',greek,greek-ext';
            }
            if (nbfoody_get_options('subset_vietnamese')) {
                $gg_subset .= ',vietnamese';
            }

            $query_args = array(
                'family' => urldecode(implode('|', $gg_font_parse)),
                'subset' => urldecode($gg_subset),
            );

            $font_url = add_query_arg($query_args, 'https://fonts.googleapis.com/css');

            $enqueue = esc_url_raw($font_url);

            wp_enqueue_style('nbfoody-google-fonts', $enqueue);
        }
    }

    public static function upload_mimes($t)
    {
        // Add supported font extensions and MIME types.
        $t['eot'] = 'application/vnd.ms-fontobject';
        $t['otf'] = 'application/x-font-opentype';
        $t['ttf'] = 'application/x-font-ttf';
        $t['woff'] = 'application/font-woff';
        $t['woff2'] = 'application/font-woff2';

        return $t;
    }

    public static function register_required_plugins()
    {
        if(!isset(self::$plugins)) {
            self::$plugins = array(
                array(
                    'name' => 'Netbase Framework',
                    'slug' => 'nb-fw',
                    'required' => true,
                    'version' => '1.3.0',
                    'source' => get_template_directory() . '/plugins/nb-fw.zip',
                    'force_activation' => true,
                ),

            );
        }

        $config = array(
            'id'           => 'nb-foody',                 // Unique ID for hashing notices for multiple instances of TGMPA.
            'default_path' => '',                      // Default absolute path to bundled plugins.
            'menu'         => 'tgmpa-install-plugins', // Menu slug.
            'has_notices'  => true,                    // Show admin notices or not.
            'dismissable'  => true,                    // If false, a user cannot dismiss the nag message.
            'dismiss_msg'  => '',                      // If 'dismissable' is false, this message will be output at top of nag.
            'is_automatic' => false,                   // Automatically activate plugins after installation or not.
            'message'      => '',                      // Message to output right before the plugins table.
        );

        tgmpa( self::$plugins, $config );
    }
}

new NBFoody_Core();