<?php
/**
 * Main ContactsheetsLite\WPSSLC_Google_API namespace.
 *
 * @since 1.0.0
 * @package contactsheets-lite
 */
if (!defined('ABSPATH')) {
	exit; // Exit if accessed directly
}
use ContactsheetsLite\WPSSLC_Google_API_Functions;
/**
 * Handle plugin installation upon activation.
 *
 * @since 1.0.0
 */
class WPSSLC_Plugin_Settings
{
	/**
	 * Url for plugin api settings documentation.
	 *
	 * @var $doc_sheet_setting .
	 */
	protected static $doc_sheet_setting = 'https://docs.wpsyncsheets.com/wpssc-google-sheets-api-settings/';
	/**
	 * Url for plugin support.
	 *
	 * @var $submit_ticket
	 */
	protected static $submit_ticket = 'https://wordpress.org/support/plugin/contactsheets-lite/';
	/**
	 * Instance of class.
	 *
	 * @var $instance Instance variable of class.
	 */
	private static $instance = null;
	/**
	 * Instance of WPSSLC_Google_API_Functions class.
	 *
	 * @var $instance_api Instance variable of WPSSLC_Google_API_Functions class.
	 */
	private static $instance_api = null;
	/**
	 * Primary class constructor.
	 *
	 * @since 1.0.0
	 */
	public function __construct()
	{
		register_activation_hook(WPSSLC_BASE_FILE, array($this, 'wpsslc_activation'));
		register_deactivation_hook(WPSSLC_BASE_FILE, array($this, 'wpsslc_deactivation'));

		register_activation_hook(WPSSLC_BASE_FILE, array($this, 'wpssc_cf7_create_entry_table'));


		add_action('admin_menu', array($this, 'wpsslc_menu_page'), 40);
		add_action('admin_enqueue_scripts', array($this, 'wpsslc_load_custom_wp_admin_style'));
		add_action('admin_enqueue_scripts', array($this, 'wpsslc_selectively_enqueue_admin_script'));
		add_filter('plugin_row_meta', array($this, 'wpsslc_plugin_row_meta'), 10, 2);
		$this->wpsslc_google_api();

		// Dashboard Install & Active AJAX
		add_action('wp_ajax_install_and_activate_plugin', array($this, 'wpsslc_install_and_activate_plugin'));

		add_action('wp_ajax_wpssc_toggle_form_status', array($this, 'wp_ajax_wpssc_toggle_form_status'));
		add_action('admin_init', array($this, 'wpssc_handle_export'));
		add_action('wp_ajax_wpssc_toggle_db_status', array($this, 'wpssc_toggle_db_status'));
	}
	/**
	 * Main WPSSLC_Plugin_Settings Instance.
	 *
	 * @since 1.0.0
	 *
	 * @return instance
	 */
	public static function instance()
	{
		if (null === self::$instance) {
			self::$instance = new self();
		}
		return self::$instance;
	}
	/**
	 * Get an instance of WPSSLC_Google_API_Functions class.
	 *
	 * @return WPSSLC_Google_API_Functions class instance
	 */
	public static function wpsslc_google_api()
	{
		if (null === self::$instance_api) {
			self::$instance_api = new WPSSLC_Google_API_Functions();
		}
		return self::$instance_api;
	}
	/**
	 * WPSSLC Plugin Activation Hook
	 */
	public function wpsslc_activation()
	{
		update_option('active_contactsheets', 1);
	}
	/**
	 * WPSSLC Plugin Deactivation Hook
	 */
	public function wpsslc_deactivation()
	{
		update_option('active_contactsheets', '');
	}
	/**
	 * Register a plugin menu page.
	 */
	public function wpsslc_menu_page()
	{
		global $admin_page_hooks, $_parent_pages;
		if (!isset($admin_page_hooks['wpsyncsheets_lite'])) {
			$wpsslc_page = add_menu_page(
				esc_attr__('WPSyncSheets Lite', 'contactsheets-lite'),
				'WPSyncSheets Lite',
				'manage_options',
				'wpsyncsheets_lite',
				'',
				WPSSLC_URL . 'assets/images/dashicons-wpsyncsheets.svg',
				90
			);
		}
		add_submenu_page('wpsyncsheets_lite', 'WPSyncSheets Lite For Contact Form 7', 'For Contact Form 7', 'manage_options', 'wpsyncsheets-for-contact-form-7', array($this, 'wpsslc_plugin_page'), 4);
		$this->remove_duplicate_submenu_page();
	}

