1
0
Fork 0
mirror of https://github.com/yunluo/gdk.git synced 2024-05-13 11:46:57 +02:00
gdk/class/points/points.php

64 lines
1.7 KiB
PHP
Raw Normal View History

2020-02-02 04:13:58 +01:00
<?php
2020-03-15 14:29:06 +01:00
include 'class-points.php';
2021-10-10 15:48:53 +02:00
2020-02-02 04:13:58 +01:00
include 'class-points-admin.php';
2021-10-10 15:48:53 +02:00
2020-02-02 04:13:58 +01:00
include 'class-points-shortcodes.php';
2020-03-15 14:29:06 +01:00
class GDK_Points_Class
{
private static $__notices = [];
2021-10-10 15:48:53 +02:00
2020-03-15 14:29:06 +01:00
public static function init()
{
add_action('init', [__CLASS__, 'wp_init']);
add_action('admin_init', [__CLASS__, 'activate']);
}
public static function wp_init()
{
GDK_Points_Admin::init();
}
/**
* activation work.
*/
public static function activate()
{
global $wpdb;
$charset_collate = '';
if (!empty($wpdb->charset)) {
2021-10-10 15:48:53 +02:00
$charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
2020-03-15 14:29:06 +01:00
}
if (!empty($wpdb->collate)) {
2021-10-10 15:48:53 +02:00
$charset_collate .= " COLLATE {$wpdb->collate}";
2020-03-15 14:29:06 +01:00
}
// create tables
2021-10-10 15:48:53 +02:00
$points_users_table = GDK_Points_Database::points_get_table('users');
if ($wpdb->get_var("SHOW TABLES LIKE '{$points_users_table}'") != $points_users_table) {
$queries[] = "CREATE TABLE {$points_users_table} (
2020-02-02 04:13:58 +01:00
point_id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
user_id BIGINT(20) UNSIGNED NOT NULL,
points BIGINT(20) DEFAULT 0,
datetime datetime NOT NULL,
description varchar(5000),
ref_id BIGINT(20) DEFAULT null,
ip int(10) unsigned default NULL,
ipv6 decimal(39,0) unsigned default NULL,
data longtext default NULL,
status varchar(10) NOT NULL DEFAULT 'accepted',
type varchar(32) NULL,
PRIMARY KEY (point_id)
2021-10-10 15:48:53 +02:00
) {$charset_collate};";
2020-03-15 14:29:06 +01:00
}
if (!empty($queries)) {
2021-10-10 15:48:53 +02:00
require_once ABSPATH.'wp-admin/includes/upgrade.php';
2020-03-15 14:29:06 +01:00
dbDelta($queries);
}
}
2020-02-02 04:13:58 +01:00
}
2020-03-15 14:29:06 +01:00
GDK_Points_Class::init();