This repository has been archived by the owner on Sep 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFlovidy_LifeCycle.php
88 lines (70 loc) · 2.46 KB
/
Flovidy_LifeCycle.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
81
82
83
84
85
86
87
88
<?php
include_once('Flovidy_InstallIndicator.php');
class Flovidy_LifeCycle extends Flovidy_InstallIndicator {
public function install() {
// Initialize Plugin Options
$this->initOptions();
// Initialize DB Tables used by the plugin
$this->installDatabaseTables();
// Record the installed version
$this->saveInstalledVersion();
// To avoid running install() more then once
$this->markAsInstalled();
}
public function uninstall() {
$this->unInstallDatabaseTables();
$this->deleteSavedOptions();
$this->markAsUnInstalled();
}
public function upgrade() {
}
public function activate() {
}
public function deactivate() {
}
protected function initOptions() {
}
public function addActionsAndFilters() {
}
protected function installDatabaseTables() {
global $wpdb;
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
$table_name = $wpdb->prefix . 'ai_link';
$charset_collate = $wpdb->get_charset_collate();
$sql = "CREATE TABLE $table_name (
id mediumint(9) NOT NULL AUTO_INCREMENT,
us_link TEXT(1400),
in_link TEXT(1400),
jp_link TEXT(1400),
fr_link TEXT(1400),
de_link TEXT(1400),
it_link TEXT(1400),
es_link TEXT(1400),
uk_link TEXT(1400),
ca_link TEXT(1400),
br_link TEXT(1400),
cn_link TEXT(1400),
au_link TEXT(1400),
PRIMARY KEY (id)
) $charset_collate;";
dbDelta( $sql );
}
protected function unInstallDatabaseTables() {
global $wpdb;
$table_name_links = $wpdb->prefix . 'ai_link';
$wpdb->query( "DROP TABLE IF EXISTS $table_name_links;" );
}
public function addSettingsSubMenuPage() {
$this->requireExtraPluginFiles();
$displayName = "Flovidy";
add_options_page($displayName, $displayName, 'manage_options', get_class($this) . 'Settings', array(&$this, 'settingsPage'));
}
protected function requireExtraPluginFiles() {
require_once(ABSPATH . 'wp-includes/pluggable.php');
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
}
protected function prefixTableName($name) {
global $wpdb;
return $wpdb->prefix . strtolower($this->prefix($name));
}
}