Files
WooCow/includes/class-woocow-installer.php
Malin 2ee81efacf feat: initial WooCow plugin — Mailcow/WooCommerce integration
- Mailcow API client wrapping domains, mailboxes, aliases endpoints
- Admin backend: server management, customer-domain assignments, mailbox overview
- WooCommerce My Account: email hosting tab with mailbox/alias management
- Per-mailbox password change (independent of WP account password)
- Optional WP account password sync to all customer mailboxes
- Installer creates wp_woocow_servers and wp_woocow_assignments DB tables
- Full nonce + capability + ownership verification on all AJAX endpoints

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-27 08:06:22 +01:00

40 lines
1.3 KiB
PHP

<?php
defined( 'ABSPATH' ) || exit;
class WooCow_Installer {
public static function install(): void {
global $wpdb;
$charset = $wpdb->get_charset_collate();
$servers_sql = "CREATE TABLE {$wpdb->prefix}woocow_servers (
id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(100) NOT NULL,
url VARCHAR(500) NOT NULL,
api_key VARCHAR(500) NOT NULL,
active TINYINT(1) NOT NULL DEFAULT 1,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id)
) $charset;";
$assignments_sql = "CREATE TABLE {$wpdb->prefix}woocow_assignments (
id INT NOT NULL AUTO_INCREMENT,
customer_id BIGINT NOT NULL,
server_id INT NOT NULL,
domain VARCHAR(255) NOT NULL,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id),
KEY idx_customer (customer_id),
KEY idx_server (server_id),
UNIQUE KEY uniq_cust_domain (customer_id, domain)
) $charset;";
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta( $servers_sql );
dbDelta( $assignments_sql );
update_option( 'woocow_db_version', WOOCOW_VERSION );
}
}