<?php
/**
 * Admin settings class
 *
 * @since             1.0.0
 * @package           TInvWishlist\Admin
 * @subpackage        Settings
 */

// If this file is called directly, abort.
if ( ! defined( 'ABSPATH' ) ) {
	die;
}

/**
 * Admin settings class
 */
class TInvWL_Admin_Settings_General extends TInvWL_Admin_BaseSection {

	/**
	 * Priority for admin menu
	 *
	 * @var integer
	 */
	public $priority = 20;

	/**
	 * Menu array
	 *
	 * @return array
	 */
	function menu() {
		return array(
			'title'  => __( 'General Settings', 'ti-woocommerce-wishlist' ),
			'method' => array( $this, '_print_' ),
			'slug'   => '',
			'capability' => 'tinvwl_general_settings',
		);
	}

	/**
	 * Create sections for this settings
	 *
	 * @return array
	 */
	function constructor_data() {
		add_action( $this->_name . '_section_before', array( $this, 'premium_features' ), 9 );
		$lists     = get_pages( array( 'number' => 999999 ) ); // @codingStandardsIgnoreLine WordPress.VIP.RestrictedFunctions.get_pages
		$page_list = array( '' => '' );
		foreach ( $lists as $list ) {
			$page_list[ $list->ID ] = $list->post_title;
		}

		return array(
			array(
				'id'         => 'general',
				'title'      => __( 'General Settings', 'ti-woocommerce-wishlist' ),
				'desc'       => __( 'Wishlist page need to be selected so the plugin knows where it is. This page should have been created upon installation of the plugin, if not you will need to create it manually.', 'ti-woocommerce-wishlist' ),
				'show_names' => true,
				'fields'     => array(
					array(
						'type' => 'text',
						'name' => 'default_title',
						'text' => __( 'Default Wishlist Name', 'ti-woocommerce-wishlist' ),
						'std'  => 'Default wishlist',
					),
					array(
						'type'     => 'select',
						'name'     => 'page_wishlist',
						'text'     => __( 'Wishlist Page', 'ti-woocommerce-wishlist' ),
						'std'      => '',
						'options'  => $page_list,
						'validate' => FILTER_VALIDATE_INT,
					),
					array(
						'type'  => 'checkboxonoff',
						'name'  => 'require_login',
						'text'  => __( 'Require Login', 'ti-woocommerce-wishlist' ),
						'desc'  => __( 'Disallows guests to use Wishlist functionality until they sign-in.', 'ti-woocommerce-wishlist' ),
						'std'   => false,
						'extra' => array(
							'tiwl-show' => '.tiwl-general-redirect-require-login',
						),
					),
					array(
						'type'  => 'checkboxonoff',
						'name'  => 'redirect_require_login',
						'text'  => __( 'Redirect to Login Page', 'ti-woocommerce-wishlist' ),
						'desc'  => '<span class="tiwl-button-show-notice-warning-popup"><strong>' . __( 'Currently this option could not be changed because "Show successful notice in popup" is disabled. Guests will be redirected automatically to a login page.', 'ti-woocommerce-wishlist' ) . '</strong></span><span class="tiwl-button-show-notice">' . __( 'If enabled, guests will be redirected to a login page once clicking the "Add to Wishlist" button or "Wishlist Products Counter" link. Otherwise a popup with login required notice will appear.', 'ti-woocommerce-wishlist' ) . '</span>',
						'std'   => false,
						'class' => 'tiwl-general-redirect-require-login',
					),
					array(
						'type' => 'checkboxonoff',
						'name' => 'link_in_myaccount',
						'text' => __( 'Show Link to Wishlist in my account', 'ti-woocommerce-wishlist' ),
						'std'  => true,
					),
					array(
						'type'  => 'checkboxonoff',
						'name'  => 'processing_autoremove',
						'text'  => __( 'Remove Product from Wishlist if added to cart', 'ti-woocommerce-wishlist' ),
						'std'   => true,
						'extra' => array( 'tiwl-show' => '.tiwl-processing-autoremove-anyone' ),
					),
					array(
						'type' => 'checkboxonoff',
						'name' => 'processing_redirect_checkout',
						'text' => __( 'Redirect to the checkout page from Wishlist if added to cart', 'ti-woocommerce-wishlist' ),
						'std'  => false,
					),
					array(
						'type'  => 'checkboxonoff',
						'name'  => 'processing_autoremove_anyone',
						'text'  => __( 'Remove by anyone', 'ti-woocommerce-wishlist' ),
						'std'   => false,
						'class' => 'tiwl-processing-autoremove-anyone',
					),
					array(
						'type'  => 'checkboxonoff',
						'name'  => 'simple_flow',
						'text'  => __( 'Remove product from Wishlist on second click', 'ti-woocommerce-wishlist' ),
						'std'   => false,
						'extra' => array(
							'tiwl-show' => '.tiwl-general-simple-flow>td, .tiwl-button-simple-flow',
							'tiwl-hide' => '.tiwl-general-simple-flow-hide>td',
						),
					),
					array(
						'type' => 'group',
						'id'   => 'show_notice',
					),
					array(
						'type'  => 'checkboxonoff',
						'name'  => 'show_notice',
						'text'  => __( 'Show successful notice in popup', 'ti-woocommerce-wishlist' ),
						'desc'  => __( 'This option allows to show/hide a popup with successful or error notices after addition or removing products from a Wishlist.', 'ti-woocommerce-wishlist' ),
						'std'   => true,
						'extra' => array(
							'tiwl-show' => '.tiwl-button-show-notice',
							'tiwl-hide' => '.tiwl-button-show-notice-warning-popup',
						),
					),
					array(
						'type'  => 'text',
						'name'  => 'text_browse',
						'text'  => __( '"View Wishlist" button Text', 'ti-woocommerce-wishlist' ),
						'std'   => 'View Wishlist',
						'class' => 'tiwl-button-show-notice',
					),
					array(
						'type'  => 'checkboxonoff',
						'name'  => 'redirect',
						'text'  => __( 'Redirect to Wishlist', 'ti-woocommerce-wishlist' ),
						'desc'  => __( 'If enabled, user will be redirected to wishlist page after 5 sec from adding product to wishlist.', 'ti-woocommerce-wishlist' ),
						'std'   => true,
						'class' => 'tiwl-button-show-notice',
					),
					array(
						'type'  => 'text',
						'name'  => 'text_added_to',
						'text'  => __( '"Product added to Wishlist" Text', 'ti-woocommerce-wishlist' ),
						'std'   => 'Product added to Wishlist',
						'class' => 'tiwl-button-show-notice',
					),
					array(
						'type'  => 'text',
						'name'  => 'text_already_in',
						'text'  => __( '"Product already in Wishlist" Text', 'ti-woocommerce-wishlist' ),
						'desc'  => __( 'This notification will be shown if user will try to add a product that is already in the wishlist.', 'ti-woocommerce-wishlist' ),
						'std'   => 'Product already in Wishlist',
						'class' => 'tiwl-button-show-notice tiwl-general-simple-flow-hide',
					),
					array(
						'type'  => 'text',
						'name'  => 'text_removed_from',
						'text'  => __( '"Product removed from Wishlist" Text', 'ti-woocommerce-wishlist' ),
						'desc'  => __( 'This notification will be shown once the product is removed from Wishlist on a single or a catalog page.', 'ti-woocommerce-wishlist' ),
						'std'   => 'Product removed from Wishlist',
						'class' => 'tiwl-button-show-notice tiwl-general-simple-flow',
					),
				),
			),
			array(
				'id'         => 'page',
				'title'      => __( 'Wishlist Page Options', 'ti-woocommerce-wishlist' ),
				'desc'       => __( 'Coming soon', 'ti-woocommerce-wishlist' ),
				'show_names' => true,
				'style'      => 'display:none;',
				'fields'     => array(
					array(
						'type'     => 'select',
						'name'     => 'wishlist',
						'text'     => __( 'My Wishlist', 'ti-woocommerce-wishlist' ),
						'std'      => '',
						'options'  => $page_list,
						'validate' => FILTER_VALIDATE_INT,
					),
				),
			),
			array(
				'id'         => 'processing',
				'title'      => __( 'Wishlist Processing Options', 'ti-woocommerce-wishlist' ),
				'desc'       => __( 'Coming soon', 'ti-woocommerce-wishlist' ),
				'style'      => 'display:none;',
				'show_names' => true,
				'fields'     => array(
					array(
						'type'  => 'checkboxonoff',
						'name'  => 'autoremove',
						'text'  => __( 'Automatic removal', 'ti-woocommerce-wishlist' ),
						'std'   => true,
						'extra' => array( 'tiwl-show' => '.tiwl-processing-autoremove' ),
					),
					array(
						'type'    => 'select',
						'name'    => 'autoremove_status',
						'text'    => __( 'Remove condition', 'ti-woocommerce-wishlist' ),
						'std'     => 'tinvwl-addcart',
						'options' => array(
							'tinvwl-addcart' => __( 'Add to Cart', 'ti-woocommerce-wishlist' ),
						),
						'class'   => 'tiwl-processing-autoremove',
					),
					array(
						'type'  => 'checkboxonoff',
						'name'  => 'redirect_checkout',
						'text'  => __( 'Redirect to the checkout page from Wishlist if added to cart', 'ti-woocommerce-wishlist' ),
						'std'   => false,
						'class' => 'tiwl-processing-redirect-checkout',
					),
					array(
						'type'  => 'checkboxonoff',
						'name'  => 'autoremove_anyone',
						'text'  => __( 'Remove by anyone', 'ti-woocommerce-wishlist' ),
						'std'   => false,
						'class' => 'tiwl-processing-autoremove',
					),
				),
			),
			array(
				'id'         => 'add_to_wishlist',
				'title'      => __( 'Product page "Add to Wishlist" Button Settings', 'ti-woocommerce-wishlist' ),
				'show_names' => true,
				'fields'     => array(
					array(
						'type'    => 'select',
						'name'    => 'position',
						'text'    => __( 'Button position', 'ti-woocommerce-wishlist' ),
						'desc'    => __( 'Add this shortcode <code>[ti_wishlists_addtowishlist]</code> anywhere on product page, if you have chosen custom position for product button. You will have to do this for each product.', 'ti-woocommerce-wishlist' ),
						'std'     => 'after',
						'options' => array(
							'after'     => __( 'After "Add to Cart" button', 'ti-woocommerce-wishlist' ),
							'before'    => __( 'Before "Add to Cart" button', 'ti-woocommerce-wishlist' ),
							'shortcode' => __( 'Custom position with code', 'ti-woocommerce-wishlist' ),
						),
					),
					array(
						'type'    => 'select',
						'name'    => 'type',
						'text'    => __( 'Button type', 'ti-woocommerce-wishlist' ),
						'std'     => 'button',
						'options' => array(
							'link'   => __( 'Link', 'ti-woocommerce-wishlist' ),
							'button' => __( 'Button', 'ti-woocommerce-wishlist' ),
						),
					),
					array(
						'type'    => 'select',
						'name'    => 'icon',
						'text'    => __( '"Add to Wishlist" Icon', 'ti-woocommerce-wishlist' ),
						'desc'    => __( 'You can choose from our predefined icons or upload your custom icon. Custom icon size is limited to 16x16 px.', 'ti-woocommerce-wishlist' ),
						'std'     => 'heart',
						'options' => array(
							''           => __( 'None', 'ti-woocommerce-wishlist' ),
							'heart'      => __( 'Heart', 'ti-woocommerce-wishlist' ),
							'heart-plus' => __( 'Heart+', 'ti-woocommerce-wishlist' ),
							'custom'     => __( 'Custom', 'ti-woocommerce-wishlist' ),
						),
						'extra'   => array(
							'class'      => 'tiwl-button-icon',
							'tiwl-show'  => '.tiwl-button-icon-custom',
							'tiwl-hide'  => '.tiwl-button-icon-style',
							'tiwl-value' => 'custom',
						),
					),
					array(
						'type'  => 'uploadfile',
						'name'  => 'icon_upload',
						'std'   => '',
						'text'  => ' ',
						'class' => 'tiwl-button-icon-custom',
						'extra' => array(
							'button' => array(
								'value' => __( 'Upload', 'ti-woocommerce-wishlist' ),
							),
							'type'   => array( 'image' ),
						),
					),
					array(
						'type'    => 'select',
						'name'    => 'icon_style',
						'std'     => 'black',
						'text'    => __( '"Add to Wishlist" Icon Color', 'ti-woocommerce-wishlist' ),
						'options' => array(
							'black' => __( 'Black', 'ti-woocommerce-wishlist' ),
							'white' => __( 'White', 'ti-woocommerce-wishlist' ),
						),
						'class'   => 'tiwl-button-icon-style',
					),
					array(
						'type'  => 'checkboxonoff',
						'name'  => 'show_text',
						'text'  => __( 'Show button text', 'ti-woocommerce-wishlist' ),
						'std'   => true,
						'extra' => array(
							'tiwl-show' => '.tiwl-button-text',
						),
					),
					array(
						'type'  => 'group',
						'id'    => 'show_text_single',
						'class' => 'tiwl-button-text',
						'style' => 'border-top: 0px; padding-top: 0px;',
					),
					array(
						'type' => 'text',
						'name' => 'text',
						'text' => __( '"Add to Wishlist" button Text', 'ti-woocommerce-wishlist' ),
						'std'  => 'Add to Wishlist',
					),
					array(
						'type'  => 'text',
						'name'  => 'text_remove',
						'text'  => __( '"Remove from Wishlist" Button Text', 'ti-woocommerce-wishlist' ),
						'std'   => 'Remove from Wishlist',
						'class' => 'tiwl-button-simple-flow',
					),
				),
			),
			array(
				'id'         => 'add_to_wishlist_catalog',
				'title'      => __( 'Product listing Button Settings', 'ti-woocommerce-wishlist' ),
				'desc'       => __( 'These are separate settings for the "Add to Wishlist" button on a product listing (Shop page, categories, etc.). You can also adjust button and text colors, size, etc. in a <code>TI Wishlist > Style Options.</code>', 'ti-woocommerce-wishlist' ),
				'show_names' => true,
				'fields'     => array(
					array(
						'type'  => 'checkboxonoff',
						'name'  => 'show_in_loop',
						'text'  => __( 'Show in Product Listing', 'ti-woocommerce-wishlist' ),
						'std'   => true,
						'extra' => array(
							'tiwl-show' => '.tiwl-buttoncat-button',
						),
					),
					array(
						'type'  => 'group',
						'id'    => 'add_to_wishlist_catalog',
						'class' => 'tiwl-buttoncat-button',
						'style' => 'border-top: 0px; padding-top: 0px;',
					),
					array(
						'type'    => 'select',
						'name'    => 'position',
						'text'    => __( 'Button position', 'ti-woocommerce-wishlist' ),
						'std'     => 'after',
						'options' => array(
							'after'       => __( 'After "Add to Cart" button', 'ti-woocommerce-wishlist' ),
							'before'      => __( 'Before "Add to Cart" button', 'ti-woocommerce-wishlist' ),
							'above_thumb' => __( 'Above Thumbnail', 'ti-woocommerce-wishlist' ),
							'shortcode'   => __( 'Custom position with code', 'ti-woocommerce-wishlist' ),
						),
						'desc'    => __( 'Note: if "Custom position with code" option is applied, the "Add to Wishlist" button should be added into template using <code>do_shortcode()</code> function like this:<br /><code>do_shortcode("[ti_wishlists_addtowishlist loop=yes]")</code>', 'ti-woocommerce-wishlist' ),
					),
					array(
						'type'    => 'select',
						'name'    => 'type',
						'text'    => __( 'Button type', 'ti-woocommerce-wishlist' ),
						'std'     => 'button',
						'options' => array(
							'link'   => __( 'Link', 'ti-woocommerce-wishlist' ),
							'button' => __( 'Button', 'ti-woocommerce-wishlist' ),
						),
					),
					array(
						'type'    => 'select',
						'name'    => 'icon',
						'text'    => __( '"Add to Wishlist" Icon', 'ti-woocommerce-wishlist' ),
						'std'     => 'heart',
						'options' => array(
							''           => __( 'None', 'ti-woocommerce-wishlist' ),
							'heart'      => __( 'Heart', 'ti-woocommerce-wishlist' ),
							'heart-plus' => __( 'Heart+', 'ti-woocommerce-wishlist' ),
							'custom'     => __( 'Custom', 'ti-woocommerce-wishlist' ),
						),
						'extra'   => array(
							'tiwl-show'  => '.tiwl-buttoncat-icon-custom',
							'tiwl-hide'  => '.tiwl-buttoncat-icon-style',
							'tiwl-value' => 'custom',
						),
					),
					array(
						'type'  => 'uploadfile',
						'name'  => 'icon_upload',
						'std'   => '',
						'text'  => ' ',
						'class' => 'tiwl-buttoncat-icon-custom',
						'extra' => array(
							'button' => array(
								'value' => __( 'Upload', 'ti-woocommerce-wishlist' ),
							),
							'type'   => array( 'image' ),
						),
					),
					array(
						'type'    => 'select',
						'name'    => 'icon_style',
						'std'     => 'black',
						'text'    => __( '"Add to Wishlist" Icon Color', 'ti-woocommerce-wishlist' ),
						'options' => array(
							'black' => __( 'Black', 'ti-woocommerce-wishlist' ),
							'white' => __( 'White', 'ti-woocommerce-wishlist' ),
						),
						'class'   => 'tiwl-buttoncat-icon-style',
					),
					array(
						'type'  => 'checkboxonoff',
						'name'  => 'show_text',
						'text'  => __( 'Show button text', 'ti-woocommerce-wishlist' ),
						'std'   => true,
						'extra' => array(
							'tiwl-show' => '.tiwl-button-text-catalog',
						),
					),
					array(
						'type'  => 'group',
						'id'    => 'show_text_single',
						'class' => 'tiwl-button-text-catalog',
						'style' => 'border-top: 0px; padding-top: 0px;',
					),
					array(
						'type' => 'text',
						'name' => 'text',
						'text' => __( '"Add to Wishlist" Text', 'ti-woocommerce-wishlist' ),
						'std'  => 'Add to Wishlist',
					),
					array(
						'type'  => 'text',
						'name'  => 'text_remove',
						'text'  => __( '"Remove from Wishlist" Button Text', 'ti-woocommerce-wishlist' ),
						'std'   => 'Remove from Wishlist',
						'class' => 'tiwl-button-simple-flow',
					),
				),
			),
			array(
				'id'         => 'product_table',
				'title'      => __( 'Wishlist Product Settings', 'ti-woocommerce-wishlist' ),
				'desc'       => __( 'Following options allows you to choose what information/functionality to show/enable in wishlist table on wishlist page.', 'ti-woocommerce-wishlist' ),
				'show_names' => true,
				'fields'     => array(
					array(
						'type'  => 'checkboxonoff',
						'name'  => 'add_to_cart',
						'text'  => __( 'Show "Add to Cart" button', 'ti-woocommerce-wishlist' ),
						'std'   => true,
						'extra' => array( 'tiwl-show' => '.tiwl-table-action-addcart' ),
					),
					array(
						'type'  => 'text',
						'name'  => 'text_add_to_cart',
						'text'  => __( '"Add to Cart" Text', 'ti-woocommerce-wishlist' ),
						'std'   => 'Add to Cart',
						'class' => 'tiwl-table-action-addcart',
					),
					array(
						'type' => 'checkboxonoff',
						'name' => 'colm_price',
						'text' => __( 'Show Unit price', 'ti-woocommerce-wishlist' ),
						'std'  => true,
					),
					array(
						'type' => 'checkboxonoff',
						'name' => 'colm_stock',
						'text' => __( 'Show Stock status', 'ti-woocommerce-wishlist' ),
						'std'  => true,
					),
					array(
						'type' => 'checkboxonoff',
						'name' => 'colm_date',
						'text' => __( 'Show Date of addition', 'ti-woocommerce-wishlist' ),
						'std'  => true,
					),
				),
			),
			array(
				'id'         => 'table',
				'title'      => __( 'Wishlist Table Settings', 'ti-woocommerce-wishlist' ),
				'desc'       => __( 'Following options will help user to manage and add products to cart from wishlist table in bulk.', 'ti-woocommerce-wishlist' ),
				'show_names' => true,
				'fields'     => array(
					array(
						'type'  => 'checkboxonoff',
						'name'  => 'colm_checkbox',
						'text'  => __( 'Show Checkboxes', 'ti-woocommerce-wishlist' ),
						'std'   => true,
						'extra' => array( 'tiwl-show' => '.tiwl-table-cb-button' ),
					),
					array(
						'type'  => 'group',
						'id'    => 'cb_button',
						'class' => 'tiwl-table-cb-button',
					),
					array(
						'type' => 'checkboxonoff',
						'name' => 'colm_actions',
						'text' => __( 'Show Actions button', 'ti-woocommerce-wishlist' ),
						'desc' => __( 'Bulk actions drop down at the bottom of wishlist table', 'ti-woocommerce-wishlist' ),
						'std'  => true,
					),
					array(
						'type'  => 'checkboxonoff',
						'name'  => 'add_select_to_cart',
						'text'  => __( 'Show "Add Selected to Cart" button', 'ti-woocommerce-wishlist' ),
						'std'   => true,
						'extra' => array( 'tiwl-show' => '.tiwl-table-addcart-sel' ),
					),
					array(
						'type'  => 'text',
						'name'  => 'text_add_select_to_cart',
						'text'  => __( '"Add Selected to Cart" Button Text', 'ti-woocommerce-wishlist' ),
						'std'   => 'Add Selected to Cart',
						'class' => 'tiwl-table-addcart-sel',
					),
					array(
						'type' => 'group',
						'id'   => '_button',
					),
					array(
						'type'  => 'checkboxonoff',
						'name'  => 'add_all_to_cart',
						'text'  => __( 'Show "Add All to Cart" button', 'ti-woocommerce-wishlist' ),
						'std'   => true,
						'extra' => array( 'tiwl-show' => '.tiwl-table-addcart-all' ),
					),
					array(
						'type'  => 'text',
						'name'  => 'text_add_all_to_cart',
						'text'  => __( '"Add All to Cart" Button Text', 'ti-woocommerce-wishlist' ),
						'std'   => 'Add All to Cart',
						'class' => 'tiwl-table-addcart-all',
					),
				),
			),
			array(
				'id'         => 'social',
				'show_names' => true,
				'fields'     => array(
					array(
						'type'  => 'group',
						'id'    => 'social',
						'desc'  => __( 'Following options enable/disable Social share icons below wishlist table on wishlist page. Wishlist owner can easily share their wishlists using this button on social networks. Wishlist privacy should be set to public or shared status, private wishlists can\'t be shared.', 'ti-woocommerce-wishlist' ),
						'class' => 'tinvwl-info-top',
					),
					array(
						'type'  => 'html',
						'name'  => 'social',
						'text'  => __( 'Social Networks Sharing Options', 'ti-woocommerce-wishlist' ),
						'class' => 'tinvwl-header-row tinvwl-line-border',
					),
					array(
						'type' => 'checkboxonoff',
						'name' => 'facebook',
						'text' => __( 'Show "Facebook" Button', 'ti-woocommerce-wishlist' ),
						'std'  => true,
					),
					array(
						'type' => 'checkboxonoff',
						'name' => 'twitter',
						'text' => __( 'Show "Twitter" Button', 'ti-woocommerce-wishlist' ),
						'std'  => true,
					),
					array(
						'type' => 'checkboxonoff',
						'name' => 'pinterest',
						'text' => __( 'Show "Pinterest" Button', 'ti-woocommerce-wishlist' ),
						'std'  => true,
					),
					array(
						'type' => 'checkboxonoff',
						'name' => 'google',
						'text' => __( 'Show "Google+" Button', 'ti-woocommerce-wishlist' ),
						'std'  => true,
					),
					array(
						'type' => 'checkboxonoff',
						'name' => 'email',
						'text' => __( 'Show "Share by Email" Button', 'ti-woocommerce-wishlist' ),
						'std'  => true,
					),
					array(
						'type' => 'text',
						'name' => 'share_on',
						'text' => __( '"Share on" Text', 'ti-woocommerce-wishlist' ),
						'std'  => 'Share on',
					),
					array(
						'type'     => 'select',
						'name'     => 'icon_style',
						'text'     => __( 'Social Icons Color', 'ti-woocommerce-wishlist' ),
						'options'  => array(
							'dark'  => __( 'Dark', 'ti-woocommerce-wishlist' ),
							'white' => __( 'White', 'ti-woocommerce-wishlist' ),
						),
						'validate' => FILTER_DEFAULT,
					),
				),
			),
			array(
				'id'         => 'topline',
				'title'      => __( 'Wishlist Products Counter', 'ti-woocommerce-wishlist' ),
				'desc'       => sprintf( __( 'Add this shortcode <code>[ti_wishlist_products_counter]</code> anywhere into a page content to show Wishlist Counter.<br/><br/>It can be also added as a widget <code>Wishlist Products Counter</code> under the <a href="%s">Appearance -> Widgets</a> section.', 'ti-woocommerce-wishlist' ), esc_url( admin_url( 'widgets.php' ) ) ),
				'show_names' => true,
				'fields'     => array(
					array(
						'type'    => 'select',
						'name'    => 'icon',
						'text'    => __( '"Wishlist" Icon', 'ti-woocommerce-wishlist' ),
						'std'     => 'heart',
						'options' => array(
							''           => __( 'None', 'ti-woocommerce-wishlist' ),
							'heart'      => __( 'Heart', 'ti-woocommerce-wishlist' ),
							'heart-plus' => __( 'Heart+', 'ti-woocommerce-wishlist' ),
							'custom'     => __( 'Custom', 'ti-woocommerce-wishlist' ),
						),
						'desc'    => __( 'You can choose from our predefined icons or upload your custom icon. Custom icon size is limited to 16x16 px.', 'ti-woocommerce-wishlist' ),
						'extra'   => array(
							'tiwl-show'  => '.tiwl-dropdown-icon-custom',
							'tiwl-hide'  => '.tiwl-dropdown-icon-style',
							'tiwl-value' => 'custom',
						),
					),
					array(
						'type'  => 'uploadfile',
						'name'  => 'icon_upload',
						'std'   => '',
						'text'  => ' ',
						'class' => 'tiwl-dropdown-icon-custom',
						'extra' => array(
							'button' => array(
								'value' => __( 'Upload', 'ti-woocommerce-wishlist' ),
							),
							'type'   => array( 'image' ),
						),
					),
					array(
						'type'    => 'select',
						'name'    => 'icon_style',
						'std'     => 'black',
						'text'    => __( '"Wishlist" Icon Color', 'ti-woocommerce-wishlist' ),
						'options' => array(
							'black' => __( 'Black', 'ti-woocommerce-wishlist' ),
							'white' => __( 'White', 'ti-woocommerce-wishlist' ),
						),
						'class'   => 'tiwl-dropdown-icon-style',
					),
					array(
						'type'  => 'checkboxonoff',
						'name'  => 'show_text',
						'text'  => __( 'Show counter text', 'ti-woocommerce-wishlist' ),
						'std'   => true,
						'extra' => array(
							'tiwl-show' => '.tiwl-dropdown-text',
						),
					),
					array(
						'type'  => 'text',
						'name'  => 'text',
						'text'  => __( 'Counter Text', 'ti-woocommerce-wishlist' ),
						'std'   => __( 'Wishlist - ', 'ti-woocommerce-wishlist' ),
						'class' => 'tiwl-dropdown-text',
					),
				),
			),
			array(
				'id'     => 'save_buttons',
				'class'  => 'only-button',
				'noform' => true,
				'fields' => array(
					array(
						'type'  => 'button_submit',
						'name'  => 'setting_save',
						'std'   => '<span><i class="ftinvwl ftinvwl-check"></i></span>' . __( 'Save Settings', 'ti-woocommerce-wishlist' ),
						'extra' => array( 'class' => 'tinvwl-btn split status-btn-ok' ),
					),
					array(
						'type'  => 'button_submit',
						'name'  => 'setting_reset',
						'std'   => '<span><i class="ftinvwl ftinvwl-times"></i></span>' . __( 'Reset', 'ti-woocommerce-wishlist' ),
						'extra' => array( 'class' => 'tinvwl-btn split status-btn-ok tinvwl-confirm-reset' ),
					),
					array(
						'type' => 'button_submit_quick',
						'name' => 'setting_save_quick',
						'std'  => '<span><i class="ftinvwl ftinvwl-floppy-o"></i></span>' . __( 'Save', 'ti-woocommerce-wishlist' ),
					),
				),
			),
		);
	}

