-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathqa-hide-category-admin.php
executable file
·68 lines (51 loc) · 1.91 KB
/
qa-hide-category-admin.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
<?php
/*
Question2Answer (c) Gideon Greenspan
http://www.question2answer.org/
Hide Category Plugin by Bruno Vandekerkhove © 2015
*/
class qa_hide_category_admin {
// Default admin options
function option_default($option) {
switch($option) {
case 'qa_hide_category_enabled':
return false;
case 'qa_hide_category_slug':
return 'mycategory';
default:
return null;
}
}
// Allow template
function allow_template($template) {
return ($template != 'admin');
}
// Create admin form
function admin_form(&$qa_content) {
// Process form input
$ok = null;
if (qa_clicked('qa_hide_category_save')) {
qa_opt('qa_hide_category_slug',qa_post_text('qa_hide_category_slug'));
qa_opt('qa_hide_category_enabled',(bool)qa_post_text('qa_hide_category_enabled'));
$ok = qa_lang('admin/options_saved');
}
else if (qa_clicked('qa_hide_category_reset')) {
// Reset options
qa_opt('qa_hide_category_enabled',$this->option_default('qa_hide_category_enabled'));
qa_opt('qa_hide_category_slug',$this->option_default('qa_hide_category_slug'));
$ok = qa_lang('admin/options_reset');
}
// Create the form for display
$fields = array();
$fields[] = array('label' => 'Hide category', 'tags' => 'NAME="qa_hide_category_enabled"', 'value' => qa_opt('qa_hide_category_enabled'), 'type' => 'checkbox',);
$fields[] = array('label' => 'Category slug', 'type' => 'text', 'value' => qa_opt('qa_hide_category_slug'), 'tags' => 'NAME="qa_hide_category_slug"',);
return array(
'ok' => ($ok && !isset($error)) ? $ok : null,
'fields' => $fields,
'buttons' => array(
array('label' => 'Save', 'tags' => 'NAME="qa_hide_category_save"',),
array('label' => 'Reset to defaults', 'tags' => 'NAME="qa_hide_category_reset"',)
),
);
}
}