File: D:/HostingSpaces/MvAlphen/va-bo.nl/wwwroot/wp-content/themes/hattan/functions.php
<?php
define('EF1_THEME_NAME', 'hattan');
define('EF1_INDEX_JS', get_template_directory_uri() . '/assets/js/');
define('EF1_INDEX_CSS', get_template_directory_uri() . '/assets/css/');
define('EF1_VC_MODULES', get_template_directory() . '/includes/visual-composer/modules');
require_once ('framework/tgm/tgm.php');
require_once ('includes/custom_css.php');
require_once ('framework/meta-box/meta-box-class/my-meta-box-class.php');
require_once ('includes/meta_box.php');
if ( !class_exists( 'ReduxFramework' ) && file_exists( dirname( __FILE__ ) . '/framework/ReduxFramework/ReduxCore/framework.php' ) ) {
require_once( dirname( __FILE__ ) . '/framework/ReduxFramework/ReduxCore/framework.php' );
}
if ( !isset( $redux_demo ) && file_exists( dirname( __FILE__ ) . '/includes/ReduxConfig/config.php' ) ) {
require_once( dirname( __FILE__ ) . '/includes/ReduxConfig/config.php' );
}
if (!function_exists('ef1_setup_theme')) {
add_action('after_setup_theme', 'ef1_setup_theme');
function ef1_setup_theme(){
load_theme_textdomain(EF1_THEME_NAME, get_template_directory() . '/languages');
}
}
if (!function_exists('ef1_register_my_menu')) {
function ef1_register_my_menu() {
register_nav_menus( array(
'primary' => __( 'Primary Menu', EF1_THEME_NAME ),
'portfolio' => __( 'Portfolio Menu', EF1_THEME_NAME )
) );
}
add_action( 'init', 'ef1_register_my_menu' );
}
if (!function_exists('remove_shortcode_from_index')) {
function remove_shortcode_from_index( $content ) {
$content = strip_shortcodes( $content );
return $content;
}
add_filter( 'the_excerpt', 'remove_shortcode_from_index' );
}
if(!function_exists('search_filter')){
function search_filter($query) {
if ( !is_admin() && $query->is_main_query() ) {
if ($query->is_search) {
$query->set('post_type', array( 'post' ) );
}
}
}
add_action('pre_get_posts','search_filter');
}
if(!function_exists('ef1_menu')){
function ef1_menu( $items, $args ) {
if(isset($args->menu) && $args->theme_location == 'portfolio'){
$nepo = $prpo = "";
$nepo=get_next_post();
if(!empty($nepo)){
$nepoid=$nepo->ID;
$next_post_url = get_permalink($nepoid);
}
$prpo=get_previous_post();
if(!empty($prpo)){
$prpoid=$prpo->ID;
$prev_post_url = get_permalink($prpoid);
}
if($prpo != ""){
$items .='<li id="menu-item-prev" class="menu-item menu-item-previous-project"><a href="'.$prev_post_url.'">'.__('PREVIOUS PROJECT',EF1_THEME_NAME).'</a></li>';
}
if($nepo != ""){
$items .='<li id="menu-item-next" class="menu-item menu-item-next-project"><a href="'.$next_post_url.'">'.__('NEXT PROJECT',EF1_THEME_NAME).'</a></li>';
}
}
return $items;
}
add_filter('wp_nav_menu_items','ef1_menu', 10, 2);
}
if (!function_exists('ef1_after_setup')) {
function ef1_after_setup() {
add_theme_support('post-formats',array('video','gallery') );
//add feed
add_theme_support( 'automatic-feed-links' );
//add thumb
add_theme_support( 'post-thumbnails' );
add_image_size( 'post-thumb', 875, 430, true );
add_image_size( 'post-thumb-big', 1200, 720, true );
// Post Page Main image
}
add_action( 'after_setup_theme', 'ef1_after_setup' );
}
if (!function_exists('ef1_widgets_init')) {
function ef1_widgets_init() {
register_sidebar( array(
'name' => __( 'Sidebar', EF1_THEME_NAME ),
'id' => 'sidebar-1',
'description' => __( 'Appears when using the optional Front Page template with a page set as Static Front Page', EF1_THEME_NAME ),
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>',
'before_title' => '<header><h3 class="widget-title line-header">',
'after_title' => '</h3><div class="short-line"></div></header>',
) );
}
add_action( 'widgets_init', 'ef1_widgets_init' );
}
if ( ! isset( $content_width ) ) $content_width = 900;
if (!function_exists('ef1_custom_excerpt_length')) {
// excerpt lenght
function ef1_custom_excerpt_length( $length ) {
if(is_home() )return 25;
else return 50;
}
add_filter( 'excerpt_length', 'ef1_custom_excerpt_length', 999 );
// end excerpt lenght
}
if (!function_exists('ef1_change_level_comment')) {
//comments lvl
function ef1_change_level_comment($count) {
if ( ! current_user_can( 'manage_network' ) ) {
return 2; // or any number you want
}
}
add_filter( 'thread_comments_depth_max', 'ef1_change_level_comment',999 );
}
if (!function_exists('ef1_js_scripts')) {
function ef1_js_scripts() {
wp_enqueue_script( 'plugins', EF1_INDEX_JS.'plugins.js', array('jquery'), '1.0.0', true);
wp_enqueue_script( 'scripts', EF1_INDEX_JS.'scripts.js', array('jquery'), '1.0.0', true);
if ( is_singular() ){
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'ef1_js_scripts',5 );
}
if (!function_exists('ef1_style_js_header')) {
function ef1_style_js_header(){?>
<!--[if lt IE 9]>
<meta http-equiv="X-UA-Compatible" content="IE=8" />
<![endif]-->
<!--[if lt IE 9]>
<script>ie_script = true;</script>
<script src="<?php echo EF1_INDEX_JS.'html5shiv.js';?>"></script>
<script src="<?php echo EF1_INDEX_JS.'respond.js';?>"></script>
<![endif]-->
<?php }
add_action( 'wp_head', 'ef1_style_js_header',999 );
}
if (!function_exists('ef1_style')) {
function ef1_style() {
if ( ! is_admin() ){
wp_enqueue_style( 'reset', EF1_INDEX_CSS. 'reset.css' );
wp_enqueue_style( 'bootstrap', EF1_INDEX_CSS. 'bootstrap.css' );
wp_enqueue_style( 'lineicons', EF1_INDEX_CSS. 'lineicons.css' );
wp_enqueue_style( 'font-awesome', EF1_INDEX_CSS. 'font-awesome.min.css' );
wp_enqueue_style( 'bxslider', EF1_INDEX_CSS. 'jquery.bxslider.css' );
wp_enqueue_style( 'animate', EF1_INDEX_CSS. 'animate.min.css' );
wp_enqueue_style( 'prettyPhoto', EF1_INDEX_CSS. 'prettyPhoto.css' );
wp_enqueue_style( 'style', get_stylesheet_directory_uri(). '/style.css' );
wp_register_style( 'ie-css', EF1_INDEX_CSS.'ie.css', false);
$GLOBALS['wp_styles']->add_data( 'ie-css', 'conditional', 'lt IE 9' );
wp_enqueue_style( 'ie-css' );
}
}
add_action( 'wp_enqueue_scripts', 'ef1_style',1 );
}
if (!function_exists('ef1_title_filter')) {
function ef1_title_filter( $title, $sep ) {
// get special index page type (if any)
$seplocation= "";
$sep = '-';
$site_description = get_bloginfo( 'description', 'display' );
// get the page number
if( get_query_var( 'paged' ) )
$page_num = get_query_var( 'paged' ); // on index
elseif( get_query_var( 'page' ) )
$page_num = get_query_var( 'page' ); // on single
else $page_num = false;
// strip title separator
$title = trim( str_replace( $sep, '', $title ) );
// determine order based on seplocation
if ( $site_description && ( is_home() || is_front_page() ) ) {
$parts = array( get_bloginfo( 'name' ), $site_description );
}else{
$parts = array( get_bloginfo( 'name' ), $title, $page_num );
}
if( $seplocation == 'left' )
$parts = array_reverse( $parts );
// strip blanks, implode, and return title tag
$parts = array_filter( $parts );
return implode( ' ' . $sep . ' ', $parts );
}
add_filter( 'wp_title', 'ef1_title_filter', 10, 2 );
}
if (!function_exists('ef1_mytheme_fonts')) {
//Enqueue the Open Sans font.
function ef1_mytheme_fonts() {
$protocol = is_ssl() ? 'https' : 'http';
wp_enqueue_style( 'Raleway', "$protocol://fonts.googleapis.com/css?family=Raleway:400,300,600,500,700" );
}
add_action( 'wp_enqueue_scripts', 'ef1_mytheme_fonts',4 );
}
if (!function_exists('my_layerslider_overrides')) {
function my_layerslider_overrides() {
// Disable auto-updates
$GLOBALS['lsAutoUpdateBox'] = false;
}
add_action('layerslider_ready', 'my_layerslider_overrides');
}