<?php
/**
 * Uninstall ZERTI — remove plugin-owned options, transients, and capabilities.
 */

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

delete_option('zerti_settings');
delete_option('zerti_postal_pdf_settings');
delete_option('zerti_attribute_groups');
delete_option('zerti_admin_notes');

delete_transient('zerti_home_dashboard_stats_v3');
delete_transient('zerti_home_leaderboards_v1');
delete_transient('zerti_home_dashboard_stats_build_v1');
delete_transient('zerti_home_leaderboards_build_v1');

foreach (['administrator', 'shop_manager'] as $role_name) {
    $role = get_role($role_name);
    if ($role) {
        $role->remove_cap('zerti_access');
    }
}
