| 1 |
<?php |
| 2 |
// Exit if accessed directly |
| 3 |
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) exit; |
| 4 |
|
| 5 |
/** |
| 6 |
* Uninstall this plugin |
| 7 |
*/ |
| 8 |
class EPKB_Uninstall { |
| 9 |
|
| 10 |
public function __construct() { |
| 11 |
|
| 12 |
flush_rewrite_rules(false); |
| 13 |
|
| 14 |
delete_option( 'epkb_error_log' ); |
| 15 |
delete_option( 'epkb_flush_rewrite_rules' ); |
| 16 |
delete_option( 'amgr_error_log' ); |
| 17 |
|
| 18 |
$delete_data = get_transient( '_epkb_delete_all_kb_data' ); |
| 19 |
if ( ! empty( $delete_data ) ) { |
| 20 |
$this->uninstall_kb(); |
| 21 |
} |
| 22 |
} |
| 23 |
|
| 24 |
/** |
| 25 |
* Removes ALL plugin data for KB #1 |
| 26 |
* only when the relevant option is active |
| 27 |
* |
| 28 |
*/ |
| 29 |
private function uninstall_kb() { |
| 30 |
/** @global wpdb $wpdb */ |
| 31 |
global $wpdb; |
| 32 |
|
| 33 |
delete_option( 'epkb_version' ); |
| 34 |
delete_option( 'epkb_last_seen_version' ); |
| 35 |
delete_option( 'epkb_config_1' ); |
| 36 |
delete_option( 'epkb_orignal_config_1' ); |
| 37 |
delete_option( 'epkb_articles_sequence_1' ); |
| 38 |
delete_option( 'epkb_categories_sequence_1' ); |
| 39 |
delete_option( 'epkb_categories_icons_images_1' ); |
| 40 |
delete_option( 'epkb_post_type_1_category_children' ); |
| 41 |
delete_option( 'epkb_one_time_notices' ); |
| 42 |
delete_option( 'epkb_ongoing_notices' ); |
| 43 |
delete_option( 'epkb_long_notices' ); |
| 44 |
delete_option( 'epkb_elementor_settings_dismissed' ); |
| 45 |
delete_option( 'epkb_delete_all_kb_data' ); |
| 46 |
delete_option( 'epkb_flags' ); |
| 47 |
delete_option( 'epkb_openai_api_key' ); |
| 48 |
delete_option( 'epkb_openai_key' ); |
| 49 |
delete_option( 'epkb_ml_custom_css_1' ); |
| 50 |
delete_option( 'epkb_ml_faqs_kb_id_1' ); |
| 51 |
delete_option( 'epkb_ml_faqs_category_ids_1' ); |
| 52 |
delete_option( 'epkb_faq_group_ids_1' ); |
| 53 |
delete_transient( '_epkb_plugin_activated' ); |
| 54 |
delete_transient( '_epkb_delete_all_kb_data' ); |
| 55 |
|
| 56 |
// Delete AI configurations |
| 57 |
delete_option( 'epkb_ai_configuration' ); |
| 58 |
delete_option( 'epkb_ai_training_data_configuration' ); |
| 59 |
delete_option( 'epkb_ai_widget_configuration_1' ); |
| 60 |
|
| 61 |
// Delete AI database table versions |
| 62 |
delete_option( 'epkb_ai_training_data_table_version' ); |
| 63 |
delete_option( 'epkb_ai_content_analysis_table_version' ); |
| 64 |
delete_option( 'epkb_ai_messages_table_version' ); |
| 65 |
|
| 66 |
// Clear AI cron jobs |
| 67 |
wp_clear_scheduled_hook( 'epkb_do_sync_cron_event' ); |
| 68 |
wp_clear_scheduled_hook( 'epkb_do_content_analysis_cron_event' ); |
| 69 |
|
| 70 |
// Delete AI transients |
| 71 |
delete_transient( 'epkb_openai_rate_limit' ); |
| 72 |
delete_transient( 'epkb_ai_dashboard_status' ); |
| 73 |
delete_transient( 'epkb_ai_chat_security_logs' ); |
| 74 |
delete_transient( 'epkb_ai_sync_lock' ); |
| 75 |
delete_transient( 'epkb_ai_rate_limit_until' ); |
| 76 |
|
| 77 |
// Delete all AI error notification count transients (they use date suffix) |
| 78 |
$wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_epkb_ai_error_notification_count_%'" ); |
| 79 |
$wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_timeout_epkb_ai_error_notification_count_%'" ); |
| 80 |
|
| 81 |
// Drop AI database tables |
| 82 |
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}epkb_ai_training_data" ); |
| 83 |
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}epkb_ai_content_analysis" ); |
| 84 |
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}epkb_ai_messages" ); |
| 85 |
|
| 86 |
delete_option( 'asea_version' ); |
| 87 |
delete_option( 'asea_version_first' ); |
| 88 |
delete_option( 'asea_error_log' ); |
| 89 |
delete_option( 'asea_license_key' ); |
| 90 |
delete_option( 'asea_license_state' ); |
| 91 |
|
| 92 |
delete_option( 'elay_version' ); |
| 93 |
delete_option( 'elay_version_first' ); |
| 94 |
delete_option( 'elay_error_log' ); |
| 95 |
delete_option( 'elay_license_key' ); |
| 96 |
delete_option( 'elay_license_state' ); |
| 97 |
|
| 98 |
delete_option( 'eprf_version' ); |
| 99 |
delete_option( 'eprf_version_first' ); |
| 100 |
delete_option( 'eprf_error_log' ); |
| 101 |
delete_option( 'eprf_license_key' ); |
| 102 |
delete_option( 'eprf_license_state' ); |
| 103 |
|
| 104 |
delete_option( 'epie_version' ); |
| 105 |
delete_option( 'epie_version_first' ); |
| 106 |
delete_option( 'epie_error_log' ); |
| 107 |
delete_option( 'epie_license_key' ); |
| 108 |
delete_option( 'epie_license_state' ); |
| 109 |
|
| 110 |
delete_option( 'kblk_version' ); |
| 111 |
delete_option( 'kblk_version_first' ); |
| 112 |
delete_option( 'kblk_error_log' ); |
| 113 |
delete_option( 'kblk_license_key' ); |
| 114 |
delete_option( 'kblk_license_state' ); |
| 115 |
|
| 116 |
delete_option( 'emkb_version' ); |
| 117 |
delete_option( 'emkb_version_first' ); |
| 118 |
delete_option( 'emkb_error_log' ); |
| 119 |
delete_option( 'emkb_license_key' ); |
| 120 |
delete_option( 'emkb_license_state' ); |
| 121 |
|
| 122 |
delete_option( 'widg_version' ); |
| 123 |
delete_option( 'widg_version_first' ); |
| 124 |
delete_option( 'widg_error_log' ); |
| 125 |
delete_option( 'widg_license_key' ); |
| 126 |
delete_option( 'widg_license_state' ); |
| 127 |
|
| 128 |
delete_option( '_epie_import_current_kb_id' ); |
| 129 |
delete_option( '_epie_import_current_step' ); |
| 130 |
delete_option( '_epie_import_selected_rows' ); |
| 131 |
delete_option( '_epie_import_processed_count' ); |
| 132 |
delete_transient( '_epie_import_articles_to_import' ); |
| 133 |
} |
| 134 |
} |
| 135 |
|
| 136 |
new EPKB_Uninstall(); |