forked from Automattic/cheezcap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config-sample.php
163 lines (158 loc) · 5.33 KB
/
config-sample.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
<?php
/**
* CheezCap - Cheezburger Custom Administration Panel
* (c) 2008 - 2011 Cheezburger Network (Pet Holdings, Inc.)
* LOL: http://cheezburger.com
* Source: http://github.com/cheezburger/cheezcap/
* Authors: Kyall Barrows, Toby McKes, Stefan Rusek, Scott Porad
* UnLOLs by Mo Jangda ([email protected])
* License: GNU General Public License, version 2 (GPL), http://www.gnu.org/licenses/gpl-2.0.html
*/
$number_entries = array( '', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '12', '14', '16', '18', '20' );
$number_entries_labels = array( '== Select a Number ==' );
$multiple_checkboxes = array( '', 'one', 'two', 'three' );
$multiple_checkboxes_labels = array '', 'One', 'Two', 'Three' );
$cap = new CheezCap( array(
new CheezCapGroup( 'First Group', 'firstGroup',
array(
new CheezCapBooleanOption(
'Simple Boolean Example',
'This will create a simple true/false switch with default of "true".',
'simple_boolean_example',
true
),
new CheezCapTextOption(
'Simple Text Example',
'This will create store a string value with a default of "Say Cheez!".',
'simple_text_example',
'Say Cheez!'
),
new CheezCapTextOption(
'Text Area Example',
'This text option is displayed as a Text Area',
'text_area_example',
'Sup Dawg? I put an option in your option so that you would have options.',
true
),
new CheezCapDropdownOption(
'Reusable Options Dropdown Example',
'This dropdown creates its options by reusing an array.',
'resuable_options_dropdown_example',
$number_entries,
0, // Default index is 0, 0 == 'Select a Number:'
$number_entries_labels
),
new CheezCapMultipleCheckboxesOption(
'Multiple Checkboxes Options Example',
'Example of multiple checkboxes option',
'multiple_checkboxes_example',
$multiple_checkboxes,
$multiple_checkboxes_labels,
// Checked keys of an array
array( 'one', 'two' ),
// Validation callback, also works on other Cheezcap Options (except boolean)
'my_validation_cb'
),
)
),
new CheezCapGroup( 'Another Group', 'anotherGroup',
array(
new CheezCapBooleanOption(
'Simple Boolean Example #2',
'This will create a simple true/false switch with default of "true".',
'simple_boolean_example2',
true
),
new CheezCapTextOption(
'Simple Text Example #2',
'This will create store a string value with a default of "Say Cheez!".',
'simple_text_example2',
'Say Cheez!'
),
new CheezCapTextOption(
'Text Area Example #2',
'This text option is displayed as a Text Area',
'text_area_example2',
'Sup Dawg? I put an option in your option so that you would have options.',
true
),
new CheezCapDropdownOption(
'Inline Options Dropdown Example #2',
'This dropdown creates its options using an inline array.',
'inline_options_dropdown_example2',
array( 'Red', 'Yellow', 'Green' ),
1 // Yellow
),
new CheezCapDropdownOption(
'Reusable Options Dropdown Example #2',
'This dropdown creates its options by reusing an array.',
'resuable_options_dropdown_example2',
$number_entries,
1, // 1
$number_entries_labels
),
)
),
new CheezCapGroup( 'Yet Another', 'yetAnother',
array(
new CheezCapBooleanOption(
'Simple Boolean Example #3',
'This will create a simple true/false switch with default of "true".',
'simple_boolean_example3',
true
),
new CheezCapTextOption(
'Simple Text Example #3',
'This will create store a string value with a default of "Say Cheez!".',
'simple_text_example3',
'Say Cheez!'
),
new CheezCapTextOption(
'Text Area Example #3',
'This text option is displayed as a Text Area',
'text_area_example3',
'Sup Dawg? I put an option in your option so that you would have options.',
true
),
new CheezCapDropdownOption(
'Inline Options Dropdown Example #3',
'This dropdown creates its options using an inline array.',
'inline_options_dropdown_example3',
array( 'Red', 'Yellow', 'Green' ),
2 // Green
),
new CheezCapDropdownOption(
'Reusable Options Dropdown Example #3',
'This dropdown creates its options by reusing an array.',
'resuable_options_dropdown_example3',
$number_entries,
2, // 2
$number_entries_labels
),
)
)
), array(
'themename' => 'CheezCap', // used on the title of the custom admin page
'req_cap_to_edit' => 'manage_options', // the user capability that is required to access the CheezCap settings page
'cap_menu_position' => 99, // OPTIONAL: This value represents the order in the dashboard menu that the CheezCap menu will display in. Larger numbers push it further down.
'cap_icon_url' => '', // OPTIONAL: Path to a custom icon for the CheezCap menu item. ex. $cap_icon_url = WP_CONTENT_URL . '/your-theme-name/images/awesomeicon.png'; Image size should be around 20px x 20px.
)
);
/**
* Custom validation callback
*
* @param $key cheezcap option key
* @param mixed $value value of option
*
*/
function my_validation_cb( $key, $value ) {
switch ( $key ) {
case 'my-date':
// Perform date specific validation
break;
default:
// Treat everything else as string
$value = filter_var( $value, FILTER_SANITIZE_STRING );
}
return $value;
}