admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'aimslms_checkout_nonce' ), 'stripe_key' => ( 'live' === get_option( 'aimslms_stripe_payment_mode' ) ) ? get_option( 'aimslms_stripe_live_publishable' ) : get_option( 'aimslms_stripe_test_publishable' ), 'razorpay_key' => $razorpay_key, ) ); } /** * Render the [aimslms_checkout] shortcode output. * * @return string Checkout template markup. */ public function render() { wp_enqueue_script( 'aimslms-checkout' ); ob_start(); include AIMSLMS_PLUGIN_DIR . 'public/templates/user/aimslms-checkout.php'; return ob_get_clean(); } /** * Whether the current front-end request is actually the checkout page * (or another page embedding the [aimslms_checkout] shortcode). Used to * avoid loading the Stripe/Razorpay checkout SDKs - which eagerly fetch * many extra script chunks on load - on every single page of the site. */ private static function is_checkout_page() { $checkout_page_id = get_option( 'aimslms_checkout_page' ); if ( $checkout_page_id && is_page( $checkout_page_id ) ) { return true; } global $post; return $post instanceof WP_Post && has_shortcode( $post->post_content, 'aimslms_checkout' ); } } new AIMSLMS_Checkout();