-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathform.php
105 lines (87 loc) · 2.94 KB
/
form.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
/*
Plugin Name: Form
Plugin URI: http://pc-moon.net
Description: Hello , This's Plugin Created By AL-Jazaeri Mohammed
Version: 1.0.0
Author URI: http://pc-moon.net
*/
if (!defined('ABSPATH')) {
header('HTTP/1.0 403 Forbidden');
exit;
}
//start : activation
function myplugin_activate() {
global $wpdb;
$table_name1 = $wpdb->prefix . "foodrequests";
$table_name2 = $wpdb->prefix . "regions";
$table_name3 = $wpdb->prefix . "regionperm";
$charset_collate = $wpdb->get_charset_collate();
$sql1 = "
CREATE TABLE IF NOT EXISTS {$table_name1} (
id bigint(20) NOT NULL AUTO_INCREMENT,
title varchar(250) DEFAULT NULL,
details text,
foods text,
email varchar(100) ,
mobile varchar(20) ,
address text,
region int(5) DEFAULT NULL,
created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
sentmail text NOT NULL DEFAULT 0,
finished int(11) NOT NULL,
PRIMARY KEY ( id )
) {$charset_collate};
";
$sql2 = "
CREATE TABLE IF NOT EXISTS {$table_name2} (
id int(11) NOT NULL AUTO_INCREMENT COMMENT 'التسلسل',
title varchar(250) NOT NULL COMMENT 'الاسم',
PRIMARY KEY ( id )
) {$charset_collate};
";
$sql3 = "
CREATE TABLE IF NOT EXISTS {$table_name3} (
id int(4) NOT NULL AUTO_INCREMENT,
rid int(11) NOT NULL,
uid int(11) NOT NULL,
PRIMARY KEY ( id )
) {$charset_collate};
";
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta($sql1);
dbDelta($sql2);
dbDelta($sql3);
}
register_activation_hook(__FILE__, 'myplugin_activate');
//end : activation
//start : uninstall
function myplugin_uninstall() {
global
$wpdb;
$table_name1 = $wpdb->prefix . "foodrequests";
$table_name2 = $wpdb->prefix . "regions";
$table_name3 = $wpdb->prefix . "regionperm";
$wpdb->query("DROP TABLE IF EXISTS {$table_name1},{$table_name2},{$table_name3}");
}
register_uninstall_hook(__FILE__, 'myplugin_uninstall');
//End : uninstall
function shortcode_form($atts) {
ob_start();
require_once 'script/mainform.php';
$c = forn_controller();
$v = form_view();
return $c.$v ;
}
add_shortcode('lf', 'shortcode_form');
//add menu
add_action('admin_menu', 'my_admin_menu');
function my_admin_menu() {
add_menu_page('Left Food', 'Left Food\'s', 'manage_options', 'foodleft', 'mainpage', 'dashicons-tickets', 2);
add_submenu_page('foodleft','المناطق', 'المناطق', 'manage_options', 'regions', 'regions' );
add_submenu_page('foodleft','طلبات تواجد الطعام', 'طلبات تواجد الطعام', 'manage_options', 'requests', 'requests' );
}
function mainpage(){include_once 'script/mainpage.php';pagemain();}
function regions(){include_once 'script/regions.php';pageregions();}
function requests(){include_once 'script/requests.php';pagerequests();}
?>