<?php
namespace FinchCart\Admin\Settings;

use function FinchCart\fc_kses_allowed_svg;
use EDITH;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Plugin Settings Class
 */
class PluginSettings {

	/**
	 * Class Constructor.
	 */
	public function __construct() {
		add_action( 'after_setup_theme', array( $this, 'adding_plugin_settings' ) );
	}

	/**
	 * Is pro version activated or not
	 *
	 * @since      1.0.0
	 */
	public function is_pro_activated() {
		return class_exists( 'FinchCartPro' );
	}

	/**
	 * Adding Plugin Settings Page
	 *
	 * @return void
	 */
	public function adding_plugin_settings() {
		$prefix       = 'finchcart_settings_';
		$settings_svg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><g id="cart"><path class="cls-1" d="M29.46 10.14A2.94 2.94 0 0 0 27.1 9H10.22L8.76 6.35A2.67 2.67 0 0 0 6.41 5H3a1 1 0 0 0 0 2h3.41a.68.68 0 0 1 .6.31l1.65 3 .86 9.32a3.84 3.84 0 0 0 4 3.38h10.37a3.92 3.92 0 0 0 3.85-2.78l2.17-7.82a2.58 2.58 0 0 0-.45-2.27zM28 11.86l-2.17 7.83A1.93 1.93 0 0 1 23.89 21H13.48a1.89 1.89 0 0 1-2-1.56L10.73 11H27.1a1 1 0 0 1 .77.35.59.59 0 0 1 .13.51z"/><circle class="cls-1" cx="14" cy="26" r="2"/><circle class="cls-1" cx="24" cy="26" r="2"/></g></svg>';
		$menu_svg     = '<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M2.08416 2.7512C2.22155 2.36044 2.6497 2.15503 3.04047 2.29242L3.34187 2.39838C3.95839 2.61511 4.48203 2.79919 4.89411 3.00139C5.33474 3.21759 5.71259 3.48393 5.99677 3.89979C6.27875 4.31243 6.39517 4.76515 6.4489 5.26153C6.47295 5.48373 6.48564 5.72967 6.49233 6H17.1305C18.8155 6 20.3323 6 20.7762 6.57708C21.2202 7.15417 21.0466 8.02369 20.6995 9.76275L20.1997 12.1875C19.8846 13.7164 19.727 14.4808 19.1753 14.9304C18.6236 15.38 17.8431 15.38 16.2821 15.38H10.9792C8.19028 15.38 6.79583 15.38 5.92943 14.4662C5.06302 13.5523 4.99979 12.5816 4.99979 9.64L4.99979 7.03832C4.99979 6.29837 4.99877 5.80316 4.95761 5.42295C4.91828 5.0596 4.84858 4.87818 4.75832 4.74609C4.67026 4.61723 4.53659 4.4968 4.23336 4.34802C3.91052 4.18961 3.47177 4.03406 2.80416 3.79934L2.54295 3.7075C2.15218 3.57012 1.94678 3.14197 2.08416 2.7512Z" fill="#1C274C"></path> <path d="M7.5 18C8.32843 18 9 18.6716 9 19.5C9 20.3284 8.32843 21 7.5 21C6.67157 21 6 20.3284 6 19.5C6 18.6716 6.67157 18 7.5 18Z" fill="#1C274C"></path> <path d="M16.5 18.0001C17.3284 18.0001 18 18.6716 18 19.5001C18 20.3285 17.3284 21.0001 16.5 21.0001C15.6716 21.0001 15 20.3285 15 19.5001C15 18.6716 15.6716 18.0001 16.5 18.0001Z" fill="#1C274C"></path> </g></svg>';

		EDITH::createOptions(
			$prefix,
			array(
				'framework_title' => wp_kses( $settings_svg, fc_kses_allowed_svg() ) . esc_html__( ' Finch Cart', 'finch-cart-product-recommendations' ),
				'menu_icon'       => 'data:image/svg+xml;base64,' . base64_encode( $menu_svg ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
				'menu_title'      => esc_html__( 'Finch Cart', 'finch-cart-product-recommendations' ),
				'menu_slug'       => 'finch-cart-settings',
				'menu_type'       => 'menu',
				'menu_capability' => 'manage_options',
				'show_bar_menu'   => false,
				'show_sub_menu'   => false,
				'show_search'     => true,
				'footer_credit'   => false,
				'footer_text'     => false,
				'theme'           => 'light',
				'nav'             => 'normal',
				'menu_position'   => 60,
				'database'        => 'options',
				'ajax_save'       => true,
			)
		);

		EDITH::createSection(
			$prefix,
			array(
				'title' => esc_html__( 'Popup Content', 'finch-cart-product-recommendations' ),
				'id'    => $prefix . 'content',
				'icon'  => 'far fa-newspaper',
			)
		);

		EDITH::createSection(
			$prefix,
			array(
				'title'  => esc_html__( 'Notification', 'finch-cart-product-recommendations' ),
				'parent' => $prefix . 'content',
				'icon'   => 'fas fa-bell',
				'fields' => array(
					array(
						'id'       => 'finchcart_show_notification',
						'type'     => 'switcher',
						'title'    => esc_html__( 'Show Notification', 'finch-cart-product-recommendations' ),
						'subtitle' => esc_html__( 'This option allows you to turn on or off the added to cart notice in the popup.', 'finch-cart-product-recommendations' ),
						'default'  => true,
					),
					array(
						'id'         => 'finchcart_notification_content',
						'type'       => 'fieldset',
						'class'      => 'edith-fieldset-inline',
						'title'      => esc_html__( 'Notification Content', 'finch-cart-product-recommendations' ),
						'subtitle'   => esc_html__( 'Each part of content in the notification can be turn on or off.', 'finch-cart-product-recommendations' ),
						'fields'     => array(
							array(
								'id'    => 'finchcart_notice_show_image',
								'type'  => 'switcher',
								'title' => esc_html__( 'Product Image', 'finch-cart-product-recommendations' ),
								'help'  => esc_html__( 'This option allows you to toggle the product image on or off in the added to cart notice.', 'finch-cart-product-recommendations' ),
							),
							array(
								'id'    => 'finchcart_notice_show_view_cart',
								'type'  => 'switcher',
								'title' => esc_html__( 'View Cart Link', 'finch-cart-product-recommendations' ),
								'help'  => esc_html__( 'You can turn the view cart link on or off in the added to cart notice by using this option.', 'finch-cart-product-recommendations' ),
							),
							array(
								'id'    => 'finchcart_notice_show_con_shop',
								'type'  => 'switcher',
								'title' => esc_html__( 'Continue Shopping', 'finch-cart-product-recommendations' ),
								'help'  => esc_html__( 'This option allows you to toggle the "Continue Shopping" button in the "added to cart" notice on and off.', 'finch-cart-product-recommendations' ),
							),
							array(
								'id'    => 'finchcart_notice_show_checkout',
								'type'  => 'switcher',
								'title' => esc_html__( 'Checkout', 'finch-cart-product-recommendations' ),
								'help'  => esc_html__( 'You can turn on and off the "Checkout" button in the added to cart notice with this option.', 'finch-cart-product-recommendations' ),
							),
							array(
								'id'    => 'finchcart_notice_show_cart_count',
								'type'  => 'switcher',
								'title' => esc_html__( 'Cart Count', 'finch-cart-product-recommendations' ),
								'help'  => esc_html__( 'This option allows you to toggle the "Cart Count" in the added to cart notice on and off.', 'finch-cart-product-recommendations' ),
							),
						),
						'default'    => array(
							'finchcart_notice_show_image' => true,
							'finchcart_notice_show_view_cart' => true,
							'finchcart_notice_show_con_shop' => true,
							'finchcart_notice_show_checkout' => true,
							'finchcart_notice_show_cart_count' => true,
						),
						'dependency' => array( 'finchcart_show_notification', '==', 'true' ),
					),
					array(
						'id'         => 'finchcart_notice_message_text',
						'type'       => 'text',
						'title'      => esc_html__( 'Custom Added-to-cart Message', 'finch-cart-product-recommendations' ),
						'subtitle'   => esc_html__( 'You can add your own custom added-to-cart message text here. For the product title, use pattern %title%.', 'finch-cart-product-recommendations' ),
						'default'    => esc_html__( '%title% has been added to your cart.', 'finch-cart-product-recommendations' ),
						'dependency' => array(
							array( 'finchcart_show_notification', '==', 'true' ),
						),
					),
					array(
						'id'         => 'finchcart_notification_btns_label',
						'type'       => 'fieldset',
						'class'      => 'edith-fieldset-inline',
						'title'      => esc_html__( 'Notification Bar Buttons Label', 'finch-cart-product-recommendations' ),
						'subtitle'   => esc_html__( 'These settings allow you to modify the buttons text in the notification area.', 'finch-cart-product-recommendations' ),
						'fields'     => array(
							array(
								'id'    => 'finchcart_notice_cart_link',
								'type'  => 'text',
								'title' => esc_html__( 'Cart Link Text', 'finch-cart-product-recommendations' ),
							),
							array(
								'id'    => 'finchcart_notice_con_shop_text',
								'type'  => 'text',
								'title' => esc_html__( 'Continue Shopping Text', 'finch-cart-product-recommendations' ),
							),
							array(
								'id'    => 'finchcart_notice_checkout_text',
								'type'  => 'text',
								'title' => esc_html__( 'Checkout Text', 'finch-cart-product-recommendations' ),
							),
						),
						'default'    => array(
							'finchcart_notice_cart_link' => esc_html__( 'View Cart →', 'finch-cart-product-recommendations' ),
							'finchcart_notice_con_shop_text' => esc_html__( 'Continue Shopping', 'finch-cart-product-recommendations' ),
							'finchcart_notice_checkout_text' => esc_html__( 'Checkout', 'finch-cart-product-recommendations' ),
						),
						'dependency' => array( 'finchcart_show_notification', '==', 'true' ),
					),
				),
			)
		);

		EDITH::createSection(
			$prefix,
			array(
				'title'  => esc_html__( 'Heading', 'finch-cart-product-recommendations' ),
				'parent' => $prefix . 'content',
				'icon'   => 'fas fa-heading',
				'fields' => array(
					array(
						'id'       => 'finchcart_show_heading',
						'type'     => 'switcher',
						'title'    => esc_html__( 'Show Heading', 'finch-cart-product-recommendations' ),
						'subtitle' => esc_html__( 'This option allows you to turn on or off the added to cart heading in the popup.', 'finch-cart-product-recommendations' ),
						'default'  => true,
					),
					array(
						'id'            => 'finchcart_default_heading_text',
						'title'         => esc_html__( 'Default Heading', 'finch-cart-product-recommendations' ),
						'subtitle'      => esc_html__( 'Use the default heading if you want to use the same heading format for all recommendation. For the product title, use pattern %title%. You may change the pattern [item, items] to suit your preferences. You can change the pattern [item, items] to suit your needs based on the recommended singular and plural products.', 'finch-cart-product-recommendations' ),
						'type'          => 'wp_editor',
						'height'        => '100px',
						'media_buttons' => false,
						'default'       => esc_html__( 'You may purchase the following [item, items] with the %title%', 'finch-cart-product-recommendations' ),
						'dependency'    => array( 'finchcart_show_heading', '==', 'true' ),
					),
					array(
						'id'            => 'finchcart_default_subheading_text',
						'title'         => esc_html__( 'Default Heading Description', 'finch-cart-product-recommendations' ),
						'subtitle'      => esc_html__( 'You can add your heading description text here.', 'finch-cart-product-recommendations' ),
						'type'          => 'wp_editor',
						'height'        => '100px',
						'media_buttons' => false,
						'dependency'    => array( 'finchcart_show_heading', '==', 'true' ),
					),
				),
			)
		);

		EDITH::createSection(
			$prefix,
			array(
				'title'  => esc_html__( 'Products', 'finch-cart-product-recommendations' ),
				'parent' => $prefix . 'content',
				'icon'   => 'fas fa-boxes',
				'fields' => array(
					array(
						'id'       => 'finchcart_products_layout',
						'type'     => 'button_set',
						'title'    => esc_html__( 'Products Layout', 'finch-cart-product-recommendations' ),
						'subtitle' => esc_html__( 'In the popup, the recommended products may be displayed as a list, grid, or slider.', 'finch-cart-product-recommendations' ),
						'options'  => array(
							'grid'   => esc_html__( 'Grid', 'finch-cart-product-recommendations' ),
							'slider' => esc_html__( 'Slider', 'finch-cart-product-recommendations' ),
							'list'   => esc_html__( 'List', 'finch-cart-product-recommendations' ),
						),
						'default'  => 'grid',
					),
					array(
						'id'         => 'finchcart_grid_columns',
						'type'       => 'fieldset',
						'class'      => 'edith-fieldset-inline',
						'title'      => esc_html__( 'Grid Column Settings', 'finch-cart-product-recommendations' ),
						'subtitle'   => esc_html__( 'The product grid columns and gap are adjustable for different screens.', 'finch-cart-product-recommendations' ),
						'dependency' => array( 'finchcart_products_layout', '==', 'grid' ),
						'fields'     => array(
							array(
								'id'       => 'finchcart_grid_columns_desktop',
								'type'     => 'number',
								'title'    => esc_html__( 'Desktop', 'finch-cart-product-recommendations' ),
								'subtitle' => esc_html__( 'For large screen.', 'finch-cart-product-recommendations' ),
								'default'  => 5,
							),
							array(
								'id'       => 'finchcart_grid_columns_small_desktop',
								'type'     => 'number',
								'title'    => esc_html__( 'Small Desktop', 'finch-cart-product-recommendations' ),
								'subtitle' => esc_html__( 'For 900px screen.', 'finch-cart-product-recommendations' ),
								'default'  => 4,
							),
							array(
								'id'       => 'finchcart_grid_columns_tablet',
								'type'     => 'number',
								'title'    => esc_html__( 'Tablet', 'finch-cart-product-recommendations' ),
								'subtitle' => esc_html__( 'For 768px screen.', 'finch-cart-product-recommendations' ),
								'default'  => 3,
							),
							array(
								'id'       => 'finchcart_grid_columns_large_mobile',
								'type'     => 'number',
								'title'    => esc_html__( 'Large Mobile', 'finch-cart-product-recommendations' ),
								'subtitle' => esc_html__( 'For 500px screen.', 'finch-cart-product-recommendations' ),
								'default'  => 2,
							),
							array(
								'id'       => 'finchcart_grid_columns_mobile',
								'type'     => 'number',
								'title'    => esc_html__( 'Mobile', 'finch-cart-product-recommendations' ),
								'subtitle' => esc_html__( 'For 400px screen.', 'finch-cart-product-recommendations' ),
								'default'  => 1,
							),
							array(
								'id'          => 'finchcart_grid_columns_gap',
								'type'        => 'number',
								'title'       => esc_html__( 'Columns Gap', 'finch-cart-product-recommendations' ),
								'subtitle'    => esc_html__( 'Gap between items.', 'finch-cart-product-recommendations' ),
								'unit'        => esc_html__( 'rem', 'finch-cart-product-recommendations' ),
								'output'      => '.finchcart-modal-products',
								'output_mode' => 'gap',
								'default'     => 2,
							),
						),
					),
					array(
						'id'         => 'finchcart_slider_columns',
						'type'       => 'fieldset',
						'class'      => 'edith-fieldset-inline',
						'title'      => esc_html__( 'Slider Column Settings', 'finch-cart-product-recommendations' ),
						'subtitle'   => esc_html__( 'The product slider columns and gap are adjustable for different screens.', 'finch-cart-product-recommendations' ),
						'dependency' => array( 'finchcart_products_layout', '==', 'slider' ),
						'fields'     => array(
							array(
								'id'       => 'finchcart_slider_columns_desktop',
								'type'     => 'number',
								'title'    => esc_html__( 'Desktop', 'finch-cart-product-recommendations' ),
								'subtitle' => esc_html__( 'For large screen.', 'finch-cart-product-recommendations' ),
								'default'  => 5,
							),
							array(
								'id'       => 'finchcart_slider_columns_small_desktop',
								'type'     => 'number',
								'title'    => esc_html__( 'Small Desktop', 'finch-cart-product-recommendations' ),
								'subtitle' => esc_html__( 'For 900px screen.', 'finch-cart-product-recommendations' ),
								'default'  => 4,
							),
							array(
								'id'       => 'finchcart_slider_columns_tablet',
								'type'     => 'number',
								'title'    => esc_html__( 'Tablet', 'finch-cart-product-recommendations' ),
								'subtitle' => esc_html__( 'For 768px screen.', 'finch-cart-product-recommendations' ),
								'default'  => 3,
							),
							array(
								'id'       => 'finchcart_slider_columns_large_mobile',
								'type'     => 'number',
								'title'    => esc_html__( 'Large Mobile', 'finch-cart-product-recommendations' ),
								'subtitle' => esc_html__( 'For 500px screen.', 'finch-cart-product-recommendations' ),
								'default'  => 2,
							),
							array(
								'id'       => 'finchcart_slider_columns_mobile',
								'type'     => 'number',
								'title'    => esc_html__( 'Mobile', 'finch-cart-product-recommendations' ),
								'subtitle' => esc_html__( 'For 400px screen.', 'finch-cart-product-recommendations' ),
								'default'  => 1,
							),
						),
					),
					array(
						'id'         => 'finchcart_slider_options',
						'type'       => 'fieldset',
						'class'      => 'edith-fieldset-inline',
						'title'      => esc_html__( 'Slider Options', 'finch-cart-product-recommendations' ),
						'subtitle'   => esc_html__( 'These settings allow you to change the behavior of the product slider.', 'finch-cart-product-recommendations' ),
						'dependency' => array( 'finchcart_products_layout', '==', 'slider' ),
						'fields'     => array(
							array(
								'id'      => 'finchcart_slider_autoplay',
								'type'    => 'switcher',
								'title'   => esc_html__( 'Slider Autoplay', 'finch-cart-product-recommendations' ),
								'default' => true,
							),
							array(
								'id'      => 'finchcart_slider_autoplay_speed',
								'type'    => 'number',
								'title'   => esc_html__( 'Auto Play Speed', 'finch-cart-product-recommendations' ),
								'unit'    => esc_html__( 'ms', 'finch-cart-product-recommendations' ),
								'default' => 3000,
							),
							array(
								'id'      => 'finchcart_slider_loop',
								'type'    => 'switcher',
								'title'   => esc_html__( 'Slider Loop', 'finch-cart-product-recommendations' ),
								'default' => true,
							),
							array(
								'id'      => 'finchcart_slider_columns_gap',
								'type'    => 'number',
								'title'   => esc_html__( 'Columns Gap', 'finch-cart-product-recommendations' ),
								'unit'    => esc_html__( 'px', 'finch-cart-product-recommendations' ),
								'default' => 30,
							),
						),
					),
					array(
						'id'         => 'finchcart_list_columns',
						'type'       => 'fieldset',
						'class'      => 'edith-fieldset-inline',
						'title'      => esc_html__( 'List Column Settings', 'finch-cart-product-recommendations' ),
						'subtitle'   => esc_html__( 'The product list columns and gap are adjustable for different screens.', 'finch-cart-product-recommendations' ),
						'dependency' => array( 'finchcart_products_layout', '==', 'list' ),
						'fields'     => array(
							array(
								'id'       => 'finchcart_list_columns_desktop',
								'type'     => 'number',
								'title'    => esc_html__( 'Desktop', 'finch-cart-product-recommendations' ),
								'subtitle' => esc_html__( 'For large screen.', 'finch-cart-product-recommendations' ),
								'default'  => 3,
							),
							array(
								'id'       => 'finchcart_list_columns_small_desktop',
								'type'     => 'number',
								'title'    => esc_html__( 'Small Desktop', 'finch-cart-product-recommendations' ),
								'subtitle' => esc_html__( 'For 900px screen.', 'finch-cart-product-recommendations' ),
								'default'  => 2,
							),
							array(
								'id'       => 'finchcart_list_columns_tablet',
								'type'     => 'number',
								'title'    => esc_html__( 'Tablet', 'finch-cart-product-recommendations' ),
								'subtitle' => esc_html__( 'For 768px screen.', 'finch-cart-product-recommendations' ),
								'default'  => 2,
							),
							array(
								'id'       => 'finchcart_list_columns_large_mobile',
								'type'     => 'number',
								'title'    => esc_html__( 'Large Mobile', 'finch-cart-product-recommendations' ),
								'subtitle' => esc_html__( 'For 500px screen.', 'finch-cart-product-recommendations' ),
								'default'  => 1,
							),
							array(
								'id'       => 'finchcart_list_columns_mobile',
								'type'     => 'number',
								'title'    => esc_html__( 'Mobile', 'finch-cart-product-recommendations' ),
								'subtitle' => esc_html__( 'For 400px screen.', 'finch-cart-product-recommendations' ),
								'default'  => 1,
							),
							array(
								'id'          => 'finchcart_list_columns_gap',
								'type'        => 'number',
								'title'       => esc_html__( 'Columns Gap', 'finch-cart-product-recommendations' ),
								'subtitle'    => esc_html__( 'Gap between items.', 'finch-cart-product-recommendations' ),
								'unit'        => esc_html__( 'rem', 'finch-cart-product-recommendations' ),
								'output'      => '.finchcart-modal-products-list',
								'output_mode' => 'gap',
								'default'     => 2,
							),
						),
					),
				),
			)
		);

		EDITH::createSection(
			$prefix,
			array(
				'title'       => esc_html__( 'Product Recommendations', 'finch-cart-product-recommendations' ),
				'description' => esc_html__( 'If no configuration is found on each product edit page, this global product recommendation will be used as a fallback.', 'finch-cart-product-recommendations' ),
				'icon'        => 'fas fa-globe',
				'fields'      => array(
					array(
						'id'       => 'finchcart_global_product_recommendations',
						'type'     => 'switcher',
						'title'    => esc_html__( 'Global Product Recommendations', 'finch-cart-product-recommendations' ),
						'subtitle' => esc_html__( 'The global product recommendations for all the products can be toggle on or off using this option.', 'finch-cart-product-recommendations' ),
						'default'  => true,
					),
					array(
						'id'       => 'finchcart_global_product_recommendations_type',
						'type'     => 'button_set',
						'title'    => esc_html__( 'Recommendation Type', 'finch-cart-product-recommendations' ),
						'subtitle' => esc_html__( 'You can choose recommended products from different sources.', 'finch-cart-product-recommendations' ),
						'options'  => array(
							'related' => esc_html__( 'Product Related Categories', 'finch-cart-product-recommendations' ),
							'manual'  => esc_html__( 'Manually Select Categories', 'finch-cart-product-recommendations' ),
						),
						'default'  => 'related',
					),
					array(
						'id'          => 'finchcart_global_categories',
						'type'        => 'select',
						'title'       => esc_html__( 'Select Product Categories', 'finch-cart-product-recommendations' ),
						'subtitle'    => esc_html__( 'Include the product categories that you like to have displayed as global recommendations for those products.', 'finch-cart-product-recommendations' ),
						'placeholder' => esc_html__( 'Select product categories', 'finch-cart-product-recommendations' ),
						'chosen'      => true,
						'multiple'    => true,
						'sortable'    => true,
						'ajax'        => true,
						'options'     => 'categories',
						'query_args'  => array(
							'taxonomy' => 'product_cat',
						),
						'dependency'  => array( 'finchcart_global_product_recommendations_type', '==', 'manual' ),
					),
					array(
						'id'          => 'finchcart_global_tags',
						'type'        => 'select',
						'title'       => esc_html__( 'Select Product Tags', 'finch-cart-product-recommendations' ),
						'subtitle'    => esc_html__( 'Include the product tags that you like to have displayed as global recommendations for those products.', 'finch-cart-product-recommendations' ),
						'placeholder' => esc_html__( 'Select product tags', 'finch-cart-product-recommendations' ),
						'chosen'      => true,
						'multiple'    => true,
						'sortable'    => true,
						'ajax'        => true,
						'options'     => 'categories',
						'query_args'  => array(
							'taxonomy' => 'product_tag',
						),
					),
					array(
						'id'       => 'finchcart_global_additional_options',
						'type'     => 'fieldset',
						'class'    => 'edith-fieldset-inline',
						'title'    => esc_html__( 'Additional Settings', 'finch-cart-product-recommendations' ),
						'subtitle' => esc_html__( 'These extra options let you narrow down and reorder the recommended products.', 'finch-cart-product-recommendations' ),
						'fields'   => array(
							array(
								'id'          => 'finchcart_global_products_orderby',
								'type'        => 'select',
								'title'       => esc_html__( 'Products Order By', 'finch-cart-product-recommendations' ),
								'placeholder' => esc_html__( 'Select an option', 'finch-cart-product-recommendations' ),
								'options'     => array(
									'rand'       => esc_html__( 'Random Order', 'finch-cart-product-recommendations' ),
									'date'       => esc_html__( 'Publish Date', 'finch-cart-product-recommendations' ),
									'price'      => esc_html__( 'Price', 'finch-cart-product-recommendations' ),
									'popularity' => esc_html__( 'Popularity (sales)', 'finch-cart-product-recommendations' ),
									'rating'     => esc_html__( 'Product Rating', 'finch-cart-product-recommendations' ),
									'menu'       => esc_html__( 'Menu Order', 'finch-cart-product-recommendations' ),
									'title'      => esc_html__( 'Title', 'finch-cart-product-recommendations' ),
								),
								'default'     => 'rand',
							),
							array(
								'id'          => 'finchcart_global_products_order',
								'type'        => 'select',
								'title'       => esc_html__( 'Products Order', 'finch-cart-product-recommendations' ),
								'placeholder' => esc_html__( 'Select an option', 'finch-cart-product-recommendations' ),
								'options'     => array(
									'ASC'  => esc_html__( 'Ascending Order', 'finch-cart-product-recommendations' ),
									'DESC' => esc_html__( 'Descending Order', 'finch-cart-product-recommendations' ),
								),
								'default'     => 'DESC',
							),
							array(
								'id'          => 'finchcart_global_products_type',
								'type'        => 'select',
								'title'       => esc_html__( 'Products Type', 'finch-cart-product-recommendations' ),
								'placeholder' => esc_html__( 'Select an option', 'finch-cart-product-recommendations' ),
								'options'     => array(
									'simple'       => esc_html__( 'Simple product', 'finch-cart-product-recommendations' ),
									'downloadable' => esc_html__( ' → Downloadable', 'finch-cart-product-recommendations' ),
									'virtual'      => esc_html__( ' → Virtual', 'finch-cart-product-recommendations' ),
									'grouped'      => esc_html__( 'Grouped product', 'finch-cart-product-recommendations' ),
									'external'     => esc_html__( 'External/Affiliate product', 'finch-cart-product-recommendations' ),
									'variable'     => esc_html__( 'Variable product', 'finch-cart-product-recommendations' ),
								),
							),
							array(
								'id'          => 'finchcart_global_products_stock_status',
								'type'        => 'select',
								'title'       => esc_html__( 'Products Stock Status', 'finch-cart-product-recommendations' ),
								'placeholder' => esc_html__( 'Select an option', 'finch-cart-product-recommendations' ),
								'options'     => array(
									'instock'     => esc_html__( 'In stock', 'finch-cart-product-recommendations' ),
									'outofstock'  => esc_html__( 'Out of stock', 'finch-cart-product-recommendations' ),
									'onbackorder' => esc_html__( 'On backorder', 'finch-cart-product-recommendations' ),
								),
							),
							array(
								'id'    => 'finchcart_global_on_sale_products_only',
								'type'  => 'switcher',
								'title' => esc_html__( 'On-Sale Products Only', 'finch-cart-product-recommendations' ),
							),
							array(
								'id'    => 'finchcart_global_featured_products_only',
								'type'  => 'switcher',
								'title' => esc_html__( 'Featured Products Only', 'finch-cart-product-recommendations' ),
							),
							array(
								'id'      => 'finchcart_global_numbers_of_products',
								'type'    => 'slider',
								'title'   => esc_html__( 'Numbers of Products', 'finch-cart-product-recommendations' ),
								'default' => 12,
								'max'     => 100,
								'step'    => 1,
							),
						),
					),
					array(
						'id'       => 'finchcart_individual_product_recommendations',
						'type'     => 'switcher',
						'title'    => esc_html__( 'Individual Product Recommendations', 'finch-cart-product-recommendations' ),
						'subtitle' => esc_html__( 'The individual recommended products choose options on each product edit page can be toggle on or off using this option.', 'finch-cart-product-recommendations' ),
						'default'  => true,
					),
				),
			)
		);

		EDITH::createSection(
			$prefix,
			array(
				'title'       => esc_html__( 'Product Content', 'finch-cart-product-recommendations' ),
				'description' => esc_html__( 'You may select the content within the product loop in the recommended products.', 'finch-cart-product-recommendations' ),
				'icon'        => 'fas fa-box-open',
				'fields'      => array(
					array(
						'id'       => 'finchcart_show_product_image',
						'type'     => 'switcher',
						'title'    => esc_html__( 'Product Image', 'finch-cart-product-recommendations' ),
						'subtitle' => esc_html__( 'This option allows you to toggle the product image on or off in the recommended products loop.', 'finch-cart-product-recommendations' ),
						'default'  => true,
					),
					array(
						'id'       => 'finchcart_show_product_price',
						'type'     => 'switcher',
						'title'    => esc_html__( 'Product Price', 'finch-cart-product-recommendations' ),
						'subtitle' => esc_html__( 'This option allows you to toggle the product price on or off in the recommended products loop.', 'finch-cart-product-recommendations' ),
						'default'  => true,
					),
					array(
						'id'       => 'finchcart_show_product_rating',
						'type'     => 'switcher',
						'title'    => esc_html__( 'Product Rating', 'finch-cart-product-recommendations' ),
						'subtitle' => esc_html__( 'This option allows you to toggle the product rating on or off in the recommended products loop.', 'finch-cart-product-recommendations' ),
						'default'  => true,
					),
					array(
						'id'       => 'finchcart_show_product_title',
						'type'     => 'switcher',
						'title'    => esc_html__( 'Product Title', 'finch-cart-product-recommendations' ),
						'subtitle' => esc_html__( 'This option allows you to toggle the product title on or off in the recommended products loop.', 'finch-cart-product-recommendations' ),
						'default'  => true,
					),
					array(
						'id'       => 'finchcart_show_product_cart_btn',
						'type'     => 'switcher',
						'title'    => esc_html__( 'Product Cart Button', 'finch-cart-product-recommendations' ),
						'subtitle' => esc_html__( 'This option allows you to toggle the product cart button on or off in the recommended products loop.', 'finch-cart-product-recommendations' ),
						'default'  => true,
					),
				),
			)
		);

		EDITH::createSection(
			$prefix,
			array(
				'title'  => esc_html__( 'Popup Settings', 'finch-cart-product-recommendations' ),
				'icon'   => 'far fa-window-restore',
				'fields' => array(
					array(
						'id'       => 'finchcart_popup_show',
						'type'     => 'button_set',
						'title'    => esc_html__( 'Popup Show', 'finch-cart-product-recommendations' ),
						'subtitle' => esc_html__( 'If you think the popup could bother your consumers, you can limit its visibility.', 'finch-cart-product-recommendations' ),
						'options'  => array(
							'everytime'     => esc_html__( 'Every Time', 'finch-cart-product-recommendations' ),
							'limited_times' => esc_html__( 'Limited Times', 'finch-cart-product-recommendations' ),
						),
						'default'  => 'everytime',
					),
					array(
						'id'         => 'finchcart_popup_show_limited_times',
						'type'       => 'number',
						'title'      => esc_html__( 'Show the Popup for', 'finch-cart-product-recommendations' ),
						'subtitle'   => esc_html__( 'You can change the number of times the popup appears.', 'finch-cart-product-recommendations' ),
						'unit'       => 'times',
						'default'    => 2,
						'dependency' => array( 'finchcart_popup_show', '==', 'limited_times' ),
					),
					array(
						'id'       => 'finchcart_popup_width',
						'type'     => 'slider',
						'title'    => esc_html__( 'Popup Width', 'finch-cart-product-recommendations' ),
						'subtitle' => esc_html__( 'You can adjust the popup width for larger screen sizes here. For smaller screens, it will be automatically adjusted.', 'finch-cart-product-recommendations' ),
						'unit'     => 'px',
						'default'  => '1000',
						'max'      => 2000,
						'min'      => 0,
						'step'     => 1,
					),
					array(
						'id'       => 'finchcart_popup_close_icon',
						'type'     => 'switcher',
						'title'    => esc_html__( 'Popup Close Icon', 'finch-cart-product-recommendations' ),
						'subtitle' => esc_html__( 'You can turn on and off the "popup close icon" with this option.', 'finch-cart-product-recommendations' ),
						'default'  => true,
					),
					array(
						'id'       => 'finchcart_popup_esc_close',
						'type'     => 'switcher',
						'title'    => esc_html__( 'Popup Close on Esc', 'finch-cart-product-recommendations' ),
						'subtitle' => esc_html__( 'Close the popup when pressing [esc] key.', 'finch-cart-product-recommendations' ),
						'default'  => true,
					),
					array(
						'id'       => 'finchcart_popup_overlay_close',
						'type'     => 'switcher',
						'title'    => esc_html__( 'Popup Close on Click', 'finch-cart-product-recommendations' ),
						'subtitle' => esc_html__( 'Close the popup when click anywhere in the popup overlay.', 'finch-cart-product-recommendations' ),
						'default'  => true,
					),
				),
			)
		);

		// Style Settings Section.
		$popup_style_settings = array();

		if ( ! $this->is_pro_activated() ) {
			$popup_style_settings[] = array(
				'type'     => 'pro_notice',
				'heading'  => esc_html__( 'This plugin\'s premium edition offers a wide range of style customization options.', 'finch-cart-product-recommendations' ),
				'content'  => 'The settings allow you to change almost anything. Additionally, it offers a variety of layout possibilities for the content of the added to cart popup.<br>Upgrade today to any premium plan and receive a <strong>30% early bird discount</strong>.',
				'btn_text' => esc_html__( 'Buy Now', 'finch-cart-product-recommendations' ),
				'btn_url'  => 'https://wpbean.com/?p=44891&utm_content=Finch+Cart&utm_campaign=adminlink&utm_medium=style-settings-link&utm_source=FreeVersion',
			);
		}

		// EDITH::createSection(
		// 	$prefix,
		// 	array(
		// 		'title'  => esc_html__( 'Style Settings', 'finch-cart-product-recommendations' ),
		// 		'id'     => $prefix . 'style_settings',
		// 		'icon'   => 'fas fa-palette',
		// 		'fields' => $popup_style_settings,
		// 	)
		// );
	}
}
