echoPayPalConnector::isConnected()?'<p class="sg-ok">Connected ('.esc_html('live'===$s['paypal_mode']?'Live':'Sandbox').').</p>':'<p class="sg-warn">Not connected yet. Follow the steps in the <a href="'.esc_url(SetupPage::url(1)).'">setup guide</a>.</p>';
echo'</select><p class="description">One currency for the whole site. It applies to goals you create from now on; existing goals keep their currency. Check the fixed fee below after changing it.</p></td></tr>';
echo'<tr><th scope="row"><label for="sg_notice">Notice under the donation form</label></th><td><input type="text" id="sg_notice" name="donation_notice" class="large-text" maxlength="200" value="'.esc_attr((string)$s['donation_notice']).'"><p class="description">Shown right under the PayPal buttons so donors see it before paying. Plain text, up to 200 characters. The default says donations are non-refundable. Leave it empty to hide the notice.</p></td></tr>';
echo'<tr><th scope="row">Moderation</th><td><label><input type="checkbox" name="moderate_messages" value="1"'.checked(!empty($s['moderate_messages']),true,false).'> Hold messages for my approval before they can be shown in alerts</label></td></tr>';
echo'<tr><th scope="row">Profanity filter</th><td><label><input type="checkbox" name="profanity_filter" value="1"'.checked(!empty($s['profanity_filter']),true,false).'> Filter bad language in messages and names</label><br>';
echo'<label><input type="checkbox" name="profanity_use_builtin" value="1"'.checked(!empty($s['profanity_use_builtin']),true,false).'> Use the built-in word list</label>';
echo'<p><label for="sg_words">Your own words to block (one per line)</label><br><textarea id="sg_words" name="profanity_words" rows="6" class="large-text code">'.esc_textarea((string)$s['profanity_words']).'</textarea></p></td></tr></table></div>';
echo'<label><input type="checkbox" name="funding_card" value="1"'.checked(!empty($s['funding_card']),true,false).'> Show "Debit or Credit Card" (donors without a PayPal account)</label><br>';
echo'<label><input type="checkbox" name="funding_paylater" value="1"'.checked(!empty($s['funding_paylater']),true,false).'> Show "Pay Later" (donors pay in instalments; you are still paid in full)</label>';
echo'<p class="description">The PayPal button is always shown. Which extra buttons appear can also depend on the donor\'s country.</p></td></tr></table></div>';
echo'<div class="sg-card"><h2>Advanced</h2><table class="form-table" role="presentation"><tr><th scope="row"><label for="sg_ip">Visitor IP address</label></th><td><select id="sg_ip" name="visitor_ip_header">';
echo'</select><p class="description">Donation forms limit how fast one visitor can start payments (to stop abuse). Behind a proxy, every visitor can look like the same address, and a busy moment, like a raid, could block donations. <strong>Automatic</strong> recognises Cloudflare by its published addresses and counts each visitor separately; it ignores forged headers from anywhere else. For another kind of proxy, choose its option here, but only if <em>all</em> traffic to your site really goes through it.</p>';
echo'<tr><th scope="row">Uninstall</th><td><label><input type="checkbox" name="delete_data_on_uninstall" value="1"'.checked(!empty($s['delete_data_on_uninstall']),true,false).'> Delete all data when the plugin is deleted</label>';
echo'<p class="description"><strong>When you delete the plugin from the Plugins screen, also delete ALL donations, goals, rules, rewards, alerts, tiers and settings. This cannot be undone. Leave off to keep your data if you reinstall later.</strong></p></td></tr></table></div>';
echo'<tr><th scope="row">Latest release</th><td>'.($rel?'<code>'.esc_html($rel['version']).'</code>'.(\StreamGoals\Update\ReleaseParser::isNewer($rel['version'],STREAMGOALS_VERSION)?' (update available)':' (up to date)'):'Not found yet (or the check failed).').' <button type="submit" form="sg_update_check_form" class="button">Check for updates now</button></td></tr>';
echo'<tr><th scope="row"><label for="sg_utoken">Access token (only needed while the update repository is private)</label></th><td><input type="password" id="sg_utoken" name="update_token" class="regular-text code" autocomplete="new-password" spellcheck="false" value="" placeholder="'.esc_attr(''!==(string)$s['update_token']?Input::maskSecret((string)$s['update_token']):'Paste a read-only token').'">';
echo'<p class="description">'.(''!==(string)$s['update_token']?'A token is saved. Leave this empty to keep it, or paste a new one to replace it.':'Not needed once the repository is public.').'</p></td></tr></table></div>';
echo'<p>When a donor chooses "cover the fees", the form adds the estimated PayPal fee so you receive the amount they intended. The defaults (<strong>3.49% + $0.49</strong>) are <strong>US domestic estimates</strong>. Fees for international (cross-border) payments and currency conversion are higher and are <strong>not</strong> included, so you may receive slightly less than expected in those cases. Check PayPal\'s current fee page for your country and adjust.</p>';
echo'<tr><td>Is this connection from Cloudflare?</td><td>'.($viaCf?'<strong>Yes</strong> - the connection comes from a Cloudflare address':'No').'</td></tr>';
echo'<tr><td><strong>Visitor address used with the saved option</strong></td><td><code>'.esc_html(\StreamGoals\Core\ClientIp::resolve($server,$mode)).'</code></td></tr>';
echo'</tbody></table>'.(!$viaCf&&(isset($server['HTTP_CF_RAY'])||isset($server['HTTP_CF_CONNECTING_IP']))?'<p class="sg-warn">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).</p>':'').'<p class="description">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.</p></details>';
$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.';