<?php
	
/*
	*
	*	Theme Functions
	*	------------------------------------------------
	*	Katon Press Framework
	* 	Copyright http://www.katonpress.net
	*
	*	THEME DEFINITIONS
	*	ENQUEUE SCRIPTS
	*	ENQUEUE STYLES
	*	FUNCTION INCLUDES
	*   THEME SIDEBAR WIDGETS
	*	THUMBNAIL SIZES
	*   PAGINATION

*/

#-----------------------------------------------------------------#
# Define theme constants
#-----------------------------------------------------------------#
define('KP_THEME_DIRECTORY', get_template_directory_uri());
define('KP_THEME_DOCUMENT_ROOT', get_template_directory() );
define('KP_FRAMEWORK_DIRECTORY', get_template_directory_uri() . '/framework/');
define("KP_THEME_IMAGES", KP_THEME_DIRECTORY . '/images');
define('KP_THEME_NAME', 'slant');
define('KP_THEME_VERSION', '1.0');





if ( ! function_exists( 'slant_theme_setup' ) ) :
/**
 * Set 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 post thumbnails.
 *
 */
function slant_theme_setup() {

	/*
	 * Make slant available for translation.
	 * Translations can be added to the /languages/ directory.
	 */
	load_theme_textdomain(KP_THEME_NAME, get_template_directory() . '/language');


	// Add RSS feed links to <head> for posts and comments.
	add_theme_support( 'automatic-feed-links' );
	
	// Enable support for Post Thumbnails, and declare two sizes.
	add_theme_support( 'post-thumbnails' );
	
	add_theme_support( 'post-formats', array('video', 'gallery',) );
	
	#-----------------------------------------------------------------#
	# THUMBNAIL SIZES
	#-----------------------------------------------------------------#
	add_image_size( 'portfolio-thumb', 600, 400, true );
	add_image_size( 'portfolio-thumb-long', 600, 850, true );
	add_image_size( 'blog-thumb', 600, 285, true );
	add_image_size( 'blog-thumb-related', 300, 300, true );
	add_image_size( 'blog-large', 800, 533, true );
	add_image_size( 'team-thumb', 300, 300, true );

	// slant theme uses wp_nav_menu() in Primery locations.
	register_nav_menus( array(
		'main_nav'   => __( 'Primary Navigation Menu', 'KP_THEME_NAME' ),
	) );
	

}
endif; // slant_theme_setup
add_action( 'after_setup_theme', 'slant_theme_setup' );



