Instead of using a deactivation hook or the register_uninstall_hook, XenWord has an uninstall.php file that runs automatically if a user deletes the XenWord plugin.
This was rewritten this afternoon to include a conditional for checking if the column exists.
PHP:
<?php
/**
* Filename: uninstall.php
*
* This is the uninstall procedure and runs automatically when the user deletes this plugin.
*
* @package xenword
*/
/**
* This section is for security. Do not modify this part:
* @ignore
*/
if ( ! defined('WP_UNINSTALL_PLUGIN') ) { die; }
/**
* Remove the thread_id from the WordPress posts table
*
* Pull all the columns from the posts table. Drop the column thread_id if it exists
*/
global $wpdb;
$xenwordThreadId = $wpdb->get_row("SELECT * FROM $wpdb->posts");
if( isset( $xenwordThreadId->thread_id ) ) {
$wpdb->query("ALTER TABLE $wpdb->posts DROP COLUMN thread_id");
echo 'The XenWord Bridge has successfully removed the thread_id table alteration and is now uninstalled';
} else {
echo 'XenWord has not altered any WordPress tables.';
}
// End of uninstall.php