Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 298 lines (249 sloc) 9.726 kb
6926ce7 @devinsays Complete rewrite using Options Framework Plugin code as a base.
devinsays authored
1 <?php
2 /**
3 * A unique identifier is defined to store the options in the database and reference them from the theme.
4 * By default it uses the theme name, in lowercase and without spaces, but this can be changed if needed.
5 * If the identifier changes, it'll appear as if the options have been reset.
6 */
7
8 function optionsframework_option_name() {
bea13cc @devinsays Update textdomain name.
devinsays authored
9
10 // This gets the theme name from the stylesheet
11 $themename = get_option( 'stylesheet' );
12 $themename = preg_replace("/\W/", "_", strtolower($themename) );
13
14 $optionsframework_settings = get_option( 'optionsframework' );
6926ce7 @devinsays Complete rewrite using Options Framework Plugin code as a base.
devinsays authored
15 $optionsframework_settings['id'] = $themename;
bea13cc @devinsays Update textdomain name.
devinsays authored
16 update_option( 'optionsframework', $optionsframework_settings );
6926ce7 @devinsays Complete rewrite using Options Framework Plugin code as a base.
devinsays authored
17 }
18
19 /**
20 * Defines an array of options that will be used to generate the settings page and be saved in the database.
8de4fea fully translation support
Satrya Bima authored
21 * When creating the 'id' fields, make sure to use all lowercase and no spaces.
bea13cc @devinsays Update textdomain name.
devinsays authored
22 *
23 * If you are making your theme translatable, you should replace 'options_framework_theme'
24 * with the actual text domain for your theme. Read more:
25 * http://codex.wordpress.org/Function_Reference/load_theme_textdomain
6926ce7 @devinsays Complete rewrite using Options Framework Plugin code as a base.
devinsays authored
26 */
27
28 function optionsframework_options() {
bea13cc @devinsays Update textdomain name.
devinsays authored
29
6926ce7 @devinsays Complete rewrite using Options Framework Plugin code as a base.
devinsays authored
30 // Test data
bea13cc @devinsays Update textdomain name.
devinsays authored
31 $test_array = array(
32 'one' => __('One', 'options_framework_theme'),
33 'two' => __('Two', 'options_framework_theme'),
34 'three' => __('Three', 'options_framework_theme'),
35 'four' => __('Four', 'options_framework_theme'),
36 'five' => __('Five', 'options_framework_theme')
37 );
38
6926ce7 @devinsays Complete rewrite using Options Framework Plugin code as a base.
devinsays authored
39 // Multicheck Array
bea13cc @devinsays Update textdomain name.
devinsays authored
40 $multicheck_array = array(
41 'one' => __('French Toast', 'options_framework_theme'),
42 'two' => __('Pancake', 'options_framework_theme'),
43 'three' => __('Omelette', 'options_framework_theme'),
44 'four' => __('Crepe', 'options_framework_theme'),
45 'five' => __('Waffle', 'options_framework_theme')
46 );
47
6926ce7 @devinsays Complete rewrite using Options Framework Plugin code as a base.
devinsays authored
48 // Multicheck Defaults
bea13cc @devinsays Update textdomain name.
devinsays authored
49 $multicheck_defaults = array(
50 'one' => '1',
51 'five' => '1'
52 );
53
6926ce7 @devinsays Complete rewrite using Options Framework Plugin code as a base.
devinsays authored
54 // Background Defaults
bea13cc @devinsays Update textdomain name.
devinsays authored
55 $background_defaults = array(
56 'color' => '',
57 'image' => '',
58 'repeat' => 'repeat',
59 'position' => 'top center',
cad7259 @devinsays Updates for 1.1.
devinsays authored
60 'attachment'=>'scroll' );
61
62 // Typography Defaults
63 $typography_defaults = array(
64 'size' => '15px',
65 'face' => 'georgia',
66 'style' => 'bold',
67 'color' => '#bada55' );
68
69 // Typography Options
70 $typography_options = array(
71 'sizes' => array( '6','12','14','16','20' ),
72 'faces' => array( 'Helvetica Neue' => 'Helvetica Neue','Arial' => 'Arial' ),
73 'styles' => array( 'normal' => 'Normal','bold' => 'Bold' ),
74 'color' => false
bea13cc @devinsays Update textdomain name.
devinsays authored
75 );
76
6926ce7 @devinsays Complete rewrite using Options Framework Plugin code as a base.
devinsays authored
77 // Pull all the categories into an array
bea13cc @devinsays Update textdomain name.
devinsays authored
78 $options_categories = array();
6926ce7 @devinsays Complete rewrite using Options Framework Plugin code as a base.
devinsays authored
79 $options_categories_obj = get_categories();
80 foreach ($options_categories_obj as $category) {
bea13cc @devinsays Update textdomain name.
devinsays authored
81 $options_categories[$category->cat_ID] = $category->cat_name;
6926ce7 @devinsays Complete rewrite using Options Framework Plugin code as a base.
devinsays authored
82 }
bea13cc @devinsays Update textdomain name.
devinsays authored
83
6926ce7 @devinsays Complete rewrite using Options Framework Plugin code as a base.
devinsays authored
84 // Pull all the pages into an array
bea13cc @devinsays Update textdomain name.
devinsays authored
85 $options_pages = array();
6926ce7 @devinsays Complete rewrite using Options Framework Plugin code as a base.
devinsays authored
86 $options_pages_obj = get_pages('sort_column=post_parent,menu_order');
87 $options_pages[''] = 'Select a page:';
88 foreach ($options_pages_obj as $page) {
bea13cc @devinsays Update textdomain name.
devinsays authored
89 $options_pages[$page->ID] = $page->post_title;
6926ce7 @devinsays Complete rewrite using Options Framework Plugin code as a base.
devinsays authored
90 }
bea13cc @devinsays Update textdomain name.
devinsays authored
91
6926ce7 @devinsays Complete rewrite using Options Framework Plugin code as a base.
devinsays authored
92 // If using image radio buttons, define a directory path
a9156ef @devinsays Update image path.
devinsays authored
93 $imagepath = get_template_directory_uri() . '/images/';
bea13cc @devinsays Update textdomain name.
devinsays authored
94
6926ce7 @devinsays Complete rewrite using Options Framework Plugin code as a base.
devinsays authored
95 $options = array();
bea13cc @devinsays Update textdomain name.
devinsays authored
96
cad7259 @devinsays Updates for 1.1.
devinsays authored
97 $options[] = array(
98 'name' => __('Basic Settings', 'options_framework_theme'),
bea13cc @devinsays Update textdomain name.
devinsays authored
99 'type' => 'heading');
100
cad7259 @devinsays Updates for 1.1.
devinsays authored
101 $options[] = array(
102 'name' => __('Input Text Mini', 'options_framework_theme'),
bea13cc @devinsays Update textdomain name.
devinsays authored
103 'desc' => __('A mini text input field.', 'options_framework_theme'),
104 'id' => 'example_text_mini',
105 'std' => 'Default',
106 'class' => 'mini',
107 'type' => 'text');
108
cad7259 @devinsays Updates for 1.1.
devinsays authored
109 $options[] = array(
110 'name' => __('Input Text', 'options_framework_theme'),
bea13cc @devinsays Update textdomain name.
devinsays authored
111 'desc' => __('A text input field.', 'options_framework_theme'),
112 'id' => 'example_text',
113 'std' => 'Default Value',
114 'type' => 'text');
115
cad7259 @devinsays Updates for 1.1.
devinsays authored
116 $options[] = array(
117 'name' => __('Textarea', 'options_framework_theme'),
bea13cc @devinsays Update textdomain name.
devinsays authored
118 'desc' => __('Textarea description.', 'options_framework_theme'),
119 'id' => 'example_textarea',
120 'std' => 'Default Text',
121 'type' => 'textarea');
122
cad7259 @devinsays Updates for 1.1.
devinsays authored
123 $options[] = array(
124 'name' => __('Input Select Small', 'options_framework_theme'),
bea13cc @devinsays Update textdomain name.
devinsays authored
125 'desc' => __('Small Select Box.', 'options_framework_theme'),
126 'id' => 'example_select',
127 'std' => 'three',
128 'type' => 'select',
129 'class' => 'mini', //mini, tiny, small
130 'options' => $test_array);
131
cad7259 @devinsays Updates for 1.1.
devinsays authored
132 $options[] = array(
133 'name' => __('Input Select Wide', 'options_framework_theme'),
bea13cc @devinsays Update textdomain name.
devinsays authored
134 'desc' => __('A wider select box.', 'options_framework_theme'),
135 'id' => 'example_select_wide',
136 'std' => 'two',
137 'type' => 'select',
138 'options' => $test_array);
139
cad7259 @devinsays Updates for 1.1.
devinsays authored
140 $options[] = array(
141 'name' => __('Select a Category', 'options_framework_theme'),
bea13cc @devinsays Update textdomain name.
devinsays authored
142 'desc' => __('Passed an array of categories with cat_ID and cat_name', 'options_framework_theme'),
143 'id' => 'example_select_categories',
144 'type' => 'select',
145 'options' => $options_categories);
146
cad7259 @devinsays Updates for 1.1.
devinsays authored
147 $options[] = array(
148 'name' => __('Select a Page', 'options_framework_theme'),
bea13cc @devinsays Update textdomain name.
devinsays authored
149 'desc' => __('Passed an pages with ID and post_title', 'options_framework_theme'),
150 'id' => 'example_select_pages',
151 'type' => 'select',
152 'options' => $options_pages);
153
cad7259 @devinsays Updates for 1.1.
devinsays authored
154 $options[] = array(
155 'name' => __('Input Radio (one)', 'options_framework_theme'),
bea13cc @devinsays Update textdomain name.
devinsays authored
156 'desc' => __('Radio select with default options "one".', 'options_framework_theme'),
157 'id' => 'example_radio',
158 'std' => 'one',
159 'type' => 'radio',
160 'options' => $test_array);
161
cad7259 @devinsays Updates for 1.1.
devinsays authored
162 $options[] = array(
163 'name' => __('Example Info', 'options_framework_theme'),
bea13cc @devinsays Update textdomain name.
devinsays authored
164 'desc' => __('This is just some example information you can put in the panel.', 'options_framework_theme'),
165 'type' => 'info');
166
cad7259 @devinsays Updates for 1.1.
devinsays authored
167 $options[] = array(
168 'name' => __('Input Checkbox', 'options_framework_theme'),
bea13cc @devinsays Update textdomain name.
devinsays authored
169 'desc' => __('Example checkbox, defaults to true.', 'options_framework_theme'),
170 'id' => 'example_checkbox',
171 'std' => '1',
172 'type' => 'checkbox');
173
cad7259 @devinsays Updates for 1.1.
devinsays authored
174 $options[] = array(
175 'name' => __('Advanced Settings', 'options_framework_theme'),
bea13cc @devinsays Update textdomain name.
devinsays authored
176 'type' => 'heading');
177
cad7259 @devinsays Updates for 1.1.
devinsays authored
178 $options[] = array(
179 'name' => __('Check to Show a Hidden Text Input', 'options_framework_theme'),
bea13cc @devinsays Update textdomain name.
devinsays authored
180 'desc' => __('Click here and see what happens.', 'options_framework_theme'),
181 'id' => 'example_showhidden',
182 'type' => 'checkbox');
cad7259 @devinsays Updates for 1.1.
devinsays authored
183
184 $options[] = array(
185 'name' => __('Hidden Text Input', 'options_framework_theme'),
bea13cc @devinsays Update textdomain name.
devinsays authored
186 'desc' => __('This option is hidden unless activated by a checkbox click.', 'options_framework_theme'),
187 'id' => 'example_text_hidden',
188 'std' => 'Hello',
189 'class' => 'hidden',
190 'type' => 'text');
191
cad7259 @devinsays Updates for 1.1.
devinsays authored
192 $options[] = array(
193 'name' => __('Uploader Test', 'options_framework_theme'),
bea13cc @devinsays Update textdomain name.
devinsays authored
194 'desc' => __('This creates a full size uploader that previews the image.', 'options_framework_theme'),
195 'id' => 'example_uploader',
196 'type' => 'upload');
197
cad7259 @devinsays Updates for 1.1.
devinsays authored
198 $options[] = array(
199 'name' => "Example Image Selector",
200 'desc' => "Images for layout.",
201 'id' => "example_images",
202 'std' => "2c-l-fixed",
203 'type' => "images",
bea13cc @devinsays Update textdomain name.
devinsays authored
204 'options' => array(
205 '1col-fixed' => $imagepath . '1col.png',
206 '2c-l-fixed' => $imagepath . '2cl.png',
207 '2c-r-fixed' => $imagepath . '2cr.png')
208 );
209
cad7259 @devinsays Updates for 1.1.
devinsays authored
210 $options[] = array(
211 'name' => __('Example Background', 'options_framework_theme'),
bea13cc @devinsays Update textdomain name.
devinsays authored
212 'desc' => __('Change the background CSS.', 'options_framework_theme'),
213 'id' => 'example_background',
214 'std' => $background_defaults,
cad7259 @devinsays Updates for 1.1.
devinsays authored
215 'type' => 'background' );
bea13cc @devinsays Update textdomain name.
devinsays authored
216
cad7259 @devinsays Updates for 1.1.
devinsays authored
217 $options[] = array(
218 'name' => __('Multicheck', 'options_framework_theme'),
bea13cc @devinsays Update textdomain name.
devinsays authored
219 'desc' => __('Multicheck description.', 'options_framework_theme'),
220 'id' => 'example_multicheck',
221 'std' => $multicheck_defaults, // These items get checked by default
222 'type' => 'multicheck',
223 'options' => $multicheck_array);
224
cad7259 @devinsays Updates for 1.1.
devinsays authored
225 $options[] = array(
226 'name' => __('Colorpicker', 'options_framework_theme'),
bea13cc @devinsays Update textdomain name.
devinsays authored
227 'desc' => __('No color selected by default.', 'options_framework_theme'),
228 'id' => 'example_colorpicker',
229 'std' => '',
cad7259 @devinsays Updates for 1.1.
devinsays authored
230 'type' => 'color' );
231
bea13cc @devinsays Update textdomain name.
devinsays authored
232 $options[] = array( 'name' => __('Typography', 'options_framework_theme'),
233 'desc' => __('Example typography.', 'options_framework_theme'),
cad7259 @devinsays Updates for 1.1.
devinsays authored
234 'id' => "example_typography",
235 'std' => $typography_defaults,
236 'type' => 'typography' );
237
238 $options[] = array(
239 'name' => __('Custom Typography', 'options_framework_theme'),
240 'desc' => __('Custom typography options.', 'options_framework_theme'),
241 'id' => "custom_typography",
242 'std' => $typography_defaults,
243 'type' => 'typography',
244 'options' => $typography_options );
245
246 $options[] = array(
247 'name' => __('Text Editor', 'options_framework_theme'),
248 'type' => 'heading' );
249
250 /**
251 * For $settings options see:
252 * http://codex.wordpress.org/Function_Reference/wp_editor
253 *
254 * 'media_buttons' are not supported as there is no post to attach items to
255 * 'textarea_name' is set by the 'id' you choose
256 */
257
258 $wp_editor_settings = array(
259 'wpautop' => true, // Default
260 'textarea_rows' => 5,
261 'tinymce' => array( 'plugins' => 'wordpress' )
262 );
263
264 $options[] = array(
265 'name' => __('Default Text Editor', 'options_framework_theme'),
266 'desc' => sprintf( __( 'You can also pass settings to the editor. Read more about wp_editor in <a href="%1$s" target="_blank">the WordPress codex</a>', 'options_framework_theme' ), 'http://codex.wordpress.org/Function_Reference/wp_editor' ),
267 'id' => 'example_editor',
268 'type' => 'editor',
269 'settings' => $wp_editor_settings );
270
6926ce7 @devinsays Complete rewrite using Options Framework Plugin code as a base.
devinsays authored
271 return $options;
e0e38f6 @devinsays Minor code cleanup. Simplify functions.php.
devinsays authored
272 }
273
bea13cc @devinsays Update textdomain name.
devinsays authored
274 /*
e0e38f6 @devinsays Minor code cleanup. Simplify functions.php.
devinsays authored
275 * This is an example of how to add custom scripts to the options panel.
276 * This example shows/hides an option when a checkbox is clicked.
277 */
278
279 add_action('optionsframework_custom_scripts', 'optionsframework_custom_scripts');
280
281 function optionsframework_custom_scripts() { ?>
282
283 <script type="text/javascript">
284 jQuery(document).ready(function($) {
285
286 $('#example_showhidden').click(function() {
287 $('#section-example_text_hidden').fadeToggle(400);
288 });
bea13cc @devinsays Update textdomain name.
devinsays authored
289
e0e38f6 @devinsays Minor code cleanup. Simplify functions.php.
devinsays authored
290 if ($('#example_showhidden:checked').val() !== undefined) {
291 $('#section-example_text_hidden').show();
292 }
bea13cc @devinsays Update textdomain name.
devinsays authored
293
e0e38f6 @devinsays Minor code cleanup. Simplify functions.php.
devinsays authored
294 });
295 </script>
296
297 <?php
6926ce7 @devinsays Complete rewrite using Options Framework Plugin code as a base.
devinsays authored
298 }
Something went wrong with that request. Please try again.