	/**
	 * Remove duplicate submenu
	 * Submenu page hack: Remove the duplicate WPSyncSheets Plugin link on subpages
	 */
	public function remove_duplicate_submenu_page()
	{
		remove_submenu_page('wpsyncsheets_lite', 'wpsyncsheets_lite');
	}
	/**
	 * Enqueue css and js files
	 */
	public static function wpsslc_load_custom_wp_admin_style()
	{

		$page = isset($_GET['page']) ? sanitize_text_field(wp_unslash($_GET['page'])) : ''; // phpcs:ignore

		// @codingStandardsIgnoreStart.
		$allowed_pages = array('wpcf7', 'wpsyncsheets-for-contact-form-7', 'wpcf7-new');

		if (is_admin() && in_array($page, $allowed_pages, true)) {

			// @codingStandardsIgnoreEnd.
			//wp_enqueue_script('wpsslc-admin-setting', WPSSLC_URL . 'assets/js/wpsslc-admin-setting.js?s', WPSSLC_VERSION, true, false);
			
			// ✅ Load dependencies
			wp_enqueue_script('jquery');
			wp_enqueue_script('jquery-ui-sortable');

			wp_enqueue_script(
			    'wpsslc-admin-setting',
			    WPSSLC_URL . 'assets/js/wpsslc-admin-setting.js',
			    array('jquery', 'jquery-ui-sortable'), // ✅ REQUIRED
			    WPSSLC_VERSION,
			    true // footer
			);

			wp_localize_script(
				'wpsslc-admin-setting',
				'ajax_login_object',
				array(
				'ajaxurl' => admin_url('admin-ajax.php'),
				'adminSettingsPageUrl' => admin_url('admin.php?page=wpsyncsheets-for-contact-form-7'),
				'nonce' => wp_create_nonce('wpssc_toggle_nonce'),
			),
			);

			if ('wpsyncsheets-for-contact-form-7' !== $page) {
				wp_enqueue_style('wpsslc-admin-setting', WPSSLC_URL . 'assets/css/wpsslc-admin-setting.css', WPSSLC_VERSION, true);
			}
			// phpcs:ignore
			wp_register_style('wpsslc-wp-admin-plugin-setting', WPSSLC_URL . 'assets/css/wpsslc-admin-plugin-setting-style.css', false, WPSSLC_VERSION);
			wp_enqueue_style('wpsslc-wp-admin-plugin-setting');

			wp_register_script(
				'wpsslc-bootstrap',
				WPSSLC_URL . 'assets/js/bootstrap.min.js',
				array('jquery'),
				'3.4.1',
				true
			);
			wp_enqueue_script('wpsslc-bootstrap');

		}
		wp_add_inline_style(
			'wp-admin',
			'#toplevel_page_wpsyncsheets_lite .wp-menu-image img {
	            width: 20px;
	            height: auto;
	            filter: brightness(100);
	        }
	        #toplevel_page_wpsyncsheets_lite:hover .wp-menu-image img {
	            filter: unset;
	        }
	        #toplevel_page_wpsyncsheets_lite.wp-has-current-submenu .wp-menu-image img {
	            filter: brightness(100) !important;
	        }'
		);
	}
	/**
	 * Enqueue css and js files
	 */
	public function wpsslc_selectively_enqueue_admin_script()
	{
		wp_enqueue_script('wpsslc-general-script', WPSSLC_URL . 'assets/js/wpsslc-general.js', WPSSLC_VERSION, true, false);
	}
	public static function wpssc_cf7_add_composite_index($table_name)
	{

		global $wpdb;

		$index_name = 'cf7_data_index';

		// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- One-time schema check at activation; INFORMATION_SCHEMA cannot use wp_cache.
		$exists = $wpdb->get_var(
			$wpdb->prepare(
			"SELECT COUNT(1)
	             FROM INFORMATION_SCHEMA.STATISTICS
	             WHERE table_schema = DATABASE()
	             AND table_name = %s
	             AND index_name = %s",
			$table_name,
			$index_name
		)
		);

		if (!$exists) {
			// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange, PluginCheck.Security.DirectDB.UnescapedDBParameter -- One-time composite index creation at activation; $table_name from $wpdb->prefix; $index_name is a hardcoded literal.
			$wpdb->query("ALTER TABLE $table_name ADD INDEX $index_name (cf7_id, data_id)");
		}
	}

	public static function wp_ajax_wpssc_toggle_form_status()
	{

		if (!current_user_can('manage_options')) {
			wp_send_json_error(['message' => 'Permission denied']);
		}

		check_ajax_referer('wpssc_toggle_nonce', 'nonce');

		$form_id = isset($_POST['form_id']) ? intval($_POST['form_id']) : 0;

		if (!$form_id) {
			wp_send_json_error(['message' => 'Invalid form ID']);
		}

		$status = (isset($_POST['status']) && sanitize_text_field(wp_unslash($_POST['status'])) === 'yes') ? 'yes' : 'no';

		update_post_meta($form_id, 'wpssc_all_settings', $status);

		wp_send_json_success();
	}

	public static function wpssc_toggle_db_status()
	{

		if (!current_user_can('manage_options')) {
			wp_send_json_error();
		}

		check_ajax_referer('wpssc_toggle_nonce', 'nonce');

		$form_id = isset($_POST['form_id']) ? intval($_POST['form_id']) : 0;
		if (!$form_id) {
			wp_send_json_error();
		}

		$current = get_post_meta($form_id, 'wpssc_enable_db_save', true);

		if ('yes' === $current) {
			update_post_meta($form_id, 'wpssc_enable_db_save', 'no');
			wp_send_json_success(['status' => 'no']);
		}
		else {
			update_post_meta($form_id, 'wpssc_enable_db_save', 'yes');
			wp_send_json_success(['status' => 'yes']);
		}
	}

	public function wpssc_handle_export()
	{
		if (!is_admin())
			return;

		$do_export = isset($_POST['wpssc_do_export']) ? absint( wp_unslash($_POST['wpssc_do_export']) ) : 0;
		if (  1 !== $do_export ) {
			return; // stop immediately if not export
		}


		if ( empty($_POST['wpssc_export_nonce_field']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['wpssc_export_nonce_field'])), 'wpssc_export_nonce') ) {
		    return;
		}
		
	    $export_mode = isset($_POST['wpssc_export_mode']) ? sanitize_text_field( wp_unslash($_POST['wpssc_export_mode']) ) : '';
		
		$page = isset($_GET['page']) ? sanitize_text_field(wp_unslash($_GET['page'])) : '';
		$view = isset($_GET['view']) ? sanitize_text_field(wp_unslash($_GET['view'])) : '';
		$form_id = isset($_GET['form_id']) ? absint(wp_unslash($_GET['form_id'])) : 0;

		if ( 'wpsyncsheets-for-contact-form-7' !== $page) return;
		if ('entries' !== $view) return;
		if (!$form_id || !$export_mode) return;

		if (!current_user_can('manage_options')) {
			return;
		}

		

		/*if (
		empty($_REQUEST['wpssc_export_nonce_field']) ||
		!wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['wpssc_export_nonce_field'])), 'wpssc_export_nonce')
		) {
			wp_die('Security check failed.');
		}*/

		global $wpdb;

		$form_id = absint($_GET['form_id']);
		$mode = isset($_REQUEST['wpssc_export_mode']) ? sanitize_text_field(wp_unslash($_REQUEST['wpssc_export_mode'])) : '';
		$search = isset($_GET['s']) ? sanitize_text_field(wp_unslash($_GET['s'])) : '';

		$orderby = isset($_GET['orderby']) ? sanitize_text_field(wp_unslash($_GET['orderby'])) : 'data_id';
		$order = isset($_GET['order']) ? strtoupper(sanitize_text_field(wp_unslash($_GET['order']))) : 'DESC';
		$order = 'ASC' === $order ? 'ASC' : 'DESC';

		$date_filter = isset($_GET['date_filter']) ? sanitize_text_field(wp_unslash($_GET['date_filter'])) : '';
		$date_from = isset($_GET['date_from']) ? sanitize_text_field(wp_unslash($_GET['date_from'])) : '';
		$date_to = isset($_GET['date_to']) ? sanitize_text_field(wp_unslash($_GET['date_to'])) : '';
		$type = isset($_POST['wpssc_export_type']) ? sanitize_text_field(wp_unslash($_POST['wpssc_export_type'])) : 'csv';

		$table = $wpdb->prefix . 'wpssc_form_entry';

		// ==========================
		// BUILD WHERE
		// ==========================

		$where = $wpdb->prepare("WHERE t1.cf7_id = %d", $form_id);

		// SEARCH
		if ('all' !== $mode && $search) {
			// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- $table is built from $wpdb->prefix only; safe.
			$where .= $wpdb->prepare(
				" AND t1.data_id IN (
	                SELECT data_id FROM $table
	                WHERE cf7_id=%d AND value LIKE %s
	            )",
				$form_id,
				'%' . $wpdb->esc_like($search) . '%'
			);
		// phpcs:enable
		}

		// DATE FILTER
		if ('all' !== $mode && $date_filter) {

			switch ($date_filter) {

				case 'today':
					$today = current_time('Y-m-d');
					// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- $table is built from $wpdb->prefix only; safe.
					$where .= $wpdb->prepare(
						" AND t1.data_id IN (
	                        SELECT data_id FROM $table
	                        WHERE cf7_id=%d
	                        AND name='submit_time'
	                        AND DATE(value) = %s
	                    )",
						$form_id,
						$today
					);
					// phpcs:enable
					break;

				case '7days':
					$from = wp_date('Y-m-d', strtotime('-7 days'));
					// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- $table is built from $wpdb->prefix only; safe.
					$where .= $wpdb->prepare(
						" AND t1.data_id IN (
	                        SELECT data_id FROM $table
	                        WHERE cf7_id=%d
	                        AND name='submit_time'
	                        AND DATE(value) >= %s
	                    )",
						$form_id,
						$from
					);
					// phpcs:enable
					break;

				case 'month':
					$month = wp_date('m');
					$year = wp_date('Y');
					// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- $table is built from $wpdb->prefix only; safe.
					$where .= $wpdb->prepare(
						" AND t1.data_id IN (
	                        SELECT data_id FROM $table
	                        WHERE cf7_id=%d
	                        AND name='submit_time'
	                        AND MONTH(value)=%d
	                        AND YEAR(value)=%d
	                    )",
						$form_id,
						$month,
						$year
					);
					// phpcs:enable
					break;

				case 'custom':
					if ($date_from && $date_to) {
						// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- $table is built from $wpdb->prefix only; safe.
						$where .= $wpdb->prepare(
							" AND t1.data_id IN (
	                            SELECT data_id FROM $table
	                            WHERE cf7_id=%d
	                            AND name='submit_time'
	                            AND DATE(value) BETWEEN %s AND %s
	                        )",
							$form_id,
							$date_from,
							$date_to
						);
					// phpcs:enable
					}
					break;
			}
		}

		// SELECTED MODE
		if ('selected' === $mode) {

			if (empty($_POST['entry'])) {

				$redirect_url = add_query_arg(
				    [
				        'page'    => 'wpsyncsheets-for-contact-form-7',
				        'view'    => 'entries',
				        'form_id' => $form_id,
				        'wpssc_export_error' => 'no_selection',
				    ],
				    admin_url('admin.php')
				);
				wp_safe_redirect($redirect_url);
				exit;
			}

			$selected_ids = array_map('absint', $_POST['entry']);

			if (!empty($selected_ids)) {
				$placeholders = implode(',', array_fill(0, count($selected_ids), '%d'));
				// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- $placeholders contains only comma-separated %d tokens, all values passed as $selected_ids.
				$where .= $wpdb->prepare(
					" AND t1.data_id IN ($placeholders)",
					...$selected_ids
				);
			// phpcs:enable
			}
		}

		// ==========================
		// GET DATA IDS
		// ==========================

		$safe_table = esc_sql($table);
		$safe_orderby = esc_sql($orderby);

		// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, PluginCheck.Security.DirectDB.UnescapedDBParameter -- $safe_table/$safe_orderby are esc_sql()-escaped; $order is whitelisted to ASC/DESC; $where is built entirely from $wpdb->prepare() calls.
		$data_ids = $wpdb->get_col("
	        SELECT DISTINCT t1.data_id
	        FROM $safe_table t1
	        $where
	        ORDER BY t1.$safe_orderby $order
	    ");
		// phpcs:enable

		if (empty($data_ids)) {
			wp_die('No entries found.');
		}

		$placeholders = implode(',', array_fill(0, count($data_ids), '%d'));

		// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter -- User-triggered export query; dynamic placeholders make caching impractical. $safe_table is esc_sql()-escaped; $order is whitelisted to ASC/DESC; $placeholders contains only %d tokens.
		$rows = $wpdb->get_results(
			$wpdb->prepare(
			"SELECT data_id, name, value
	             FROM $safe_table
	             WHERE cf7_id = %d
	             AND data_id IN ($placeholders)
	             ORDER BY data_id $order",
			...array_merge([$form_id], $data_ids)
		),
			ARRAY_A
		);
		// phpcs:enable
		// ==========================
		// GROUP DATA
		// ==========================

		$grouped = [];

		$skip_fields = [
			'_db_submission_speed_ms',
			'_google_submission_speed_ms',
			'_is_status'
		];


		foreach ($rows as $row_key => $row) {

			if (in_array($row['name'], $skip_fields, true)) {
				unset($rows[$row_key]);
				continue;
			}

			$data_id = $row['data_id'];

			if (!isset($grouped[$data_id])) {
				$grouped[$data_id] = ['data_id' => $data_id];
			}

			$value = maybe_unserialize($row['value']);

			if (is_array($value)) {
				$value = implode(', ', $value);
			}

			$grouped[$data_id][$row['name']] = $value;
		}

		// ==========================
		// LOAD MANAGE COLUMN SETTINGS
		// ==========================

		$settings = get_option("wpssc_form_columns_{$form_id}", []);

		$fields = array_unique(array_column($rows, 'name'));
		$fields = array_diff($fields, $skip_fields);


		$visible = $settings['wpssc_visible'] ?? $fields;
		$labels = $settings['wpssc_labels'] ?? [];
		$order = $settings['column_order'] ?? $fields;

		// ensure new fields are added
		$order = array_unique(array_merge($order, $fields));

		// Build final column list
		$header_keys = ['data_id'];
		$header_labels = ['Entry ID'];

		foreach ($order as $field) {

			if ('data_id' === $field) {
				continue;
			}

			$header_keys[] = $field;

			$label = $labels[$field] ?? ucwords(str_replace(['-', '_'], ' ', $field));

			$header_labels[] = $label;
		}

		if (ob_get_length())
			ob_end_clean();

		$filename = 'cf7-entries-' . wp_date('Y-m-d');

		if ('excel' === $type) {

			// Excel (XLS format - opens in Excel perfectly)
			header("Content-Type: application/vnd.ms-excel");
			header("Content-Disposition: attachment; filename={$filename}.xls");
			header("Pragma: no-cache");
			header("Expires: 0");

			echo "\xEF\xBB\xBF"; // UTF-8 BOM

			echo "<table border='1'>";
			echo "<tr>";

			foreach ($header_labels as $label) {
				echo "<th>" . esc_html($label) . "</th>";
			}

			echo "</tr>";

			foreach ($grouped as $entry) {

				echo "<tr>";

				foreach ($header_keys as $key) {
					$value = isset($entry[$key]) ? $entry[$key] : '';
					echo "<td>" . esc_html($value) . "</td>";
				}

				echo "</tr>";
			}

			echo "</table>";

		}
		else {

			// CSV (default)
			header('Content-Type: text/csv; charset=utf-8');
			header("Content-Disposition: attachment; filename={$filename}.csv");

			$output = fopen('php://output', 'w');
			fputcsv($output, $header_labels);

			foreach ($grouped as $entry) {

				$row = [];

				foreach ($header_keys as $key) {
					$row[] = isset($entry[$key]) ? $entry[$key] : '';
				}

				fputcsv($output, $row);
			}

			// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fclose -- Writing to php://output stream, not a real file; WP_Filesystem is not applicable here.
			fclose($output);
		}

		exit;
	}

	public static function wpssc_cf7_create_entry_table()
	{

		if (get_option('wpssc_table_created'))
			return;
		update_option('wpssc_table_created', 1);
		global $wpdb;

		$table_name = $wpdb->prefix . 'wpssc_form_entry';
		$charset_collate = $wpdb->get_charset_collate();

		require_once ABSPATH . 'wp-admin/includes/upgrade.php';

		$sql = "CREATE TABLE $table_name (
	        id INT(11) NOT NULL AUTO_INCREMENT,
	        cf7_id INT(11) NOT NULL,
	        data_id INT(11) NOT NULL,
	        name VARCHAR(250) NULL,
	        value LONGTEXT NULL,
	        PRIMARY KEY (id),
	        KEY cf7_id (cf7_id),
	        KEY data_id (data_id)
	    ) $charset_collate;";

		dbDelta($sql);

		// Add composite index safely
		self::instance()->wpssc_cf7_add_composite_index($table_name);
	}

	/**
	 * Show row meta on the plugin screen.
	 *
	 * @param mixed $wpsslc_links Plugin Row Meta.
	 * @param mixed $wpsslc_file  Plugin Base file.
	 * @return  array
	 */
	public static function wpsslc_plugin_row_meta($wpsslc_links, $wpsslc_file)
	{
		if ('contactsheets-lite/wpsyncsheets-lite-contact-form-7.php' === (string)$wpsslc_file) {
			$wpsslc_row_meta = array(
				'docs' => '<a href="' . esc_url(WPSSLC_DOCS_LINK) . '" title="' . esc_attr(__('View Documentation', 'contactsheets-lite')) . '" target="_blank">' . __('View Documentation', 'contactsheets-lite') . '</a>',
			);
			return array_merge($wpsslc_links, $wpsslc_row_meta);
		}
		return (array)$wpsslc_links;
	}
	/**
	 * Show wpsslc plugin screen.
	 */
	public function wpsslc_plugin_page()
	{

		$wpsslc_error = '';
		$wpsslc_token_error = false;
		$wpsslc_error_general = '';
		$wpsslc_apisettings = '';
		$wpsslc_generalsettings = '';
		$wpsslc_emsettings = '';
		$wpsslc_supportsettings = '';
		if (!isset($_GET['tab'])) {
			// Google API Settings Tab.
			if (isset($_POST['submit']) || isset($_POST['revoke'])) {
				if (!isset($_POST['wpsslc_api_settings']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['wpsslc_api_settings'])), 'save_api_settings')) {
					$wpsslc_error = '<div class="error token_error"><p><strong class="err-msg">Error: Sorry, your nonce did not verify.</strong></p></div>';
				}
				else {
					if (isset($_POST['client_token'])) {
						$wpsslc_clienttoken = sanitize_text_field(wp_unslash($_POST['client_token']));
					}
					else {
						$wpsslc_clienttoken = '';
					}
					if (isset($_POST['client_id']) && isset($_POST['client_secret'])) {
						$wpsslc_google_settings = array(sanitize_text_field(wp_unslash($_POST['client_id'])), sanitize_text_field(wp_unslash($_POST['client_secret'])), $wpsslc_clienttoken);
					}
					else {
						$wpsslc_google_settings_value = self::$instance_api->wpsslc_option('wpssc_google_settings');
						$wpsslc_google_settings = array($wpsslc_google_settings_value[0], $wpsslc_google_settings_value[1], $wpsslc_clienttoken);
					}
					self::$instance_api->wpsslc_update_option('wpssc_google_settings', $wpsslc_google_settings);
					if (isset($_POST['revoke'])) {
						$wpsslc_google_settings = self::$instance_api->wpsslc_option('wpssc_google_settings');
						$wpsslc_google_settings[2] = '';
						self::$instance_api->wpsslc_update_option('wpssc_google_settings', $wpsslc_google_settings);
						self::$instance_api->wpsslc_update_option('wpssc_google_accessToken', '');
					}
				}
			}
		}
		if (isset($_GET['code']) && !empty(sanitize_text_field(wp_unslash($_GET['code'])))) {
			$wpsslc_code = sanitize_text_field(wp_unslash($_GET['code']));
			$wpsslc_token_value = $wpsslc_code;
			$wpsslc_google_settings = self::$instance_api->wpsslc_option('wpssc_google_settings');
			$wpsslc_google_settings[2] = $wpsslc_code;
			self::$instance_api->wpsslc_update_option('wpssc_google_settings', $wpsslc_google_settings);

			wp_safe_redirect(admin_url('admin.php?page=wpsyncsheets-for-contact-form-7&tab=wpsslc-nav-googleapi'));
			exit;
		}

		$wpsslc_google_settings_value = self::$instance_api->wpsslc_option('wpssc_google_settings');

		if (!empty($wpsslc_google_settings_value[2])) {
			if (!self::$instance_api->checkcredenatials()) {
				$wpsslc_error = self::$instance_api->getClient(1);
				if ('Invalid token format' === (string)$wpsslc_error) {
					$wpsslc_error = '<div class="error token_error"><p><strong class="err-msg">Error: Invalid Token - Revoke Token with below settings and try again.</strong></p></div>';
				}
				else {
					$wpsslc_error = '<div class="error token_error"><p><strong class="err-msg">Error: ' . $wpsslc_error . '</strong></p></div>';
				}
				$wpsslc_token_error = true;
			}
		}

		if (empty($wpsslc_error) && !empty($wpsslc_google_settings_value[2])) {
			try {
				$spreadsheets_list = self::$instance_api->get_spreadsheet_listing();
			}
			catch (Exception $e) {

				$error = json_decode($e->getMessage(), true);

				$reason = '';
				if (isset($error['error']) && is_array($error['error'])) {
					$errors = isset($error['error']['errors']) ? $error['error']['errors'] : array();
					foreach ($errors as $err) {
						$reason = isset($err['reason']) ? $err['reason'] : '';
					}
				}
				elseif (isset($error['error'])) {
					$reason = $error['error'];
				}
				if ('insufficientPermissions' === (string)$reason) {
					$wpsslc_error = '<div class="error token_error"><p><strong class="err-msg">Error: Insufficient Permissions - Revoke Token with below settings and when generating access token select all the permissions.</strong></p></div>';
				}
				if ('accessNotConfigured' === (string)$reason) {
					$wpsslc_error = '<div class="error token_error"><p><strong class="err-msg">Error: Access not Configured - Please enable Google Sheets API and Google Drive API. Follow the <a target="_blank" href="https://docs.wpsyncsheets.com/wpssc-google-sheets-api-settings/" style="color:#000;">Google Sheets API Settings documentation</a> to enable APIs.</strong></p></div>';
				}
				if (empty($wpsslc_error) && '' !== (string)$reason) {
					$wpsslc_error = '<div class="error token_error"><p><strong class="err-msg">Error: Invalid Credentials - Reset settings and try again.</strong></p></div>';
				}
				$wpsslc_token_error = true;
			}
		}
		$show_tab = 'dashboard';
		$get_tab = isset($_GET['tab']) ? sanitize_text_field(wp_unslash($_GET['tab'])) : '';

		if (!isset($wpsslc_google_settings_value[0]) || empty($wpsslc_google_settings_value[0]) || 'wpsslc-nav-dashboard' === $get_tab) {
			$show_tab = 'dashboard';
		}
		elseif ($wpsslc_token_error || !isset($wpsslc_google_settings_value[2]) || empty($wpsslc_google_settings_value[2]) || 'wpsslc-nav-googleapi' === $get_tab) {
			$show_tab = 'api';
		}

		if (isset($_GET['page']) && 'wpsyncsheets-for-contact-form-7' === $_GET['page']) {

			// If viewing entries
			if (isset($_GET['view']) && in_array($_GET['view'], array('entry', 'entries', 'forms'), true)) {
				$show_tab = 'forms';

			// If inside forms listing (example: search, pagination)
			}
			elseif (isset($_GET['tab']) && 'forms' === $_GET['tab']) {
				$show_tab = 'forms';
			}
		}

