Version Description
- Fixed errors when more than one multicheck options is used
- Updated optionsframework_setdefaults so defaults actually save on first run
- Require that all options have lowercase alphanumeric ids
- Added link to options from the WordPress admin bar
Download this release
Release Info
Developer | downstairsdev |
Plugin | Options Framework |
Version | 0.5 |
Comparing to | |
See all releases |
Code changes from version 0.4 to 0.5
- options-framework.php +26 -5
- options-interface.php +7 -4
- readme.txt +8 -1
- screenshot-1.png +0 -0
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: 0.
|
7 |
Author: Devin Price
|
8 |
Author URI: http://www.wptheming.com
|
9 |
License: GPLv2
|
@@ -161,15 +161,14 @@ function optionsframework_setdefaults() {
|
|
161 |
foreach ($options as $option) {
|
162 |
|
163 |
if ( ($option['type'] != 'heading') && ($option['type'] != 'info') ) {
|
164 |
-
$option_id = preg_replace(
|
165 |
|
166 |
// wp_filter_post_kses for strings
|
167 |
if (isset($option['std' ]) ) {
|
168 |
if ( !is_array($option['std' ]) ) {
|
169 |
-
$
|
170 |
} else {
|
171 |
foreach ($option['std' ] as $key => $value) {
|
172 |
-
$values[$option_id . '_' . $key] = wp_filter_post_kses($value);
|
173 |
$optionarray[$key] = wp_filter_post_kses($value);
|
174 |
}
|
175 |
$values[$option_id] = $optionarray;
|
@@ -355,6 +354,9 @@ function optionsframework_validate($input) {
|
|
355 |
// Verify that the option has an id
|
356 |
if ( isset ($option['id']) ) {
|
357 |
|
|
|
|
|
|
|
358 |
// Checkbox data isn't sent if it's unchecked, so we'll default it to false
|
359 |
if ( ($option['type'] == 'checkbox') && !isset($input[($option['id'])]) ) {
|
360 |
$input[($option['id'])] = 'false';
|
@@ -376,9 +378,10 @@ function optionsframework_validate($input) {
|
|
376 |
|
377 |
// If it's a multicheck
|
378 |
case ($option['type'] == 'multicheck'):
|
|
|
379 |
foreach ($option['options'] as $key => $option_name ) {
|
380 |
// Make sure the key is lowercase and without spaces
|
381 |
-
$key = preg_replace(
|
382 |
// Check that the option isn't null
|
383 |
if (!empty($input[($option['id']. '_' . $key)])) {
|
384 |
// If it's not null, make sure it's true, add it to an array
|
@@ -478,4 +481,22 @@ function of_get_option($name, $default = 'false') {
|
|
478 |
return $default;
|
479 |
}
|
480 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
481 |
}
|
3 |
Plugin Name: Options Framework
|
4 |
Plugin URI: http://www.wptheming.com
|
5 |
Description: A framework for building theme options.
|
6 |
+
Version: 0.5
|
7 |
Author: Devin Price
|
8 |
Author URI: http://www.wptheming.com
|
9 |
License: GPLv2
|
161 |
foreach ($options as $option) {
|
162 |
|
163 |
if ( ($option['type'] != 'heading') && ($option['type'] != 'info') ) {
|
164 |
+
$option_id = preg_replace('/\W/', '', strtolower($option['id']) );
|
165 |
|
166 |
// wp_filter_post_kses for strings
|
167 |
if (isset($option['std' ]) ) {
|
168 |
if ( !is_array($option['std' ]) ) {
|
169 |
+
$values[$option_id] = wp_filter_post_kses($option['std']);
|
170 |
} else {
|
171 |
foreach ($option['std' ] as $key => $value) {
|
|
|
172 |
$optionarray[$key] = wp_filter_post_kses($value);
|
173 |
}
|
174 |
$values[$option_id] = $optionarray;
|
354 |
// Verify that the option has an id
|
355 |
if ( isset ($option['id']) ) {
|
356 |
|
357 |
+
// Keep all ids lowercase with no spaces
|
358 |
+
$option['id'] = preg_replace('/\W/', '', strtolower($option['id']) );
|
359 |
+
|
360 |
// Checkbox data isn't sent if it's unchecked, so we'll default it to false
|
361 |
if ( ($option['type'] == 'checkbox') && !isset($input[($option['id'])]) ) {
|
362 |
$input[($option['id'])] = 'false';
|
378 |
|
379 |
// If it's a multicheck
|
380 |
case ($option['type'] == 'multicheck'):
|
381 |
+
unset($checkboxarray);
|
382 |
foreach ($option['options'] as $key => $option_name ) {
|
383 |
// Make sure the key is lowercase and without spaces
|
384 |
+
$key = preg_replace('/\W/', '', strtolower($key));
|
385 |
// Check that the option isn't null
|
386 |
if (!empty($input[($option['id']. '_' . $key)])) {
|
387 |
// If it's not null, make sure it's true, add it to an array
|
481 |
return $default;
|
482 |
}
|
483 |
}
|
484 |
+
}
|
485 |
+
|
486 |
+
/**
|
487 |
+
* Add Theme Options menu item to Admin Bar.
|
488 |
+
*/
|
489 |
+
|
490 |
+
add_action( 'wp_before_admin_bar_render', 'optionsframework_adminbar' );
|
491 |
+
|
492 |
+
function optionsframework_adminbar() {
|
493 |
+
|
494 |
+
global $wp_admin_bar;
|
495 |
+
|
496 |
+
$wp_admin_bar->add_menu( array(
|
497 |
+
'parent' => 'appearance',
|
498 |
+
'id' => 'of_theme_options',
|
499 |
+
'title' => __( 'Theme Options' ),
|
500 |
+
'href' => admin_url( 'themes.php?page=options-framework' )
|
501 |
+
));
|
502 |
}
|
options-interface.php
CHANGED
@@ -31,11 +31,14 @@ function optionsframework_fields() {
|
|
31 |
|
32 |
// Wrap all options
|
33 |
if ( ($value['type'] != "heading") && ($value['type'] != "info") ) {
|
|
|
|
|
|
|
|
|
34 |
$class = ''; if(isset( $value['class'] )) { $class = $value['class']; }
|
35 |
$output .= '<div id="section-' . $value['id'] .'" class="section section-'.$value['type'].' '. $class .'">'."\n";
|
36 |
$output .= '<h3 class="heading">'. $value['name'] .'</h3>'."\n";
|
37 |
$output .= '<div class="option">'."\n" . '<div class="controls">'."\n";
|
38 |
-
|
39 |
}
|
40 |
|
41 |
// Set default value to $val
|
@@ -120,10 +123,10 @@ function optionsframework_fields() {
|
|
120 |
|
121 |
// Multicheck
|
122 |
case "multicheck":
|
123 |
-
$output .= '<input id="'. $value['id'] .'" type="hidden" name="'.$option_name.'['.$value['id'].']" />';
|
124 |
foreach ($value['options'] as $key => $option) {
|
125 |
$checkbox_name = $option;
|
126 |
-
$option = preg_replace(
|
127 |
$checkbox_id = $option_name.'['.$value['id'].'_'. $option .']';
|
128 |
$checked = '';
|
129 |
|
@@ -290,7 +293,7 @@ function optionsframework_fields() {
|
|
290 |
if($counter >= 2){
|
291 |
$output .= '</div>'."\n";
|
292 |
}
|
293 |
-
$jquery_click_hook =
|
294 |
$jquery_click_hook = "of-option-" . $jquery_click_hook;
|
295 |
$menu .= '<li><a title="'. $value['name'] .'" href="#'. $jquery_click_hook .'">'. $value['name'] .'</a></li>';
|
296 |
$output .= '<div class="group" id="'. $jquery_click_hook .'"><h2>'.$value['name'].'</h2>'."\n";
|
31 |
|
32 |
// Wrap all options
|
33 |
if ( ($value['type'] != "heading") && ($value['type'] != "info") ) {
|
34 |
+
|
35 |
+
// Keep all ids lowercase with no spaces
|
36 |
+
$value['id'] = preg_replace('/\W/', '', strtolower($value['id']) );
|
37 |
+
|
38 |
$class = ''; if(isset( $value['class'] )) { $class = $value['class']; }
|
39 |
$output .= '<div id="section-' . $value['id'] .'" class="section section-'.$value['type'].' '. $class .'">'."\n";
|
40 |
$output .= '<h3 class="heading">'. $value['name'] .'</h3>'."\n";
|
41 |
$output .= '<div class="option">'."\n" . '<div class="controls">'."\n";
|
|
|
42 |
}
|
43 |
|
44 |
// Set default value to $val
|
123 |
|
124 |
// Multicheck
|
125 |
case "multicheck":
|
126 |
+
$output .= '<input id="'. $value['id'] .'" type="hidden" name="'.$option_name.'['.$value['id'].']" />';
|
127 |
foreach ($value['options'] as $key => $option) {
|
128 |
$checkbox_name = $option;
|
129 |
+
$option = preg_replace('/\W/', '', strtolower($key));
|
130 |
$checkbox_id = $option_name.'['.$value['id'].'_'. $option .']';
|
131 |
$checked = '';
|
132 |
|
293 |
if($counter >= 2){
|
294 |
$output .= '</div>'."\n";
|
295 |
}
|
296 |
+
$jquery_click_hook = preg_replace('/\W/', '', strtolower($value['name']) );
|
297 |
$jquery_click_hook = "of-option-" . $jquery_click_hook;
|
298 |
$menu .= '<li><a title="'. $value['name'] .'" href="#'. $jquery_click_hook .'">'. $value['name'] .'</a></li>';
|
299 |
$output .= '<div class="group" id="'. $jquery_click_hook .'"><h2>'.$value['name'].'</h2>'."\n";
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Donate link:
|
|
5 |
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=X238BDP4QGTV2
|
6 |
Requires at least: 3.0
|
7 |
Tested up to: 3.1
|
8 |
-
Stable tag: 0.
|
9 |
License: GPLv2
|
10 |
|
11 |
== Description ==
|
@@ -52,6 +52,13 @@ You can also watch the video screencast I have at [http://wptheming.com/options-
|
|
52 |
|
53 |
== Changelog ==
|
54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
= 0.4 =
|
56 |
|
57 |
* Updated multicheck option to save keys rather than values
|
5 |
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=X238BDP4QGTV2
|
6 |
Requires at least: 3.0
|
7 |
Tested up to: 3.1
|
8 |
+
Stable tag: 0.5
|
9 |
License: GPLv2
|
10 |
|
11 |
== Description ==
|
52 |
|
53 |
== Changelog ==
|
54 |
|
55 |
+
= 0.5 =
|
56 |
+
|
57 |
+
* Fixed errors when more than one multicheck options is used
|
58 |
+
* Updated optionsframework_setdefaults so defaults actually save on first run
|
59 |
+
* Require that all options have lowercase alphanumeric ids
|
60 |
+
* Added link to options from the WordPress admin bar
|
61 |
+
|
62 |
= 0.4 =
|
63 |
|
64 |
* Updated multicheck option to save keys rather than values
|
screenshot-1.png
CHANGED
File without changes
|