<?php
/** Uninstall Event Booking Manager. */
defined( 'WP_UNINSTALL_PLUGIN' ) || exit;

if ( ! get_option( 'plugoza_ett_remove_data_on_uninstall', false ) ) { return; }
global $wpdb;
foreach ( array( 'plugoza_ett_events', 'plugoza_ett_tickets', 'plugoza_ett_bookings', 'plugoza_ett_customers', 'plugoza_ett_organizers', 'plugoza_ett_checkins' ) as $plugoza_ett_uninstall_table ) {
	$wpdb->query( $wpdb->prepare( 'DROP TABLE IF EXISTS %i', $wpdb->prefix . $plugoza_ett_uninstall_table ) );
}
delete_option( 'plugoza_ett_version' );
delete_option( 'plugoza_ett_settings' );
delete_option( 'plugoza_ett_payment_gateways' );
$plugoza_ett_event_method_options = $wpdb->get_col( $wpdb->prepare( "SELECT option_name FROM %i WHERE option_name LIKE %s", $wpdb->options, 'plugoza_ett_event_payment_methods_%' ) );
foreach ( $plugoza_ett_event_method_options as $plugoza_ett_option_name ) {
	delete_option( $plugoza_ett_option_name );
}
delete_option( 'plugoza_ett_remove_data_on_uninstall' );
