<?php

/**
 * Plugin Name:       Bingo Car Rental
 * Plugin URI:        https://bingorentals.com
 * Description:       Full-featured car rental booking system. Manage your fleet, reservations, locations and pricing entirely inside WordPress — no external service required.
 * Version:           1.0.59
 * Author:            BitsHost Team
 * License:           GPL v2 or later
 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain:       bingocar
 * Domain Path:       /languages
 * Requires at least: 6.0
 * Tested up to:      7.0
 * Requires PHP:      8.1
 */
if ( !defined( 'ABSPATH' ) ) {
    exit;
}
define( 'BINGOCR_VERSION', '1.0.59' );
define( 'BINGOCR_DB_VERSION', '1.2' );
define( 'BINGOCR_DIR', plugin_dir_path( __FILE__ ) );
define( 'BINGOCR_URL', plugin_dir_url( __FILE__ ) );
define( 'BINGOCR_FILE', __FILE__ );
// ── Freemius SDK bootstrap ────────────────────────────────────────────────────
// SDK lives in /vendor/freemius/ (bundled with the plugin). The file_exists guard
// keeps the plugin loading even if the SDK folder is missing — BingoCR_License
// handles bingocr_fs() returning null and the plugin runs as a free plugin.
if ( !function_exists( 'bingocr_fs' ) ) {
    // Create a helper function for easy SDK access.
    function bingocr_fs() {
        global $bingocr_fs;
        if ( !isset( $bingocr_fs ) ) {
            // Include Freemius SDK. Guarded so a missing SDK folder degrades to a free
            // plugin (bingocr_fs() returns null, which BingoCR_License handles) instead
            // of a fatal error.
            $bingocr_sdk = dirname( __FILE__ ) . '/vendor/freemius/start.php';
            if ( !file_exists( $bingocr_sdk ) ) {
                $bingocr_fs = null;
                return $bingocr_fs;
            }
            require_once $bingocr_sdk;
            $bingocr_fs = fs_dynamic_init( array(
                'id'               => '31971',
                'slug'             => 'bingocar',
                'type'             => 'plugin',
                'public_key'       => 'pk_c8b73bab667232387259122993b3f',
                'is_premium'       => false,
                'premium_suffix'   => 'Business',
                'has_addons'       => false,
                'has_paid_plans'   => true,
                'is_org_compliant' => true,
                'trial'            => array(
                    'days'               => 7,
                    'is_require_payment' => true,
                ),
                'menu'             => array(
                    'slug' => 'bingocr',
                ),
                'is_live'          => true,
            ) );
        }
        return $bingocr_fs;
    }

    // Init Freemius.
    bingocr_fs();
    // Signal that SDK was initiated.
    do_action( 'bingocr_fs_loaded' );
}
// ─────────────────────────────────────────────────────────────────────────────
foreach ( array(
    'class-bingocr-license',
    // must load before everything else
    'class-bingocr-crypto',
    // secret encryption at rest (used by settings + PayPal)
    'class-bingocr-activator',
    'class-bingocr-db',
    'class-bingocr-pricing',
    'class-bingocr-email',
    'class-bingocr-rest-api',
    'class-bingocr-shortcode',
    'class-bingocr-admin',
    'class-bingocr',
) as $bingocr_file ) {
    require_once BINGOCR_DIR . 'includes/' . $bingocr_file . '.php';
}
// Premium-only files — Freemius strips these from the free build. The
// `__premium_only` filename suffix is Freemius's reliable strip marker (the
// `@fs_premium_only` docblock tag alone did NOT strip them). Loaded conditionally
// so the free build, where they're absent, never fatals. Every reference is also
// guarded with class_exists().
foreach ( array(
    'class-bingocr-premium__premium_only',
    // extras, discounts, out-of-hours fee (server logic)
    'class-bingocr-paypal__premium_only',
    // online payments (PayPal)
    'class-bingocr-rest-premium__premium_only',
) as $bingocr_premium_file ) {
    $bingocr_premium_path = BINGOCR_DIR . 'includes/' . $bingocr_premium_file . '.php';
    if ( file_exists( $bingocr_premium_path ) ) {
        require_once $bingocr_premium_path;
    }
}
register_activation_hook( BINGOCR_FILE, array('BingoCR_Activator', 'activate') );
register_deactivation_hook( BINGOCR_FILE, array('BingoCR_Activator', 'deactivate') );
// Uninstall cleanup runs through Freemius's after_uninstall action — NOT an
// uninstall.php file, which Freemius forbids (it would block uninstall tracking).
$bingocr_fs_instance = ( function_exists( 'bingocr_fs' ) ? bingocr_fs() : null );
if ( $bingocr_fs_instance ) {
    $bingocr_fs_instance->add_action( 'after_uninstall', array('BingoCR_Activator', 'uninstall') );
}
add_action( 'plugins_loaded', array('BingoCR', 'instance') );