-
Notifications
You must be signed in to change notification settings - Fork 0
/
installation.php
34 lines (29 loc) · 1.11 KB
/
installation.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
function ntalam_countdown_activation_action()
{
global $wpdb;
$tablename = $wpdb->prefix . NTALAM_COUNTDOWN__TABLE_COUNTDOWN_OPTIONS;
$table_create = "CREATE TABLE `" . $tablename . "` (
`id` bigint NOT NULL AUTO_INCREMENT,
`key` varchar(200) NOT NULL,
`value` varchar(350) NOT NULL,
`user_id` bigint NOT NULL,
`deadline` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
INDEX (`id`));";
$table_exists = $wpdb->get_var("SHOW TABLES LIKE '$tablename'") == $tablename;
// $filepath = 'error_file.log';
if ($table_exists) {
} else {
$results = $wpdb->get_results($wpdb->prepare($table_create));
$lastError = $wpdb->last_error;
if ($lastError) {
$wpdb->print_error();
// error_log(PHP_EOL . $lastError, 3, NTALAM_COUNTDOWN__AJAX_ACTION_ERROR_LOG_PATH);
errorLog($lastError);
set_transient('ntalam_countdown_admin_error_notice_' . get_current_user_id(), true, 10);
die();
}
}
}
register_activation_hook(NTALAM_COUNTDOWN__PLUGIN_DIR . '/ntalam-countdown.php', 'ntalam_countdown_activation_action');