Idiot Check
<?php
namespace robido;
class ModHistory {
private $mods = false;
private $table = 'modifications';
public function __construct() {
[register_activation_hook](http://codex.wordpress.org/Function_Reference/register_activation_hook)( __FILE__, array( $this, 'install' ) );
register_uninstall_hook( __FILE__, array( $this, 'uninstall' ) );
[add_action](http://codex.wordpress.org/Function_Reference/add_action)( '[add_meta_boxes](http://codex.wordpress.org/Plugin_API/Action_Reference/add_meta_boxes)', array( $this, 'metaboxes' ) );
[add_action](http://codex.wordpress.org/Function_Reference/add_action)( '[pre_post_update](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_post_update)', array( $this, 'history_save' ) );
[add_action](http://codex.wordpress.org/Function_Reference/add_action)( 'post_updated', array( $this, 'modifications_saved' ) );
[add_action](http://codex.wordpress.org/Function_Reference/add_action)( '[wp_insert_post](http://codex.wordpress.org/Plugin_API/Action_Reference/wp_insert_post)', array( $this, 'postmeta_modifications_saved' ), 99999 );
// [add_action](http://codex.wordpress.org/Function_Reference/add_action)( 'updated_postmeta', 'postmeta_modifications_saved' );
}
/**
* Install routine
*/
function install() {
// Create custom modification history table
global $[wpdb](http://codex.wordpress.org/Class_Reference/wpdb);
$charset_collate = $[wpdb](http://codex.wordpress.org/Class_Reference/wpdb)->get_charset_collate();
$sql = "CREATE TABLE IF NOT EXISTS `{$[wpdb](http://codex.wordpress.org/Class_Reference/wpdb)->prefix}{$this->table}` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`post_id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`posts_before` mediumtext NOT NULL,
`postmeta_before` mediumtext NOT NULL,
`posts_after` mediumtext NOT NULL,
`postmeta_after` mediumtext NOT NULL,
`modified` datetime NOT NULL,
PRIMARY KEY (`ID`)
) $charset_collate;";
require_once( ABSPATH . '[wp](http://codex.wordpress.org/Plugin_API/Action_Reference/wp)-admin/includes/upgrade.php' );
dbDelta( $sql );
}
/**
* Uninstall routine
*/
function uninstall() {
echo 'test';
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) exit();
// Delete modification history options
// Delete modification history table
global $[wpdb](http://codex.wordpress.org/Class_Reference/wpdb);
$[wpdb](http://codex.wordpress.org/Class_Reference/wpdb)->query( "DROP TABLE IF EXISTS {$[wpdb](http://codex.wordpress.org/Class_Reference/wpdb)->prefix}{$this->table}" );
[wp_die](http://codex.wordpress.org/Function_Reference/wp_die)( 'got here executing: ' . "DROP TABLE IF EXISTS {$[wpdb](http://codex.wordpress.org/Class_Reference/wpdb)->prefix}{$this->table}" );
}
}