Files
wordpress-theme-aksrt/uninstall.php
T
kate522 1d2505356e feat: remove shop feature (Phase 2)
Delete all shop domain classes, controllers, schema builders, templates,
JS/CSS, admin SPA pages, and shop-only payment classes (Shipping,
AfterSale, Discount). Remove shop-only DB table definitions (product_variant,
after_sale, order_shipping, card_key) from migrator and add their DROP
to uninstall.php. Clean up shared files:

- Remove aksrt_product CPT + taxonomies from Setup.php
- Remove shop rewrite rules/query vars/template redirect from SetupPart2.php
- Remove shop widget areas from SetupPart1.php
- Remove shop enqueues from ScriptsPart1b.php
- Remove sepakerator-aksrt-shop from SetupPart2.php
- Remove get_shop_settings facade (delete ForumShop.php, clean DomainGroups.php)
- Remove ORDER_PRODUCT_SHOP constant from DomainModel.php
- Remove Shop::class fallback branches from UserOrders.php, OrderCenterRest.php
- Remove shipping/after-sale branches from OrderRepositoryAdmin.php, PayMenus.php, PayOrders.php
- Remove shop product widgets from widgets-register.php
- Remove cart page from template-registry.php, routing.php, ScriptsPart2.php
- Remove cart UI from sidebar-nav.php, profile-orders.php, sidebar-orders.php
- Clean up order-center.js (remove rebuy/cartUrl/receipt/after-sale handlers)
- Remove aksrt_get_cart_page_url/product_page/product_edit from transactions.php
- Clean up aksrt_product_cat references in Coupon.php, PayCoupons.php

Shared payment/order/credits/content-pay stack fully retained.
2026-08-02 21:25:52 +08:00

83 lines
2.1 KiB
PHP

<?php
/**
* AKSRT Theme — Uninstall Handler
*
* Runs when the theme is deleted via the WordPress admin.
* Optionally cleans up custom database tables and options.
*
* @package AKSRT
*/
// Abort if not called by WordPress
if (!defined('WP_UNINSTALL_PLUGIN') && !defined('ABSPATH')) {
exit;
}
// Only run if the user has opted in to data deletion.
// Check for a specific option flag; if not set, preserve data.
$should_cleanup = get_option('aksrt_cleanup_on_uninstall', false);
if (!$should_cleanup) {
return;
}
global $wpdb;
// ── Drop custom tables ──
$tables = [
'aksrt_credit_log',
'aksrt_signin_log',
'aksrt_invite',
'aksrt_dl_token',
'aksrt_notification',
'aksrt_conversation',
'aksrt_conversation_message',
'aksrt_report',
'aksrt_follow',
'aksrt_user_restriction',
'aksrt_product_variant',
'aksrt_after_sale',
'aksrt_order_shipping',
'aksrt_card_key',
'aksrt_revenue',
'aksrt_withdrawal',
'aksrt_charge_card',
];
foreach ($tables as $table) {
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}{$table}");
}
// ── Delete AKSRT options ──
$options = $wpdb->get_col(
"SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE 'aksrt_%'"
);
if ($options) {
foreach ($options as $option) {
delete_option($option);
}
}
// ── Delete AKSRT user meta ──
$meta_keys = [
'aksrt_user_contacts',
'aksrt_avatar_attachment_id',
'aksrt_background_attachment_id',
'aksrt_background_image',
'aksrt_email_verification_status',
'aksrt_email_verified_at',
'aksrt_unread_message_count',
'_aksrt_active_restrictions',
'_aksrt_is_banned',
'_aksrt_favorite_posts',
'aksrt_wechat_openid',
'aksrt_wechat_subscriptions',
];
foreach ($meta_keys as $key) {
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->usermeta} WHERE meta_key = %s", $key));
}
// ── Delete transients ──
$wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_aksrt_%'");
$wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_timeout_aksrt_%'");