#-----------------------------------------------------------------#
# Theme Framework Admin Options
#-----------------------------------------------------------------#
if ( !class_exists( 'ReduxFramework' ) && file_exists( dirname( __FILE__ ) . '/framework/options/ReduxCore/framework.php' ) ) {
    require_once( dirname( __FILE__ ) . '/framework/options/ReduxCore/framework.php' );
}
if ( !isset( $redux_demo ) && file_exists( dirname( __FILE__ ) . '/framework/options/options/options-config.php' ) ) {
    require_once( dirname( __FILE__ ) . '/framework/options/options/options-config.php' );
}



	
#-----------------------------------------------------------------#
# Register/Enqueue JS
#-----------------------------------------------------------------#
function slant_scripts_with_jquery()
{

	global $post;
	global $slant_options;

	$kp_options = get_option('slant_options');
	if(!is_object($post)) $post = (object) array('post_content'=>' ', 'ID' => ' ');
    $template_name = get_post_meta( $post->ID, '_wp_page_template', true );

	if (!is_admin()) {
	
	wp_enqueue_script('jquery');

	wp_register_script( 'bootstrap', get_template_directory_uri() . '/js/lib/bootstrap.min.js', array( 'jquery' ),'0.3', false );
	wp_enqueue_script( 'bootstrap' );
	
	wp_register_script( 'modernizr', get_template_directory_uri() . '/js/lib/modernizr.custom.js', array( 'jquery' ),'2.8.2', false);
	wp_enqueue_script( 'modernizr' );
	
	wp_register_script( 'easing', get_template_directory_uri() . '/js/lib/jquery.easing.1.3.js', array( 'jquery' ),'1.3', false);
	wp_enqueue_script( 'easing' );
	
	
	wp_register_script( 'youtube-player', get_template_directory_uri() . '/js/plugins/jquery.mb.YTPlayer.js', array( 'jquery' ), '1.0', true );
	wp_enqueue_script( 'youtube-player' );

	wp_register_script( 'nicescroll', get_template_directory_uri() . '/js/plugins/jquery.nicescroll.js', array( 'jquery' ),'3.5.0', true);
	if( !empty($kp_options['nice_scroll']) && $kp_options['nice_scroll'] == '1' ) wp_enqueue_script('nicescroll');
	
		if(isset($kp_options['nav_style'])){
		$nav_style = $kp_options['nav_style'];
		if($nav_style =="default"  ){
		wp_register_script( 'menuzord-menu', get_template_directory_uri() . '/js/plugins/menuzord.js', array( 'jquery' ),'0.3.3', true );
		wp_enqueue_script( 'menuzord-menu' );
		}
		
		elseif($nav_style =="side" || $nav_style =="push" ){	
		wp_register_script( 'tendina', get_template_directory_uri() . '/js/plugins/tendina.min.js', array( 'jquery' ), 1.2, true );
		wp_enqueue_script( 'tendina' );
		}

		}
		
	
	wp_register_script( 'header-animate', get_template_directory_uri() . '/js/plugins/cbpAnimatedHeader.js', array( 'jquery' ),'0.1', true );
	wp_enqueue_script( 'header-animate' );
	
	
	
	wp_register_script( 'appear', get_template_directory_uri() . '/js/plugins/appear.js', array( 'jquery' ),'0.3.3', true );
	wp_enqueue_script( 'appear' );


	wp_register_script( 'skewSlider', get_template_directory_uri() . '/js/plugins/jquery.skewSlider.js', array( 'jquery' ), '1.0', true );
	
	

	wp_register_script( 'fitvids', get_template_directory_uri() . '/js/plugins/jquery.fitvids.js', array( 'jquery' ),'1.1', true );
	wp_enqueue_script( 'fitvids' );
	

	wp_register_script( 'parallax', get_template_directory_uri() . '/js/plugins/jquery.parallax-1.1.3.js', array( 'jquery' ),'1.1.3', true );
	wp_enqueue_script( 'parallax' );
	
	
	wp_register_script( 'scrollIt', get_template_directory_uri() . '/js/plugins/scrollIt.min.js', array( 'jquery' ), '1.0', true );
	wp_enqueue_script( 'scrollIt' );
	
	
	wp_register_script( 'owl-carousel', get_template_directory_uri() . '/js/plugins/owl.carousel.min.js', array( 'jquery' ),'1.3.2', true );
	wp_enqueue_script( 'owl-carousel' );
	
	wp_register_script( 'plugins', get_template_directory_uri() . '/js/plugins/plugins.js', array( 'jquery' ),'2.0.2', true );
	wp_enqueue_script( 'plugins' );

	
	wp_register_script( 'classie', get_template_directory_uri() . '/js/plugins/classie.js', array( 'jquery' ),'1.3.2', true );
	wp_enqueue_script( 'classie' );
	
	wp_register_script( 'masonry', get_template_directory_uri() . '/js/plugins/masonry.pkgd.min.js', array( 'jquery' ), '3.0', true );
	wp_enqueue_script( 'masonry' );
	
    wp_register_script( 'piechart', get_template_directory_uri() . '/js/plugins/jquery.easypiechart.min.js', array( 'jquery' ),'2.1.5', true );
	
	
	
	 wp_register_script( 'gridScrollFx', get_template_directory_uri() . '/js/plugins/gridScrollFx.js', array( 'jquery' ),'1.0', true );
	 wp_register_script( 'colorfinder', get_template_directory_uri() . '/js/plugins/colorfinder-1.1.js', array( 'jquery' ),'1.1', true );
	 wp_register_script( 'imagesloaded', get_template_directory_uri() . '/js/plugins/imagesloaded.pkgd.min.js', array( 'jquery' ),'3.1.6', true );
	
	 wp_register_script( 'isotope', get_template_directory_uri() . '/js/plugins/isotope.pkgd.min.js', array( 'jquery' ),'2.0', true );
	
	
	wp_register_script( 'count', get_template_directory_uri() . '/js/plugins/count.js', array( 'jquery' ),'1.0', true );
	
	
	if ( is_page_template('comming-soon.php') || $template_name == 'comming-soon.php' ) {
	
	wp_register_script( 'countdown', get_template_directory_uri() . '/js/plugins/jquery.countdown.min.js', array( 'jquery' ),'1.0', true );
	wp_enqueue_script( 'countdown' );
	
	$blog_lang = substr(get_locale(), 0, 2);
	if($blog_lang !='en'){
	wp_register_script( 'countdown-lang', get_template_directory_uri() . '/js/countlang/jquery.countdown-'.$blog_lang.'.js', array( 'jquery' ),'1.0', true );
	wp_enqueue_script( 'countdown-lang' );
	}
	
	}
	
	
	if(isset($kp_options['banner_style']) && $kp_options['banner_style'] !="" ){
	$banner_style = $kp_options['banner_style'];
	
	if ( is_page_template('homepage-template.php') || $template_name == 'homepage-template.php' ) {
		if($banner_style =="slider"){
			wp_register_script( 'juicyslider', get_template_directory_uri() . '/js/plugins/juicyslider-min.js', array( 'jquery' ), 1.0, true );
			wp_enqueue_script( 'juicyslider' );
			
			wp_register_script( 'jquery-ui', get_template_directory_uri() . '/js/plugins/jquery.ui.js', array( 'jquery' ), 1.9, true );
			wp_enqueue_script( 'jquery-ui' );
		}
		
		if($banner_style =="video"){
		wp_enqueue_script( 'youtube-player' );
		}
	}
 }
	
	

	
	//comments
	if ( is_singular() && comments_open() && get_option('thread_comments') )
	wp_enqueue_script('comment-reply');
	
	// init Scripts
	wp_register_script( 'init', get_template_directory_uri() . '/js/custom.js', array( 'jquery' ), KP_THEME_VERSION, true);
	wp_enqueue_script( 'init' );
	}  
	
}
add_action( 'wp_enqueue_scripts', 'slant_scripts_with_jquery' );



