LICENSE, clean uninstall (opt-in data removal), privacy policy text, Update URI header
Test and Release / test (push) Successful in 1m28s
Test and Release / release (push) Successful in 4s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
shadowdaoandClaude Sonnet 5.5 committed 2026-11-15 14:00:04 -08:00
1 parent fb200594ce
commit 68bd917660
11 files changed
+669 -1

No files matched your search

+4 -1
View File
@@ -59,7 +59,9 @@ final class SettingsPage {
}
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>';
self::ipDiagnostics( (string) $s['visitor_ip_header'] );
echo '</td></tr></table></div>';
echo '</td></tr>';
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>';
$rel = \StreamGoals\Update\Updater::latest();
echo '<div class="sg-card"><h2>Plugin updates</h2><table class="form-table" role="presentation">';
@@ -148,6 +150,7 @@ final class SettingsPage {
}
$upd['funding_card'] = ! empty( $post['funding_card'] );
$upd['funding_paylater'] = ! empty( $post['funding_paylater'] );
$upd['delete_data_on_uninstall'] = ! empty( $post['delete_data_on_uninstall'] );
$upd['donation_notice'] = Input::text( $post['donation_notice'] ?? '', 200 );
$upd['moderate_messages'] = ! empty( $post['moderate_messages'] );
$upd['profanity_filter'] = ! empty( $post['profanity_filter'] );
+1
View File
@@ -20,6 +20,7 @@ final class Plugin {
public static function boot(): void {
Installer::maybe_upgrade();
Maintenance::register();
Privacy::register();
foreach ( self::MODULES as $module ) {
if ( class_exists( $module ) && method_exists( $module, 'register' ) ) {
$module::register();
+47
View File
@@ -0,0 +1,47 @@
<?php
declare( strict_types=1 );
namespace StreamGoals\Core;
/** Suggested privacy-policy text (Settings > Privacy > Policy Guide). Describes only what the code actually does. */
final class Privacy {
public const DOMAIN = 'streamgoals-donate';
public static function register(): void {
add_action( 'admin_init', array( self::class, 'add_policy_content' ) );
}
public static function add_policy_content(): void {
if ( ! function_exists( 'wp_add_privacy_policy_content' ) ) {
return;
}
wp_add_privacy_policy_content( 'StreamGoals Donate', self::content() );
}
/** @param callable|null $t Translator taking one string (defaults to WordPress' __ with this text domain). */
public static function content( ?callable $t = null ): string {
$t ??= static fn( string $s ): string => __( $s, self::DOMAIN ); // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
$html = '<div class="wp-suggested-text">';
$html .= '<p class="privacy-policy-tutorial">' . $t( 'Suggested text for your privacy policy. Review it and adjust it to how you use the plugin, and to the laws that apply to you.' ) . '</p>';
$html .= '<strong class="privacy-policy-tutorial">' . $t( 'Suggested text:' ) . '</strong> ';
$html .= '<h2>' . $t( 'Donations' ) . '</h2>';
$html .= '<p>' . $t( 'When you make a donation on this site, we store the amount, the currency, the date and time, the PayPal order and capture identifiers, and the display name you entered, unless you chose to donate anonymously. The name of an anonymous donor is never stored. If you write a message with your donation, we store that message too, so please do not put personal details in it.' ) . '</p>';
$html .= '<p>' . $t( 'We do not store your email address, postal address or payment card details. Payments are processed by PayPal, which collects and handles those details under its own privacy statement:' ) . ' <a href="https://www.paypal.com/webapps/mpp/ua/privacy-full" target="_blank" rel="noopener noreferrer">https://www.paypal.com/webapps/mpp/ua/privacy-full</a></p>';
$html .= '<p>' . $t( 'The donation form loads PayPal\'s payment script from paypal.com, so PayPal receives your IP address and browser information when the form is shown.' ) . '</p>';
$html .= '<h2>' . $t( 'How long we keep data' ) . '</h2>';
$html .= '<p>' . $t( 'Donation records are kept until the site owner deletes them. The site owner can export them as a CSV file. Checkouts that were started but never paid are removed automatically after a week.' ) . '</p>';
$html .= '<h2>' . $t( 'Abuse protection' ) . '</h2>';
$html .= '<p>' . $t( 'To stop abuse, the number of donation requests from one visitor is limited. For this, a one-way hash of the visitor\'s IP address is used as the name of a temporary cache entry (a WordPress transient) that expires after a few minutes. The IP address itself is not written to the donation records. Expired entries can remain in the database until WordPress cleans them up, and on sites with a persistent object cache they are kept in that cache instead.' ) . '</p>';
$html .= '<h2>' . $t( 'Stream overlays' ) . '</h2>';
$html .= '<p>' . $t( 'The overlay pages shown in broadcasting software load no third-party scripts, fonts or services. They show donor display names and messages (not the names of anonymous donors) and any images or sounds the site owner chose from the Media Library.' ) . '</p>';
$html .= '</div>';
return $html;
}
}
+1
View File
@@ -40,6 +40,7 @@ final class Settings {
'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)
);
}
+110
View File
@@ -0,0 +1,110 @@
<?php
declare( strict_types=1 );
namespace StreamGoals\Core;
/**
* Removes what the plugin created. Dependency-free on purpose: uninstall.php loads this single file with
* require_once, without the plugin's autoloader or constants.
*
* Always removed on uninstall: the cron event and all transients (they are only caches/notices).
* Removed ONLY when the owner ticked "delete data on uninstall": every sg_ table and option.
*
* Keep the lists below in sync with Installer (tables) and every add/update_option call; UninstallerTest fails
* when something is missing.
*/
final class Uninstaller {
public const CRON_HOOK = 'sg_purge_abandoned';
/** @return string[] Table names without the WordPress prefix. */
public static function tables(): array {
return array(
'sg_goals',
'sg_donations',
'sg_rules',
'sg_rule_events',
'sg_state',
'sg_actions',
'sg_action_events',
'sg_alert_defs',
'sg_goal_tiers',
);
}
/** @return string[] Option names (per site). */
public static function options(): array {
return array(
'sg_settings',
'sg_db_version',
'sg_overlay_epoch',
'sg_overlay_rules_version',
'sg_currency',
'sg_paypal_verified',
'sg_donate_page_id',
'sg_wizard_goal_id',
);
}
/** @return string[] Fixed-name site transients. */
public static function site_transients(): array {
return array( 'sg_update_release' );
}
/** @return string[] Prefixes of transients whose names carry a suffix (rate limiter hashes, per-user notices). */
public static function transient_prefixes(): array {
return array( 'sg_rl_', 'sg_notice_' );
}
/** Whether this site's saved settings ask for all data to be deleted. */
public static function wants_data_deleted( mixed $settings ): bool {
return is_array( $settings ) && ! empty( $settings['delete_data_on_uninstall'] );
}
/** Drops every plugin table for the current site prefix. @param object $wpdb wpdb-like (prefix, query). */
public static function drop_tables( object $wpdb ): void {
foreach ( self::tables() as $t ) {
$wpdb->query( 'DROP TABLE IF EXISTS `' . $wpdb->prefix . $t . '`' ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
}
}
/** Deletes the dynamically named transients (and their timeouts) straight from the options table. @param object $wpdb wpdb-like (options, esc_like, prepare, query). */
public static function delete_dynamic_transients( object $wpdb ): void {
foreach ( self::transient_prefixes() as $prefix ) {
foreach ( array( '_transient_', '_transient_timeout_' ) as $kind ) {
$like = $wpdb->esc_like( $kind . $prefix ) . '%';
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s", $like ) ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
}
}
}
/** Uninstall for the current site (call inside switch_to_blog on multisite). */
public static function run_site( object $wpdb ): void {
$delete = self::wants_data_deleted( get_option( 'sg_settings', array() ) );
wp_clear_scheduled_hook( self::CRON_HOOK );
self::delete_dynamic_transients( $wpdb );
if ( $delete ) {
self::drop_tables( $wpdb );
foreach ( self::options() as $o ) {
delete_option( $o );
}
}
}
/** Entry point for uninstall.php. */
public static function run(): void {
global $wpdb;
if ( function_exists( 'is_multisite' ) && is_multisite() ) {
foreach ( get_sites( array( 'fields' => 'ids', 'number' => 0 ) ) as $id ) {
switch_to_blog( (int) $id );
self::run_site( $wpdb );
restore_current_blog();
}
} else {
self::run_site( $wpdb );
}
foreach ( self::site_transients() as $t ) {
delete_site_transient( $t );
}
}
}