<?php

/* Magazi, WP FUNCTIONS FILE */

add_action('after_setup_theme', 'magazi_theme_setup');

function magazi_theme_setup() {

load_theme_textdomain('magazi', get_template_directory() . '/languages');

//CONTENT WIDTH
global $content_width;
if ( ! isset( $content_width ) )
$content_width = 600;

//THEME SUPPORT

add_theme_support( 'post-formats', array(
		'aside', 'audio', 'chat', 'gallery', 'image', 'link', 'quote', 'status', 'video'
	) );

add_theme_support( 'title-tag' );

add_theme_support('post-thumbnails');

add_theme_support('automatic-feed-links');

add_editor_style( 'editor-style.css' );

add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption'
	) );

//CUSTOM BACKGROUND
$defaults = array(
	'default-color'          => '#FFFFFF',
	'default-image' 	 => '',
	'wp-head-callback'       => '_custom_background_cb',
	'admin-head-callback'    => '',
	'admin-preview-callback' => ''
);
add_theme_support( 'custom-background', $defaults );

//CUSTOM HEADER
$defaults = array(
	'random-default'         => false,
	'width'                  => '',
	'height'                 => '',
	'flex-height'            => true,
	'flex-width'             => true,
	'default-text-color'     => '#424242',
	'header-text'            => true,
	'uploads'                => true,
	'wp-head-callback'       => '',
	'admin-head-callback'    => '',
	'admin-preview-callback' => '',
	'default-image'		 => '#',
);
add_theme_support( 'custom-header', $defaults );

//ADD NAVIGATION
add_action( 'init', 'magazi_register_my_menus' );

//ADD SIDEBARS
add_action( 'widgets_init', 'magazi_register_sidebars' );

//ENQUE STYLESHEETS AND SCRIPTS
add_action( 'wp_enqueue_scripts', 'magazi_enqueue_style' );

}


//FUNCTIONS


//ADD STYLESHEET TO PAGE
function magazi_enqueue_style() {
    wp_enqueue_style( 'magazi-style', get_stylesheet_uri() ); 
}


//MENU NAVIGATION
function magazi_register_my_menus() {
  register_nav_menus(
	array(
	'primary-menu' => __( 'Primary Menu','magazi' ),
	'secondary-menu' => __( 'Secondary Menu','magazi' )
	)
	);
}


//WIDGET AREAS
function magazi_register_sidebars() {
	register_sidebar( array(
		'name' => __( 'Main sidebar', 'magazi' ),
		'id' => __( 'sidebar-1', 'magazi' ),
		'description' => __( 'First sidebar widget area', 'magazi' ),
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget' => '</div>',
		'before_title' => '<h2 class="widget-title">',
		'after_title' => '</h2>',
	) );

	register_sidebar( array(
		'name' => __( 'Footer with 4 areas', 'magazi' ),
		'id' => __( 'footer-1', 'magazi' ),
		'description' => __( 'Footer widget area', 'magazi' ),
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget' => '</div>',
		'before_title' => '<h2 class="widget-title">',
		'after_title' => '</h2>',
	) );

	register_sidebar( array(
		'name' => __( 'Top banner for ads etc', 'magazi' ),
		'id' => __( 'banner-1', 'magazi' ),
		'description' => __( 'Banner widget area on first page', 'magazi' ),
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget' => '</div>',
		'before_title' => '<h2 class="widget-title">',
		'after_title' => '</h2>',
	) );

}

//SCRIPTS THREADED COMMENTS
function magazi_load_scripts() {

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


?>