'sandbox', // sandbox | live 'paypal_client_id' => '', 'paypal_client_secret' => '', 'paypal_webhook_id' => '', 'fee_percent_bps' => 349, // 3.49% 'fee_fixed_minor' => 49, 'anonymity_policy' => 'allow', // allow | require_name | force_anonymous 'moderate_messages' => false, 'profanity_filter' => true, // streamer-controlled master switch 'profanity_use_builtin' => true, // small built-in list 'profanity_words' => '', // streamer's extra words, one per line 'message_max_length' => 200, 'min_donation_minor' => 100, 'donation_notice' => 'Donations are non-refundable.', // shown under the donation form; empty hides it 'overlay_token' => '', 'visitor_ip_header' => 'auto', // auto | '' (direct) | cloudflare | real_ip | forwarded (see Core\ClientIp) 'funding_paylater' => false, // show PayPal "Pay Later" button 'update_token' => '', // optional Gitea read token (only while the update repo is private) 'funding_card' => true, // show the Debit/Credit Card button 'delete_data_on_uninstall' => false, // when the plugin is deleted, also drop all tables/options (see Core\Uninstaller) ); } public static function all(): array { $saved = get_option( 'sg_settings', array() ); return array_merge( self::defaults(), is_array( $saved ) ? $saved : array() ); } public static function get( string $key, mixed $default = null ): mixed { $all = self::all(); return $all[ $key ] ?? $default; } public static function update( array $values ): void { $allowed = array_intersect_key( $values, self::defaults() ); update_option( 'sg_settings', array_merge( self::all(), $allowed ), false ); } /** Generates the overlay token if none is stored (a DB write: only from activation or an authenticated admin screen). */ public static function ensure_overlay_token(): string { $token = (string) self::get( 'overlay_token', '' ); if ( strlen( $token ) < 32 ) { $token = bin2hex( random_bytes( 16 ) ); self::update( array( 'overlay_token' => $token ) ); } return $token; } public static function fee_calculator(): FeeCalculator { return new FeeCalculator( (int) self::get( 'fee_percent_bps' ), (int) self::get( 'fee_fixed_minor' ) ); } }