//post Metabox scripts
add_action('admin_enqueue_scripts', 'slant_metabox_scripts');
function slant_metabox_scripts() {
	wp_register_script('meta-script', get_template_directory_uri() . '/framework/assets/js/meta.js', 'jquery', '1.0', TRUE);
	wp_enqueue_script('meta-script');	
}



#-----------------------------------------------------------------#
# Register/ Enqueue CSS / ENQUEUE STYLES
#-----------------------------------------------------------------#
function slant_main_styles() {

	global $post;
	global $slant_options;

	$kp_options = get_option('slant_options');
	if(!is_object($post)) $post = (object) array('post_content'=>' ', 'ID' => ' ');
    $template_name = get_post_meta( $post->ID, '_wp_page_template', true );

		 // Register 
		 
		wp_register_style('preloader-css', get_template_directory_uri() . '/css/preloader.css');
		wp_enqueue_style('preloader-css'); 
		 
		 wp_register_style('bootstrap', get_template_directory_uri() . '/css/bootstrap.min.css');
		 wp_enqueue_style('bootstrap');
		 
		  
		 wp_register_style('font-awesome', get_template_directory_uri() . '/font-awesome/css/font-awesome.min.css');
		 wp_enqueue_style('font-awesome'); 
		 
		 
		 wp_register_style('animate-css', get_template_directory_uri() . '/css/animate.min.css');
		 wp_enqueue_style('animate-css');
		 
		 wp_register_style('youtube-player', get_template_directory_uri() . '/css/YTPlayer.css');
		 wp_enqueue_style('youtube-player');
		 
		 
		 wp_register_style('juicyslider-css', get_template_directory_uri() . '/css/juicyslider-min.css');
		 wp_enqueue_style('juicyslider-css');
		 
		 wp_register_style('api-css', get_template_directory_uri() . '/css/api-demo.css');
		 wp_enqueue_style('api-css');
		 
		 wp_register_style('component-css', get_template_directory_uri() . '/css/component.css');
		 wp_enqueue_style('component-css');
		 
		 
		 wp_register_style('skw-css', get_template_directory_uri() . '/css/skw-core.css');
		 wp_enqueue_style('skw-css');
		 
		 		 
		 wp_register_style('menuzord-css', get_template_directory_uri() . '/css/menuzord.css');
		 wp_enqueue_style('menuzord-css');

		 wp_register_style('owl-carousel', get_template_directory_uri() . '/css/owl.carousel.css');
		 wp_enqueue_style('owl-carousel');
		 
		 wp_register_style('owl-transitions', get_template_directory_uri() . '/css/owl.transitions.css');
		 wp_enqueue_style('owl-transitions');
		 
		 
		 	if ( is_page_template('comming-soon.php') || $template_name == 'comming-soon.php' ) {
			wp_register_style('countdown-css', get_template_directory_uri() . '/css/countdown.css');
			wp_enqueue_style('countdown-css');
			}
		
		 
		 /* Main CSS */
        wp_enqueue_style( 'slant-style' , get_stylesheet_uri(), array(), KP_THEME_VERSION );
		
	if(isset($kp_options['nav_style'])){
		$nav_style = $kp_options['nav_style'];
		
		if($nav_style =="side"){
		 wp_register_style('sidebar-css', get_template_directory_uri() . '/css/sidebar.css');
		 wp_enqueue_style('sidebar-css');
		}
		
		if($nav_style =="push" ){
		 wp_register_style('PushMenu-css', get_template_directory_uri() . '/css/PushMenu.css');
		 wp_enqueue_style('PushMenu-css');
		}
	}	
		 
}

