forked from northdpole/webstuff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.php
executable file
·301 lines (268 loc) · 9.06 KB
/
options.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
<?php
class vegas{
public function __construct(){
if(is_admin()){
add_action('admin_menu', array($this, 'vegas_add_settings_page'));
add_action('admin_init', array($this, 'page_init'));
}
}
public function vegas_add_settings_page(){
add_submenu_page('edit.php?post_type=vegasslider', 'Custom Vegas Settings', 'Settings', 'edit_posts', basename(__FILE__), array($this, 'create_vegas_admin_page'));
add_action('admin_menu', 'vegas_add_settings_page'); // add the admin options page
}
public function create_vegas_admin_page(){
?>
<div class="wrap">
<?php screen_icon(); ?>
<h2>Vegas Settings</h2>
<form method="post" action="options.php">
<?php
// This prints out all hidden setting fields
settings_fields('vegas_option_group');
do_settings_sections('vegas-setting-admin');
?>
<?php submit_button(); ?>
</form>
</div>
<?php
}
public function page_init(){
register_setting('vegas_option_group', 'where_key', array($this, 'check_where'));
register_setting('vegas_option_group', 'fade_key', array($this, 'check_fade'));
register_setting('vegas_option_group', 'delay_key', array($this, 'check_delay'));
register_setting('vegas_option_group', 'overlay_key', array($this, 'check_overlay'));
register_setting('vegas_option_group', 'title_key', array($this, 'check_title'));
register_setting('vegas_option_group', 'arrows_key', array($this, 'check_arrows'));
register_setting('vegas_option_group', 'autoplay_key', array($this, 'check_autoplay'));
register_setting('vegas_option_group', 'global_key', array($this, 'check_global'));
register_setting('vegas_option_group', 'id_key', array($this, 'check_id'));
add_settings_section(
'setting_section_id',
'Setting',
array($this, 'print_section_info'),
'vegas-setting-admin'
);
add_settings_field(
'Fade',
'Fade (milliseconds):',
array($this, 'fade_field'),
'vegas-setting-admin',
'setting_section_id'
);
add_settings_field(
'Delay',
'Delay (milliseconds):',
array($this, 'delay_field'),
'vegas-setting-admin',
'setting_section_id'
);
add_settings_field(
'Overlay',
'Overlay (Full Image URL):',
array($this, 'overlay_field'),
'vegas-setting-admin',
'setting_section_id'
);
add_settings_field(
'Title',
'Title:',
array($this, 'title_field'),
'vegas-setting-admin',
'setting_section_id'
);
add_settings_field(
'Arrows',
'Display Arrows:',
array($this, 'arrows_field'),
'vegas-setting-admin',
'setting_section_id'
);
add_settings_field(
'Autoplay',
'Autoplay:',
array($this, 'autoplay_field'),
'vegas-setting-admin',
'setting_section_id'
);
add_settings_field(
'Global',
'Global (Adds the slider to every page/post):',
array($this, 'global_field'),
'vegas-setting-admin',
'setting_section_id'
);
add_settings_field(
'Id',
'Slider ID (specific to the slider you want to use):',
array($this, 'id_field'),
'vegas-setting-admin',
'setting_section_id'
);
add_settings_field(
'where',
'where (id):',
array($this, 'where_field'),
'vegas-setting-admin',
'setting_section_id'
);
}
public function check_where($input){
var_dump("Where_Check");
if( isset($input['where'])){$where = $input['where'];}
if( !isset($where['where']) && isset($input['where'])){
if(get_option('where') === FALSE){
add_option('where', $where);
}else{
update_option('where', $where);
}
}else{
$where = '';
}
return $where;
}
public function check_fade($input){
if( isset($input['Fade'])){$Fade = $input['Fade'];}
if( !isset($Fade['Fade']) && isset($input['Fade']) && is_numeric($input['Fade'])){
if(get_option('fade') === FALSE){
add_option('fade', $Fade);
}else{
update_option('fade', $Fade);
}
}else{
$Fade = '';
}
return $Fade;
}
public function check_delay($input){
if( isset($input['Delay'])){$Delay = $input['Delay'];}
if( !isset($Delay['Delay']) && isset($input['Delay']) && is_numeric($input['Delay'])){
if(get_option('delay') === FALSE){
add_option('delay', $Delay);
}else{
update_option('delay', $Delay);
}
}else{
$Delay = '';
}
return $Delay;
}
public function check_overlay($input){
if( isset($input['Overlay'])){$Overlay = $input['Overlay']; }
if(!isset($Overlay['Overlay']) && isset($input['Overlay']) &&!is_numeric ($input['Overlay'])){
if(get_option('overlay') === FALSE){
add_option('overlay', $Overlay);
}else{
update_option('overlay', $Overlay);
}
}else{
$Overlay = '';
}
return $Overlay;
}
public function check_title($input){
if( isset($input['Title'])){$Title = $input['Title']; }
if(!isset($Title['Title']) && isset($input['Title']) && !is_numeric ($input['Title'])){
if(get_option('title') === FALSE){
add_option('title', $Title);
}else{
update_option('title', $Title);
}
}else{
$Title = '';
}
return $Title;
}
public function check_arrows($input){
if( isset($input['Arrows'])){$Arrows = $input['Arrows']; }
if ( !isset( $Arrows['arrows'] ) ) {
$Arrows = 0;
add_option('arrows', $Arrows);
}
if ( $input['Arrows'] == 1 ) {
$Arrows = 1;
update_option('arrows', $Arrows);
} else {
$Arrows = 0;
update_option('arrows', $Arrows);
}
return $Arrows;
}
public function check_autoplay($input){
if( isset($input['Autoplay'])){$Autoplay = $input['Autoplay']; }
if ( $input['Autoplay'] == 1 ) {
$Autoplay = 1;
update_option('autoplay', $Autoplay);
} else {
$Autoplay = 0;
update_option('autoplay', $Autoplay);
}
return $Autoplay;
}
public function check_global($input){
if( isset($input['Global'])){$Global = $input['Global']; }
if ( $input['Global'] == 1 ) {
$Global = 1;
update_option('global', $Global);
} else {
$Global = 0;
update_option('global', $Global);
}
return $Global;
}
public function check_id($input){
if( isset($input['Id'])){$ID = $input['Id']; }
if(!isset($ID['Id']) && isset($input['Id']) && is_numeric($input['Id'])){
if(get_option('id') === FALSE){
add_option('id', $ID);
}else{
update_option('id', $ID);
}
}else{
$ID = '';
}
return $ID;
}
public function print_section_info(){
print 'These settings help define the shortcodes that are generated for you when you create a slide and are used exclusively if you use the global option. Enter your settings below:';
}
public function fade_field(){
?><input type="text" id="fade" name="fade_key[Fade]" value="<?php echo get_option('fade'); ?>" /><?php
}
public function delay_field(){
?><input type="text" id="delay" name="delay_key[Delay]" value="<?php echo get_option('delay'); ?>" /><?php
}
public function overlay_field(){
?><input type="text" id="overlay" name="overlay_key[Overlay]" value="<?php echo get_option('overlay'); ?>" /><?php
}
public function title_field(){
?><input type="text" id="title" name="title_key[Title]" value="<?php echo get_option('title'); ?>" /><?php
}
public function where_field(){
?><input type="text" id="where" name="where_key[where]" value="<?php echo get_option('where'); ?>" /><?php
}
public function arrows_field(){
$Arrows = get_option('arrows');
if($Arrows == 1) { $checked = ' checked="checked" '; }
else{ $checked = '';}
echo '<input type="checkbox" id="arrows" name="arrows_key[Arrows]" value="1" '.$checked.' />'; //<333333
}
public function autoplay_field(){
$Autoplay = get_option('autoplay');
if($Autoplay == 1) { $checked = ' checked="checked" '; }
else{ $checked = '';}
echo '<input type="checkbox" id="autoplay" name="autoplay_key[Autoplay]" value="1" '.$checked.' />';
}
public function global_field(){
$Global = get_option('global');
if($Global == 1) { $checked = ' checked="checked" '; }
else{ $checked = '';}
echo '<input type="checkbox" id="global" name="global_key[Global]" value="1" '.$checked.' />';
}
public function id_field(){
$Global = get_option('global');
?><input type="text" id="id" name="id_key[Id]" value="<?php echo get_option('id');?>" <?php if($Global != 1){echo 'disabled="disabled"';} ?> /><br/>
<p>Note: You have to set the global option and save before you can add the id. Also the id is neccessary if you're going to use the global option.<br/> You can find the id on the slide page (where you added the photos)</p>
<?php
}
}
$vs_enet = new vegas(); ?>