-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstallation.php
68 lines (51 loc) · 1.83 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
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
<?php
function deepi_install(){
//// Default Table of Deepi
global $wpdb;
$table_name = $wpdb->prefix . "deepi";
$charset_collate = $wpdb->get_charset_collate();
$sql = "CREATE TABLE IF NOT EXISTS $table_name (
`id` int(9) NOT NULL AUTO_INCREMENT,
`key` varchar(255) NOT NULL,
`value` varchar(255) NOT NULL,
PRIMARY KEY (id)
) $charset_collate;
";
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta($sql);
$table_name = $wpdb->prefix . "deepi";
global $wpdb;
$wpdb->insert($table_name, array(
'key' => 'secret_key',
) );
$wpdb->insert($table_name, array(
'key' => 'slug',
) );
$wpdb->insert($table_name, array(
'key' => 'style',
'value' => "default",
) );
$wpdb->insert($table_name, array(
'key' => 'form_visibility',
'value' => 1,
) );
$wpdb->insert($table_name, array(
'key' => 'deepi_link_visibility',
'value' => 1,
) );
$wpdb->insert($table_name, array(
'key' => 'deepi_post_link',
'value' => 1,
) );
//// Post Status
$table_name = $wpdb->prefix . "posts";
$column_name_1 = 'deepi_status';
$sql = "ALTER TABLE $table_name ADD `$column_name_1` enum('crawled', 'submitted', 'error', 'unsubmitted') NOT NULL DEFAULT 'unsubmitted' AFTER `ID` ;";
$sql2 = "update `$table_name` set `deepi_status` = 'crawled' where `deepi_status`='unsubmitted' ;";
$if_column_exist_1 = $wpdb->get_results( "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = '$table_name' AND column_name = '$column_name_1'" );
if(empty($if_column_exist_1)){
$wpdb->query($sql);
$wpdb->query($sql2);
}
}