query( "DROP TABLE IF EXISTS `{$wpdb->prefix}{$table}`" ); } // ── 2. Alle wp_options löschen ─────────────────────────────────────────────── $options = [ 'wbf_settings', 'wbf_custom_roles', 'wbf_level_config', 'wbf_levels_enabled', 'wbf_profile_fields', 'wbf_profile_field_cats', 'wbf_reactions', 'wbf_forum_page_id', 'wbf_superadmin_email', 'wbf_db_version', 'wbf_word_filter', ]; foreach ( $options as $option ) { delete_option( $option ); } // Multisite: Netzwerk-Optionen ebenfalls entfernen if ( is_multisite() ) { foreach ( $options as $option ) { delete_site_option( $option ); } } // ── 3. Transients löschen ──────────────────────────────────────────────────── delete_transient( 'wbf_activation_redirect' ); delete_transient( 'wbf_stats_cache' ); delete_transient( 'wbf_update_check' ); // Alle wbf_* Transients per LIKE-Query entfernen (inkl. Update-Dismissed-Transients) $wpdb->query( "DELETE FROM `{$wpdb->options}` WHERE `option_name` LIKE '_transient_wbf_%' OR `option_name` LIKE '_transient_timeout_wbf_%'" ); // ── 4. Geplante Cron-Jobs entfernen ────────────────────────────────────────── wp_clear_scheduled_hook( 'wbf_check_expired_bans' ); wp_clear_scheduled_hook( 'wbf_check_for_updates' ); // ── 5. Forum-Seite löschen (vom Setup-Wizard erstellt) ─────────────────────── $forum_page_id = get_option( 'wbf_forum_page_id' ); if ( $forum_page_id ) { wp_delete_post( (int) $forum_page_id, true ); // true = dauerhaft löschen } // ── 6. Upload-Unterverzeichnis entfernen ───────────────────────────────────── $upload_dir = wp_upload_dir(); $wbf_dir = trailingslashit( $upload_dir['basedir'] ) . 'wbf-avatars'; if ( is_dir( $wbf_dir ) ) { wbf_uninstall_rmdir( $wbf_dir ); } /** * Hilfsfunktion: Verzeichnis rekursiv löschen. * Nur innerhalb des WP-Upload-Verzeichnisses erlaubt. */ function wbf_uninstall_rmdir( $dir ) { $upload_base = wp_upload_dir()['basedir']; // Sicherheitscheck: nur Unterverzeichnisse von uploads/ löschen if ( strpos( realpath( $dir ), realpath( $upload_base ) ) !== 0 ) { return; } $files = array_diff( scandir( $dir ), [ '.', '..' ] ); foreach ( $files as $file ) { $path = $dir . DIRECTORY_SEPARATOR . $file; is_dir( $path ) ? wbf_uninstall_rmdir( $path ) : unlink( $path ); } rmdir( $dir ); }