-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBCB-Platform.php
executable file
·149 lines (91 loc) · 4.6 KB
/
BCB-Platform.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
/*
Plugin Name: Barcamp Bangalore Platform
Plugin URI: http://barcampbangalore.org.com/platform
Description: Provides Scheduling capabilities and Android App compatibility for Barcamp Bangalore Platform
Version: 0.1
Author: Aman Manglik
Author URI: http://amanmanglik.com
License: GPL2
*/
register_activation_hook(__FILE__, 'bcbp_plugin_activate');
register_deactivation_hook(__FILE__, 'bcbp_plugin_deactivate');
add_action('admin_menu', 'bcbp_add_admin_menu');
function bcbp_plugin_activate()
{
add_option("bcbp_num_tracks", 6);
add_option("bcbp_num_slots", 11);
add_option("bcbp_category", 6);
$TRACKS = array('Asteroids', 'Battleship', 'Contra', 'Diablo', 'Everquest', 'Fable');
add_option("bcbp_trackdata", $TRACKS );
$SLOTS = array();
$SLOTS[] = array("type" => "fixed", "start" => "800", "end" => "900", "display_string" => "8:00AM - 9:00AM", "name" => "Registration");
$SLOTS[] = array("type" => "fixed", "start" => "900", "end" => "930", "display_string" => "9:00AM - 9:30AM", "name" => "Introduction");
$SLOTS[] = array("type" => "session", "start" => "930", "end" => "1015", "display_string" => "9:30AM - 10:15AM", "name" => "Slot 1");
$SLOTS[] = array("type" => "session", "start" => "1030", "end" => "1115", "display_string" => "10:30AM - 11:15AM", "name" => "Slot 2");
$SLOTS[] = array("type" => "session", "start" => "1130", "end" => "1215", "display_string" => "11:30AM - 12:15AM", "name" => "Slot 3");
$SLOTS[] = array("type" => "fixed", "start" => "1230", "end" => "1330", "display_string" => "12:30AM - 13:30AM", "name" => "Lunch");
$SLOTS[] = array("type" => "fixed", "start" => "1330", "end" => "1430", "display_string" => "1:30PM - 2:30PM", "name" => "Techlash");
$SLOTS[] = array("type" => "session", "start" => "1430", "end" => "1515", "display_string" => "2:30PM - 3:15PM", "name" => "Slot 4");
$SLOTS[] = array("type" => "session", "start" => "1530", "end" => "1615", "display_string" => "3:30PM - 4:15PM", "name" => "Slot 5");
$SLOTS[] = array("type" => "session", "start" => "1630", "end" => "1715", "display_string" => "4:30PM - 5:15PM", "name" => "Slot 6");
$SLOTS[] = array("type" => "fixed", "start" => "1730", "end" => "1815", "display_string" => "5:30PM - 6:15PM", "name" => "Feedback");
add_option("bcbp_slotdata", $SLOTS);
}
function bcbp_plugin_deactivate()
{
delete_option("bcbp_num_tracks");
delete_option("bcbp_num_slots");
delete_option("bcbp_category");
delete_option("bcbp_trackdata");
delete_option("bcbp_slotdata");
}
function bcbp_add_admin_menu()
{
add_menu_page('BCB Platform Administration', 'BCB Platform Admin', 'manage_options', 'bcbp_admin', 'bcbp_admin_content_callback');
}
function bcbp_admin_content_callback()
{
$NUM_TRACKS = get_option("bcbp_num_tracks");
$NUM_SLOTS = get_option("bcbp_num_slots");
$TRACKS = get_option("bcbp_trackdata");
$SLOTS = get_option("bcbp_slotdata");
?>
BCB Platform Settings
<form>
<?php for ($i = 0; $i < $NUM_TRACKS; $i++): ?>
Track <?php echo $i+1; ?> <input type="text" name="track<?php echo $i; ?>" value="<?php echo $TRACKS[$i]; ?>" /><br/>
<?php endfor; ?>
<br/><br/>
<?php for ($i = 0; $i < $NUM_SLOTS; $i++): ?>
Slot <?php echo $i+1; ?> |
Type <select name="slot-select-<?php echo $i; ?>" >
<option value="fixed" <?php if ($SLOTS[$i]['type'] == "fixed") echo 'selected' ?> >Fixed</option>
<option value="session" <?php if ($SLOTS[$i]['type'] == "session") echo 'selected' ?> >Session</option>
</select>
Name <input type="text" name="slot-name-<?php echo $i; ?>" value="<?php echo $SLOTS[$i]['name']; ?>" />
Start Time <input type="number" name="slot-start-<?php echo $i; ?>" value="<?php echo $SLOTS[$i]['start']; ?>" />
End Time <input type="number" name="slot-end-<?php echo $i; ?>" value="<?php echo $SLOTS[$i]['end']; ?>" />
<br/>
<?php endfor; ?>
</form>
<pre>
<?php
print_r($SLOTS);
print_r($TRACKS);
?>
</pre>
<?php
}
add_action("admin_enqueue_scripts", "bcbp_enqueue_admin_scripts");
function bcbp_enqueue_admin_scripts()
{
wp_enqueue_script("bcbp_admin_script", plugin_dir_url(__FILE__)."bcbp_script.js", array('jquery'));
}
add_action("wp_ajax_bcbp_tracks_form", "bcbp_get_tracks_form");
function bcbp_get_tracks_form($hook)
{
echo "TYEST".$hook;
die();
}
?>