<?php

/**
 * Freemius SDK initialization.
 *
 * This file initializes the Freemius SDK for licensing, updates,
 * and account management. It must be loaded before any other plugin code.
 *
 * @package MediaTasker
 */
// Prevent direct file access.
if ( !defined( 'ABSPATH' ) ) {
    exit;
}
if ( !function_exists( 'mediat_fs' ) ) {
    // Create a helper function for easy SDK access.
    function mediat_fs() {
        global $mediat_fs;
        if ( !isset( $mediat_fs ) ) {
            // Include Freemius SDK.
            require_once dirname( __FILE__ ) . '/../vendor/freemius/start.php';
            $mediat_fs = fs_dynamic_init( array(
                'id'               => '26039',
                'slug'             => 'mediatasker',
                'premium_slug'     => 'mediatasker-pro',
                'type'             => 'plugin',
                'public_key'       => 'pk_f7a72ec64e8175fd4c681967a36b0',
                'is_premium'       => false,
                'premium_suffix'   => 'Pro',
                'has_addons'       => false,
                'has_paid_plans'   => true,
                'is_org_compliant' => true,
                'menu'             => array(
                    'slug'    => 'mediatasker',
                    'support' => false,
                ),
                'is_live'          => true,
            ) );
        }
        return $mediat_fs;
    }

    // Init Freemius.
    mediat_fs();
    // Signal that SDK was initiated.
    do_action( 'mediat_fs_loaded' );
}
/*
|--------------------------------------------------------------------------
| Freemius Uninstall Cleanup
|--------------------------------------------------------------------------
| Register a cleanup function that Freemius will call after the
| plugin is uninstalled. This supplements uninstall.php for
| Freemius-specific data.
| */
/**
 * Clean up Freemius-specific data on uninstall.
 *
 * @return void
 */
function mediat_fs_uninstall_cleanup() {
    global $wpdb;
    $table_name = esc_sql( $wpdb->prefix . 'mediat_work_logs' );
    // Drop table requires a direct query. We use esc_sql to satisfy WPCS and PluginCheck.
    // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQL.NotPrepared
    $wpdb->query( "DROP TABLE IF EXISTS `{$table_name}`" );
    delete_option( 'mediat_options' );
}

mediat_fs()->add_action( 'after_uninstall', 'mediat_fs_uninstall_cleanup' );