<?php
/**
 * doo functions and definitions
 *
 * @package doo
 */

/**
 * Set the content width based on the theme's design and stylesheet.
 */
global $content_width;
if ( ! isset( $content_width ) ) {
	$content_width = 650; /* pixels */
}

if ( ! function_exists( 'doo_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 doo_setup() {

	/*
	 * Make theme available for translation.
	 * Translations can be filed in the /languages/ directory.
	 * If you're building a theme based on doo, use a find and replace
	 * to change 'doo' to the name of your theme in all the template files
	 */
	load_theme_textdomain( 'doo', 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 http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
	 */

	// This theme uses wp_nav_menu() in one location.
	register_nav_menus( array(
		'menu-1' => __( 'Primary Menu', 'doo' ),
	) );

	/*
	 * 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 http://codex.wordpress.org/Post_Formats
	 */
	add_theme_support( 'post-formats', array(
		 'aside', 'image', 'video', 'quote', 'link', 'gallery', 'chat', 'audio', 'status',
	) );
	
	add_theme_support( 'post-thumbnails' );
}
endif; // doo_setup
add_action( 'after_setup_theme', 'doo_setup' );

/**
 * Enqueue scripts and styles.
 */
function doo_theme_scripts() {
	wp_enqueue_style( 'doo-style', get_stylesheet_uri() );
	wp_enqueue_style( 'doo_font-awesome', get_template_directory_uri() . '/font-awesome/css/font-awesome.min.css', array() );
	wp_enqueue_style( 'doo_google-fonts', '//fonts.googleapis.com/css?family=Open+Sans:400,400italic,700,700italic', array() );

	wp_enqueue_script( 'doo-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20120206', true );

	wp_enqueue_script( 'doo-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130115', true );
	
	wp_enqueue_script( 'doo-fitvids', get_template_directory_uri() . '/js/jquery.fitvids.js', array('jquery'), '' );
	wp_enqueue_script( 'doo-fitvids-doc-ready', get_template_directory_uri() . '/js/fitvids-doc-ready.js', array( 'jquery' ), '' );
	
	wp_enqueue_script( 'doo-basejs', get_template_directory_uri() . '/js/base.js',array('jquery'), '' );

	wp_enqueue_script( 'html5shiv', get_template_directory_uri() . '/js/html5shiv.js', array(), '', true );
	wp_script_add_data( 'html5shiv', 'conditional', 'lt IE 9' );
	
	if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
		wp_enqueue_script( 'comment-reply' );
	}
}
add_action( 'wp_enqueue_scripts', 'doo_theme_scripts' );

/**
 * Custom template tags for this theme.
 */
require get_template_directory() . '/inc/template-tags.php';

/**
 * Custom functions that act independently of the theme templates.
 */
require get_template_directory() . '/inc/extras.php';

/**
 * Customizer additions.
 */
require get_template_directory() . '/inc/customizer.php';

/**
 * Load Jetpack compatibility file.
 */
require get_template_directory() . '/inc/jetpack.php';

require_once( get_template_directory() . '/inc/functions.php' );
require_once( get_template_directory() . '/inc/header-functions.php' );
require_once( get_template_directory() . '/inc/widgets/widgets.php' );
?>