<?php
/**
* Fired when the plugin is uninstalled.
*
* This file cleans up the database options to prevent bloat.
* However, to protect our users' critical institutional data,
* we deliberately DO NOT delete the actual Document records (CPTs)
* or their attached meta data.
*/
// SECURITY: If uninstall is not called directly from WordPress, exit immediately.
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit;
}
/**
* 1. CLEAN UP PLUGIN SETTINGS (Options)
* We delete the lightweight configuration settings so we don't leave junk in the database.
*/
$options_to_delete = array(
'ttdvr_public_categories',
'ttdvr_show_pdf_link',
'ttdvr_search_label',
'ttdvr_db_version'
);
foreach ( $options_to_delete as $option ) {
delete_option( $option );
}
/**
* 2. CLEAN UP TEMPORARY DATA (Transients)
*/
delete_transient( 'ttdvr_upgrade_complete' );
delete_transient( 'ttdvr_bulk_upload_message' );
delete_transient( 'ttdvr_bulk_upload_message_type' );
/**
* 3. CLEAN UP USER META (Dismissed Notices)
* We loop through users to remove the flag that hides the 5-star review notice.
*/
global $wpdb;
$wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key = 'ttdvr_review_notice_dismissed'" );
/**
* NOTE ON DOCUMENT DATA:
* We intentionally DO NOT loop through and delete posts of type 'ttdvr_document'.
* Institutions rely on this data. If they accidentally delete the plugin,
* they can simply reinstall it, and all their documents will instantly reappear.
*/