add_action('wp_enqueue_scripts', 'slant_main_styles');




global $slant_options;
$kp_options = get_option('slant_options');
if($kp_options['use-custom-fonts'] != 1){
function slant_fonts() {
$protocol = is_ssl() ? 'https' : 'http';
wp_enqueue_style( 'slant-roboto', "$protocol://fonts.googleapis.com/css?family=Roboto+Condensed:400,300,400italic,400italic,700" );
wp_enqueue_style( 'slant-lato', "$protocol://fonts.googleapis.com/css?family=Lato:400,300,300italic,400italic,700,700italic,900,900italic" );
}
add_action( 'wp_enqueue_scripts', 'slant_fonts' );
} 


#-----------------------------------------------------------------#
# Functions Include
#-----------------------------------------------------------------#
/* theme demo importer */
include_once( "framework/demo-importer.php" );
#-----------------------------------------------------------------#
# Custom Post Type
#-----------------------------------------------------------------#
include_once("framework/post-types/portfolio_init.php");
include_once("framework/post-types/team_init.php");
include_once("framework/post-types/testimonial_init.php");

// Skew Slider initiate
include('framework/skewslider_init.php');
#-----------------------------------------------------------------#
# Meta Boxes
#-----------------------------------------------------------------#
include_once('framework/meta-box/meta-box.php');
// Metabox Creation
include_once('framework/meta-boxes.php');

#-----------------------------------------------------------------#
# Menu Walker
#-----------------------------------------------------------------#
include_once('framework/nav_walker.php');

#-----------------------------------------------------------------#
# Custom CSS
#-----------------------------------------------------------------#
include_once('css/custom-css.php');


#-----------------------------------------------------------------#
# Plugin Activation
#-----------------------------------------------------------------#
require_once('framework/tgm-plugin-activation/class-tgm-plugin-activation.php');
require_once('framework/tgm-plugin-activation/required_plugins.php');


#-----------------------------------------------------------------#
# //Shortcode initiate
#-----------------------------------------------------------------# 
include_once('framework/shortcode/shortcodes.php'); // Load Shortcodes
	
/* Include TinyMce Shortcode Buttons */
include_once('framework/shortcode/tinymce/tinymce_buttons.php');

//Admin Shortcode Styles
add_action('admin_enqueue_scripts', 'slant_admin_css');
function slant_admin_css() {
		wp_enqueue_style('shortcode-css', get_template_directory_uri() . '/framework/assets/css/shortcodes.css');
		wp_enqueue_style('fontawesome-admin-css', get_template_directory_uri() . '/font-awesome/css/font-awesome.min.css');
}


