<?php

/**
 * Theme functions and definitions
 *
 * @package _xs
 */
 
/** ----------------------------------------------------------------------------
*** GENERAL CONFIG
*** --------------------------------------------------------------------------*/

/**
 * Define Current Version number & Theme Name.
 */
define( 'XS_THEME', 'onEvent' );

define( 'XS_VERSION', '1.0.0' );
define('XS_THEME_URL', get_template_directory_uri());
/**
 * Set the content width based on the theme's design and stylesheet.
 */
if ( ! isset( $content_width ) ) {
	$content_width = 1170; /* pixels */
}

if ( ! function_exists( 'xs_setup' ) ) :
/**
 * Sets up theme defaults and registers support for various WordPress features.
 *
 * Note that this function is hooked into the after_setup_theme hook, which
 * runs before the init hook. The init hook is too late for some features, such
 * as indicating support for post thumbnails.
 */
function xs_setup() {

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

	// Add default posts and comments RSS feed links to head.
	add_theme_support( 'automatic-feed-links' );
	
	/* extra theme supports */
	add_theme_support( 'custom-header' );
	add_editor_style( 'editor-style.css' );
        /*
         * 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 http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
	 */
	//add_theme_support( 'post-thumbnails' );

	// This theme uses wp_nav_menu() in one location.
	register_nav_menus( array(
		'primary' => __( 'Primary Menu', 'xs' )
	) );

	/*
	 * 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'
	) );

	/*
	 * Add theme thumbnail support and other custom sizes
	 */
	add_theme_support( 'post-thumbnails' );
	set_post_thumbnail_size( 300, 300, array( 'center', 'center' ) ); // Hard crop center center
	
	if ( function_exists( 'add_image_size' ) ) {
		add_image_size( 'gallery-thumb', 300, 200, array( 'center', 'center' ) );
		add_image_size( 'medium', 432, 291, array( 'center', 'center' ) );
		add_image_size( 'wide', 700, 350, array( 'center', 'center' ) );
	}

	/*
	 * Enable support for Post Formats.
	 * See http://codex.wordpress.org/Post_Formats
	 */
	add_theme_support( 'post-formats', array(
		//'aside', 'gallery', 'link', 'image', 'quote', 'status', 'video', 'audio', 'chat'
	) );

	// Set up the WordPress core custom background feature.
	add_theme_support( 'custom-background', apply_filters( 'xs_custom_background_args', array(
		'default-color' => 'ffffff',
		'default-image' => ''
	) ) );
}
endif; // xs_setup
add_action( 'after_setup_theme', 'xs_setup' );


/**
 * Register widget area.
 *
 * @link http://codex.wordpress.org/Function_Reference/register_sidebar
 */
function xs_widgets_init() {

	// Blog Sidebar (blog-sidebar)
	register_sidebar( array(
		'name'          => __( 'OnEvent Sidebar', 'xs' ),
		'id'            => 'sidebar-1',
		'description'   => '',
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget'  => '</div>',
		'before_title'  => '<div class="widget-head border-color"><h4 class="widget-title">',
		'after_title'   => '</h4></div>',
	) );

}
add_action( 'widgets_init', 'xs_widgets_init' );

//remove_filter ('the_content', 'wpautop');



/** ----------------------------------------------------------------------------
*** INCLUDING ENQUEUE FILES
*** --------------------------------------------------------------------------*/

/**
 * enqueue dynamic inline scripts
 */
require( get_template_directory(). '/framework/configurations/enqueue.php' );





/** ----------------------------------------------------------------------------
*** INCLUDING FRAMEWORK & NECESSARY FILES
*** --------------------------------------------------------------------------*/

/**
 * Loads Theme Framework ()
 */
require_once( get_template_directory() . '/framework/option-tree/ot-loader.php' );

/**
 * Custom Post Type & Meta Boxes
 */
require( get_template_directory(). '/framework/components/custom-posts/loader.php' );

/**
 * Include the TGM_Plugin_Activation class.
 */
require_once( get_template_directory() . '/framework/components/tgm-activation/class-tgm-plugin-activation.php' );

/**
 * WP Bootstrap Walker-menu
 */
require_once( get_template_directory() . '/framework/components/walker-menu/wp_bootstrap_navwalker.php' );
require_once( get_template_directory() . '/framework/components/custom-menu-option/menu-item-custom-fields.php' );


/**
 * Load WP Importer.
 */
require ( get_template_directory() . '/framework/components/importer/xs-importer.php' );
require ( get_template_directory() . '/framework/components/importer/options-data.php' );

/**
 * Load Event Register.
 */
require ( get_template_directory() . '/framework/components/event-user-register/ajax-call.php' );

/**
 * Load Shortcode file.
 */
require ( get_template_directory() . '/framework/shortcodes/xs_shortcode.php' );
require ( get_template_directory() . '/framework/shortcodes.php' );




/** ----------------------------------------------------------------------------
*** INCLUDING CONFIGURATION FILES
*** --------------------------------------------------------------------------*/

/**
 * Theme Options
 */
require( get_template_directory() . '/framework/configurations/theme-options.php' ); // Theme Options
require( get_template_directory() . '/framework/configurations/tab-options.php' ); // Event Options

/**
 * Custom menu options
 */
require( get_template_directory() . '/framework/configurations/custom-nav-options.php' );

/**
 * Firing required plugins to TGM_Plugin_Activation class.
 */
require( get_template_directory() . '/framework/configurations/tgm-required-plugins.php' );

/**
 * Theme Customizer
 */
require( get_template_directory() . '/framework/configurations/customizer.php' );

/**
 * Load Jetpack compatibility file.
 */
require ( get_template_directory() . '/framework/configurations/jetpack.php' );





/** ----------------------------------------------------------------------------
*** INCLUDING EXTRA FUNCTION FILES
*** --------------------------------------------------------------------------*/

/**
 * Custom template tags.
 */
require ( get_template_directory() . '/framework/configurations/template-tags.php' );

/**
 * Custom functions that act independently.
 */
require ( get_template_directory() . '/framework/configurations/extra-functions.php' );


