• Welcome to Tux Reports: Where Penguins Fly. We hope you find the topics varied, interesting, and worthy of your time. Please become a member and join in the discussions.

XenWord uninstall.php File

This entry is part of a series of entries "December 2016 - XenWord Development Log"
unplug.jpg


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
Next entry in series Widgets
Previous entry in series The Current Status of XenWord

Blog entry information

Author
LPH
Views
1,292
Last update

More entries in Technology

More entries from LPH

Top