<?php
/**
 * Monitor.Cat uninstall handler.
 *
 * Fires when the plugin is deleted via the WordPress admin.
 * Removes all plugin data from the database.
 *
 * @package MonitorCat
 */

declare(strict_types=1);

// Exit if not called by WordPress.
defined( 'WP_UNINSTALL_PLUGIN' ) || exit;

// Delete the main settings option.
delete_option( 'monitorcat_settings' );

// Clear scheduled cron events.
wp_clear_scheduled_hook( 'monitorcat_db_auto_cleanup' );

// Delete all transients with our prefix.
global $wpdb;

// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
$wpdb->query(
	"DELETE FROM {$wpdb->options}
	WHERE option_name LIKE '_transient_monitorcat_%'
	OR option_name LIKE '_transient_timeout_monitorcat_%'"
);
