<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit; }
/*
	Works in the background: yes
	Pro version scans the entire website: yes
	Sends email reminders: yes
	Finds place holder text: yes
	Custom Dictionary for unusual words: yes
	Scans Password Protected membership Sites: yes
	Unlimited scans on my website: Yes





	Scans Categories: Yes WP Spell Check Pro
	Scans SEO Titles: Yes WP Spell Check Pro
	Scans SEO Descriptions: Yes WP Spell Check Pro
	Scans WordPress Menus: Yes WP Spell Check Pro
	Scans Page Titles: Yes WP Spell Check Pro
	Scans Post Titles: Yes WP Spell Check Pro
	Scans Page slugs: Yes WP Spell Check Pro
	Scans Post Slugs: Yes WP Spell Check Pro
	Scans Post categories: Yes WP Spell Check Pro

	Privacy URI: https://www.wpspellcheck.com/privacy-policy/
	Pro Add-on / Home Page: https://www.wpspellcheck.com/
	Pro Add-on / Prices: https://www.wpspellcheck.com/pricing/
*/
	const WPSCX_PRO_LOC  = 'wp-spell-check-pro/wpspellcheckpro.php';
	const WPSCX_SETTINGS = '[wpsc_settings]';
	const WPSCX_GRAMMAR  = '[wpsc_grammar]';
	const WPSCX_DICT     = '[wpsc_dictionary]';
	const WPSCX_IGNORE   = '[wpsc_ignore]';

class Wpscx_Options {

	/* Clear out the database for uninstallation */
	function prepare_uninstall() {
		// This function is now deprecated - cleanup moved to uninstall.php
		// Kept for backward compatibility with existing network uninstall page

		// Call the new uninstall process
		if ( file_exists( plugin_dir_path( __DIR__ ) . 'uninstall.php' ) ) {
			define( 'WP_UNINSTALL_PLUGIN', 'wp-spell-check/wpspellcheck.php' );
			include_once plugin_dir_path( __DIR__ ) . 'uninstall.php';
		}
	}
}

/**
 * Enqueue styles early for options page to prevent FOUC
 *
 * @since 9.22
 */
function wpscx_enqueue_options_styles() {
	global $wpsc_version;
	$screen = get_current_screen();
	if ( $screen && ( 'wp-spellcheck-options' === $screen->id || ( isset( $_GET['page'] ) && 'wp-spellcheck-options.php' === $_GET['page'] ) ) ) {
		wp_enqueue_style( 'wpsc-admin-styles', plugin_dir_url( __DIR__ ) . 'css/admin-styles.css', array(), $wpsc_version, 'all' );
		wp_enqueue_style( 'wpsc-sidebar', plugin_dir_url( __DIR__ ) . 'css/wpsc-sidebar.css', array(), $wpsc_version, 'all' );
		wp_enqueue_style( 'wpsc-sidebar-inline', plugin_dir_url( __DIR__ ) . 'admin/css/sidebar-inline.css', array( 'wpsc-sidebar' ), $wpsc_version, 'all' );
	}
}
add_action( 'admin_enqueue_scripts', 'wpscx_enqueue_options_styles', 5 );

