<?php
/**
 * Runs on plugin uninstall.
 *
 * Removes all plugin options and cached transients from the database.
 *
 * @package IGIT_RPWT
 */

if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
	exit;
}

// Remove settings.
delete_option( 'igit_rpwt_settings' );

// Remove legacy v4 option (kept during migration for rollback; clean up on uninstall).
delete_option( 'igit_rpwt' );

// Remove all cached transients.
global $wpdb;
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.PreparedSQL.InterpolatedNotPrepared
$wpdb->query(
	"DELETE FROM {$wpdb->options}
	 WHERE option_name LIKE '%_transient_igit_rpwt_%'
	    OR option_name LIKE '%_transient_timeout_igit_rpwt_%'"
);
