SEC-001 CRITICAL: Remove spoofable X-Forwarded-For/X-Real-IP from IP detection; trust only CF-Connecting-IP + REMOTE_ADDR SEC-004 HIGH: Add peptide name input validation with character whitelist and prompt injection blocking SEC-006 HIGH: Add missing return after wp_send_json_success in handle_pending_retry max-retries block SEC-007 MEDIUM: KB articles now respect auto_publish setting instead of always publishing SEC-009 MEDIUM: Replace hardcoded page ID 73 with configurable kb_page_id setting SEC-010 MEDIUM: Fix cache invalidation — add underscore prefix to transient name pattern SEC-011 MEDIUM: Skip sleep() during WP-Cron to avoid blocking PHP workers on rate limit retry SEC-012 MEDIUM: Add global daily generation cap (50/day) to prevent cost overruns SEC-013 LOW: Add @deprecated notice to unused PSA_Error class SEC-015 LOW: Convert uninstall.php from space to tab indentation (WPCS) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
40 lines
966 B
PHP
40 lines
966 B
PHP
<?php
|
|
/**
|
|
* Fired when the plugin is uninstalled.
|
|
*
|
|
* Cleans up all plugin data: peptide posts, post meta, options, transients, and rewrite rules.
|
|
*
|
|
* @package PeptideSearchAI
|
|
*/
|
|
|
|
// Abort if not called by WordPress.
|
|
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
|
exit;
|
|
}
|
|
|
|
global $wpdb;
|
|
|
|
// 1. Delete all peptide custom posts and their meta.
|
|
$peptide_ids = $wpdb->get_col(
|
|
"SELECT ID FROM {$wpdb->posts} WHERE post_type = 'peptide'"
|
|
);
|
|
|
|
if ( ! empty( $peptide_ids ) ) {
|
|
foreach ( $peptide_ids as $post_id ) {
|
|
wp_delete_post( (int) $post_id, true ); // Force delete, bypass trash.
|
|
}
|
|
}
|
|
|
|
// 2. Delete plugin options.
|
|
delete_option( 'psa_settings' );
|
|
|
|
// 3. Delete all plugin transients (validation cache, rate limits).
|
|
$wpdb->query(
|
|
"DELETE FROM {$wpdb->options}
|
|
WHERE option_name LIKE '_transient_psa_%'
|
|
OR option_name LIKE '_transient_timeout_psa_%'"
|
|
);
|
|
|
|
// 4. Flush rewrite rules to clean up the peptide post type permalinks.
|
|
flush_rewrite_rules();
|