<?php
/**
* @package CembraPay Payment Gateway for WooCommerce
* @author  Adrian Emil Tudorache
* @license GPL-2.0+
* @link    https://www.tudorache.me/
*/

if ( ! defined( 'ABSPATH' ) ) {
	header( 'Status: 403 Forbidden' );
	header( 'HTTP/1.1 403 Forbidden' );
	exit;
}

/**
 * Drop the database tables on plugin uninstallation.
 * Remove all options if they exist from the _options table.
 * 
 * @return void
 */
function cembrapay_uninstall(): void {

	global $wpdb;

    $tables = array(
        CEMBRA_LOGS_TABLE
    );

    foreach( $tables as $table ) {
        $wpdb->query( $wpdb->prepare( "DROP TABLE IF EXISTS %s", array( $table ) ) );
    }

    $options = array(
        'woocommerce_cembrapay_settings',
        'woocommerce_cembrapay_legacy_settings',
        'woocommerce_update_options_payment_gateways_cembrapay',
        'cembrapay_access_token',
        'cembrapay_token_type',
        'cembrapay_field_translations'
    );

    if( $options ) {

        foreach( $options as $option ) {
            delete_option( $option );
        }

    }

}
?>
