prepare(). global $wpdb; /* * Always-safe cleanup: transient caches, backoff counters and per-post scan * timestamps. These are derived scratch state — regenerated by the next scan — * so removing them leaves nothing the user would miss, and leaving them behind * would litter the options table on a genuine uninstall. */ delete_option( '_transient_nlhealth_suggestions' ); delete_option( '_transient_timeout_nlhealth_suggestions' ); delete_option( '_transient_nlhealth_seo_audit_results' ); delete_option( '_transient_timeout_nlhealth_seo_audit_results' ); delete_option( '_transient_nlhealth_manual_scan_active' ); delete_option( '_transient_timeout_nlhealth_manual_scan_active' ); delete_post_meta_by_key( '_nlhealth_last_scan' ); $nlhealth_transient_ok_prefix = $wpdb->esc_like( '_transient_nlhealth_ok_' ) . '%'; $nlhealth_transient_ok_timeout_prefix = $wpdb->esc_like( '_transient_timeout_nlhealth_ok_' ) . '%'; $nlhealth_transient_retry_prefix = $wpdb->esc_like( '_transient_nlhealth_retry_' ) . '%'; $nlhealth_transient_retry_timeout_prefix = $wpdb->esc_like( '_transient_timeout_nlhealth_retry_' ) . '%'; $nlhealth_transient_fail_prefix = $wpdb->esc_like( '_transient_nlhealth_fail_' ) . '%'; $nlhealth_transient_fail_timeout_prefix = $wpdb->esc_like( '_transient_timeout_nlhealth_fail_' ) . '%'; $nlhealth_transient_broken_counts_prefix = $wpdb->esc_like( '_transient_nlhealth_broken_counts_' ) . '%'; $nlhealth_transient_broken_counts_timeout = $wpdb->esc_like( '_transient_timeout_nlhealth_broken_counts_' ) . '%'; $nlhealth_last_ok_option_prefix = $wpdb->esc_like( 'nlhealth_last_ok_' ) . '%'; $nlhealth_last_soft_option_prefix = $wpdb->esc_like( 'nlhealth_last_soft_' ) . '%'; $wpdb->query( $wpdb->prepare( 'DELETE FROM %i WHERE option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s', $wpdb->options, $nlhealth_transient_ok_prefix, $nlhealth_transient_ok_timeout_prefix, $nlhealth_transient_retry_prefix, $nlhealth_transient_retry_timeout_prefix, $nlhealth_transient_fail_prefix, $nlhealth_transient_fail_timeout_prefix, $nlhealth_transient_broken_counts_prefix, $nlhealth_transient_broken_counts_timeout, $nlhealth_last_ok_option_prefix, $nlhealth_last_soft_option_prefix ) ); /* * Everything below is the user's own data. It goes only when the site owner * explicitly asked for it in Settings > Link Health > Data & Uninstall. */ if ( ! rest_sanitize_boolean( get_option( 'nlhealth_remove_all_on_uninstall', false ) ) ) { return; } $nlhealth_table = $wpdb->prefix . 'nlhealth_link_errors'; $nlhealth_events_table = $wpdb->prefix . 'nlhealth_link_events'; $nlhealth_correction_log_table = $wpdb->prefix . 'nlhealth_correction_log'; // phpcs:ignore WordPress.DB.DirectDatabaseQuery.SchemaChange -- Opt-in removal of this plugin's own table. $wpdb->query( $wpdb->prepare( 'DROP TABLE IF EXISTS %i', $nlhealth_table ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.SchemaChange -- Opt-in removal of this plugin's own table. $wpdb->query( $wpdb->prepare( 'DROP TABLE IF EXISTS %i', $nlhealth_events_table ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.SchemaChange -- Opt-in removal of this plugin's own table. $wpdb->query( $wpdb->prepare( 'DROP TABLE IF EXISTS %i', $nlhealth_correction_log_table ) ); $nlhealth_link_map_table = $wpdb->prefix . 'nlhealth_link_map'; $nlhealth_link_scores_table = $wpdb->prefix . 'nlhealth_link_scores'; // phpcs:ignore WordPress.DB.DirectDatabaseQuery.SchemaChange -- Opt-in removal of this plugin's own table. $wpdb->query( $wpdb->prepare( 'DROP TABLE IF EXISTS %i', $nlhealth_link_map_table ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.SchemaChange -- Opt-in removal of this plugin's own table. $wpdb->query( $wpdb->prepare( 'DROP TABLE IF EXISTS %i', $nlhealth_link_scores_table ) ); delete_option( 'nlhealth_db_version' ); delete_option( 'nlhealth_juice_dirty' ); delete_option( 'nlhealth_juice_computed_at' ); delete_option( 'nlhealth_health_history' ); delete_option( 'nlhealth_ignored_urls' ); delete_option( 'nlhealth_scan_batch_size' ); delete_option( 'nlhealth_scan_scope' ); delete_option( 'nlhealth_comment_scan_last_id' ); delete_option( 'nlhealth_scan_metrics' ); delete_option( 'nlhealth_auto_rules' ); delete_option( 'nlhealth_show_welcome' ); delete_option( 'nlhealth_remove_all_on_uninstall' );