?>
		<!-- .wrap -->
		<div class="wpsslc-main-wrap">
			<div class="wpssw_order_top_header"> <!-- ONLY this will be hidden -->
						<div class="wpssw_top_header_content_wrapper">
							<p class="wpssw_top_header_text">
								You're using our free version. To unlock more features,
								<a href="<?php echo esc_url(WPSSLC_PRO_VERSION_BUY_URL); ?>" target="_blank">upgrade to pro →</a>
							</p>
						</div>
						<button class="wpssw_close_btn" onclick="wc_closeTopHeader()">×</button>
			</div>
			<div class="wpsslc-header-main">
				<div class="container">
					<div class="wpsslc-header-section">
						<div class="wpsslc-header-left">
							<div class="wpsslc-logo-section">
								<img src="<?php echo esc_url(WPSSLC_URL . 'assets/images/logo.svg?ver='); ?><?php echo esc_attr(WPSSLC_VERSION); ?>">
							</div>
							<div class="wpsslc-nav-top">
								<ul>
									<li>
										<button class="navtablinks wpsslc-nav-dashboard <?php
		if ('dashboard' === $show_tab) {
			echo " active";
		}
?>" onclick="wpsslcNavTab(event, 'wpsslc-nav-dashboard')">
											<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
												<g clip-path="url(#clip0_269_64)">
												<path d="M6.75 0.462891C7.73721 0.462891 8.53711 1.26279 8.53711 2.25V8.4375C8.53711 9.42471 7.73721 10.2246 6.75 10.2246H2.25C1.26279 10.2246 0.462891 9.42471 0.462891 8.4375V2.25C0.462891 1.26279 1.26279 0.462891 2.25 0.462891H6.75ZM2.25 1.78711C1.99457 1.78711 1.78711 1.99457 1.78711 2.25V8.4375C1.78711 8.69294 1.99457 8.90039 2.25 8.90039H6.75C7.00544 8.90039 7.21289 8.69294 7.21289 8.4375V2.25C7.21289 1.99457 7.00544 1.78711 6.75 1.78711H2.25Z" fill="#64748B" stroke="#64748B" stroke-width="0.2"/>
												<path d="M15.75 7.77539C16.7372 7.77539 17.5371 8.57529 17.5371 9.5625V15.75C17.5371 16.7372 16.7372 17.5371 15.75 17.5371H11.25C10.2628 17.5371 9.46289 16.7372 9.46289 15.75V9.5625C9.46289 8.57529 10.2628 7.77539 11.25 7.77539H15.75ZM11.25 9.09961C10.9946 9.09961 10.7871 9.30706 10.7871 9.5625V15.75C10.7871 16.0054 10.9946 16.2129 11.25 16.2129H15.75C16.0054 16.2129 16.2129 16.0054 16.2129 15.75V9.5625C16.2129 9.30706 16.0054 9.09961 15.75 9.09961H11.25Z" fill="#64748B" stroke="#64748B" stroke-width="0.2"/>
												<path d="M6.75 11.1504C7.73721 11.1504 8.53711 11.9503 8.53711 12.9375V15.75C8.53711 16.7372 7.73721 17.5371 6.75 17.5371H2.25C1.26279 17.5371 0.462891 16.7372 0.462891 15.75V12.9375C0.462891 11.9503 1.26279 11.1504 2.25 11.1504H6.75ZM2.25 12.4746C1.99457 12.4746 1.78711 12.6821 1.78711 12.9375V15.75C1.78711 16.0054 1.99457 16.2129 2.25 16.2129H6.75C7.00544 16.2129 7.21289 16.0054 7.21289 15.75V12.9375C7.21289 12.6821 7.00544 12.4746 6.75 12.4746H2.25Z" fill="#64748B" stroke="#64748B" stroke-width="0.2"/>
												<path d="M15.75 0.462891C16.7372 0.462891 17.5371 1.26279 17.5371 2.25V5.0625C17.5371 6.04971 16.7372 6.84961 15.75 6.84961H11.25C10.2628 6.84961 9.46289 6.04971 9.46289 5.0625V2.25C9.46289 1.26279 10.2628 0.462891 11.25 0.462891H15.75ZM11.25 1.78711C10.9946 1.78711 10.7871 1.99457 10.7871 2.25V5.0625C10.7871 5.31794 10.9946 5.52539 11.25 5.52539H15.75C16.0054 5.52539 16.2129 5.31794 16.2129 5.0625V2.25C16.2129 1.99457 16.0054 1.78711 15.75 1.78711H11.25Z" fill="#64748B" stroke="#64748B" stroke-width="0.2"/>
												</g>
												<defs>
												<clipPath id="clip0_269_64">
												<rect width="18" height="18" fill="white"/>
												</clipPath>
												</defs>
											</svg>
											Dashboard
										</button>
	                                </li>
									<li>
										<button class="navtablinks wpsslc-nav-googleapi <?php
		if ('api' === $show_tab) {
			echo " active";
		}
?>" onclick="wpsslcNavTab(event, 'wpsslc-nav-googleapi')">
											<svg width="21" height="19" viewBox="0 0 21 19" fill="none" xmlns="http://www.w3.org/2000/svg">
												<path d="M5.21777 19C3.83444 19 2.65527 18.5125 1.68027 17.5375C0.705273 16.5625 0.217773 15.3833 0.217773 14C0.217773 12.7833 0.59694 11.7208 1.35527 10.8125C2.11361 9.90417 3.06777 9.33333 4.21777 9.1V11.175C3.63444 11.375 3.15527 11.7333 2.78027 12.25C2.40527 12.7667 2.21777 13.35 2.21777 14C2.21777 14.8333 2.50944 15.5417 3.09277 16.125C3.67611 16.7083 4.38444 17 5.21777 17C6.05111 17 6.75944 16.7083 7.34277 16.125C7.92611 15.5417 8.21777 14.8333 8.21777 14V13H14.0928C14.2261 12.85 14.3886 12.7292 14.5803 12.6375C14.7719 12.5458 14.9844 12.5 15.2178 12.5C15.6344 12.5 15.9886 12.6458 16.2803 12.9375C16.5719 13.2292 16.7178 13.5833 16.7178 14C16.7178 14.4167 16.5719 14.7708 16.2803 15.0625C15.9886 15.3542 15.6344 15.5 15.2178 15.5C14.9844 15.5 14.7719 15.4542 14.5803 15.3625C14.3886 15.2708 14.2261 15.15 14.0928 15H10.1178C9.88444 16.15 9.31361 17.1042 8.40527 17.8625C7.49694 18.6208 6.43444 19 5.21777 19ZM15.2178 19C14.2844 19 13.4386 18.7708 12.6803 18.3125C11.9219 17.8542 11.3261 17.25 10.8928 16.5H13.5678C13.8011 16.6667 14.0594 16.7917 14.3428 16.875C14.6261 16.9583 14.9178 17 15.2178 17C16.0511 17 16.7594 16.7083 17.3428 16.125C17.9261 15.5417 18.2178 14.8333 18.2178 14C18.2178 13.1667 17.9261 12.4583 17.3428 11.875C16.7594 11.2917 16.0511 11 15.2178 11C14.8844 11 14.5761 11.0458 14.2928 11.1375C14.0094 11.2292 13.7428 11.3667 13.4928 11.55L10.4428 6.475C10.0928 6.40833 9.80111 6.24167 9.56777 5.975C9.33444 5.70833 9.21777 5.38333 9.21777 5C9.21777 4.58333 9.36361 4.22917 9.65527 3.9375C9.94694 3.64583 10.3011 3.5 10.7178 3.5C11.1344 3.5 11.4886 3.64583 11.7803 3.9375C12.0719 4.22917 12.2178 4.58333 12.2178 5V5.2125C12.2178 5.27083 12.2011 5.34167 12.1678 5.425L14.3428 9.075C14.4761 9.04167 14.6178 9.02083 14.7678 9.0125C14.9178 9.00417 15.0678 9 15.2178 9C16.6011 9 17.7803 9.4875 18.7553 10.4625C19.7303 11.4375 20.2178 12.6167 20.2178 14C20.2178 15.3833 19.7303 16.5625 18.7553 17.5375C17.7803 18.5125 16.6011 19 15.2178 19ZM5.21777 15.5C4.80111 15.5 4.44694 15.3542 4.15527 15.0625C3.86361 14.7708 3.71777 14.4167 3.71777 14C3.71777 13.6333 3.83444 13.3167 4.06777 13.05C4.30111 12.7833 4.58444 12.6083 4.91777 12.525L7.26777 8.625C6.78444 8.175 6.40527 7.6375 6.13027 7.0125C5.85527 6.3875 5.71777 5.71667 5.71777 5C5.71777 3.61667 6.20527 2.4375 7.18027 1.4625C8.15527 0.4875 9.33444 0 10.7178 0C12.1011 0 13.2803 0.4875 14.2553 1.4625C15.2303 2.4375 15.7178 3.61667 15.7178 5H13.7178C13.7178 4.16667 13.4261 3.45833 12.8428 2.875C12.2594 2.29167 11.5511 2 10.7178 2C9.88444 2 9.17611 2.29167 8.59277 2.875C8.00944 3.45833 7.71777 4.16667 7.71777 5C7.71777 5.71667 7.93444 6.34583 8.36777 6.8875C8.80111 7.42917 9.35111 7.775 10.0178 7.925L6.64277 13.55C6.67611 13.6333 6.69694 13.7083 6.70527 13.775C6.71361 13.8417 6.71777 13.9167 6.71777 14C6.71777 14.4167 6.57194 14.7708 6.28027 15.0625C5.98861 15.3542 5.63444 15.5 5.21777 15.5Z" fill="#64748B"/>
											</svg>
											API Integration
										</button>
									</li>
									<li>
										<button class="navtablinks wpssc-nav-forms <?php
		if ('forms' === $show_tab) {
			echo " active";
		}
