<?php
/*
 *  Author: SecretLab
 *  URL: http://secretlab.pw
 *  Custom functions, support and more.
 */


update_option('ultimate_vc_addons_redirect', false);
$sell_ultimate_constants = get_option('ultimate_constants');
$sell_ultimate_constants['ULTIMATE_NO_PLUGIN_PAGE_NOTICE'] = 1;
update_option('ultimate_constants', $sell_ultimate_constants);
update_option( 'wpb_js_composer_license_activation_notified', 'yes' );
remove_action('init', 'vc_page_welcome_redirect');
remove_action('vc_activation_hook', 'vc_page_welcome_set_redirect');
delete_transient('_redux_activation_redirect');
delete_transient('_wc_activation_redirect');
$GLOBALS['redux_notice_check'] = 0;
update_option('revslider-valid-notice', 'false');

add_action( 'after_setup_theme', 'theguard_remove_vc_reminder' );

function theguard_remove_vc_reminder() {
	SetCookie('vchideactivationmsg_vc11', '12.0');
}

// Welcome Page section */

add_action('admin_menu', 'theguard_welcome_screen_page');
function theguard_welcome_screen_page(){
	if (function_exists('welcome_notice')) {
		add_theme_page(esc_html__('Welcome', 'the-guard'), esc_html__('Welcome', 'the-guard'), 'read', 'secretlab-welcome', 'theguard_welcome_page');
	}
}
function theguard_welcome_page(){
	require_once(get_template_directory() . '/inc/welcome_page.php');
}
// end of Welcome Page section

if ( class_exists( 'Redux' ) && file_exists( get_template_directory() . '/inc/config.php' ) ) {
	require_once( get_template_directory() . '/inc/config.php' );
}

add_action('after_switch_theme', 'theguard_secretlab_activate');

function theguard_secretlab_activate() {
	
    add_action('admin_menu','welcome_redirect');
    function welcome_redirect($plugin) {
        wp_redirect(admin_url('themes.php'));
        die();
    }	
	
}


global $secretlab;
$sell_opt_name = 'secretlab';

/**
 * The Guard only works in WordPress 4.1 or later.
 */
if ( version_compare( $GLOBALS['wp_version'], '4.1-alpha', '<' ) ) {
	require get_template_directory() . '/inc/back-compat.php';
}

/**
 *  The Guard setup.
 *
 * Sets up theme defaults and registers the various WordPress features that
 *  The Guard supports.
 *
 * @uses load_theme_textdomain() For translation/localization support.
 * @uses add_editor_style() To add Visual Editor stylesheets.
 * @uses add_theme_support() To add support for automatic feed links, post
 * formats, and post thumbnails.
 * @uses register_nav_menu() To add support for a navigation menu.
 * @uses set_post_thumbnail_size() To set a custom post thumbnail size.
 *

 */

function theguard_setup() {
	/*
	 * Makes The SEO available for translation.
	 *
	 * Translations can be added to the /languages/ directory.
	 * If you're building a theme based on SecretLab, use a find and
	 * replace to change 'the-guard' to the name of your theme in all
	 * template files.
	 */
	load_theme_textdomain( 'the-guard', get_template_directory() . '/languages' );

	/*
	 * This theme styles the visual editor to resemble the theme style,
	 * specifically font, colors, icons, and column width.
	 */
	add_editor_style( array( 'css/editor-style.css', 'genericons/genericons.css' ) );

	// Adds RSS feed links to <head> for posts and comments.
	add_theme_support( 'automatic-feed-links' );

	/*
	 * Let WordPress manage the document title.
	 * By adding theme support, we declare that this theme does not use a
	 * hard-coded <title> tag in the document head, and expect WordPress to
	 * provide it for us.
	 */
	add_theme_support( 'title-tag' );
	/*
	 * Switches default core markup for search form, comment form,
	 * and comments to output valid HTML5.
	 */
	add_theme_support( 'html5', array(
		'search-form', 'comment-form', 'comment-list', 'gallery', 'caption'
	) );


	// This theme uses wp_nav_menu() in one location.
	register_nav_menu( 'theguard_top_menu', esc_html__( 'Header Menu', 'the-guard' ) );


	/*
	 * This theme uses a custom image size for featured images, displayed on
	 * "standard" posts and pages.
	 */
	add_theme_support( 'post-thumbnails' );
	set_post_thumbnail_size( 560, 280, true );
	add_image_size('theguard_smalldigital', 250, 250, true); // For 2 col post feed
	add_image_size('theguard_services', 600, 290, true); // Services Presentation
	add_image_size('theguard_featured_preview', 55, 55, true);

	// This theme uses its own gallery styles.
	add_filter( 'use_default_gallery_style', '__return_false' );
}
add_action( 'after_setup_theme', 'theguard_setup' );