// Check Menu Item Disabled
function slant_check_menu_item_disable($id) {
	 if(has_nav_menu('main_nav')) {
	if ( ( $locations = get_nav_menu_locations() ) && $locations['main_nav'] ) {
    $menu = wp_get_nav_menu_object( $locations['main_nav'] );
    $menu_items = wp_get_nav_menu_items($menu->term_id);
    foreach($menu_items as $item) {
	
        if(($item->object_id == $id)&&(in_array('disable', $item->classes)))
           return true;	
    }
	
	}
	}

}


#-----------------------------------------------------------------#
# Wp Staff
#-----------------------------------------------------------------#	
//Content Width
if ( ! isset( $content_width ) ) {
	$content_width = 1000;
}

//excerpt length
function slant_excerpt_length( $length ) {
	global $slant_options;
	$kp_options = get_option('slant_options'); 
	$slant_excerpt_length = (!empty($kp_options['blog_excerpt_length'])) ? intval($kp_options['blog_excerpt_length']) : 30; 
    return $slant_excerpt_length;
}
add_filter( 'excerpt_length', 'slant_excerpt_length', 999 );

//custom excerpt ending
function slant_excerpt_more( $more ) {
	return '...';
}
add_filter('excerpt_more', 'slant_excerpt_more');

//Excerpt Limit
function slant_excerpt_limit($limit) {

  $excerpt = explode(' ', get_the_excerpt(), $limit);

  if (count($excerpt)>=$limit) {
    array_pop($excerpt);
    $excerpt = implode(" ",$excerpt).'...';

  } else {
    $excerpt = implode(" ",$excerpt);
  }            

  $excerpt = preg_replace('`\[[^\]]*\]`','',$excerpt);
  return $excerpt;

}

//content Limit
function slant_content_limit($limit) {

  $content = explode(' ', get_the_content(), $limit);
  if (count($content)>=$limit) {
    array_pop($content);
    $content = implode(" ",$content).'...';

  } else {

    $content = implode(" ",$content);

  }            

  $content = preg_replace('/\[.+\]/','', $content);
  $content = apply_filters('the_content', $content); 
  $content = str_replace(']]>', ']]&gt;', $content);
  return $content;

}


//Widget Shortcode
add_filter('widget_text', 'do_shortcode');

    if (function_exists('register_sidebar')) {
	
	global $slant_options;
	$kp_options = get_option('slant_options');
	
    	register_sidebar(array(
    		'name' => 'Sidebar Widgets',
    		'id'   => 'sidebar-widgets',
    		'description'   => 'Default sidebar widgets.',
    		'before_widget' => '<div id="%1$s" class="widget %2$s">',
    		'after_widget'  => '</div>',
    		'before_title'  => '<h2>',
    		'after_title'   => '</h2>'
    	));
		register_sidebar(array(
		'name' => 'Blog Sidebar',
		'description'   => 'Blog sidebar widgets.',
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget'  => '</div>',
		'before_title'  => '<h2>',
		'after_title'   => '</h2>'
		));
		
		if(isset($kp_options['functional-footer']) && $kp_options['functional-footer'] =="1" ){
		register_sidebar(array(
		'name' => 'Footer Area 1',
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget'  => '</div>',
		'before_title'  => '<h2>',
		'after_title'   => '</h2>'
		));
		register_sidebar(array(
		'name' => 'Footer Area 2',
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget'  => '</div>',
		'before_title'  => '<h2>',
		'after_title'   => '</h2>'
		));
		register_sidebar(array(
		'name' => 'Footer Area 3',
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget'  => '</div>',
		'before_title'  => '<h2>',
		'after_title'   => '</h2>'
		));
		register_sidebar(array(
		'name' => 'Footer Area 4',
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget'  => '</div>',
		'before_title'  => '<h2>',
		'after_title'   => '</h2>'
		));
	  }
    }
	
#-----------------------------------------------------------------#
# Custom widgets
#-----------------------------------------------------------------#
//Recent Posts Extra
include('framework/custom-widgets/recent-posts-extra-widget.php');
//Contact Us
include('framework/custom-widgets/contactus-widget.php');
	
