<?php
/**
 * Uninstall Formulate Pricing.
 *
 * @package Formulate_Pricing
 */

defined( 'WP_UNINSTALL_PLUGIN' ) || exit;

require_once plugin_dir_path( __FILE__ ) . 'includes/class-formulate-pricing-database.php';

/**
 * Remove plugin data on uninstall.
 */
function formulate_pricing_uninstall() {
	$tables = array(
		Formulate_Pricing_Database::get_entries_table(),
		Formulate_Pricing_Database::get_forms_table(),
	);

	global $wpdb;

	$tables[] = $wpdb->prefix . 'smart_pricing_forms';
	$tables[] = $wpdb->prefix . 'smart_pricing_entries';
	$tables[] = $wpdb->prefix . 'quotelix_forms';
	$tables[] = $wpdb->prefix . 'quotelix_entries';

	foreach ( array_unique( $tables ) as $table ) {
		Formulate_Pricing_Database::drop_table_if_exists( $table );
	}

	delete_option( 'formulate_pricing_db_version' );
	delete_option( 'formulate_pricing_product_id' );
	delete_option( 'smart_pricing_db_version' );
	delete_option( 'smart_pricing_product_id' );
	delete_option( 'quotelix_db_version' );
	delete_option( 'quotelix_product_id' );
}

formulate_pricing_uninstall();