?>"
										onclick="wpsslcNavTab(event, 'wpssc-nav-forms')">
											<svg width="21" height="19" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
												<g clip-path="url(#clip0_7_103)">
													<path d="M8.00018 0.67627C9.47308 0.67627 10.961 0.831404 12.0851 1.13721C12.6461 1.28982 13.1265 1.48231 13.4699 1.71924C13.812 1.95532 14.0431 2.25357 14.0432 2.61768C14.0432 2.9818 13.812 3.28002 13.4699 3.51611C13.1265 3.75306 12.6462 3.9465 12.0851 4.09912C10.961 4.40491 9.47303 4.55908 8.00018 4.55908C6.52759 4.55906 5.0402 4.40482 3.9162 4.09912C3.35524 3.94652 2.87482 3.75301 2.53143 3.51611C2.18925 3.28001 1.95819 2.98184 1.95819 2.61768C1.95824 2.25357 2.18929 1.95532 2.53143 1.71924C2.87481 1.48238 3.35531 1.28979 3.9162 1.13721C5.04022 0.831472 6.5275 0.676291 8.00018 0.67627ZM8.00018 1.48389C6.36804 1.48391 5.03613 1.67246 4.11639 1.92334C3.65557 2.04906 3.30402 2.18903 3.07147 2.32471C2.95508 2.39263 2.87428 2.4559 2.8244 2.51123C2.77376 2.56744 2.76585 2.60277 2.76581 2.61768C2.76581 2.63251 2.77363 2.66776 2.8244 2.72412C2.87429 2.77951 2.95492 2.84362 3.07147 2.91162C3.30402 3.04727 3.65568 3.18632 4.11639 3.31201C5.03613 3.5629 6.368 3.75144 8.00018 3.75146C9.63262 3.75146 10.9651 3.56295 11.8849 3.31201C12.3457 3.1863 12.6973 3.04729 12.9299 2.91162C13.0464 2.84364 13.1271 2.77949 13.1769 2.72412C13.2276 2.66786 13.2355 2.63249 13.2355 2.61768C13.2355 2.60277 13.2275 2.56741 13.1769 2.51123C13.1271 2.45591 13.0462 2.39262 12.9299 2.32471C12.6973 2.18903 12.3457 2.04906 11.8849 1.92334C10.9651 1.6724 9.63262 1.48389 8.00018 1.48389Z" fill="#64748B" stroke="#64748B" stroke-width="0.294737"/>
													<path d="M13.6386 9.39032C13.8614 9.39032 14.0417 9.57091 14.0419 9.79364V13.3825C14.0418 13.7465 13.8118 14.0449 13.4697 14.2809C13.1263 14.5179 12.6459 14.7104 12.0849 14.863C10.9608 15.1688 9.47282 15.3239 7.99994 15.3239C6.52728 15.3239 5.03997 15.1687 3.91595 14.863C3.3551 14.7104 2.87456 14.5178 2.53119 14.2809C2.1891 14.0449 1.95807 13.7465 1.95795 13.3825V9.79364C1.95818 9.57106 2.13868 9.39056 2.36127 9.39032C2.58405 9.39032 2.76533 9.57091 2.76556 9.79364V13.3825C2.76566 13.3975 2.77369 13.4329 2.82416 13.489C2.87406 13.5443 2.95486 13.6076 3.07123 13.6755C3.30378 13.8112 3.65532 13.9511 4.11615 14.0768C5.03589 14.3277 6.36782 14.5163 7.99994 14.5163C9.63238 14.5163 10.9649 14.3278 11.8847 14.0768C12.3455 13.9511 12.6971 13.8112 12.9296 13.6755C13.046 13.6076 13.1269 13.5443 13.1767 13.489C13.2272 13.4329 13.2352 13.3975 13.2353 13.3825V9.79364C13.2355 9.57095 13.4159 9.39039 13.6386 9.39032Z" fill="#64748B" stroke="#64748B" stroke-width="0.294737"/>
													<path d="M13.6386 5.80219C13.8614 5.80219 14.0417 5.98278 14.0419 6.20551V9.79437C14.0418 10.1584 13.8118 10.4568 13.4697 10.6928C13.1263 10.9297 12.6459 11.1222 12.0849 11.2748C10.9608 11.5806 9.47282 11.7358 7.99994 11.7358C6.52728 11.7358 5.03997 11.5806 3.91595 11.2748C3.35509 11.1223 2.87456 10.9297 2.53119 10.6928C2.18909 10.4568 1.95806 10.1584 1.95795 9.79437V6.20551C1.95818 5.98292 2.13868 5.80242 2.36127 5.80219C2.58405 5.80219 2.76533 5.98278 2.76556 6.20551V9.79437C2.76566 9.80937 2.77369 9.8448 2.82416 9.90082C2.87406 9.95614 2.95486 10.0194 3.07123 10.0873C3.30378 10.223 3.65532 10.363 4.11615 10.4887C5.03589 10.7396 6.36782 10.9281 7.99994 10.9282C9.63238 10.9282 10.9649 10.7396 11.8847 10.4887C12.3455 10.363 12.6971 10.223 12.9296 10.0873C13.046 10.0194 13.1269 9.95614 13.1767 9.90082C13.2272 9.8448 13.2352 9.80937 13.2353 9.79437V6.20551C13.2355 5.98282 13.4159 5.80225 13.6386 5.80219Z" fill="#64748B" stroke="#64748B" stroke-width="0.294737"/>
													<path d="M13.6386 2.21399C13.8614 2.21399 14.0417 2.39458 14.0419 2.61731V6.20618C14.0418 6.57021 13.8118 6.86857 13.4697 7.10461C13.1263 7.34153 12.6459 7.53403 12.0849 7.68665C10.9608 7.99245 9.47282 8.14758 7.99994 8.14758C6.52728 8.14756 5.03997 7.99238 3.91595 7.68665C3.35509 7.53407 2.87456 7.34146 2.53119 7.10461C2.18909 6.86856 1.95806 6.57022 1.95795 6.20618V2.61731C1.95818 2.39472 2.13868 2.21422 2.36127 2.21399C2.58405 2.21399 2.76533 2.39458 2.76556 2.61731V6.20618C2.76566 6.22118 2.77369 6.2566 2.82416 6.31262C2.87406 6.36795 2.95486 6.43124 3.07123 6.49915C3.30378 6.63483 3.65532 6.77479 4.11615 6.90051C5.03589 7.15139 6.36782 7.33994 7.99994 7.33997C9.63238 7.33997 10.9649 7.15145 11.8847 6.90051C12.3455 6.7748 12.6971 6.63482 12.9296 6.49915C13.046 6.43123 13.1269 6.36795 13.1767 6.31262C13.2272 6.2566 13.2352 6.22117 13.2353 6.20618V2.61731C13.2355 2.39462 13.4159 2.21406 13.6386 2.21399Z" fill="#64748B" stroke="#64748B" stroke-width="0.294737"/>
													<path d="M11.7708 5.198C11.9936 5.198 12.1749 5.37858 12.1751 5.60132C12.1751 5.82426 11.9938 6.00562 11.7708 6.00562C11.5481 6.00538 11.3675 5.82411 11.3675 5.60132C11.3677 5.37873 11.5482 5.19823 11.7708 5.198Z" fill="#64748B" stroke="#64748B" stroke-width="0.294737"/>
													<path d="M11.7708 8.78625C11.9936 8.78625 12.1749 8.96684 12.1751 9.18958C12.1751 9.41251 11.9938 9.59387 11.7708 9.59387C11.5481 9.59364 11.3675 9.41237 11.3675 9.18958C11.3677 8.96698 11.5482 8.78649 11.7708 8.78625Z" fill="#64748B" stroke="#64748B" stroke-width="0.294737"/>
													<path d="M11.7708 12.3743C11.9936 12.3743 12.1749 12.5549 12.1751 12.7776C12.1751 13.0006 11.9938 13.1819 11.7708 13.1819C11.5481 13.1817 11.3675 13.0004 11.3675 12.7776C11.3677 12.5551 11.5482 12.3746 11.7708 12.3743Z" fill="#64748B" stroke="#64748B" stroke-width="0.294737"/>
												</g>
												<defs>
													<clipPath id="clip0_7_103">
														<rect width="16" height="16" fill="white"/>
													</clipPath>
												</defs>
											</svg>
											Save to DB
										</button>
									</li>
									<li>
										<button class="navtablinks wpsslc-nav-freevspro" onclick="wpsslcNavTab(event, 'wpsslc-nav-freevspro')">
											<svg width="21" height="21" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
												<path d="M6.53411 8.4773H3.94319C3.42782 8.4773 2.93357 8.27257 2.56915 7.90815C2.20473 7.54373 2 7.04948 2 6.53411V3.94319C2 3.42782 2.20473 2.93357 2.56915 2.56915C2.93357 2.20473 3.42782 2 3.94319 2H6.53411C7.04948 2 7.54373 2.20473 7.90815 2.56915C8.27257 2.93357 8.4773 3.42782 8.4773 3.94319V6.53411C8.4773 7.04948 8.27257 7.54373 7.90815 7.90815C7.54373 8.27257 7.04948 8.4773 6.53411 8.4773ZM3.94319 3.29546C3.7714 3.29546 3.60665 3.3637 3.48518 3.48518C3.3637 3.60665 3.29546 3.7714 3.29546 3.94319V6.53411C3.29546 6.7059 3.3637 6.87065 3.48518 6.99212C3.60665 7.1136 3.7714 7.18184 3.94319 7.18184H6.53411C6.7059 7.18184 6.87065 7.1136 6.99212 6.99212C7.1136 6.87065 7.18184 6.7059 7.18184 6.53411V3.94319C7.18184 3.7714 7.1136 3.60665 6.99212 3.48518C6.87065 3.3637 6.7059 3.29546 6.53411 3.29546H3.94319ZM14.3069 8.4773H11.716C11.2006 8.4773 10.7063 8.27257 10.3419 7.90815C9.97749 7.54373 9.77276 7.04948 9.77276 6.53411V3.94319C9.77276 3.42782 9.97749 2.93357 10.3419 2.56915C10.7063 2.20473 11.2006 2 11.716 2H14.3069C14.8222 2 15.3165 2.20473 15.6809 2.56915C16.0453 2.93357 16.2501 3.42782 16.2501 3.94319V6.53411C16.2501 7.04948 16.0453 7.54373 15.6809 7.90815C15.3165 8.27257 14.8222 8.4773 14.3069 8.4773ZM11.716 3.29546C11.5442 3.29546 11.3794 3.3637 11.2579 3.48518C11.1365 3.60665 11.0682 3.7714 11.0682 3.94319V6.53411C11.0682 6.7059 11.1365 6.87065 11.2579 6.99212C11.3794 7.1136 11.5442 7.18184 11.716 7.18184H14.3069C14.4787 7.18184 14.6434 7.1136 14.7649 6.99212C14.8864 6.87065 14.9546 6.7059 14.9546 6.53411V3.94319C14.9546 3.7714 14.8864 3.60665 14.7649 3.48518C14.6434 3.3637 14.4787 3.29546 14.3069 3.29546H11.716ZM6.53411 16.2501H3.94319C3.42782 16.2501 2.93357 16.0453 2.56915 15.6809C2.20473 15.3165 2 14.8222 2 14.3069V11.716C2 11.2006 2.20473 10.7063 2.56915 10.3419C2.93357 9.97749 3.42782 9.77276 3.94319 9.77276H6.53411C7.04948 9.77276 7.54373 9.97749 7.90815 10.3419C8.27257 10.7063 8.4773 11.2006 8.4773 11.716V14.3069C8.4773 14.8222 8.27257 15.3165 7.90815 15.6809C7.54373 16.0453 7.04948 16.2501 6.53411 16.2501ZM3.94319 11.0682C3.7714 11.0682 3.60665 11.1365 3.48518 11.2579C3.3637 11.3794 3.29546 11.5442 3.29546 11.716V14.3069C3.29546 14.4787 3.3637 14.6434 3.48518 14.7649C3.60665 14.8864 3.7714 14.9546 3.94319 14.9546H6.53411C6.7059 14.9546 6.87065 14.8864 6.99212 14.7649C7.1136 14.6434 7.18184 14.4787 7.18184 14.3069V11.716C7.18184 11.5442 7.1136 11.3794 6.99212 11.2579C6.87065 11.1365 6.7059 11.0682 6.53411 11.0682H3.94319ZM14.3069 16.2501H11.716C11.2006 16.2501 10.7063 16.0453 10.3419 15.6809C9.97749 15.3165 9.77276 14.8222 9.77276 14.3069V11.716C9.77276 11.2006 9.97749 10.7063 10.3419 10.3419C10.7063 9.97749 11.2006 9.77276 11.716 9.77276H14.3069C14.8222 9.77276 15.3165 9.97749 15.6809 10.3419C16.0453 10.7063 16.2501 11.2006 16.2501 11.716V14.3069C16.2501 14.8222 16.0453 15.3165 15.6809 15.6809C15.3165 16.0453 14.8222 16.2501 14.3069 16.2501ZM11.716 11.0682C11.5442 11.0682 11.3794 11.1365 11.2579 11.2579C11.1365 11.3794 11.0682 11.5442 11.0682 11.716V14.3069C11.0682 14.4787 11.1365 14.6434 11.2579 14.7649C11.3794 14.8864 11.5442 14.9546 11.716 14.9546H14.3069C14.4787 14.9546 14.6434 14.8864 14.7649 14.7649C14.8864 14.6434 14.9546 14.4787 14.9546 14.3069V11.716C14.9546 11.5442 14.8864 11.3794 14.7649 11.2579C14.6434 11.1365 14.4787 11.0682 14.3069 11.0682H11.716Z" fill="#64748B"/>
											</svg>
											Free vs Pro
										</button>
									</li>
								</ul>
							</div>
						</div>
						<div class="wpsslc-header-right">
							<ul class="wpsslc-header-links">
								<li class="version"><span>V<?php echo esc_html(WPSSLC_VERSION); ?></span></li>
								<li id="wpsslcBtn">
									<a target="_blank" href="<?php echo esc_url(WPSSLC_DOCS_LINK); ?>">
										<svg width="16" height="20" viewBox="0 0 15 19" fill="none" xmlns="http://www.w3.org/2000/svg">
											<path d="M4.61806 7.6H5.54167C5.78662 7.6 6.02155 7.49991 6.19476 7.32175C6.36797 7.14359 6.46528 6.90196 6.46528 6.65C6.46528 6.39804 6.36797 6.15641 6.19476 5.97825C6.02155 5.80009 5.78662 5.7 5.54167 5.7H4.61806C4.3731 5.7 4.13817 5.80009 3.96496 5.97825C3.79175 6.15641 3.69444 6.39804 3.69444 6.65C3.69444 6.90196 3.79175 7.14359 3.96496 7.32175C4.13817 7.49991 4.3731 7.6 4.61806 7.6ZM4.61806 9.5C4.3731 9.5 4.13817 9.60009 3.96496 9.77825C3.79175 9.95641 3.69444 10.198 3.69444 10.45C3.69444 10.702 3.79175 10.9436 3.96496 11.1218C4.13817 11.2999 4.3731 11.4 4.61806 11.4H10.1597C10.4047 11.4 10.6396 11.2999 10.8128 11.1218C10.986 10.9436 11.0833 10.702 11.0833 10.45C11.0833 10.198 10.986 9.95641 10.8128 9.77825C10.6396 9.60009 10.4047 9.5 10.1597 9.5H4.61806ZM14.7778 6.593C14.7682 6.50573 14.7496 6.41975 14.7224 6.3365V6.251C14.678 6.15332 14.6187 6.06353 14.5469 5.985L9.00521 0.285C8.92886 0.211105 8.84156 0.150177 8.7466 0.1045C8.71903 0.100472 8.69104 0.100472 8.66347 0.1045C8.56965 0.0491542 8.46603 0.013627 8.35868 0H2.77083C2.03596 0 1.33119 0.300267 0.811558 0.834746C0.291926 1.36922 0 2.09413 0 2.85V16.15C0 16.9059 0.291926 17.6308 0.811558 18.1653C1.33119 18.6997 2.03596 19 2.77083 19H12.0069C12.7418 19 13.4466 18.6997 13.9662 18.1653C14.4859 17.6308 14.7778 16.9059 14.7778 16.15V6.65C14.7778 6.65 14.7778 6.65 14.7778 6.593ZM9.23611 3.2395L11.6283 5.7H10.1597C9.91477 5.7 9.67984 5.59991 9.50663 5.42175C9.33342 5.24359 9.23611 5.00196 9.23611 4.75V3.2395ZM12.9306 16.15C12.9306 16.402 12.8332 16.6436 12.66 16.8218C12.4868 16.9999 12.2519 17.1 12.0069 17.1H2.77083C2.52588 17.1 2.29095 16.9999 2.11774 16.8218C1.94453 16.6436 1.84722 16.402 1.84722 16.15V2.85C1.84722 2.59804 1.94453 2.35641 2.11774 2.17825C2.29095 2.00009 2.52588 1.9 2.77083 1.9H7.38889V4.75C7.38889 5.50587 7.68081 6.23078 8.20045 6.76525C8.72008 7.29973 9.42485 7.6 10.1597 7.6H12.9306V16.15ZM10.1597 13.3H4.61806C4.3731 13.3 4.13817 13.4001 3.96496 13.5782C3.79175 13.7564 3.69444 13.998 3.69444 14.25C3.69444 14.502 3.79175 14.7436 3.96496 14.9218C4.13817 15.0999 4.3731 15.2 4.61806 15.2H10.1597C10.4047 15.2 10.6396 15.0999 10.8128 14.9218C10.986 14.7436 11.0833 14.502 11.0833 14.25C11.0833 13.998 10.986 13.7564 10.8128 13.5782C10.6396 13.4001 10.4047 13.3 10.1597 13.3Z" fill="#464D58"/>
										</svg>
										<span class="tooltip-text">Documentation</span>
									</a>
								</li>
								<li>
									<a target="_blank" href="<?php echo esc_url(self::$submit_ticket); ?>">
										<svg width="20" height="20" viewBox="0 0 19 19" fill="none" xmlns="http://www.w3.org/2000/svg">
											<path d="M13.2708 2.87C13.5005 3.00037 13.7724 3.03464 14.0273 2.96532C14.2821 2.896 14.4992 2.72873 14.6311 2.5C14.7403 2.30736 14.9104 2.15639 15.1146 2.07078C15.3188 1.98517 15.5457 1.96975 15.7597 2.02694C15.9736 2.08414 16.1626 2.21071 16.2968 2.38681C16.4311 2.56291 16.5031 2.77858 16.5015 3C16.5015 3.26522 16.3961 3.51957 16.2086 3.70711C16.021 3.89464 15.7666 4 15.5013 4C15.236 4 14.9816 4.10536 14.794 4.29289C14.6065 4.48043 14.5011 4.73478 14.5011 5C14.5011 5.26522 14.6065 5.51957 14.794 5.70711C14.9816 5.89464 15.236 6 15.5013 6C16.0279 5.99966 16.5452 5.86075 17.0011 5.59723C17.4571 5.33371 17.8356 4.95486 18.0987 4.49875C18.3618 4.04264 18.5002 3.52533 18.5 2.9988C18.4998 2.47227 18.361 1.95507 18.0975 1.49917C17.834 1.04326 17.4552 0.664718 16.9991 0.401563C16.5429 0.138409 16.0255 -8.42941e-05 15.4989 3.84915e-08C14.9723 8.43711e-05 14.4549 0.138743 13.9989 0.402044C13.5428 0.665344 13.1641 1.04401 12.9008 1.5C12.8346 1.61413 12.7917 1.74022 12.7745 1.871C12.7574 2.00178 12.7662 2.13466 12.8006 2.262C12.835 2.38934 12.8943 2.50862 12.975 2.61297C13.0557 2.71732 13.1562 2.80467 13.2708 2.87ZM17.5717 10C17.3092 9.96593 17.0438 10.0373 16.8338 10.1985C16.6239 10.3597 16.4864 10.5976 16.4515 10.86C16.2416 12.5552 15.419 14.1151 14.1386 15.246C12.8583 16.3769 11.2085 17.0007 9.50006 17H3.90889L4.55903 16.35C4.74532 16.1626 4.84988 15.9092 4.84988 15.645C4.84988 15.3808 4.74532 15.1274 4.55903 14.94C3.58378 13.9611 2.92007 12.7156 2.65153 11.3603C2.38298 10.005 2.52159 8.60052 3.04992 7.32383C3.57824 6.04714 4.47263 4.95532 5.62044 4.18589C6.76825 3.41646 8.11813 3.00384 9.50006 3C9.76533 3 10.0197 2.89464 10.2073 2.70711C10.3949 2.51957 10.5003 2.26522 10.5003 2C10.5003 1.73478 10.3949 1.48043 10.2073 1.29289C10.0197 1.10536 9.76533 0.999999 9.50006 0.999999C7.80894 1.00705 6.15401 1.49024 4.72486 2.39419C3.29571 3.29815 2.15016 4.58632 1.41944 6.11112C0.688721 7.63592 0.40239 9.33568 0.593251 11.0157C0.784113 12.6956 1.44445 14.2879 2.4986 15.61L0.788246 17.29C0.64946 17.4306 0.555444 17.6092 0.518062 17.8032C0.48068 17.9972 0.501607 18.1979 0.578203 18.38C0.653238 18.5626 0.780663 18.7189 0.944417 18.8293C1.10817 18.9396 1.30093 18.999 1.49839 19H9.50006C11.692 19.0003 13.8087 18.201 15.4531 16.7521C17.0975 15.3031 18.1567 13.3041 18.4319 11.13C18.4502 10.9993 18.4424 10.8662 18.409 10.7385C18.3756 10.6107 18.3172 10.4909 18.2373 10.3858C18.1573 10.2808 18.0573 10.1926 17.9431 10.1264C17.8289 10.0602 17.7026 10.0172 17.5717 10ZM15.8814 7.07C15.6993 6.98945 15.4973 6.96508 15.3013 7L15.1212 7.06L14.9412 7.15L14.7912 7.28C14.7012 7.37215 14.6299 7.48081 14.5811 7.6C14.522 7.72473 14.4945 7.86212 14.5011 8C14.4982 8.13337 14.522 8.26597 14.5711 8.39C14.6228 8.51002 14.6976 8.61873 14.7912 8.71C14.8846 8.80268 14.9955 8.87601 15.1173 8.92577C15.2392 8.97553 15.3697 9.00076 15.5013 9C15.7666 9 16.021 8.89464 16.2086 8.70711C16.3961 8.51957 16.5015 8.26522 16.5015 8C16.5049 7.86882 16.4775 7.73868 16.4215 7.62C16.314 7.37971 16.1217 7.18745 15.8814 7.08V7.07Z" fill="#464D58"/>
										</svg>
										<span class="tooltip-text">Support</span>
									</a>
								</li>
								<li>
									<a class="whatsNew-toggle" href="#">
										<svg width="17" height="18" viewBox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg">
											<path d="M15.6111 1.5157e-07C15.4944 -6.7285e-05 15.3787 0.0231658 15.2709 0.0683712C15.163 0.113577 15.065 0.179867 14.9824 0.263454C14.8999 0.34704 14.8344 0.446282 14.7897 0.555505C14.7451 0.664729 14.7222 0.781791 14.7222 0.9V1.47305C13.9725 2.41418 13.025 3.17422 11.9487 3.69785C10.8723 4.22147 9.69415 4.4955 8.5 4.5H3.16667C2.45966 4.50078 1.78183 4.7855 1.2819 5.29167C0.781971 5.79785 0.500772 6.48415 0.5 7.2V9C0.500772 9.71584 0.781971 10.4021 1.2819 10.9083C1.78183 11.4145 2.45966 11.6992 3.16667 11.7H3.5967L1.46094 16.7458C1.4029 16.8826 1.37934 17.0319 1.39237 17.1803C1.40539 17.3286 1.45461 17.4714 1.53558 17.5957C1.61656 17.7201 1.72677 17.8221 1.85631 17.8927C1.98585 17.9632 2.13068 18.0001 2.27778 18H5.83333C6.00734 18.0001 6.17753 17.9484 6.32276 17.8514C6.46799 17.7543 6.58185 17.6162 6.65018 17.4542L9.07129 11.7342C10.1652 11.8155 11.231 12.123 12.203 12.6377C13.1749 13.1524 14.0323 13.8634 14.7222 14.7268V15.3C14.7222 15.5387 14.8159 15.7676 14.9826 15.9364C15.1493 16.1052 15.3754 16.2 15.6111 16.2C15.8469 16.2 16.073 16.1052 16.2396 15.9364C16.4063 15.7676 16.5 15.5387 16.5 15.3V0.9C16.5001 0.781791 16.4771 0.664728 16.4325 0.555504C16.3878 0.44628 16.3224 0.347037 16.2398 0.263451C16.1572 0.179865 16.0592 0.113574 15.9514 0.0683688C15.8435 0.0231639 15.7279 -6.84694e-05 15.6111 1.5157e-07ZM3.16667 9.9C2.93097 9.89984 2.70497 9.80497 2.5383 9.63622C2.37164 9.46747 2.27794 9.23864 2.27778 9V7.2C2.27794 6.96135 2.37164 6.73253 2.5383 6.56378C2.70497 6.39504 2.93097 6.30016 3.16667 6.3H4.05556V9.9H3.16667ZM5.2474 16.2H3.62587L5.53038 11.7H7.15191L5.2474 16.2ZM14.7222 12.1696C12.9696 10.7077 10.7708 9.90565 8.5 9.89995H5.83333V6.29995H8.5C10.7709 6.29408 12.9696 5.4919 14.7222 4.02985V12.1696Z" fill="#464D58"/>
										</svg>
										<span class="tooltip-text">Change Log</span>
									</a>
								</li>
							</ul>
							<div class="whatsNew-block">
								<div class="block-header">
									<h3>Change Log</h3>
									<button type="button" class="close-block">
										<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true" class="h-6 w-6"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12"></path></svg>
									</button>
								</div>	
								<div class="wpsslc-block-content changeLog-conntent">
									<?php
		$changelog = self::wpsslc_get_plugin_changelog(WP_PLUGIN_DIR . '/contactsheets-lite');
		// phpcs:ignore
		echo nl2br($changelog);
