<?php
/*************************************
* Define Paths
*************************************/
if ( ! isset( $content_width ) ) $content_width = auto;
add_theme_support( $feature );
define("THEME_NAME", 'MyTheme');
get_template_part( 'nhp-options');
get_template_part('widget/social_widget' );
get_template_part('widget/most_viewed_artical' );
get_template_part('widget/most_commented_artical' );
get_template_part('widget/advertisement-widget' );
get_template_part('breadcrumb' );
add_theme_support( 'automatic-feed-links' );
add_theme_support( "custom-header", $args );
add_theme_support( "custom-background", $args );
function my_theme_add_editor_styles() {
    add_editor_style( 'custom-editor-style.css' );
}
add_action( 'after_setup_theme', 'my_theme_add_editor_styles' );


define("THEME_DIR", get_template_directory_uri());
/*--- REMOVE GENERATOR META TAG ---*/
remove_action('wp_head', 'wp_generator');
add_theme_support( 'post-thumbnails' );
add_image_size( 'sidebar-thumb', 88, 69, true );
add_image_size( 'category-thumb', 710, 300, true );
add_image_size( 'slider-thumb', 190, 160, true );
add_image_size( 'vertical-slider-large', 548, 275, true );
add_image_size( 'vertical-slider-small', 92,63, true );
/*************************************
* Register Script And Styles
*************************************/
//******************** ENQUEUE STYLES**************************
     
function enqueue_styles() {
     
    /** REGISTER css/screen.css **/
    wp_register_style( 'bootstrap-style', THEME_DIR . '/css/bootstrap.min.css', array(), '1', 'all' );
	wp_register_style( 'font-awesome-style', THEME_DIR . '/css/font-awesome.min.css', array(), '1', 'all' );
	wp_register_style( 'media-style', THEME_DIR . '/css/ media.css', array(), '1', 'all' );
	wp_register_style( 'slider-owl-style', THEME_DIR . '/css/owl.carousel.css', array(), '1', 'all' );
	wp_register_style( 'main-style', THEME_DIR . '/css/style.css', array(), '1', 'all' );
	wp_enqueue_style( 'bootstrap-style' );
    wp_enqueue_style( 'font-awesome-style' );
	wp_enqueue_style( 'media-style' );
	wp_enqueue_style( 'slider-owl-style' );
	wp_enqueue_style( 'main-style' );
         
}
add_action( 'wp_enqueue_scripts', 'enqueue_styles' );
     
//******************** ENQUEUE SCRIPTS**************************
     
function enqueue_scripts() {
     
    /** REGISTER HTML5 Shim **/
    wp_register_script( 'html5-shim', 'http://html5shim.googlecode.com/svn/trunk/html5.js', array( 'jquery' ), '1', false );
    wp_enqueue_script( 'html5-shim' );
         
    /** REGISTER HTML5 OtherScript.js **/
    wp_register_script( 'bootsrap-script', THEME_DIR . '/js/bootstrap.min.js', array( 'jquery' ), '1', false );
	wp_register_script( 'flexi-script', THEME_DIR . '/js/jquery.flexisel.js', array( 'jquery' ), '1', false );
	wp_register_script( 'jquery-script', THEME_DIR . '/js/jquery.min.js', array( 'jquery' ), '1', false );
	wp_register_script( 'jquery-script2', THEME_DIR . '/js/jssor.js', array( 'jquery' ), '1', false );
	wp_register_script( 'jassor-slider-script', THEME_DIR . '/js/jssor.slider.js', array( 'jquery' ), '1', false );
	wp_register_script( 'owl-script', THEME_DIR . '/js/owl.carousel.js', array( 'jquery' ), '1', false );
    wp_enqueue_script( 'bootsrap-script' );
	wp_enqueue_script( 'flexi-script' );
	wp_enqueue_script( 'jquery-script' );
	wp_enqueue_script( 'jquery-script2' );
	wp_enqueue_script( 'jassor-slider-script' );
	wp_enqueue_script( 'owl-script' );
         
}
add_action( 'wp_enqueue_scripts', 'enqueue_scripts' );
function twentyfourteen_widgets_init() {

	register_sidebar( array(
		'name'          => __( 'Right Sidebar', 'MyTheme' ),
		'id'            => 'sidebar-1',
		'description'   => __( 'Main sidebar that appears on the right.', 'MyTheme' ),
		'before_widget' => '<div id="%1$s" class="widget sidebar %2$s">',
		'after_widget'  => '</div>',
		'before_title'  => '<h2>',
		'after_title'   => '</h2><div class="clearfix"></div>
		<div class="heading"> </div></h2>',
	) );

	
}
add_action( 'widgets_init', 'twentyfourteen_widgets_init' );
//******************** Most Read Articals**************************
function getPostViews($postID){
    $count_key = 'post_views_count';
    $count = get_post_meta($postID, $count_key, true);
    if($count==''){
        delete_post_meta($postID, $count_key);
        add_post_meta($postID, $count_key, '0');
        return '0';
    }
    return $count.'';
}
 
// function to count views.
function wpb_set_post_views($postID) {
    $count_key = 'wpb_post_views_count';
    $count = get_post_meta($postID, $count_key, true);
    if($count==''){
        $count = 0;
        delete_post_meta($postID, $count_key);
        add_post_meta($postID, $count_key, '0');
    }else{
        $count++;
        update_post_meta($postID, $count_key, $count);
    }
}
//To keep the count accurate, lets get rid of prefetching
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
function wpb_track_post_views ($post_id) {
    if ( !is_single() ) return;
    if ( empty ( $post_id) ) {
        global $post;
        $post_id = $post->ID;    
    }
    wpb_set_post_views($post_id);
}
add_action( 'wp_head', 'wpb_track_post_views');
function wpb_get_post_views($postID){
    $count_key = 'wpb_post_views_count';
    $count = get_post_meta($postID, $count_key, true);
    if($count==''){
        delete_post_meta($postID, $count_key);
        add_post_meta($postID, $count_key, '0');
        return "0";
    }
    return $count;
}

/////pagination///////
function paginations() {

global $wp_query;

$big = 999999999; // need an unlikely integer

echo paginate_links( array(
    'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
    'format' => '?paged=%#%',
    'current' => max( 1, get_query_var('paged') ),
    'total' => $wp_query->max_num_pages
) );

}
register_nav_menus( array(
		'primary'   => __( 'Top primary menu', 'MyTheme' ),
		'secondary' => __( 'Footer Nav', 'MyTheme' ),
	) );
/*breads*/

?>
