Files

44 lines
1.3 KiB
PHP

<?php
/**
* Uninstall Community Suggestions plugin
*
* @package Community Suggestions
*/
// Prevent direct access
if (!defined('WP_UNINSTALL_PLUGIN')) {
exit;
}
// Remove database tables
function pc_community_suggestions_uninstall() {
global $wpdb;
$suggestions_table = $wpdb->prefix . 'pc_community_suggestions';
$votes_table = $wpdb->prefix . 'pc_community_votes';
// Drop tables
$wpdb->query("DROP TABLE IF EXISTS $suggestions_table");
$wpdb->query("DROP TABLE IF EXISTS $votes_table");
// Remove options
delete_option('pc_community_suggestions_moderation');
delete_option('pc_community_suggestions_default_sort');
delete_option('pc_community_suggestions_page_id');
delete_option('pc_community_suggestions_version');
// Remove any transients
$wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '%pc_community_suggestions_%'");
// Remove scheduled events
wp_clear_scheduled_hook('pc_community_suggestions_daily_cleanup');
// Remove the default page if it exists
$page_id = get_option('pc_community_suggestions_page_id', 0);
if ($page_id && get_post_type($page_id) === 'page') {
wp_delete_post($page_id, true);
}
}
// Run uninstall function
pc_community_suggestions_uninstall();