function wpscx_render_options() {
	global $wpdb;
	global $wpscx_ent_included;
	global $wpscx_key_valid;
	global $wpsc_version;
	$options       = new Wpscx_Options();
	$table_name    = $wpdb->prefix . 'spellcheck_options';
	$ignore_table  = $wpdb->prefix . 'spellcheck_ignore';
	$grammar_table = $wpdb->prefix . 'spellcheck_grammar_options';
	$dict_table    = $wpdb->prefix . 'spellcheck_dictionary';
	$words_table   = $wpdb->prefix . 'spellcheck_words';
	ini_set( 'memory_limit', '512M' ); // Sets the PHP memory limit

	wp_enqueue_script( 'jquery-ui-dialog' );
	// wp_enqueue_script( 'admin-js', plugin_dir_url( __FILE__ ) . '../js/feature-request.js' );
	wp_enqueue_script( 'feature-request', plugin_dir_url( __FILE__ ) . '../js/admin-js.js' );
	wp_enqueue_script( 'wpscx-jquery-contextMenu', plugin_dir_url( __FILE__ ) . '../js/wpscx-jquery.contextMenu.js' );
	wp_enqueue_script( 'wpscx-jquery-ui-position', plugin_dir_url( __FILE__ ) . '../js/wpscx-jquery.ui.position.js' );
	wp_enqueue_style( 'wpsc-admin-styles', plugin_dir_url( __DIR__ ) . 'css/admin-styles.css', array(), $wpsc_version, 'all' );
	wp_enqueue_style( 'wpsc-sidebar', plugin_dir_url( __DIR__ ) . 'css/wpsc-sidebar.css' );
	wp_enqueue_style( 'wpsc-sidebar-inline', plugin_dir_url( __DIR__ ) . 'admin/css/sidebar-inline.css', array( 'wpsc-sidebar' ) );

	$message = '';
	if ( isset( $_POST['uninstall'] ) && 'Clean up Database and Deactivate Plugin' === $_POST['uninstall'] ) {
		if ( ! current_user_can( 'manage_options' ) ) {
			wp_die( 'You do not have permission to uninstall the plugin.', 403 );
		}
		// phpcs:ignore WordPress.Security.NonceVerification.Missing -- Nonce verified on next line
		$nonce_received        = isset( $_POST['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) ) : '';
		$nonce_valid_result    = wp_verify_nonce( $nonce_received, 'wpsc_update_options' );
		$http_referer          = isset( $_SERVER['HTTP_REFERER'] ) ? esc_url_raw( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '';
		$post_referer          = isset( $_POST['_wp_http_referer'] ) ? esc_url_raw( wp_unslash( $_POST['_wp_http_referer'] ) ) : '';
		$admin_url_val         = admin_url();
		$wp_get_referer_result = wp_get_referer();
		// Verify nonce - if it fails, check referer as fallback for stale nonces
		// This handles cases where browser caches the form HTML with an old nonce
		if ( ! $nonce_valid_result ) {
			// Nonce failed - check if referer is valid as security fallback
			// Use HTTP_REFERER header directly since wp_get_referer() may return false
			$referer = $http_referer ? $http_referer : $post_referer;

			// Handle relative URLs in POST referer by converting to absolute
			if ( $referer && ! preg_match( '/^https?:\/\//', $referer ) ) {
				// Relative URL - convert to absolute using admin_url()
				$referer = admin_url( $referer );
			}

			// Use strpos for PHP 7.x compatibility instead of str_starts_with (PHP 8.0+)
			$admin_url_lower = strtolower( $admin_url_val );
			$referer_lower   = $referer ? strtolower( $referer ) : '';
			$referer_valid   = $referer && ( strpos( $referer_lower, $admin_url_lower ) === 0 );

			if ( ! $referer_valid ) {
				// Both nonce and referer failed - this is a security issue
				wp_die( 'The link you followed has expired. Please try again.' );
			}

			// Referer is valid - allow the request
			// This handles stale nonces from browser cache while maintaining security via referer check
		}
		$options->prepare_uninstall();
		deactivate_plugins( 'wp-spell-check/wpspellcheck.php' );
		if ( $wpscx_ent_included ) {
			deactivate_plugins( WPSCX_PRO_LOC );
		}
		wp_die( 'WP Spell Check has been deactivated. If you wish to use the plugin again you may activate it on the <a href="' . esc_url( admin_url( 'plugins.php' ) ) . '">WordPress plugin page</a>.' );
	}

	$next_scan = wp_next_scheduled( 'admincheckcode', array( 10, 1 ) );
	wp_unschedule_event( $next_scan, 'admincheckcode', array( 10, 1 ) );

	if ( isset( $_POST['import'] ) && isset( $_FILES['import_file']['name'] ) && $wpscx_ent_included ) {
		if ( ! current_user_can( 'manage_options' ) ) {
			wp_die( 'You do not have permission to import plugin data.', 403 );
		}
		$nonce_received        = isset( $_POST['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) ) : '';
		$nonce_valid_result    = wp_verify_nonce( $nonce_received, 'wpsc_update_options' );
		$http_referer          = isset( $_SERVER['HTTP_REFERER'] ) ? esc_url_raw( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '';
		$post_referer          = isset( $_POST['_wp_http_referer'] ) ? esc_url_raw( wp_unslash( $_POST['_wp_http_referer'] ) ) : '';
		$admin_url_val         = admin_url();
		$wp_get_referer_result = wp_get_referer();
		// Verify nonce - if it fails, check referer as fallback for stale nonces
		// This handles cases where browser caches the form HTML with an old nonce
		if ( ! $nonce_valid_result ) {
			// Nonce failed - check if referer is valid as security fallback
			// Use HTTP_REFERER header directly since wp_get_referer() may return false
			$referer = $http_referer ? $http_referer : $post_referer;

			// Handle relative URLs in POST referer by converting to absolute
			if ( $referer && ! preg_match( '/^https?:\/\//', $referer ) ) {
				// Relative URL - convert to absolute using admin_url()
				$referer = admin_url( $referer );
			}

			// Use strpos for PHP 7.x compatibility instead of str_starts_with (PHP 8.0+)
			$admin_url_lower = strtolower( $admin_url_val );
			$referer_lower   = $referer ? strtolower( $referer ) : '';
			$referer_valid   = $referer && ( strpos( $referer_lower, $admin_url_lower ) === 0 );

			if ( ! $referer_valid ) {
				// Both nonce and referer failed - this is a security issue
				wp_die( 'The link you followed has expired. Please try again.' );
			}

			// Referer is valid - allow the request
			// This handles stale nonces from browser cache while maintaining security via referer check
		}
		if ( 'Import Plugin Data' === $_POST['import'] ) {
			$extension = end( explode( '.', sanitize_text_field( $_FILES['import_file']['name'] ) ) );
			if ( 'ini' !== $extension ) {
				// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Output is safe: hardcoded translation string
				wp_die( __( 'Please Upload a valid .ini file', 'wp-spell-check' ) ); // Check to make sure the imported file is a .ini file
			}

			$import_file = sanitize_text_field( $_FILES['import_file']['tmp_name'] );
			if ( empty( $import_file ) ) {
				// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Output is safe: hardcoded translation string
				wp_die( __( 'Please upload a file with content. Last file has no content', 'wp-spell-check' ) ); // Check to make sure that the imported file isn't empty
			}

			$input = file_get_contents( $import_file ); // Get the contents of the uploaded file

			$content = explode( "\r\n", $input );

			$to_add           = '[none]';
			$dict_dupe        = "<h3 style='color: rgb(200, 0, 0);'> The following words were not added to My Dictionary because they were a duplicate:";
			$dict_dupe_ig     = "<h3 style='color: rgb(200, 0, 0);'> The following words were not added to My Dictionary because they were found in the Ignore List:";
			$ignore_dupe      = "<h3 style='color: rgb(200, 0, 0);'> The following words were not added to Ignore List because they were a duplicate:";
			$ignore_dupe_dict = "<h3 style='color: rgb(200, 0, 0);'> The following words were not added to Ignore List because they were found in My Dictionary:";

			$dict_display        = false;
			$dict_display_ig     = false;
			$ignore_display      = false;
			$ignore_display_dict = false;

			foreach ( $content as $item ) {
				if ( '' === $item ) {
					continue;
				}
				if ( WPSCX_SETTINGS === $item ) {
					$to_add = WPSCX_SETTINGS;
				}
				if ( WPSCX_GRAMMAR === $item ) {
					$to_add = WPSCX_GRAMMAR;
				}
				if ( WPSCX_DICT === $item ) {
					$to_add = WPSCX_DICT;
				}
				if ( WPSCX_IGNORE === $item ) {
					$to_add = WPSCX_IGNORE;
				}
					// Check for the headers of each section and set flag accordingly

				if ( WPSCX_SETTINGS === $to_add && WPSCX_SETTINGS !== $item ) {
						$settings = explode( '=', $item );
					if ( sizeof( (array) $settings ) === 2 ) {
						$wpdb->update( $table_name, array( 'option_value' => $settings[1] ), array( 'option_name' => $settings[0] ) ); // Update the main settings table
					}
				} elseif ( WPSCX_GRAMMAR === $to_add && WPSCX_GRAMMAR !== $item ) {
						$settings = explode( '=', $item );
					if ( sizeof( (array) $settings ) === 2 ) {
						$wpdb->update( $grammar_table, array( 'option_value' => $settings[1] ), array( 'option_name' => $settings[0] ) ); // Update the grammar settings table
					}
				} elseif ( WPSCX_DICT === $to_add && WPSCX_DICT !== $item ) {
					// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Table names are safe
					$check_dict = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM ' . $dict_table . ' WHERE word=%s', $item ) );
					// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Table names are safe
					$check_ignore = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM ' . $words_table . ' WHERE word=%s AND ignore_word = true', $item ) );

					if ( sizeof( (array) $check_dict ) > 0 ) {
							$dict_display = true;
							$dict_dupe   .= ' ' . $item . ',';
					} elseif ( sizeof( (array) $check_ignore ) > 0 ) {
						$dict_display_ig = true;
						$dict_dupe_ig   .= ' ' . $item . ',';
					} else {
						$wpdb->insert( $dict_table, array( 'word' => $item ) ); // Update the dictionary table
					}
				} elseif ( WPSCX_IGNORE === $to_add && WPSCX_IGNORE !== $item ) {
					// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Table names are safe
					$check_dict = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM ' . $dict_table . ' WHERE word=%s', $item ) );
					// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Table names are safe
					$check_ignore = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM ' . $words_table . ' WHERE word=%s AND ignore_word = true', $item ) );

					if ( sizeof( (array) $check_dict ) > 0 ) {
							$ignore_display_dict = true;
							$ignore_dupe_dict   .= ' ' . $item . ',';
					} elseif ( sizeof( (array) $check_ignore ) > 0 ) {
						$ignore_display = true;
						$ignore_dupe   .= ' ' . $item . ',';
					} else {
						$wpdb->insert(
							$words_table,
							array(
								'word'        => $item,
								'page_name'   => 'WPSC_Ignore',
								'ignore_word' => true,
								'page_type'   => 'wpsc_ignore',
							)
						); // Update the ignore table
					}
				}
			}
		}

			$dict_dupe        = trim( $dict_dupe, ',' );
			$dict_dupe_ig     = trim( $dict_dupe_ig, ',' );
			$ignore_dupe      = trim( $ignore_dupe, ',' );
			$ignore_dupe_dict = trim( $ignore_dupe_dict, ',' );

			$dict_dupe        .= '</h3>';
			$dict_dupe_ig     .= '</h3>';
			$ignore_dupe      .= '</h3>';
			$ignore_dupe_dict .= '</h3>';

		if ( $dict_display ) {
			echo 'True';
		}

			$message = '<h3>Plugin data has been successfully imported</h3>';

		if ( true === $dict_display ) {
			$message .= $dict_dupe;
		}
		if ( true === $dict_display_ig ) {
			$message .= $dict_dupe_ig;
		}
		if ( true === $ignore_display ) {
			$message .= $ignore_dupe;
		}
		if ( true === $ignore_display_dict ) {
			$message .= $ignore_dupe_dict;
		}
	}

	// set defaults for anything not already set

	if ( ! isset( $_POST['email'] ) ) {
		$_POST['email'] = '';
	}
	if ( ! isset( $_POST['ignore-caps'] ) ) {
		$_POST['ignore-caps'] = '';
	}
	if ( ! isset( $_POST['check-pages'] ) ) {
		$_POST['check-pages'] = '';
	}
	if ( ! isset( $_POST['check-posts'] ) ) {
		$_POST['check-posts'] = '';
	}
	if ( ! isset( $_POST['check-authors'] ) ) {
		$_POST['check-authors'] = '';
	}
	if ( ! isset( $_POST['check-sliders'] ) ) {
		$_POST['check-sliders'] = '';
	}
	if ( ! isset( $_POST['check-media'] ) ) {
		$_POST['check-media'] = '';
	}
	if ( ! isset( $_POST['check-menu'] ) ) {
		$_POST['check-menus'] = '';
	}
	if ( ! isset( $_POST['page-titles'] ) ) {
		$_POST['page-titles'] = '';
	}
	if ( ! isset( $_POST['post-titles'] ) ) {
		$_POST['post-titles'] = '';
	}
	if ( ! isset( $_POST['tags'] ) ) {
		$_POST['tags'] = '';
	}
	if ( ! isset( $_POST['check-tag-desc'] ) ) {
		$_POST['check-tag-desc'] = '';
	}
	if ( ! isset( $_POST['check-tag-slug'] ) ) {
		$_POST['check-tag-slug'] = '';
	}
	if ( ! isset( $_POST['categories'] ) ) {
		$_POST['categories'] = '';
	}
	if ( ! isset( $_POST['check-cat-desc'] ) ) {
		$_POST['check-cat-desc'] = '';
	}
	if ( ! isset( $_POST['check-cat-slug'] ) ) {
		$_POST['check-cat-slug'] = '';
	}
	if ( ! isset( $_POST['seo-titles'] ) ) {
		$_POST['seo-titles'] = '';
	}
	if ( ! isset( $_POST['seo-desc'] ) ) {
		$_POST['seo-desc'] = '';
	}
	if ( ! isset( $_POST['page-slugs'] ) ) {
		$_POST['page-slugs'] = '';
	}
	if ( ! isset( $_POST['post-slugs'] ) ) {
		$_POST['post-slugs'] = '';
	}
	if ( ! isset( $_POST['check-ecommerce'] ) ) {
		$_POST['check-ecommerce'] = '';
	}
	if ( ! isset( $_POST['check-custom'] ) ) {
		$_POST['check-custom'] = '';
	}
	if ( ! isset( $_POST['ignore-emails'] ) ) {
		$_POST['ignore-emails'] = '';
	}
	if ( ! isset( $_POST['ignore-websites'] ) ) {
		$_POST['ignore-websites'] = '';
	}
	if ( ! isset( $_POST['highlight-words'] ) ) {
		$_POST['highlight-words'] = '';
	}
	if ( ! isset( $_POST['check-cf7'] ) ) {
		$_POST['check-cf7'] = '';
	}
	if ( ! isset( $_POST['check-post-drafts'] ) ) {
		$_POST['check-post-drafts'] = '';
	}
	if ( ! isset( $_POST['check-page-drafts'] ) ) {
		$_POST['check-page-drafts'] = '';
	}
	if ( ! isset( $_POST['check-authors-empty'] ) ) {
		$_POST['check-authors-empty'] = '';
	}
	if ( ! isset( $_POST['check-page-titles-empty'] ) ) {
		$_POST['check-page-titles-empty'] = '';
	}
	if ( ! isset( $_POST['check-post-titles-empty'] ) ) {
		$_POST['check-post-titles-empty'] = '';
	}
	if ( ! isset( $_POST['check-menu-empty'] ) ) {
		$_POST['check-menu-empty'] = '';
	}
	if ( ! isset( $_POST['check-tag-desc-empty'] ) ) {
		$_POST['check-tag-desc-empty'] = '';
	}
	if ( ! isset( $_POST['check-cat-desc-empty'] ) ) {
		$_POST['check-cat-desc-empty'] = '';
	}
	if ( ! isset( $_POST['check-page-seo-empty'] ) ) {
		$_POST['check-page-seo-empty'] = '';
	}
	if ( ! isset( $_POST['check-post-seo-empty'] ) ) {
		$_POST['check-post-seo-empty'] = '';
	}
	if ( ! isset( $_POST['check-media-seo-empty'] ) ) {
		$_POST['check-media-seo-empty'] = '';
	}
	if ( ! isset( $_POST['check-ecommerce-empty'] ) ) {
		$_POST['check-ecommerce-empty'] = '';
	}
	if ( ! isset( $_POST['check-media-empty'] ) ) {
		$_POST['check-media-empty'] = '';
	}
	if ( ! isset( $_POST['check-pages-grammar'] ) ) {
		$_POST['check-pages-grammar'] = '';
	}
	if ( ! isset( $_POST['check-posts-grammar'] ) ) {
		$_POST['check-posts-grammar'] = '';
	}
	if ( ! isset( $_POST['check-widgets'] ) ) {
		$_POST['check-widgets'] = '';
	}
	if ( ! isset( $_POST['wpsc-scan-tab'] ) ) {
		$_POST['wpsc-scan-tab'] = '';
	} else {
		$_POST['wpsc-scan-tab'] = sanitize_text_field( wp_unslash( $_POST['wpsc-scan-tab'] ) );
	}
	if ( ! isset( $_POST['uninstall'] ) ) {
		$_POST['uninstall'] = '';
	}

	if ( isset( $_POST['submit'] ) && ( 'Update' === $_POST['submit'] || 'Send Test' === $_POST['submit'] ) ) {
		// Verify nonce - if it fails, check referer as fallback for stale nonces
		// This handles cases where browser caches the form HTML with an old nonce
		$nonce_received = isset( $_POST['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) ) : '';
		$nonce_valid    = wp_verify_nonce( $nonce_received, 'wpsc_update_options' );

		if ( ! $nonce_valid ) {
			// Nonce failed - check if referer is valid as security fallback
			// Use HTTP_REFERER header directly since wp_get_referer() may return false
			$http_referer_header = isset( $_SERVER['HTTP_REFERER'] ) ? esc_url_raw( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '';
			$post_referer        = isset( $_POST['_wp_http_referer'] ) ? esc_url_raw( wp_unslash( $_POST['_wp_http_referer'] ) ) : '';
			// Check both HTTP_REFERER header and POST _wp_http_referer field
			$referer = $http_referer_header ? $http_referer_header : $post_referer;

			// Use strpos for PHP 7.x compatibility instead of str_starts_with (PHP 8.0+)
			$admin_url_lower = strtolower( admin_url() );
			$referer_lower   = $referer ? strtolower( $referer ) : '';
			$referer_valid   = $referer && ( strpos( $referer_lower, $admin_url_lower ) === 0 );

			if ( ! $referer_valid ) {
				// Both nonce and referer failed - this is a security issue
				wp_die( 'The link you followed has expired. Please try again.' );
			}

			// Referer is valid - allow the request
			// This handles stale nonces from browser cache while maintaining security via referer check
		}

		$message = "<h3 style='color: rgb(0, 115, 0);'>Options Updated</h3>";
		if ( 'email' === $_POST['email'] ) {
			$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'email' ) );
		} else {
			$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'email' ) );
		}
		if ( isset( $_POST['email_address'] ) ) {
			$wpdb->update( $table_name, array( 'option_value' => sanitize_email( wp_unslash( $_POST['email_address'] ) ) ), array( 'option_name' => 'email_address' ) ); }
		if ( 'ignore-caps' === $_POST['ignore-caps'] ) {
			$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'ignore_caps' ) );
		} else {
			$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'ignore_caps' ) );
		}
		if ( 'check-pages' === $_POST['check-pages'] ) {
			$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'check_pages' ) );
		} else {
			$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'check_pages' ) );
		}
		if ( 'check-posts' === $_POST['check-posts'] ) {
			$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'check_posts' ) );
		} else {
			$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'check_posts' ) );
		}
		if ( 'check-authors' === $_POST['check-authors'] ) {
			$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'check_authors' ) );
		} else {
			$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'check_authors' ) );
		}
		if ( $wpscx_ent_included ) {
			if ( 'check-sliders' === $_POST['check-sliders'] ) {
				$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'check_sliders' ) );
			} else {
				$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'check_sliders' ) );
			}
			if ( 'check-media' === $_POST['check-media'] ) {
				$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'check_media' ) );
			} else {
				$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'check_media' ) );
			}

			if ( isset( $_POST['check-menu'] ) && 'check-menu' === $_POST['check-menu'] ) {
				$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'check_menus' ) );
			} else {
				$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'check_menus' ) );
			}
			if ( 'page-titles' === $_POST['page-titles'] ) {
				$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'page_titles' ) );
			} else {
				$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'page_titles' ) );
			}
			if ( 'post-titles' === $_POST['post-titles'] ) {
				$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'post_titles' ) );
			} else {
				$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'post_titles' ) );
			}
			if ( 'tags' === $_POST['tags'] ) {
				$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'tags' ) );
			} else {
				$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'tags' ) );
			}
			if ( 'check-tag-desc' === $_POST['check-tag-desc'] ) {
				$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'check_tag_desc' ) );
			} else {
				$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'check_tag_desc' ) );
			}
			if ( 'check-tag-slug' === $_POST['check-tag-slug'] ) {
				$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'check_tag_slug' ) );
			} else {
				$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'check_tag_slug' ) );
			}
			if ( 'categories' === $_POST['categories'] ) {
				$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'categories' ) );
			} else {
				$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'categories' ) );
			}
			if ( 'check-cat-desc' === $_POST['check-cat-desc'] ) {
				$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'check_cat_desc' ) );
			} else {
				$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'check_cat_desc' ) );
			}
			if ( 'check-cat-slug' === $_POST['check-cat-slug'] ) {
				$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'check_cat_slug' ) );
			} else {
				$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'check_cat_slug' ) );
			}
			if ( 'seo-titles' === $_POST['seo-titles'] ) {
				$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'seo_titles' ) );
			} else {
				$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'seo_titles' ) );
			}
			if ( 'seo-desc' === $_POST['seo-desc'] ) {
				$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'seo_desc' ) );
			} else {
				$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'seo_desc' ) );
			}
			if ( 'page-slugs' === $_POST['page-slugs'] ) {
				$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'page_slugs' ) );
			} else {
				$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'page_slugs' ) );
			}
			if ( 'post-slugs' === $_POST['post-slugs'] ) {
				$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'post_slugs' ) );
			} else {
				$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'post_slugs' ) );
			}
			if ( 'check-ecommerce' === $_POST['check-ecommerce'] ) {
				$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'check_ecommerce' ) );
			} else {
				$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'check_ecommerce' ) );
			}
			if ( 'check-widgets' === $_POST['check-widgets'] ) {
				$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'check_widgets' ) );
			} else {
				$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'check_widgets' ) );
			}
		}
		if ( 'check-custom' === $_POST['check-custom'] ) {
			$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'check_custom' ) );
		} else {
			$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'check_custom' ) );
		}
		if ( 'ignore-emails' === $_POST['ignore-emails'] ) {
			$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'ignore_emails' ) );
		} else {
			$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'ignore_emails' ) );
		}
		if ( 'ignore-websites' === $_POST['ignore-websites'] ) {
			$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'ignore_websites' ) );
		} else {
			$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'ignore_websites' ) );
		}
		if ( 'highlight-words' === $_POST['highlight-words'] ) {
			$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'highlight_word' ) );
		} else {
			$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'highlight_word' ) );
		}
		if ( 'check-cf7' === $_POST['check-cf7'] ) {
			$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'check_cf7' ) );
		} else {
			$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'check_cf7' ) );
		}

		if ( 'check-post-drafts' === $_POST['check-post-drafts'] ) {
			$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'scan_post_drafts' ) );
		} else {
			$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'scan_post_drafts' ) );
		}
		if ( 'check-page-drafts' === $_POST['check-page-drafts'] ) {
			$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'scan_page_drafts' ) );
		} else {
			$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'scan_page_drafts' ) );
		}
		if ( isset( $_POST['wpsc_admin_theme'] ) ) {
			$theme = sanitize_text_field( wp_unslash( $_POST['wpsc_admin_theme'] ) );
			if ( in_array( $theme, array( 'light', 'dark' ), true ) ) {
				$wpdb->update( $table_name, array( 'option_value' => $theme ), array( 'option_name' => 'wpsc_admin_theme' ) );
				if ( function_exists( 'wpsc_clear_admin_theme_cache' ) ) {
					wpsc_clear_admin_theme_cache();
				}
			}
		}

		if ( 'check-authors' === $_POST['check-authors-empty'] ) {
			$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'check_authors_empty' ) );
		} else {
			$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'check_authors_empty' ) );
		}
		if ( 'check-page-titles' === $_POST['check-page-titles-empty'] ) {
			$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'check_page_titles_empty' ) );
		} else {
			$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'check_page_titles_empty' ) );
		}
		if ( 'check-post-titles' === $_POST['check-post-titles-empty'] ) {
			$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'check_post_titles_empty' ) );
		} else {
			$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'check_post_titles_empty' ) );
		}
		if ( $wpscx_ent_included ) {
			if ( 'check-menu' === $_POST['check-menu-empty'] ) {
				$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'check_menu_empty' ) );
			} else {
				$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'check_menu_empty' ) );
			}
			if ( 'check-tag-desc' === $_POST['check-tag-desc-empty'] ) {
				$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'check_tag_desc_empty' ) );
			} else {
				$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'check_tag_desc_empty' ) );
			}
			if ( 'check-cat-desc' === $_POST['check-cat-desc-empty'] ) {
				$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'check_cat_desc_empty' ) );
			} else {
				$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'check_cat_desc_empty' ) );
			}
			if ( 'check-page-seo' === $_POST['check-page-seo-empty'] ) {
				$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'check_page_seo_empty' ) );
			} else {
				$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'check_page_seo_empty' ) );
			}
			if ( 'check-post-seo' === $_POST['check-post-seo-empty'] ) {
				$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'check_post_seo_empty' ) );
			} else {
				$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'check_post_seo_empty' ) );
			}
			if ( 'check-media-seo' === $_POST['check-media-seo-empty'] ) {
				$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'check_media_seo_empty' ) );
			} else {
				$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'check_media_seo_empty' ) );
			}
			if ( 'check-ecommerce' === $_POST['check-ecommerce-empty'] ) {
				$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'check_ecommerce_empty' ) );
			} else {
				$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'check_ecommerce_empty' ) );
			}
			if ( 'check-media' === $_POST['check-media-empty'] ) {
				$wpdb->update( $table_name, array( 'option_value' => 'true' ), array( 'option_name' => 'check_media_empty' ) );
			} else {
				$wpdb->update( $table_name, array( 'option_value' => 'false' ), array( 'option_name' => 'check_media_empty' ) );
			}
		}

		if ( 'check-pages' === $_POST['check-pages-grammar'] ) {
			$wpdb->update( $grammar_table, array( 'option_value' => 'true' ), array( 'option_name' => 'check_pages' ) );
		} else {
			$wpdb->update( $grammar_table, array( 'option_value' => 'false' ), array( 'option_name' => 'check_pages' ) );
		}
		if ( 'check-posts' === $_POST['check-posts-grammar'] ) {
			$wpdb->update( $grammar_table, array( 'option_value' => 'true' ), array( 'option_name' => 'check_posts' ) );
		} else {
			$wpdb->update( $grammar_table, array( 'option_value' => 'false' ), array( 'option_name' => 'check_posts' ) );
		}
		if ( $wpscx_ent_included ) {
			$scan_frequency = isset( $_POST['scan_frequency'] ) ? sanitize_text_field( wp_unslash( $_POST['scan_frequency'] ) ) : '';
			if ( is_numeric( $scan_frequency ) && $scan_frequency > 0 ) {
					wpscx_set_schedule();
			} else {
					$message = 'Please enter a valid number for scan frequency';
			}
		} else {
			$next_scan = wp_next_scheduled( 'adminscansite', array( 10 ) );
			wp_unschedule_event( $next_scan, 'adminscansite', array( 10 ) );
		}
		if ( isset( $_POST['scan_frequency_interval'] ) ) {
			$wpdb->update( $table_name, array( 'option_value' => sanitize_text_field( wp_unslash( $_POST['scan_frequency_interval'] ) ) ), array( 'option_name' => 'scan_frequency_interval' ) ); }
		if ( isset( $_POST['language_setting'] ) ) {
			$wpdb->update( $table_name, array( 'option_value' => sanitize_text_field( wp_unslash( $_POST['language_setting'] ) ) ), array( 'option_name' => 'language_setting' ) ); }
		if ( isset( $_POST['api_key'] ) ) {
			$wpdb->update( $table_name, array( 'option_value' => sanitize_text_field( wp_unslash( $_POST['api_key'] ) ) ), array( 'option_name' => 'api_key' ) ); }

		$pages = explode( PHP_EOL, sanitize_text_field( wp_unslash( $_POST['pages-ignore'] ) ) );

		// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Table name is safe: constructed from $wpdb->prefix + hardcoded string
		$wpdb->query( 'TRUNCATE TABLE ' . $ignore_table );

		foreach ( $pages as $page ) {
			if ( null !== $page ) {
				$wpdb->insert(
					$ignore_table,
					array(
						'keyword' => $page,
						'type'    => 'page',
					)
				);
			}
		}

		if ( is_plugin_active( WPSCX_PRO_LOC ) ) {
			if ( 'Clean up Database and Deactivate Plugin' !== $_POST['uninstall'] ) {
				wpsc_do_ent_api_request( true ); // Refresh the API Key validation after updating it unless deactivating plugin
			}
		}
		global $wpscx_key_valid;
		global $wpscx_ent_included;

		$user_id = get_current_user_id();
		update_user_meta( $user_id, 'wpsc_usedyslexic', sanitize_text_field( wp_unslash( $_POST['wpsc_usedyslexic'] ) ) );
	}

	// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Table name is safe: constructed from $wpdb->prefix + hardcoded string
	$settings = $wpdb->get_results( 'SELECT option_name, option_value FROM ' . $table_name );
	// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Table name is safe: constructed from $wpdb->prefix + hardcoded string
	$grammar_settings = $wpdb->get_results( 'SELECT option_name, option_value FROM ' . $grammar_table );

	$grammar_pages = $grammar_settings[0]->option_value;
	$grammar_posts = $grammar_settings[1]->option_value;

	$email                    = $settings[0]->option_value;
	$email_address            = $settings[1]->option_value;
	$ignore_caps              = $settings[3]->option_value;
	$check_pages              = $settings[4]->option_value;
	$check_posts              = $settings[5]->option_value;
	$check_menus              = $settings[7]->option_value;
	$scan_frequency           = $settings[8]->option_value;
	$scan_frequency_interval  = $settings[9]->option_value;
	$email_frequency_interval = $settings[10]->option_value;
	$language_setting         = $settings[11]->option_value;
	$page_titles              = $settings[12]->option_value;
	$post_titles              = $settings[13]->option_value;
	$tags                     = $settings[14]->option_value;
	$categories               = $settings[15]->option_value;
	$seo_desc                 = $settings[16]->option_value;
	$seo_titles               = $settings[17]->option_value;
	$page_slugs               = $settings[18]->option_value;
	$post_slugs               = $settings[19]->option_value;
	$api_key                  = $settings[20]->option_value;
	$ignore_emails            = $settings[23]->option_value;
	$ignore_websites          = $settings[24]->option_value;
	$check_sliders            = $settings[30]->option_value;
	$check_media              = $settings[31]->option_value;
	$highlight_words          = $settings[33]->option_value;
	$check_ecommerce          = $settings[36]->option_value;
	$check_cf7                = $settings[37]->option_value;
	$check_tag_desc           = $settings[38]->option_value;
	$check_tag_slug           = $settings[39]->option_value;
	$check_cat_desc           = $settings[40]->option_value;
	$check_cat_slug           = $settings[41]->option_value;
	$check_custom             = $settings[42]->option_value;
	$check_authors            = $settings[44]->option_value;
	$check_authors_empty      = $settings[47]->option_value;
	$check_menu_empty         = $settings[48]->option_value;
	$check_page_titles_empty  = $settings[49]->option_value;
	$check_post_titles_empty  = $settings[50]->option_value;
	$check_tag_desc_empty     = $settings[51]->option_value;
	$check_cat_desc_empty     = $settings[52]->option_value;
	$check_page_seo_empty     = $settings[53]->option_value;
	$check_post_seo_empty     = $settings[54]->option_value;
	$check_media_seo_empty    = $settings[55]->option_value;
	$check_media_empty        = $settings[56]->option_value;
	$check_ecommerce_empty    = $settings[57]->option_value;
	$check_page_drafts        = $settings[136]->option_value;
	$check_post_drafts        = $settings[137]->option_value;
	$check_widgets            = $settings[147]->option_value;

	// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Table name is safe: constructed from $wpdb->prefix + hardcoded string, WHERE value is hardcoded
	$page_data = $wpdb->get_results( 'SELECT keyword FROM ' . $ignore_table . " WHERE type='page';" );
	$page_list = '';
	foreach ( $page_data as $page ) {
		$page_list .= $page->keyword . PHP_EOL;
	}
	if ( isset( $_POST['test-email'] ) && 'Send Test' === $_POST['test-email'] ) {
		if ( ! current_user_can( 'manage_options' ) ) {
			wp_die( 'You do not have permission to send test emails.', 403 );
		}
		$nonce_received        = isset( $_POST['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) ) : '';
		$nonce_valid_result    = wp_verify_nonce( $nonce_received, 'wpsc_update_options' );
		$http_referer          = isset( $_SERVER['HTTP_REFERER'] ) ? esc_url_raw( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '';
		$post_referer          = isset( $_POST['_wp_http_referer'] ) ? esc_url_raw( wp_unslash( $_POST['_wp_http_referer'] ) ) : '';
		$admin_url_val         = admin_url();
		$wp_get_referer_result = wp_get_referer();
		// Verify nonce - if it fails, check referer as fallback for stale nonces
		// This handles cases where browser caches the form HTML with an old nonce
		if ( ! $nonce_valid_result ) {
			// Nonce failed - check if referer is valid as security fallback
			// Use HTTP_REFERER header directly since wp_get_referer() may return false
			$referer = $http_referer ? $http_referer : $post_referer;

			// Handle relative URLs in POST referer by converting to absolute
			if ( $referer && ! preg_match( '/^https?:\/\//', $referer ) ) {
				// Relative URL - convert to absolute using admin_url()
				$referer = admin_url( $referer );
			}

			// Use strpos for PHP 7.x compatibility instead of str_starts_with (PHP 8.0+)
			$admin_url_lower = strtolower( $admin_url_val );
			$referer_lower   = $referer ? strtolower( $referer ) : '';
			$referer_valid   = $referer && ( strpos( $referer_lower, $admin_url_lower ) === 0 );

			if ( ! $referer_valid ) {
				// Both nonce and referer failed - this is a security issue
				wp_die( 'The link you followed has expired. Please try again.' );
			}

			// Referer is valid - allow the request
			// This handles stale nonces from browser cache while maintaining security via referer check
		}
		$wpdb->update( $table_name, array( 'option_value' => sanitize_email( wp_unslash( $_POST['email_address'] ) ) ), array( 'option_name' => 'email_address' ) );
			$emailer   = new Wpscx_Email();
		$message       = $emailer->send_test_email();
		$email_address = sanitize_email( wp_unslash( $_POST['email_address'] ) );
	}

	wp_enqueue_script( 'options-nav', plugin_dir_url( __FILE__ ) . 'options-nav.js' );
	wp_enqueue_script( 'options-page', plugin_dir_url( __FILE__ ) . 'js/options-page.js', array(), $wpsc_version, true );

	?>
	<?php // wpscx_show_feature_window(); ?>
		<div class="wrap wpsc-options-page">
			<h2><a href="admin.php?page=wp-spellcheck.php"><img src="<?php echo esc_url( plugin_dir_url( __FILE__ ) ) . 'images/logo.png'; ?>" alt="WP Spell Check" /></a> <span style="position: relative; top: -8px;"> - Options</span></h2>
					<?php
					if ( '' !== $api_key && ! is_plugin_active( WPSCX_PRO_LOC ) ) {
						echo "<div class='wpsc-notice-error'>WP Spell Check Pro Version must be active. Please activate WP Spell Check Pro</div>";
					} elseif ( ! $wpscx_key_valid && '' !== $api_key ) {
						echo "<div class='wpsc-notice-error'>API Key not valid</div>";
					} elseif ( $wpscx_key_valid ) {
						echo "<div class='wpsc-notice-success'>API Key is valid</div>";
					}
					?>
		<?php
		if ( '' !== $message ) {
			// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Output is safe: $message contains hardcoded strings, already escaped with esc_html()
			echo "<div class='wpsc-notice-success'><span class='wpsc-message'>" . htmlspecialchars_decode( esc_html( $message ) ) . '</span></div>';}
		?>
			<div class="wpsc-scan-nav-bar" style="width: 75%;">
				<a href="#general-options" id="wpsc-general-options" 
				<?php
				if ( isset( $_POST['wpsc-scan-tab'] ) && 'scan' !== $_POST['wpsc-scan-tab'] && 'empty' !== $_POST['wpsc-scan-tab'] && 'grammar' !== $_POST['wpsc-scan-tab'] && 'accessibility' !== $_POST['wpsc-scan-tab'] ) {
					echo 'class="selected"';}
				?>
				name="wpsc-general-options">General Settings</a>
				<a href="#scan-options" id="wpsc-scan-options" 
				<?php
				if ( isset( $_POST['wpsc-scan-tab'] ) && 'scan' === $_POST['wpsc-scan-tab'] ) {
					echo 'class="selected"';}
				?>
				name="wpsc-scan-options">Spell Check Options</a>
				<a href="#grammar-options" id="wpsc-grammar-options" 
				<?php
				if ( isset( $_POST['wpsc-scan-tab'] ) && 'grammar' === $_POST['wpsc-scan-tab'] ) {
					echo 'class="selected"';}
				?>
				name="wpsc-grammar-options">Grammar Options</a>
				<a href="#empty-options" id="wpsc-empty-options" 
				<?php
				if ( isset( $_POST['wpsc-scan-tab'] ) && 'empty' === $_POST['wpsc-scan-tab'] ) {
					echo 'class="selected"';}
				?>
				name="wpsc-empty-options">SEO Options<span style="font-size: 8px;"></span></a>
				<a href="#accessibility-options" id="wpsc-accessibility-options" 
				<?php
				if ( isset( $_POST['wpsc-scan-tab'] ) && 'accessibility' === $_POST['wpsc-scan-tab'] ) {
					echo 'class="selected"';}
				?>
				name="wpsc-accessibility-options">Accessibility Options<span style="font-size: 8px;"></span></a>
			</div>
			<form action="admin.php?page=wp-spellcheck-options.php" method="post" name="options" style="margin-top: -7px;" enctype="multipart/form-data" id="wpsc-options-form">
						<?php wp_nonce_field( 'wpsc_update_options' ); ?>
			<input type="hidden" name="wpsc-scan-tab" class="wpsc-nav-tab" value="<?php echo esc_attr( isset( $_POST['wpsc-scan-tab'] ) ? sanitize_text_field( wp_unslash( $_POST['wpsc-scan-tab'] ) ) : '' ); ?>">
			<div id="wpsc-general-options-tab" 
			<?php
			if ( isset( $_POST['wpsc-scan-tab'] ) && ( 'scan' === $_POST['wpsc-scan-tab'] || 'empty' === $_POST['wpsc-scan-tab'] || 'grammar' === $_POST['wpsc-scan-tab'] || 'accessibility' === $_POST['wpsc-scan-tab'] ) ) {
				echo 'class="hidden"';}
			?>
			>
							<div style="width: 75%; float: left;">
			<table class="form-table wpsc-general-options-table wpsc-options-card" style="display: block; padding-top: 20px;" role="presentation"><tbody>
							<?php
							if ( ! $wpscx_ent_included ) {
								?>
								<tr><td>You're using WP Spell Check Base Version - no API key needed! <br><br>To unlock Pro features, <a target="_blank" href="https://www.wpspellcheck.com/pricing/?utm_source=baseplugin&utm_campaign=upgradeoptions&utm_medium=spellcheck_options&utm_content=<?php echo esc_attr( $wpsc_version ); ?>">Click here</a> to upgrade</td></tr><?php } ?>
								<tr><td style="padding-top: 30px; width: 755px;"><label for="wpsc-api-key" style="display: inline-block; margin-bottom: 6px;">Already Upgraded? Simply enter your API key in the box below<br>and make sure to install and activate the Pro plugin as well!</label><br /><input type="text" id="wpsc-api-key" name="api_key" value="<?php echo esc_attr( $api_key ); ?>" placeholder="Paste your API key here"></td>
				<td style="padding-top: 30px;"><label style="display: inline-block; margin-bottom: 6px;">Language</label><br /><select style="display: inline-block; width: 140px; height: 27px; margin-top: 1px;" name="language_setting">
<option value="en_CA" 
	<?php
	if ( 'en_CA' === $language_setting ) {
		echo "selected='selected'";}
	?>
>English (Canada)</option>
<option value="en_US" 
	<?php
	if ( 'en_US' === $language_setting ) {
		echo "selected='selected'";}
	?>
>English (US)</option>
<option value="en_UK" 
	<?php
	if ( 'en_UK' === $language_setting ) {
		echo "selected='selected'";}
	?>
>English (UK)</option>
</select></td></tr>
				<tr><td><label>Pages/Posts to ignore (Please enter Page/Post titles and place one on each line)</label></td><td colspan="2"><textarea name="pages-ignore" rows="4" cols="50"><?php echo esc_html( $page_list ); ?></textarea></td></tr>
								<tr><td colspan="2"><hr style="width: 50%;"><p style="text-align: center; margin-top: -5px; font-weight: bold;">Choose if you want to scan the pages/posts that are saved as drafts</p></td></tr>
				<tr><td><input class="ignore-check-all" type="checkbox" name="check-page-drafts" value="check-page-drafts" 
				<?php
				if ( 'true' === $check_page_drafts ) {
					echo 'checked';}
				?>
				>Scan Page Drafts</td>
				<td><input class="ignore-check-all" type="checkbox" name="check-post-drafts" value="check-post-drafts" 
				<?php
				if ( 'true' === $check_post_drafts ) {
					echo 'checked';}
				?>
				>Scan Post Drafts</td></tr>
				<tr><td colspan="2"><hr style="width: 50%;"></td></tr>
				<tr><td colspan="2"><p style="text-align: center; margin-top: -5px; font-weight: bold;">Theme Appearance</p></td></tr>
				<tr><td><label for="wpsc-admin-theme">Theme</label></td>
				<td>
				<?php
				$current_theme = function_exists( 'wpsc_get_effective_admin_theme' ) ? wpsc_get_effective_admin_theme() : 'dark';
				?>
				<div id="wpsc-admin-theme" class="wpsc-theme-toggle" role="group" aria-label="<?php esc_attr_e( 'Theme', 'wp-spell-check' ); ?>">
					<input type="radio" id="wpsc-theme-light" name="wpsc_admin_theme" value="light" <?php echo ( 'light' === $current_theme ) ? 'checked' : ''; ?>>
					<label for="wpsc-theme-light"><?php esc_html_e( 'Light', 'wp-spell-check' ); ?></label>
					<input type="radio" id="wpsc-theme-dark" name="wpsc_admin_theme" value="dark" <?php echo ( 'dark' === $current_theme ) ? 'checked' : ''; ?>>
					<label for="wpsc-theme-dark"><?php esc_html_e( 'Dark', 'wp-spell-check' ); ?></label>
				</div>
				</td></tr>
				
				<tr colspan="2"><td><input type="submit" name="submit" value="Update" class="button button-primary" /></td></tr>
						</table>
							<table class="form-table wpsc-general-options-table wpsc-options-card" style="margin-top: 20px; display: block; padding-top: 20px;" role="presentation"><tbody>
								<tr><td colspan="2"><p style="text-align: center; font-weight: bold;">Setup email notifications to get notified about errors on your website, especially broken HTML and broken shortcode notifications.</p></td></tr>
				<tr><td><span style="display: inline-block; margin-bottom: 6px;"><input type="checkbox" name="email" value="email" 
				<?php
				if ( 'true' === $email ) {
					echo 'checked';}
				?>
				<?php
				if ( ! $wpscx_ent_included ) {
									echo 'disabled';}
				?>
>Send Email Reports</span><br /><input type="text" name="email_address" value="<?php echo esc_attr( $email_address ); ?>" 
																							<?php
																							if ( ! $wpscx_ent_included ) {
																												echo 'disabled';}
																							?>
><input type="hidden" name="page" value="wp-spellcheck-options.php">
				<input type="hidden" name="action" value="check">
		<input type="submit" name="test-email" id="test-email" class="button button-primary" value="Send Test" 
		<?php
		if ( ! $wpscx_ent_included ) {
			echo 'disabled';}
		?>
		>
	<?php
	if ( ! $wpscx_ent_included ) {
		?>
			<span class="wpsc-mouseover-email" style="border-radius: 29px; border: 1px solid green; display: inline-block; margin-left: 10px; padding: 4px 10px; cursor: help;">?</span><span class="wpsc-mouseover-text-email"><span style="display: block;text-align: center;font-size: 14px;padding: 10px 0 10px 0;background-color: #2271b1;color: white;margin-bottom: 8px;"> This is a Pro Feature</span><span style="padding: 0 10px; display: block;">To receive email reports,  <a href="https://www.wpspellcheck.com/pricing/" target="_blank">Click Here</a> to upgrade to WP Spell Check Pro.</span></span><?php } ?></td><td><label style="display: inline-block; margin-bottom: 6px; margin-top: -2px;">Scan Frequency</label><br />Every <input size="5" name="scan_frequency" style="border: 1px solid #ddd" value="<?php echo esc_html( $scan_frequency ); ?>" 
																																																																																																																																																								<?php
																																																																																																																																																								if ( ! $wpscx_ent_included ) {
																																																																																																																																																									echo 'disabled';}
																																																																																																																																																								?>
			><select style="height: 27px; margin-top: 0px; display: inline-block;" name="scan_frequency_interval" 
	<?php
	if ( ! $wpscx_ent_included ) {
		echo 'disabled';}
	?>
>
	<?php
	// Pro: only days; free: minutes, hours, days.
	if ( ! $wpscx_ent_included ) {
	?>
	<option value="minutes"
	<?php
	if ( 'minutes' === $scan_frequency_interval ) {
		echo "selected='selected'";}
	?>
	>Minute(s)</option>
	<option value="hourly"
	<?php
	if ( 'hourly' === $scan_frequency_interval ) {
		echo "selected='selected'";}
	?>
	>Hour(s)</option>
	<?php
	}
	?>
	<option value="daily"
	<?php
	if ( 'daily' === $scan_frequency_interval || ( $wpscx_ent_included && in_array( $scan_frequency_interval, array( 'minutes', 'hourly' ), true ) ) ) {
		echo "selected='selected'";}
	?>
>Day(s)</option>
</select><span class="wpsc-mouseover-button-freq" style="border-radius: 29px; border: 1px solid green; display: inline-block; margin-left: 10px; padding: 4px 10px; cursor: help;">?</span><span class="wpsc-mouseover-text-freq"><span style="display: block;text-align: center;font-size: 14px;padding: 10px 0 10px 0;background-color: #2271b1;color: white;margin-bottom: 8px;"> Scheduled Scans</span><span style="padding: 0 10px; display: block;">For scans twice a day, set to 12 hours.<br>For scans once per week, set to 7 days.<br>For scans once per month, set to 30 days.</span></span></td></tr>
				<?php if ( true !== is_plugin_active( 'wp-mail-smtp/wp_mail_smtp.php' ) ) { ?>
					<tr><td colspan="2">To ensure emails are delivered, try using <a target="_blank" href="https://en-ca.wordpress.org/plugins/wp-mail-smtp/">WP Mail SMTP</a></td></tr>
				<?php } ?>
				<?php if ( '' === $email_address && 'true' === $email ) { ?>
					<tr><td colspan="2">An email address must be entered in order to receive email alerts</td></tr>
				<?php } ?>
								<tr><td colspan="2"><hr style="width: 50%;"></td></tr>
				<tr><td><h2>Import/Export Plugin Data</h2></td></tr>
				<tr>
					<td><input type="checkbox" class="export-dict" name="export-dict" value="true" 
					<?php
					if ( ! $wpscx_ent_included ) {
						echo 'disabled';}
					?>
					/> Export My Dictionary<br><br><input type="checkbox" class="export-ignore" name="export-ignore" value="true" 
	<?php
	if ( ! $wpscx_ent_included ) {
						echo 'disabled';}
	?>
/> Export Ignore List</td>
					<td><input type="file" name="import_file" id="import-file" 
					<?php
					if ( ! $wpscx_ent_included ) {
						echo 'disabled';}
					?>
					></td>
				</tr>
				<tr>
					<?php wp_nonce_field( 'wpsc_export' ); ?>
					<td><input type="submit" class="wpsc-export-data button button-primary" name="export" value="Export Plugin Data"
					<?php
					if ( ! $wpscx_ent_included ) {
						echo 'disabled';}
					?>
					/>
	<?php
	if ( ! $wpscx_ent_included ) {
		?>
						<span class="wpsc-mouseover-export" style="border-radius: 29px; border: 1px solid green; display: inline-block; margin-left: 10px; padding: 4px 10px; cursor: help;">?</span><span class="wpsc-mouseover-text-export"><span style="display: block;text-align: center;font-size: 14px;padding: 10px 0 10px 0;background-color: #2271b1;color: white;margin-bottom: 8px;"> This is a Pro Feature</span><span style="padding: 0 10px; display: block;">To export plugin settings,  <a href="https://www.wpspellcheck.com/pricing/" target="_blank">Click Here</a> to upgrade to WP Spell Check Pro.</span></span><?php } ?></td>
					<td><input type="submit" name="import" id="wpsc-import-button" value="Import Plugin Data" class="button button-primary"
					<?php
					if ( ! $wpscx_ent_included ) {
						echo 'disabled';
					} else {
						echo 'disabled'; // Initially disabled until file is selected
					}
					?>
					/>
	<?php
	if ( ! $wpscx_ent_included ) {
		?>
						<span class="wpsc-mouseover-import" style="border-radius: 29px; border: 1px solid green; display: inline-block; margin-left: 10px; padding: 4px 10px; cursor: help;">?</span><span class="wpsc-mouseover-text-import"><span style="display: block;text-align: center;font-size: 14px;padding: 10px 0 10px 0;background-color: #2271b1;color: white;margin-bottom: 8px;"> This is a Pro Feature</span><span style="padding: 0 10px; display: block;">To import plugin settings,  <a href="https://www.wpspellcheck.com/pricing/" target="_blank">Click Here</a> to upgrade to WP Spell Check Pro.</span></span><?php } ?></td>
				</tr>
							<?php if ( ! $wpscx_ent_included ) { ?>
								<tr><td style="color: red; font-weight: bold; font-size: 16px;"><a href="https://www.wpspellcheck.com/pricing/?utm_source=baseplugin&utm_campaign=upgradeoptions&utm_medium=spellcheck_options&utm_content=<?php echo esc_attr( $wpsc_version ); ?>" target="_blank">Upgrade to Pro</a> to send email reports and import/export your plugin data to or from other websites.</td></tr>
								<?php } ?>
								<tr><td colspan="2"><hr style="width: 50%;"></td></tr>
				<tr><td colspan="3"  align="left"><input type="button" id="wpsc-uninstall-btn" class="button" value="Clean up Database and Deactivate Plugin" /><input type="hidden" name="uninstall" id="wpsc-uninstall-hidden" value="" /><span style="margin-left: 10px;">Removes all plugin data and deactivates the plugin.</span></td></tr>
								<tr><td><a href="<?php echo esc_url( plugin_dir_url( __FILE__ ) ) . 'wpsc-data.ini'; ?>" download id='wpsc-settings-download' hidden></a></td></tr>
			</tbody>
			</table>
							</div>
			</div>
			<div id="wpsc-scan-options-tab" 
			<?php
			if ( isset( $_POST['wpsc-scan-tab'] ) && 'scan' !== $_POST['wpsc-scan-tab'] ) {
				echo 'class="hidden"';}
			?>
			>
				<table class="form-table wpsc-options-card" style="width: 75%; float: left;" role="presentation"><tbody>
										<tr><td colspan="3"><h3>Select which parts of your website you'd like to check for spelling errors and click on the Update button</h3></td></tr>
				<?php if ( $wpscx_ent_included ) { ?>
				<tr><td><input type="checkbox" id="check-all" name="check-all" value="check-all">Select All</td></tr>
				<tr><td style="width: 33%;"><input type="checkbox" name="check-pages" value="check-pages" 
					<?php
					if ( 'true' === $check_pages ) {
						echo 'checked';}
					?>
				>Pages</td>
				<td style="width: 33%;"><input type="checkbox" name="page-titles" value="page-titles" 
					<?php
					if ( 'true' === $page_titles ) {
						echo 'checked';}
					?>
				>Page Titles</td>
				<td style="width: 33%;"><input type="checkbox" name="page-slugs" value="page-slugs" 
					<?php
					if ( 'true' === $page_slugs ) {
						echo 'checked';}
					?>
				>Page Slugs</td>
				</tr>
				<tr><td><input type="checkbox" name="check-posts" value="check-posts" 
					<?php
					if ( 'true' === $check_posts ) {
						echo 'checked';}
					?>
				>Posts</td>
				<td><input type="checkbox" name="post-titles" value="post-titles" 
					<?php
					if ( 'true' === $post_titles ) {
						echo 'checked';}
					?>
				>Post Titles</td>
				<td><input type="checkbox" name="post-slugs" value="post-slugs" 
					<?php
					if ( 'true' === $post_slugs ) {
						echo 'checked';}
					?>
				>Post Slugs</td>
				</tr>
				<tr><td><input type="checkbox" name="tags" value="tags" 
					<?php
					if ( 'true' === $tags ) {
						echo 'checked';}
					?>
				>Tags</td>
				<td><input type="checkbox" name="check-tag-desc" value="check-tag-desc" 
					<?php
					if ( 'true' === $check_tag_desc ) {
						echo 'checked';}
					?>
				>Tag Descriptions</td>
				<td><input type="checkbox" name="check-tag-slug" value="check-tag-slug" 
					<?php
					if ( 'true' === $check_tag_slug ) {
						echo 'checked';}
					?>
				>Tag Slugs</td>
				</tr>
				<tr><td><input type="checkbox" name="categories" value="categories" 
					<?php
					if ( 'true' === $categories ) {
						echo 'checked';}
					?>
				>Categories</td>
				<td><input type="checkbox" name="check-cat-desc" value="check-cat-desc" 
					<?php
					if ( 'true' === $check_cat_desc ) {
						echo 'checked';}
					?>
				>Category Descriptions</td>
				<td><input type="checkbox" name="check-cat-slug" value="check-cat-slug" 
					<?php
					if ( 'true' === $check_cat_slug ) {
						echo 'checked';}
					?>
				>Category Slugs</td>
				</tr>
				<tr><td><input type="checkbox" name="check-media" value="check-media" 
					<?php
					if ( 'true' === $check_media ) {
						echo 'checked';}
					?>
				>Media Files</td>
				<td><input type="checkbox" name="seo-desc" value="seo-desc" 
					<?php
					if ( 'true' === $seo_desc ) {
						echo 'checked';}
					?>
				>SEO Descriptions</td>
				<td><input type="checkbox" name="seo-titles" value="seo-titles" 
					<?php
					if ( 'true' === $seo_titles ) {
						echo 'checked';}
					?>
				>SEO Titles</td>
				</tr>
				<tr><td><input type="checkbox" name="check-menu" value="check-menu" 
					<?php
					if ( 'true' === $check_menus ) {
						echo 'checked';}
					?>
				>WordPress Menus</td>
				<td><input type="checkbox" name="check-sliders" value="check-sliders" 
					<?php
					if ( 'true' === $check_sliders ) {
						echo 'checked';}
					?>
				>Sliders</td>				
				<td><input type="checkbox" name="check-ecommerce" value="check-ecommerce" 
					<?php
					if ( 'true' === $check_ecommerce ) {
						echo 'checked';}
					?>
				>WooCommerce Products</td></tr>
				<tr>
				<td><input type="checkbox" name="check-cf7" value="check-cf7" 
					<?php
					if ( 'true' === $check_cf7 ) {
						echo 'checked';}
					?>
				>Contact Form 7</td>
				<td><input type="checkbox" name="check-authors" value="check-authors" 
					<?php
					if ( 'true' === $check_authors ) {
						echo 'checked';}
					?>
				>Authors</td>
				<td><input type="checkbox" name="check-widgets" value="check-widgets" 
					<?php
					if ( 'true' === $check_widgets ) {
						echo 'checked';}
					?>
				>Widgets</td></tr>
				<tr><td><div style="margin-top: 25px;"></div></td></tr>
				<tr><td style="vertical-align: top;"><input class="ignore-check-all" type="checkbox" name="ignore-caps" value="ignore-caps" 
					<?php
					if ( 'true' === $ignore_caps ) {
						echo 'checked';}
					?>
				>Ignore fully capitalized words</td>
				<td style="vertical-align: top;"><input class="ignore-check-all" type="checkbox" name="ignore-emails" value="ignore-emails" 
					<?php
					if ( 'true' === $ignore_emails ) {
						echo 'checked';}
					?>
				>Ignore Email Addresses</td></tr>
				<tr><td style="vertical-align: top;"><input class="ignore-check-all" type="checkbox" name="ignore-websites" value="ignore-websites" 
					<?php
					if ( 'true' === $ignore_websites ) {
						echo 'checked';}
					?>
				>Ignore Website URLs</td>
								<td style="vertical-align: top;"><input 
								<?php
								if ( ! $wpscx_ent_included ) {
									echo 'disabled';}
								?>
								class="ignore-check-all" type="checkbox" name="highlight-words" value="highlight-words" 
					<?php
					if ( 'true' === $highlight_words && ( $wpscx_ent_included ) ) {
						echo 'checked';}
					?>
>Highlight Misspelled Words (For logged in admin only)
					<?php
					if ( ! $wpscx_ent_included ) {
						?>
									<span class='wpsc-mouseover-pro-feature' style='border-radius: 29px; border: 1px solid green; display: inline-block; margin-left: 10px; padding: 4px 10px; cursor: help;'>?<span class="wpsc-mouseover-text-pro-feature"><span style="display: block;text-align: center;font-size: 14px;padding: 10px 0 10px 0;background-color: #2271b1;color: white;margin-bottom: 8px;"> This is a Pro Feature</span><span style="padding: 0 10px; display: block;">To highlight misspelled words, <a href="https://www.wpspellcheck.com/pricing/" target="_blank">Click Here</a> to upgrade to WP Spell Check Pro..</span></span></span><?php } ?></td></tr>
								<tr colspan="2"><td><input type="submit" name="submit" value="Update" class="button button-primary" /></td></tr>
				<?php } else { ?>
				<tr><td><input type="checkbox" id="check-all" name="check-all" value="check-all">Select All</td></tr>
				<tr><td style="width: 33%;"><input type="checkbox" name="check-pages" value="check-pages" 
					<?php
					if ( 'true' === $check_pages ) {
						echo 'checked';}
					?>
				>Pages</td>
				<td style="width: 33%;"><input type="checkbox" name="check-posts" value="check-posts" 
					<?php
					if ( 'true' === $check_posts ) {
						echo 'checked';}
					?>
				>Posts</td>
				<td style="width: 33%;"><input type="checkbox" name="check-cf7" value="check-cf7" 
					<?php
					if ( 'true' === $check_cf7 ) {
						echo 'checked';}
					?>
				>Contact Form 7</td></tr>
				<tr><td><input type="checkbox" name="check-authors" value="check-authors" 
					<?php
					if ( 'true' === $check_authors ) {
						echo 'checked';}
					?>
				>Authors</td></tr>
				<tr><td><div style="margin-top: 25px;"></div></td></tr>
				<tr><td><input class="ignore-check-all" type="checkbox" name="ignore-caps" value="ignore-caps" 
					<?php
					if ( 'true' === $ignore_caps ) {
						echo 'checked';}
					?>
				>Ignore fully capitalized words</td>
				<td><input class="ignore-check-all" type="checkbox" name="ignore-emails" value="ignore-emails" 
					<?php
					if ( 'true' === $ignore_emails ) {
						echo 'checked';}
					?>
				>Ignore Email Addresses</td></tr>
				<tr><td><input class="ignore-check-all" type="checkbox" name="ignore-websites" value="ignore-websites" 
					<?php
					if ( 'true' === $ignore_websites ) {
						echo 'checked';}
					?>
				>Ignore Website URLs</td>
				<td><input 
					<?php
					if ( ! $wpscx_ent_included ) {
						echo 'disabled';}
					?>
				class="ignore-check-all" type="checkbox" name="highlight-words" value="highlight-words" 
					<?php
					if ( 'true' === $highlight_words && ( $wpscx_ent_included ) ) {
						echo 'checked';}
					?>
>Highlight Misspelled Words (For logged in admin only)
					<?php
					if ( ! $wpscx_ent_included ) {
						?>
					<span class='wpsc-mouseover-pro-feature' style='border-radius: 29px; border: 1px solid green; display: inline-block; margin-left: 10px; padding: 4px 10px; cursor: help;'>?<span class="wpsc-mouseover-text-pro-feature"><span style="display: block;text-align: center;font-size: 14px;padding: 10px 0 10px 0;background-color: #2271b1;color: white;margin-bottom: 8px;"> This is a Pro Feature</span><span style="padding: 0 10px; display: block;">To highlight misspelled words, <a href="https://www.wpspellcheck.com/pricing/" target="_blank">Click Here</a> to upgrade to WP Spell Check Pro.</span></span></span><?php } ?></td></tr>
								<tr colspan="2"><td><input type="submit" name="submit" value="Update" class="button button-primary" /></td></tr>
								<tr><td colspan="3"><hr style="width: 50%;"></td></tr>
					<tr class="wpsc-upgrade-pro-row"><td colspan="3"><h3 style="color: red;"><a href="https://www.wpspellcheck.com/pricing/?utm_source=baseplugin&utm_campaign=upgradeoptions&utm_medium=spellcheck_options&utm_content=<?php echo esc_attr( $wpsc_version ); ?>" target="_blank">Upgrade to Pro</a> to scan the following</h3></td></tr>
					<tr class="wpsc-upgrade-pro-row"><td>WordPress Menus</td><td>Page Titles</td><td>Post Titles</td></tr>
					<tr class="wpsc-upgrade-pro-row"><td>Tags</td><td>Tag Descriptions</td><td>Tag Slugs</td></tr>
					<tr class="wpsc-upgrade-pro-row"><td>Category Slugs</td><td>Categories</td><td>Category Descriptions</td></tr>
					<tr class="wpsc-upgrade-pro-row"><td>SEO Descriptions</td><td>SEO Titles</td><td>Page Slugs</td></tr>
					<tr class="wpsc-upgrade-pro-row"><td>Post Slugs</td><td>Sliders</td><td>Media Files</td></tr>
					<tr class="wpsc-upgrade-pro-row"><td>WooCommerce Products</td></tr>
				<?php } ?>
				<?php
				if ( $wpscx_ent_included ) {
					?>
					<tr><td colspan="3"  align="left"><span style="font-size: 14px; font-weight: bold; color: red;">Warning: When updating <span class="wpsc-warning-highlight" style="color: black; text-decoration: underline;">page/post slugs</span>, some links contained within the theme may not be updated. Consult your webmaster before updating page/post slugs.</span><br /><br /><span style="font-size: 14px; font-weight: bold; color: red;">When updating <span class="wpsc-warning-highlight" style="color: black; text-decoration: underline;">Media filenames</span> this may cause images to stop working on your website. This does not apply to descriptions, alternate text, or captions.</span></td></tr> <?php } ?>
			</tbody></table>
		</div>
		<div id="wpsc-empty-options-tab" 
		<?php
		if ( isset( $_POST['wpsc-scan-tab'] ) && 'empty' !== $_POST['wpsc-scan-tab'] ) {
			echo 'class="hidden"';}
		?>
		>
				<table class="form-table wpsc-options-card" style="width: 75%; float: left;" role="presentation"><tbody>
									<tr><td colspan="3"><h3>Select which parts of your website you'd like to audit for SEO Empty Fields to improve your SEO. <a href="https://www.wpspellcheck.com/plugin-support/how-to-improve-wordpress-seo/" target="_blank">See Video</a></h3></td></tr>
				<tr><td><input type="checkbox" id="check-all-empty" name="check-all-empty" value="check-all-empty">Select All</td></tr>
				<?php if ( $wpscx_ent_included ) { ?>
				<tr><td style="width: 33%;"><input type="checkbox" name="check-authors-empty" value="check-authors" 
					<?php
					if ( 'true' === $check_authors_empty ) {
						echo 'checked';}
					?>
				>Authors</td>
				<td style="width: 33%;"><input type="checkbox" name="check-menu-empty" value="check-menu" 
					<?php
					if ( 'true' === $check_menu_empty ) {
						echo 'checked';}
					?>
				>WordPress Menus</td>
				<td style="width: 33%;"><input type="checkbox" name="check-page-titles-empty" value="check-page-titles" 
					<?php
					if ( 'true' === $check_page_titles_empty ) {
						echo 'checked';}
					?>
				>Page Titles</td></tr>
				<tr><td><input type="checkbox" name="check-post-titles-empty" value="check-post-titles" 
					<?php
					if ( 'true' === $check_post_titles_empty ) {
						echo 'checked';}
					?>
				>Post Titles</td>
				<td><input type="checkbox" name="check-tag-desc-empty" value="check-tag-desc" 
					<?php
					if ( 'true' === $check_tag_desc_empty ) {
						echo 'checked';}
					?>
				>Tag Descriptions</td>
				<td><input type="checkbox" name="check-cat-desc-empty" value="check-cat-desc" 
					<?php
					if ( 'true' === $check_cat_desc_empty ) {
						echo 'checked';}
					?>
				>Category Descriptions</td></tr>
				<tr><td><input type="checkbox" name="check-page-seo-empty" value="check-page-seo" 
					<?php
					if ( 'true' === $check_page_seo_empty ) {
						echo 'checked';}
					?>
				>Page SEO</td>
				<td><input type="checkbox" name="check-post-seo-empty" value="check-post-seo" 
					<?php
					if ( 'true' === $check_post_seo_empty ) {
						echo 'checked';}
					?>
				>Post SEO</td>
				<td><input type="checkbox" name="check-media-seo-empty" value="check-media-seo" 
					<?php
					if ( 'true' === $check_media_seo_empty ) {
						echo 'checked';}
					?>
				>Media Files SEO</td></tr>
				<tr><td><input type="checkbox" name="check-media-empty" value="check-media" 
					<?php
					if ( 'true' === $check_media_empty ) {
						echo 'checked';}
					?>
				>Media Files</td>
				<td><input type="checkbox" name="check-ecommerce-empty" value="check-ecommerce" 
					<?php
					if ( 'true' === $check_ecommerce_empty ) {
						echo 'checked';}
					?>
				>WooCommerce Products</td>
				</tr>
								<tr colspan="2"><td><input type="submit" name="submit" value="Update" class="button button-primary" /></td></tr>
				<?php } else { ?>
				<tr><td style="width: 33%;"><input type="checkbox" name="check-authors-empty" value="check-authors" 
					<?php
					if ( 'true' === $check_authors_empty ) {
						echo 'checked';}
					?>
				>Authors</td>
					<td style="width: 33%;"><input type="checkbox" name="check-page-titles-empty" value="check-page-titles" 
					<?php
					if ( 'true' === $check_page_titles_empty ) {
						echo 'checked';}
					?>
					>Page Titles</td>
					<td style="width: 33%;"><input type="checkbox" name="check-post-titles-empty" value="check-post-titles" 
					<?php
					if ( 'true' === $check_post_titles_empty ) {
						echo 'checked';}
					?>
					>Post Titles</td></tr>
								<tr colspan="2"><td><input type="submit" name="submit" value="Update" class="button button-primary" /></td></tr>
								<tr><td colspan="3"><hr style="width: 50%;"></td></tr>
					<tr class="wpsc-upgrade-pro-row"><td colspan="3"><h3 style="color: red;"><a href="https://www.wpspellcheck.com/pricing/?utm_source=baseplugin&utm_campaign=upgradeoptions&utm_medium=seo_options&utm_content=<?php echo esc_attr( $wpsc_version ); ?>" target="_blank">Upgrade to Pro</a> to scan the following</h3></td></tr>
					<tr class="wpsc-upgrade-pro-row"><td>WordPress Menus</td><td>Tag Descriptions</td><td>Category Descriptions</td></tr>
					<tr class="wpsc-upgrade-pro-row"><td>Page SEO</td><td>Post SEO</td><td>Media Files SEO</td></tr>
					<tr class="wpsc-upgrade-pro-row"><td>Media Files</td><td colspan="2">WooCommerce Products</td></tr>
				<?php } ?>
			</tbody></table>
		</div>
		<div id="wpgc-grammar-options-tab" 
		<?php
		if ( isset( $_POST['wpsc-scan-tab'] ) && 'grammar' !== $_POST['wpsc-scan-tab'] ) {
			echo 'class="hidden"';}
		?>
		>
			<table class="form-table wpsc-options-card" style="width: 75%; float: left;" role="presentation"><tbody>
								<tr><td colspan="3" style="padding-bottom: 0px;"><h3>Select whether you want to which parts of your website you'd like to scan for grammar errors. Right  now our plugin checks for the following rules: Complex Expression, Hidden Verb, Passive Voice, Possessive Ending, Redundant Expression, Contractions</h3></td></tr>
																<tr><td colspan="3" style="padding-top: 0px;"><h3 style="font-size: 17px;">The WP Spell Check Grammar feature is designed to work with WordPress Classic Editor. You will need to have it active in order to see the Grammar Scan results</h3></td></tr>
				<tr><td><div style="margin-top: 5px;"></div></td></tr>
				<tr>
					<td style="width: 33%;"><input type="checkbox" name="check-pages-grammar" value="check-pages" 
					<?php
					if ( 'true' === $grammar_pages ) {
						echo 'checked';}
					?>
					>Pages</td>
					<td><input type="checkbox" name="check-posts-grammar" value="check-posts" 
					<?php
					if ( 'true' === $grammar_posts ) {
						echo 'checked';}
					?>
					>Posts</td>
				</tr>
							<?php
							if ( ! $wpscx_ent_included ) {
								?>
								<tr class="wpsc-upgrade-pro-row"><td colspan="3"><h3 style="color: red;"><a href="https://www.wpspellcheck.com/pricing/?utm_source=baseplugin&utm_campaign=upgradeoptions&utm_medium=spellcheck_options&utm_content=<?php echo esc_attr( $wpsc_version ); ?>" target="_blank">Upgrade to Pro</a> to scan your entire site</h3></td></tr><?php } ?>
				<tr colspan="2"><td><input type="submit" name="submit" value="Update" class="button button-primary" /></td></tr>
			</table>
		</div>
		<div id="wpgc-accessibility-options-tab" 
		<?php
		if ( isset( $_POST['wpsc-scan-tab'] ) && 'accessibility' !== $_POST['wpsc-scan-tab'] ) {
			echo 'class="hidden"';}
		?>
		>
			<table class="form-table wpsc-options-card" style="width: 75%; float: left;" role="presentation"><tbody>
				<tr><td><div style="margin-top: 5px;"></div></td></tr>
				<tr>
					<td>Use OpenDyslexic Font<br />You can use the OpenDyslexic font on the website or on both the website and the admin. The OpenDyslexic font is designed to help people with dyslexia with their reading.</td>
					<td>
						<select name="wpsc_usedyslexic" id="wpsc_usedyslexic" >
							<?php
							$user_id = get_current_user_id();
							?>
							<option value="no" <?php selected( 'no', get_user_meta( $user_id, 'wpsc_usedyslexic', true ) ); ?>><?php esc_html_e( 'Do Not use the OpenDyslexic Font', 'wp-spell-check' ); ?></option>
							<option value="yes_adminonly" <?php selected( 'yes_adminonly', get_user_meta( $user_id, 'wpsc_usedyslexic', true ) ); ?>><?php esc_html_e( 'Use only on the admin area (back-end)', 'wp-spell-check' ); ?></option>
							<option value="yes_websiteonly" <?php selected( 'yes_websiteonly', get_user_meta( $user_id, 'wpsc_usedyslexic', true ) ); ?>><?php esc_html_e( 'Use only on the website (front-end)', 'wp-spell-check' ); ?></option>
							<option value="yes_everywhere" <?php selected( 'yes_everywhere', get_user_meta( $user_id, 'wpsc_usedyslexic', true ) ); ?>><?php esc_html_e( 'Use both on the website and Admin area', 'wp-spell-check' ); ?></option>
						</select>
					</td>
				</tr>
				<tr colspan="2"><td><input type="submit" name="submit" value="Update" class="button button-primary" /></td></tr>
			</table>
		</div>
		<div id="wpsc-uninstall-modal" class="wpsc-uninstall-modal" role="dialog" aria-labelledby="wpsc-uninstall-modal-title" aria-modal="true" style="display: none;">
			<div class="wpsc-uninstall-modal-overlay"></div>
			<div class="wpsc-uninstall-modal-content">
				<h2 id="wpsc-uninstall-modal-title" class="wpsc-uninstall-modal-title">Confirm cleanup and deactivation</h2>
				<p class="wpsc-uninstall-modal-message">This will clean your Dictionary and ignore list and all plugin data, then deactivate the plugin. Are you sure you want to continue?</p>
				<div class="wpsc-uninstall-modal-actions">
					<button type="button" class="button button-primary wpsc-uninstall-modal-yes">Yes, continue</button>
					<button type="button" class="button wpsc-uninstall-modal-no">Cancel</button>
				</div>
			</div>
		</div>
		<style>
			.wpsc-uninstall-modal { position: fixed; inset: 0; z-index: 100000; align-items: center; justify-content: center; }
			.wpsc-uninstall-modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
			.wpsc-uninstall-modal-content { position: relative; background: #b32d2e; color: #fff; padding: 24px 28px; border-radius: 8px; box-shadow: 0 4px 24px rgba(0,0,0,0.3); max-width: 420px; margin: 20px; }
			.wpsc-uninstall-modal-title { margin: 0 0 12px 0; font-size: 1.25em; color: #fff; }
			.wpsc-uninstall-modal-message { margin: 0 0 20px 0; line-height: 1.5; }
			.wpsc-uninstall-modal-actions { display: flex; gap: 10px; flex-wrap: wrap; }
			.wpsc-uninstall-modal-yes { background: #fff; color: #b32d2e; border-color: #fff; }
			.wpsc-uninstall-modal-yes:hover { background: #f0f0f0; color: #8a2324; border-color: #f0f0f0; }
			.wpsc-uninstall-modal-no { background: transparent; color: #fff; border-color: rgba(255,255,255,0.7); }
			.wpsc-uninstall-modal-no:hover { background: rgba(255,255,255,0.15); color: #fff; }
		</style>
		<script>
		(function() {
			function initUninstallModal() {
				var modal = document.getElementById('wpsc-uninstall-modal');
				var btn = document.getElementById('wpsc-uninstall-btn');
				var hidden = document.getElementById('wpsc-uninstall-hidden');
				var form = document.getElementById('wpsc-options-form') || (document.forms && document.forms['options']);
				var overlay = modal ? modal.querySelector('.wpsc-uninstall-modal-overlay') : null;
				var yesBtn = modal ? modal.querySelector('.wpsc-uninstall-modal-yes') : null;
				var noBtn = modal ? modal.querySelector('.wpsc-uninstall-modal-no') : null;
				function showModal() { if (modal) { modal.style.display = 'flex'; } }
				function hideModal() { if (modal) { modal.style.display = 'none'; } }
				function confirmUninstall(e) {
					if (e) { e.preventDefault(); }
					if (hidden && form) {
						hidden.value = 'Clean up Database and Deactivate Plugin';
						hideModal();
						// Use native submit so it runs even if jQuery or another script overrides form.submit
						HTMLFormElement.prototype.submit.call(form);
					}
				}
				if (btn) { btn.addEventListener('click', showModal); }
				if (overlay) { overlay.addEventListener('click', hideModal); }
				if (yesBtn) { yesBtn.addEventListener('click', confirmUninstall); }
				if (noBtn) { noBtn.addEventListener('click', hideModal); }
			}
			if (document.readyState === 'loading') {
				document.addEventListener('DOMContentLoaded', initUninstallModal);
			} else {
				initUninstallModal();
			}
		})();
		</script>
		</form>
	<?php include 'sidebar.php'; ?>
</div>
	<?php
}
?>