/*------------------------------------*\
	Menu and Sidebar
\*------------------------------------*/
/* Menu Layout Settings */
function theguard_set_nav() {
	wp_nav_menu(
		array(
			'theme_location'  => 'theguard_top_menu',
			'menu'            => '',
			'container'       => '',
			'container_class' => '',
			'container_id'    => '',
			'menu_class'      => '',
			'menu_id'         => '',
			'echo'            => true,
			'fallback_cb'     => '__return_empty_string',
			'before'          => '',
			'after'           => '',
			'link_before'     => '',
			'link_after'      => '',
			'items_wrap'      => '%3$s',
			'depth'           => 3,
			'walker'          => ''
		)
	);

}

/**
 * Register 7 widget areas.
 */
function theguard_widgets_init() {
	register_sidebar( array(
		'name'          => esc_html__( 'Left Sidebar', 'the-guard' ),
		'id'            => '_default_left_sidebar',
		'description'   => esc_html__( 'Appears in the left section of the site.', 'the-guard' ),
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h3 class="widget-title">',
		'after_title'   => '</h3>',
	) );
	register_sidebar( array(
		'name'          => esc_html__( 'Right Sidebar', 'the-guard' ),
		'id'            => '_default_right_sidebar',
		'description'   => esc_html__( 'Appears in the right section of the site.', 'the-guard' ),
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h3 class="widget-title">',
		'after_title'   => '</h3>',
	) );
	register_sidebar( array(
		'name'          => esc_html__( 'Left Blog Sidebar', 'the-guard' ),
		'id'            => 'blog_default_left_sidebar',
		'description'   => esc_html__( 'Appears in the left blog section of the site.', 'the-guard' ),
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h3 class="widget-title">',
		'after_title'   => '</h3>',
	) );
	register_sidebar( array(
		'name'          => esc_html__( 'Right Blog Sidebar', 'the-guard' ),
		'id'            => 'blog_default_right_sidebar',
		'description'   => esc_html__( 'Appears in the right blog section of the site.', 'the-guard' ),
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h3 class="widget-title">',
		'after_title'   => '</h3>',
	) );
	register_sidebar( array(
		'name'          => esc_html__( 'Left Shop Sidebar', 'the-guard' ),
		'id'            => 'shop_default_left_sidebar',
		'description'   => esc_html__( 'Appears in the left shop section of the site.', 'the-guard' ),
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h3 class="widget-title">',
		'after_title'   => '</h3>',
	) );
	register_sidebar( array(
		'name'          => esc_html__( 'Right Shop Sidebar', 'the-guard' ),
		'id'            => 'shop_default_right_sidebar',
		'description'   => esc_html__( 'Appears in the left shop section of the site.', 'the-guard' ),
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h3 class="widget-title">',
		'after_title'   => '</h3>',
	) );
	register_sidebar( array(
		'name'          => esc_html__( 'Bottom Sidebars: 1st tab', 'the-guard' ),
		'id'            => 'botttom_sidebar_one',
		'description'   => esc_html__( 'Appears in the bottom section at Footer #1', 'the-guard' ),
		'before_widget' => '<aside id="%1$s" class="widget">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h3 class="widget-title">',
		'after_title'   => '</h3>',
	) );
	register_sidebar( array(
		'name'          => esc_html__( 'Bottom Sidebar: 2nd tab', 'the-guard' ),
		'id'            => 'botttom_sidebar_two',
		'description'   => esc_html__( 'Appears in the bottom section at Footer #1', 'the-guard' ),
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h3 class="widget-title">',
		'after_title'   => '</h3>',
	) );
	register_sidebar( array(
		'name'          => esc_html__( 'Bottom Sidebar: for Footer 2', 'the-guard' ),
		'id'            => 'botttom_sidebar_f2',
		'description'   => esc_html__( 'Appears in the bottom section at Footer #2', 'the-guard' ),
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h3 class="widget-title">',
		'after_title'   => '</h3>',
	) );

}
add_action( 'widgets_init', 'theguard_widgets_init' );


add_action( 'vc_before_init', 'sell_secret_setup_vc' );

function sell_secret_setup_vc() {

        if(function_exists('vc_set_default_editor_post_types')) {

        $list = array(
            'page',
            'post',
            'portfolio',
            'service',
			'teammate',
			'widget'
        );

        vc_set_default_editor_post_types( $list );

        }

}



/*-----------------------------------------------------------------------------------*/
/*	Include Designs Functions
/*-----------------------------------------------------------------------------------*/
//require_once(get_template_directory() . '/inc/widgets.php');

require_once(get_template_directory() . '/auxillary.php'); //Extra functions for layout and SecretLab Shortcodes Plugin
require_once(get_template_directory() . '/functions/blog.php'); // Functions and layouts for blog
require_once(get_template_directory() . '/functions/functions.php'); // General Functions of the theme. Under the hood.
require_once(get_template_directory() . '/functions/layout.php'); // General Functions of the theme. Under the hood.
require_once(get_template_directory() . '/functions/woocommerce.php'); // Functions for woocommerce and a cart in menu
require_once(get_template_directory() . '/functions/footer.php'); // Functions for footer section
require_once(get_template_directory() . '/functions/header.php'); // Functions for header section

// Change plugins list if inctaller is active
if (function_exists('welcome_notice')) {
	require_once ( get_template_directory() . '/inc/plugins-list.php');
} else {
	require_once ( get_template_directory() . '/inc/plugins-list_f.php');
}
