<?php
/**
 * Uninstall cleanup for Mersal Notifications.
 *
 * @package Mersal_Notif
 */

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

$options = array(
	'mnotif_settings',
	'mnotif_rules',
	'mnotif_custom_events',
	'mnotif_rule_sent',
	'mnotif_stats',
	'mnotif_log',
	'mnotif_activated_at',
	'mnotif_light_default_applied',
	'mnotif_updater_auto_update',
	'mnotif_sso_token',
	'mnotif_api_key',
	'mnotif_mersal_user',
	'mnotif_site_url',
	'mnotif_gateways',
	'mnotif_sso_unlinked',
	'mnotif_connect_last_error',
);
foreach ( $options as $opt ) {
	delete_option( $opt );
}

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

// Remove user meta.
$wpdb->delete( $wpdb->usermeta, array( 'meta_key' => 'mnotif_notif_seen' ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
