Restore to commit 74e578279624c6045ca440a3459ebfa1f8d54191

This commit is contained in:
southseact-3d
2026-02-07 20:32:41 +00:00
commit ed67b7741b
252 changed files with 99814 additions and 0 deletions

View File

@@ -0,0 +1,74 @@
<?php
/**
* Installation class for database setup and cleanup
*/
// Prevent direct access
if (!defined('ABSPATH')) {
exit;
}
class PC_Announcements_274_Install {
/**
* Install plugin - create database tables and set default options
*/
public static function install() {
global $wpdb;
// Ensure plugin constants are defined
if (!defined('PC_ANNOUNCEMENTS_274_VERSION')) {
define('PC_ANNOUNCEMENTS_274_VERSION', '1.0.0');
}
if (!function_exists('dbDelta')) {
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
}
$table_name = $wpdb->prefix . 'pc_announcements_274';
$charset_collate = '';
if (method_exists($wpdb, 'get_charset_collate')) {
$charset_collate = $wpdb->get_charset_collate();
}
if (empty($charset_collate)) {
$charset_collate = 'DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci';
}
$sql = "CREATE TABLE $table_name (
id int(11) NOT NULL AUTO_INCREMENT,
title varchar(255) NOT NULL,
message text NOT NULL,
image_url varchar(500) DEFAULT NULL,
banner_color varchar(7) DEFAULT '#0d47a1',
link_url varchar(500) DEFAULT NULL,
start_date datetime DEFAULT NULL,
end_date datetime DEFAULT NULL,
status varchar(20) DEFAULT 'active',
created_at datetime DEFAULT CURRENT_TIMESTAMP,
updated_at datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
created_by int(11) NOT NULL,
PRIMARY KEY (id),
KEY status (status),
KEY start_date (start_date),
KEY end_date (end_date)
) $charset_collate;";
dbDelta($sql);
add_option('pc_announcements_274_version', PC_ANNOUNCEMENTS_274_VERSION);
add_option('pc_announcements_274_db_version', '1.0');
}
/**
* Get table name
*/
public static function get_table_name() {
global $wpdb;
if (!isset($wpdb)) {
return null;
}
return $wpdb->prefix . 'pc_announcements_274';
}
}