49 lines
1.2 KiB
PHP
Executable File
49 lines
1.2 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* Uninstall MLS by HansonXyz Plugin
|
|
*
|
|
* This file runs when the plugin is deleted via the WordPress admin.
|
|
* It removes all plugin data including database tables and options.
|
|
*/
|
|
|
|
// Exit if not called by WordPress
|
|
if (!defined('WP_UNINSTALL_PLUGIN')) {
|
|
exit;
|
|
}
|
|
|
|
global $wpdb;
|
|
|
|
// Delete options
|
|
delete_option('mls_plugin_options');
|
|
delete_option('mls_db_version');
|
|
delete_option('mls_activated_at');
|
|
|
|
// Drop tables
|
|
$tables = array(
|
|
$wpdb->prefix . 'mls_properties',
|
|
$wpdb->prefix . 'mls_media',
|
|
$wpdb->prefix . 'mls_sync_state',
|
|
$wpdb->prefix . 'mls_rate_limits',
|
|
$wpdb->prefix . 'mls_sync_log',
|
|
);
|
|
|
|
foreach ($tables as $table) {
|
|
$wpdb->query("DROP TABLE IF EXISTS {$table}");
|
|
}
|
|
|
|
// Clear scheduled cron events
|
|
wp_clear_scheduled_hook('mls_sync_properties');
|
|
wp_clear_scheduled_hook('mls_sync_media');
|
|
wp_clear_scheduled_hook('mls_cleanup');
|
|
|
|
// Optionally delete media files
|
|
// Note: Uncomment this if you want to delete all downloaded media on uninstall
|
|
/*
|
|
$upload_dir = wp_upload_dir();
|
|
$mls_dir = $upload_dir['basedir'] . '/mls-listings';
|
|
|
|
if (is_dir($mls_dir)) {
|
|
// Recursive delete would go here
|
|
}
|
|
*/
|