Options Framework - Version 1.1

Version Description

  • Added support for wp_editor
  • Updated textarea settings to allow rows parameter
  • Updated cursor:default for h3 metabox, props @yurifedorov
  • Filtering of typography options (@mattwiebe)
  • Updated methods for typography options
Download this release

Release Info

Developer downstairsdev
Plugin Icon wp plugin Options Framework
Version 1.1
Comparing to
See all releases

Code changes from version 1.0 to 1.1

css/admin-style.css CHANGED
@@ -12,9 +12,13 @@
12
  max-width:780px;
13
  background:#fff;
14
  }
 
 
 
15
  #optionsframework p {
16
  margin-bottom:0;
17
  padding-bottom:10px;
 
18
  }
19
  #optionsframework .section {
20
  padding:10px 10px 0;
@@ -62,6 +66,7 @@
62
  }
63
  #optionsframework input.checkbox, #optionsframework input.of-radio {
64
  width: 30px;
 
65
  float:left;
66
  clear:both;
67
  }
@@ -152,6 +157,15 @@
152
  #optionsframework .mini .explain {
153
  max-width:74%;
154
  }
 
 
 
 
 
 
 
 
 
155
  /* Image Uploader */
156
 
157
  #optionsframework .controls input.upload {
@@ -219,4 +233,14 @@
219
  }
220
  #optionsframework .button-primary {
221
  float:right;
 
 
 
 
 
 
 
 
 
 
222
  }
12
  max-width:780px;
13
  background:#fff;
14
  }
15
+ #optionsframework h3 {
16
+ cursor: default;
17
+ }
18
  #optionsframework p {
19
  margin-bottom:0;
20
  padding-bottom:10px;
21
+ line-height: 1.4em;
22
  }
23
  #optionsframework .section {
24
  padding:10px 10px 0;
66
  }
67
  #optionsframework input.checkbox, #optionsframework input.of-radio {
68
  width: 30px;
69
+ margin-top:2px;
70
  float:left;
71
  clear:both;
72
  }
157
  #optionsframework .mini .explain {
158
  max-width:74%;
159
  }
160
+
161
+ /* Editor */
162
+
163
+ #optionsframework .section-editor .explain {
164
+ max-width: 98%;
165
+ float:none;
166
+ margin-bottom:5px;
167
+ }
168
+
169
  /* Image Uploader */
170
 
171
  #optionsframework .controls input.upload {
233
  }
234
  #optionsframework .button-primary {
235
  float:right;
236
+ }
237
+
238
+ /* Bottom Section */
239
+
240
+ #optionsframework .section:before, #optionsframework .section:after {
241
+ content: "";
242
+ display: table;
243
+ }
244
+ #optionsframework .section:after {
245
+ clear: both;
246
  }
js/options-custom.js CHANGED
@@ -67,6 +67,15 @@ jQuery(document).ready(function($) {
67
  $('.group').hide();
68
  $(clicked_group).fadeIn();
69
  evt.preventDefault();
 
 
 
 
 
 
 
 
 
70
  });
71
 
72
  $('.group .collapsed input:checkbox').click(unhideHidden);
67
  $('.group').hide();
68
  $(clicked_group).fadeIn();
69
  evt.preventDefault();
70
+
71
+ // Editor Height (needs improvement)
72
+ $('.wp-editor-wrap').each(function() {
73
+ var editor_iframe = $(this).find('iframe');
74
+ if ( editor_iframe.height() < 30 ) {
75
+ editor_iframe.css({'height':'auto'});
76
+ }
77
+ });
78
+
79
  });
80
 
81
  $('.group .collapsed input:checkbox').click(unhideHidden);
