register_settings(); } public function register_settings(): void { register_setting( Constants::OPTION_GROUP, Constants::OPTION_PREFIX . 'articlevault_enabled', array( 'type' => 'boolean', 'default' => true, 'sanitize_callback' => array( $this, 'sanitize_checkbox' ), ) ); register_setting( Constants::OPTION_GROUP, Constants::OPTION_PREFIX . 'articlevault_article_price', array( 'type' => 'string', 'default' => Constants::DEFAULT_PRICE, 'sanitize_callback' => array( $this, 'sanitize_price' ), ) ); register_setting( Constants::OPTION_GROUP, Constants::OPTION_PREFIX . 'stripe_mode', array( 'type' => 'string', 'default' => Constants::DEFAULT_STRIPE_MODE, 'sanitize_callback' => array( $this, 'sanitize_stripe_mode' ), ) ); register_setting( Constants::OPTION_GROUP, Constants::OPTION_PREFIX . 'stripe_test_publishable_key', array( 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', ) ); register_setting( Constants::OPTION_GROUP, Constants::OPTION_PREFIX . 'stripe_test_secret_key', array( 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', ) ); register_setting( Constants::OPTION_GROUP, Constants::OPTION_PREFIX . 'stripe_live_publishable_key', array( 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', ) ); register_setting( Constants::OPTION_GROUP, Constants::OPTION_PREFIX . 'stripe_live_secret_key', array( 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', ) ); register_setting( Constants::OPTION_GROUP, Constants::OPTION_PREFIX . 'stripe_webhook_secret', array( 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', ) ); add_settings_section( 'articlevault_general', 'General Settings', array( $this, 'render_general_section' ), Constants::SETTINGS_PAGE_SLUG ); add_settings_field( Constants::OPTION_PREFIX . 'articlevault_enabled', 'Enable ArticleVault', array( $this, 'render_enabled_field' ), Constants::SETTINGS_PAGE_SLUG, 'articlevault_general' ); add_settings_field( Constants::OPTION_PREFIX . 'articlevault_article_price', 'Default Article Price (USD)', array( $this, 'render_price_field' ), Constants::SETTINGS_PAGE_SLUG, 'articlevault_general' ); add_settings_section( 'articlevault_stripe', 'Stripe Settings', array( $this, 'render_stripe_section' ), Constants::SETTINGS_PAGE_SLUG ); add_settings_field( Constants::OPTION_PREFIX . 'stripe_mode', 'Stripe Mode', array( $this, 'render_stripe_mode_field' ), Constants::SETTINGS_PAGE_SLUG, 'articlevault_stripe' ); add_settings_field( Constants::OPTION_PREFIX . 'stripe_test_publishable_key', 'Test Publishable Key', array( $this, 'render_test_publishable_key_field' ), Constants::SETTINGS_PAGE_SLUG, 'articlevault_stripe' ); add_settings_field( Constants::OPTION_PREFIX . 'stripe_test_secret_key', 'Test Secret Key', array( $this, 'render_test_secret_key_field' ), Constants::SETTINGS_PAGE_SLUG, 'articlevault_stripe' ); add_settings_field( Constants::OPTION_PREFIX . 'stripe_live_publishable_key', 'Live Publishable Key', array( $this, 'render_live_publishable_key_field' ), Constants::SETTINGS_PAGE_SLUG, 'articlevault_stripe' ); add_settings_field( Constants::OPTION_PREFIX . 'stripe_live_secret_key', 'Live Secret Key', array( $this, 'render_live_secret_key_field' ), Constants::SETTINGS_PAGE_SLUG, 'articlevault_stripe' ); add_settings_field( Constants::OPTION_PREFIX . 'stripe_webhook_secret', 'Webhook Signing Secret', array( $this, 'render_webhook_secret_field' ), Constants::SETTINGS_PAGE_SLUG, 'articlevault_stripe' ); } public function is_enabled(): bool { return (bool) get_option( Constants::OPTION_PREFIX . 'articlevault_enabled', true ); } public function get_default_price(): string { return get_option( Constants::OPTION_PREFIX . 'articlevault_article_price', Constants::DEFAULT_PRICE ); } public function get_stripe_mode(): string { return get_option( Constants::OPTION_PREFIX . 'stripe_mode', Constants::DEFAULT_STRIPE_MODE ); } public function get_stripe_publishable_key(): string { $mode = $this->get_stripe_mode(); return get_option( Constants::OPTION_PREFIX . 'stripe_' . $mode . '_publishable_key', '' ); } public function get_stripe_secret_key(): string { $mode = $this->get_stripe_mode(); return get_option( Constants::OPTION_PREFIX . 'stripe_' . $mode . '_secret_key', '' ); } public function get_stripe_webhook_secret(): string { return get_option( Constants::OPTION_PREFIX . 'stripe_webhook_secret', '' ); } public function render_general_section(): void { echo '

Configure the core settings for ArticleVault Pro.

'; } public function render_stripe_section(): void { echo '

Connect Stripe Checkout to process premium article purchases.

'; } public function render_enabled_field(): void { $value = $this->is_enabled(); ?> > get_default_price(); ?> get_stripe_mode(); ?> render_text_input( 'stripe_test_publishable_key' ); } public function render_test_secret_key_field(): void { $this->render_password_input( 'stripe_test_secret_key' ); } public function render_live_publishable_key_field(): void { $this->render_text_input( 'stripe_live_publishable_key' ); } public function render_live_secret_key_field(): void { $this->render_password_input( 'stripe_live_secret_key' ); } public function render_webhook_secret_field(): void { $this->render_password_input( 'stripe_webhook_secret' ); echo '

Stripe webhook endpoint: ' . esc_html( home_url( '/?articlevault_stripe_webhook=1' ) ) . '

'; } private function render_text_input( string $option_key ): void { $name = Constants::OPTION_PREFIX . $option_key; $value = get_option( $name, '' ); ?>