<?php

/**
 * The admin-specific functionality of the plugin.
 *
 * @link       www.colijn-it.nl
 * @since      1.0.0
 *
 * @package    ione360_configurator
 * @subpackage ione360_configurator/admin
 */

/**
 * The admin-specific functionality of the plugin.
 *
 * Defines the plugin name, version, and two examples hooks for how to
 * enqueue the admin-specific stylesheet and JavaScript.
 *
 * @package    ione360_configurator
 * @subpackage ione360_configurator/admin
 * @author     Colijn-IT <info@colijn-it.nl>
 */
class ione360_configurator_Admin {

	/**
	 * The ID of this plugin.
	 *
	 * @since    1.0.0
	 * @access   private
	 * @var      string    $plugin_name    The ID of this plugin.
	 */
	private $plugin_name;

	/**
	 * The version of this plugin.
	 *
	 * @since    1.0.0
	 * @access   private
	 * @var      string    $version    The current version of this plugin.
	 */
	private $version;

	/**
	 * Initialize the class and set its properties.
	 *
	 * @since    1.0.0
	 * @param      string    $plugin_name       The name of this plugin.
	 * @param      string    $version    The version of this plugin.
	 */
	public function __construct( $plugin_name, $version ) {

		$this->plugin_name = $plugin_name;
		$this->version = $version;
		add_action('admin_menu', array( $this, 'addPluginAdminMenu' ), 9);
		add_action('admin_init', array( $this, 'registerAndBuildFields' ));
		    // Css rules for Color Picker
		
	}

	/**
	 * Register the stylesheets for the admin area.
	 *
	 * @since    1.0.0
	 */
	public function enqueue_styles() {

		/**
		 * This function is provided for demonstration purposes only.
		 *
		 * An instance of this class should be passed to the run() function
		 * defined in ione360_configurator_Loader as all of the hooks are defined
		 * in that particular class.
		 *
		 * The ione360_configurator_Loader will then create the relationship
		 * between the defined hooks and the functions defined in this
		 * class.
		 */

		wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/configurator-iOne360-admin.css', array(), $this->version, 'all' );
		wp_enqueue_style( 'wp-color-picker' );
		wp_enqueue_media();
	}

	/**
	 * Register the JavaScript for the admin area.
	 *
	 * @since    1.0.0
	 */
	public function enqueue_scripts() {

		/**
		 * This function is provided for demonstration purposes only.
		 *
		 * An instance of this class should be passed to the run() function
		 * defined in ione360_configurator_Loader as all of the hooks are defined
		 * in that particular class.
		 *
		 * The ione360_configurator_Loader will then create the relationship
		 * between the defined hooks and the functions defined in this
		 * class.
		 */
		wp_enqueue_script( 'wp-color-picker-alpha', plugins_url( '/js/wp-color-picker-alpha.js',  __FILE__ ), array( 'wp-color-picker' ), '3.0.0', true );
		wp_enqueue_script( 'wp-color-picker-init',  plugins_url( '/js/wp-color-picker-init.js',  __FILE__ ), array( 'wp-color-picker-alpha' ), '3.0.0', true );

		
	}



	public function addPluginAdminMenu() {
			//add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position );
			
			$png = 'iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAQAAAD8x0bcAAAABGdBTUEAALGPC/xhBQAAAAJiS0dEAP+Hj8y/AAAACXBIWXMAAAsSAAALEgHS3X78AAAAB3RJTUUH5gUKCBYCVxG4aAAAAjFJREFUKM8Fwc9Lk3EcwPH39/t9tuk2pzgNM/wxS+0HUYcgEpXwYBEiHQqLLpHRsQilQ5D1F0hFgUUhQYcwxUMY0iGyW0QUiUbBTKOcsza36eZ+PM/z6fVSr3SVOsJtc7K9cTBw2R9wKKJIpxhbHD8dFSZATK/pkHElV/Tz5uMJzwc1xxcSlPlqukJnBlKNX/+Csj7KRVN50x75Jm/tBWsZg8JDrep2ztfteTAfunN3WiH8GPzp3iseKu6UBmmRdtknbRKROukszdjp0sIlQc3sPTyX3DHkLJpaNAXyaIQyFAla7YeWXnvZbUaGyk88tmetMMIWNh4ELzZCNXGdKkUqw7ZaSsSqruo0PgoEKVJEKBBCo3Hxc03C25a/epVVGuhgnh78TNGPwzsaOMoom/xSSb+l+I1gKFFOM0FC1NHNd0LUo1FEaRIrLlllyPIehzfkWWaSSTIkKeHDZhuFTis/GsHGkGKTbvJ4ifCHGUBTTZmy/mXqK0IqSxDhAIYAHsJ8wmEXabzUSCBnLoTqutadBR0EYizxgzVirAJCjojTqs0TvfEsF+83ESeJJkOWHDkyeBHWCdhtRuJ6zEwnVjdUnysxN6s1Gi+Ci02aFruPSsX1qVlzzPR8ns34e5q84m6RU5tsU6CKLmfAtNjJG0NjE1qNmhoWTe3ZimF9MGeKxID9+Nyw9qws3xp+8dTJKDWry1Ve9dqP6itOmQFPp68sILvVSnTpvu/1ueiE5brV8h/6++4bwRUj9AAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMi0wNS0xMFQwODoyMTo0OSswMDowMGefozAAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjItMDUtMTBUMDg6MjE6NDkrMDA6MDAWwhuMAAAAAElFTkSuQmCC';
			$icon = 'data:image/png;base64,' . $png;
			add_menu_page(  $this->plugin_name, 'iONE360', 'manage_options', $this->plugin_name, array( $this, 'displayPluginAdminDashboard' ), null);

			//add_submenu_page( '$parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function );
				add_submenu_page( $this->plugin_name, 'iONE360', 'Configurator settings', 'manage_options', $this->plugin_name, array( $this, 'displayPluginAdminDashboard' ));
				add_submenu_page( $this->plugin_name, 'iONE360', 'Render settings', 'manage_options', $this->plugin_name.'-rendersettings', array( $this, 'displayPluginAdminSettingsrender'));
				add_submenu_page( $this->plugin_name, 'iONE360', 'Layout settings', 'manage_options', $this->plugin_name.'-layoutsettings', array( $this, 'displayPluginAdminSettingslayout'));
				add_submenu_page( $this->plugin_name, 'iONE360', 'Contact Settings', 'manage_options', $this->plugin_name.'-contactsettings', array( $this, 'displayPluginAdminSettingscontact'));
				add_submenu_page( $this->plugin_name, 'iONE360', 'Contact Form', 'manage_options', $this->plugin_name.'-contactform', array( $this, 'displayPluginAdminFormcontact'));
				include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
				$pluginPath = "woocommerce/woocommerce.php" ;
				if(is_plugin_active($pluginPath)) {
						add_submenu_page( $this->plugin_name, 'iONE360', 'Woocommerce', 'manage_options', $this->plugin_name.'-woocommercesettings', array( $this, 'displayPluginWoocommerceSettings'));
				}


	}
	public function displayPluginAdminDashboard() {
		require_once 'partials/'.$this->plugin_name.'-admin-display.php';
	}
		public function displayPluginAdminSettings() {
			// set this var to be used in the settings-display view
			$active_tab = isset( $_GET[ 'tab' ] ) ? sanitize_text_field($_GET[ 'tab' ]) : 'general';
			if(isset($_GET['error_message'])){
					add_action('admin_notices', array($this,'settingsConfiguratorMessages'));
					do_action( 'admin_notices', $_GET['error_message'] );
			}
			require_once 'partials/'.$this->plugin_name.'-admin-settings-display.php';
		}