?>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<!-- messages html -->
			<div class="alert-messages">
				<div class="container">
				</div>
			</div>
			<!-- messages html end-->		
			<div class="wpsslc-tabs-main">

			     <!-- DashBoard html start   -->
				<div id="wpsslc-nav-dashboard" class="navtabcontent vertical-tabs"
					<?php
		if ('dashboard' !== $show_tab) {
			echo "style='display:none;'";
		}
		else {
			echo "style='display:block;'";
		}
?> >
					<div class="wpss-dashboard-container">

						<!-- Welcome html start -->
						<div class="wpss-dashboard-left-content">
							<div class="wpss-dashboard-navtabcontent">
								<!-- Header Section -->
								<div class="welcome-wpsyncsheets-section">
									<div class="welcome-data">
										<div class="welcome-title">
											<span>Welcome To WPSyncSheets</span>
										</div>
										<p>
											WPSyncSheets For Contact Form 7 is designed to simplify your workflow by syncing your website forms data directly with Google Sheets. To explore all its features, check out the official documentation and video tutorials.
										</p>
									</div>
									<div class="unlock-pro-button-section">
										<a class="underline" href="javascript:void(0)" onclick="wpsslcNavTabLetsBegin(event, 'wpsslc-nav-googleapi')">
											Let's Connect
										</a>
									</div>
								</div>
							</div>

							<div class="wpss-setup-guide-navtabcontent">
								<!-- Header Section -->
								<div class="setup-guide-section">
									<div class="setup-guide-data">
										<div class="setup-guide-title">
											<span>Setup Guide & Troubleshooting</span>
										</div>
										<p>
											Sync Contact Form 7 data with Google Sheets in real-time — effortlessly and accurately.
										</p>
									</div>
									<div class="setup-content-data">
										<div class="setup-row">
											<div class="google-api-setting-guide">
												<h1>Connecting Google Account</h1>
												<ul>
													<li><a href="https://docs.wpsyncsheets.com/wpssc-google-sheets-api-settings/" target="_blank">Google API Settings Guide</a></li>
													<li><a href="https://www.wpsyncsheets.com/how-to-resolve-google-oauth-2-authorization-error-redirect_uri_mismatch/" target="_blank">How to resolve 400 redirect_uri_mismatch?</a></li>
													<li><a href="https://docs.wpsyncsheets.com/wpssc-faq/#appverified" target="_blank">How to resolve "This app isn’t verified"?</a></li>
													<li><a href="https://docs.wpsyncsheets.com/wpssc-faq/#rangeexceed" target="_blank">How to resolve range exceeds grid limits?</a></li>
												</ul>
											</div>
											<div class="google-api-setting-guide">
												<h1>Miscellaneous</h1>
												<ul>
													<li><a href="https://docs.wpsyncsheets.com/wpssc-filters-hooks-snippets/" target="_blank">Filters, Hooks & Snippets</a></li>
												</ul>
											</div>
										</div>

										<div class="setup-row">
											<div class="google-api-setting-guide">
												<h1>Export</h1>
												<ul>
													<li><a href="https://docs.wpsyncsheets.com/how-to-export-cf-entries/" target="_blank">How to Export Entries?</a></li>
												</ul>
											</div>
										</div>
									</div>
								</div>
							</div>
							
						</div>

						<!-- Import Export plugin -->
						<div class="wpss-dashboard-right-content">
							<div class="wpss-dashboard-related-plugins">
								<div class="wpss-import-export-plugins">
									<h1 class="import-export-title">Automated Sync for WordPress Data with Google Sheets</h1>

									<!-- Gravity Form -->	
									<div class="import-export-plugin-section">
										<div class="free-right-title">
											<span>Free</span>
										</div>
										<div class="import-export-plugin-info">
											<div class="import-export-feature-img">
												<img src="<?php echo esc_url(WPSSLC_URL . 'assets/images/woocommerce-icon.svg'); ?>">
											</div>
											<div class="import-export-box-border">
												<div class="import-export-pro-content">
													<h1>WPSyncSheets For WooCommerce</h1>
												</div>
													<p class="text">Sync WooCommerce submissions with Google Sheets. Automate data management through real-time imports and exports.</p>
										
												<div class="import-export-button-section">
													<?php
		$wpssw_plugin_slug = 'wpsyncsheets-woocommerce';
		$wpssw_plugin_file = 'wpsyncsheets-woocommerce/wpsyncsheets-lite-woocommerce.php';
		$wpssw_status = WPSSLC_Dependencies::check_plugin_install_and_activation_status($wpssw_plugin_slug, $wpssw_plugin_file);
