/**
 * Plugin Name: Revive Laptop – GST Invoice
 * Description: Custom GST invoice generator for Revive Laptop.
 * Version: 1.0.0
 * Author: Revive Laptop
 * Text Domain: revive-laptop-gst
 * Update URI: false
 */

// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;

/**
 * Plugin version.
 */
if ( ! defined( 'MMSGST_VERSION' ) ) {
	define( 'MMSGST_VERSION', '1.0.0' );
}

/**
 * Plugin directory.
 */
if ( ! defined( 'MMSGST_DIR' ) ) {
	define( 'MMSGST_DIR', plugin_dir_path( __FILE__ ) );
}

/**
 * Plugin URL.
 */
if ( ! defined( 'MMSGST_URL' ) ) {
	define( 'MMSGST_URL', plugin_dir_url( __FILE__ ) );
}

/**
 * Composer autoloader (preferred).
 */
$marginminds_gst_autoloader = MMSGST_DIR . 'vendor/autoload.php';
if ( file_exists( $marginminds_gst_autoloader ) ) {
	require_once $marginminds_gst_autoloader;
} else {
	/**
	 * Fallback PSR-4 autoloader for the plugin namespace.
	 *
	 * This will only be used when Composer's autoloader is not available.
	 *
	 * @param string $class_name Fully-qualified class name.
	 *
	 * @return void
	 */
	spl_autoload_register(
		function ( $class_name ) {
			$prefix = 'Marginminds\\Gst\\';

			/* Only handle classes in our namespace. */
			if ( 0 !== strpos( $class_name, $prefix ) ) {
				return;
			}

			// Strip the namespace prefix.
			$relative = substr( $class_name, strlen( $prefix ) );
			$parts    = explode( '\\', $relative );

			// bail early.
			if ( empty( $parts ) ) {
				return;
			}

			// Extract the class segment (last part).
			$class_segment = array_pop( $parts );

			// Map intermediate namespace parts to folder names (lowercase).
			$folders = array_map(
				function ( $p ) {
					return strtolower( $p );
				},
				$parts
			);

			// Convert class segment to kebab-case filename: - replace underscores with hyphen - lower-case - prefix with "class-".
			$filename = 'class-' . str_replace( '_', '-', strtolower( $class_segment ) ) . '.php';
			$path     = MMSGST_DIR . 'src/';
			if ( ! empty( $folders ) ) {
				$path .= implode( '/', $folders ) . '/';
			}
			$path .= $filename;
			// Require if file exists.
			if ( file_exists( $path ) ) {
				require_once $path;
			}
		}
	);
}

/**
 * Show an admin notice when WooCommerce is not active.
 *
 * @return void
 */
function marginminds_gst_missing_woocommerce_notice(): void {
	echo '<div class="notice notice-error"><p>' .
		esc_html__( 'Marginminds GST requires WooCommerce to be installed and active.', 'marginminds-gst' ) .
		'</p></div>';
}

/**
 * Initiate the plugin.
 *
 * @return void
 */
function marginminds_gst_bootstrap(): void {
	if ( ! class_exists( 'WooCommerce' ) ) {
		add_action( 'admin_notices', 'marginminds_gst_missing_woocommerce_notice' );
		return;
	}

	if ( class_exists( 'Marginminds\\Gst\\Plugin' ) ) {
		Marginminds\Gst\Plugin::instance()->init();
	}
}

add_action( 'plugins_loaded', 'marginminds_gst_bootstrap', 10 );
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://revivelaptop.com/wp-sitemap-index.xsl" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://revivelaptop.com/wp-sitemap-posts-post-1.xml</loc></sitemap><sitemap><loc>https://revivelaptop.com/wp-sitemap-posts-page-1.xml</loc></sitemap><sitemap><loc>https://revivelaptop.com/wp-sitemap-posts-product-1.xml</loc></sitemap><sitemap><loc>https://revivelaptop.com/wp-sitemap-posts-order_status-1.xml</loc></sitemap><sitemap><loc>https://revivelaptop.com/wp-sitemap-taxonomies-category-1.xml</loc></sitemap><sitemap><loc>https://revivelaptop.com/wp-sitemap-taxonomies-product_brand-1.xml</loc></sitemap><sitemap><loc>https://revivelaptop.com/wp-sitemap-taxonomies-product_cat-1.xml</loc></sitemap><sitemap><loc>https://revivelaptop.com/wp-sitemap-taxonomies-pa_adapter-watt-1.xml</loc></sitemap><sitemap><loc>https://revivelaptop.com/wp-sitemap-taxonomies-pa_pin-type-1.xml</loc></sitemap><sitemap><loc>https://revivelaptop.com/wp-sitemap-taxonomies-pa_product-version-1.xml</loc></sitemap><sitemap><loc>https://revivelaptop.com/wp-sitemap-users-1.xml</loc></sitemap></sitemapindex>