		public function displayPluginAdminSettingsrender() {
			// set this var to be used in the settings-display view
			$active_tab = isset( $_GET[ 'tab' ] ) ? sanitize_text_field($_GET[ 'tab' ]) : 'rendersettings';
			if(isset($_GET['error_message'])){
					add_action('admin_notices', array($this,'settingsConfiguratorMessages'));
					do_action( 'admin_notices', $_GET['error_message'] );
			}
			require_once 'partials/'.$this->plugin_name.'-admin-settings-render-display.php';
		}
		public function displayPluginAdminSettingslayout() {
			// set this var to be used in the settings-display view
			$active_tab = isset( $_GET[ 'tab' ] ) ? sanitize_text_field($_GET[ 'tab' ]) : 'layoutsettings';
			if(isset($_GET['error_message'])){
					add_action('admin_notices', array($this,'settingsConfiguratorMessages'));
					do_action( 'admin_notices', $_GET['error_message'] );
			}
			require_once 'partials/'.$this->plugin_name.'-admin-settings-layout-display.php';
		}
		public function displayPluginAdminSettingscontact() {
			// set this var to be used in the settings-display view
			$active_tab = isset( $_GET[ 'tab' ] ) ? sanitize_text_field($_GET[ 'tab' ]) : 'contactsettings';
			if(isset($_GET['error_message'])){
					add_action('admin_notices', array($this,'settingsConfiguratorMessages'));
					do_action( 'admin_notices', $_GET['error_message'] );
			}
			require_once 'partials/'.$this->plugin_name.'-admin-contact-settings.php';
		}	
		public function displayPluginAdminFormcontact() {
			// set this var to be used in the settings-display view
			$active_tab = isset( $_GET[ 'tab' ] ) ? sanitize_text_field($_GET[ 'tab' ]) : 'contactform';
			if(isset($_GET['error_message'])){
					add_action('admin_notices', array($this,'settingsConfiguratorMessages'));
					do_action( 'admin_notices', $_GET['error_message'] );
			}
			require_once 'partials/'.$this->plugin_name.'-admin-contact-form.php';
		}
		public function displayPluginWoocommerceSettings() {
			// set this var to be used in the settings-display view
			$active_tab = isset( $_GET[ 'tab' ] ) ? sanitize_text_field($_GET[ 'tab' ]) : 'woocommercesettings';
			if(isset($_GET['error_message'])){
					add_action('admin_notices', array($this,'settingsConfiguratorMessages'));
					do_action( 'admin_notices', $_GET['error_message'] );
			}
			require_once 'partials/'.$this->plugin_name.'-admin-woocommerce-settings.php';
		}		
		public function settingsConfiguratorMessages($error_message){
			switch ($error_message) {
					case '1':
							$message = __( 'There was an error adding this setting. Please try again.  If this persists, shoot us an email.', 'my-text-domain' );                 
							$err_code = esc_attr( 'configurator_example_setting' );                 
							$setting_field = 'configurator_example_setting';
							break;
			}
			$type = 'error';
			add_settings_error(
						$setting_field,
						$err_code,
						$message,
						$type
				);
		}
		public function registerAndBuildFields() {
				/**
			 * First, we add_settings_section. This is necessary since all future settings must belong to one.
			 * Second, add_settings_field
			 * Third, register_setting
			 */
			add_settings_section(
				// ID used to identify this section and with which to register options
				'configurator_general_section',
				// Title to be displayed on the administration page
				'',
				// Callback used to render the description of the section
					array( $this, 'configurator_display_general_account' ),
				// Page on which to add this section of options
				'configurator_general_settings'
			);

			add_settings_section(
				// ID used to identify this section and with which to register options
				'configurator_render_settings_section',
				// Title to be displayed on the administration page
				'',
				// Callback used to render the description of the section
					'',
				// Page on which to add this section of options
				'configurator_render_settings'
			);
			add_settings_section(
				// ID used to identify this section and with which to register options
				'configurator_layout_settings_section',
				// Title to be displayed on the administration page
				'',
				// Callback used to render the description of the section
					'',
				// Page on which to add this section of options
				'configurator_layout_settings'
			);
			add_settings_section(
				// ID used to identify this section and with which to register options
				'configurator_contact_settings_section',
				// Title to be displayed on the administration page
				'',
				// Callback used to render the description of the section
					'',
				// Page on which to add this section of options
				'configurator_contact_settings'
			);
			add_settings_section(
				// ID used to identify this section and with which to register options
				'configurator_woocommerce_settings_section',
				// Title to be displayed on the administration page
				'',
				// Callback used to render the description of the section
					'',
				// Page on which to add this section of options
				'configurator_woocommerce_settings'
			);			
			unset($args);

			/*Start Configurator Settings */
			$args = array (
				'type'      => 'input',
				'subtype'   => 'dropdown',
				'id'        => 'configurator_bundle_selections',
				'name'      => 'configurator_bundle_selections',
				'required'  => 'true',
				'get_options_list' => '',
				'value_type'=> 'normal',
				'wp_data'   => 'option',
				'description' => 'Choose your iONE version.',
				'sanitize_callback' => 'sanitize_text_field',
				'options'   => array(
					'production' => 'Production',
					'254' => 'iONE 254',
					'255' => 'iONE 255',
					'develop' => 'Develop'
				)
			);
			add_settings_field(
				'configurator_bundle_selections',
				'iONE bundle version',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_general_settings',
				'configurator_general_section',
				$args
			);				
			$args = array (
					'type'      => 'input',
					'subtype'   => 'text',
					'id'    => 'configurator_endpoint_setting',
					'name'      => 'configurator_endpoint_setting',
					'required' => 'true',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_endpoint_setting',
				'iONE endpoint',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_general_settings',
				'configurator_general_section',
				$args
			);
			$args = array (
					'type'      => 'input',
					'subtype'   => 'text',
					'id'    => 'configurator_scheme_setting',
					'name'      => 'configurator_scheme_setting',
					'required' => 'true',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_scheme_setting',
				'iONE scheme',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_general_settings',
				'configurator_general_section',
				$args
			);
			$args = array (
					'type'      => 'input',
					'subtype'   => 'text',
					'id'    => 'configurator_version_setting',
					'name'      => 'configurator_version_setting',
					'required' => 'true',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_version_setting',
				'iONE version',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_general_settings',
				'configurator_general_section',
				$args
			);
			$args = array (
					'type'      => 'input',
					'subtype'   => 'text',
					'id'    => 'configurator_cdn_setting',
					'name'      => 'configurator_cdn_setting',
					'required' => 'true',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_cdn_setting',
				'iONE cdn',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_general_settings',
				'configurator_general_section',
				$args
			);
			$args = array (
					'type'      => 'input',
					'subtype'   => 'text',
					'id'    => 'configurator_assets_setting',
					'name'      => 'configurator_assets_setting',
					'required' => 'true',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_assets_setting',
				'iONE assets',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_general_settings',
				'configurator_general_section',
				$args
			);
			$args = array (
					'type'      => 'input',
					'subtype'   => 'text',
					'id'    => 'configurator_language_setting',
					'name'      => 'configurator_language_setting',
					'required' => 'true',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_language_setting',
				'iONE language',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_general_settings',
				'configurator_general_section',
				$args
			);
			$args = array (
					'type'      => 'input',
					'subtype'   => 'text',
					'id'    => 'configurator_currency_setting',
					'name'      => 'configurator_currency_setting',
					'required' => 'true',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_currency_setting',
				'Currency Code',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_general_settings',
				'configurator_general_section',
				$args
			);			
			$args = array (
					'type'      => 'input',
					'subtype'   => 'text',
					'id'    => 'configurator_gtm_setting',
					'name'      => 'configurator_gtm_setting',
					'required' => 'true',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_gtm_setting',
				'GTM Code',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_general_settings',
				'configurator_general_section',
				$args
			);
			$args = array (
					'type'      => 'input',
					'subtype'   => 'text',
					'id'    => 'configurator_camera_setting',
					'name'      => 'configurator_camera_setting',
					'required' => 'true',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_camera_setting',
				'Camera Settings',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_general_settings',
				'configurator_general_section',
				$args
			);	
			$args = array (
					'type'      => 'input',
					'subtype'   => 'text',
					'id'    => 'configurator_light_setting',
					'name'      => 'configurator_light_setting',
					'required' => 'true',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_light_setting',
				'Light Settings',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_general_settings',
				'configurator_general_section',
				$args
			);			
			$args = array (
					'type'      => 'input',
					'subtype'   => 'text',
					'id'    => 'configurator_background_setting',
					'name'      => 'configurator_background_setting',
					'required' => 'true',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_background_setting',
				'Canvas Background',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_general_settings',
				'configurator_general_section',
				$args
			);
			$args = array (
					'type'      => 'input',
					'subtype'   => 'checkbox',
					'id'    => 'configurator_AREnabled_setting',
					'name'      => 'configurator_AREnabled_setting',
					'required' => 'true',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_AREnabled_setting',
				'AR enabled',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_general_settings',
				'configurator_general_section',
				$args
			);
			$args = array (
					'type'      => 'input',
					'subtype'   => 'checkbox',
					'id'    => 'configurator_standaloneFloors_setting',
					'name'      => 'configurator_standaloneFloors_setting',
					'required' => 'true',
					'get_options_list' => '',
					'value_type'=>'boolean',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_standaloneFloors_setting',
				'Show Floors',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_general_settings',
				'configurator_general_section',
				$args
			);
			$args = array (
					'type'      => 'input',
					'subtype'   => 'checkbox',
					'id'    => 'configurator_showAsConfigured_setting',
					'name'      => 'configurator_showAsConfigured_setting',
					'required' => 'true',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_showAsConfigured_setting',
				'Show Total Price',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_general_settings',
				'configurator_general_section',
				$args
			);
			$args = array (
					'type'      => 'input',
					'subtype'   => 'checkbox',
					'id'    => 'configurator_show3dwatermark_setting',
					'name'      => 'configurator_show3dwatermark_setting',
					'required' => 'true',
					'value'		=>	'',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_show3dwatermark_setting',
				'Show iONE360 watermark',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_general_settings',
				'configurator_general_section',
				$args
			);
			$args = array (
					'type'      => 'input',
					'subtype'   => 'checkbox',
					'id'    => 'configurator_showiOnewatermark_setting',
					'name'      => 'configurator_showiOnewatermark_setting',
					'required' => 'true',
					'value'		=>	'',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_showiOnewatermark_setting',
				'Show iONE icon (new layout)',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_general_settings',
				'configurator_general_section',
				$args
			);			
			$args = array (
					'type'      => 'input',
					'subtype'   => 'checkbox',
					'id'    => 'configurator_showtagfilter_setting',
					'name'      => 'configurator_showtagfilter_setting',
					'required' => 'true',
					'value'		=>	'',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_showtagfilter_setting',
				'Show Tag Filter',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_general_settings',
				'configurator_general_section',
				$args
			);
			$args = array (
					'type'      => 'input',
					'subtype'   => 'checkbox',
					'id'    => 'configurator_showzoombutton_setting',
					'name'      => 'configurator_showzoombutton_setting',
					'required' => 'true',
					'value'		=>	'',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_showzoombutton_setting',
				'Show Zoom Button',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_general_settings',
				'configurator_general_section',
				$args
			);
			
			$args = array (
					'type'      => 'input',
					'subtype'   => 'checkbox',
					'id'    => 'configurator_showdimensions_setting',
					'name'      => 'configurator_showdimensions_setting',
					'required' => 'true',
					'value'		=>	'',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_showdimensions_setting',
				'Show Dimensions',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_general_settings',
				'configurator_general_section',
				$args
			);
			$args = array (
					'type'      => 'input',
					'subtype'   => 'checkbox',
					'id'    => 'configurator_showdownload_setting',
					'name'      => 'configurator_showdownload_setting',
					'required' => 'true',
					'value'		=>	'',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_showdownload_setting',
				'Show Download',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_general_settings',
				'configurator_general_section',
				$args
			);	
			register_setting('configurator_general_settings', 'configurator_bundle_selections');
			register_setting('configurator_general_settings', 'configurator_endpoint_setting');
			register_setting('configurator_general_settings', 'configurator_scheme_setting');
			register_setting('configurator_general_settings', 'configurator_version_setting');
			register_setting('configurator_general_settings', 'configurator_cdn_setting');
			register_setting('configurator_general_settings', 'configurator_assets_setting');
			register_setting('configurator_general_settings', 'configurator_language_setting');
			register_setting('configurator_general_settings', 'configurator_currency_setting');		
			register_setting('configurator_general_settings', 'configurator_camera_setting');	
			register_setting('configurator_general_settings', 'configurator_light_setting');
			register_setting('configurator_general_settings', 'configurator_background_setting');			
			register_setting('configurator_general_settings', 'configurator_gtm_setting');
			register_setting('configurator_general_settings', 'configurator_lightpresetsindex_setting');
			register_setting('configurator_general_settings', 'configurator_timeoutinms_setting');
			register_setting('configurator_general_settings', 'configurator_standaloneARButton_setting');
			register_setting('configurator_general_settings', 'configurator_AREnabled_setting');
			register_setting('configurator_general_settings', 'configurator_standaloneFloors_setting');
			register_setting('configurator_general_settings', 'configurator_inlineAnswers_setting');
			register_setting('configurator_general_settings', 'configurator_showAsConfigured_setting');
			register_setting('configurator_general_settings', 'configurator_show3dwatermark_setting');
			register_setting('configurator_general_settings', 'configurator_showiOnewatermark_setting');
			register_setting('configurator_general_settings', 'configurator_showtagfilter_setting');
			register_setting('configurator_general_settings', 'configurator_showzoombutton_setting');
			register_setting('configurator_general_settings', 'configurator_showdimensions_setting');
			register_setting('configurator_general_settings', 'configurator_showdownload_setting');
			/* End Configurator Settings */
			
			/* Start Render Settings */
			$args = array (
					'type'      => 'input',
					'subtype'   => 'checkbox',
					'id'    => 'configurator_use_ione_images_setting',
					'name'      => 'configurator_use_ione_images_setting',
					'required' => 'true',
					'value'		=>	'',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_use_ione_images_setting',
				'iONE images only',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_render_settings',
				'configurator_render_settings_section',
				$args
			);			
			$args = array (
					'type'      => 'input',
					'subtype'   => 'checkbox',
					'id'    => 'configurator_use_renders_setting',
					'name'      => 'configurator_use_renders_setting',
					'required' => 'true',
					'value'		=>	'',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_use_renders_setting',
				'Use renders',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_render_settings',
				'configurator_render_settings_section',
				$args
			);			
/* 			$args = array (
					'type'      => 'input',
					'subtype'   => 'text',
					'id'    => 'configurator_render_host_setting',
					'name'      => 'configurator_render_host_setting',
					'required' => 'true',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);		
			add_settings_field(
				'configurator_render_host_setting',
				'iONE host adress',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_render_settings',
				'configurator_render_settings_section',
				$args
			);
			$args = array (
					'type'      => 'input',
					'subtype'   => 'text',
					'id'    => 'configurator_render_port_setting',
					'name'      => 'configurator_render_port_setting',
					'required' => 'true',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_render_port_setting',
				'iONE port',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_render_settings',
				'configurator_render_settings_section',
				$args
			);
			$args = array (
					'type'      => 'input',
					'subtype'   => 'text',
					'id'    => 'configurator_render_environmentIntensity',
					'name'      => 'configurator_render_environmentIntensity',
					'required' => 'true',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_render_environmentIntensity',
				'Environment Intensity',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_render_settings',
				'configurator_render_settings_section',
				$args
			);
			$args = array (
					'type'      => 'input',
					'subtype'   => 'text',
					'id'    => 'configurator_render_imageWidth',
					'name'      => 'configurator_render_imageWidth',
					'required' => 'true',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_render_imageWidth',
				'Image Width',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_render_settings',
				'configurator_render_settings_section',
				$args
			);
			$args = array (
					'type'      => 'input',
					'subtype'   => 'text',
					'id'    => 'configurator_render_imageHeight',
					'name'      => 'configurator_render_imageHeight',
					'required' => 'true',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_render_imageHeight',
				'Image Height',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_render_settings',
				'configurator_render_settings_section',
				$args
			);
			$args = array (
					'type'      => 'input',
					'subtype'   => 'text',
					'id'    => 'configurator_render_iterations',
					'name'      => 'configurator_render_iterations',
					'required' => 'true',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_render_iterations',
				'Render Iterations',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_render_settings',
				'configurator_render_settings_section',
				$args
			); */
			$args = array (
					'type'      => 'input',
					'subtype'   => 'checkbox',
					'id'    => 'configurator_render_button',
					'name'      => 'configurator_render_button',
					'required' => 'true',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_render_button',
				'Force Render Button',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_render_settings',
				'configurator_render_settings_section',
				$args
			);
			$args = array(
				'type'      => 'input',
				'subtype'   => 'image_upload',
				'id'        => 'configurator_render_loader',
				'name'      => 'configurator_render_loader',
				'required'  => 'false',
				'wp_data'   => 'option',
				'value_type'=> 'normal',
			);
			add_settings_field(
				'configurator_render_loader',
				'Upload Render loader',
				array($this, 'configurator_render_settings_field'),
				'configurator_render_settings',
				'configurator_render_settings_section',
				$args
			);				
			register_setting('configurator_render_settings', 'configurator_use_ione_images_setting');			
			register_setting('configurator_render_settings', 'configurator_use_renders_setting');
/* 			register_setting('configurator_render_settings', 'configurator_render_host_setting');
			register_setting('configurator_render_settings', 'configurator_render_port_setting');
			register_setting('configurator_render_settings', 'configurator_render_environmentIntensity');
			register_setting('configurator_render_settings', 'configurator_render_imageWidth');
			register_setting('configurator_render_settings', 'configurator_render_imageHeight');
			register_setting('configurator_render_settings', 'configurator_render_iterations'); */
			register_setting('configurator_render_settings', 'configurator_render_button');
			register_setting('configurator_render_settings', 'configurator_render_loader');
			/* End Render Settings */
			
			/* Layout Settings */
			$args = array (
				'type'      => 'input',
				'subtype'   => 'checkbox',
				'id'    => 'configurator_layout',
				'name'      => 'configurator_layout',
				'required' => 'true',
				'get_options_list' => '',
				'value_type'=>'normal',
				'wp_data' => 'option',
				'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_layout',
				'Use new template (Wordpress)',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_layout_settings',
				'configurator_layout_settings_section',
				$args
			);
			$args = array (
				'type'      => 'input',
				'subtype'   => 'dropdown',
				'id'        => 'configurator_layout_selections',
				'name'      => 'configurator_layout_selections',
				'required'  => 'true',
				'get_options_list' => '',
				'value_type'=> 'normal',
				'wp_data'   => 'option',
				'description' => 'Works only when New Template is disabled.',
				'sanitize_callback' => 'sanitize_text_field',
				'options'   => array(
					'layout1' => 'Default Layout',
					'layout2' => 'Slim layout with numbers'
				)
			);
			add_settings_field(
				'configurator_layout_selections',
				'Use new template only for selections & answers (Wordpress)',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_layout_settings',
				'configurator_layout_settings_section',
				$args
			);				
			$args = array (
				'type'      => 'input',
				'subtype'   => 'checkbox',
				'id'    => 'configurator_showname_text',
				'name'      => 'configurator_showname_text',
				'required' => 'true',
				'get_options_list' => '',
				'value_type'=>'normal',
				'wp_data' => 'option',
				'sanitize_callback' => 'sanitize_text_field'
			);
			
			add_settings_field(
				'configurator_showname_text',
				'Show Product Name',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_layout_settings',
				'configurator_layout_settings_section',
				$args
			);
			$args = array (
				'type'      => 'input',
				'subtype'   => 'checkbox',
				'id'    => 'configurator_show_configure',
				'name'      => 'configurator_show_configure',
				'required' => 'true',
				'get_options_list' => '',
				'value_type'=>'normal',
				'wp_data' => 'option',
				'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_show_configure',
				'Show Configure Text above selections',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_layout_settings',
				'configurator_layout_settings_section',
				$args
			);	
			$args = array (
				'type'      => 'input',
				'subtype'   => 'text',
				'id'    => 'configurator_text_configure',
				'name'      => 'configurator_text_configure',
				'description' => 'When empty, default "Configure" is displayed.',
				'required' => 'true',
				'get_options_list' => '',
				'value_type'=>'normal',
				'wp_data' => 'option',
				'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_text_configure',
				'Text above selections',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_layout_settings',
				'configurator_layout_settings_section',
				$args
			);
			$args = array (
				'type'      => 'input',
				'subtype'   => 'checkbox',
				'id'    => 'configurator_show_from_price',
				'name'      => 'configurator_show_from_price',
				'required' => 'true',
				'get_options_list' => '',
				'value_type'=>'normal',
				'wp_data' => 'option',
				'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_show_from_price',
				'Show From price (new template)',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_layout_settings',
				'configurator_layout_settings_section',
				$args
			);	
			$args = array (
				'type'      => 'input',
				'subtype'   => 'text',
				'id'    => 'configurator_text_from_price',
				'name'      => 'configurator_text_from_price',
				'description' => 'When empty, default "Price from" is displayed.',
				'required' => 'true',
				'get_options_list' => '',
				'value_type'=>'normal',
				'wp_data' => 'option',
				'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_text_from_price',
				'From price text',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_layout_settings',
				'configurator_layout_settings_section',
				$args
			);			
			$args = array (
				'type'      => 'input',
				'subtype'   => 'text',
				'id'    => 'configurator_text_totals',
				'name'      => 'configurator_text_totals',
				'description' => 'When empty, default "As configured" is displayed.',
				'required' => 'true',
				'get_options_list' => '',
				'value_type'=>'normal',
				'wp_data' => 'option',
				'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_text_totals',
				'Text next total price',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_layout_settings',
				'configurator_layout_settings_section',
				$args
			);				
			$args = array (
				'type'      => 'input',
				'subtype'   => 'checkbox',
				'id'    => 'configurator_hideprice_text',
				'name'      => 'configurator_hideprice_text',
				'required' => 'true',
				'get_options_list' => '',
				'value_type'=>'normal',
				'wp_data' => 'option',
				'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_hideprice_text',
				'Hide Total Price',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_layout_settings',
				'configurator_layout_settings_section',
				$args
			);		
			$args = array (
				'type'      => 'input',
				'subtype'   => 'color',
				'id'    => 'configurator_colorheading_config',
				'name'      => 'configurator_colorheading_config',
				'required' => 'true',
				'get_options_list' => '',
				'value_type'=>'normal',
				'wp_data' => 'option',
				'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_colorheading_config',
				'Heading Color',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_layout_settings',
				'configurator_layout_settings_section',
				$args
			);	
			$args = array (
				'type'      => 'input',
				'subtype'   => 'color',
				'id'    => 'configurator_colortext_config',
				'name'      => 'configurator_colortext_config',
				'required' => 'true',
				'get_options_list' => '',
				'value_type'=>'normal',
				'wp_data' => 'option',
				'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_colortext_config',
				'Text Color',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_layout_settings',
				'configurator_layout_settings_section',
				$args
			);	
			$args = array (
				'type'      => 'input',
				'subtype'   => 'color',
				'id'    => 'configurator_colorlabel_config',
				'name'      => 'configurator_colorlabel_config',
				'required' => 'true',
				'get_options_list' => '',
				'value_type'=>'normal',
				'wp_data' => 'option',
				'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_colorlabel_config',
				'Label Color',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_layout_settings',
				'configurator_layout_settings_section',
				$args
			);		
			$args = array (
				'type'      => 'input',
				'subtype'   => 'color',
				'id'    => 'configurator_colorbtn_threed',
				'name'      => 'configurator_colorbtn_threed',
				'required' => 'true',
				'get_options_list' => '',
				'value_type'=>'normal',
				'wp_data' => 'option',
				'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_colorbtn_threed',
				'Buttons Canvas',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_layout_settings',
				'configurator_layout_settings_section',
				$args
			);	
			$args = array (
				'type'      => 'input',
				'subtype'   => 'color',
				'id'    => 'configurator_colorbtntext_threed',
				'name'      => 'configurator_colorbtntext_threed',
				'required' => 'true',
				'get_options_list' => '',
				'value_type'=>'normal',
				'wp_data' => 'option',
				'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_colorbtntext_threed',
				'Buttons Canvas Text',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_layout_settings',
				'configurator_layout_settings_section',
				$args
			);		
			$args = array (
				'type'      => 'input',
				'subtype'   => 'color',
				'id'    => 'configurator_colorbtn_cta',
				'name'      => 'configurator_colorbtn_cta',
				'required' => 'true',
				'get_options_list' => '',
				'value_type'=>'normal',
				'wp_data' => 'option',
				'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_colorbtn_cta',
				'Buttons CTA',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_layout_settings',
				'configurator_layout_settings_section',
				$args
			);
			$args = array (
				'type'      => 'input',
				'subtype'   => 'color',
				'id'    => 'configurator_colorbtn_ctatext',
				'name'      => 'configurator_colorbtn_ctatext',
				'required' => 'true',
				'get_options_list' => '',
				'value_type'=>'normal',
				'wp_data' => 'option',
				'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_colorbtn_ctatext',
				'Buttons CTA Text',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_layout_settings',
				'configurator_layout_settings_section',
				$args
			);
			$args = array (
				'type'      => 'input',
				'subtype'   => 'range3',
				'id'    => 'configurator_cta_radius',
				'name'      => 'configurator_cta_radius',
				'required' => 'true',
				'min' => '0',
				'max' => '30',
				'steps' => '1',
				'get_options_list' => '',
				'value_type'=>'normal',
				'wp_data' => 'option',
				'sanitize_callback' => 'sanitize_text_field'
			);
			
			add_settings_field(
				'configurator_cta_radius',
				'CTA Buttons Radius',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_layout_settings',
				'configurator_layout_settings_section',
				$args
			);		
			$args = array (
				'type'      => 'input',
				'subtype'   => 'range1',
				'id'    => 'configurator_button_radius',
				'name'      => 'configurator_button_radius',
				'required' => 'true',
				'min' => '0',
				'max' => '100',
				'steps' => '5',
				'get_options_list' => '',
				'value_type'=>'normal',
				'wp_data' => 'option',
				'sanitize_callback' => 'sanitize_text_field'
			);
			
			add_settings_field(
				'configurator_button_radius',
				'Buttons Radius',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_layout_settings',
				'configurator_layout_settings_section',
				$args
			);	
			
			$args = array (
				'type'      => 'input',
				'subtype'   => 'range2',
				'id'    => 'configurator_scenewidth_canvas',
				'name'      => 'configurator_scenewidth_canvas',
				'required' => 'true',
				'min' => '0',
				'max' => '100',
				'steps' => '5',
				'get_options_list' => '',
				'value_type'=>'normal',
				'wp_data' => 'option',
				'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_scenewidth_canvas',
				'Image Scene Width',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_layout_settings',
				'configurator_layout_settings_section',
				$args
			);		
			$args = array (
					'type'      => 'input',
					'subtype'   => 'textarea',
					'id'    => 'configurator_custom_css_setting',
					'name'      => 'configurator_custom_css_setting',
					'description' => 'Will be inserted inside style element',
					'required' => 'false',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_custom_css_setting',
				'Custom CSS',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_layout_settings',
				'configurator_layout_settings_section',
				$args
			);
			$args = array(
				'type'      => 'input',
				'subtype'   => 'image_upload',
				'id'        => 'configurator_custom_preloader',
				'name'      => 'configurator_custom_preloader',
				'required'  => 'false',
				'wp_data'   => 'option',
				'value_type'=> 'normal',
			);
			add_settings_field(
				'configurator_custom_preloader',
				'Upload Preloader Image',
				array($this, 'configurator_render_settings_field'),
				'configurator_layout_settings',
				'configurator_layout_settings_section',
				$args
			);			
			register_setting('configurator_layout_settings', 'configurator_layout');	
			register_setting('configurator_layout_settings', 'configurator_layout_selections');
			register_setting('configurator_layout_settings', 'configurator_colorbtn_threed');
			register_setting('configurator_layout_settings', 'configurator_colorbtn_cta');
			register_setting('configurator_layout_settings', 'configurator_colorbtntext_threed');
			register_setting('configurator_layout_settings', 'configurator_colorbtn_ctatext');
			register_setting('configurator_layout_settings', 'configurator_scenewidth_canvas');
			register_setting('configurator_layout_settings', 'configurator_cta_radius');		
			register_setting('configurator_layout_settings', 'configurator_button_radius');		
			register_setting('configurator_layout_settings', 'configurator_colorheading_config');
			register_setting('configurator_layout_settings', 'configurator_colortext_config');
			register_setting('configurator_layout_settings', 'configurator_colorlabel_config');
			register_setting('configurator_layout_settings', 'configurator_showname_text');
			register_setting('configurator_layout_settings', 'configurator_text_configure');
			register_setting('configurator_layout_settings', 'configurator_show_from_price');
			register_setting('configurator_layout_settings', 'configurator_text_from_price');				
			register_setting('configurator_layout_settings', 'configurator_text_totals');			
			register_setting('configurator_layout_settings', 'configurator_show_configure');			
			register_setting('configurator_layout_settings', 'configurator_hideprice_text');
			register_setting('configurator_layout_settings', 'configurator_custom_css_setting');
			register_setting('configurator_layout_settings', 'configurator_custom_preloader');			
			
			/*Start Contact Settings*/
			$args = array (
				'type'      => 'input',
				'subtype'   => 'checkbox',
				'id'    => 'configurator_enable_contact_form',
				'name'      => 'configurator_enable_contact_form',
				'required' => 'true',
				'get_options_list' => '',
				'value_type'=>'normal',
				'wp_data' => 'option',
				'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_enable_contact_form',
				'Enable Contact Form',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_contact_settings',
				'configurator_contact_settings_section',
				$args
			);		
			$args = array (
				'type'      => 'input',
				'subtype'   => 'text',
				'id'    => 'configurator_contact_text_setting',
				'name'      => 'configurator_contact_text_setting',
				'description' => 'When empty, default "Contact us" is displayed.',
				'required' => 'true',
				'get_options_list' => '',
				'value_type'=>'normal',
				'wp_data' => 'option',
				'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_contact_text_setting',
				'Contact Btn Text',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_contact_settings',
				'configurator_contact_settings_section',
				$args
			);		
			$args = array (
					'type'      => 'input',
					'subtype'   => 'checkbox',
					'id'    => 'configurator_contact_enable_email_setting',
					'name'      => 'configurator_contact_enable_email_setting',
					'required' => 'true',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_contact_enable_email_setting',
				'Enable Contact Email',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_contact_settings',
				'configurator_contact_settings_section',
				$args
			);	
			$args = array (
					'type'      => 'input',
					'subtype'   => 'text',
					'id'    => 'configurator_contact_name_setting',
					'name'      => 'configurator_contact_name_setting',
					'required' => 'true',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_contact_name_setting',
				'Contact Email Name',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_contact_settings',
				'configurator_contact_settings_section',
				$args
			);		
			$args = array (
					'type'      => 'input',
					'subtype'   => 'text',
					'id'    => 'configurator_contact_email_setting',
					'name'      => 'configurator_contact_email_setting',
					'required' => 'true',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_contact_email_setting',
				'Contact Email Address',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_contact_settings',
				'configurator_contact_settings_section',
				$args
			);
			$args = array (
					'type'      => 'input',
					'subtype'   => 'text',
					'id'    => 'configurator_contact_bcc_setting',
					'name'      => 'configurator_contact_bcc_setting',
					'required' => 'false',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_contact_bcc_setting',
				'Contact Email BCC',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_contact_settings',
				'configurator_contact_settings_section',
				$args
			);
			$args = array (
					'type'      => 'input',
					'subtype'   => 'text',
					'id'    => 'configurator_contact_subject_setting',
					'name'      => 'configurator_contact_subject_setting',
					'required' => 'false',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_contact_subject_setting',
				'Contact Email Subject',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_contact_settings',
				'configurator_contact_settings_section',
				$args
			);	
			$args = array (
					'type'      => 'input',
					'subtype'   => 'text',
					'id'    => 'configurator_contact_redirect_setting',
					'name'      => 'configurator_contact_redirect_setting',
					'description' => 'When empty, customer will stay on same page, displaying a success message. <br/>Redirect URL relative to websites home URL (example: /success-form).',
					'required' => 'false',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_contact_redirect_setting',
				'Contact Success URL',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_contact_settings',
				'configurator_contact_settings_section',
				$args
			);	
			$args = array (
					'type'      => 'input',
					'subtype'   => 'checkbox',
					'id'    => 'configurator_contact_enable_gdpr_setting',
					'name'      => 'configurator_contact_enable_gdpr_setting',
					'required' => 'true',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_contact_enable_gdpr_setting',
				'Enable GDPR Checkbox',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_contact_settings',
				'configurator_contact_settings_section',
				$args
			);	
			$args = array (
					'type'      => 'input',
					'subtype'   => 'textarea',
					'id'    => 'configurator_contact_gdpr_message_setting',
					'name'      => 'configurator_contact_gdpr_message_setting',
					'description' => 'HTML tags allowed',
					'required' => 'false',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_contact_gdpr_message_setting',
				'GDPR Message',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_contact_settings',
				'configurator_contact_settings_section',
				$args
			);
			$args = array (
					'type'      => 'input',
					'subtype'   => 'text',
					'id'    => 'configurator_gdpr_label_setting',
					'name'      => 'configurator_gdpr_label_setting',
					'required' => 'false',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_gdpr_label_setting',
				'GDPR Checkbox Label',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_contact_settings',
				'configurator_contact_settings_section',
				$args
			);			
			$args = array (
					'type'      => 'input',
					'subtype'   => 'checkbox',
					'id'    => 'configurator_use_recaptcha_setting',
					'name'      => 'configurator_use_recaptcha_setting',
					'required' => 'false',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_use_recaptcha_setting',
				'Enable ReCaptcha',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_contact_settings',
				'configurator_contact_settings_section',
				$args
			);					
			$args = array (
					'type'      => 'input',
					'subtype'   => 'text',
					'id'    => 'configurator_recaptcha_sitekey_setting',
					'name'      => 'configurator_recaptcha_sitekey_setting',
					'required' => 'false',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_recaptcha_sitekey_setting',
				'ReCaptcha SiteKey',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_contact_settings',
				'configurator_contact_settings_section',
				$args
			);	
			$args = array (
					'type'      => 'input',
					'subtype'   => 'text',
					'id'    => 'configurator_recaptcha_secretkey_setting',
					'name'      => 'configurator_recaptcha_secretkey_setting',
					'required' => 'false',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_recaptcha_secretkey_setting',
				'ReCaptcha SecretKey',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_contact_settings',
				'configurator_contact_settings_section',
				$args
			);	
			$args = array (
				'type'      => 'input',
				'subtype'   => 'checkbox',
				'id'    => 'configurator_showprint_button',
				'name'      => 'configurator_showprint_button',
				'required' => 'true',
				'get_options_list' => '',
				'value_type'=>'normal',
				'wp_data' => 'option',
				'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_showprint_button',
				'Show Print Button',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_contact_settings',
				'configurator_contact_settings_section',
				$args
			);
			$args = array (
					'type'      => 'input',
					'subtype'   => 'text',
					'id'    => 'configurator_printtext_setting',
					'name'      => 'configurator_printtext_setting',
					'description' => 'When empty, default "Print to pdf" is displayed.',
					'required' => 'true',
					'get_options_list' => '',
					'value_type'=>'normal',
					'wp_data' => 'option',
					'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'configurator_printtext_setting',
				'Print Button Text',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_contact_settings',
				'configurator_contact_settings_section',
				$args
			);		
				
			register_setting('configurator_contact_settings', 'configurator_enable_contact_form');
			register_setting('configurator_contact_settings', 'configurator_contact_text_setting');		
			register_setting('configurator_contact_settings', 'configurator_contact_enable_email_setting');
			register_setting('configurator_contact_settings', 'configurator_contact_name_setting');
			register_setting('configurator_contact_settings', 'configurator_contact_email_setting');
			register_setting('configurator_contact_settings', 'configurator_contact_bcc_setting');
			register_setting('configurator_contact_settings', 'configurator_contact_subject_setting');
			register_setting('configurator_contact_settings', 'configurator_contact_redirect_setting');	
			register_setting('configurator_contact_settings', 'configurator_contact_gdpr_message_setting');
			register_setting('configurator_contact_settings', 'configurator_contact_enable_gdpr_setting');
			register_setting('configurator_contact_settings', 'configurator_gdpr_label_setting');		
			register_setting('configurator_contact_settings', 'configurator_use_recaptcha_setting');
			register_setting('configurator_contact_settings', 'configurator_recaptcha_sitekey_setting');
			register_setting('configurator_contact_settings', 'configurator_recaptcha_secretkey_setting');
			register_setting('configurator_contact_settings', 'configurator_showprint_button');
			register_setting('configurator_contact_settings', 'configurator_printtext_setting');
		
			/*Start Woocommerce Settings*/
			$args = array (
				'type'      => 'input',
				'subtype'   => 'text',
				'id'    => 'woocommerce_product_page_hook',
				'name'      => 'woocommerce_product_page_hook',
				'description' => 'Default is "woocommerce_before_single_product"',
				'required' => 'false',
				'get_options_list' => '',
				'value_type'=>'normal',
				'wp_data' => 'option',
				'sanitize_callback' => 'sanitize_text_field',
				'default' => 'woocommerce_before_single_product'
			);
			add_settings_field(
				'woocommerce_product_page_hook',
				'Determine Product Page Hook',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_woocommerce_settings',
				'configurator_woocommerce_settings_section',
				$args
			);
			$args = array (
				'type'      => 'input',
				'subtype'   => 'text',
				'id'    => 'woocommerce_product_page_hook_order',
				'name'      => 'woocommerce_product_page_hook_order',
				'description' => 'Default is 11',
				'required' => 'false',
				'get_options_list' => '',
				'value_type'=>'normal',
				'wp_data' => 'option',
				'sanitize_callback' => 'sanitize_text_field',
				'default' => '11'
			);
			add_settings_field(
				'woocommerce_product_page_hook_order',
				'Set Product Page Hook Order',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_woocommerce_settings',
				'configurator_woocommerce_settings_section',
				$args
			);	
			$args = array (
				'type'      => 'input',
				'subtype'   => 'checkbox',
				'id'    => 'woocommerce_show_new_style',
				'name'      => 'woocommerce_show_new_style',
				'required' => 'true',
				'get_options_list' => '',
				'value_type'=>'normal',
				'wp_data' => 'option',
				'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'woocommerce_show_new_style',
				'Show New Template',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_woocommerce_settings',
				'configurator_woocommerce_settings_section',
				$args
			);			
			$args = array (
				'type'      => 'input',
				'subtype'   => 'checkbox',
				'id'    => 'woocommerce_force_full_width_new_style',
				'name'      => 'woocommerce_force_full_width_new_style',
				'required' => 'true',
				'get_options_list' => '',
				'value_type'=>'normal',
				'wp_data' => 'option',
				'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'woocommerce_force_full_width_new_style',
				'Show New Template in Full Width',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_woocommerce_settings',
				'configurator_woocommerce_settings_section',
				$args
			);
			$args = array (
				'type'      => 'input',
				'subtype'   => 'dropdown',
				'id'        => 'woocommerce_layout_selections',
				'name'      => 'woocommerce_layout_selections',
				'required'  => 'true',
				'get_options_list' => '',
				'value_type'=> 'normal',
				'wp_data'   => 'option',
				'sanitize_callback' => 'sanitize_text_field',
				'options'   => array(
					'layout1' => 'Default Layout',
					'layout2' => 'Slim layout with numbers'
				)
			);
			add_settings_field(
				'woocommerce_layout_selections',
				'Use New Template only for selections and answers',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_woocommerce_settings',
				'configurator_woocommerce_settings_section',
				$args
			);
			$args = array (
				'type'      => 'input',
				'subtype'   => 'text',
				'id'    => 'woocommerce_client_layout',
				'name'      => 'woocommerce_client_layout',
				'description' => 'Layout name is provided by consultant.',
				'required' => 'false',
				'get_options_list' => '',
				'value_type'=>'normal',
				'wp_data' => 'option',
				'sanitize_callback' => 'sanitize_text_field',
				'default' => '11'
			);
			add_settings_field(
				'woocommerce_client_layout',
				'Use client override layout. Only in combination with default layout',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_woocommerce_settings',
				'configurator_woocommerce_settings_section',
				$args
			);			
			$args = array (
				'type'      => 'input',
				'subtype'   => 'checkbox',
				'id'    => 'woocommerce_product_page_enable_scroll',
				'name'      => 'woocommerce_product_page_enable_scroll',
				'required' => 'true',
				'get_options_list' => '',
				'value_type'=>'normal',
				'wp_data' => 'option',
				'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'woocommerce_product_page_enable_scroll',
				'Show Button to scroll to configurator',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_woocommerce_settings',
				'configurator_woocommerce_settings_section',
				$args
			);
			$args = array (
				'type'      => 'input',
				'subtype'   => 'text',
				'id'    => 'woocommerce_product_page_scroll_text',
				'name'      => 'woocommerce_product_page_scroll_text',
				'description' => 'default is "Configure"',
				'required' => 'false',
				'get_options_list' => '',
				'value_type'=>'normal',
				'wp_data' => 'option',
				'sanitize_callback' => 'sanitize_text_field',
			);
			add_settings_field(
				'woocommerce_product_page_scroll_text',
				'Change text of scroll button',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_woocommerce_settings',
				'configurator_woocommerce_settings_section',
				$args
			);			
			$args = array (
				'type'      => 'input',
				'subtype'   => 'text',
				'id'    => 'woocommerce_product_page_scroll_hook',
				'name'      => 'woocommerce_product_page_scroll_hook',
				'description' => 'Assign hook when Show scroll button is enabled',
				'required' => 'false',
				'get_options_list' => '',
				'value_type'=>'normal',
				'wp_data' => 'option',
				'sanitize_callback' => 'sanitize_text_field',
			);
			add_settings_field(
				'woocommerce_product_page_scroll_hook',
				'Determine Scroll Button Hook',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_woocommerce_settings',
				'configurator_woocommerce_settings_section',
				$args
			);
			$args = array (
				'type'      => 'input',
				'subtype'   => 'text',
				'id'    => 'woocommerce_product_page_scroll_hook_order',
				'name'      => 'woocommerce_product_page_scroll_hook_order',
				'description' => 'Assign Order when Show scroll button is enabled',
				'required' => 'false',
				'get_options_list' => '',
				'value_type'=>'normal',
				'wp_data' => 'option',
				'sanitize_callback' => 'sanitize_text_field',
				'default' => '11'
			);
			add_settings_field(
				'woocommerce_product_page_scroll_hook_order',
				'Set Product Scroll Button Hook Order',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_woocommerce_settings',
				'configurator_woocommerce_settings_section',
				$args
			);			
			$args = array (
				'type'      => 'input',
				'subtype'   => 'checkbox',
				'id'    => 'woocommerce_show_only_configurator',
				'name'      => 'woocommerce_show_only_configurator',
				'required' => 'true',
				'get_options_list' => '',
				'value_type'=>'normal',
				'wp_data' => 'option',
				'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'woocommerce_show_only_configurator',
				'Replace Product Block with Configurator',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_woocommerce_settings',
				'configurator_woocommerce_settings_section',
				$args
			);	
			$args = array (
				'type'      => 'input',
				'subtype'   => 'checkbox',
				'id'    => 'woocommerce_show_addtocart',
				'name'      => 'woocommerce_show_addtocart',
				'required' => 'true',
				'get_options_list' => '',
				'value_type'=>'normal',
				'wp_data' => 'option',
				'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'woocommerce_show_addtocart',
				'Show Add to cart button',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_woocommerce_settings',
				'configurator_woocommerce_settings_section',
				$args
			);	
			$args = array (
				'type'      => 'input',
				'subtype'   => 'text',
				'id'    => 'woocommerce_text_addtocart',
				'name'      => 'woocommerce_text_addtocart',
				'description' => 'When empty, default "Configure" is displayed.',
				'required' => 'true',
				'get_options_list' => '',
				'value_type'=>'normal',
				'wp_data' => 'option',
				'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'woocommerce_text_addtocart',
				'Text Add to cart button',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_woocommerce_settings',
				'configurator_woocommerce_settings_section',
				$args
			);			
			$args = array (
				'type'      => 'input',
				'subtype'   => 'checkbox',
				'id'    => 'woocommerce_enable_contact_form',
				'name'      => 'woocommerce_enable_contact_form',
				'required' => 'true',
				'get_options_list' => '',
				'value_type'=>'normal',
				'wp_data' => 'option',
				'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'woocommerce_enable_contact_form',
				'Enable Contact Form',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_woocommerce_settings',
				'configurator_woocommerce_settings_section',
				$args
			);
			$args = array (
				'type'      => 'input',
				'subtype'   => 'checkbox',
				'id'    => 'woocommerce_enable_print_pdf',
				'name'      => 'woocommerce_enable_print_pdf',
				'required' => 'true',
				'get_options_list' => '',
				'value_type'=>'normal',
				'wp_data' => 'option',
				'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'woocommerce_enable_print_pdf',
				'Enable PDF/Print',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_woocommerce_settings',
				'configurator_woocommerce_settings_section',
				$args
			);			
			$args = array (
				'type'      => 'input',
				'subtype'   => 'range4',
				'id'    => 'woocommerce_scenewidth_canvas',
				'name'      => 'woocommerce_scenewidth_canvas',
				'required' => 'true',
				'min' => '0',
				'max' => '100',
				'steps' => '5',
				'get_options_list' => '',
				'value_type'=>'normal',
				'wp_data' => 'option',
				'sanitize_callback' => 'sanitize_text_field'
			);
			add_settings_field(
				'woocommerce_scenewidth_canvas',
				'Canvas Scene Width',
				array( $this, 'configurator_render_settings_field' ),
				'configurator_woocommerce_settings',
				'configurator_woocommerce_settings_section',
				$args
			);
			register_setting('configurator_woocommerce_settings', 'woocommerce_product_page_hook');	
			register_setting('configurator_woocommerce_settings', 'woocommerce_product_page_hook_order');	
			register_setting('configurator_woocommerce_settings', 'woocommerce_show_new_style');
			register_setting('configurator_woocommerce_settings', 'woocommerce_force_full_width_new_style');
			register_setting('configurator_woocommerce_settings', 'woocommerce_layout_selections');	
			register_setting('configurator_woocommerce_settings', 'woocommerce_client_layout');
			register_setting('configurator_woocommerce_settings', 'woocommerce_product_page_enable_scroll');
			register_setting('configurator_woocommerce_settings', 'woocommerce_product_page_scroll_text');			
			register_setting('configurator_woocommerce_settings', 'woocommerce_product_page_scroll_hook');	
			register_setting('configurator_woocommerce_settings', 'woocommerce_product_page_scroll_hook_order');			
			register_setting('configurator_woocommerce_settings', 'woocommerce_show_only_configurator');	
			register_setting('configurator_woocommerce_settings', 'woocommerce_text_addtocart');			
			register_setting('configurator_woocommerce_settings', 'woocommerce_show_addtocart');						
			register_setting('configurator_woocommerce_settings', 'woocommerce_enable_contact_form');
			register_setting('configurator_woocommerce_settings', 'woocommerce_enable_print_pdf');
			register_setting('configurator_woocommerce_settings', 'woocommerce_scenewidth_canvas');
		}		
		public function configurator_display_general_account() {
			echo '<p><i>To insert the configurator on your CMS pages, use the following shortcode <br/>"<b>[ione360_configurator sku=123]</b>" (where the sku number can be replaced with the desired sku).</i></p>
			<i>Questions? Please, contact your iONE consultant or go to <a href="https://www.ione360.com" target="_blank">ione360.com</a></i></p>';
		}