?>
													<?php wp_nonce_field('install_active', 'wpssw_api_dashboard'); ?>
													<?php
		if ($wpssw_status['active'] || $wpssw_status['network_active']) {
?>
													<a class="activated" href="javascript:void(0)">
														Activated
													</a>
													<?php
		}
		else if (!$wpssw_status['installed']) { ?>
													<a class="underline" href="javascript:void(0)" id="wpsswinstallactivebtn">
														Install
													</a>
													<?php
		}
		else { ?>
													<a class="underline" href="javascript:void(0)" id="wpsswactivebtn">
														Activate
													</a>
													<?php
		}?>
												</div>
											</div>
										</div>
									</div>

									<!-- Elementor -->
									<div class="import-export-plugin-section">
										<div class="free-left-title">
											<span>Free</span>
										</div>
										<div class="import-export-plugin-info">
											<div class="import-export-box-border">
												<div class="import-export-pro-content">
													<h1>WPSyncSheets For Elementor</h1>
												</div>
													<p class="text">Sync Elementor Form submissions with Google Sheets. Automate data management through real-time imports and exports.</p>
										
												<div class="import-export-button-section">
													<?php
		$wpsse_plugin_slug = 'wpsyncsheets-elementor';
		$wpsse_plugin_file = 'wpsyncsheets-elementor/wpsyncsheets-lite-elementor.php';
		$wpsse_status = WPSSLC_Dependencies::check_plugin_install_and_activation_status($wpsse_plugin_slug, $wpsse_plugin_file);
?>
													<?php wp_nonce_field('install_active', 'wpsse_api_dashboard'); ?>
													<?php
		if ($wpsse_status['active'] || $wpsse_status['network_active']) {
?>
													<a class="activated" href="javascript:void(0)">
														Activated
													</a>
													<?php
		}
		else if (!$wpsse_status['installed']) { ?>
													<a class="underline" href="javascript:void(0)" id="wpsseinstallactivebtn">
														Install
													</a>
													<?php
		}
		else { ?>
													<a class="underline" href="javascript:void(0)" id="wpsseactivebtn">
														Activate
													</a>
													<?php
		}?>
												</div>
											</div>
											<div class="import-export-feature-img">
												<img src="<?php echo esc_url(WPSSLC_URL . 'assets/images/Elementor-icon.svg'); ?>">
											</div>
										</div>
									</div>

									<!-- Contact Form -->
									<div class="import-export-plugin-section">
										<div class="free-right-title">
											<span>Free</span>
										</div>
										<div class="import-export-plugin-info">
											<div class="import-export-feature-img">
												<img src="<?php echo esc_url(WPSSLC_URL . 'assets/images/GravityForms-icon.svg'); ?>">
											</div>
											<div class="import-export-box-border">
												<div class="import-export-pro-content">
													<h1>WPSyncSheets For GravityForms</h1>
												</div>
													<p class="text">Sync Gravity Forms submissions with Google Sheets. Automate data management through real-time exports.</p>
										
												<div class="import-export-button-section">
													<?php
		$wpssg_plugin_slug = 'wpsyncsheets-gravity-forms';
		$wpssg_plugin_file = 'wpsyncsheets-gravity-forms/wpsyncsheets-lite-gravity-forms.php';
		$wpssg_status = WPSSLC_Dependencies::check_plugin_install_and_activation_status($wpssg_plugin_slug, $wpssg_plugin_file);
?>
													<?php wp_nonce_field('install_active', 'wpssg_api_dashboard'); ?>
													<?php
		if ($wpssg_status['active'] || $wpssg_status['network_active']) {
?>
													<a class="activated" href="javascript:void(0)">
														Activated
													</a>
													<?php
		}
		else if (!$wpssg_status['installed']) { ?>
													<a class="underline" href="javascript:void(0)" id="wpssginstallactivebtn">
														Install
													</a>
													<?php
		}
		else { ?>
													<a class="underline" href="javascript:void(0)" id="wpssgactivebtn">
														Activate
													</a>
													<?php
		}?>
												</div>
											</div>
										</div>
									</div>

									<!-- WPForms -->
									<div class="import-export-plugin-section">
										<div class="free-left-title">
											<span>Free</span>
										</div>
										<div class="import-export-plugin-info">
											<div class="import-export-box-border">
												<div class="import-export-pro-content">
													<h1>WPSyncSheets For WPForms</h1>
												</div>
													<p class="text">Sync WPForms submissions with Google Sheets. Automate data management through real-time exports.</p>
												<div class="import-export-button-section">
													<?php
		$wpsswp_plugin_slug = 'wpsyncsheets-wpforms';
		$wpsswp_plugin_file = 'wpsyncsheets-wpforms/wpsyncsheets-lite-wpforms.php';
		$wpsswp_status = WPSSLC_Dependencies::check_plugin_install_and_activation_status($wpsswp_plugin_slug, $wpsswp_plugin_file);
?>
													<?php wp_nonce_field('install_active', 'wpsswp_api_dashboard'); ?>
													<?php
		if ($wpsswp_status['active'] || $wpsswp_status['network_active']) {
?>
													<a class="activated" href="javascript:void(0)">
														Activated
													</a>
													<?php
		}
		else if (!$wpsswp_status['installed']) { ?>
													<a class="underline" href="javascript:void(0)" id="wpsswpinstallactivebtn">
														Install
													</a>
													<?php
		}
		else { ?>
													<a class="underline" href="javascript:void(0)" id="wpsswpactivebtn">
														Activate
													</a>
													<?php
		}?>
												</div>
											</div>
											<div class="import-export-feature-img">
												<img src="<?php echo esc_url(WPSSLC_URL . 'assets/images/WPForms-icon.svg'); ?>">
											</div>
										</div>
									</div>
									
								</div>
							</div>
						</div>
					
					</div>
						<!-- Video Tutorial html start -->
					<div class="wpss-dashboard-bottom-content">
						<div class="wpss-dashboard-related-video">
							<!-- Header Section -->
							<div class="video-tutorial-section">
								<div class="video-title">
									<span>Video Tutorials</span>
								</div>
								<div class="video-grid">
									<div class="video-item">
										<a href="#" target="_blank" class="play-icon" data-video-id="Z6-wzgpRlLE">
										    <img src="<?php echo esc_url(WPSSLC_URL . 'assets/images/WPSyncSheets-Intro.jpg'); ?>" alt="">
										</a>
									</div>
									<div class="video-item">
										<a href="#" target="_blank" class="play-icon" data-video-id="EFLcBu-Jgp8">
										    <img src="<?php echo esc_url(WPSSLC_URL . 'assets/images/client-id-client-secret.jpg'); ?>" alt="">
										</a>
									</div>
								</div>
								<div id="video-popup">
									<div class="popup-inner">
										<span class="close">&times;</span>
										<div class="video-wrapper">
										<iframe id="youtube-video" src="" frameborder="0" allowfullscreen allow="autoplay"></iframe>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>    
             

				<div id="wpsslc-nav-googleapi" class="navtabcontent vertical-tabs"
					<?php
		if ('api' !== $show_tab) {
			echo "style='display:none;'";
		}
		else {
			echo "style='display:block;'";
		}
