'Donors choose: they can give a name or stay anonymous', 'require_name' => 'Donors must give a name', 'force_anonymous' => 'Everyone is anonymous (no names are collected or stored)', ); public static function render(): void { Admin::open( 'StreamGoals settings' ); $s = Settings::all(); $cur = Admin::currency(); echo '

PayPal connection

'; echo PayPalConnector::isConnected() ? '

Connected (' . esc_html( 'live' === $s['paypal_mode'] ? 'Live' : 'Sandbox' ) . ').

' : '

Not connected yet. Follow the steps in the setup guide.

'; Admin::form( 'sg_paypal_connect', array( 'return' => 'settings' ) ); PayPalConnector::fields(); echo '

Webhook address (registered automatically): ' . esc_html( PayPalConnector::webhookUrl() ) . '
Webhook status: ' . ( '' !== (string) $s['paypal_webhook_id'] ? 'registered' : 'not registered' ) . '

'; echo '

'; Admin::form( 'sg_settings_save' ); echo '

Donations

'; echo ''; echo ''; echo ''; echo ''; echo '
'; echo '

Messages

'; echo ''; echo '
'; echo '

Checkout buttons

'; echo '

Advanced

'; $rel = \StreamGoals\Update\Updater::latest(); echo '

Plugin updates

'; echo ''; echo ''; echo '
'; echo '

PayPal fee estimate

'; echo '

When a donor chooses "cover the fees", the form adds the estimated PayPal fee so you receive the amount they intended. The defaults (3.49% + $0.49) are US domestic estimates. Fees for international (cross-border) payments and currency conversion are higher and are not included, so you may receive slightly less than expected in those cases. Check PayPal\'s current fee page for your country and adjust.

'; echo ''; echo '
'; echo '

'; echo '
'; wp_nonce_field( \StreamGoals\Update\Updater::ACTION_CHECK ); echo '
'; Admin::close(); } /** Shows the owner what their server passes to the plugin right now, to help pick the right option. */ private static function ipDiagnostics( string $mode ): void { $keys = array( 'REMOTE_ADDR' => 'Connection address', 'HTTP_CF_CONNECTING_IP' => 'CF-Connecting-IP', 'HTTP_CF_RAY' => 'CF-Ray', 'HTTP_X_REAL_IP' => 'X-Real-IP', 'HTTP_X_FORWARDED_FOR' => 'X-Forwarded-For' ); $server = array(); foreach ( $keys as $k => $_ ) { if ( isset( $_SERVER[ $k ] ) && is_string( $_SERVER[ $k ] ) ) { $server[ $k ] = sanitize_text_field( wp_unslash( $_SERVER[ $k ] ) ); } } echo '
What does my server see right now?'; foreach ( $keys as $k => $label ) { echo ''; } $viaCf = isset( $server['REMOTE_ADDR'] ) && \StreamGoals\Core\CloudflareRanges::isCloudflare( $server['REMOTE_ADDR'], (array) apply_filters( 'streamgoals_cloudflare_ranges', array() ) ); echo ''; echo ''; echo '
' . esc_html( $label ) . '' . ( isset( $server[ $k ] ) ? esc_html( $server[ $k ] ) : '(not sent)' ) . '
Is this connection from Cloudflare?' . ( $viaCf ? 'Yes - the connection comes from a Cloudflare address' : 'No' ) . '
Visitor address used with the saved option' . esc_html( \StreamGoals\Core\ClientIp::resolve( $server, $mode ) ) . '
' . ( ! $viaCf && ( isset( $server['HTTP_CF_RAY'] ) || isset( $server['HTTP_CF_CONNECTING_IP'] ) ) ? '

Cloudflare headers were sent, but the connection is not from a known Cloudflare address, so "Automatic" ignores them. If your site really is behind Cloudflare, choose "Cloudflare" above (or update the plugin, as Cloudflare may have added new addresses).

' : '' ) . '

This is your own visit. If the connection address belongs to your proxy or CDN (not to you) and your proxy\'s header shows your real address, choose that proxy option above and save. Then the "used" row should show your real address.

'; } public static function handleSave(): void { Admin::guard( 'sg_settings_save' ); $post = Admin::post_raw(); $back = Admin::url( 'streamgoals-settings' ); $errors = array(); $cur = Format::currency( $post['currency'] ?? 'USD' ); $upd = array(); $min = Input::amountToMinor( $post['min_donation'] ?? '', $cur ); if ( null === $min || $min < \StreamGoals\Core\Settings::HARD_MIN_MINOR ) { $errors[] = 'Minimum donation must be at least ' . Format::money( \StreamGoals\Core\Settings::HARD_MIN_MINOR, $cur ) . '. PayPal\'s fixed fee makes smaller donations lose money.'; } else { $upd['min_donation_minor'] = $min; } $len = Input::int( $post['message_max_length'] ?? '', 0, 500 ); if ( null === $len ) { $errors[] = 'Longest message must be a number from 0 to 500.'; } else { $upd['message_max_length'] = $len; } $pct = Input::percentToBps( $post['fee_percent'] ?? '' ); if ( null === $pct ) { $errors[] = 'Percentage fee must be between 0 and 30 (for example 3.49).'; } else { $upd['fee_percent_bps'] = $pct; } $fix = Input::amountToMinor( $post['fee_fixed'] ?? '', $cur ); if ( null === $fix || $fix > 10000 ) { $errors[] = 'Fixed fee must be a small amount (for example 0.49).'; } else { $upd['fee_fixed_minor'] = $fix; } $pol = isset( $post['anonymity_policy'] ) && is_string( $post['anonymity_policy'] ) ? $post['anonymity_policy'] : ''; if ( ! isset( self::POLICIES[ $pol ] ) ) { $errors[] = 'Please choose a names option.'; } else { $upd['anonymity_policy'] = $pol; } $ipMode = isset( $post['visitor_ip_header'] ) && is_string( $post['visitor_ip_header'] ) ? $post['visitor_ip_header'] : ''; if ( ! array_key_exists( $ipMode, \StreamGoals\Core\ClientIp::MODES ) ) { $errors[] = 'Please choose a visitor IP option.'; } else { $upd['visitor_ip_header'] = $ipMode; } $tok = $post['update_token'] ?? ''; if ( ! Input::secretUnchanged( is_string( $tok ) ? $tok : '' ) ) { $upd['update_token'] = Input::text( $tok, 300 ); } $upd['funding_card'] = ! empty( $post['funding_card'] ); $upd['funding_paylater'] = ! empty( $post['funding_paylater'] ); $upd['donation_notice'] = Input::text( $post['donation_notice'] ?? '', 200 ); $upd['moderate_messages'] = ! empty( $post['moderate_messages'] ); $upd['profanity_filter'] = ! empty( $post['profanity_filter'] ); $upd['profanity_use_builtin'] = ! empty( $post['profanity_use_builtin'] ); $upd['profanity_words'] = Input::words( isset( $post['profanity_words'] ) && is_string( $post['profanity_words'] ) ? $post['profanity_words'] : '' ); Settings::update( $upd ); update_option( 'sg_currency', $cur, false ); // Settings has no currency key, so it lives in its own option. if ( $errors ) { Admin::redirect( $back, 'warning', 'Some settings were not saved: ' . implode( ' ', $errors ) . ' Everything else was saved.' ); } Admin::redirect( $back, 'success', 'Settings saved.' ); } }