#-----------------------------------------------------------------#
# Breadcrumb
#-----------------------------------------------------------------#
function slant_breadcrumbs() {
       global $options;
		global $post;
	
        echo '<ul class="breadcrumb">';

         if ( !is_front_page() ) {
        echo '<li>'.$options['breacrumb_prefix'].' <a href="';
        echo home_url();
        echo '"> <i class="fa fa-home"></i> '.__('Home', 'THEME_NAME');
        echo "</a></li>";
        }

        $params['link_none'] = '';
        $separator = '';

        if (is_category() && !is_singular('portfolio')) {
            $category = get_the_category();
            $ID = $category[0]->cat_ID;
            echo is_wp_error( $cat_parents = get_category_parents($ID, TRUE, '', FALSE ) ) ? '' : '<li>'.$cat_parents.'</li>';
        }

        if(is_singular('portfolio')) {
            echo get_the_term_list($post->ID, 'portfolio-category', '<li>', '&nbsp;<i class="fa fa-angle-right"></i>&nbsp;&nbsp;', '</li>');
            echo '<li>'.get_the_title().'</li>';
        }

        if (is_tax()) {
            $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
            echo '<li>'.$term->name.'</li>';
        }

        if(is_home()) { echo '<li>' .get_bloginfo('name').'</li>'; }
        if(is_page() && !is_front_page()) {
            $parents = array();
            $parent_id = $post->post_parent;
            while ( $parent_id ) :
                $page = get_page( $parent_id );
                if ( $params["link_none"] )
                    $parents[]  = get_the_title( $page->ID );
                else
                    $parents[]  = '<li><a href="' . get_permalink( $page->ID ) . '" title="' . get_the_title( $page->ID ) . '"<i class="fa fa-angle-right"></i>' . get_the_title( $page->ID ) . '</a></li>' . $separator;
                $parent_id  = $page->post_parent;
            endwhile;
            $parents = array_reverse( $parents );
            echo join( '', $parents );
            echo '<li>'.get_the_title().'</li>';
        }
        if(is_single() && !is_singular('portfolio')) {
            $categories_1 = get_the_category($post->ID);
            if($categories_1):
                foreach($categories_1 as $cat_1):
                    $cat_1_ids[] = $cat_1->term_id;
                endforeach;
                $cat_1_line = implode(',', $cat_1_ids);
            endif;
            $categories = get_categories(array(
                'include' => $cat_1_line,
                'orderby' => 'id'
            ));
            if ( $categories ) :
                foreach ( $categories as $cat ) :
                    $cats[] = '<li><a href="' . get_category_link( $cat->term_id ) . '" title="' . $cat->name . '<i class="fa fa-angle-right"></i>' . $cat->name . '</a></li>';
                endforeach;
                echo join( '', $cats );
            endif;
            echo '<li>'.get_the_title().'</li>';
        }
        if(is_tag()){ echo '<li>'."Tag: ".single_tag_title('',FALSE).'</li>'; }
        if(is_404()){ echo '<li>'.__("404 - Page not Found", 'THEME_NAME').'</li>'; }
        if(is_search()){ echo '<li>'.__("Search", 'THEME_NAME').'</li>'; }
        if(is_year()){ echo '<li>'.get_the_time('Y').'</li>'; }

        echo "</ul>";
			
}

#-----------------------------------------------------------------#
# PAGINATION
#-----------------------------------------------------------------#

