forked from wp-sms/wp-sms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.php
80 lines (67 loc) · 2.32 KB
/
install.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
/**
* Class WP_SMS_INSTALL
*/
class WP_SMS_INSTALL {
/**
* Table SQL
*
* @param Not param
*/
public function table_sql()
{
global $wpdb;
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
$table_name = $wpdb->prefix.'sms_subscribes';
if( $wpdb->get_var( "show tables like '{$table_name}'" ) != $table_name ) {
$create_sms_subscribes = ("CREATE TABLE IF NOT EXISTS {$table_name}(
ID int(10) NOT NULL auto_increment,
date DATETIME,
name VARCHAR(20),
mobile VARCHAR(20) NOT NULL,
status tinyint(1),
activate_key INT(11),
group_ID int(5),
PRIMARY KEY(ID)) CHARSET=utf8");
dbDelta( $create_sms_subscribes );
}
$table_name = $wpdb->prefix.'sms_subscribes_group';
if( $wpdb->get_var( "show tables like '{$table_name}'" ) != $table_name ) {
$create_sms_subscribes_group = ("CREATE TABLE IF NOT EXISTS {$table_name}(
ID int(10) NOT NULL auto_increment,
name VARCHAR(250),
PRIMARY KEY(ID)) CHARSET=utf8");
dbDelta( $create_sms_subscribes_group );
}
$table_name = $wpdb->prefix.'sms_send';
if( $wpdb->get_var( "show tables like '{$table_name}'" ) != $table_name ) {
$create_sms_send = ("CREATE TABLE IF NOT EXISTS {$table_name}(
ID int(10) NOT NULL auto_increment,
date DATETIME,
sender VARCHAR(20) NOT NULL,
message TEXT NOT NULL,
recipient TEXT NOT NULL,
PRIMARY KEY(ID)) CHARSET=utf8");
dbDelta( $create_sms_send );
}
}
/**
* Adding new MYSQL Table in Activation Plugin
*
* @param Not param
*/
public function create_table( $network_wide )
{
global $wpdb;
if ( is_multisite() && $network_wide ) {
$blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
foreach ( $blog_ids as $blog_id ) {
switch_to_blog( $blog_id );
$this->table_sql();
restore_current_blog();
}
} else {
$this->table_sql();
}
}
}