		public function configurator_render_settings_field($args) {

			if($args['wp_data'] == 'option'){
				$wp_data_value = get_option($args['name']);
			} elseif($args['wp_data'] == 'post_meta'){
				$wp_data_value = get_post_meta($args['post_id'], $args['name'], true );
			}
			switch ($args['type']) {
				case 'input':
						$value = ($args['value_type'] == 'serialized') ? serialize($wp_data_value) : $wp_data_value;						
						if ($args['subtype'] == 'image_upload') {
							?>
							<div>
								<input type="text" id="<?php echo esc_attr($args['id']); ?>" name="<?php echo esc_attr($args['name']); ?>" value="<?php echo esc_attr($value); ?>" class="regular-text">
								<button type="button" class="button configurator_upload_image_button">Upload Image</button>
							</div>
							<?php if ($value) { ?>
								<div><img src="<?php echo esc_url($value); ?>" style="max-width: 150px; height: auto;"></div>
							<?php } ?>
							<script>
								jQuery(document).ready(function($){
									$('.configurator_upload_image_button').click(function(e) {
										e.preventDefault();
										var button = $(this);
										var custom_uploader = wp.media({
											title: 'Choose Image',
											library: { type: 'image' },
											button: { text: 'Use this Image' },
											multiple: false
										}).on('select', function() {
											var attachment = custom_uploader.state().get('selection').first().toJSON();
											button.prev('input').val(attachment.url);
										}).open();
									});
								});
							</script>
							<?php
						} else if($args['subtype'] != 'checkbox'){
							if($args['subtype'] == 'color') {
								echo '<input type="text" name="'.esc_attr($args['name']).'" data-alpha-enabled="true" data-default-color="rgba(0,0,0,0.85)" value="' . esc_attr($value) . '" class="color-picker" id="'.esc_attr($args['id']).'">';							
							} else if ($args['subtype'] == 'range1') {
								echo '<div class="slidecontainer"><input class="slider" type="range" name="'.esc_attr($args['name']).'" step="' . esc_attr($args['steps']) . '" min="' . esc_attr($args['min']) . '" max="' . esc_attr($args['max']) . '" value="' . esc_attr($value) . '" class="cpa-color-picker" id="myRange1"><p class="counter"><span id="demo1"></span><span class="px">%</span></p></div>';				
							} else if ($args['subtype'] == 'range2') {
								$i = 1;
								echo '<div class="slidecontainer"><input class="slider" type="range" name="'.esc_attr($args['name']).'" step="' . esc_attr($args['steps']) . '" min="' . esc_attr($args['min']) . '" max="' . esc_attr($args['max']) . '" value="' . esc_attr($value) . '" class="cpa-color-picker" id="myRange2"><p class="counter"><span id="demo2"></span><span class="px">%</span></p></div>';
								$i++;
							} else if ($args['subtype'] == 'range3') {
								echo '<div class="slidecontainer"><input class="slider" type="range" name="'.esc_attr($args['name']).'" step="' . esc_attr($args['steps']) . '" min="' . esc_attr($args['min']) . '" max="' . esc_attr($args['max']) . '" value="' . esc_attr($value) . '" class="cpa-color-picker" id="myRange3"><p class="counter"><span id="demo3"></span><span class="px">px</span></p></div>';								
							} else if ($args['subtype'] == 'range4') {
								echo '<div class="slidecontainer"><input class="slider" type="range" name="'.esc_attr($args['name']).'" step="' . esc_attr($args['steps']) . '" min="' . esc_attr($args['min']) . '" max="' . esc_attr($args['max']) . '" value="' . esc_attr($value) . '" class="cpa-color-picker" id="myRange4"><p class="counter"><span id="demo4"></span><span class="px">%</span></p></div>';																						
							} else if ($args['subtype'] == 'textarea') {
								echo '<textarea rows="4" cols="50" id="'.esc_attr($args['id']).'" "'.esc_attr($args['required']).'" ' . 'name="'.esc_attr($args['name']).'">' . esc_attr($value) . '</textarea>';
								if(isset($args['description'])) {
									echo '<p class="description">'.($args['description']).'</p>';
								}
							} else if ($args['subtype'] == 'dropdown') {
									echo '<select name="'.esc_attr($args['name']).'" id="'.esc_attr($args['id']).'">';
									foreach ($args['options'] as $option_value => $option_label) {
										$selected = ($value == $option_value) ? 'selected' : '';
										echo '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . esc_html($option_label) . '</option>';
									}
									echo '</select>';
								if(isset($args['description'])) {
									echo '<p class="description">'.($args['description']).'</p>';
								}									
							} else {
								$prependStart = (isset($args['prepend_value'])) ? '<div class="input-prepend"> <span class="add-on">'.$args['prepend_value'].'</span>' : '';
								$prependEnd = (isset($args['prepend_value'])) ? '</div>' : '';
								$step = (isset($args['step'])) ? 'step="'.$args['step'].'"' : '';
								$min = (isset($args['min'])) ? 'min="'.$args['min'].'"' : '';
								$max = (isset($args['max'])) ? 'max="'.$args['max'].'"' : '';
								if(isset($args['enabled'])){
										echo esc_html($prependStart).'<input type="'.esc_attr($args['subtype']).'" id="'.esc_attr($args['id']).'_disabled" '.esc_attr($step).' '.esc_attr($max).' '.esc_attr($min).' name="'.esc_attr($args['name']).'_disabled" size="40" disabled value="' . esc_attr($value) . '" /><input type="hidden" id="'.esc_attr($args['id']).'" '.esc_attr($step).' '.esc_attr($max).' '.esc_attr($min).' name="'.esc_attr($args['name']).'" size="40" value="' . esc_attr($value) . '" />'.esc_attr($prependEnd);
								} else {
										echo esc_html($prependStart).'<input type="'.esc_attr($args['subtype']).'" id="'.esc_attr($args['id']).'" "'.esc_attr($args['required']).'" '.esc_attr($step).' '.esc_attr($max).' '.esc_attr($min).'name="'.esc_attr($args['name']).'" size="40" value="' . esc_attr($value) . '" />'.esc_attr($prependEnd);
										if(isset($args['description'])) {
											echo '<p class="description">'.($args['description']).'</p>';
										}
								}
							}
						} else {
								$checked = (esc_attr($value)) ? 'checked' : '';
								echo '<div class="toggle-button-cover"><div class="button-cover"><div class="button r" id="button-1"><input class="checkbox" type="'.esc_attr($args['subtype']).'" id="'.esc_attr($args['id']).'" "'.esc_attr($args['required']).'" name="'.esc_attr($args['name']).'" size="40" value="1" '.esc_attr($checked).' /><div class="knobs"></div><div class="slayer"></div></div></div></div>';
						}
						break;
				default:
						# code...
						break;
			}
		}
}