?> >
					<div id="googleapi-settings" class="wpsslc-navtabcontent">
						<?php
		if (!current_user_can('edit_wpsyncsheets_contact_form_7_lite_main_settings')) {
?>
						<div class="wpsslc-top-subtext generalSetting-section">
							<div class="generalSetting-left">
								<h4><?php echo esc_html__('You do not have permission to access this page.', 'contactsheets-lite'); ?></h4>
							</div>
						</div>
							<?php
		}
		else {
?>
						<div class="wpsslc-top-subtext generalSetting-section">
							<div class="generalSetting-left">
								<h4><?php echo esc_html__('Google API Settings', 'contactsheets-lite'); ?></h4>
								<p><?php echo esc_html__('Google APIs allow you to embed Google Services in your online site. To connect Google Drive and Google Sheets with your WordPress website, you need to generate dedicated API keys. To begin the process, kindly log in to your Gmail Account and follow the link to initiate the setup ', 'contactsheets-lite'); ?><a href="<?php echo esc_url(self::$doc_sheet_setting); ?>" target="_blank"><?php echo esc_html__('click here', 'contactsheets-lite'); ?>.</a></p>
							</div>
						</div>
						<form method="post" action="<?php echo esc_html(admin_url('admin.php?page=wpsyncsheets-for-contact-form-7')); ?>">
							<?php wp_nonce_field('save_api_settings', 'wpsslc_api_settings'); ?>
							<div id="universal-message-container">
								<div class="generalSetting-section">
									<div class="integrationtabform">
										<div class="options">
											<ul class="form-table">
												<li>
													<label> <?php echo esc_html__('Client ID', 'contactsheets-lite'); ?> </label>
													<div class="forminp forminp-text">
														<input type="text" id="client_id" name="client_id" value="<?php echo isset($wpsslc_google_settings_value[0]) ? esc_attr($wpsslc_google_settings_value[0]) : ''; ?>" size="80" class = "googlesettinginput" placeholder="Enter Client Id" 
															<?php
			if (!empty($wpsslc_google_settings_value[0])) {
				echo 'readonly';
			}
?>
														/>
													</div>
												</li>
												<li>
													<label> <?php echo esc_html__('Client Secret Key', 'contactsheets-lite'); ?> </label>
													<div class="forminp forminp-text">
														<input type="text" id="client_secret" name="client_secret" value="<?php echo isset($wpsslc_google_settings_value[1]) ? esc_attr($wpsslc_google_settings_value[1]) : ''; ?>" size="80" class = "googlesettinginput" placeholder="Enter Client Secret" 
															<?php
			if (!empty($wpsslc_google_settings_value[1])) {
				echo 'readonly';
			}
?>
														/>
													</div>
												</li>
												<?php
			if (!empty($wpsslc_google_settings_value[0]) && !empty($wpsslc_google_settings_value[1])) {
				$wpsslc_token_value = $wpsslc_google_settings_value[2];
?>
												<li>
													<label><?php echo esc_html__('Client Token', 'contactsheets-lite'); ?></label>
													<?php
				if (empty($wpsslc_token_value) && !isset($_GET['code'])) {
					$wpsslc_auth_url = self::$instance_api->getClient();
					self::$instance_api->wpsslc_update_option('wpssc_share_enable', true);
?>
														<div id="authbtn">
															<a href="<?php echo esc_url($wpsslc_auth_url); ?>" id="authlink" target="_blank" ><div class="wpsslc-button wpsslc-button-secondary"><?php echo esc_html__('Click here to generate an Authentication Token', 'contactsheets-lite'); ?></div></a>
														</div>
														<?php
				}
				$wpsslc_code = '';
				$wpsslc_google_settings_value = self::$instance_api->wpsslc_option('wpssc_google_settings');
?>
													<div  id="authtext" 
													<?php
				if (!empty($wpsslc_token_value) || $wpsslc_code) {
					echo 'class = "forminp forminp-text wpsslc-authtext" ';
				}
				else {
					echo 'class="forminp forminp-text"';
				}
?>
														><input type="text" name="client_token" value="<?php echo $wpsslc_token_value ? esc_attr($wpsslc_token_value) : esc_attr($wpsslc_code); ?>" size="80" placeholder="Please enter authentication code" id="client_token" class="googlesettinginput" 
															<?php
				if (!empty($wpsslc_google_settings_value[2])) {
					echo 'readonly';
				}
?>
														/>
													</div>
												</li>
												<?php
			}
			if (!empty($wpsslc_token_value)) { ?>
												<li>
													<label></label>
													<div><input type="submit" name="revoke" id="revoke" value = "Revoke Token" class="wpsslc-button wpsslc-button-secondary"/></div>
												</li>
												<?php
			}?>
											</ul>
										</div>
										<?php
			$site_url = isset($_SERVER['SERVER_NAME']) ? sanitize_text_field(wp_unslash($_SERVER['SERVER_NAME'])) : '';
			$site_url = str_replace('www.', '', $site_url);
?>
										<div class="submit-section">
											<p class="submit">
												<input type="submit" name="submit" id="submit" class="wpsslc-button wpsslc-button-primary" value="Save">
												<?php
			if (!empty($wpsslc_token_value) || !empty($wpsslc_google_settings_value[0]) || !empty($wpsslc_google_settings_value[1])) {
?>
														<input type="submit" name="reset_settings" id="reset_settings" value = "Reset" class="wpsslc-button wpsslc-button-primary reset_settings"/>
													<?php
			}?>
											</p>
										</div>
									</div>
								</div>
								<div class="generalSetting-section copy-url-table">
									<ul>
										<li>
											<label><?php echo esc_html__('Authorized Domain : ', 'contactsheets-lite'); ?></label>
											<div class="copy-url-text"><span id="authorized_domain"><?php echo esc_html($site_url); ?></span>
												<span class="copy-icon wpsslc-button" id="a_domain" onclick="wpsslcCopy('authorized_domain','a_domain');">
													<svg width="15" height="18" viewBox="0 0 15 18" fill="none" xmlns="http://www.w3.org/2000/svg">
														<path d="M2.16667 17.3334C1.70833 17.3334 1.31597 17.1702 0.989583 16.8438C0.663194 16.5174 0.5 16.1251 0.5 15.6667V4.00008H2.16667V15.6667H11.3333V17.3334H2.16667ZM5.5 14.0001C5.04167 14.0001 4.64931 13.8369 4.32292 13.5105C3.99653 13.1841 3.83333 12.7917 3.83333 12.3334V2.33341C3.83333 1.87508 3.99653 1.48272 4.32292 1.15633C4.64931 0.829942 5.04167 0.666748 5.5 0.666748H13C13.4583 0.666748 13.8507 0.829942 14.1771 1.15633C14.5035 1.48272 14.6667 1.87508 14.6667 2.33341V12.3334C14.6667 12.7917 14.5035 13.1841 14.1771 13.5105C13.8507 13.8369 13.4583 14.0001 13 14.0001H5.5ZM5.5 12.3334H13V2.33341H5.5V12.3334Z" fill="#383E46"/>
													</svg>
													<span class="tooltip-text">Copied</span>
												</span>
											</div>
										</li>
										<li>
											<label><?php echo esc_html__('Authorised redirect URIs : ', 'contactsheets-lite'); ?></label>
											<div class="copy-url-text">
												<span id="authorized_uri"><?php echo esc_html(admin_url('admin.php?page=wpsyncsheets-for-contact-form-7')); ?></span>
												<span class="copy-icon wpsslc-button tooltip-click1" onclick="wpsslcCopy('authorized_uri','a_uri');" id="a_uri">
													<svg width="15" height="18" viewBox="0 0 15 18" fill="none" xmlns="http://www.w3.org/2000/svg">
													<path d="M2.16667 17.3334C1.70833 17.3334 1.31597 17.1702 0.989583 16.8438C0.663194 16.5174 0.5 16.1251 0.5 15.6667V4.00008H2.16667V15.6667H11.3333V17.3334H2.16667ZM5.5 14.0001C5.04167 14.0001 4.64931 13.8369 4.32292 13.5105C3.99653 13.1841 3.83333 12.7917 3.83333 12.3334V2.33341C3.83333 1.87508 3.99653 1.48272 4.32292 1.15633C4.64931 0.829942 5.04167 0.666748 5.5 0.666748H13C13.4583 0.666748 13.8507 0.829942 14.1771 1.15633C14.5035 1.48272 14.6667 1.87508 14.6667 2.33341V12.3334C14.6667 12.7917 14.5035 13.1841 14.1771 13.5105C13.8507 13.8369 13.4583 14.0001 13 14.0001H5.5ZM5.5 12.3334H13V2.33341H5.5V12.3334Z" fill="#383E46"/>
													</svg>
													<span class="tooltip-text">Copied</span>
												</span>
											</div>
										</li>
									</ul>
								</div>
							</div>
						</form>
						<?php
		}?>
					</div>
				</div>
				<div id="wpssc-nav-forms" class="navtabcontent" 
					<?php
		if ('forms' !== $show_tab) {
			echo "style='display:none;'";
		}
		else {
			echo "style='display:block;'";
		}
?>
					>
					<div id="forms-settings" class="forms-settings">
						<?php
		require_once plugin_dir_path(__FILE__) . 'entry/class-wpsslc-forms-page.php';
