Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: cgutierrez/NHP-Theme-Options-Framework
base: ca17def7f9
...
head fork: cgutierrez/NHP-Theme-Options-Framework
compare: 8564476ba3
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 37 files changed
  • 0 commit comments
  • 2 contributors
Commits on Apr 21, 2012
@leemason leemason adding v1.0.5 72d3077
@leemason leemason removing non comments from master branch 04fa31e
Commits on Apr 23, 2012
@cgutierrez added set method to allow for setting arbitrary options. update get m…
…ethod to take a default value and not error if the option doesn't exist.
8564476
Showing with 363 additions and 354 deletions.
  1. +1 −1  README.md
  2. BIN  options/fields/.DS_Store
  3. +3 −3 options/fields/button_set/field_button_set.php
  4. +2 −2 options/fields/cats_multi_select/field_cats_multi_select.php
  5. +2 −2 options/fields/cats_select/field_cats_select.php
  6. +2 −2 options/fields/checkbox/field_checkbox.php
  7. +3 −3 options/fields/checkbox_hide_below/field_checkbox_hide_below.php
  8. +3 −3 options/fields/color/field_color.php
  9. +3 −3 options/fields/color_gradient/field_color_gradient.php
  10. +3 −3 options/fields/date/field_date.php
  11. +2 −2 options/fields/divide/field_divide.php
  12. +2 −2 options/fields/editor/field_editor.php
  13. +2 −2 options/fields/info/field_info.php
  14. +7 −6 options/fields/menu_location_select/field_menu_location_select.php
  15. +7 −5 options/fields/menu_select/field_menu_select.php
  16. +2 −2 options/fields/multi_checkbox/field_multi_checkbox.php
  17. +2 −2 options/fields/multi_select/field_multi_select.php
  18. +16 −0 options/fields/multi_text/field_multi_text.js
  19. +81 −0 options/fields/multi_text/field_multi_text.php
  20. +2 −2 options/fields/pages_multi_select/field_pages_multi_select.php
  21. +2 −2 options/fields/pages_select/field_pages_select.php
  22. +2 −2 options/fields/post_type_select/field_post_type_select.php
  23. +2 −2 options/fields/posts_multi_select/field_posts_multi_select.php
  24. +2 −2 options/fields/posts_select/field_posts_select.php
  25. +2 −2 options/fields/radio/field_radio.php
  26. +3 −3 options/fields/radio_img/field_radio_img.php
  27. +2 −2 options/fields/select/field_select.php
  28. +3 −3 options/fields/select_hide_below/field_select_hide_below.php
  29. +2 −2 options/fields/tags_multi_select/field_tags_multi_select.php
  30. +2 −2 options/fields/tags_select/field_tags_select.php
  31. +2 −2 options/fields/text/field_text.php
  32. +2 −2 options/fields/textarea/field_textarea.php
  33. +3 −3 options/fields/upload/field_upload.php
  34. BIN  options/img/menu_icon.png
  35. +2 −1  options/js/options.js
  36. +132 −259 options/options.php
  37. +55 −20 theme-options.php
