forked from carlosfilho88/wp-moip
-
Notifications
You must be signed in to change notification settings - Fork 1
/
install-script.php
38 lines (32 loc) · 1.12 KB
/
install-script.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
<?php
if (!defined( 'MN_TABLE' ) )
define(MN_TABLE, "mn_payments");
//Install script
function mn_install() {
global $wpdb;
$collate = '';
if($wpdb->supports_collation()) {
if(!empty($wpdb->charset)) $collate = "DEFAULT CHARACTER SET $wpdb->charset";
if(!empty($wpdb->collate)) $collate .= " COLLATE $wpdb->collate";
}
$query="CREATE TABLE IF NOT EXISTS `" . $wpdb->prefix.MN_TABLE . "` (
`id_transacao` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`valor` INT(9) NULL,
`status_pagamento` INT(2) UNSIGNED NULL,
`cod_moip` VARCHAR(32) NULL,
`forma_pagamento` INT(2) UNSIGNED NULL,
`tipo_pagamento` VARCHAR(32) NULL,
`email_consumidor` VARCHAR(45) NULL,
PRIMARY KEY (`id_transacao`)
) $collate;";
$wpdb->query($query);
}
//Unistall script
function mn_uninstall() {
global $wpdb;
//Delete any options that's stored also?
delete_option('mn_check_sandbox');
delete_option('mn_moip_email');
delete_option('mn_ajax_reload');
$wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix.MN_TABLE);
}