?>
					</div>
				</div>

					<!-- Free Vs Pro html start   -->
				<div id="wpsslc-nav-freevspro" class="navtabcontent vertical-tabs">
					<div class="wpsslc-navtabcontent">
								<!-- Header Section -->
								<div class="free-pro-header">
									<div class="free-pro-data">
										<div class="free-pro-title">
											<span>Free vs Pro</span>
										</div>
										<p>
											Compare the features to find the best option for your website.
										</p>
									</div>
									<div class="unlock-pro-button-section">
										<a class="underline" href="<?php echo esc_url(WPSSLC_PRO_VERSION_BUY_URL); ?>" target="_blank" rel="noreferrer">
											Upgrade Now
										</a>
									</div>
								</div>

								<!-- Comparison Table -->
								<div class="pro-free-features">
										<!-- Table Header Row -->
										<div class="dynamic-content">
											<p>General  Features</p>
											<div class="free-title">
												<p>Free</p>
												<p>Pro</p>
											</div>
										</div>

										<!-- Feature: Automatically Create New Google Spreadsheet -->
									<div class="feature-data">
										<p>Automatically Create New Google Spreadsheet</p>
											<div class="feature-icon">
												<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#16A34A" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check">
												<path d="M20 6 9 17l-5-5"></path>
												</svg>

												<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#16A34A" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check">
												<path d="M20 6 9 17l-5-5"></path>
												</svg>
											</div>
									</div>

									<!-- Feature: Automatcailly Create New Google Sheets -->
									<div class="feature-data">
										<p>Automatcailly Create New Google Sheets</p>
											<div class="feature-icon">
												<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#16A34A" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check">
												<path d="M20 6 9 17l-5-5"></path>
												</svg>

												<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#16A34A" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check">
												<path d="M20 6 9 17l-5-5"></path>
												</svg>
											</div>
									</div>

									<!-- Feature: Download Excel & CSV -->
									<div class="feature-data">
										<p>Download Excel & CSV</p>
											<div class="feature-icon">
												<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#16A34A" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check">
												<path d="M20 6 9 17l-5-5"></path>
												</svg>

												<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#16A34A" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check">
												<path d="M20 6 9 17l-5-5"></path>
												</svg>
											</div>
									</div>

									<!-- Feature: Automatically Clear Google Spreadsheet -->
									<div class="feature-data">
										<p>Automatically Clear Google Spreadsheet</p>
											<div class="feature-icon">
												<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#16A34A" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check">
												<path d="M20 6 9 17l-5-5"></path>
												</svg>

												<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#16A34A" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check">
												<path d="M20 6 9 17l-5-5"></path>
												</svg>
											</div>
									</div>

									<!-- Feature: Freeze Headers (First Row of the Google Spreadsheet) -->
									<div class="feature-data">
										<p>Freeze Headers (First Row of the Google Spreadsheet)</p>
											<div class="feature-icon">
												<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#16A34A" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check">
												<path d="M20 6 9 17l-5-5"></path>
												</svg>

												<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#16A34A" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check">
												<path d="M20 6 9 17l-5-5"></path>
												</svg>
											</div>
									</div>

									<!-- Feature: Automatic Field Mapping -->
									<div class="feature-data">
										<p>Automatic Field Mapping</p>
											<div class="feature-icon">
												<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#16A34A" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check">
												<path d="M20 6 9 17l-5-5"></path>
												</svg>

												<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#16A34A" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check">
												<path d="M20 6 9 17l-5-5"></path>
												</svg>
											</div>
									</div>

									<!-- Feature: Enable/Disable Sheet Headers -->
									<div class="feature-data">
										<p>Enable/Disable Sheet Headers</p>
											<div class="feature-icon">
												<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#16A34A" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check">
												<path d="M20 6 9 17l-5-5"></path>
												</svg>

												<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#16A34A" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check">
												<path d="M20 6 9 17l-5-5"></path>
												</svg>
											</div>
									</div>

									<!-- Feature: Support multiple forms to sheets -->
									<div class="feature-data">
										<p>Support Multiple Forms to Sheets</p>
											<div class="feature-icon">
												<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#16A34A" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check">
												<path d="M20 6 9 17l-5-5"></path>
												</svg>

												<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#16A34A" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check">
												<path d="M20 6 9 17l-5-5"></path>
												</svg>
											</div>
									</div>

									<!-- Feature: Submission Date & Time -->
									<div class="feature-data">
										<p>Submission Date & Time</p>
											<div class="feature-icon">
												<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#16A34A" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check">
												<path d="M20 6 9 17l-5-5"></path>
												</svg>

												<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#16A34A" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check">
												<path d="M20 6 9 17l-5-5"></path>
												</svg>
											</div>
									</div>

									<!-- Feature: Reorder Sheet Headers (Spreadsheet Columns) -->
									<div class="feature-data">
										<p>Reorder Sheet Headers (Spreadsheet Columns)</p>
											<div class="feature-icon">
												<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#DC2626" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-x">
												<path d="M18 6 6 18"></path>
												<path d="m6 6 12 12"></path>
												</svg>

												<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#16A34A" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check">
												<path d="M20 6 9 17l-5-5"></path>
												</svg>
											</div>
									</div>

									<!-- Feature: Update Sheet Headers Name (Spreadsheet Columns) -->
									<div class="feature-data">
										<p>Update Sheet Headers Name (Spreadsheet Columns)</p>
											<div class="feature-icon">
												<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#DC2626" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-x">
												<path d="M18 6 6 18"></path>
												<path d="m6 6 12 12"></path>
												</svg>

												<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#16A34A" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check">
												<path d="M20 6 9 17l-5-5"></path>
												</svg>
											</div>
									</div>

									<!-- Feature: Row Input Format Option -->
									<div class="feature-data">
										<p>Row Input Format Option</p>
											<div class="feature-icon">
												<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#DC2626" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-x">
												<path d="M18 6 6 18"></path>
												<path d="m6 6 12 12"></path>
												</svg>

												<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#16A34A" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check">
												<path d="M20 6 9 17l-5-5"></path>
												</svg>
											</div>
									</div>

					            </div>
				    </div>
				</div>

				<?php

		if (!empty($wpsslc_error) || !empty($wpsslc_error_general) || !\WPSSLC_Dependencies::wpsslc_is_contact_form_7_plugin_active()) {
			$error_msg = '';
			if (!\WPSSLC_Dependencies::wpsslc_is_contact_form_7_plugin_active()) {
				$error_msg = 'WPSyncSheets Lite For Contact Form 7 plugin requires <a href="' . esc_url('https://wordpress.org/plugins/contact-form-7/') . '" target= "_blank">Contact Form 7</a> plugin to be active!';
?>
					<input type="hidden" id="error-message" value="<?php echo esc_attr($error_msg); ?>">
						<?php
			}
			else {
				if (!empty($wpsslc_error_general)) {
					$error_msg = wp_strip_all_tags($wpsslc_error_general);
				}
				else {
					$error_msg = wp_strip_all_tags($wpsslc_error);
				}
				if ($error_msg) {
?>
						<input type="hidden" id="error-message" value="<?php echo esc_attr($error_msg); ?>">
							<?php
				}
			}
?>
				<?php
		}
		elseif (isset($_POST['submit'])) { ?>
				<input type="hidden" id="success-message" value="Settings are saved successfully.">
					<?php
		}
		$token_error_val = 0;
		if ($wpsslc_token_error) {
			$token_error_val = 1;
		}
?>
				<input type="hidden" id="token-error" value="<?php echo esc_attr($token_error_val); ?>">
				<script type="text/javascript">
					jQuery.noConflict();
					jQuery(".wpsslc-header-section .whatsNew-toggle, .wpsslc-header-section .close-block").click(function(){
						jQuery(".wpsslc-header-section .wpsslc-header-right").toggleClass('active');
						jQuery(".wpsslc-header-section .whatsNew-toggle").toggleClass('active');
					});
				</script>
                <div class="clear"></div>
			</div>
			<div class="clear"></div>

			<!-- Unlock Pro Features -->
			<div class="wpsslc-tabs-main wpsslc-pro-main">
				<div class="upgrade-pro-navtabcontent">
					<div class="wpsslc-navtabcontent">
						<div class="generalSetting-section">
							<div class="box-border">
								<div class="unlock-pro-content">
									<div class="unlock-pro-title">
										<svg width="64" height="56" viewBox="0 0 64 56" fill="none" xmlns="http://www.w3.org/2000/svg">
											<path d="M20.9521 4.49219C26.2038 1.9958 32.146 1.35206 37.8105 2.66504C43.4752 3.97804 48.5287 7.17034 52.1465 11.7227C55.3478 15.7509 57.2568 20.6337 57.6543 25.7334H54.2324C53.8432 21.4057 52.198 17.2692 49.4766 13.8447C46.3383 9.89585 41.9548 7.12637 37.041 5.9873C32.1271 4.84831 26.9717 5.40664 22.416 7.57227C20.0832 8.68124 17.6708 10.5132 15.5957 12.5684C14.1879 13.9626 12.8819 15.5127 11.833 17.0889L9.59082 15.082C12.1905 10.477 16.1542 6.77301 20.9521 4.49219Z" fill="#4169E1" stroke="#4169E1" stroke-width="4"/>
											<path d="M9.48975 29.7333C9.8653 33.9608 11.4252 38.012 14.0103 41.412C17.0007 45.3451 21.1975 48.1897 25.9585 49.5106C30.7195 50.8315 35.7822 50.5565 40.3716 48.7264C42.7389 47.7824 45.2135 46.1131 47.3716 44.2225C48.8135 42.9593 50.1674 41.5489 51.2935 40.1122L53.2524 42.2411C50.3731 46.4591 46.2973 49.7365 41.5327 51.6366C36.307 53.7205 30.5417 54.0342 25.1206 52.5302C19.6996 51.0261 14.9211 47.7867 11.5161 43.3085C8.51618 39.3629 6.72919 34.6468 6.34619 29.7333H9.48975Z" fill="#4169E1" stroke="#4169E1" stroke-width="4"/>
											<path d="M47.0158 27.1168L55.4635 36.9778L64.0003 27.0222H58.6144H52.6613H46.9336L47.0158 27.1168Z" fill="#4169E1"/>
											<path d="M16.9846 31.1943L8.53702 21.3333L0.000234604 31.2888L5.38608 31.2888L11.3392 31.2888L17.0669 31.2888L16.9846 31.1943Z" fill="#4169E1"/>
										</svg>
										<span>Unlock Pro Features</span>
                                    </div>
									<h1>Supercharge Your Data Sync With WPSyncSheets Pro!</h1>
								</div>
									<p class="text">Sync Contact Form 7 data with Google Sheets in real-time — effortlessly and accurately.</p>
							
                                <ul class="pro-features-content">
									<li>
										<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check text-brand-primary-600">
										<path d="M20 6 9 17l-5-5"></path></svg><span>Reorder Sheet Headers (Spreadsheet Columns)</span>
									</li>
									<li>
										<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check text-brand-primary-600">
										<path d="M20 6 9 17l-5-5"></path></svg><span>Update Sheet Headers Name (Spreadsheet Columns)</span>
									</li>
									<li>
										<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check text-brand-primary-600">
										<path d="M20 6 9 17l-5-5"></path></svg><span>Row Input Format Option</span>
									</li>
									<li>
										<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check text-brand-primary-600">
										<path d="M20 6 9 17l-5-5"></path></svg><span>And More…</span>
									</li>
								</ul>

								<div class="unlock-pro-button-section">
									<a class="underline" href="<?php echo esc_url(WPSSLC_PRO_VERSION_BUY_URL); ?>" target="_blank" rel="noreferrer">
									    Upgrade Now
								    </a>
									<a class="no-underline" href="javascript:void(0)" onclick="wpsslcNavTabfreevspro(event, 'wpsslc-nav-freevspro')">
									    Free vs Pro
								    </a>
								</div>
							</div>
	
							<div class="pro-feature-img">
								<img src="<?php echo esc_url(WPSSLC_URL . 'assets/css/images/pro.png'); ?>" />
							</div>
						</div>	
					</div>
				</div>
			</div>
			
		</div>
		<?php
	}
	/**
	 * Get changelog.
	 *
	 * @param string $plugin_path plugin path.
	 */
	public static function wpsslc_get_plugin_changelog($plugin_path)
	{
		// Path to the readme.txt file.
		$readme_file = $plugin_path . '/readme.txt';

		// Check if the file exists.
		if (!file_exists($readme_file)) {
			return '';
		}

		// phpcs:ignore
		$content = file_get_contents($readme_file); // Read the file content.

		if (!$content || is_wp_error($content)) {
			return '';
		}

		// Regular expression to extract the Changelog section.
		$pattern = '/==\s*Changelog\s*==\s*(.*?)(==|$)/is';

		// Match the pattern.
		if (preg_match($pattern, $content, $matches)) {
			// Extracted Changelog section.
			$changelog_content = trim($matches[1]);

			// Regular expression to parse individual versions.
			$version_pattern = '/=+\s*(\d+(?:\.\d+)+\s*(\(.+?\))?)\s*=+\s*(.*?)(?==+\s*\d+(?:\.\d+)+\s*(\(.+?\))?\s*=+|$)/is';
			preg_match_all($version_pattern, $changelog_content, $version_matches, PREG_SET_ORDER);

			$html_output = '';



			foreach ($version_matches as $version_match) {
				$version = $version_match[1];
				$changes = trim($version_match[3]);

				// Convert changes to list items.
				$change_items = preg_split('/\r\n|\r|\n/', $changes);
				$change_items = array_filter(array_map('trim', $change_items));

				$html_output .= "<h5><strong>Version $version</strong></h5>\n<ol>\n";

				foreach ($change_items as $item) {
					// Remove leading '*' and trim the item.
					$item = ltrim($item, '* ');
					if (!empty($item)) {
						$html_output .= '<li>' . htmlspecialchars($item) . "</li>\n";
					}
				}

				$html_output .= "</ol>\n<hr class=\"wp-block-separator has-css-opacity\">\n";
			}

			// Remove any unintended <br> tags.
			return str_replace(array('<br>', '<br/>', '<br />'), '', $html_output);
		}
		else {
			return '';
		}
	}

	/**
	 * Handles AJAX request to install and activate a WordPress.org plugin.
	 */
	public static function wpsslc_install_and_activate_plugin()
	{

		if (!current_user_can('install_plugins')) {
			wp_send_json_error('Permission denied.');
		}

		check_ajax_referer('wpssc_install_plugin_nonce', 'nonce');

		$plugin_slug = isset($_POST['plugin_slug']) ? sanitize_text_field(wp_unslash($_POST['plugin_slug'])) : '';

		if (empty($plugin_slug)) {
			wp_send_json_error('Plugin slug missing.');
		}

		include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
		include_once ABSPATH . 'wp-admin/includes/plugin.php';
		include_once ABSPATH . 'wp-admin/includes/file.php';
		include_once ABSPATH . 'wp-admin/includes/misc.php';
		include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader-skin.php';

		if (!isset($_POST['plugin_active']) || sanitize_text_field(wp_unslash($_POST['plugin_active'])) !== 'true') {
			$upgrader = new Plugin_Upgrader(new Plugin_Installer_Skin());
			$result = $upgrader->install("https://downloads.wordpress.org/plugin/{$plugin_slug}.latest-stable.zip");

			if (is_wp_error($result)) {
				wp_send_json_error('Plugin installation failed: ' . $result->get_error_message());
			}
		}
		// You might need to dynamically get the correct plugin file.
		$plugins = get_plugins("/{$plugin_slug}");
		if (empty($plugins)) {
			wp_send_json_error('Could not find installed plugin.');
		}

		// Get the first plugin file found
		$plugin_file = key($plugins);

		$activation = activate_plugin("{$plugin_slug}/{$plugin_file}");

		if (is_wp_error($activation)) {
			wp_send_json_error('Activation failed: ' . $activation->get_error_message());
		}

		wp_send_json_success('Plugin installed and activated successfully!');
	}
}
new WPSSLC_Plugin_Settings();