<?php
/**
 * Plugin Name:       SumeetSarna – Update Guardian
 * Description:        Catches regressions before your customers do. Snapshots your key pages and re-checks them after every plugin, theme, or core update, flagging broken pages, PHP errors, and missing features.
 * Version:           0.1.0
 * Requires at least: 6.0
 * Requires PHP:      7.4
 * Author:            Sumeet Sarna
 * License:           GPL-2.0-or-later
 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain:       sumeetsarna-update-guardian
 *
 * @package UpdateGuardian
 */

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

if ( function_exists( 'upguard_fs' ) ) {
	upguard_fs()->set_basename( true, __FILE__ );
} else {
	// DO NOT REMOVE THIS IF, IT IS ESSENTIAL FOR THE `function_exists` CALL ABOVE TO PROPERLY WORK.
	if ( ! function_exists( 'upguard_fs' ) ) {
		// Create a helper function for easy SDK access.
		function upguard_fs() {
			global $upguard_fs;

			if ( ! isset( $upguard_fs ) ) {
				// Include Freemius SDK.
				require_once dirname( __FILE__ ) . '/vendor/freemius/start.php';

				$upguard_fs = fs_dynamic_init(
					array(
						'id'                  => '33343',
						'slug'                => 'update-guardian',
						'type'                => 'plugin',
						'public_key'          => 'pk_9537042ae685873779e4485161808',
						'is_premium'          => false,
						'premium_suffix'      => 'Pro',
						'has_premium_version' => false,
						'has_addons'          => false,
						'has_paid_plans'      => true,
						'is_org_compliant'    => true,
						'menu'                => array(
							'slug'    => 'update-guardian',
							'support' => false,
							'parent'  => array(
								'slug' => 'tools.php',
							),
						),
					)
				);
			}

			return $upguard_fs;
		}

		// Init Freemius.
		upguard_fs();
		// Signal that SDK was initiated.
		do_action( 'upguard_fs_loaded' );
	}

	define( 'UPGUARD_VERSION', '0.1.0' );
	define( 'UPGUARD_PATH', plugin_dir_path( __FILE__ ) );

	require_once UPGUARD_PATH . 'includes/helpers.php';
	require_once UPGUARD_PATH . 'includes/class-client.php';
	require_once UPGUARD_PATH . 'includes/class-settings.php';
	require_once UPGUARD_PATH . 'includes/class-monitor.php';

	/**
	 * Boot the plugin's pieces once WordPress is ready.
	 */
	function upguard_init() {
		$client   = new Upguard_Client();
		$settings = new Upguard_Settings( $client );
		$monitor  = new Upguard_Monitor( $client );

		$settings->hooks();
		$monitor->hooks();
	}
	add_action( 'plugins_loaded', 'upguard_init' );
}
