-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.php
executable file
·215 lines (175 loc) · 7.29 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
<?php
/**
* A unique identifier is defined to store the options in the database and reference them from the theme.
* By default it uses the theme name, in lowercase and without spaces, but this can be changed if needed.
* If the identifier changes, it'll appear as if the options have been reset.
*
*/
function optionsframework_option_name() {
// This gets the theme name from the stylesheet (lowercase and without spaces)
$themename = get_theme_data(STYLESHEETPATH . '/style.css');
$themename = $themename['Name'];
$themename = preg_replace("/\W/", "", strtolower($themename) );
$optionsframework_settings = get_option('optionsframework');
$optionsframework_settings['id'] = $themename;
update_option('optionsframework', $optionsframework_settings);
// echo $themename;
}
/**
* Defines an array of options that will be used to generate the settings page and be saved in the database.
* When creating the "id" fields, make sure to use all lowercase and no spaces.
*
*/
function optionsframework_options() {
// Test data
$test_array = array("one" => "One","two" => "Two","three" => "Three","four" => "Four","five" => "Five");
// Multicheck Array
$multicheck_array = array("one" => "French Toast", "two" => "Pancake", "three" => "Omelette", "four" => "Crepe", "five" => "Waffle");
// Multicheck Defaults
$multicheck_defaults = array("one" => "1","five" => "1");
// Background Defaults
$background_defaults = array('color' => '', 'image' => '', 'repeat' => 'repeat','position' => 'top center','attachment'=>'scroll');
// Pull all the categories into an array
$options_categories = array();
$options_categories_obj = get_categories();
foreach ($options_categories_obj as $category) {
$options_categories[$category->cat_ID] = $category->cat_name;
}
// Pull all the pages into an array
$options_pages = array();
$options_pages_obj = get_pages('sort_column=post_parent,menu_order');
$options_pages[''] = 'Select a page:';
foreach ($options_pages_obj as $page) {
$options_pages[$page->ID] = $page->post_title;
}
// If using image radio buttons, define a directory path
$imagepath = get_bloginfo('stylesheet_directory') . '/images/';
$options = array();
$options[] = array( "name" => "Basic Settings",
"type" => "heading");
$options[] = array( "name" => "Body Background Color",
"desc" => "Change the background CSS color of the body.",
"id" => "body_background",
"std" => "",
"type" => "color");
$options[] = array( "name" => "Header Background Color",
"desc" => "No color selected by default.",
"id" => "header_background",
"std" => "",
"type" => "color");
$options[] = array( "name" => "Header Background Image",
"desc" => "Background image that lays behind the ccmech logo. Maximum width: 810px. Maximum height: 160px",
"id" => "header_background_image",
"type" => "upload");
$options[] = array( "name" => "Navigation Color - 1",
"desc" => "No color selected by default.",
"id" => "nav_background1",
"std" => "",
"type" => "color");
$options[] = array( "name" => "Navigation Color - 2",
"desc" => "No color selected by default.",
"id" => "nav_background2",
"std" => "",
"type" => "color");
$options[] = array( "name" => "Input Text Mini",
"desc" => "A mini text input field.",
"id" => "example_text_mini",
"std" => "Default",
"class" => "mini",
"type" => "text");
$options[] = array( "name" => "Input Text",
"desc" => "A text input field.",
"id" => "example_text",
"std" => "Default Value",
"type" => "text");
$options[] = array( "name" => "Textarea",
"desc" => "Textarea description.",
"id" => "example_textarea",
"std" => "Default Text",
"type" => "textarea");
$options[] = array( "name" => "Input Select Small",
"desc" => "Small Select Box.",
"id" => "example_select",
"std" => "three",
"type" => "select",
"class" => "mini", //mini, tiny, small
"options" => $test_array);
$options[] = array( "name" => "Input Select Wide",
"desc" => "A wider select box.",
"id" => "example_select_wide",
"std" => "two",
"type" => "select",
"options" => $test_array);
$options[] = array( "name" => "Select a Category",
"desc" => "Passed an array of categories with cat_ID and cat_name",
"id" => "example_select_categories",
"type" => "select",
"options" => $options_categories);
$options[] = array( "name" => "Select a Page",
"desc" => "Passed an pages with ID and post_title",
"id" => "example_select_pages",
"type" => "select",
"options" => $options_pages);
$options[] = array( "name" => "Input Radio (one)",
"desc" => "Radio select with default options 'one'.",
"id" => "example_radio",
"std" => "one",
"type" => "radio",
"options" => $test_array);
$options[] = array( "name" => "Example Info",
"desc" => "This is just some example information you can put in the panel.",
"type" => "info");
$options[] = array( "name" => "Input Checkbox",
"desc" => "Example checkbox, defaults to true.",
"id" => "example_checkbox",
"std" => "1",
"type" => "checkbox");
$options[] = array( "name" => "Advanced Settings",
"type" => "heading");
$options[] = array( "name" => "Check to Show a Hidden Text Input",
"desc" => "Click here and see what happens.",
"id" => "example_showhidden",
"type" => "checkbox");
$options[] = array( "name" => "Hidden Text Input",
"desc" => "This option is hidden unless activated by a checkbox click.",
"id" => "example_text_hidden",
"std" => "Hello",
"class" => "hidden",
"type" => "text");
$options[] = array( "name" => "Uploader Test",
"desc" => "This creates a full size uploader that previews the image.",
"id" => "example_uploader",
"type" => "upload");
$options[] = array( "name" => "Example Image Selector",
"desc" => "Images for layout.",
"id" => "example_images",
"std" => "2c-l-fixed",
"type" => "images",
"options" => array(
'1col-fixed' => $imagepath . '1col.png',
'2c-l-fixed' => $imagepath . '2cl.png',
'2c-r-fixed' => $imagepath . '2cr.png')
);
$options[] = array( "name" => "Example Background",
"desc" => "Change the background CSS.",
"id" => "example_background",
"std" => $background_defaults,
"type" => "background");
$options[] = array( "name" => "Multicheck",
"desc" => "Multicheck description.",
"id" => "example_multicheck",
"std" => $multicheck_defaults, // These items get checked by default
"type" => "multicheck",
"options" => $multicheck_array);
$options[] = array( "name" => "Colorpicker",
"desc" => "No color selected by default.",
"id" => "example_colorpicker",
"std" => "",
"type" => "color");
$options[] = array( "name" => "Typography",
"desc" => "Example typography.",
"id" => "example_typography",
"std" => array('size' => '12px','face' => 'verdana','style' => 'bold italic','color' => '#123456'),
"type" => "typography");
return $options;
}