<?php 

// Sanchari functions and definitions
if ( ! function_exists( 'sanchari_wp_theme_setup' ) ) :
	function sanchari_wp_theme_setup() {
	load_theme_textdomain( 'sanchari_wp_theme_lan', get_template_directory() . '/languages' );

}
endif;
add_action( 'after_setup_theme', 'sanchari_wp_theme_setup' );


/** custom background support */
		 
		$background_args = array(
		  'default-color'  => 'f0f0f0',
		  'default-repeat' => 'fixed',
		);
		add_theme_support( 'custom-background', $background_args );
		
		
		if ( ! isset( $content_width ) ) $content_width = 1170;

/**
 * Enqueue scripts and styles
 */
 
 function sanchari_wp_theme_scripts_and_styles() {
 
      //load wp masonry from Wordpress
	  
	  wp_enqueue_script( 'jquery-masonry', array( 'jquery' ) );
 
 
 	/*
	 * Adds JavaScript to pages with the comment form to support
	 * sites with threaded comments (when in use).
	 */
	 
	if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
		wp_enqueue_script( 'comment-reply' );
		
	
		
	
	// load bootstrap css
	wp_enqueue_style( 'sanchari_wp_theme_bootstrap_css', get_template_directory_uri() . '/css/bootstrap.min.css' );
	
	// load bootstrap-theme.min css
	wp_enqueue_style( 'sanchari_wp_theme_bootstrap_theme_css', get_template_directory_uri() . '/css/bootstrap-theme.min.css' );
	
	
	//load bootstrap js
		wp_enqueue_script('sanchari_wp_theme_bootstrap_js', get_template_directory_uri().'/js/bootstrap.min.js', array('jquery') );
		
	//load modernizr js
	
	wp_enqueue_script('sanchari_wp_theme_modernizr_js', get_template_directory_uri().'/js/modernizr-2.6.2.min.js', array('jquery') );
	
	// load Font Awesome css
	
	wp_enqueue_style( 'sanchari_wp_theme_font_awesome', get_template_directory_uri() . '/css/font-awesome.min.css' );
	
	// load  respond js
	
	wp_enqueue_script('sanchari_wp_theme_respond_js', get_template_directory_uri().'/js/respond.js', array('jquery') );
	
	
	// load html5shiv js
	
	wp_enqueue_script('sanchari_wp_theme_html5shiv_js', get_template_directory_uri().'/js/html5shiv.js', array('jquery') );
	
	// load navbar.matchMedia.js 
	wp_enqueue_script('sanchari_wp_theme_navbar_matchMedia.js', get_template_directory_uri().'/js/navbar.matchMedia.js', array('jquery') );
	
	
	//load active js
	
	wp_enqueue_script('sanchari_wp_theme_active_js', get_template_directory_uri().'/js/active.js', array('jquery') );
	
	// Loads our main stylesheet.
	wp_enqueue_style( 'sanchari_wp_theme_main_css', get_stylesheet_uri() );
	
	
}
add_action( 'wp_enqueue_scripts', 'sanchari_wp_theme_scripts_and_styles' );

//Set up theme defaults and register support for various WordPress features

/* Enable support for post-thumbnails */
    add_theme_support( 'post-thumbnails'); // Add it for posts
	
	
/**
	 * Add default posts and comments RSS feed links to head
	 */
	add_theme_support( 'automatic-feed-links' );
	add_theme_support( 'custom-header' );
	
	
	
	
/* This code enable Shortcodes in WordPress Text Widget */

add_filter('widget_text', 'do_shortcode');



	
/* post-excerpt and read more in index.php */

/* code for read more  in functions.php*/
function sanchari_wp_theme_excerpt($num) {
$limit = $num+1;
$sanchari_wp_theme_excerpt = explode(' ', get_the_excerpt(), $limit);
array_pop($sanchari_wp_theme_excerpt);
$sanchari_wp_theme_excerpt = implode(" ",$sanchari_wp_theme_excerpt)." <a href='" .get_permalink($post->ID) ." ' class='".readmore."'>.</a>";
echo $sanchari_wp_theme_excerpt;
}

//load feature images
include_once( 'inc/feature_images.php' );

//load menu 
include_once( 'inc/menus.php' );

//load widgets
include_once('inc/widgets.php');




//load wp_bootstrap_navwalker (bt dropdown Integrate wp)
include_once('inc/wp_bootstrap_navwalker.php');

//load wp_custom-header)
include_once('inc/custom-header.php');


//add styles to nav a css class 

add_filter('next_posts_link_attributes', 'sanchari_wp_theme_posts_link_attributes_1');
add_filter('previous_posts_link_attributes', 'sanchari_wp_theme_posts_link_attributes_2');

function sanchari_wp_theme_posts_link_attributes_1() {
    return 'class="next_navigation"';
}
function sanchari_wp_theme_posts_link_attributes_2() {
    return 'class="previous_navigation"';
}

//admin bar to bottom

function sanchari_wp_theme_custom_move_admin_bar() {
    echo '
    <style type="text/css">
    body {
    margin-top: -28px;
    padding-bottom: 28px;
    }
    body.admin-bar #wphead {
       padding-top: 0;
    }
    body.admin-bar #footer {
       padding-bottom: 28px;
    }
    #wpadminbar {
        top: auto !important;
        bottom: 0;
    }
    #wpadminbar .quicklinks .menupop ul {
        bottom: 28px;
    }
    </style>';
}
// // on backend area
// if ( is_admin_bar_showing() )
// {add_action( 'admin_head', 'sanchari_wp_theme_custom_move_admin_bar' );}
// on frontend area
if ( is_admin_bar_showing() )
{add_action( 'wp_head', 'sanchari_wp_theme_custom_move_admin_bar' );}






