<?php
/**
 * Plugin Name: TechDex Search Scrape Guard
 * Description: Protects public WordPress search from abusive queries, deep pagination, automation, and search-rate spikes before the main search query runs.
 * Version: 0.4.1
 * Author: Dexter Nelson | TechDex Development and Solutions
 * Author URI: https://techdex.net/
 * License: GPLv2 or later
 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain: techdex-search-scrape-guard
 * Domain Path: /languages
 * Requires at least: 6.0
 * Requires PHP: 7.4
 */

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

define( 'TDSSG_VERSION', '0.4.1' );
define( 'TDSSG_FILE', __FILE__ );
define( 'TDSSG_DIR', plugin_dir_path( __FILE__ ) );

require_once TDSSG_DIR . 'includes/class-tdssg-settings.php';
require_once TDSSG_DIR . 'includes/class-tdssg-rate-limiter.php';
require_once TDSSG_DIR . 'includes/class-tdssg-logger.php';
require_once TDSSG_DIR . 'includes/class-tdssg-guard.php';
require_once TDSSG_DIR . 'includes/class-tdssg-admin.php';

/**
 * Start the plugin.
 */
function tdssg_init() {
	TDSSG_Logger::maybe_upgrade();
	TDSSG_Guard::init();
	TDSSG_Admin::init();
}
add_action( 'plugins_loaded', 'tdssg_init' );

/**
 * Create bounded storage on activation.
 */
function tdssg_activate() {
	TDSSG_Rate_Limiter::activate();
	TDSSG_Logger::install();
}
register_activation_hook( TDSSG_FILE, 'tdssg_activate' );
