<?php


/*********************
SCRIPTS & ENQUEUEING
*********************/

function thefashblog_scripts_and_styles() {

  global $wp_styles; // call global $wp_styles variable to add conditional wrapper around ie stylesheet the WordPress way

		// modernizr (without media query polyfill)
		wp_enqueue_script( 'thefashblog-modernizr', get_template_directory_uri() . '/library/js/libs/modernizr.custom.min.js', array('jquery'), '2.5.3', false );

		
		wp_enqueue_style( 'thefashblog-scroll-style', get_template_directory_uri() . '/library/css/jquery.mCustomScrollbar.css', array(), '', 'all' );
		wp_enqueue_style( 'font-awesome', get_template_directory_uri() . '/css/font-awesome.min.css', array(), '', 'all' );
		// ie-only style sheet
		wp_enqueue_style( 'thefashblog-ie-only', get_template_directory_uri() . '/library/css/ie.css', array(), '' );

		// register main stylesheet
		wp_enqueue_style('google-font-pt-serif', '//fonts.googleapis.com/css?family=PT+Serif:400,400italic,700,700italic');
		
		if ( is_home() ){
			wp_enqueue_style( 'thefashblog_slick', get_template_directory_uri() . '/library//slick/slick.css', array(), '' );
            wp_enqueue_style( 'thefashblog_slick_theme', get_template_directory_uri() . '/library//slick/slick-theme.css', array(), '' );
		}
		

	    // comment reply script for threaded comments
	    if ( is_singular() AND comments_open() AND (get_option('thread_comments') == 1)) {
			  wp_enqueue_script( 'comment-reply' );
	    }

		//adding scripts file in the footer
		wp_enqueue_script( 'jquery-mCustomScrollbar', get_template_directory_uri() . '/library/js/jquery.mCustomScrollbar.concat.min.js', array('jquery'), '', true);
		wp_enqueue_script( 'thefashblog-js', get_template_directory_uri() . '/library/js/scripts.js', array('jquery'), '', true );

		if ( is_home() ){
			wp_enqueue_script( 'jquery-slick', get_template_directory_uri() . '/library//slick/slick.min.js', array(), '', true );
			wp_enqueue_script( 'thefashblog-scripts-home', get_template_directory_uri() . '/library/js/scripts-home.js', array('jquery'), '', true );
		}
		$wp_styles->add_data( 'thefashblog-ie-only', 'conditional', 'lt IE 9' ); // add conditional wrapper around ie stylesheet

}
/*********************
THEME SUPPORT
*********************/

// Adding WP 3+ Functions & Theme Support
function thefashblog_theme_support() {

	// wp thumbnails (sizes handled in functions.php)
	add_theme_support( 'post-thumbnails' );
	// default thumb size
	set_post_thumbnail_size( 600, 600 );
	
	// wp custom background (thx to @bransonwerner for update)
	add_theme_support( 'custom-background',
	    array(
	    'default-image' => '',    // background image default
	    'default-color' => 'ffffff',    // background color default (dont add the #)
	    'wp-head-callback' => '_custom_background_cb',
	    'admin-head-callback' => '',
	    'admin-preview-callback' => ''
	    )
	);

	// rss thingy
	add_theme_support('automatic-feed-links');

	// to add header image support go here: http://themble.com/support/adding-header-background-image-support/

	add_theme_support( 'title-tag' );

	// registering wp3+ menus
	register_nav_menus(
		array(
			'main-nav' => __( 'The Main Menu', 'the-fash-blog' ),   // main nav in header
		)
	);
	$args = array(
	'default-image'          => '',
	'width'                  => 0,
	'height'                 => 0,
	'flex-height'            => false,
	'flex-width'             => false,
	'uploads'                => true,
	'random-default'         => false,
	'header-text'            => true,
	'default-text-color'     => '000000',
	'wp-head-callback'       => '',
	'admin-head-callback'    => '',
	'admin-preview-callback' => '',
	);
	add_theme_support( 'custom-header', $args );

	add_theme_support( 'custom-logo' );

} /* end thefashblog theme support */


function thefashblog_more_link_scroll( $link ) {
	$link = preg_replace( '|#more-[0-9]+|', '', $link );
	return $link;
}
add_filter( 'the_content_more_link', 'thefashblog_more_link_scroll' );