<?php
/**
 * Theme sprecific functions and definitions
 */


/* Theme setup section
------------------------------------------------------------------- */

// Set the content width based on the theme's design and stylesheet.
if ( ! isset( $content_width ) ) $content_width = 1170; /* pixels */

// Add theme specific actions and filters
// Attention! Function were add theme specific actions and filters handlers must have priority 1
if ( !function_exists( 'seohub_theme_setup' ) ) {
	add_action( 'seohub_action_before_init_theme', 'seohub_theme_setup', 1 );
	function seohub_theme_setup() {

		// Register theme menus
		add_filter( 'seohub_filter_add_theme_menus',		'seohub_add_theme_menus' );

		// Register theme sidebars
		add_filter( 'seohub_filter_add_theme_sidebars',	'seohub_add_theme_sidebars' );

		// Set Theme required plugins
		add_filter( 'seohub_filter_required_plugins',		'seohub_set_required_plugins', 9 );

		// Set options for importer
		add_filter( 'seohub_filter_importer_options',		'seohub_set_importer_options' );

	}
}


// Add/Remove theme nav menus
if ( !function_exists( 'seohub_add_theme_menus' ) ) {
	//add_filter( 'seohub_filter_add_theme_menus', 'seohub_add_theme_menus' );
	function seohub_add_theme_menus($menus) {
		//For example:
		//$menus['menu_footer'] = esc_html__('Footer Menu', 'seohub');
		//if (isset($menus['menu_panel'])) unset($menus['menu_panel']);
		return $menus;
	}
}


// Add theme specific widgetized areas
if ( !function_exists( 'seohub_add_theme_sidebars' ) ) {
	//add_filter( 'seohub_filter_add_theme_sidebars',	'seohub_add_theme_sidebars' );
	function seohub_add_theme_sidebars($sidebars=array()) {
		if (is_array($sidebars)) {
			$theme_sidebars = array(
				'sidebar_main'		=> esc_html__( 'Main Sidebar', 'seohub' ),
				'sidebar_outer'		=> esc_html__( 'Outer Sidebar', 'seohub' ),
				'sidebar_footer'	=> esc_html__( 'Footer Sidebar', 'seohub' )
			);
			if (function_exists('seohub_exists_woocommerce') && seohub_exists_woocommerce()) {
				$theme_sidebars['sidebar_cart']  = esc_html__( 'WooCommerce Cart Sidebar', 'seohub' );
			}
			$sidebars = array_merge($theme_sidebars, $sidebars);
		}
		return $sidebars;
	}
}


// Set theme required plugins
if ( !function_exists( 'seohub_set_required_plugins' ) ) {
	//add_filter( 'seohub_filter_required_plugins', 'seohub_set_required_plugins', 9, 1 );
	function seohub_set_required_plugins($list=array()) {
		global $SEOHUB_GLOBALS;
		$SEOHUB_GLOBALS['required_plugins'] = array(
// Attention!
// Plugin Booking Calendar not compatible with bbPress and BuddyPress!
// And it generate notice messages, that break AJAX installer!
// Uncomment it if your theme not use bbPress and BuddyPress
			'essgrids',
			'instagram_widget',
			'revslider',
			'seohub_utils',
			'visual_composer',
		);
		return $list;
	}
}


// Set theme specific importer options
if ( !function_exists( 'seohub_set_importer_options' ) ) {
	//add_filter( 'seohub_filter_importer_options',	'seohub_set_importer_options' );
	function seohub_set_importer_options($options=array()) {
		if (is_array($options)) {
			// Please, note! The following text strings should not be translated, 
			// since these are article titles, menu locations, etc. used by us in the demo-website. 
			// They are required when setting some of the WP parameters during demo data installation 
			// and cannot be changed/translated into other languages.
			$options['debug'] = seohub_get_theme_option('debug_mode')=='yes';
			$options['domain_dev'] = 'seohub.dv.ancorathemes.com';
			$options['domain_demo'] = 'seohub.ancorathemes.com';
			$options['menus'] = array(																	// Menus locations and names (NOT FOR TRANSLATION)
				'menu-main'	  => esc_html__('Main menu', 'seohub'),
				'menu-user'	  => esc_html__('User menu', 'seohub'),
				'menu-footer' => esc_html__('Footer menu', 'seohub'),
				'menu-outer'  => esc_html__('Main menu', 'seohub')
			);
		}
		return $options;
	}
}


/* Include framework core files
------------------------------------------------------------------- */
// If now is WP Heartbeat call - skip loading theme core files
if (!isset($_POST['action']) || $_POST['action']!="heartbeat") {
	require_once get_template_directory().'/fw/loader.php';
}
?>