136 lines
3.4 KiB
PHP
136 lines
3.4 KiB
PHP
<?php
|
|
/**
|
|
* Uninstall Handler
|
|
*
|
|
* Cleans up plugin data on uninstall
|
|
*
|
|
* @package Igny8Bridge
|
|
*/
|
|
|
|
// If uninstall not called from WordPress, then exit
|
|
if (!defined('WP_UNINSTALL_PLUGIN')) {
|
|
exit;
|
|
}
|
|
|
|
// Remove all IGNY8 options from wp_options table
|
|
$igny8_options = array(
|
|
// Core Connection (current)
|
|
'igny8_api_key',
|
|
'igny8_site_id',
|
|
'igny8_last_communication',
|
|
|
|
// Deprecated Auth (kept for cleanup of old installations)
|
|
'igny8_access_token',
|
|
'igny8_refresh_token',
|
|
'igny8_email',
|
|
'igny8_integration_id',
|
|
'igny8_access_token_issued',
|
|
'igny8_token_refreshed_at',
|
|
'igny8_bridge_version',
|
|
|
|
// API & Health
|
|
'igny8_last_api_health_check',
|
|
'igny8_api_key_revoked',
|
|
|
|
// Site Sync Timestamps
|
|
'igny8_last_site_sync',
|
|
'igny8_last_site_import_id',
|
|
'igny8_last_structure_sync',
|
|
'igny8_last_taxonomy_sync',
|
|
'igny8_last_keyword_sync',
|
|
'igny8_last_writer_sync',
|
|
'igny8_last_full_site_scan',
|
|
'igny8_last_semantic_map',
|
|
'igny8_last_semantic_map_summary',
|
|
'igny8_last_incremental_site_sync',
|
|
'igny8_last_link_graph_sync',
|
|
'igny8_last_link_graph_count',
|
|
'igny8_last_sync_from_igny8',
|
|
'igny8_last_site_snapshot',
|
|
|
|
// Settings & Configuration
|
|
'igny8_default_post_status',
|
|
'igny8_default_author_role',
|
|
'igny8_enable_woocommerce',
|
|
'igny8_enable_two_way_sync',
|
|
'igny8_connection_enabled',
|
|
'igny8_control_mode',
|
|
'igny8_widgets_enabled',
|
|
'igny8_toc_min_headings',
|
|
'igny8_auto_create_authors',
|
|
'igny8_show_image_description',
|
|
|
|
// Module & Feature Toggles
|
|
'igny8_enabled_modules',
|
|
'igny8_enabled_post_types',
|
|
'igny8_enabled_taxonomies',
|
|
'igny8_available_modules',
|
|
'igny8_supported_post_types',
|
|
'igny8_supported_taxonomies',
|
|
|
|
// Data & Mappings
|
|
'igny8_taxonomy_sector_mappings',
|
|
'igny8_link_queue',
|
|
'igny8_webhook_logs',
|
|
'igny8_site_scan_settings',
|
|
'igny8_site_metadata_v1',
|
|
|
|
// Sync & Queue
|
|
'igny8_sync_enabled',
|
|
);
|
|
|
|
// Delete all IGNY8 options
|
|
foreach ($igny8_options as $option) {
|
|
delete_option($option);
|
|
}
|
|
|
|
// Remove all post meta (IGNY8-specific metadata on posts)
|
|
global $wpdb;
|
|
$wpdb->query("
|
|
DELETE FROM {$wpdb->postmeta}
|
|
WHERE meta_key LIKE '_igny8_%' OR meta_key LIKE 'igny8_%'
|
|
");
|
|
|
|
// Unschedule ALL cron jobs
|
|
$cron_hooks = array(
|
|
'igny8_sync_post_statuses',
|
|
'igny8_sync_site_data',
|
|
'igny8_sync_from_igny8',
|
|
'igny8_cron_sync_post_statuses',
|
|
'igny8_cron_sync_site_data',
|
|
'igny8_cron_sync_from_igny8',
|
|
'igny8_cron_full_site_scan',
|
|
'igny8_cron_sync_keywords',
|
|
'igny8_cron_sync_taxonomies',
|
|
'igny8_clear_old_webhook_logs',
|
|
'igny8_batch_sync_post_statuses',
|
|
);
|
|
|
|
foreach ($cron_hooks as $hook) {
|
|
$timestamp = wp_next_scheduled($hook);
|
|
while ($timestamp) {
|
|
wp_unschedule_event($timestamp, $hook);
|
|
$timestamp = wp_next_scheduled($hook);
|
|
}
|
|
// Also clear any hooks from the cron array
|
|
wp_clear_scheduled_hook($hook);
|
|
}
|
|
|
|
// Remove all IGNY8 transients
|
|
$wpdb->query("
|
|
DELETE FROM {$wpdb->options}
|
|
WHERE option_name LIKE '_transient_igny8_%'
|
|
OR option_name LIKE '_transient_timeout_igny8_%'
|
|
");
|
|
|
|
// Remove any IGNY8 user meta
|
|
$wpdb->query("
|
|
DELETE FROM {$wpdb->usermeta}
|
|
WHERE meta_key LIKE 'igny8_%' OR meta_key LIKE '_igny8_%'
|
|
");
|
|
|
|
// Note: Taxonomies and terms are NOT deleted
|
|
// They remain in WordPress for user reference
|
|
// Only the taxonomy registration is removed
|
|
|