function slant_pagination($pages = '', $range = 2)
{  

	global $slant_options;
	$kp_options = get_option('slant_options'); 
	//extra pagination
	if( !empty($kp_options['extra_pagination']) && $kp_options['extra_pagination'] == '1' ){
	
     $showitems = ($range * 2)+1;
     global $paged;
     if(empty($paged)) $paged = 1;

     if($pages == '')
     {
         global $wp_query;
         $pages = $wp_query->max_num_pages;
         if(!$pages)
         {
             $pages = 1;
         }
     }   

     if(1 != $pages)
     {
         echo "<ul class='pagination centerclearfix'>";
		 
         if($paged > 1){
         	echo "<li><a class='pagination-prev' href='".get_pagenum_link($paged - 1)."'><span class='page-prev'></span><i class='fa fa-long-arrow-left'></i></a></li>";
         }
         for ($i=1; $i <= $pages; $i++)
         { 
             if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
             {
                 echo ($paged == $i)? " <li class='active'><a href='#'><b>".$i."</b></a></li>":" <li><a href='".get_pagenum_link($i)."'>".$i."</a></li>";
             }
			
         }

         if ($paged < $pages) echo "<li><a class='pagination-next' href='".get_pagenum_link($paged + 1)."'><i class='fa fa-long-arrow-right'></i><span class='page-next'></span></a></li>";  
         echo "</ul>\n";
     }
	 
	  	}
		//regular pagination
		else{
			
			if( get_next_posts_link() || get_previous_posts_link() ) { 
				echo '<div class="pagination" id="pagination" data-is-text="'.__("All items loaded", KP_THEME_NAME).'">
				      <div class="prev">'.get_previous_posts_link('&laquo; Previous Entries').'</div>
				      <div class="next">'.get_next_posts_link('Next Entries &raquo;','').'</div>
			          </div>';
			
	        }
		}
}





#-----------------------------------------------------------------#
# Portfolio Related Posts
#-----------------------------------------------------------------#
function slant_portfolio_related_posts() {
global $post;
$cats  =  wp_get_object_terms( $post->ID, 'portfolio-category' );
if ( $cats ) {
			$catcount = count( $cats );
			for ( $i = 0; $i < $catcount; $i++ ) {
				$catSlugs[$i] = $cats[$i]->slug;
			}
			$query = array(
				'post__not_in' => array( $post->ID ),
				'showposts'=>4,
				'ignore_sticky_posts'=>1,
				'post_type' => 'portfolio',
			);
			$query['tax_query'] = array(
					array(
						'taxonomy' => 'portfolio-category',
						'field' => 'slug',
						'terms' => $catSlugs
					)
				);
				
				$output = '';
				$related = new WP_Query( $query );
			    if ( $related->have_posts() ) {
				$output .= '<h2>Related Projects</h2><ul class="related_grid">';
				while ( $related->have_posts() ) {
					global $post;
					$related->the_post();
					if ( has_post_thumbnail() ) {
					$output .= '<li class="item"><a class="portfolio-box" href="'.get_permalink().'">'. get_the_post_thumbnail($post->ID, 'portfolio-thumb', array('title' => '')).'<h3>'. get_the_title().'</h3></a></li>';
					}
					
					}
				$output .= '</ul>';
				wp_reset_postdata();
				
				}
				
				echo $output;
}
}


#-----------------------------------------------------------------#
# social share
#-----------------------------------------------------------------#
function slant_social_sharing_buttons() {

		global $post;
		global $slant_options;

		$kp_options = get_option('slant_options');
			
					echo '<div class="slant-social sharing"><ul class="social-network social-circle social-small">';
					//facebook
					echo "<li><a class='icoFacebook facebook-share slant-sharing' href='#' title='".__('Share this', KP_THEME_NAME)."'> <i class='fa fa-facebook'></i></a></li>";
					//twitter
					echo "<li><a class='icoTwitter twitter-share slant-sharing' href='#' title='".__('Tweet this', KP_THEME_NAME)."'> <i class='fa fa-twitter'></i></a></li>";
					//pinterest
					echo "<li><a class='pinterest-share slant-sharing' href='#' title='".__('Pin this', KP_THEME_NAME)."'> <i class='fa fa-pinterest'></i></a></li>";		
					echo '</ul></div>';
}


#-----------------------------------------------------------------#
# Admin Menu Icons
#-----------------------------------------------------------------#
add_action( 'admin_enqueue_scripts', 'slant_add_menu_icons_styles' );
function slant_add_menu_icons_styles(){
?>
 
<style>
#adminmenu .menu-icon-portfolio div.wp-menu-image:before {
content: "\f322";
}
#adminmenu .menu-icon-testimonial div.wp-menu-image:before {
content: "\f122";
}
#adminmenu .menu-icon-team div.wp-menu-image:before {
content: "\f307";
}
#adminmenu .menu-icon-home_slider div.wp-menu-image:before {
content: "\f102";
}

</style>
 
<?php
}

?>