Files
Bookshelf/Old/bd-simpleemail/inc/class-email-install.php
2026-10-18 19:01:01 -07:00

55 lines
1.6 KiB
PHP

<?php
// Copyright 2026 Umbra Tools (umbratools.com)
// SPDX-License-Identifier: Apache-2.0
/**
* Email Installation and Database
*/
if (!defined('ABSPATH')) {
exit;
}
class BD_SimpleEmail_Install {
public static function activate() {
self::create_tables();
}
public static function deactivate() {
}
public static function create_tables() {
global $wpdb;
$charset_collate = $wpdb->get_charset_collate();
$tables = array(
"CREATE TABLE IF NOT EXISTS {$wpdb->prefix}bd_subscribers (
id bigint(20) NOT NULL AUTO_INCREMENT,
email varchar(255) NOT NULL,
first_name varchar(100) DEFAULT NULL,
status varchar(20) DEFAULT 'subscribed',
subscribed_at datetime DEFAULT CURRENT_TIMESTAMP,
unsubscribed_at datetime DEFAULT NULL,
ip_address varchar(45) DEFAULT NULL,
PRIMARY KEY (id),
UNIQUE KEY email (email)
) $charset_collate;",
"CREATE TABLE IF NOT EXISTS {$wpdb->prefix}bd_newsletters (
id bigint(20) NOT NULL AUTO_INCREMENT,
subject varchar(255) NOT NULL,
body_html text,
sent_at datetime DEFAULT CURRENT_TIMESTAMP,
recipient_count int(11) DEFAULT 0,
PRIMARY KEY (id)
) $charset_collate;",
);
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
foreach ($tables as $table) {
dbDelta($table);
}
}
}