options-check/functions.php DELETED
@@ -1,101 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * Helper function to return the theme option value. If no value has been saved, it returns $default.
5
- * Needed because options are saved as serialized strings.
6
- *
7
- * This code allows the theme to work without errors if the Options Framework plugin has been disabled.
8
- */
9
-
10
- if ( !function_exists( 'of_get_option' ) ) {
11
- function of_get_option($name, $default = false) {
12
-
13
- $optionsframework_settings = get_option('optionsframework');
14
-
15
- // Gets the unique option id
16
- $option_name = $optionsframework_settings['id'];
17
-
18
- if ( get_option($option_name) ) {
19
- $options = get_option($option_name);
20
- }
21
-
22
- if ( isset($options[$name]) ) {
23
- return $options[$name];
24
- } else {
25
- return $default;
26
- }
27
- }
28
- }
29
-
30
- /*
31
- * This is an example of how to add custom scripts to the options panel.
32
- * This one shows/hides the an option when a checkbox is clicked.
33
- */
34
-
35
- add_action('optionsframework_custom_scripts', 'optionsframework_custom_scripts');
36
-
37
- function optionsframework_custom_scripts() { ?>
38
-
39
- <script type="text/javascript">
40
- jQuery(document).ready(function() {
41
-
42
- jQuery('#example_showhidden').click(function() {
43
- jQuery('#section-example_text_hidden').fadeToggle(400);
44
- });
45
-
46
- if (jQuery('#example_showhidden:checked').val() !== undefined) {
47
- jQuery('#section-example_text_hidden').show();
48
- }
49
-
50
- });
51
- </script>
52
-
53
- <?php
54
- }
55
-
56
- /*
57
- * This is an example of how to override a default filter
58
- * for 'text' sanitization and use a different one.
59
- */
60
-
61
- /*
62
-
63
- add_action('admin_init','optionscheck_change_santiziation', 100);
64
-
65
- function optionscheck_change_santiziation() {
66
- remove_filter( 'of_sanitize_text', 'sanitize_text_field' );
67
- add_filter( 'of_sanitize_text', 'of_sanitize_text_field' );
68
- }
69
-
70
- function of_sanitize_text_field($input) {
71
- global $allowedtags;
72
- $output = wp_kses( $input, $allowedtags);
73
- return $output;
74
- }
75
-
76
- */
77
-
78
- /*
79
- * This is an example of how to override the default location and name of options.php
80
- * In this example it has been renamed options-renamed.php and moved into the folder extensions
81
- */
82
-
83
- /*
84
-
85
- add_filter('options_framework_location','options_framework_location_override');
86
-
87
- function options_framework_location_override() {
88
- return array('/extensions/options-renamed.php');
89
- }
90
-
91
- */
92
-
93
- /*
94
- * Turns off the default options panel from Twenty Eleven
95
- */
96
-
97
- add_action('after_setup_theme','remove_twentyeleven_options', 100);
98
-
99
- function remove_twentyeleven_options() {
100
- remove_action( 'admin_menu', 'twentyeleven_theme_options_add_page' );
101
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
options-check/images/1col.png DELETED
Binary file
options-check/images/2cl.png DELETED
Binary file
options-check/images/2cr.png DELETED
Binary file
options-check/index.php DELETED
@@ -1,194 +0,0 @@
1
- <?php
2
- /**
3
- * The main template file.
4
- *
5
- * This theme is purely for the purpose of testing theme options in Options Framework plugin.
6
- *
7
- * @package WordPress
8
- * @subpackage Options Check
9
- */
10
-
11
- get_header(); ?>
12
-
13
- <div id="primary">
14
- <div id="content" role="main">
15
-
16
- <article id="post-0" class="post no-results not-found">
17
- <header class="entry-header">
18
- <h1 class="entry-title">Options Check</h1>
19
- </header><!-- .entry-header -->
20
-
21
- <div class="entry-content">
22
- <p>Use of_of_get_option($id,$default) to return option values.</p>
23
-
24
- <h2>Basic Options</h2>
25
-
26
- <dl>
27
- <dt>type: text (mini)</dt>
28
- <dd>of_get_option('example_text_mini'): <?php echo of_get_option('example_text_mini', 'no entry'); ?></dd>
29
- </dl>
30
-
31
- <dl>
32
- <dt>type: text</dt>
33
- <dd>of_get_option('example_text'): <?php echo of_get_option('example_text', 'no entry'); ?></dd>
34
- </dl>
35
-
36
- <dl>
37
- <dt>type: textarea</dt>
38
- <dd>of_get_option('example_textarea'): <?php echo of_get_option('example_textarea', 'no entry' ); ?></dd>
39
- </dl>
40
-
41
- <dl>
42
- <dt>type: select (mini)</dt>
43
- <dd>of_get_option('example_select'): <?php echo of_get_option('example_select', 'no entry' ); ?></dd>
44
- </dl>
45
-
46
- <dl>
47
- <dt>type: select2 (wide)</dt>
48
- <dd>of_get_option('example_select_wide'): <?php echo of_get_option('example_select_wide', 'no entry' ); ?></dd>
49
- </dl>
50
-
51
- <dl>
52
- <dt>type: select</dt>
53
- <dd>of_get_option('example_select_categories'): category id = <?php echo of_get_option('example_select_categories', 'no entry' ); ?></dd>
54
- </dl>
55
-
56
- <dl>
57
- <dt>type: select</dt>
58
- <dd>of_get_option('example_select_pages'): page id = <?php echo of_get_option('example_select_pages', 'no entry' ); ?></dd>
59
- </dl>
60
-
61
- <dl>
62
- <dt>type: radio</dt>
63
- <dd>of_get_option('example_radio'): <?php echo of_get_option('example_radio', 'no entry' ); ?></dd>
64
- </dl>
65
-
66
- <dl>
67
- <dt>type: checkbox</dt>
68
- <dd>of_get_option('example_checkbox'): <?php echo of_get_option('example_checkbox', 'no entry' ); ?></dd>
69
- </dl>
70
-
71
- <hr/>
72
-
73
- <h2>Advanced Options</h2>
74
-
75
- <dl>
76
- <dt>type: uploader</dt>
77
- <dd>of_get_option('example_uploader'): <?php echo of_get_option('example_uploader', 'no entry'); ?></dd>
78
- <?php if ( of_get_option('example_uploader') ) { ?>
79
- <img src="<?php echo of_get_option('example_uploader'); ?>" />
80
- <?php } ?>
81
- </dl>
82
-
83
- <dl>
84
- <dt>type: image</dt>
85
- <dd>of_get_option('images'): <?php echo of_get_option('example_images', 'no entry' ); ?></dd>
86
- </dl>
87
-
88
- <dl>
89
- <dt>type: multicheck</dt>
90
- <dd>of_get_option('multicheck'):
91
- <?php $multicheck = of_get_option('example_multicheck', 'none' ); ?>
92
- <?php print_r($multicheck); ?>
93
- </dd>
94
- </dl>
95
-
96
- <p>The array sent in the options panel was defined as:<br>
97
- <?php
98
- $test_array_jr = array("one" => "French Toast","two" => "Pancake","three" => "Omelette","four" => "Crepe","five" => "Waffle");
99
- print_r($test_array_jr);
100
- ?>
101
- </p>
102
-
103
- <p>You can get the value of all items in the checkbox array:</p>
104
- <ul>
105
- <?php
106
- if ( is_array($multicheck) ) {
107
- foreach ($multicheck as $key => $value) {
108
- // If you need the option's name rather than the key you can get that
109
- $name = $test_array_jr[$key];
110
- // Prints out each of the values
111
- echo '<li>' . $key . ' (' . $name . ') = ' . $value . '</li>';
112
- }
113
- }
114
- else {
115
- echo '<li>There are no saved values yet.</li>';
116
- }
117
- ?>
118
- </ul>
119
-
120
- <p>You can also get an individual checkbox value if you know what you are looking for. In this example, I'll check for the key "one", which is an item I sent in the array for checkboxes:</p>
121
-
122
- <p>The value of the multicheck box "one" of example_multicheck is:
123
- <b>
124
- <?php
125
- if (isset($multicheck['one']) ) {
126
- echo $multicheck['one'];
127
- } else {
128
- echo 'no entry';
129
- }
130
- ?>
131
- </b>
132
- </p>
133
-
134
-
135
- <dl>
136
- <dt>type: background</dt>
137
- <dd>of_get_option('background'):
138
- <?php $background = of_get_option('example_background');
139
- if ($background) {
140
- if ($background['image']) {
141
- echo '<span style="display: block; height: 200px; width: 200px; background:url('.$background['image']. ') "></span>';
142
- echo '<ul>';
143
- foreach ($background as $i=>$param){
144
- echo '<li>'.$i . ' = ' . $param.'</li>';
145
- }
146
- echo '</ul>';
147
- } else {
148
- echo '<span style="display: inline-block; height: 20px; width: 20px; background:'.$background['color']. ' "></span>';
149
- echo '<ul>';
150
- echo '<li>'.$background['color'].'</li>';
151
- echo '</ul>';
152
- }
153
- } else {
154
- echo "no entry";
155
- }; ?>
156
- </span>
157
- </dd>
158
- </dl>
159
-
160
- <dl>
161
- <dt>type: colorpicker</dt>
162
- <dd>of_get_option('colorpicker'):
163
- <span style="color:<?php echo of_get_option('example_colorpicker', '#000' ); ?>">
164
- <?php echo of_get_option('example_colorpicker', 'no entry' ); ?>
165
- </span>
166
- </dd>
167
- </dl>
168
-
169
- <dl>
170
- <dt>type: typography</dt>
171
- <dd>of_get_option('typography'):
172
- <?php $typography = of_get_option('example_typography');
173
- if ($typography) {
174
- echo '<span style="font-family: ' . $typography['face']. '; font:'.$typography['size'] . $typography['style'] . '; color:'.$typography['color'].';">Some sample text in your style</span>';
175
-
176
- echo '<ul>';
177
- foreach ($typography as $i=>$param) {
178
- echo '<li>'.$i . ' = ' . $param.'</li>';
179
- }
180
- echo '</ul>';
181
- } else {
182
- echo "no entry";
183
- } ?>
184
- </dd>
185
- </dl>
186
-
187
- </div><!-- .entry-content -->
188
- </article><!-- #post-0 -->
189
-
190
-
191
- </div><!-- #content -->
192
- </div><!-- #primary -->
193
-
194
- <?php get_footer(); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
options-check/options.php DELETED
@@ -1,186 +0,0 @@
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
-
9
- function optionsframework_option_name() {
10
-
11
- // This gets the theme name from the stylesheet (lowercase and without spaces)
12
- $themename = get_option( 'stylesheet' );
13
- $themename = preg_replace("/\W/", "_", strtolower($themename) );
14
-
15
- $optionsframework_settings = get_option('optionsframework');
16
- $optionsframework_settings['id'] = $themename;
17
- update_option('optionsframework', $optionsframework_settings);
18
-
19
- // echo $themename;
20
- }
21
-
22
- /**
23
- * Defines an array of options that will be used to generate the settings page and be saved in the database.
24
- * When creating the "id" fields, make sure to use all lowercase and no spaces.
25
- *
26
- */
27
-
28
- function optionsframework_options() {
29
-
30
- // Test data
31
- $test_array = array("one" => "One","two" => "Two","three" => "Three","four" => "Four","five" => "Five");
32
-
33
- // Multicheck Array
34
- $multicheck_array = array("one" => "French Toast", "two" => "Pancake", "three" => "Omelette", "four" => "Crepe", "five" => "Waffle");
35
-
36
- // Multicheck Defaults
37
- $multicheck_defaults = array("one" => "1","five" => "1");
38
-
39
- // Background Defaults
40
-
41
- $background_defaults = array('color' => '', 'image' => '', 'repeat' => 'repeat','position' => 'top center','attachment'=>'scroll');
42
-
43
-
44
- // Pull all the categories into an array
45
- $options_categories = array();
46
- $options_categories_obj = get_categories();
47
- foreach ($options_categories_obj as $category) {
48
- $options_categories[$category->cat_ID] = $category->cat_name;
49
- }
50
-
51
- // Pull all the pages into an array
52
- $options_pages = array();
53
- $options_pages_obj = get_pages('sort_column=post_parent,menu_order');
54
- $options_pages[''] = 'Select a page:';
55
- foreach ($options_pages_obj as $page) {
56
- $options_pages[$page->ID] = $page->post_title;
57
- }
58
-
59
- // If using image radio buttons, define a directory path
60
- $imagepath = get_bloginfo('stylesheet_directory') . '/images/';
61
-
62
- $options = array();
63
-
64
- $options[] = array( "name" => "Basic Settings",
65
- "type" => "heading");
66
-
67
- $options[] = array( "name" => "Input Text Mini",
68
- "desc" => "A mini text input field.",
69
- "id" => "example_text_mini",
70
- "std" => "Default",
71
- "class" => "mini",
72
- "type" => "text");
73
-
74
- $options[] = array( "name" => "Input Text",
75
- "desc" => "A text input field.",
76
- "id" => "example_text",
77
- "std" => "Default Value",
78
- "type" => "text");
79
-
80
- $options[] = array( "name" => "Textarea",
81
- "desc" => "Textarea description.",
82
- "id" => "example_textarea",
83
- "std" => "Default Text",
84
- "type" => "textarea");
85
-
86
- $options[] = array( "name" => "Input Select Small",
87
- "desc" => "Small Select Box.",
88
- "id" => "example_select",
89
- "std" => "three",
90
- "type" => "select",
91
- "class" => "mini", //mini, tiny, small
92
- "options" => $test_array);
93
-
94
- $options[] = array( "name" => "Input Select Wide",
95
- "desc" => "A wider select box.",
96
- "id" => "example_select_wide",
97
- "std" => "two",
98
- "type" => "select",
99
- "options" => $test_array);
100
-
101
- $options[] = array( "name" => "Select a Category",
102
- "desc" => "Passed an array of categories with cat_ID and cat_name",
103
- "id" => "example_select_categories",
104
- "type" => "select",
105
- "options" => $options_categories);
106
-
107
- $options[] = array( "name" => "Select a Page",
108
- "desc" => "Passed an pages with ID and post_title",
109
- "id" => "example_select_pages",
110
- "type" => "select",
111
- "options" => $options_pages);
112
-
113
- $options[] = array( "name" => "Input Radio (one)",
114
- "desc" => "Radio select with default options 'one'.",
115
- "id" => "example_radio",
116
- "std" => "one",
117
- "type" => "radio",
118
- "options" => $test_array);
119
-
120
- $options[] = array( "name" => "Example Info",
121
- "desc" => "This is just some example information you can put in the panel.",
122
- "type" => "info");
123
-
124
- $options[] = array( "name" => "Input Checkbox",
125
- "desc" => "Example checkbox, defaults to true.",
126
- "id" => "example_checkbox",
127
- "std" => "1",
128
- "type" => "checkbox");
129
-
130
- $options[] = array( "name" => "Advanced Settings",
131
- "type" => "heading");
132
-
133
- $options[] = array( "name" => "Check to Show a Hidden Text Input",
134
- "desc" => "Click here and see what happens.",
135
- "id" => "example_showhidden",
136
- "type" => "checkbox");
137
-
138
- $options[] = array( "name" => "Hidden Text Input",
139
- "desc" => "This option is hidden unless activated by a checkbox click.",
140
- "id" => "example_text_hidden",
141
- "std" => "Hello",
142
- "class" => "hidden",
143
- "type" => "text");
144
-
145
- $options[] = array( "name" => "Uploader Test",
146
- "desc" => "This creates a full size uploader that previews the image.",
147
- "id" => "example_uploader",
148
- "type" => "upload");
149
-
150
- $options[] = array( "name" => "Example Image Selector",
151
- "desc" => "Images for layout.",
152
- "id" => "example_images",
153
- "std" => "2c-l-fixed",
154
- "type" => "images",
155
- "options" => array(
156
- '1col-fixed' => $imagepath . '1col.png',
157
- '2c-l-fixed' => $imagepath . '2cl.png',
158
- '2c-r-fixed' => $imagepath . '2cr.png')
159
- );
160
-
161
- $options[] = array( "name" => "Example Background",
162
- "desc" => "Change the background CSS.",
163
- "id" => "example_background",
164
- "std" => $background_defaults,
165
- "type" => "background");
166
-
167
- $options[] = array( "name" => "Multicheck",
168
- "desc" => "Multicheck description.",
169
- "id" => "example_multicheck",
170
- "std" => $multicheck_defaults, // These items get checked by default
171
- "type" => "multicheck",
172
- "options" => $multicheck_array);
173
-
174
- $options[] = array( "name" => "Colorpicker",
175
- "desc" => "No color selected by default.",
176
- "id" => "example_colorpicker",
177
- "std" => "",
178
- "type" => "color");
179
-
180
- $options[] = array( "name" => "Typography",
181
- "desc" => "Example typography.",
182
- "id" => "example_typography",
183
- "std" => array('size' => '12px','face' => 'verdana','style' => 'bold italic','color' => '#123456'),
184
- "type" => "typography");
185
- return $options;
186
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
options-check/screenshot.png DELETED
Binary file
options-check/style.css DELETED
@@ -1,13 +0,0 @@
1
- /*
2
- Theme Name: Options Check
3
- Theme URI: http://wptheming.com
4
- Description: A example/test theme to make sure all the options work in the Options Framework plugin.
5
- Author: Devin Price
6
- Author URI: http://wptheming.com
7
- Version: 1.0
8
- Template: twentyeleven
9
- */
10
-
11
- @import url('../twentyeleven/style.css');
12
-
13
- #branding hgroup, #searchform, #branding img, #access {display:none;}
 
 
 
 
 
 
 
 
 
 
 
 
 
options-framework.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Options Framework
4
  Plugin URI: http://www.wptheming.com
5
  Description: A framework for building theme options.
6
- Version: 1.0
7
  Author: Devin Price
8
  Author URI: http://www.wptheming.com
9
  License: GPLv2
@@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27
 
28
  /* Basic plugin definitions */
29
 
30
- define('OPTIONS_FRAMEWORK_VERSION', '1.0');
31
  define('OPTIONS_FRAMEWORK_URL', plugin_dir_url( __FILE__ ));
32
 
33
  /* Make sure we don't expose any info if called directly */
@@ -41,7 +41,7 @@ if ( !function_exists( 'add_action' ) ) {
41
 
42
  add_action('init', 'optionsframework_rolescheck' );
43
 
44
- function optionsframework_rolescheck () {
45
  if ( current_user_can( 'edit_theme_options' ) ) {
46
  $options =& _optionsframework_options();
47
  if ( $options ) {
@@ -65,8 +65,8 @@ function optionsframework_admin_notice() {
65
  global $current_user ;
66
  $user_id = $current_user->ID;
67
  if ( ! get_user_meta($user_id, 'optionsframework_ignore_notice') ) {
68
- echo '<div class="updated optionsframework_setup_nag"><p>';
69
- printf(__('Your current theme does not have support for the Options Framework plugin. <a href="%1$s" target="_blank">Learn More</a> | <a href="%2$s">Hide Notice</a>'), 'http://wptheming.com/options-framework-plugin', '?optionsframework_nag_ignore=0');
70
  echo "</p></div>";
71
  }
72
  }
@@ -74,9 +74,9 @@ function optionsframework_admin_notice() {
74
 
75
  function optionsframework_nag_ignore() {
76
  global $current_user;
77
- $user_id = $current_user->ID;
78
- if ( isset($_GET['optionsframework_nag_ignore']) && '0' == $_GET['optionsframework_nag_ignore'] ) {
79
- add_user_meta($user_id, 'optionsframework_ignore_notice', 'true', true);
80
  }
81
  }
82
 
@@ -95,7 +95,7 @@ register_uninstall_hook( __FILE__, 'optionsframework_delete_options' );
95
  function optionsframework_delete_options() {
96
 
97
  $optionsframework_settings = get_option('optionsframework');
98
-
99
  // Each theme saves its data in a seperate option, which all gets deleted
100
  $knownoptions = $optionsframework_settings['knownoptions'];
101
  if ($knownoptions) {
@@ -115,7 +115,7 @@ function optionsframework_load_sanitization() {
115
  require_once dirname( __FILE__ ) . '/options-sanitize.php';
116
  }
117
 
118
- /*
119
  * The optionsframework_init loads all the required files and registers the settings.
120
  *
121
  * Read more about the Settings API in the WordPress codex:
@@ -123,7 +123,7 @@ function optionsframework_load_sanitization() {
123
  *
124
  * The theme options are saved using a unique option id in the database. Developers
125
  * traditionally set the option id via in theme using the function
126
- * optionsframework_option_name, but it can also be set using a hook of the same name.
127
  *
128
  * If a theme developer doesn't explictly set the unique option id using one of those
129
  * functions it will be set by default to: optionsframework_[the theme name]
@@ -135,14 +135,14 @@ function optionsframework_init() {
135
  // Include the required files
136
  require_once dirname( __FILE__ ) . '/options-interface.php';
137
  require_once dirname( __FILE__ ) . '/options-medialibrary-uploader.php';
138
-
139
  // Optionally Loads the options file from the theme
140
  $location = apply_filters( 'options_framework_location', array('options.php') );
141
  $optionsfile = locate_template( $location );
142
-
143
  // Load settings
144
  $optionsframework_settings = get_option( 'optionsframework' );
145
-
146
  // Updates the unique option id in the database if it has changed
147
  if ( function_exists( 'optionsframework_option_name' ) ) {
148
  optionsframework_option_name();
@@ -168,18 +168,18 @@ function optionsframework_init() {
168
  update_option( 'optionsframework', $optionsframework_settings );
169
  }
170
  }
171
-
172
  // If the option has no saved data, load the defaults
173
  if ( ! get_option( $optionsframework_settings['id'] ) ) {
174
  optionsframework_setdefaults();
175
  }
176
-
177
  // Registers the settings fields and callback
178
  register_setting( 'optionsframework', $optionsframework_settings['id'], 'optionsframework_validate' );
179
  // Change the capability required to save the 'optionsframework' options group.
180
  add_filter( 'option_page_capability_optionsframework', 'optionsframework_page_capability' );
181
-
182
-
183
  }
184
 
185
  /**
@@ -189,13 +189,13 @@ function optionsframework_init() {
189
  * @param string $capability The capability used for the page, which is manage_options by default.
190
  * @return string The capability to actually use.
191
  */
192
-
193
  function optionsframework_page_capability( $capability ) {
194
- return 'edit_theme_options';
195
  }
196
 
197
 
198
- /*
199
  * Adds default options to the database if they aren't already present.
200
  * May update this later to load only on plugin activation, or theme
201
  * activation since most people won't be editing the options.php
@@ -206,20 +206,20 @@ function optionsframework_page_capability( $capability ) {
206
  */
207
 
208
  function optionsframework_setdefaults() {
209
-
210
  $optionsframework_settings = get_option('optionsframework');
211
 
212
  // Gets the unique option id
213
  $option_name = $optionsframework_settings['id'];
214
-
215
- /*
216
  * Each theme will hopefully have a unique id, and all of its options saved
217
  * as a separate option set. We need to track all of these option sets so
218
  * it can be easily deleted if someone wishes to remove the plugin and
219
- * its associated data. No need to clutter the database.
220
  *
221
  */
222
-
223
  if ( isset($optionsframework_settings['knownoptions']) ) {
224
  $knownoptions = $optionsframework_settings['knownoptions'];
225
  if ( !in_array($option_name, $knownoptions) ) {
@@ -232,13 +232,13 @@ function optionsframework_setdefaults() {
232
  $optionsframework_settings['knownoptions'] = $newoptionname;
233
  update_option('optionsframework', $optionsframework_settings);
234
  }
235
-
236
  // Gets the default options data from the array in options.php
237
  $options =& _optionsframework_options();
238
-
239
  // If the options haven't been added to the database yet, they are added now
240
  $values = of_get_default_values();
241
-
242
  if ( isset($values) ) {
243
  add_option( $option_name, $values ); // Add option with default settings
244
  }
@@ -247,35 +247,38 @@ function optionsframework_setdefaults() {
247
  /* Add a subpage called "Theme Options" to the appearance menu. */
248
 
249
  if ( !function_exists( 'optionsframework_add_page' ) ) {
250
- function optionsframework_add_page() {
251
 
252
- $of_page = add_theme_page('Theme Options', 'Theme Options', 'edit_theme_options', 'options-framework','optionsframework_page');
253
-
254
- // Adds actions to hook in the required css and javascript
255
- add_action("admin_print_styles-$of_page",'optionsframework_load_styles');
256
- add_action("admin_print_scripts-$of_page", 'optionsframework_load_scripts');
 
 
257
 
258
  }
259
- }
260
 
261
  /* Loads the CSS */
262
 
263
  function optionsframework_load_styles() {
264
  wp_enqueue_style('admin-style', OPTIONS_FRAMEWORK_URL.'css/admin-style.css');
265
  wp_enqueue_style('color-picker', OPTIONS_FRAMEWORK_URL.'css/colorpicker.css');
266
- }
267
 
268
  /* Loads the javascript */
269
 
270
- function optionsframework_load_scripts() {
271
 
272
- // Inline scripts from options-interface.php
273
- add_action('admin_head', 'of_admin_head');
274
 
275
  // Enqueued scripts
276
  wp_enqueue_script('jquery-ui-core');
277
- wp_enqueue_script('color-picker', OPTIONS_FRAMEWORK_URL.'js/colorpicker.js', array('jquery'));
278
- wp_enqueue_script('options-custom', OPTIONS_FRAMEWORK_URL.'js/options-custom.js', array('jquery'));
 
 
 
279
  }
280
 
281
  function of_admin_head() {
@@ -284,7 +287,7 @@ function of_admin_head() {
284
  do_action( 'optionsframework_custom_scripts' );
285
  }
286
 
287
- /*
288
  * Builds out the options panel.
289
  *
290
  * If we were using the Settings API as it was likely intended we would use
@@ -297,24 +300,23 @@ function of_admin_head() {
297
  */
298
 
299
  if ( !function_exists( 'optionsframework_page' ) ) {
300
- function optionsframework_page() {
301
- $return = optionsframework_fields();
302
- settings_errors();
303
- ?>
304
-
305
  <div class="wrap">
306
  <?php screen_icon( 'themes' ); ?>
307
  <h2 class="nav-tab-wrapper">
308
- <?php echo $return[1]; ?>
309
  </h2>
310
-
311
  <div class="metabox-holder">
312
  <div id="optionsframework" class="postbox">
313
  <form action="options.php" method="post">
314
  <?php settings_fields('optionsframework'); ?>
315
 
316
- <?php echo $return[0]; /* Settings */ ?>
317
-
318
  <div id="optionsframework-submit">
319
  <input type="submit" class="button-primary" name="update" value="<?php esc_attr_e( 'Save Options' ); ?>" />
320
  <input type="submit" class="reset-button button-secondary" name="reset" value="<?php esc_attr_e( 'Restore Defaults' ); ?>" onclick="return confirm( '<?php print esc_js( __( 'Click OK to reset. Any theme settings will be lost!' ) ); ?>' );" />
@@ -326,10 +328,10 @@ function optionsframework_page() {
326
  </div> <!-- / .wrap -->
327
 
328
  <?php
329
- }
330
  }
331
 
332
- /**
333
  * Validate Options.
334
  *
335
  * This runs after the submit/reset button has been clicked and
@@ -340,6 +342,8 @@ function optionsframework_page() {
340
  */
341
  function optionsframework_validate( $input ) {
342
 
 
 
343
  /*
344
  * Restore Defaults.
345
  *
@@ -347,7 +351,7 @@ function optionsframework_validate( $input ) {
347
  * button, the options defined in the theme's options.php
348
  * file will be added to the option for the active theme.
349
  */
350
-
351
  if ( isset( $_POST['reset'] ) ) {
352
  add_settings_error( 'options-framework', 'restore_defaults', __( 'Default options restored.', 'optionsframework' ), 'updated fade' );
353
  return of_get_default_values();
@@ -356,8 +360,9 @@ function optionsframework_validate( $input ) {
356
  /*
357
  * Udpdate Settings.
358
  */
359
-
360
  if ( isset( $_POST['update'] ) ) {
 
361
  $clean = array();
362
  $options =& _optionsframework_options();
363
  foreach ( $options as $option ) {
@@ -397,7 +402,7 @@ function optionsframework_validate( $input ) {
397
  /*
398
  * Request Not Recognized.
399
  */
400
-
401
  return of_get_default_values();
402
  }
403
 
@@ -414,7 +419,7 @@ function optionsframework_validate( $input ) {
414
  *
415
  * @access private
416
  */
417
-
418
  function of_get_default_values() {
419
  $output = array();
420
  $config =& _optionsframework_options();
@@ -438,17 +443,17 @@ function of_get_default_values() {
438
  /**
439
  * Add Theme Options menu item to Admin Bar.
440
  */
441
-
442
  function optionsframework_adminbar() {
443
-
444
  global $wp_admin_bar;
445
-
446
  $wp_admin_bar->add_menu( array(
447
- 'parent' => 'appearance',
448
- 'id' => 'of_theme_options',
449
- 'title' => __( 'Theme Options' ),
450
- 'href' => admin_url( 'themes.php?page=options-framework' )
451
- ));
452
  }
453
 
454
  if ( ! function_exists( 'of_get_option' ) ) {
@@ -460,7 +465,7 @@ if ( ! function_exists( 'of_get_option' ) ) {
460
  * If no value has been saved, it returns $default.
461
  * Needed because options are saved as serialized strings.
462
  */
463
-
464
  function of_get_option( $name, $default = false ) {
465
  $config = get_option( 'optionsframework' );
466
 
@@ -480,10 +485,10 @@ if ( ! function_exists( 'of_get_option' ) ) {
480
 
481
  /**
482
  * Wrapper for optionsframework_options()
483
- *
484
  * Allows for manipulating or setting options via 'of_options' filter
485
  * For example:
486
- *
487
  * <code>
488
  * add_filter('of_options', function($options) {
489
  * $options[] = array(
@@ -494,23 +499,23 @@ if ( ! function_exists( 'of_get_option' ) ) {
494
  * 'class' => 'mini',
495
  * 'type' => 'text'
496
  * );
497
- *
498
  * return $options;
499
  * });
500
  * </code>
501
- *
502
- * Also allows for setting options via a return statement in the
503
  * options.php file. For example (in options.php):
504
- *
505
  * <code>
506
  * return array(...);
507
  * </code>
508
- *
509
  * @return array (by reference)
510
  */
511
  function &_optionsframework_options() {
512
  static $options = null;
513
-
514
  if (!$options) {
515
  // Load options from options.php file (if it exists)
516
  $location = apply_filters( 'options_framework_location', array('options.php') );
@@ -519,13 +524,13 @@ function &_optionsframework_options() {
519
  if (is_array($maybe_options)) {
520
  $options = $maybe_options;
521
  } else if (function_exists('optionsframework_options')) {
522
- $options = optionsframework_options();
523
- }
524
  }
525
-
526
  // Allow setting/manipulating options via filters
527
  $options = apply_filters('of_options', $options);
528
  }
529
-
530
  return $options;
531
  }
3
  Plugin Name: Options Framework
4
  Plugin URI: http://www.wptheming.com
5
  Description: A framework for building theme options.
6
+ Version: 1.1
7
  Author: Devin Price
8
  Author URI: http://www.wptheming.com
9
  License: GPLv2
27
 
28
  /* Basic plugin definitions */
29
 
30
+ define('OPTIONS_FRAMEWORK_VERSION', '1.1');
31
  define('OPTIONS_FRAMEWORK_URL', plugin_dir_url( __FILE__ ));
32
 
33
  /* Make sure we don't expose any info if called directly */
41
 
42
  add_action('init', 'optionsframework_rolescheck' );
43
 
44
+ function optionsframework_rolescheck() {
45
  if ( current_user_can( 'edit_theme_options' ) ) {
46
  $options =& _optionsframework_options();
47
  if ( $options ) {
65
  global $current_user ;
66
  $user_id = $current_user->ID;
67
  if ( ! get_user_meta($user_id, 'optionsframework_ignore_notice') ) {
68
+ echo '<div class="updated optionsframework_setup_nag"><p>';
69
+ printf(__('Your current theme does not have support for the Options Framework plugin. <a href="%1$s" target="_blank">Learn More</a> | <a href="%2$s">Hide Notice</a>'), 'http://wptheming.com/options-framework-plugin', '?optionsframework_nag_ignore=0');
70
  echo "</p></div>";
71
  }
72
  }
74
 
75
  function optionsframework_nag_ignore() {
76
  global $current_user;
77
+ $user_id = $current_user->ID;
78
+ if ( isset($_GET['optionsframework_nag_ignore']) && '0' == $_GET['optionsframework_nag_ignore'] ) {
79
+ add_user_meta($user_id, 'optionsframework_ignore_notice', 'true', true);
80
  }
81
  }
82
 
95
  function optionsframework_delete_options() {
96
 
97
  $optionsframework_settings = get_option('optionsframework');
98
+
99
  // Each theme saves its data in a seperate option, which all gets deleted
100
  $knownoptions = $optionsframework_settings['knownoptions'];
101
  if ($knownoptions) {
115
  require_once dirname( __FILE__ ) . '/options-sanitize.php';
116
  }
117
 
118
+ /*
119
  * The optionsframework_init loads all the required files and registers the settings.
120
  *
121
  * Read more about the Settings API in the WordPress codex:
123
  *
124
  * The theme options are saved using a unique option id in the database. Developers
125
  * traditionally set the option id via in theme using the function
126
+ * optionsframework_option_name, but it can also be set using a hook of the same name.
127
  *
128
  * If a theme developer doesn't explictly set the unique option id using one of those
129
  * functions it will be set by default to: optionsframework_[the theme name]
135
  // Include the required files
136
  require_once dirname( __FILE__ ) . '/options-interface.php';
137
  require_once dirname( __FILE__ ) . '/options-medialibrary-uploader.php';
138
+
139
  // Optionally Loads the options file from the theme
140
  $location = apply_filters( 'options_framework_location', array('options.php') );
141
  $optionsfile = locate_template( $location );
142
+
143
  // Load settings
144
  $optionsframework_settings = get_option( 'optionsframework' );
145
+
146
  // Updates the unique option id in the database if it has changed
147
  if ( function_exists( 'optionsframework_option_name' ) ) {
148
  optionsframework_option_name();
168
  update_option( 'optionsframework', $optionsframework_settings );
169
  }
170
  }
171
+
172
  // If the option has no saved data, load the defaults
173
  if ( ! get_option( $optionsframework_settings['id'] ) ) {
174
  optionsframework_setdefaults();
175
  }
176
+
177
  // Registers the settings fields and callback
178
  register_setting( 'optionsframework', $optionsframework_settings['id'], 'optionsframework_validate' );
179
  // Change the capability required to save the 'optionsframework' options group.
180
  add_filter( 'option_page_capability_optionsframework', 'optionsframework_page_capability' );
181
+
182
+
183
  }
184
 
185
  /**
189
  * @param string $capability The capability used for the page, which is manage_options by default.
190
  * @return string The capability to actually use.
191
  */
192
+
193
  function optionsframework_page_capability( $capability ) {
194
+ return 'edit_theme_options';
195
  }
196
 
197
 
198
+ /*
199
  * Adds default options to the database if they aren't already present.
200
  * May update this later to load only on plugin activation, or theme
201
  * activation since most people won't be editing the options.php
206
  */
207
 
208
  function optionsframework_setdefaults() {
209
+
210
  $optionsframework_settings = get_option('optionsframework');
211
 
212
  // Gets the unique option id
213
  $option_name = $optionsframework_settings['id'];
214
+
215
+ /*
216
  * Each theme will hopefully have a unique id, and all of its options saved
217
  * as a separate option set. We need to track all of these option sets so
218
  * it can be easily deleted if someone wishes to remove the plugin and
219
+ * its associated data. No need to clutter the database.
220
  *
221
  */
222
+
223
  if ( isset($optionsframework_settings['knownoptions']) ) {
224
  $knownoptions = $optionsframework_settings['knownoptions'];
225
  if ( !in_array($option_name, $knownoptions) ) {
232
  $optionsframework_settings['knownoptions'] = $newoptionname;
233
  update_option('optionsframework', $optionsframework_settings);
234
  }
235
+
236
  // Gets the default options data from the array in options.php
237
  $options =& _optionsframework_options();
238
+
239
  // If the options haven't been added to the database yet, they are added now
240
  $values = of_get_default_values();
241
+
242
  if ( isset($values) ) {
243
  add_option( $option_name, $values ); // Add option with default settings
244
  }
247
  /* Add a subpage called "Theme Options" to the appearance menu. */
248
 
249
  if ( !function_exists( 'optionsframework_add_page' ) ) {
 
250
 
251
+ function optionsframework_add_page() {
252
+ $of_page = add_theme_page('Theme Options', 'Theme Options', 'edit_theme_options', 'options-framework','optionsframework_page');
253
+
254
+ // Load the required CSS and javscript
255
+ add_action('admin_enqueue_scripts', 'optionsframework_load_scripts');
256
+ add_action( 'admin_print_styles-' . $of_page, 'optionsframework_load_styles' );
257
+ }
258
 
259
  }
 
260
 
261
  /* Loads the CSS */
262
 
263
  function optionsframework_load_styles() {
264
  wp_enqueue_style('admin-style', OPTIONS_FRAMEWORK_URL.'css/admin-style.css');
265
  wp_enqueue_style('color-picker', OPTIONS_FRAMEWORK_URL.'css/colorpicker.css');
266
+ }
267
 
268
  /* Loads the javascript */
269
 
270
+ function optionsframework_load_scripts($hook) {
271
 
272
+ if ( 'appearance_page_options-framework' != $hook )
273
+ return;
274
 
275
  // Enqueued scripts
276
  wp_enqueue_script('jquery-ui-core');
277
+ wp_enqueue_script('color-picker', OPTIONS_FRAMEWORK_URL .'js/colorpicker.js', array('jquery'));
278
+ wp_enqueue_script('options-custom', OPTIONS_FRAMEWORK_URL .'js/options-custom.js', array('jquery'));
279
+
280
+ // Inline scripts from options-interface.php
281
+ add_action('admin_head', 'of_admin_head');
282
  }
283
 
284
  function of_admin_head() {
287
  do_action( 'optionsframework_custom_scripts' );
288
  }
289
 
290
+ /*
291
  * Builds out the options panel.
292
  *
293
  * If we were using the Settings API as it was likely intended we would use
300
  */
301
 
302
  if ( !function_exists( 'optionsframework_page' ) ) {
303
+ function optionsframework_page() {
304
+ settings_errors();
305
+ ?>
306
+
 
307
  <div class="wrap">
308
  <?php screen_icon( 'themes' ); ?>
309
  <h2 class="nav-tab-wrapper">
310
+ <?php echo optionsframework_tabs(); ?>
311
  </h2>
312
+
313
  <div class="metabox-holder">
314
  <div id="optionsframework" class="postbox">
315
  <form action="options.php" method="post">
316
  <?php settings_fields('optionsframework'); ?>
317
 
318
+ <?php optionsframework_fields(); /* Settings */ ?>
319
+
320
  <div id="optionsframework-submit">
321
  <input type="submit" class="button-primary" name="update" value="<?php esc_attr_e( 'Save Options' ); ?>" />
322
  <input type="submit" class="reset-button button-secondary" name="reset" value="<?php esc_attr_e( 'Restore Defaults' ); ?>" onclick="return confirm( '<?php print esc_js( __( 'Click OK to reset. Any theme settings will be lost!' ) ); ?>' );" />
328
  </div> <!-- / .wrap -->
329
 
330
  <?php
331
+ }
332
  }
333
 
334
+ /**
335
  * Validate Options.
336
  *
337
  * This runs after the submit/reset button has been clicked and
342
  */
343
  function optionsframework_validate( $input ) {
344
 
345
+ //var_dump($input);
346
+
347
  /*
348
  * Restore Defaults.
349
  *
351
  * button, the options defined in the theme's options.php
352
  * file will be added to the option for the active theme.
353
  */
354
+
355
  if ( isset( $_POST['reset'] ) ) {
356
  add_settings_error( 'options-framework', 'restore_defaults', __( 'Default options restored.', 'optionsframework' ), 'updated fade' );
357
  return of_get_default_values();
360
  /*
361
  * Udpdate Settings.
362
  */
363
+
364
  if ( isset( $_POST['update'] ) ) {
365
+
366
  $clean = array();
367
  $options =& _optionsframework_options();
368
  foreach ( $options as $option ) {
402
  /*
403
  * Request Not Recognized.
404
  */
405
+
406
  return of_get_default_values();
407
  }
408
 
419
  *
420
  * @access private
421
  */
422
+
423
  function of_get_default_values() {
424
  $output = array();
425
  $config =& _optionsframework_options();
443
  /**
444
  * Add Theme Options menu item to Admin Bar.
445
  */
446
+
447
  function optionsframework_adminbar() {
448
+
449
  global $wp_admin_bar;
450
+
451
  $wp_admin_bar->add_menu( array(
452
+ 'parent' => 'appearance',
453
+ 'id' => 'of_theme_options',
454
+ 'title' => __( 'Theme Options' ),
455
+ 'href' => admin_url( 'themes.php?page=options-framework' )
456
+ ));
457
  }
458
 
459
  if ( ! function_exists( 'of_get_option' ) ) {
465
  * If no value has been saved, it returns $default.
466
  * Needed because options are saved as serialized strings.
467
  */
468
+
469
  function of_get_option( $name, $default = false ) {
470
  $config = get_option( 'optionsframework' );
471
 
485
 
486
  /**
487
  * Wrapper for optionsframework_options()
488
+ *
489
  * Allows for manipulating or setting options via 'of_options' filter
490
  * For example:
491
+ *
492
  * <code>
493
  * add_filter('of_options', function($options) {
494
  * $options[] = array(
499
  * 'class' => 'mini',
500
  * 'type' => 'text'
501
  * );
502
+ *
503
  * return $options;
504
  * });
505
  * </code>
506
+ *
507
+ * Also allows for setting options via a return statement in the
508
  * options.php file. For example (in options.php):
509
+ *
510
  * <code>
511
  * return array(...);
512
  * </code>
513
+ *
514
  * @return array (by reference)
515
  */
516
  function &_optionsframework_options() {
517
  static $options = null;
518
+
519
  if (!$options) {
520
  // Load options from options.php file (if it exists)
521
  $location = apply_filters( 'options_framework_location', array('options.php') );
524
  if (is_array($maybe_options)) {
525
  $options = $maybe_options;
526
  } else if (function_exists('optionsframework_options')) {
527
+ $options = optionsframework_options();
528
+ }
529
  }
530
+
531
  // Allow setting/manipulating options via filters
532
  $options = apply_filters('of_options', $options);
533
  }
534
+
535
  return $options;
536
  }
options-interface.php CHANGED
@@ -1,5 +1,27 @@
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  /**
4
  * Generates the options fields that are used in the form.
5
  */
@@ -8,13 +30,9 @@ function optionsframework_fields() {
8
 
9
  global $allowedtags;
10
  $optionsframework_settings = get_option('optionsframework');
11
-
12
- // Get the theme name so we can display it up top
13
- $themename = get_theme_data(STYLESHEETPATH . '/style.css');
14
- $themename = $themename['Name'];
15
 
16
  // Gets the unique option id
17
- if (isset($optionsframework_settings['id'])) {
18
  $option_name = $optionsframework_settings['id'];
19
  }
20
  else {
@@ -22,21 +40,21 @@ function optionsframework_fields() {
22
  };
23
 
24
  $settings = get_option($option_name);
25
- $options =& _optionsframework_options();
26
-
27
- $counter = 0;
28
  $menu = '';
29
- $output = '';
30
-
31
- foreach ($options as $value) {
32
-
33
  $counter++;
34
  $val = '';
35
  $select_value = '';
36
  $checked = '';
37
-
 
38
  // Wrap all options
39
- if ( ($value['type'] != "heading") && ($value['type'] != "info") ) {
40
 
41
  // Keep all ids lowercase with no spaces
42
  $value['id'] = preg_replace('/[^a-zA-Z0-9._\-]/', '', strtolower($value['id']) );
@@ -55,70 +73,73 @@ function optionsframework_fields() {
55
  if ( isset( $value['name'] ) ) {
56
  $output .= '<h4 class="heading">' . esc_html( $value['name'] ) . '</h4>' . "\n";
57
  }
58
- $output .= '<div class="option">' . "\n" . '<div class="controls">' . "\n";
59
- }
60
-
 
 
 
 
 
61
  // Set default value to $val
62
- if ( isset( $value['std']) ) {
63
  $val = $value['std'];
64
  }
65
-
66
  // If the option is already saved, ovveride $val
67
- if ( ($value['type'] != 'heading') && ($value['type'] != 'info')) {
68
- if ( isset($settings[($value['id'])]) ) {
69
- $val = $settings[($value['id'])];
70
- // Striping slashes of non-array options
71
- if (!is_array($val)) {
72
- $val = stripslashes($val);
73
- }
74
  }
75
  }
76
-
77
  // If there is a description save it for labels
78
  $explain_value = '';
79
  if ( isset( $value['desc'] ) ) {
80
  $explain_value = $value['desc'];
81
  }
82
-
83
  switch ( $value['type'] ) {
84
-
85
  // Basic text input
86
  case 'text':
87
  $output .= '<input id="' . esc_attr( $value['id'] ) . '" class="of-input" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" type="text" value="' . esc_attr( $val ) . '" />';
88
- break;
89
-
90
  // Textarea
91
  case 'textarea':
92
- $cols = '8';
93
- $ta_value = '';
94
-
95
- if(isset($value['options'])){
96
- $ta_options = $value['options'];
97
- if(isset($ta_options['cols'])){
98
- $cols = $ta_options['cols'];
99
- } else { $cols = '8'; }
100
  }
101
-
102
  $val = stripslashes( $val );
103
-
104
- $output .= '<textarea id="' . esc_attr( $value['id'] ) . '" class="of-input" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" cols="'. esc_attr( $cols ) . '" rows="8">' . esc_textarea( $val ) . '</textarea>';
105
- break;
106
-
107
  // Select Box
108
  case ($value['type'] == 'select'):
109
  $output .= '<select class="of-input" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" id="' . esc_attr( $value['id'] ) . '">';
110
-
111
  foreach ($value['options'] as $key => $option ) {
112
  $selected = '';
113
- if( $val != '' ) {
114
- if ( $val == $key) { $selected = ' selected="selected"';}
115
- }
116
- $output .= '<option'. $selected .' value="' . esc_attr( $key ) . '">' . esc_html( $option ) . '</option>';
117
- }
118
- $output .= '</select>';
119
- break;
 
120
 
121
-
122
  // Radio Box
123
  case "radio":
124
  $name = $option_name .'['. $value['id'] .']';
@@ -126,8 +147,8 @@ function optionsframework_fields() {
126
  $id = $option_name . '-' . $value['id'] .'-'. $key;
127
  $output .= '<input class="of-input of-radio" type="radio" name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" value="'. esc_attr( $key ) . '" '. checked( $val, $key, false) .' /><label for="' . esc_attr( $id ) . '">' . esc_html( $option ) . '</label>';
128
  }
129
- break;
130
-
131
  // Image Selectors
132
  case "images":
133
  $name = $option_name .'['. $value['id'] .']';
@@ -144,14 +165,14 @@ function optionsframework_fields() {
144
  $output .= '<div class="of-radio-img-label">' . esc_html( $key ) . '</div>';
145
  $output .= '<img src="' . esc_url( $option ) . '" alt="' . $option .'" class="of-radio-img-img' . $selected .'" onclick="document.getElementById(\''. esc_attr($value['id'] .'_'. $key) .'\').checked=true;" />';
146
  }
147
- break;
148
-
149
  // Checkbox
150
  case "checkbox":
151
  $output .= '<input id="' . esc_attr( $value['id'] ) . '" class="checkbox of-input" type="checkbox" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" '. checked( $val, 1, false) .' />';
152
  $output .= '<label class="explain" for="' . esc_attr( $value['id'] ) . '">' . wp_kses( $explain_value, $allowedtags) . '</label>';
153
- break;
154
-
155
  // Multicheck
156
  case "multicheck":
157
  foreach ($value['options'] as $key => $option) {
@@ -162,115 +183,164 @@ function optionsframework_fields() {
162
  $id = $option_name . '-' . $value['id'] . '-'. $option;
163
  $name = $option_name . '[' . $value['id'] . '][' . $option .']';
164
 
165
- if ( isset($val[$option]) ) {
166
  $checked = checked($val[$option], 1, false);
167
  }
168
 
169
  $output .= '<input id="' . esc_attr( $id ) . '" class="checkbox of-input" type="checkbox" name="' . esc_attr( $name ) . '" ' . $checked . ' /><label for="' . esc_attr( $id ) . '">' . esc_html( $label ) . '</label>';
170
  }
171
- break;
172
-
173
  // Color picker
174
  case "color":
175
  $output .= '<div id="' . esc_attr( $value['id'] . '_picker' ) . '" class="colorSelector"><div style="' . esc_attr( 'background-color:' . $val ) . '"></div></div>';
176
  $output .= '<input class="of-color" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" id="' . esc_attr( $value['id'] ) . '" type="text" value="' . esc_attr( $val ) . '" />';
177
- break;
178
-
179
  // Uploader
180
  case "upload":
181
- $output .= optionsframework_medialibrary_uploader( $value['id'], $val, null ); // New AJAX Uploader using Media Library
182
- break;
183
-
184
  // Typography
185
- case 'typography':
186
 
187
- $typography_stored = $val;
188
-
189
- // Font Size
190
- $output .= '<select class="of-typography of-typography-size" name="' . esc_attr( $option_name . '[' . $value['id'] . '][size]' ) . '" id="' . esc_attr( $value['id'] . '_size' ) . '">';
191
- for ($i = 9; $i < 71; $i++) {
192
- $size = $i . 'px';
193
- $output .= '<option value="' . esc_attr( $size ) . '" ' . selected( $typography_stored['size'], $size, false ) . '>' . esc_html( $size ) . '</option>';
194
- }
195
- $output .= '</select>';
196
 
197
- // Font Face
198
- $output .= '<select class="of-typography of-typography-face" name="' . esc_attr( $option_name . '[' . $value['id'] . '][face]' ) . '" id="' . esc_attr( $value['id'] . '_face' ) . '">';
 
 
 
 
 
 
199
 
200
- $faces = of_recognized_font_faces();
201
- foreach ( $faces as $key => $face ) {
202
- $output .= '<option value="' . esc_attr( $key ) . '" ' . selected( $typography_stored['face'], $key, false ) . '>' . esc_html( $face ) . '</option>';
203
- }
 
 
204
 
205
- $output .= '</select>';
 
 
206
 
207
- // Font Weight
208
- $output .= '<select class="of-typography of-typography-style" name="'.$option_name.'['.$value['id'].'][style]" id="'. $value['id'].'_style">';
 
 
 
 
 
 
 
 
209
 
210
- /* Font Style */
211
- $styles = of_recognized_font_styles();
212
- foreach ( $styles as $key => $style ) {
213
- $output .= '<option value="' . esc_attr( $key ) . '" ' . selected( $typography_stored['style'], $key, false ) . '>'. $style .'</option>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
  }
215
- $output .= '</select>';
216
 
217
- // Font Color
218
- $output .= '<div id="' . esc_attr( $value['id'] ) . '_color_picker" class="colorSelector"><div style="' . esc_attr( 'background-color:' . $typography_stored['color'] ) . '"></div></div>';
219
- $output .= '<input class="of-color of-typography of-typography-color" name="' . esc_attr( $option_name . '[' . $value['id'] . '][color]' ) . '" id="' . esc_attr( $value['id'] . '_color' ) . '" type="text" value="' . esc_attr( $typography_stored['color'] ) . '" />';
 
 
 
 
 
 
 
 
 
220
 
221
- break;
222
-
223
  // Background
224
  case 'background':
225
-
226
  $background = $val;
227
-
228
- // Background Color
229
  $output .= '<div id="' . esc_attr( $value['id'] ) . '_color_picker" class="colorSelector"><div style="' . esc_attr( 'background-color:' . $background['color'] ) . '"></div></div>';
230
  $output .= '<input class="of-color of-background of-background-color" name="' . esc_attr( $option_name . '[' . $value['id'] . '][color]' ) . '" id="' . esc_attr( $value['id'] . '_color' ) . '" type="text" value="' . esc_attr( $background['color'] ) . '" />';
231
-
232
  // Background Image - New AJAX Uploader using Media Library
233
  if (!isset($background['image'])) {
234
  $background['image'] = '';
235
  }
236
-
237
  $output .= optionsframework_medialibrary_uploader( $value['id'], $background['image'], null, '',0,'image');
238
  $class = 'of-background-properties';
239
  if ( '' == $background['image'] ) {
240
  $class .= ' hide';
241
  }
242
  $output .= '<div class="' . esc_attr( $class ) . '">';
243
-
244
  // Background Repeat
245
  $output .= '<select class="of-background of-background-repeat" name="' . esc_attr( $option_name . '[' . $value['id'] . '][repeat]' ) . '" id="' . esc_attr( $value['id'] . '_repeat' ) . '">';
246
  $repeats = of_recognized_background_repeat();
247
-
248
  foreach ($repeats as $key => $repeat) {
249
  $output .= '<option value="' . esc_attr( $key ) . '" ' . selected( $background['repeat'], $key, false ) . '>'. esc_html( $repeat ) . '</option>';
250
  }
251
  $output .= '</select>';
252
-
253
  // Background Position
254
  $output .= '<select class="of-background of-background-position" name="' . esc_attr( $option_name . '[' . $value['id'] . '][position]' ) . '" id="' . esc_attr( $value['id'] . '_position' ) . '">';
255
  $positions = of_recognized_background_position();
256
-
257
  foreach ($positions as $key=>$position) {
258
  $output .= '<option value="' . esc_attr( $key ) . '" ' . selected( $background['position'], $key, false ) . '>'. esc_html( $position ) . '</option>';
259
  }
260
  $output .= '</select>';
261
-
262
  // Background Attachment
263
  $output .= '<select class="of-background of-background-attachment" name="' . esc_attr( $option_name . '[' . $value['id'] . '][attachment]' ) . '" id="' . esc_attr( $value['id'] . '_attachment' ) . '">';
264
  $attachments = of_recognized_background_attachment();
265
-
266
  foreach ($attachments as $key => $attachment) {
267
  $output .= '<option value="' . esc_attr( $key ) . '" ' . selected( $background['attachment'], $key, false ) . '>' . esc_html( $attachment ) . '</option>';
268
  }
269
  $output .= '</select>';
270
  $output .= '</div>';
271
-
272
- break;
273
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
274
  // Info
275
  case "info":
276
  $class = 'section';
@@ -288,13 +358,13 @@ function optionsframework_fields() {
288
  if ( $value['desc'] ) {
289
  $output .= apply_filters('of_sanitize_info', $value['desc'] ) . "\n";
290
  }
291
- $output .= '<div class="clear"></div></div>' . "\n";
292
- break;
293
-
294
  // Heading for Navigation
295
  case "heading":
296
  if ($counter >= 2) {
297
- $output .= '</div>'."\n";
298
  }
299
  $jquery_click_hook = preg_replace('/[^a-zA-Z0-9._\-]/', '', strtolower($value['name']) );
300
  $jquery_click_hook = "of-option-" . $jquery_click_hook;
@@ -302,19 +372,18 @@ function optionsframework_fields() {
302
  $output .= '<div class="group" id="' . esc_attr( $jquery_click_hook ) . '">';
303
  $output .= '<h3>' . esc_html( $value['name'] ) . '</h3>' . "\n";
304
  break;
 
305
  }
306
 
307
  if ( ( $value['type'] != "heading" ) && ( $value['type'] != "info" ) ) {
308
- if ( $value['type'] != "checkbox" ) {
309
- $output .= '<br/>';
310
- }
311
  $output .= '</div>';
312
- if ( $value['type'] != "checkbox" ) {
313
  $output .= '<div class="explain">' . wp_kses( $explain_value, $allowedtags) . '</div>'."\n";
314
  }
315
- $output .= '<div class="clear"></div></div></div>'."\n";
316
  }
 
 
317
  }
318
- $output .= '</div>';
319
- return array($output,$menu);
320
  }
1
  <?php
2
 
3
+ /**
4
+ * Generates the tabs that are used in the options menu
5
+ */
6
+
7
+ function optionsframework_tabs() {
8
+
9
+ $optionsframework_settings = get_option('optionsframework');
10
+ $options =& _optionsframework_options();
11
+ $menu = '';
12
+
13
+ foreach ($options as $value) {
14
+ // Heading for Navigation
15
+ if ($value['type'] == "heading") {
16
+ $jquery_click_hook = preg_replace('/[^a-zA-Z0-9._\-]/', '', strtolower($value['name']) );
17
+ $jquery_click_hook = "of-option-" . $jquery_click_hook;
18
+ $menu .= '<a id="'. esc_attr( $jquery_click_hook ) . '-tab" class="nav-tab" title="' . esc_attr( $value['name'] ) . '" href="' . esc_attr( '#'. $jquery_click_hook ) . '">' . esc_html( $value['name'] ) . '</a>';
19
+ }
20
+ }
21
+
22
+ return $menu;
23
+ }
24
+
25
  /**
26
  * Generates the options fields that are used in the form.
27
  */
30
 
31
  global $allowedtags;
32
  $optionsframework_settings = get_option('optionsframework');
 
 
 
 
33
 
34
  // Gets the unique option id
35
+ if ( isset( $optionsframework_settings['id'] ) ) {
36
  $option_name = $optionsframework_settings['id'];
37
  }
38
  else {
40
  };
41
 
42
  $settings = get_option($option_name);
43
+ $options =& _optionsframework_options();
44
+
45
+ $counter = 0;
46
  $menu = '';
47
+
48
+ foreach ( $options as $value ) {
49
+
 
50
  $counter++;
51
  $val = '';
52
  $select_value = '';
53
  $checked = '';
54
+ $output = '';
55
+
56
  // Wrap all options
57
+ if ( ( $value['type'] != "heading" ) && ( $value['type'] != "info" ) ) {
58
 
59
  // Keep all ids lowercase with no spaces
60
  $value['id'] = preg_replace('/[^a-zA-Z0-9._\-]/', '', strtolower($value['id']) );
73
  if ( isset( $value['name'] ) ) {
74
  $output .= '<h4 class="heading">' . esc_html( $value['name'] ) . '</h4>' . "\n";
75
  }
76
+ if ( $value['type'] != 'editor' ) {
77
+ $output .= '<div class="option">' . "\n" . '<div class="controls">' . "\n";
78
+ }
79
+ else {
80
+ $output .= '<div class="option">' . "\n" . '<div>' . "\n";
81
+ }
82
+ }
83
+
84
  // Set default value to $val
85
+ if ( isset( $value['std'] ) ) {
86
  $val = $value['std'];
87
  }
88
+
89
  // If the option is already saved, ovveride $val
90
+ if ( ( $value['type'] != 'heading' ) && ( $value['type'] != 'info') ) {
91
+ if ( isset( $settings[($value['id'])]) ) {
92
+ $val = $settings[($value['id'])];
93
+ // Striping slashes of non-array options
94
+ if ( !is_array($val) ) {
95
+ $val = stripslashes( $val );
96
+ }
97
  }
98
  }
99
+
100
  // If there is a description save it for labels
101
  $explain_value = '';
102
  if ( isset( $value['desc'] ) ) {
103
  $explain_value = $value['desc'];
104
  }
105
+
106
  switch ( $value['type'] ) {
107
+
108
  // Basic text input
109
  case 'text':
110
  $output .= '<input id="' . esc_attr( $value['id'] ) . '" class="of-input" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" type="text" value="' . esc_attr( $val ) . '" />';
111
+ break;
112
+
113
  // Textarea
114
  case 'textarea':
115
+ $rows = '8';
116
+
117
+ if ( isset( $value['settings']['rows'] ) ) {
118
+ $custom_rows = $value['settings']['rows'];
119
+ if ( is_numeric( $custom_rows ) ) {
120
+ $rows = $custom_rows;
121
+ }
 
122
  }
123
+
124
  $val = stripslashes( $val );
125
+ $output .= '<textarea id="' . esc_attr( $value['id'] ) . '" class="of-input" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" rows="' . $rows . '">' . esc_textarea( $val ) . '</textarea>';
126
+ break;
127
+
 
128
  // Select Box
129
  case ($value['type'] == 'select'):
130
  $output .= '<select class="of-input" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" id="' . esc_attr( $value['id'] ) . '">';
131
+
132
  foreach ($value['options'] as $key => $option ) {
133
  $selected = '';
134
+ if ( $val != '' ) {
135
+ if ( $val == $key) { $selected = ' selected="selected"';}
136
+ }
137
+ $output .= '<option'. $selected .' value="' . esc_attr( $key ) . '">' . esc_html( $option ) . '</option>';
138
+ }
139
+ $output .= '</select>';
140
+ break;
141
+
142
 
 
143
  // Radio Box
144
  case "radio":
145
  $name = $option_name .'['. $value['id'] .']';
147
  $id = $option_name . '-' . $value['id'] .'-'. $key;
148
  $output .= '<input class="of-input of-radio" type="radio" name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" value="'. esc_attr( $key ) . '" '. checked( $val, $key, false) .' /><label for="' . esc_attr( $id ) . '">' . esc_html( $option ) . '</label>';
149
  }
150
+ break;
151
+
152
  // Image Selectors
153
  case "images":
154
  $name = $option_name .'['. $value['id'] .']';
165
  $output .= '<div class="of-radio-img-label">' . esc_html( $key ) . '</div>';
166
  $output .= '<img src="' . esc_url( $option ) . '" alt="' . $option .'" class="of-radio-img-img' . $selected .'" onclick="document.getElementById(\''. esc_attr($value['id'] .'_'. $key) .'\').checked=true;" />';
167
  }
168
+ break;
169
+
170
  // Checkbox
171
  case "checkbox":
172
  $output .= '<input id="' . esc_attr( $value['id'] ) . '" class="checkbox of-input" type="checkbox" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" '. checked( $val, 1, false) .' />';
173
  $output .= '<label class="explain" for="' . esc_attr( $value['id'] ) . '">' . wp_kses( $explain_value, $allowedtags) . '</label>';
174
+ break;
175
+
176
  // Multicheck
177
  case "multicheck":
178
  foreach ($value['options'] as $key => $option) {
183
  $id = $option_name . '-' . $value['id'] . '-'. $option;
184
  $name = $option_name . '[' . $value['id'] . '][' . $option .']';
185
 
186
+ if ( isset($val[$option]) ) {
187
  $checked = checked($val[$option], 1, false);
188
  }
189
 
190
  $output .= '<input id="' . esc_attr( $id ) . '" class="checkbox of-input" type="checkbox" name="' . esc_attr( $name ) . '" ' . $checked . ' /><label for="' . esc_attr( $id ) . '">' . esc_html( $label ) . '</label>';
191
  }
192
+ break;
193
+
194
  // Color picker
195
  case "color":
196
  $output .= '<div id="' . esc_attr( $value['id'] . '_picker' ) . '" class="colorSelector"><div style="' . esc_attr( 'background-color:' . $val ) . '"></div></div>';
197
  $output .= '<input class="of-color" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" id="' . esc_attr( $value['id'] ) . '" type="text" value="' . esc_attr( $val ) . '" />';
198
+ break;
199
+
200
  // Uploader
201
  case "upload":
202
+ $output .= optionsframework_medialibrary_uploader( $value['id'], $val, null );
203
+ break;
204
+
205
  // Typography
206
+ case 'typography':
207
 
208
+ unset( $font_size, $font_style, $font_face, $font_color );
 
 
 
 
 
 
 
 
209
 
210
+ $typography_defaults = array(
211
+ 'size' => '',
212
+ 'face' => '',
213
+ 'style' => '',
214
+ 'color' => ''
215
+ );
216
+
217
+ $typography_stored = wp_parse_args( $val, $typography_defaults );
218
 
219
+ $typography_options = array(
220
+ 'sizes' => of_recognized_font_sizes(),
221
+ 'faces' => of_recognized_font_faces(),
222
+ 'styles' => of_recognized_font_styles(),
223
+ 'color' => true
224
+ );
225
 
226
+ if ( isset( $value['options'] ) ) {
227
+ $typography_options = wp_parse_args( $value['options'], $typography_options );
228
+ }
229
 
230
+ // Font Size
231
+ if ( $typography_options['sizes'] ) {
232
+ $font_size = '<select class="of-typography of-typography-size" name="' . esc_attr( $option_name . '[' . $value['id'] . '][size]' ) . '" id="' . esc_attr( $value['id'] . '_size' ) . '">';
233
+ $sizes = $typography_options['sizes'];
234
+ foreach ( $sizes as $i ) {
235
+ $size = $i . 'px';
236
+ $font_size .= '<option value="' . esc_attr( $size ) . '" ' . selected( $typography_stored['size'], $size, false ) . '>' . esc_html( $size ) . '</option>';
237
+ }
238
+ $font_size .= '</select>';
239
+ }
240
 
241
+ // Font Face
242
+ if ( $typography_options['faces'] ) {
243
+ $font_face = '<select class="of-typography of-typography-face" name="' . esc_attr( $option_name . '[' . $value['id'] . '][face]' ) . '" id="' . esc_attr( $value['id'] . '_face' ) . '">';
244
+ $faces = $typography_options['faces'];
245
+ foreach ( $faces as $key => $face ) {
246
+ $font_face .= '<option value="' . esc_attr( $key ) . '" ' . selected( $typography_stored['face'], $key, false ) . '>' . esc_html( $face ) . '</option>';
247
+ }
248
+ $font_face .= '</select>';
249
+ }
250
+
251
+ // Font Styles
252
+ if ( $typography_options['styles'] ) {
253
+ $font_style = '<select class="of-typography of-typography-style" name="'.$option_name.'['.$value['id'].'][style]" id="'. $value['id'].'_style">';
254
+ $styles = $typography_options['styles'];
255
+ foreach ( $styles as $key => $style ) {
256
+ $font_style .= '<option value="' . esc_attr( $key ) . '" ' . selected( $typography_stored['style'], $key, false ) . '>'. $style .'</option>';
257
+ }
258
+ $font_style .= '</select>';
259
  }
 
260
 
261
+ // Font Color
262
+ if ( $typography_options['color'] ) {
263
+ $font_color = '<div id="' . esc_attr( $value['id'] ) . '_color_picker" class="colorSelector"><div style="' . esc_attr( 'background-color:' . $typography_stored['color'] ) . '"></div></div>';
264
+ $font_color .= '<input class="of-color of-typography of-typography-color" name="' . esc_attr( $option_name . '[' . $value['id'] . '][color]' ) . '" id="' . esc_attr( $value['id'] . '_color' ) . '" type="text" value="' . esc_attr( $typography_stored['color'] ) . '" />';
265
+ }
266
+
267
+ // Allow modification/injection of typography fields
268
+ $typography_fields = compact( 'font_size', 'font_face', 'font_style', 'font_color' );
269
+ $typography_fields = apply_filters( 'of_typography_fields', $typography_fields, $typography_stored, $option_name, $value );
270
+ $output .= implode( '', $typography_fields );
271
+
272
+ break;
273
 
 
 
274
  // Background
275
  case 'background':
276
+
277
  $background = $val;
278
+
279
+ // Background Color
280
  $output .= '<div id="' . esc_attr( $value['id'] ) . '_color_picker" class="colorSelector"><div style="' . esc_attr( 'background-color:' . $background['color'] ) . '"></div></div>';
281
  $output .= '<input class="of-color of-background of-background-color" name="' . esc_attr( $option_name . '[' . $value['id'] . '][color]' ) . '" id="' . esc_attr( $value['id'] . '_color' ) . '" type="text" value="' . esc_attr( $background['color'] ) . '" />';
282
+
283
  // Background Image - New AJAX Uploader using Media Library
284
  if (!isset($background['image'])) {
285
  $background['image'] = '';
286
  }
287
+
288
  $output .= optionsframework_medialibrary_uploader( $value['id'], $background['image'], null, '',0,'image');
289
  $class = 'of-background-properties';
290
  if ( '' == $background['image'] ) {
291
  $class .= ' hide';
292
  }
293
  $output .= '<div class="' . esc_attr( $class ) . '">';
294
+
295
  // Background Repeat
296
  $output .= '<select class="of-background of-background-repeat" name="' . esc_attr( $option_name . '[' . $value['id'] . '][repeat]' ) . '" id="' . esc_attr( $value['id'] . '_repeat' ) . '">';
297
  $repeats = of_recognized_background_repeat();
298
+
299
  foreach ($repeats as $key => $repeat) {
300
  $output .= '<option value="' . esc_attr( $key ) . '" ' . selected( $background['repeat'], $key, false ) . '>'. esc_html( $repeat ) . '</option>';
301
  }
302
  $output .= '</select>';
303
+
304
  // Background Position
305
  $output .= '<select class="of-background of-background-position" name="' . esc_attr( $option_name . '[' . $value['id'] . '][position]' ) . '" id="' . esc_attr( $value['id'] . '_position' ) . '">';
306
  $positions = of_recognized_background_position();
307
+
308
  foreach ($positions as $key=>$position) {
309
  $output .= '<option value="' . esc_attr( $key ) . '" ' . selected( $background['position'], $key, false ) . '>'. esc_html( $position ) . '</option>';
310
  }
311
  $output .= '</select>';
312
+
313
  // Background Attachment
314
  $output .= '<select class="of-background of-background-attachment" name="' . esc_attr( $option_name . '[' . $value['id'] . '][attachment]' ) . '" id="' . esc_attr( $value['id'] . '_attachment' ) . '">';
315
  $attachments = of_recognized_background_attachment();
316
+
317
  foreach ($attachments as $key => $attachment) {
318
  $output .= '<option value="' . esc_attr( $key ) . '" ' . selected( $background['attachment'], $key, false ) . '>' . esc_html( $attachment ) . '</option>';
319
  }
320
  $output .= '</select>';
321
  $output .= '</div>';
322
+
323
+ break;
324
+
325
+ // Editor
326
+ case 'editor':
327
+ $output .= '<div class="explain">' . wp_kses( $explain_value, $allowedtags) . '</div>'."\n";
328
+ echo $output;
329
+ $textarea_name = esc_attr( $option_name . '[' . $value['id'] . ']' );
330
+ $default_editor_settings = array(
331
+ 'textarea_name' => $textarea_name,
332
+ 'media_buttons' => false,
333
+ 'tinymce' => array( 'plugins' => 'wordpress' )
334
+ );
335
+ $editor_settings = array();
336
+ if ( isset( $value['settings'] ) ) {
337
+ $editor_settings = $value['settings'];
338
+ }
339
+ $editor_settings = array_merge($editor_settings, $default_editor_settings);
340
+ wp_editor( $val, $value['id'], $editor_settings );
341
+ $output = '';
342
+ break;
343
+
344
  // Info
345
  case "info":
346
  $class = 'section';
358
  if ( $value['desc'] ) {
359
  $output .= apply_filters('of_sanitize_info', $value['desc'] ) . "\n";
360
  }
361
+ $output .= '</div>' . "\n";
362
+ break;
363
+
364
  // Heading for Navigation
365
  case "heading":
366
  if ($counter >= 2) {
367
+ $output .= '</div>'."\n";
368
  }
369
  $jquery_click_hook = preg_replace('/[^a-zA-Z0-9._\-]/', '', strtolower($value['name']) );
370
  $jquery_click_hook = "of-option-" . $jquery_click_hook;
372
  $output .= '<div class="group" id="' . esc_attr( $jquery_click_hook ) . '">';
373
  $output .= '<h3>' . esc_html( $value['name'] ) . '</h3>' . "\n";
374
  break;
375
+
376
  }
377
 
378
  if ( ( $value['type'] != "heading" ) && ( $value['type'] != "info" ) ) {
 
 
 
379
  $output .= '</div>';
380
+ if ( ( $value['type'] != "checkbox" ) && ( $value['type'] != "editor" ) ) {
381
  $output .= '<div class="explain">' . wp_kses( $explain_value, $allowedtags) . '</div>'."\n";
382
  }
383
+ $output .= '</div></div>'."\n";
384
  }
385
+
386
+ echo $output;
387
  }
388
+ echo '</div>';
 
389
  }
options-sanitize.php CHANGED
@@ -14,10 +14,6 @@ function of_sanitize_textarea($input) {
14
 
15
  add_filter( 'of_sanitize_textarea', 'of_sanitize_textarea' );
16
 
17
- /* Info */
18
-
19
-
20
-
21
  /* Select */
22
 
23
  add_filter( 'of_sanitize_select', 'of_sanitize_enum', 10, 2);
@@ -76,6 +72,20 @@ function of_sanitize_upload( $input ) {
76
  }
77
  add_filter( 'of_sanitize_upload', 'of_sanitize_upload' );
78
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  /* Allowed Tags */
80
 
81
  function of_sanitize_allowedtags($input) {
@@ -156,23 +166,30 @@ add_filter( 'of_background_attachment', 'of_sanitize_background_attachment' );
156
 
157
  /* Typography */
158
 
159
- function of_sanitize_typography( $input ) {
 
160
  $output = wp_parse_args( $input, array(
161
  'size' => '',
162
  'face' => '',
163
  'style' => '',
164
  'color' => ''
165
  ) );
 
 
 
 
 
 
 
 
 
166
 
167
  $output['size'] = apply_filters( 'of_font_size', $output['size'] );
168
- $output['face'] = apply_filters( 'of_font_face', $output['face'] );
169
  $output['style'] = apply_filters( 'of_font_style', $output['style'] );
170
  $output['color'] = apply_filters( 'of_color', $output['color'] );
171
-
172
  return $output;
173
  }
174
- add_filter( 'of_sanitize_typography', 'of_sanitize_typography' );
175
-
176
 
177
  function of_sanitize_font_size( $value ) {
178
  $recognized = of_recognized_font_sizes();
@@ -182,7 +199,7 @@ function of_sanitize_font_size( $value ) {
182
  }
183
  return (int) apply_filters( 'of_default_font_size', $recognized );
184
  }
185
- add_filter( 'of_font_face', 'of_sanitize_font_face' );
186
 
187
 
188
  function of_sanitize_font_style( $value ) {
14
 
15
  add_filter( 'of_sanitize_textarea', 'of_sanitize_textarea' );
16
 
 
 
 
 
17
  /* Select */
18
 
19
  add_filter( 'of_sanitize_select', 'of_sanitize_enum', 10, 2);
72
  }
73
  add_filter( 'of_sanitize_upload', 'of_sanitize_upload' );
74
 
75
+ /* Editor */
76
+
77
+ function of_sanitize_editor($input) {
78
+ if ( current_user_can( 'unfiltered_html' ) ) {
79
+ $output = $input;
80
+ }
81
+ else {
82
+ global $allowedtags;
83
+ $output = wpautop(wp_kses( $input, $allowedtags));
84
+ }
85
+ return $output;
86
+ }
87
+ add_filter( 'of_sanitize_editor', 'of_sanitize_editor' );
88
+
89
  /* Allowed Tags */
90
 
91
  function of_sanitize_allowedtags($input) {
166
 
167
  /* Typography */
168
 
169
+ function of_sanitize_typography( $input, $option ) {
170
+
171
  $output = wp_parse_args( $input, array(
172
  'size' => '',
173
  'face' => '',
174
  'style' => '',
175
  'color' => ''
176
  ) );
177
+
178
+ if ( isset( $option['options']['faces'] ) && isset( $input['face'] ) ) {
179
+ if ( !( array_key_exists( $input['face'], $option['options']['faces'] ) ) ) {
180
+ $output['face'] = '';
181
+ }
182
+ }
183
+ else {
184
+ $output['face'] = apply_filters( 'of_font_face', $output['face'] );
185
+ }
186
 
187
  $output['size'] = apply_filters( 'of_font_size', $output['size'] );
 
188
  $output['style'] = apply_filters( 'of_font_style', $output['style'] );
189
  $output['color'] = apply_filters( 'of_color', $output['color'] );
 
190
  return $output;
191
  }
192
+ add_filter( 'of_sanitize_typography', 'of_sanitize_typography', 10, 2 );
 
193
 
194
  function of_sanitize_font_size( $value ) {
195
  $recognized = of_recognized_font_sizes();
199
  }
200
  return (int) apply_filters( 'of_default_font_size', $recognized );
201
  }
202
+ add_filter( 'of_font_face', 'of_sanitize_font_size' );
203
 
204
 
205
  function of_sanitize_font_style( $value ) {
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Options Framework ===
2
  Contributors: Devin Price
3
  Tags: options, theme options
4
- Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=X238BDP4QGTV2
5
- Requires at least: 3.0
6
  Tested up to: 3.3
7
- Stable tag: 1.0
8
  License: GPLv2
9
 
10
  == Description ==
@@ -31,7 +31,7 @@ Please visit [http://wptheming.com/options-framework-plugin](http://wptheming.co
31
 
32
  == Installation ==
33
 
34
- If your theme already has options enabled, they will show up under the apperance menu.
35
 
36
  If your theme doesn't have options, you can define them to options.php of your theme and they will instantly show up. For more on how to do this, visit [http://wptheming.com/options-framework-plugin](http://wptheming.com/options-framework-plugin).
37
 
@@ -65,6 +65,14 @@ You can also watch the video screencast I have at [http://wptheming.com/options-
65
 
66
  == Changelog ==
67
 
 
 
 
 
 
 
 
 
68
  = 1.0 =
69
 
70
  * Added filters for entire options array (props @inxilpro)
1
  === Options Framework ===
2
  Contributors: Devin Price
3
  Tags: options, theme options
4
+ Donate link: http://bit.ly/options-donate
5
+ Requires at least: 3.3
6
  Tested up to: 3.3
7
+ Stable tag: 1.1
8
  License: GPLv2
9
 
10
  == Description ==
31
 
32
  == Installation ==
33
 
34
+ If your theme already has options enabled, they will show up under the appearance menu.
35
 
36
  If your theme doesn't have options, you can define them to options.php of your theme and they will instantly show up. For more on how to do this, visit [http://wptheming.com/options-framework-plugin](http://wptheming.com/options-framework-plugin).
37
 
65
 
66
  == Changelog ==
67
 
68
+ = 1.1 =
69
+
70
+ * Added support for wp_editor
71
+ * Updated textarea settings to allow rows parameter
72
+ * Updated cursor:default for h3 metabox, props @yurifedorov
73
+ * Filtering of typography options (@mattwiebe)
74
+ * Updated methods for typography options
75
+
76
  = 1.0 =
77
 
78
  * Added filters for entire options array (props @inxilpro)