<?php
/**
 * Plugin Name: PostGate - Paywall & Content Monetization
 * Description: Monetize your WordPress content with precision using flexible paywalls, one-time purchases, and subscriptions powered by Stripe.
 * Plugin URI: https://www.qodesphere.com/plugins/postage/
 * Author URI: https://qodesphere.com
 * Text Domain: postgate
 * Version: 1.0.3
 * Author: QodeSphere
 * Requires at least: 6.2
 * Tested up to: 6.9
 * Requires PHP: 7.4
 * License: GPL v2 or later
 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
 * 
 * PostGate is a WordPress plugin that enables content creators to monetize
 * their articles through per-article payments and subscription-based access.
 * Integrates with Stripe for secure payment processing and provides flexible
 * granular content protection for site-wide content, specific categories, or individual posts and blocks.
 * 
 * @package PostGate
 * @version 1.0.3
 * @author QodeSphere
 * @license GPL-2.0-or-later
 * @since 1.0.0
 */

defined( 'ABSPATH' ) || exit;

/**
 * PostGate Plugin Constants
 *
 * Define essential plugin constants for paths, URLs, version control,
 * and bridge server configuration.
 */

/** Plugin directory path */
define( 'POSTGATE_PATH', plugin_dir_path( __FILE__ ) );

/** Plugin directory URL */
define( 'POSTGATE_URL', plugin_dir_url( __FILE__ ) );

/** Plugin file path */
define( 'POSTGATE_PLUGIN_FILE', __FILE__ );

/** Plugin version number */
define( 'POSTGATE_VERSION', '1.0.3' );

/** Pro version flag - set to false for free version */
define( 'POSTGATE_PRO', false );

/** PostGate Bridge server URL for OAuth and webhook management */
define( 'POSTGATE_BRIDGE_URL', get_option( 'postgate_bridge_url' ) );

/** Bridge server shared secret for secure communication */
define( 'POSTGATE_BRIDGE_SHARED_SECRET', get_option( 'postgate_bridge_shared_secret' ) );

/**
 * Load Composer Dependencies
 *
 * Include Composer autoloader if it exists for managing external dependencies.
 * This is typically used for Stripe SDK and other third-party libraries.
 */
if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
	require_once __DIR__ . '/vendor/autoload.php';
}

// Load core plugin classes
require_once POSTGATE_PATH . '/includes/class-core.php';
require_once POSTGATE_PATH . '/includes/class-installation.php';

// Initialize the main plugin core after all plugins are loaded
add_action( 'plugins_loaded', function () {
	PostGate_Core::init();
} );

// Register plugin activation hook to run installation routines
register_activation_hook( __FILE__, [ 'PostGate_Installation', 'activate' ] );
