<?php
/**
 * Superior defining constants, adding files and WordPress core functionality.
 *
 * Defining some constants, loading all the required files and Adding some core functionality.
 * @uses add_theme_support() To add support for post thumbnails and automatic feed links.
 * @uses register_nav_menu() To add support for navigation menu.
 *
 * @package Theme Horse
 * @subpackage Superior
 * @since Superior 1.0
 */
	add_action('after_setup_theme', 'superior_setup');
	/**
	 * This content width is based on the theme structure and style.
	 */
	function superior_setup()
	{
		global $content_width;
		if (!isset($content_width)) {
			$content_width = 770;
		}

		/*
		 * Enable support for Post Formats.
		 *
		 * See: https://codex.wordpress.org/Post_Formats
		 */
		add_theme_support( 'post-formats', array(
			'quote', 'link'
		) );
	}
	add_action('superior_init', 'superior_constants', 10);
	/**
	 * This function defines the Superior theme constants
	 *
	 * @since 1.0
	 */
	function superior_constants()
	{
		/** Define Directory Location Constants */
		define('SUPERIOR_PARENT_DIR', get_template_directory());
		define('SUPERIOR_CHILD_DIR', get_stylesheet_directory());
		define('SUPERIOR_INC_DIR', SUPERIOR_PARENT_DIR . '/inc');
		define('SUPERIOR_ADMIN_DIR', SUPERIOR_INC_DIR . '/admin');
		define('SUPERIOR_JS_DIR', SUPERIOR_PARENT_DIR . '/js');
		define('SUPERIOR_FUNCTIONS_DIR', SUPERIOR_INC_DIR . '/functions');
		define('SUPERIOR_SHORTCODES_DIR', SUPERIOR_INC_DIR . '/footer-info');
		define('SUPERIOR_STRUCTURE_DIR', SUPERIOR_INC_DIR . '/structure');
		if (!defined('SUPERIOR_LANGUAGES_DIR'))
		/** So we can define with a child theme */ {
			define('SUPERIOR_LANGUAGES_DIR', SUPERIOR_PARENT_DIR . '/languages');
		}
		define('SUPERIOR_WIDGETS_DIR', SUPERIOR_INC_DIR . '/widgets');
	}
	add_action('superior_init', 'superior_load_files', 15);
	/**
	 * Loading the included files.
	 *
	 * @since 1.0
	 */
	function superior_load_files()
	{
		/**
		 * superior_add_files hook
		 *
		 * Adding other addtional files if needed.
		 */
		do_action('superior_add_files');
		/** Load functions */
		require_once (SUPERIOR_FUNCTIONS_DIR . '/i18n.php');

		require_once (SUPERIOR_FUNCTIONS_DIR . '/custom-header.php');

		require_once (SUPERIOR_FUNCTIONS_DIR . '/functions.php');

		require_once (SUPERIOR_FUNCTIONS_DIR . '/customizer.php');

		require_once (SUPERIOR_ADMIN_DIR . '/superior-metaboxes.php');

		/** Load Footer Info */
		require_once (SUPERIOR_SHORTCODES_DIR . '/superior-footer-info.php');

		/** Load Structure */
		require_once (SUPERIOR_STRUCTURE_DIR . '/header-extensions.php');

		require_once (SUPERIOR_STRUCTURE_DIR . '/footer-extensions.php');

		require_once (SUPERIOR_STRUCTURE_DIR . '/content-extensions.php');

		/** Load Widgets and Widgetized Area */
		require_once (SUPERIOR_WIDGETS_DIR . '/superior-widgets.php');

	}
	add_action('superior_init', 'superior_core_functionality', 20);
	/**
	 * Adding the core functionality of WordPess.
	 *
	 * @since 1.0
	 */
	function superior_core_functionality()
	{
		/**
		 * superior_add_functionality hook
		 *
		 * Adding other addtional functionality if needed.
		 */
		do_action('superior_add_functionality');
		// 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');
		// This theme uses Featured Images (also known as post thumbnails) for per-post/per-page.
		add_theme_support('post-thumbnails');
		// This theme uses wp_nav_menu() in two locations.
		register_nav_menus(array(
			'primary' => __('Primary Navigation', 'superior') ,
			'social' => __('Social Navigation', 'superior') ,
		));

		// Support for WooCommerce Product gallery
		add_theme_support( 'wc-product-gallery-zoom' );
		add_theme_support( 'wc-product-gallery-lightbox' );
		add_theme_support( 'wc-product-gallery-slider' );
		
		/* 
		* Enable support for custom logo. 
		* 
		*/ 
		add_theme_support( 'custom-logo', array( 
			'height'      => 100, 
			'width'       => 260, 
			'flex-height' => true,
			'flex-width' => true,
		) );
		/**
		 * This theme supports custom background color and image
		 */
		add_theme_support('custom-background');
	}
		/**
		 * superior_init hook
		 *
		 * Hooking some functions of functions.php file to this action hook.
		 */
		do_action('superior_init');
	function superior_get_featured_posts()
	{
		/**
		 * Filter the featured posts to return in Superior.
		 * @param array|bool $posts Array of featured posts, otherwise false.
		 */
		return apply_filters('superior_get_featured_posts', array());
	}
		/**
		 * A helper conditional function that returns a boolean value.
		 * @return bool Whether there are featured posts.
		 */
	function superior_has_featured_posts()
	{
		return !is_paged() && (bool)superior_get_featured_posts();
	}
function superior_get_option_defaults() {
	global $superior_array_of_default_settings;
	$superior_array_of_default_settings = array(
		'superior_header_settings' => 'header_text',
		'superior-img-upload-header-logo' =>'',
		'superior_categories'	=>array(),
		'superior_disable_setting'	=>0,
		'superior_search_header_settings' => 0,
		'superior_site_title_setting' => 0,
		'superior-img-upload-site-title' => '',
		'superior_disable_slider' =>1,
		'superior_featured_post_slider'	=> array(),
		'superior_slider_quantity'	=> '4',
		'superior_slider_type'	=> 'post-slider',
		'superior_transition_effect' => 'fade',
		'superior_transition_delay' => '4',
		'superior_transition_duration' => '1',
		'superior_disable_setting'	=>0,
		'superior_design_layout' => 'on',
		'superior_content_layout' => 'right',
		'superior_exclude_slider_post'	=> 0,
		'superior_post_author'	=> 0,
		'superior_post_date'	=>0,
		'superior_post_comments'	=>0,
		'superior_post_category'	=>0,
		'superior_post_tags'	=>0
	);
	return apply_filters( 'superior_get_option_defaults', $superior_array_of_default_settings );
}
add_action( 'after_setup_theme', 'superior_woocommerce_support' );
function superior_woocommerce_support() {
    add_theme_support( 'woocommerce' );
}
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10);

remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);


add_action('woocommerce_before_main_content', 'superior_wrapper_start', 10);
add_action('woocommerce_after_main_content', 'superior_wrapper_end', 10);
function superior_wrapper_start() { echo '<div id="primary"> <div id="main">'; }

function superior_wrapper_end() { echo '</div></div>'; }

if ( ! function_exists( 'superior_the_custom_logo' ) ) : 
	/** 
	 * Displays the optional custom logo. 
	 * 
	 * Does nothing if the custom logo is not available. 
	 */ 
	function superior_the_custom_logo() { 
	    if ( function_exists( 'the_custom_logo' ) ) { 
	        the_custom_logo(); 
	    } 
	} 
endif;
if (!function_exists('wp_body_open')) {
	function wp_body_open() {
		do_action('wp_body_open');
	}
}

?>