<?php //phpcs:ignore -- legacy plugin
/**
 * Plugin Name: miniOrange OTP Verification and SMS Notification for WooCommerce
 * Plugin URI: http://miniorange.com/miniorange-woocommerce-otp-plugin
 * Description: WooCommerce SMS Notification. WCFM & Dokan Notifications. SMS & Email OTP Verification for all WooCommerce forms. PasswordLess Login. 24/7 support.
 * Version: 4.4.0
 * Author: miniOrange
 * Author URI: http://miniorange.com
 * Text Domain: miniorange-sms-order-notification-otp-verification
 * Domain Path: /lang
 * WC requires at least: 2.0.0
 * WC tested up to: 8.5.2
 * License: Expat
 * License URI: https://plugins.miniorange.com/mit-license
 *
 * @package miniorange-sms-order-notification-otp-verification
 */

use WCSMSOTP\MoWcInit;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
define( 'MOVWC_PLUGIN_NAME', plugin_basename( __FILE__ ) );
$mowc_dir_name = substr( MOVWC_PLUGIN_NAME, 0, strpos( MOVWC_PLUGIN_NAME, '/' ) );
define( 'MOVWC_NAME', $mowc_dir_name );

/**
 * WooCommerce hook to show that the plugin is compatible with the HPOS functionality.
 */
add_action(
	'before_woocommerce_init',
	function () {
		if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
			\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
		}
	}
);

$mowc_autoload_file = plugin_dir_path( __FILE__ ) . 'autoload.php';
if ( ! file_exists( $mowc_autoload_file ) || ! is_readable( $mowc_autoload_file ) ) {
	// Fallback when autoload is missing: bootstrap on init so textdomain loads first.
	add_action(
		'init',
		function () {
			MoWcInit::instance();
		},
		1
	);
	return;
}

// Load textdomain and plugin at init (WordPress 6.7+: translations at init or later).
add_action(
	'init',
	function () use ( $mowc_autoload_file ) {
		load_plugin_textdomain(
			'miniorange-sms-order-notification-otp-verification',
			false,
			dirname( plugin_basename( __FILE__ ) ) . '/lang/'
		);
		do_action( 'mowc_otp_verification_add_on_lang_files' );

		require $mowc_autoload_file;
		MoWcInit::instance();
	},
	0
);