View
2  README.md
@@ -1,4 +1,4 @@
-# NHP Theme Options V1.0.4 #
+# NHP Theme Options V1.0.5 #
Theme options framework which uses the [WordPress Settings API](http://codex.wordpress.org/Settings_API "WordPress Settings API"), Custom Error/Validation Handling, Custom Field/Validation Types (which are easily extendable), and import/export functionality.
View
BIN  options/fields/.DS_Store
Binary file not shown
View
6 options/fields/button_set/field_button_set.php
@@ -8,9 +8,9 @@ class NHP_Options_button_set extends NHP_Options{
*
* @since NHP_Options 1.0
*/
- function __construct($field = array(), $value =''){
+ function __construct($field = array(), $value ='', $parent){
- parent::__construct();
+ parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
$this->field = $field;
$this->value = $value;
//$this->render();
@@ -60,7 +60,7 @@ function enqueue(){
wp_enqueue_script(
'nhp-opts-field-button_set-js',
- $this->args['theme_url'].'options/fields/button_set/field_button_set.js',
+ NHP_OPTIONS_URL.'fields/button_set/field_button_set.js',
array('jquery', 'jquery-ui-core', 'jquery-ui-dialog'),
time(),
true
View
4 options/fields/cats_multi_select/field_cats_multi_select.php
@@ -8,9 +8,9 @@ class NHP_Options_cats_multi_select extends NHP_Options{
*
* @since NHP_Options 1.0.1
*/
- function __construct($field = array(), $value =''){
+ function __construct($field = array(), $value ='', $parent){
- parent::__construct();
+ parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
$this->field = $field;
$this->value = $value;
//$this->render();
View
4 options/fields/cats_select/field_cats_select.php
@@ -8,9 +8,9 @@ class NHP_Options_cats_select extends NHP_Options{
*
* @since NHP_Options 1.0.1
*/
- function __construct($field = array(), $value =''){
+ function __construct($field = array(), $value ='', $parent){
- parent::__construct();
+ parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
$this->field = $field;
$this->value = $value;
//$this->render();
View
4 options/fields/checkbox/field_checkbox.php
@@ -8,9 +8,9 @@ class NHP_Options_checkbox extends NHP_Options{
*
* @since NHP_Options 1.0
*/
- function __construct($field = array(), $value =''){
+ function __construct($field = array(), $value ='', $parent){
- parent::__construct();
+ parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
$this->field = $field;
$this->value = $value;
//$this->render();
View
6 options/fields/checkbox_hide_below/field_checkbox_hide_below.php
@@ -8,9 +8,9 @@ class NHP_Options_checkbox_hide_below extends NHP_Options{
*
* @since NHP_Options 1.0.1
*/
- function __construct($field = array(), $value =''){
+ function __construct($field = array(), $value ='', $parent){
- parent::__construct();
+ parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
$this->field = $field;
$this->value = $value;
//$this->render();
@@ -50,7 +50,7 @@ function enqueue(){
wp_enqueue_script(
'nhp-opts-checkbox-hide-below-js',
- $this->args['theme_url'].'options/fields/checkbox_hide_below/field_checkbox_hide_below.js',
+ NHP_OPTIONS_URL.'fields/checkbox_hide_below/field_checkbox_hide_below.js',
array('jquery'),
time(),
true
View
6 options/fields/color/field_color.php
@@ -8,9 +8,9 @@ class NHP_Options_color extends NHP_Options{
*
* @since NHP_Options 1.0
*/
- function __construct($field = array(), $value =''){
+ function __construct($field = array(), $value ='', $parent){
- parent::__construct();
+ parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
$this->field = $field;
$this->value = $value;
//$this->render();
@@ -53,7 +53,7 @@ function enqueue(){
wp_enqueue_script(
'nhp-opts-field-color-js',
- $this->args['theme_url'].'options/fields/color/field_color.js',
+ NHP_OPTIONS_URL.'fields/color/field_color.js',
array('jquery', 'farbtastic'),
time(),
true
View
6 options/fields/color_gradient/field_color_gradient.php
@@ -8,9 +8,9 @@ class NHP_Options_color_gradient extends NHP_Options{
*
* @since NHP_Options 1.0
*/
- function __construct($field = array(), $value =''){
+ function __construct($field = array(), $value ='', $parent){
- parent::__construct();
+ parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
$this->field = $field;
$this->value = $value;
//$this->render();
@@ -56,7 +56,7 @@ function enqueue(){
wp_enqueue_script(
'nhp-opts-field-color-js',
- $this->args['theme_url'].'options/fields/color/field_color.js',
+ NHP_OPTIONS_URL.'fields/color/field_color.js',
array('jquery', 'farbtastic'),
time(),
true
View
6 options/fields/date/field_date.php
@@ -8,9 +8,9 @@ class NHP_Options_date extends NHP_Options{
*
* @since NHP_Options 1.0
*/
- function __construct($field = array(), $value =''){
+ function __construct($field = array(), $value ='', $parent){
- parent::__construct();
+ parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
$this->field = $field;
$this->value = $value;
//$this->render();
@@ -49,7 +49,7 @@ function enqueue(){
wp_enqueue_script(
'nhp-opts-field-date-js',
- $this->args['theme_url'].'options/fields/date/field_date.js',
+ NHP_OPTIONS_URL.'fields/date/field_date.js',
array('jquery', 'jquery-ui-core', 'jquery-ui-datepicker'),
time(),
true
View
4 options/fields/divide/field_divide.php
@@ -8,9 +8,9 @@ class NHP_Options_divide extends NHP_Options{
*
* @since NHP_Options 1.0
*/
- function __construct($field = array(), $value =''){
+ function __construct($field = array(), $value ='', $parent){
- parent::__construct();
+ parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
$this->field = $field;
$this->value = $value;
//$this->render();
View
4 options/fields/editor/field_editor.php
@@ -8,9 +8,9 @@ class NHP_Options_editor extends NHP_Options{
*
* @since NHP_Options 1.0
*/
- function __construct($field = array(), $value =''){
+ function __construct($field = array(), $value ='', $parent){
- parent::__construct();
+ parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
$this->field = $field;
$this->value = $value;
//$this->render();
View
4 options/fields/info/field_info.php
@@ -8,9 +8,9 @@ class NHP_Options_info extends NHP_Options{
*
* @since NHP_Options 1.0
*/
- function __construct($field = array(), $value =''){
+ function __construct($field = array(), $value ='', $parent){
- parent::__construct();
+ parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
$this->field = $field;
$this->value = $value;
//$this->render();
View
13 options/fields/menu_location_select/field_menu_location_select.php
@@ -8,9 +8,9 @@ class NHP_Options_menu_location_select extends NHP_Options{
*
* @since NHP_Options 1.0.1
*/
- function __construct($field = array(), $value =''){
+ function __construct($field = array(), $value ='', $parent){
- parent::__construct();
+ parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
$this->field = $field;
$this->value = $value;
//$this->render();
@@ -33,10 +33,11 @@ function render(){
echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" '.$class.' >';
-
- foreach ( $_wp_registered_nav_menus as $k => $v ) {
- echo '<option value="'.$k.'"'.selected($this->value, $k, false).'>'.$v.'</option>';
- }
+ if($_wp_registered_nav_menus){
+ foreach ( $_wp_registered_nav_menus as $k => $v ) {
+ echo '<option value="'.$k.'"'.selected($this->value, $k, false).'>'.$v.'</option>';
+ }
+ }//if
echo '</select>';
View
12 options/fields/menu_select/field_menu_select.php
@@ -8,9 +8,9 @@ class NHP_Options_menu_select extends NHP_Options{
*
* @since NHP_Options 1.0.1
*/
- function __construct($field = array(), $value =''){
+ function __construct($field = array(), $value ='', $parent){
- parent::__construct();
+ parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
$this->field = $field;
$this->value = $value;
//$this->render();
@@ -36,9 +36,11 @@ function render(){
$args = wp_parse_args($this->field['args'], array());
$menus = wp_get_nav_menus($args);
- foreach ( $menus as $menu ) {
- echo '<option value="'.$menu->term_id.'"'.selected($this->value, $menu->term_id, false).'>'.$menu->name.'</option>';
- }
+ if($menus){
+ foreach ( $menus as $menu ) {
+ echo '<option value="'.$menu->term_id.'"'.selected($this->value, $menu->term_id, false).'>'.$menu->name.'</option>';
+ }
+ }//if
echo '</select>';
View
4 options/fields/multi_checkbox/field_multi_checkbox.php
@@ -8,9 +8,9 @@ class NHP_Options_multi_checkbox extends NHP_Options{
*
* @since NHP_Options 1.0
*/
- function __construct($field = array(), $value =''){
+ function __construct($field = array(), $value ='', $parent){
- parent::__construct();
+ parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
$this->field = $field;
$this->value = $value;
//$this->render();
View
4 options/fields/multi_select/field_multi_select.php
@@ -8,9 +8,9 @@ class NHP_Options_multi_select extends NHP_Options{
*
* @since NHP_Options 1.0
*/
- function __construct($field = array(), $value =''){
+ function __construct($field = array(), $value ='', $parent){
- parent::__construct();
+ parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
$this->field = $field;
$this->value = $value;
//$this->render();
View
16 options/fields/multi_text/field_multi_text.js
@@ -0,0 +1,16 @@
+jQuery(document).ready(function(){
+
+ jQuery('.nhp-opts-multi-text-remove').live('click', function(){
+ jQuery(this).prev('input[type="text"]').val('');
+ jQuery(this).parent().fadeOut('slow', function(){jQuery(this).remove();});
+ });
+
+ jQuery('.nhp-opts-multi-text-add').click(function(){
+ var new_input = jQuery('#'+jQuery(this).attr('rel-id')+' li:last-child').clone();
+ jQuery('#'+jQuery(this).attr('rel-id')).append(new_input);
+ jQuery('#'+jQuery(this).attr('rel-id')+' li:last-child').removeAttr('style');
+ jQuery('#'+jQuery(this).attr('rel-id')+' li:last-child input[type="text"]').val('');
+ jQuery('#'+jQuery(this).attr('rel-id')+' li:last-child input[type="text"]').attr('name' , jQuery(this).attr('rel-name'));
+ });
+
+});
View
81 options/fields/multi_text/field_multi_text.php
@@ -0,0 +1,81 @@
+<?php
+class NHP_Options_multi_text extends NHP_Options{
+
+ /**
+ * Field Constructor.
+ *
+ * Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
+ *
+ * @since NHP_Options 1.0.5
+ */
+ function __construct($field = array(), $value ='', $parent){
+
+ parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
+ $this->field = $field;
+ $this->value = $value;
+ //$this->render();
+
+ }//function
+
+
+
+ /**
+ * Field Render Function.
+ *
+ * Takes the vars and outputs the HTML for the field in the settings
+ *
+ * @since NHP_Options 1.0.5
+ */
+ function render(){
+
+ $class = (isset($this->field['class']))?$this->field['class']:'regular-text';
+
+ echo '<ul id="'.$this->field['id'].'-ul">';
+
+ if(isset($this->value) && is_array($this->value)){
+ foreach($this->value as $k => $value){
+ if($value != ''){
+
+ echo '<li><input type="text" id="'.$this->field['id'].'-'.$k.'" name="'.$this->args['opt_name'].'['.$this->field['id'].'][]" value="'.esc_attr($value).'" class="'.$class.'" /> <a href="javascript:void(0);" class="nhp-opts-multi-text-remove">'.__('Remove', 'nhp-opts').'</a></li>';
+
+ }//if
+
+ }//foreach
+ }else{
+
+ echo '<li><input type="text" id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].'][]" value="" class="'.$class.'" /> <a href="javascript:void(0);" class="nhp-opts-multi-text-remove">'.__('Remove', 'nhp-opts').'</a></li>';
+
+ }//if
+
+ echo '<li style="display:none;"><input type="text" id="'.$this->field['id'].'" name="" value="" class="'.$class.'" /> <a href="javascript:void(0);" class="nhp-opts-multi-text-remove">'.__('Remove', 'nhp-opts').'</a></li>';
+
+ echo '</ul>';
+
+ echo '<a href="javascript:void(0);" class="nhp-opts-multi-text-add" rel-id="'.$this->field['id'].'-ul" rel-name="'.$this->args['opt_name'].'['.$this->field['id'].'][]">'.__('Add More', 'nhp-opts').'</a><br/>';
+
+ echo ($this->field['desc'] != '')?' <span class="description">'.$this->field['desc'].'</span>':'';
+
+ }//function
+
+
+ /**
+ * Enqueue Function.
+ *
+ * If this field requires any scripts, or css define this function and register/enqueue the scripts/css
+ *
+ * @since NHP_Options 1.0.5
+ */
+ function enqueue(){
+
+ wp_enqueue_script(
+ 'nhp-opts-field-multi-text-js',
+ NHP_OPTIONS_URL.'fields/multi_text/field_multi_text.js',
+ array('jquery'),
+ time(),
+ true
+ );
+
+ }//function
+
+}//class
+?>
View
4 options/fields/pages_multi_select/field_pages_multi_select.php
@@ -8,9 +8,9 @@ class NHP_Options_pages_multi_select extends NHP_Options{
*
* @since NHP_Options 1.0.1
*/
- function __construct($field = array(), $value =''){
+ function __construct($field = array(), $value ='', $parent){
- parent::__construct();
+ parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
$this->field = $field;
$this->value = $value;
//$this->render();
View
4 options/fields/pages_select/field_pages_select.php
@@ -8,9 +8,9 @@ class NHP_Options_pages_select extends NHP_Options{
*
* @since NHP_Options 1.0.1
*/
- function __construct($field = array(), $value =''){
+ function __construct($field = array(), $value ='', $parent){
- parent::__construct();
+ parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
$this->field = $field;
$this->value = $value;
//$this->render();
View
4 options/fields/post_type_select/field_post_type_select.php
@@ -8,9 +8,9 @@ class NHP_Options_post_type_select extends NHP_Options{
*
* @since NHP_Options 1.0.1
*/
- function __construct($field = array(), $value =''){
+ function __construct($field = array(), $value ='', $parent){
- parent::__construct();
+ parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
$this->field = $field;
$this->value = $value;
//$this->render();
View
4 options/fields/posts_multi_select/field_posts_multi_select.php
@@ -8,9 +8,9 @@ class NHP_Options_posts_multi_select extends NHP_Options{
*
* @since NHP_Options 1.0.1
*/
- function __construct($field = array(), $value =''){
+ function __construct($field = array(), $value ='', $parent){
- parent::__construct();
+ parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
$this->field = $field;
$this->value = $value;
//$this->render();
View
4 options/fields/posts_select/field_posts_select.php
@@ -8,9 +8,9 @@ class NHP_Options_posts_select extends NHP_Options{
*
* @since NHP_Options 1.0.1
*/
- function __construct($field = array(), $value =''){
+ function __construct($field = array(), $value ='', $parent){
- parent::__construct();
+ parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
$this->field = $field;
$this->value = $value;
//$this->render();
View
4 options/fields/radio/field_radio.php
@@ -8,9 +8,9 @@ class NHP_Options_radio extends NHP_Options{
*
* @since NHP_Options 1.0
*/
- function __construct($field = array(), $value =''){
+ function __construct($field = array(), $value ='', $parent){
- parent::__construct();
+ parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
$this->field = $field;
$this->value = $value;
//$this->render();
View
6 options/fields/radio_img/field_radio_img.php
@@ -8,9 +8,9 @@ class NHP_Options_radio_img extends NHP_Options{
*
* @since NHP_Options 1.0
*/
- function __construct($field = array(), $value =''){
+ function __construct($field = array(), $value = '', $parent = ''){
- parent::__construct();
+ parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
$this->field = $field;
$this->value = $value;
//$this->render();
@@ -64,7 +64,7 @@ function enqueue(){
wp_enqueue_script(
'nhp-opts-field-radio_img-js',
- $this->args['theme_url'].'options/fields/radio_img/field_radio_img.js',
+ NHP_OPTIONS_URL.'fields/radio_img/field_radio_img.js',
array('jquery'),
time(),
true
View
4 options/fields/select/field_select.php
@@ -8,9 +8,9 @@ class NHP_Options_select extends NHP_Options{
*
* @since NHP_Options 1.0
*/
- function __construct($field = array(), $value =''){
+ function __construct($field = array(), $value ='', $parent){
- parent::__construct();
+ parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
$this->field = $field;
$this->value = $value;
//$this->render();
View
6 options/fields/select_hide_below/field_select_hide_below.php
@@ -8,9 +8,9 @@ class NHP_Options_select_hide_below extends NHP_Options{
*
* @since NHP_Options 1.0.1
*/
- function __construct($field = array(), $value =''){
+ function __construct($field = array(), $value ='', $parent){
- parent::__construct();
+ parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
$this->field = $field;
$this->value = $value;
//$this->render();
@@ -56,7 +56,7 @@ function enqueue(){
wp_enqueue_script(
'nhp-opts-select-hide-below-js',
- $this->args['theme_url'].'options/fields/select_hide_below/field_select_hide_below.js',
+ NHP_OPTIONS_URL.'fields/select_hide_below/field_select_hide_below.js',
array('jquery'),
time(),
true
View
4 options/fields/tags_multi_select/field_tags_multi_select.php
@@ -8,9 +8,9 @@ class NHP_Options_tags_multi_select extends NHP_Options{
*
* @since NHP_Options 1.0.1
*/
- function __construct($field = array(), $value =''){
+ function __construct($field = array(), $value ='', $parent){
- parent::__construct();
+ parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
$this->field = $field;
$this->value = $value;
//$this->render();
View
4 options/fields/tags_select/field_tags_select.php
@@ -8,9 +8,9 @@ class NHP_Options_tags_select extends NHP_Options{
*
* @since NHP_Options 1.0.1
*/
- function __construct($field = array(), $value =''){
+ function __construct($field = array(), $value ='', $parent){
- parent::__construct();
+ parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
$this->field = $field;
$this->value = $value;
//$this->render();
View
4 options/fields/text/field_text.php
@@ -8,9 +8,9 @@ class NHP_Options_text extends NHP_Options{
*
* @since NHP_Options 1.0
*/
- function __construct($field = array(), $value =''){
+ function __construct($field = array(), $value ='', $parent){
- parent::__construct();
+ parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
$this->field = $field;
$this->value = $value;
//$this->render();
View
4 options/fields/textarea/field_textarea.php
@@ -8,9 +8,9 @@ class NHP_Options_textarea extends NHP_Options{
*
* @since NHP_Options 1.0
*/
- function __construct($field = array(), $value =''){
+ function __construct($field = array(), $value ='', $parent){
- parent::__construct();
+ parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
$this->field = $field;
$this->value = $value;
//$this->render();
View
6 options/fields/upload/field_upload.php
@@ -8,9 +8,9 @@ class NHP_Options_upload extends NHP_Options{
*
* @since NHP_Options 1.0
*/
- function __construct($field = array(), $value =''){
+ function __construct($field = array(), $value ='', $parent = ''){
- parent::__construct();
+ parent::__construct($parent->sections, $parent->args, $parent->extra_tabs);
$this->field = $field;
$this->value = $value;
@@ -56,7 +56,7 @@ function enqueue(){
wp_enqueue_script(
'nhp-opts-field-upload-js',
- $this->url.'fields/upload/field_upload.js',
+ NHP_OPTIONS_URL.'fields/upload/field_upload.js',
array('jquery', 'thickbox', 'media-upload'),
time(),
true
View
BIN  options/img/menu_icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
3  options/js/options.js
@@ -2,7 +2,7 @@ jQuery(document).ready(function(){
if(jQuery('#last_tab').val() == ''){
- jQuery('#0_section_group').slideDown('fast');
+ jQuery('.nhp-opts-group-tab:first').slideDown('fast');
jQuery('#nhp-opts-group-menu li:first').addClass('active');
}else{
@@ -14,6 +14,7 @@ jQuery(document).ready(function(){
}
+
jQuery('.nhp-opts-group-tab-link-a').click(function(){
relid = jQuery(this).attr('data-rel');
View
391 options/options.php
@@ -1,25 +1,29 @@
<?php
-/*
-changelog
-
-* Added opt name to feed download of options
-* Added context to class construct - for use later on
-
-
-*/
-
if ( ! class_exists('NHP_Options') ){
- if( file_exists(STYLESHEETPATH.'/options/options.php') ){
- define('NHP_OPTIONS_URL', trailingslashit(get_stylesheet_directory_uri()).'options/');
- }elseif( file_exists(TEMPLATEPATH.'/options/options.php') ){
- define('NHP_OPTIONS_URL', trailingslashit(get_template_directory_uri()).'options/');
+ if(!defined('NHP_OPTIONS_DIR')){
+ define('NHP_OPTIONS_DIR', trailingslashit(dirname(__FILE__)));
}
- define('NHP_OPTIONS_DIR', trailingslashit(dirname(__FILE__)));
+ if(!defined('NHP_OPTIONS_URL')){
+ define('NHP_OPTIONS_URL', site_url(str_replace(ABSPATH, '', trailingslashit(dirname(__FILE__)))));
+ }
class NHP_Options{
+ public $framework_url = 'http://leemason.github.com/NHP-Theme-Options-Framework/';
+ public $framework_version = '1.0.5';
+
+ public $dir = NHP_OPTIONS_DIR;
+ public $url = NHP_OPTIONS_URL;
+ public $page = '';
+ public $args = array();
+ public $sections = array();
+ public $extra_tabs = array();
+ public $errors = array();
+ public $warnings = array();
+ public $options = array();
+
/**
@@ -29,81 +33,41 @@ class NHP_Options{
*
* @param $array $args Arguments. Class constructor arguments.
*/
- function __construct($sections = array(), $args = array(), $context = 'theme'){
-
- $this->framework_url = 'http://leemason.github.com/NHP-Theme-Options-Framework/';
- $this->framework_version = '1.0.4';
-
- //get context for use throughout framework
- $this->context = $context;
-
- //get this path
- $this->dir = NHP_OPTIONS_DIR;
- //get this frameworks url for images,etc
- $this->url = NHP_OPTIONS_URL;
-
-
- //get field classes
- $this->get_fields();
-
- //get validation classes
- $this->get_validation();
-
- //get sections
- $this->sections = apply_filters('nhp-opts-sections', $sections);
+ function __construct($sections = array(), $args = array(), $extra_tabs = array()){
$defaults = array();
-
- $defaults['theme_dir'] = trailingslashit(get_stylesheet_directory());
- $defaults['theme_url'] = trailingslashit(get_stylesheet_directory_uri());
-
-
- $defaults['theme_data'] = get_theme_data($defaults['theme_dir'] .'style.css');
-
- $defaults['theme_data']['short_name'] = strtolower(preg_replace('/ /', '_', $defaults['theme_data']['Title']));
-
- $defaults['opt_name'] = $defaults['theme_data']['short_name'];
- $defaults['parent_page'] = 'theme';
+ $defaults['opt_name'] = '';//must be defined by theme/plugin
- $defaults['menu_title'] = __('Theme Options', 'nhp-opts');
- $defaults['page_title'] = $defaults['theme_data']['Title'].__(' Theme Options', 'nhp-opts');
- $defaults['page_slug'] = 'theme_options';
+ $defaults['menu_icon'] = NHP_OPTIONS_URL.'/img/menu_icon.png';
+ $defaults['menu_title'] = __('Options', 'nhp-opts');
+ $defaults['page_icon'] = 'icon-themes';
+ $defaults['page_title'] = __('Options', 'nhp-opts');
+ $defaults['page_slug'] = '_options';
$defaults['page_cap'] = 'manage_options';
+ $defaults['page_position'] = 100;
- $defaults['show_theme_info'] = true;
$defaults['show_import_export'] = true;
$defaults['dev_mode'] = true;
$defaults['stylesheet_override'] = false;
$defaults['footer_credit'] = __('<span id="footer-thankyou">Options Panel created using the <a href="'.$this->framework_url.'" target="_blank">NHP Theme Options Framework</a> Version '.$this->framework_version.'</span>', 'nhp-opts');
-
- foreach($defaults['theme_data'] as $tkey => $tdata){
- if(is_array($tdata)){$tdata = implode(', ',$tdata);}
- //if($tkey != ''){
- $helpdata[] = '<p><strong>'.$tkey.'</strong> - '.$tdata.'</p>';
- //}//if
- }//foreach
-
-
- $defaults['help_tabs'][] = array(
- 'id' => 'nhp-opts-1',
- 'title' => __('Theme Information', 'nhp-opts'),
- 'content' => implode($helpdata)
- );
-
+ $defaults['help_tabs'] = array();
$defaults['help_sidebar'] = __('', 'nhp-opts');
-
-
-
- $this->args = wp_parse_args( $args, $defaults );
+ //get args
+ $this->args = wp_parse_args($args, $defaults);
$this->args = apply_filters('nhp-opts-args', $this->args);
+ $this->args = apply_filters('nhp-opts-args-'.$this->args['opt_name'], $this->args);
- //setup the errors and warnings array for later
- $this->errors = array();
- $this->warnings = array();
+ //get sections
+ $this->sections = apply_filters('nhp-opts-sections', $sections);
+ $this->sections = apply_filters('nhp-opts-sections-'.$this->args['opt_name'], $this->sections);
+
+ //get extra tabs
+ $this->extra_tabs = apply_filters('nhp-opts-extra-tabs', $extra_tabs);
+ $this->extra_tabs = apply_filters('nhp-opts-extra-tabs-'.$this->args['opt_name'], $this->extra_tabs);
//set option with defaults
add_action('init', array(&$this, '_set_default_options'));
@@ -111,7 +75,6 @@ function __construct($sections = array(), $args = array(), $context = 'theme'){
//options page
add_action('admin_menu', array(&$this, '_options_page'));
-
//register setting
add_action('admin_init', array(&$this, '_register_setting'));
@@ -124,19 +87,9 @@ function __construct($sections = array(), $args = array(), $context = 'theme'){
//hook into the wp feeds for downloading the exported settings
add_action('do_feed_nhpopts', array(&$this, '_download_options'), 1, 1);
-
- if($this->context == 'theme' && $this->args['parent_page'] == 'theme'){
- add_action('admin_bar_menu', array(&$this, '_admin_bar_links'));
- }
-
- if($this->context == 'theme'){
- add_action('admin_init', array(&$this, '_auto_redirect_activation'));
- }
-
//get the options for use later on
$this->options = get_option($this->args['opt_name']);
-
}//function
@@ -147,11 +100,24 @@ function __construct($sections = array(), $args = array(), $context = 'theme'){
*
* @param $array $args Arguments. Class constructor arguments.
*/
- function get($opt_name){
- return $this->options[$opt_name];
+ function get($opt_name, $default = null){
+ return (!empty($this->options[$opt_name])) ? $this->options[$opt_name] : $default;
}//function
/**
+ * ->set(); This is used to set an arbitrary option in the options array
+ *
+ * @since NHP_Options 1.0.1
+ *
+ * @param string $opt_name the name of the option being added
+ * @param mixed $value the value of the option being added
+ */
+ function set($opt_name, $value) {
+ $this->options[$opt_name] = $value;
+ update_option($this->args['opt_name'], $this->options);
+ }
+
+ /**
* ->show(); This is used to echo and option value from the options array
*
* @since NHP_Options 1.0.1
@@ -167,84 +133,6 @@ function show($opt_name){
-
- /**
- * Get Fields - requires all the built in classes for field use
- *
- * @since NHP_Options 1.0
- *
- */
- function get_fields(){
-
- //V1.0.0
- require_once($this->dir.'fields/text/field_text.php');
- require_once($this->dir.'fields/textarea/field_textarea.php');
- require_once($this->dir.'fields/editor/field_editor.php');
- require_once($this->dir.'fields/checkbox/field_checkbox.php');
- require_once($this->dir.'fields/multi_checkbox/field_multi_checkbox.php');
- require_once($this->dir.'fields/select/field_select.php');
- require_once($this->dir.'fields/multi_select/field_multi_select.php');
- require_once($this->dir.'fields/radio/field_radio.php');
- require_once($this->dir.'fields/radio_img/field_radio_img.php');
- require_once($this->dir.'fields/button_set/field_button_set.php');
- require_once($this->dir.'fields/upload/field_upload.php');
- require_once($this->dir.'fields/color/field_color.php');
- require_once($this->dir.'fields/date/field_date.php');
- require_once($this->dir.'fields/info/field_info.php');
- require_once($this->dir.'fields/divide/field_divide.php');
-
- //V1.0.1
- require_once($this->dir.'fields/pages_select/field_pages_select.php');
- require_once($this->dir.'fields/pages_multi_select/field_pages_multi_select.php');
- require_once($this->dir.'fields/posts_select/field_posts_select.php');
- require_once($this->dir.'fields/posts_multi_select/field_posts_multi_select.php');
- require_once($this->dir.'fields/tags_select/field_tags_select.php');
- require_once($this->dir.'fields/tags_multi_select/field_tags_multi_select.php');
- require_once($this->dir.'fields/cats_select/field_cats_select.php');
- require_once($this->dir.'fields/cats_multi_select/field_cats_multi_select.php');
- require_once($this->dir.'fields/menu_select/field_menu_select.php');
- require_once($this->dir.'fields/menu_location_select/field_menu_location_select.php');
- require_once($this->dir.'fields/post_type_select/field_post_type_select.php');
- require_once($this->dir.'fields/checkbox_hide_below/field_checkbox_hide_below.php');
- require_once($this->dir.'fields/select_hide_below/field_select_hide_below.php');
-
- //V1.0.4
- require_once($this->dir.'fields/color_gradient/field_color_gradient.php');
-
-
- do_action('nhp-opts-get-fields');
- }//function
-
-
- /**
- * Get Validation - requires all the built in classes for validation use
- *
- * @since NHP_Options 1.0
- *
- */
- function get_validation(){
-
- //V1.0.0
- require_once($this->dir.'validation/email/validation_email.php');
- require_once($this->dir.'validation/no_html/validation_no_html.php');
- require_once($this->dir.'validation/html/validation_html.php');
- require_once($this->dir.'validation/html_custom/validation_html_custom.php');
- require_once($this->dir.'validation/url/validation_url.php');
- require_once($this->dir.'validation/numeric/validation_numeric.php');
- require_once($this->dir.'validation/js/validation_js.php');
-
- //V1.0.1
- require_once($this->dir.'validation/color/validation_color.php');
- require_once($this->dir.'validation/date/validation_date.php');
- require_once($this->dir.'validation/comma_numeric/validation_comma_numeric.php');
- require_once($this->dir.'validation/no_special_chars/validation_no_special_chars.php');
- require_once($this->dir.'validation/preg_replace/validation_preg_replace.php');
- require_once($this->dir.'validation/str_replace/validation_str_replace.php');
-
- do_action('nhp-opts-get-validation');
- }//function
-
-
/**
* Get default options into an array suitable for the settings API
*
@@ -300,14 +188,17 @@ function _set_default_options(){
* @since NHP_Options 1.0
*/
function _options_page(){
- $addpage = 'add_'.$this->args['parent_page'].'_page';
- $this->page = $addpage(
- $this->args['page_title'],
- $this->args['menu_title'],
- $this->args['page_cap'],
- $this->args['page_slug'],
- array(&$this, '_options_page_html')
- );
+
+ $this->page = add_menu_page(
+ $this->args['page_title'],
+ $this->args['menu_title'],
+ $this->args['page_cap'],
+ $this->args['page_slug'],
+ array(&$this, '_options_page_html'),
+ $this->args['menu_icon'],
+ $this->args['page_position']
+ );
+
add_action('admin_print_styles-'.$this->page, array(&$this, '_enqueue'));
add_action('load-'.$this->page, array(&$this, '_load_page'));
}//function
@@ -321,7 +212,7 @@ function _options_page(){
function _enqueue(){
wp_register_style(
- $this->args['theme_data']['short_name'].'-css',
+ 'nhp-opts-css',
$this->url.'css/options.css',
array('farbtastic'),
time(),
@@ -337,13 +228,13 @@ function _enqueue(){
);
- if(!$this->args['stylesheet_override']){
- wp_enqueue_style($this->args['theme_data']['short_name'].'-css');
+ if(false === $this->args['stylesheet_override']){
+ wp_enqueue_style('nhp-opts-css');
}
wp_enqueue_script(
- $this->args['theme_data']['short_name'].'-js',
+ 'nhp-opts-js',
$this->url.'js/options.js',
array('jquery'),
time(),
@@ -352,6 +243,8 @@ function _enqueue(){
do_action('nhp-opts-enqueue');
+ do_action('nhp-opts-enqueue-'.$this->args['opt_name']);
+
foreach($this->sections as $k => $section){
@@ -362,9 +255,13 @@ function _enqueue(){
if(isset($field['type'])){
$field_class = 'NHP_Options_'.$field['type'];
+
+ if(!class_exists($field_class)){
+ require_once($this->dir.'fields/'.$field['type'].'/field_'.$field['type'].'.php');
+ }//if
if(class_exists($field_class) && method_exists($field_class, 'enqueue')){
- $enqueue = new $field_class();
+ $enqueue = new $field_class('','',$this);
$enqueue->enqueue();
}//if
@@ -395,7 +292,7 @@ function _download_options(){
if(isset($_GET['action']) && $_GET['action'] == 'download_options'){
header('Content-Description: File Transfer');
header('Content-type: application/txt');
- header('Content-Disposition: attachment; filename="'.$this->args['theme_data']['short_name'].'_options_'.date('d-m-Y').'.txt"');
+ header('Content-Disposition: attachment; filename="'.$_GET['option'].'_options_'.date('d-m-Y').'.txt"');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
@@ -422,7 +319,7 @@ function _load_page(){
add_action('admin_head', array(&$this, 'admin_head'));
//do admin footer text hook
- add_filter( 'admin_footer_text', array(&$this, 'admin_footer_text'));
+ add_filter('admin_footer_text', array(&$this, 'admin_footer_text'));
$screen = get_current_screen();
@@ -438,6 +335,8 @@ function _load_page(){
do_action('nhp-opts-load-page', $screen);
+ do_action('nhp-opts-load-page-'.$this->args['opt_name'], $screen);
+
}//function
@@ -450,6 +349,8 @@ function admin_head(){
do_action('nhp-opts-admin-head', $this);
+ do_action('nhp-opts-admin-head-'.$this->args['opt_name'], $this);
+
}
@@ -494,6 +395,8 @@ function _register_setting(){
do_action('nhp-opts-register-settings');
+ do_action('nhp-opts-register-settings-'.$this->args['opt_name']);
+
}//function
@@ -529,7 +432,7 @@ function _validate_options($plugin_options){
$plugin_options = $this->_default_values();
return $plugin_options;
}//if set defaults
-
+
//validate fields (if needed)
$plugin_options = $this->_validate_values($plugin_options, $this->options);
@@ -544,13 +447,15 @@ function _validate_options($plugin_options){
do_action('nhp-opts-options-validate', $plugin_options, $this->options);
+ do_action('nhp-opts-options-validate-'.$this->args['opt_name'], $plugin_options, $this->options);
+
unset($plugin_options['defaults']);
unset($plugin_options['import']);
unset($plugin_options['import_code']);
unset($plugin_options['import_link']);
-
- return $plugin_options;
+
+ return $plugin_options;
}//function
@@ -571,6 +476,8 @@ function _validate_values($plugin_options, $options){
foreach($section['fields'] as $fieldk => $field){
$field['section_id'] = $k;
+ if(isset($field['type']) && $field['type'] == 'multi_text'){continue;}//we cant validate this yet
+
if(!isset($plugin_options[$field['id']]) || $plugin_options[$field['id']] == ''){
continue;
}
@@ -587,6 +494,11 @@ function _validate_values($plugin_options, $options){
if(isset($field['validate'])){
$validate = 'NHP_Validation_'.$field['validate'];
+
+ if(!class_exists($validate)){
+ require_once($this->dir.'validation/'.$field['validate'].'/validation_'.$field['validate'].'.php');
+ }//if
+
if(class_exists($validate)){
$validation = new $validate($field, $plugin_options[$field['id']], $options[$field['id']]);
$plugin_options[$field['id']] = $validation->value;
@@ -638,11 +550,13 @@ function _validate_values($plugin_options, $options){
function _options_page_html(){
echo '<div class="wrap">';
- echo '<div id="'.apply_filters('nhp-opts-page-icon-id', 'icon-themes').'" class="icon32"><br/></div>';
+ echo '<div id="'.$this->args['page_icon'].'" class="icon32"><br/></div>';
echo '<h2 id="nhp-opts-heading">'.get_admin_page_title().'</h2>';
echo (isset($this->args['intro_text']))?$this->args['intro_text']:'';
do_action('nhp-opts-page-before-form');
+
+ do_action('nhp-opts-page-before-form-'.$this->args['opt_name']);
echo '<form method="post" action="options.php" enctype="multipart/form-data" id="nhp-opts-form-wrapper">';
settings_fields($this->args['opt_name'].'_group');
@@ -682,32 +596,28 @@ function _options_page_html(){
do_action('nhp-opts-after-section-menu-items', $this);
- if($this->args['show_import_export'] == true){
+ do_action('nhp-opts-after-section-menu-items-'.$this->args['opt_name'], $this);
+
+ if(true === $this->args['show_import_export']){
echo '<li id="import_export_default_section_group_li" class="nhp-opts-group-tab-link-li">';
echo '<a href="javascript:void(0);" id="import_export_default_section_group_li_a" class="nhp-opts-group-tab-link-a" data-rel="import_export_default"><img src="'.$this->url.'img/glyphicons/glyphicons_082_roundabout.png" /> '.__('Import / Export', 'nhp-opts').'</a>';
echo '</li>';
echo '<li class="divide">&nbsp;</li>';
}//if
- if(file_exists($this->args['theme_dir'].'README.html')){
- echo '<li id="read_me_default_section_group_li" class="nhp-opts-group-tab-link-li">';
- echo '<a href="javascript:void(0);" id="read_me_default_section_group_li_a" class="nhp-opts-group-tab-link-a custom-tab" data-rel="read_me_default"><img src="'.$this->url.'img/glyphicons/glyphicons_071_book.png" /> '.__('Documentation', 'nhp-opts').'</a>';
- echo '</li>';
- }//if
- if($this->args['show_theme_info'] == true){
- echo '<li id="theme_info_default_section_group_li" class="nhp-opts-group-tab-link-li">';
- echo '<a href="javascript:void(0);" id="theme_info_default_section_group_li_a" class="nhp-opts-group-tab-link-a custom-tab" data-rel="theme_info_default"><img src="'.$this->url.'img/glyphicons/glyphicons_195_circle_info.png" /> '.__('Theme Information', 'nhp-opts').'</a>';
- echo '</li>';
- }//if
- if(isset($this->args['support_url'])){
- echo '<li id="support_link_default_section_group_li" class="nhp-opts-group-tab-link-li">';
- echo '<a href="'.$this->args['support_url'].'" id="support_link_default_section_group_li_a" class="custom-tab support-link" target="_blank"><img src="'.$this->url.'img/glyphicons/glyphicons_050_link.png" /> '.__('Support', 'nhp-opts').'</a>';
+
+
+ foreach($this->extra_tabs as $k => $tab){
+ $icon = (!isset($tab['icon']))?'<img src="'.$this->url.'img/glyphicons/glyphicons_019_cogwheel.png" /> ':'<img src="'.$tab['icon'].'" /> ';
+ echo '<li id="'.$k.'_section_group_li" class="nhp-opts-group-tab-link-li">';
+ echo '<a href="javascript:void(0);" id="'.$k.'_section_group_li_a" class="nhp-opts-group-tab-link-a custom-tab" data-rel="'.$k.'">'.$icon.$tab['title'].'</a>';
echo '</li>';
- }//if
+ }
+
- if($this->args['dev_mode'] == true){
+ if(true === $this->args['dev_mode']){
echo '<li id="dev_mode_default_section_group_li" class="nhp-opts-group-tab-link-li">';
echo '<a href="javascript:void(0);" id="dev_mode_default_section_group_li_a" class="nhp-opts-group-tab-link-a custom-tab" data-rel="dev_mode_default"><img src="'.$this->url.'img/glyphicons/glyphicons_195_circle_info.png" /> '.__('Dev Mode Info', 'nhp-opts').'</a>';
echo '</li>';
@@ -717,16 +627,15 @@ function _options_page_html(){
echo '</div>';
echo '<div id="nhp-opts-main">';
+
foreach($this->sections as $k => $section){
echo '<div id="'.$k.'_section_group'.'" class="nhp-opts-group-tab">';
do_settings_sections($k.'_section_group');
echo '</div>';
- }
+ }
-
-
- if($this->args['show_import_export'] == true){
+ if(true === $this->args['show_import_export']){
echo '<div id="import_export_default_section_group'.'" class="nhp-opts-group-tab">';
echo '<h3>'.__('Import / Export Options', 'nhp-opts').'</h3>';
@@ -781,29 +690,16 @@ function _options_page_html(){
-
-
- if($this->args['show_theme_info'] == true){
- echo '<div id="theme_info_default_section_group'.'" class="nhp-opts-group-tab">';
- echo '<h3>'.$this->args['theme_data']['Title'].'</h3>';
- echo '<div class="nhp-opts-section-desc">';
- echo '<p class="nhp-opts-theme-data description theme-uri">'.__('<strong>Theme URL:</strong> ', 'nhp-opts').'<a href="'.$this->args['theme_data']['URI'].'" target="_blank">'.$this->args['theme_data']['URI'].'</a></p>';
- echo '<p class="nhp-opts-theme-data description theme-author">'.__('<strong>Author:</strong> ', 'nhp-opts').$this->args['theme_data']['Author'].'</p>';
- echo '<p class="nhp-opts-theme-data description theme-version">'.__('<strong>Version:</strong> ', 'nhp-opts').$this->args['theme_data']['Version'].'</p>';
- echo '<p class="nhp-opts-theme-data description theme-description">'.$this->args['theme_data']['Description'].'</p>';
- echo '<p class="nhp-opts-theme-data description theme-tags">'.__('<strong>Tags:</strong> ', 'nhp-opts').implode(', ', $this->args['theme_data']['Tags']).'</p>';
- do_action('nhp-opts-after-theme-info', $this->args['theme_data']);
- echo '</div>';
+ foreach($this->extra_tabs as $k => $tab){
+ echo '<div id="'.$k.'_section_group'.'" class="nhp-opts-group-tab">';
+ echo '<h3>'.$tab['title'].'</h3>';
+ echo $tab['content'];
echo '</div>';
}
+
- if(file_exists($this->args['theme_dir'].'README.html')){
- echo '<div id="read_me_default_section_group'.'" class="nhp-opts-group-tab">';
- echo nl2br(file_get_contents($this->args['theme_dir'].'README.html'));
- echo '</div>';
- }//if
- if($this->args['dev_mode'] == true){
+ if(true === $this->args['dev_mode']){
echo '<div id="dev_mode_default_section_group'.'" class="nhp-opts-group-tab">';
echo '<h3>'.__('Dev Mode Info', 'nhp-opts').'</h3>';
echo '<div class="nhp-opts-section-desc">';
@@ -814,6 +710,8 @@ function _options_page_html(){
do_action('nhp-opts-after-section-items', $this);
+
+ do_action('nhp-opts-after-section-items-'.$this->args['opt_name'], $this);
echo '<div class="clear"></div><!--clearfix-->';
echo '</div>';
@@ -838,6 +736,8 @@ function _options_page_html(){
do_action('nhp-opts-page-after-form');
+ do_action('nhp-opts-page-after-form-'.$this->args['opt_name']);
+
echo '<div class="clear"></div><!--clearfix-->';
echo '</div><!--wrap-->';
@@ -950,8 +850,10 @@ function _field_input($field){
if(isset($field['callback']) && function_exists($field['callback'])){
$value = (isset($this->options[$field['id']]))?$this->options[$field['id']]:'';
do_action('nhp-opts-before-field', $field, $value);
+ do_action('nhp-opts-before-field-'.$this->args['opt_name'], $field, $value);
call_user_func($field['callback'], $field, $value);
do_action('nhp-opts-after-field', $field, $value);
+ do_action('nhp-opts-after-field-'.$this->args['opt_name'], $field, $value);
return;
}
@@ -960,52 +862,23 @@ function _field_input($field){
$field_class = 'NHP_Options_'.$field['type'];
if(class_exists($field_class)){
+ require_once($this->dir.'fields/'.$field['type'].'/field_'.$field['type'].'.php');
+ }//if
+
+ if(class_exists($field_class)){
$value = (isset($this->options[$field['id']]))?$this->options[$field['id']]:'';
do_action('nhp-opts-before-field', $field, $value);
- $render = new $field_class($field, $value);
+ do_action('nhp-opts-before-field-'.$this->args['opt_name'], $field, $value);
+ $render = '';
+ $render = new $field_class($field, $value, $this);
$render->render();
do_action('nhp-opts-after-field', $field, $value);
+ do_action('nhp-opts-after-field-'.$this->args['opt_name'], $field, $value);
}//if
}//if $field['type']
}//function
-
-
-
- /**
- * Add admin bar links
- *
- * Adds links to the admin bar for the options page.
- *
- * @since NHP_Options 1.0.4
- */
- function _admin_bar_links(){
- global $wp_admin_bar;
-
- $wp_admin_bar->add_node( array(
- 'parent' => 'top-secondary',
- 'id' => $this->args['page_slug'],
- 'title' => $this->args['page_title'],
- 'href' => admin_url( $this->args['parent_page'].'s.php?page='.$this->args['page_slug'])
- ));
-
- }//function
-
-
- /**
- * Auto redirect on activation
- *
- *
- * @since NHP_Options 1.0.4
- */
- function _auto_redirect_activation(){
- global $pagenow;
- if ( is_admin() && isset($_GET['activated'] ) && $pagenow == "themes.php" ){
- wp_redirect(admin_url( $this->args['parent_page'].'s.php?page='.$this->args['page_slug']));
- }//if
-
- }//function
}//class
View
75 theme-options.php
@@ -33,7 +33,7 @@ function add_another_section($sections){
return $sections;
}//function
-add_filter('nhp-opts-sections', 'add_another_section');
+//add_filter('nhp-opts-sections-twenty_eleven', 'add_another_section');
/*
@@ -48,7 +48,7 @@ function change_framework_args($args){
return $args;
}//function
-add_filter('nhp-opts-args', 'change_framework_args');
+//add_filter('nhp-opts-args-twenty_eleven', 'change_framework_args');
@@ -67,6 +67,7 @@ function change_framework_args($args){
*
*/
+function setup_framework_options(){
$args = array();
//Set it to dev mode to view the class settings/info in the form - default is false
@@ -78,9 +79,6 @@ function change_framework_args($args){
//Add HTML before the form
$args['intro_text'] = __('<p>This is the HTML which can be displayed before the form, it isnt required, but more info is always better. Anything goes in terms of markup here, any HTML.</p>', 'nhp-opts');
-//Set the support URL - if not set the link/tab isnt shown in the form
-$args['support_url'] = 'http://no-half-pixels.com';
-
//Setup custom links in the footer for share icons
$args['share_icons']['twitter'] = array(
'link' => 'http://twitter.com/lee__mason',
@@ -93,29 +91,32 @@ function change_framework_args($args){
'img' => NHP_OPTIONS_URL.'img/glyphicons/glyphicons_337_linked_in.png'
);
-//Set this to false to stop the Theme Information tab from being displayed - default functionality is to allow
-//$args['show_theme_info'] = false;
-
//Choose to disable the import/export feature
//$args['show_import_export'] = false;
//Choose a custom option name for your theme options, the default is the theme name in lowercase with spaces replaced by underscores
-//$args['opt_name'] = $defaults['theme_data']['short_name'];
+$args['opt_name'] = 'twenty_eleven';
-//Custom menu location for options page - default is "theme" - credits to https://github.com/MartyThornley
-//$args['parent_page'] = 'theme';
+//Custom menu icon
+//$args['menu_icon'] = '';
-//Custom menu title for options page - default is "Theme Options"
-//$args['menu_title'] = __('Theme Options', 'nhp-opts');
+//Custom menu title for options page - default is "Options"
+$args['menu_title'] = __('Theme Options', 'nhp-opts');
-//Custom Page Title for options page - default is "Theme name Theme Options"
-//$args['page_title'] = $defaults['theme_data']['Title'].__(' Theme Options', 'nhp-opts');
+//Custom Page Title for options page - default is "Options"
+$args['page_title'] = __('Twenty Eleven Theme Options', 'nhp-opts');
//Custom page slug for options page (wp-admin/themes.php?page=***) - default is "nhp_theme_options"
-//$args['page_slug'] = 'nhp_theme_options';
+$args['page_slug'] = 'theme_options';
//Custom page capability - default is set to "manage_options"
//$args['page_cap'] = 'manage_options';
+
+//custom page location - default 100 - must be unique or will override other items
+//$args['page_position'] = 10;
+
+//Custom page icon class (used to override the page icon next to heading)
+//$args['page_icon'] = 'icon-themes';
//Set ANY custom page help tabs - displayed using the new help tab API, show in order of definition
$args['help_tabs'][] = array(
@@ -175,6 +176,13 @@ function change_framework_args($args){
'std' => 'test@test.com'
),
array(
+ 'id' => 'multi_text',
+ 'type' => 'multi_text',
+ 'title' => __('Multi Text Option', 'nhp-opts'),
+ 'sub_desc' => __('This is a little space under the Field Title in the Options table, additonal info is good in here.', 'nhp-opts'),
+ 'desc' => __('This is the description field, again good for additional info.', 'nhp-opts')
+ ),
+ array(
'id' => '3',
'type' => 'text',
'title' => __('Text Option - URL Validated', 'nhp-opts'),
@@ -571,11 +579,38 @@ function change_framework_args($args){
)
)
);
+
+
+ $tabs = array();
+
+ $theme_data = get_theme_data(trailingslashit(get_stylesheet_directory()) .'style.css');
+ $theme_info = '<div class="nhp-opts-section-desc">';
+ $theme_info .= '<p class="nhp-opts-theme-data description theme-uri">'.__('<strong>Theme URL:</strong> ', 'nhp-opts').'<a href="'.$theme_data['URI'].'" target="_blank">'.$theme_data['URI'].'</a></p>';
+ $theme_info .= '<p class="nhp-opts-theme-data description theme-author">'.__('<strong>Author:</strong> ', 'nhp-opts').$theme_data['Author'].'</p>';
+ $theme_info .= '<p class="nhp-opts-theme-data description theme-version">'.__('<strong>Version:</strong> ', 'nhp-opts').$theme_data['Version'].'</p>';
+ $theme_info .= '<p class="nhp-opts-theme-data description theme-description">'.$theme_data['Description'].'</p>';
+ $theme_info .= '<p class="nhp-opts-theme-data description theme-tags">'.__('<strong>Tags:</strong> ', 'nhp-opts').implode(', ', $theme_data['Tags']).'</p>';
+ $theme_info .= '</div>';
+
+
+
+ $tabs['theme_info'] = array(
+ 'icon' => NHP_OPTIONS_URL.'img/glyphicons/glyphicons_195_circle_info.png',
+ 'title' => __('Theme Information', 'nhp-opts'),
+ 'content' => $theme_info
+ );
+
+ $tabs['theme_docs'] = array(
+ 'icon' => NHP_OPTIONS_URL.'img/glyphicons/glyphicons_071_book.png',
+ 'title' => __('Documentation', 'nhp-opts'),
+ 'content' => nl2br(file_get_contents(trailingslashit(get_stylesheet_directory()).'README.html'))
+ );
+
+ global $NHP_Options;
+ $NHP_Options = new NHP_Options($sections, $args, $tabs);
-global $NHP_Options;
-$NHP_Options = new NHP_Options($sections, $args);
-
-
+}//function
+add_action('init', 'setup_framework_options', 0);
/*
*

No commit comments for this range

Something went wrong with that request. Please try again.