/**
* Creates the database table. It is also responsible for recreating the table if it is not up-to-date.
**/
public function create_table()
{
$current_version = get_option('wpfepp_db_table_version');
if ($current_version && $current_version == $this->db_version && $this->db->get_var("SHOW TABLES LIKE '{$this->table_name}'") == $this->table_name) {
return;
}
$charset_collate = $this->db->get_charset_collate();
$sql = "\r\n\t\t\tCREATE TABLE {$this->table_name} (\r\n\t\t\t\tid MEDIUMINT(9) NOT NULL AUTO_INCREMENT,\r\n\t\t\t\tname TINYTEXT NOT NULL,\r\n\t\t\t\tpost_type TINYTEXT NOT NULL,\r\n\t\t\t\tdescription TEXT NULL,\r\n\t\t\t\tfields LONGTEXT NULL,\r\n\t\t\t\tsettings LONGTEXT NULL,\r\n\t\t\t\temails LONGTEXT NULL,\r\n\t\t\t\tUNIQUE KEY id (id)\r\n\t\t\t) {$charset_collate};\r\n\t\t";
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta($sql);
update_option('wpfepp_db_table_version', $this->db_version);
}