<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

class Elex_FB_Setting_Section {


	const VERSION = '1.2.4';

	public function __construct() {
		$this->elex_fpf_register_plugin_styles_scripts();
		$this->elex_fpf_tabs();
	}

	public function elex_fpf_register_plugin_styles_scripts() {
		global $woocommerce;
		$woocommerce_version = function_exists( 'WC' ) ? WC()->version : $woocommerce->version;
		wp_nonce_field( 'ajax-elex-fpf-nonce', '_ajax_elex_fpf_nonce' );
		wp_register_style( 'elex-setting-style', ELEX_FACEBOOK_FEED_MAIN_URL_PATH . '/assets/css/elex-setting-styles.css', array(), $woocommerce_version );
		wp_enqueue_style( 'elex-setting-style' );

		wp_enqueue_script( 'elex-setting-script', ELEX_FACEBOOK_FEED_MAIN_URL_PATH . '/assets/js/elex-setting-scripts.js', array(), self::VERSION );

		wp_enqueue_script( 'elex-edit-feeds', ELEX_FACEBOOK_FEED_MAIN_URL_PATH . '/assets/js/elex-edit-feeds.js', array(), self::VERSION );

		wp_enqueue_script( 'elex-typeahead-script', ELEX_FACEBOOK_FEED_MAIN_URL_PATH . '/assets/js/elex-typeahead.js', array(), self::VERSION );

		$saved_settings_tab_data = get_option( 'elex_fpf_settings_tab_fields_data' );
		$language_selected       = isset( $saved_settings_tab_data['cat_language'] ) ? $saved_settings_tab_data['cat_language'] : 'en';
		wp_register_script( 'elex-load-cat-language', ELEX_FACEBOOK_FEED_MAIN_URL_PATH . '/assets/js/elex-load-google-categories-in-"' . $language_selected . '".js', array(), $woocommerce_version );
		wp_enqueue_script( 'elex-load-cat-language' );
		wp_register_script( 'elex-cats-auto-complete-script', ELEX_FACEBOOK_FEED_MAIN_URL_PATH . '/assets/js/elex-cats-auto-complete.js', array(), $woocommerce_version );
		wp_enqueue_script( 'elex-cats-auto-complete-script' );

		wp_enqueue_script( 'elex-multiple-chosen-script', ELEX_FACEBOOK_FEED_MAIN_URL_PATH . '/assets/js/chosen.jquery.js', array(), $woocommerce_version );

		wp_enqueue_style( 'woocommerce_admin_styles', $woocommerce->plugin_url() . '/assets/css/admin.css', array(), $woocommerce_version );
		wp_register_style( 'elex-fpf-plugin-bootstrap', plugins_url( '/assets/css/bootstrap.css', dirname( __FILE__ ) ), array(), $woocommerce_version );
		wp_enqueue_style( 'elex-fpf-plugin-bootstrap' );
		wp_register_script( 'elex-fpf-tooltip-jquery', plugins_url( '/assets/js/tooltip.js', dirname( __FILE__ ) ), array(), $woocommerce_version );
		wp_enqueue_script( 'elex-fpf-tooltip-jquery' );
		wp_enqueue_script( 'wc-enhanced-select' );
	}

	public function elex_fpf_tabs() {
		?>
		<h2 class="nav-tab-wrapper">
			<a href="admin.php?page=elex-facebook-feed-manage" class="nav-tab"><?php esc_html_e( 'Manage Feeds', 'elex-product-feed' ); ?></a>
			<a href="admin.php?page=elex-facebook-feed" class="nav-tab nav-tab-active"><?php esc_html_e( 'Create Feed', 'elex-product-feed' ); ?></a>
			<a href='admin.php?page=elex-facebook-feed-settings' class='nav-tab'><?php esc_html_e( 'Settings', 'elex-product-feed' ); ?></a>
		<?php 
		if ( ! elex_fb_premium() ) {
			?>
			<a href='admin.php?page=elex-facebook-feed-go-premium' style="color:red;" class='nav-tab'><?php esc_html_e( 'Go Premium!', 'elex-product-feed' ); ?></a>
		<?php } else { ?>
			<a href='admin.php?page=elex-facebook-feed-licence' class='nav-tab'><?php esc_html_e( 'Licence', 'elex-product-feed' ); ?></a>
		<?php } ?>            
		</h2>
		<div class="elex-fpf-steps-navigator">
			<div id ="elex_fpf_step1" class="elex-fpf-steps active">
		<?php esc_html_e( 'START', 'elex-product-feed' ); ?>
			</div>
			<div id ="elex_fpf_step2" class="elex-fpf-steps">
		<?php esc_html_e( 'MAP CATEGORY', 'elex-product-feed' ); ?>
			</div>
			<div id ="elex_fpf_step3" class="elex-fpf-steps ">
		<?php esc_html_e( 'MAP ATTRIBUTES', 'elex-product-feed' ); ?>
			</div>
			<div id ="elex_fpf_step4" class="elex-fpf-steps">
		<?php esc_html_e( 'FILTERING OPTIONS', 'elex-product-feed' ); ?>
			</div>
			<div id ="elex_fpf_step5" class="elex-fpf-steps">
		<?php esc_html_e( 'GENERATE FEED', 'elex-product-feed' ); ?>
			</div>
		</div>

		<?php
	}

}

new Elex_FB_Setting_Section();
require_once ELEX_FACEBOOK_FEED_TEMPLATE_PATH . '/elex-settings-frontend.php';
