<?php

/**
 * Plugin Name:       Intouch Orphan Table Cleaner
 * Plugin URI:        https://dev.intouchdesign.it/plugin/intouch-orphan-table-cleaner/
 * Description:       Clean and optimize your WordPress database by removing orphan tables safely.
 * Version:           1.1.5
 * Author:            InTouchDesign
 * Author URI:        https://dev.intouchdesign.it/
 * License:           GPL-2.0+
 * License URI:       http://www.gnu.org/licenses/gpl-2.0.txt
 * Text Domain:       intouch-orphan-table-cleaner
 * Domain Path:       /languages
 */
// Security: Prevent direct access to plugin files.
defined( 'ABSPATH' ) || exit;
// Single source of truth for asset cache-busting; keep in sync with the Version header above.
if ( !defined( 'IOTC_VERSION' ) ) {
    define( 'IOTC_VERSION', '1.1.5' );
}
if ( function_exists( 'iotc_fs' ) ) {
    // Another copy of this plugin (e.g. Free + Premium coexisting after an
    // upload) already declared everything below in this request. Only let
    // Freemius refresh its basename tracking; do not redeclare anything.
    iotc_fs()->set_basename( false, __FILE__ );
} else {
    /**
     * DO NOT REMOVE THIS IF, IT IS ESSENTIAL FOR THE `function_exists`
     * CALL ABOVE TO PROPERLY WORK.
     */
    if ( !function_exists( 'iotc_fs' ) ) {
        // Create a helper function for easy SDK access.
        function iotc_fs() {
            global $iotc_fs;
            if ( !isset( $iotc_fs ) ) {
                // Include Freemius SDK.
                require_once dirname( __FILE__ ) . '/vendor/freemius/start.php';
                $iotc_fs = fs_dynamic_init( array(
                    'id'               => '33404',
                    'slug'             => 'intouch_orphan_table_cleaner',
                    'type'             => 'plugin',
                    'public_key'       => 'pk_f2815cff56ef809e24217279d96a1',
                    'is_premium'       => false,
                    'has_addons'       => false,
                    'has_paid_plans'   => true,
                    'is_org_compliant' => true,
                    'menu'             => false,
                    'is_live'          => true,
                ) );
            }
            return $iotc_fs;
        }

        // Init Freemius.
        iotc_fs();
        // Signal that SDK was initiated.
        do_action( 'iotc_fs_loaded' );
    }
    // Register activation and deactivation hooks for the cron
    // We need to require the Cron class specifically for the hooks if the Core is not loaded yet.
    function iotc_plugin_activate() {
        require_once plugin_dir_path( __FILE__ ) . 'includes/class-iotc-cron.php';
        IOTC_Cron::activate();
    }

    register_activation_hook( __FILE__, 'iotc_plugin_activate' );
    function iotc_plugin_deactivate() {
        require_once plugin_dir_path( __FILE__ ) . 'includes/class-iotc-cron.php';
        IOTC_Cron::deactivate();
    }

    register_deactivation_hook( __FILE__, 'iotc_plugin_deactivate' );
    // Include the Core class and initialize
    function iotc_run_plugin() {
        require_once plugin_dir_path( __FILE__ ) . 'includes/class-iotc-core.php';
        new IOTC_Core();
    }

    iotc_run_plugin();
}