includes(); add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); add_action( 'init', function () { // Only start a PHP session for requests that actually need the checkout // session (the checkout POST itself, or an AJAX call that reads/writes // $_SESSION['aimslms_checkout']) - never on plain page loads, so full-page // caching (Nginx/Varnish/managed-host caches) isn't bypassed site-wide. // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Only used to decide whether a session is needed; the actual charge amount is always re-derived server-side from course post meta (see AIMSLMS_Payment_Ajax) before any payment is created, never trusted from this value. $needs_session = ! empty( $_POST['aimslms_course_id'] ) // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Same rationale as above; only used to decide whether a session is needed. || ( isset( $_REQUEST['action'] ) && in_array( wp_unslash( $_REQUEST['action'] ), array( 'aimslms_create_paypal_order', 'aimslms_create_razorpay_order', 'aimslms_process_stripe_payment', 'aimslms_finalize_stripe_payment', 'aimslms_remove_checkout_item' ), true ) ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Same rationale as above; PayPal return/cancel redirects that read/clear the checkout session. || ( isset( $_GET['aimslms_action'] ) && in_array( wp_unslash( $_GET['aimslms_action'] ), array( 'paypal_success', 'paypal_cancel' ), true ) ); if ( $needs_session && session_status() === PHP_SESSION_NONE ) { session_start(); } $checkout_nonce_valid = isset( $_POST['aimslms_checkout_nonce_field'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['aimslms_checkout_nonce_field'] ) ), 'aimslms_checkout_nonce' ); // The actual charge amount is always re-derived server-side from course post meta // (see AIMSLMS_Payment_Ajax) before any payment is created, never trusted from this // session value; the nonce check above still guards against an unauthenticated // request silently overwriting the visitor's own checkout selection. if ( $needs_session && $checkout_nonce_valid && ! empty( $_POST['aimslms_course_id'] ) ) { $_SESSION['aimslms_checkout'] = array( 'course_id' => intval( $_POST['aimslms_course_id'] ), 'price' => isset( $_POST['aimslms_price'] ) ? floatval( $_POST['aimslms_price'] ) : 0, ); } // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Debug/manual trigger, gated by capability check below. if ( isset( $_GET['run_aimslms_cron'] ) && '1' === $_GET['run_aimslms_cron'] ) { if ( ! current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'Unauthorized', 'aims-infosoft-lms' ), '', array( 'response' => 403 ) ); } do_action( 'aimslms_check_pending_payments' ); echo esc_html__( 'Aims Infosoft LMS cron executed manually.', 'aims-infosoft-lms' ); exit; } } ); } /** * Requires the vendor autoloader (if present) and all payment gateway, webhook, * refund, and email class files, and registers the cron activation/deactivation hooks. */ private function includes() { if ( file_exists( AIMSLMS_PLUGIN_DIR . 'vendor/autoload.php' ) ) { require_once AIMSLMS_PLUGIN_DIR . 'vendor/autoload.php'; } require_once __DIR__ . '/class-aimslms-refund.php'; require_once __DIR__ . '/cron/class-aimslms-cron.php'; require_once __DIR__ . '/emails/class-aimslms-payment-emails.php'; require_once __DIR__ . '/gateways/class-aimslms-gateway-paypal.php'; require_once __DIR__ . '/webhooks/class-aimslms-webhook-paypal.php'; require_once __DIR__ . '/gateways/class-aimslms-gateway-stripe.php'; require_once __DIR__ . '/webhooks/class-aimslms-webhook-stripe.php'; require_once __DIR__ . '/gateways/class-aimslms-gateway-razorpay.php'; require_once __DIR__ . '/webhooks/class-aimslms-webhook-razorpay.php'; /* ACTIVATE */ register_activation_hook( __FILE__, array( 'AIMSLMS_Cron', 'activate' ) ); /* DEACTIVATE */ register_deactivation_hook( __FILE__, array( 'AIMSLMS_Cron', 'deactivate' ) ); } /** * Enqueues front-end payment scripts and styles. Currently a no-op placeholder. */ public function enqueue_scripts() {} }