	/**
	 * Load value from database
	 *
	 * @param array $sections Sections array.
	 *
	 * @return array
	 */
	function constructor_load( $sections ) {
		$data                                            = parent::constructor_load( $sections );
		$data['general']['page_wishlist']                = $data['page']['wishlist'];
		$data['general']['processing_autoremove']        = $data['processing']['autoremove'];
		$data['general']['processing_autoremove_anyone'] = $data['processing']['autoremove_anyone'];
		$data['general']['processing_redirect_checkout'] = $data['processing']['redirect_checkout'];

		return $data;
	}

	/**
	 * Save value to database and flush rewrite.
	 *
	 * @param array $data Post section data.
	 */
	function constructor_save( $data ) {
		parent::constructor_save( $data );
		if ( empty( $data ) || ! is_array( $data ) ) {
			return false;
		}
		tinv_update_option( 'page', 'wishlist', $data['general']['page_wishlist'] );
		tinv_update_option( 'processing', 'autoremove', $data['general']['processing_autoremove'] );
		tinv_update_option( 'processing', 'autoremove_anyone', $data['general']['processing_autoremove_anyone'] );
		tinv_update_option( 'processing', 'redirect_checkout', $data['general']['processing_redirect_checkout'] );
		tinv_update_option( 'processing', 'autoremove_status', 'tinvwl-addcart' );
		if ( filter_input( INPUT_POST, 'save_buttons-setting_reset' ) ) {
			foreach ( $data as $key => $value ) {
				if ( ! in_array( $key, array( 'page' ) ) ) {
					$data[ $key ] = array();
				}
			}
			parent::constructor_save( $data );
		}
		TInvWL_Public_TInvWL::update_rewrite_rules();
	}

	/**
	 * Show Premium Features sections
	 */
	function premium_features() {
		TInvWL_View::view( 'premium-features' );
	}
}
