<?php
/**
 * Main plugin class.
 *
 * Handles plugin initialization, text domain loading, and provides
 * helper methods for connection state.
 *
 * @package Memwc_Connector
 * @since   1.0.0
 */

defined( 'ABSPATH' ) || exit;

/**
 * Class Memwc_Connector
 *
 * Singleton class that bootstraps the plugin.
 */
class Memwc_Connector {

	/**
	 * Single instance of this class.
	 *
	 * @var Memwc_Connector|null
	 */
	private static $instance = null;

	/**
	 * Get the singleton instance.
	 *
	 * @return Memwc_Connector
	 */
	public static function get_instance() {
		if ( null === self::$instance ) {
			self::$instance = new self();
		}
		return self::$instance;
	}

	/**
	 * Constructor.
	 */
	private function __construct() {
		$this->init_hooks();
	}

	/**
	 * Register hooks.
	 *
	 * @return void
	 */
	private function init_hooks() {
		// Translations are loaded automatically by WordPress.org for plugins
		// hosted there (since WP 4.6), so load_plugin_textdomain() is not needed.

		if ( is_admin() ) {
			new Memwc_Admin();
		}
	}

	/**
	 * Check if the store is connected to MEM.
	 *
	 * @return bool
	 */
	public static function is_connected() {
		return (bool) get_option( 'memwc_connector_connected', false );
	}
}
