<?php
if (!defined('WP_UNINSTALL_PLUGIN')) {
    exit;
}

$axagbuin_option_keys = [
    'seller_name',
    'seller_reg',
    'seller_vat',
    'seller_address',
    'seller_bank',
    'seller_iban',
    'seller_email',
    'seller_phone',
    'seller_website',
    'seller_logo_url',
    'invoice_title',
    'invoice_footer',
    'invoice_language',
    'header_color',
    'show_product_images',
];

foreach ($axagbuin_option_keys as $axagbuin_key) {
    delete_option('axagbuin_invoice_' . $axagbuin_key);
}

global $wpdb;
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->options} WHERE option_name LIKE %s", $wpdb->esc_like('_transient_axagbuin_job_') . '%')); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- one-time uninstall cleanup of this plugin's own namespaced transients; SQL is fully prepared via $wpdb->prepare().
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->options} WHERE option_name LIKE %s", $wpdb->esc_like('_transient_timeout_axagbuin_job_') . '%')); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- one-time uninstall cleanup of this plugin's own namespaced transients; SQL is fully prepared via $wpdb->prepare().

$axagbuin_upload_dir = wp_upload_dir();
$axagbuin_tmp_dir    = trailingslashit($axagbuin_upload_dir['basedir']) . 'axagbuin-invoices-tmp';
if (is_dir($axagbuin_tmp_dir)) {
    $axagbuin_tmp_files = glob(trailingslashit($axagbuin_tmp_dir) . '*.zip');
    if ($axagbuin_tmp_files) {
        foreach ($axagbuin_tmp_files as $axagbuin_tmp_file) {
            wp_delete_file($axagbuin_tmp_file);
        }
    }
    @rmdir($axagbuin_tmp_dir); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_rmdir -- WP_Filesystem is not guaranteed initialized in uninstall.php context; directory is this plugin's own empty temp folder, already emptied of files above.
}
