<?php
require get_template_directory() . '/inc/template-tags.php';
require get_template_directory() . '/inc/extras.php';
require get_template_directory() . '/inc/customizer.php';
require get_template_directory() . '/inc/widgets.php';
require get_template_directory() . '/inc/search-improve.php';

if ( ! isset( $content_width ) ) {
	$content_width = 670;
}

if ( ! function_exists( 'dw_gamez_setup' ) ) {
	function dw_gamez_setup() {
		add_editor_style();
		add_theme_support( 'automatic-feed-links' );
		register_nav_menus( array(
			'primary' => __( 'Primary Menu', 'dw-gamez' ),
			'top-header' => __( 'Top Header Menu', 'dw-gamez' ),
			'footer-nav' => __( 'Footer Menu', 'dw-gamez' ),
		) );
		add_theme_support( 'post-formats', array( 'video', 'gallery' ) );

		add_theme_support( 'custom-background', apply_filters( 'dw_gamez_custom_background_args', array(
			'default-color' => '333333',
			'default-image' => '',
		) ) );
		add_theme_support( 'post-thumbnails' );
		add_image_size( 'homepage-wide', 670, 9999 );
		add_image_size( 'homepage-narrow', 210, 210, true );
	}
}
add_action( 'after_setup_theme', 'dw_gamez_setup' );

function dw_gamez_widgets_init() {
	register_sidebar( array(
		'name'          => __( 'Sidebar', 'dw-gamez' ),
		'id'            => 'sidebar-1',
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h3 class="widget-title">',
		'after_title'   => '</h3>',
	) );
	register_sidebar( array(
		'name'          => __( 'Feature 1', 'dw-gamez' ),
		'id'            => 'feature-1',
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h3 class="widget-title">',
		'after_title'   => '</h3>',
	) );
	register_sidebar( array(
		'name'          => __( 'Feature 2', 'dw-gamez' ),
		'id'            => 'feature-2',
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h3 class="widget-title">',
		'after_title'   => '</h3>',
	) );
	register_sidebar( array(
		'name'          => __( 'Feature 3', 'dw-gamez' ),
		'id'            => 'feature-3',
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h3 class="widget-title">',
		'after_title'   => '</h3>',
	) );
	register_sidebar( array(
		'name'          => __( 'Content Top', 'dw-gamez' ),
		'id'            => 'content-1',
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h3 class="widget-title">',
		'after_title'   => '</h3>',
	) );
	register_sidebar( array(
		'name'          => __( 'Content bottom', 'dw-gamez' ),
		'id'            => 'content-2',
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h3 class="widget-title">',
		'after_title'   => '</h3>',
	) );
	register_sidebar( array(
		'name'          => __( 'Footer 1', 'dw-gamez' ),
		'id'            => 'footer-1',
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h3 class="widget-title">',
		'after_title'   => '</h3>',
	) );
	register_sidebar( array(
		'name'          => __( 'Footer 2', 'dw-gamez' ),
		'id'            => 'footer-2',
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h3 class="widget-title">',
		'after_title'   => '</h3>',
	) );
	register_sidebar( array(
		'name'          => __( 'Footer 3', 'dw-gamez' ),
		'id'            => 'footer-3',
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h3 class="widget-title">',
		'after_title'   => '</h3>',
	) );
	register_sidebar( array(
		'name'          => __( 'Footer 4', 'dw-gamez' ),
		'id'            => 'footer-4',
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h3 class="widget-title">',
		'after_title'   => '</h3>',
	) );
	register_sidebar( array(
		'name'          => __( 'Footer 5', 'dw-gamez' ),
		'id'            => 'footer-5',
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h3 class="widget-title">',
		'after_title'   => '</h3>',
	) );
}
add_action( 'widgets_init', 'dw_gamez_widgets_init' );

function dw_gamez_scripts() {
	wp_enqueue_style( 'dw-gamez-main', get_template_directory_uri() . '/assets/css/main.css' );
	wp_enqueue_style( 'dw-gamez-style', get_stylesheet_uri() );
	wp_enqueue_style( 'dw-gamez-font-awesome', get_template_directory_uri() . '/assets/inc/font-awesome/css/font-awesome.min.css' );
	wp_enqueue_script( 'dw-gamez-modernizr', get_template_directory_uri() . '/assets/js/modernizr-2.6.2.min.js', array(), '20130716' );
	if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
		wp_enqueue_script( 'comment-reply' );
	}
}
add_action( 'wp_enqueue_scripts', 'dw_gamez_scripts' );

function dw_gamez_footer_scripts() {
	wp_enqueue_script( 'jquery' );
	wp_enqueue_script( 'dw-gamez-bootstrap', get_template_directory_uri() . '/assets/js/bootstrap.min.js', array(), '20130716' );
	wp_enqueue_script( 'dw-gamez-cookie', get_template_directory_uri() . '/assets/js/jquery.cookie.js', array(), '20130716' );
	wp_enqueue_script( 'dw-gamez-main', get_template_directory_uri() . '/assets/js/main.js', array(), '20130716' );
}
add_action( 'wp_footer', 'dw_gamez_footer_scripts' );

// load style for dw qa plugin
if( !function_exists('dwqa_gamez_scripts') ){
	function dwqa_gamez_scripts(){
	    wp_enqueue_style( 'dw-gamez-qa', get_stylesheet_directory_uri() . '/dwqa-templates/style.css' );
	}
	add_action( 'wp_enqueue_scripts', 'dwqa_gamez_scripts' );
}