Skip to content

Comparing changes

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

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 9 commits
  • 32 files changed
  • 0 commit comments
  • 3 contributors
Showing with 174 additions and 103 deletions.
  1. +4 −4 options/fields/button_set/field_button_set.php
  2. +3 −3 options/fields/cats_multi_select/field_cats_multi_select.php
  3. +3 −2 options/fields/cats_select/field_cats_select.php
  4. +10 −4 options/fields/checkbox/field_checkbox.php
  5. +3 −3 options/fields/checkbox_hide_below/field_checkbox_hide_below.php
  6. +3 −3 options/fields/color/field_color.php
  7. +4 −4 options/fields/color_gradient/field_color_gradient.php
  8. +3 −3 options/fields/date/field_date.php
  9. +2 −2 options/fields/divide/field_divide.php
  10. +1 −2 options/fields/editor/field_editor.php
  11. +2 −2 options/fields/info/field_info.php
  12. +3 −3 options/fields/menu_location_select/field_menu_location_select.php
  13. +3 −3 options/fields/menu_select/field_menu_select.php
  14. +13 −6 options/fields/multi_checkbox/field_multi_checkbox.php
  15. +3 −3 options/fields/multi_select/field_multi_select.php
  16. +23 −5 options/fields/multi_text/field_multi_text.php
  17. +3 −3 options/fields/pages_multi_select/field_pages_multi_select.php
  18. +3 −3 options/fields/pages_select/field_pages_select.php
  19. +3 −3 options/fields/post_type_select/field_post_type_select.php
  20. +3 −5 options/fields/posts_multi_select/field_posts_multi_select.php
  21. +3 −3 options/fields/posts_select/field_posts_select.php
  22. +11 −4 options/fields/radio/field_radio.php
  23. +1 −2 options/fields/radio_img/field_radio_img.php
  24. +5 −5 options/fields/select/field_select.php
  25. +3 −3 options/fields/select_hide_below/field_select_hide_below.php
  26. +3 −5 options/fields/tags_multi_select/field_tags_multi_select.php
  27. +3 −3 options/fields/tags_select/field_tags_select.php
  28. +12 −2 options/fields/text/field_text.php
  29. +3 −3 options/fields/textarea/field_textarea.php
  30. +3 −3 options/fields/upload/field_upload.php
  31. +30 −2 options/options.php
  32. +2 −2 options/validation/date/validation_date.php
View
8 options/fields/button_set/field_button_set.php
@@ -29,17 +29,17 @@ function __construct($field = array(), $value ='', $parent){
function render(){
$class = (isset($this->field['class']))?'class="'.$this->field['class'].'" ':'';
-
- echo '<fieldset class="buttonset">';
+ $attrs = $this->_field_attrs($this->field['attrs']);
+ echo '<fieldset class="buttonset" ' . $attrs . '>';
foreach($this->field['options'] as $k => $v){
- echo '<input type="radio" id="'.$this->field['id'].'_'.array_search($k,array_keys($this->field['options'])).'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" '.$class.' value="'.$k.'" '.checked($this->value, $k, false).'/>';
+ echo '<input type="radio" id="'.$this->field['id'].'_'.array_search($k,array_keys($this->field['options'])).'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" '.$class.' value="'.$k.'" '.checked($this->value, $k, false) . $attrs . '/>';
echo '<label for="'.$this->field['id'].'_'.array_search($k,array_keys($this->field['options'])).'">'.$v.'</label>';
}//foreach
- echo ($this->field['desc'] != '')?'&nbsp;&nbsp;<span class="description">'.$this->field['desc'].'</span>':'';
+ echo (isset($this->field['desc']) && !empty($this->field['desc']))?'&nbsp;&nbsp;<span class="description">'.$this->field['desc'].'</span>':'';
echo '</fieldset>';
View
6 options/fields/cats_multi_select/field_cats_multi_select.php
@@ -29,8 +29,8 @@ function __construct($field = array(), $value ='', $parent){
function render(){
$class = (isset($this->field['class']))?'class="'.$this->field['class'].'" ':'';
-
- echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].'][]" '.$class.'multiple="multiple" >';
+ $attrs = $this->_field_attrs($this->field['attrs']);
+ echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].'][]" '.$class.'multiple="multiple"' . $attrs . '>';
$args = wp_parse_args($this->field['args'], array());
@@ -44,7 +44,7 @@ function render(){
echo '</select>';
- echo ($this->field['desc'] != '')?'<br/><span class="description">'.$this->field['desc'].'</span>':'';
+ echo (isset($this->field['desc']) && !empty($this->field['desc']))?'<br/><span class="description">'.$this->field['desc'].'</span>':'';
}//function
View
5 options/fields/cats_select/field_cats_select.php
@@ -30,7 +30,8 @@ function render(){
$class = (isset($this->field['class']))?'class="'.$this->field['class'].'" ':'';
- echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" '.$class.' >';
+ $attrs = $this->_field_attrs($this->field['attrs']);
+ echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" '.$class . $attrs . '>';
$args = wp_parse_args($this->field['args'], array());
@@ -41,7 +42,7 @@ function render(){
echo '</select>';
- echo ($this->field['desc'] != '')?' <span class="description">'.$this->field['desc'].'</span>':'';
+ echo (isset($this->field['desc']) && !empty($this->field['desc']))?' <span class="description">'.$this->field['desc'].'</span>':'';
}//function
View
14 options/fields/checkbox/field_checkbox.php
@@ -28,13 +28,19 @@ function __construct($field = array(), $value ='', $parent){
*/
function render(){
- $class = (isset($this->field['class']))?$this->field['class']:'';
+ $attrs = array_merge($this->field['attrs'], array(
+ 'class' => (isset($this->field['class'])) ? $this->field['class'] : '',
+ 'id' => $this->field['id'],
+ 'name' => $this->args['opt_name'] . '[' . $this->field['id'] . ']',
+ 'value' => '1'
+ ));
- echo ($this->field['desc'] != '')?' <label for="'.$this->args['opt_name'].'['.$this->field['id'].']">':'';
+ $attrs = $this->_field_attrs($attrs);
- echo '<input type="checkbox" id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" value="1" class="'.$class.'" '.checked($this->value, '1', false).'/>';
+ echo ($this->field['desc'] != '')?' <label for="'.$this->args['opt_name'].'['.$this->field['id'].']">':'';
+ echo '<input type="checkbox"' . $attrs . checked($this->value, '1', false) . '/>';
- echo ($this->field['desc'] != '')?' '.$this->field['desc'].'</label>':'';
+ echo (isset($this->field['desc']) && !empty($this->field['desc']))?' '.$this->field['desc'].'</label>':'';
}//function
View
6 options/fields/checkbox_hide_below/field_checkbox_hide_below.php
@@ -31,10 +31,10 @@ function render(){
$class = (isset($this->field['class']))?$this->field['class']:'';
echo ($this->field['desc'] != '')?' <label for="'.$this->args['opt_name'].'['.$this->field['id'].']">':'';
+ $attrs = $this->_field_attrs($this->field['attrs']);
+ echo '<input type="checkbox" id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" value="1" class="'.$class.' nhp-opts-checkbox-hide-below" '.checked($this->value, '1', false) . $attrs .'/>';
- echo '<input type="checkbox" id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" value="1" class="'.$class.' nhp-opts-checkbox-hide-below" '.checked($this->value, '1', false).' />';
-
- echo ($this->field['desc'] != '')?' '.$this->field['desc'].'</label>':'';
+ echo (isset($this->field['desc']) && !empty($this->field['desc']))?' '.$this->field['desc'].'</label>':'';
}//function
View
6 options/fields/color/field_color.php
@@ -31,11 +31,11 @@ function render(){
$class = (isset($this->field['class']))?$this->field['class']:'';
echo '<div class="farb-popup-wrapper">';
-
- echo '<input type="text" id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" value="'.$this->value.'" class="'.$class.' popup-colorpicker" style="width:70px;"/>';
+ $attrs = $this->_field_attrs($this->field['attrs']);
+ echo '<input type="text" id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" value="'.$this->value.'" class="'.$class.' popup-colorpicker" style="width:70px;"'. $attrs .'/>';
echo '<div class="farb-popup"><div class="farb-popup-inside"><div id="'.$this->field['id'].'picker" class="color-picker"></div></div></div>';
- echo ($this->field['desc'] != '')?' <span class="description">'.$this->field['desc'].'</span>':'';
+ echo (isset($this->field['desc']) && !empty($this->field['desc']))?' <span class="description">'.$this->field['desc'].'</span>':'';
echo '</div>';
View
8 options/fields/color_gradient/field_color_gradient.php
@@ -31,14 +31,14 @@ function render(){
$class = (isset($this->field['class']))?$this->field['class']:'';
echo '<div class="farb-popup-wrapper" id="'.$this->field['id'].'">';
-
- echo __('From:', 'nhp-opts').' <input type="text" id="'.$this->field['id'].'-from" name="'.$this->args['opt_name'].'['.$this->field['id'].'][from]" value="'.$this->value['from'].'" class="'.$class.' popup-colorpicker" style="width:70px;"/>';
+ $attrs = $this->_field_attrs($this->field['attrs']);
+ echo __('From:', 'nhp-opts').' <input type="text" id="'.$this->field['id'].'-from" name="'.$this->args['opt_name'].'['.$this->field['id'].'][from]" value="'.$this->value['from'].'" class="'.$class.' popup-colorpicker" style="width:70px;"' . $attrs . '/>';
echo '<div class="farb-popup"><div class="farb-popup-inside"><div id="'.$this->field['id'].'-frompicker" class="color-picker"></div></div></div>';
- echo __(' To:', 'nhp-opts').' <input type="text" id="'.$this->field['id'].'-to" name="'.$this->args['opt_name'].'['.$this->field['id'].'][to]" value="'.$this->value['to'].'" class="'.$class.' popup-colorpicker" style="width:70px;"/>';
+ echo __(' To:', 'nhp-opts').' <input type="text" id="'.$this->field['id'].'-to" name="'.$this->args['opt_name'].'['.$this->field['id'].'][to]" value="'.$this->value['to'].'" class="'.$class.' popup-colorpicker" style="width:70px;"' . $attrs . '/>';
echo '<div class="farb-popup"><div class="farb-popup-inside"><div id="'.$this->field['id'].'-topicker" class="color-picker"></div></div></div>';
- echo ($this->field['desc'] != '')?' <span class="description">'.$this->field['desc'].'</span>':'';
+ echo (isset($this->field['desc']) && !empty($this->field['desc']))?' <span class="description">'.$this->field['desc'].'</span>':'';
echo '</div>';
View
6 options/fields/date/field_date.php
@@ -29,10 +29,10 @@ function __construct($field = array(), $value ='', $parent){
function render(){
$class = (isset($this->field['class']))?$this->field['class']:'';
+ $attrs = $this->_field_attrs($this->field['attrs']);
+ echo '<input type="text" id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" value="'.$this->value.'" class="'.$class.' nhp-opts-datepicker"' . $attrs . '/>';
- echo '<input type="text" id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" value="'.$this->value.'" class="'.$class.' nhp-opts-datepicker" />';
-
- echo ($this->field['desc'] != '')?' <span class="description">'.$this->field['desc'].'</span>':'';
+ echo (isset($this->field['desc']) && !empty($this->field['desc']))?' <span class="description">'.$this->field['desc'].'</span>':'';
}//function
View
4 options/fields/divide/field_divide.php
@@ -29,8 +29,8 @@ function __construct($field = array(), $value ='', $parent){
function render(){
$class = (isset($this->field['class']))?' '.$this->field['class'].'':'';
-
- echo '</td></tr></table><div class="hr'.$class.'"/></div><table class="form-table no-border"><tbody><tr><th></th><td>';
+ $attrs = $this->_field_attrs($this->field['attrs']);
+ echo '</td></tr></table><div class="hr'.$class.'"' . $attrs . '/></div><table class="form-table no-border"><tbody><tr><th></th><td>';
}//function
View
3 options/fields/editor/field_editor.php
@@ -29,15 +29,14 @@ function __construct($field = array(), $value ='', $parent){
function render(){
$class = (isset($this->field['class']))?$this->field['class']:'';
-
//echo '<textarea id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" class="'.$class.'" rows="6" >'.$this->value.'</textarea>';
$settings = array(
'textarea_name' => $this->args['opt_name'].'['.$this->field['id'].']',
'editor_class' => $class
);
wp_editor($this->value, $this->field['id'], $settings );
- echo ($this->field['desc'] != '')?'<br/><span class="description">'.$this->field['desc'].'</span>':'';
+ echo (isset($this->field['desc']) && !empty($this->field['desc']))?'<br/><span class="description">'.$this->field['desc'].'</span>':'';
}//function
View
4 options/fields/info/field_info.php
@@ -29,8 +29,8 @@ function __construct($field = array(), $value ='', $parent){
function render(){
$class = (isset($this->field['class']))?' '.$this->field['class']:'';
-
- echo '</td></tr></table><div class="nhp-opts-info-field'.$class.'">'.$this->field['desc'].'</div><table class="form-table no-border"><tbody><tr><th></th><td>';
+ $attrs = $this->_field_attrs($this->field['attrs']);
+ echo '</td></tr></table><div class="nhp-opts-info-field'.$class.'"' . $attrs . '>'.$this->field['desc'].'</div><table class="form-table no-border"><tbody><tr><th></th><td>';
}//function
View
6 options/fields/menu_location_select/field_menu_location_select.php
@@ -30,8 +30,8 @@ function render(){
$class = (isset($this->field['class']))?'class="'.$this->field['class'].'" ':'';
global $_wp_registered_nav_menus;
-
- echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" '.$class.' >';
+ $attrs = $this->_field_attrs($this->field['attrs']);
+ echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" '.$class . $attrs .'>';
if($_wp_registered_nav_menus){
foreach ( $_wp_registered_nav_menus as $k => $v ) {
@@ -41,7 +41,7 @@ function render(){
echo '</select>';
- echo ($this->field['desc'] != '')?' <span class="description">'.$this->field['desc'].'</span>':'';
+ echo (isset($this->field['desc']) && !empty($this->field['desc']))?' <span class="description">'.$this->field['desc'].'</span>':'';
}//function
View
6 options/fields/menu_select/field_menu_select.php
@@ -29,8 +29,8 @@ function __construct($field = array(), $value ='', $parent){
function render(){
$class = (isset($this->field['class']))?'class="'.$this->field['class'].'" ':'';
-
- echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" '.$class.' >';
+ $attrs = $this->_field_attrs($this->field['attrs']);
+ echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" '.$class . $attrs .'>';
if(!isset($this->field['args'])){$this->field['args'] = array();}
$args = wp_parse_args($this->field['args'], array());
@@ -44,7 +44,7 @@ function render(){
echo '</select>';
- echo ($this->field['desc'] != '')?' <span class="description">'.$this->field['desc'].'</span>':'';
+ echo (isset($this->field['desc']) && !empty($this->field['desc']))?' <span class="description">'.$this->field['desc'].'</span>':'';
}//function
View
19 options/fields/multi_checkbox/field_multi_checkbox.php
@@ -28,21 +28,28 @@ function __construct($field = array(), $value ='', $parent){
*/
function render(){
- $class = (isset($this->field['class']))?$this->field['class']:'regular-text';
+ $class = (isset($this->field['class'])) ? $this->field['class'] : 'regular-text';
echo '<fieldset>';
-
+
foreach($this->field['options'] as $k => $v){
- $this->value[$k] = (isset($this->value[$k]))?$this->value[$k]:'';
+ $attrs = array_merge($this->field['attrs'], array(
+ 'id' => $this->field['id'] . '_' . array_search($k, array_keys($this->field['options'])),
+ 'name' => $this->args['opt_name'] . '[' . $this->field['id'] . '][' . $k .']',
+ 'class' => $class,
+ 'value' => '1'
+ ));
+
+ $this->value[$k] = (!empty($this->value[$k])) ? $this->value[$k] : '';
- echo '<label for="'.$this->field['id'].'_'.array_search($k,array_keys($this->field['options'])).'">';
- echo '<input type="checkbox" id="'.$this->field['id'].'_'.array_search($k,array_keys($this->field['options'])).'" name="'.$this->args['opt_name'].'['.$this->field['id'].']['.$k.']" '.$class.' value="1" '.checked($this->value[$k], '1', false).'/>';
+ echo '<label for="' . $attrs['id']. '">';
+ echo '<input type="checkbox"' . $attrs . checked($this->value[$k], '1', false) . '/>';
echo ' '.$v.'</label><br/>';
}//foreach
- echo ($this->field['desc'] != '')?'<span class="description">'.$this->field['desc'].'</span>':'';
+ echo (isset($this->field['desc']) && !empty($this->field['desc']))?'<span class="description">'.$this->field['desc'].'</span>':'';
echo '</fieldset>';
View
6 options/fields/multi_select/field_multi_select.php
@@ -29,8 +29,8 @@ function __construct($field = array(), $value ='', $parent){
function render(){
$class = (isset($this->field['class']))?'class="'.$this->field['class'].'" ':'';
-
- echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].'][]" '.$class.'multiple="multiple" rows="6" >';
+ $attrs = $this->_field_attrs($this->field['attrs']);
+ echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].'][]" '.$class.'multiple="multiple" rows="6"' . $attrs . '>';
foreach($this->field['options'] as $k => $v){
@@ -42,7 +42,7 @@ function render(){
echo '</select>';
- echo ($this->field['desc'] != '')?'<br/><span class="description">'.$this->field['desc'].'</span>':'';
+ echo (isset($this->field['desc']) && !empty($this->field['desc']))?'<br/><span class="description">'.$this->field['desc'].'</span>':'';
}//function
View
28 options/fields/multi_text/field_multi_text.php
@@ -29,21 +29,39 @@ function __construct($field = array(), $value ='', $parent){
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>';
+
+ $attrs = array_merge($this->field['attrs'], array(
+ 'id' => $this->field['id'] . '-' . $k,
+ 'name' => $this->args['opt_name'] . '[' . $this->field['id'] . '][]',
+ 'value' => $value,
+ 'class' => $class
+ ));
+
+ $attrs = $this->_field_attrs($attrs);
+
+ echo '<li><input type="text" ' . $attrs . '/> <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>';
+ $attrs = array_merge($this->field['attrs'], array(
+ 'id' => $this->field['id'],
+ 'name' => $this->args['opt_name'] . '[' . $this->field['id'] . '][]',
+ 'value' => $value,
+ 'class' => $class
+ ));
+
+ $attrs = $this->_field_attrs($attrs);
+
+ echo '<li><input type="text"' . $attrs . '/> <a href="javascript:void(0);" class="nhp-opts-multi-text-remove">'.__('Remove', 'nhp-opts').'</a></li>';
}//if
@@ -53,7 +71,7 @@ function render(){
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>':'';
+ echo (isset($this->field['desc']) && !empty($this->field['desc']))?' <span class="description">'.$this->field['desc'].'</span>':'';
}//function
View
6 options/fields/pages_multi_select/field_pages_multi_select.php
@@ -29,8 +29,8 @@ function __construct($field = array(), $value ='', $parent){
function render(){
$class = (isset($this->field['class']))?'class="'.$this->field['class'].'" ':'';
-
- echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].'][]" '.$class.'multiple="multiple" >';
+ $attrs = $this->_field_attrs($this->field['attrs']);
+ echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].'][]" '.$class.'multiple="multiple" ' . $attrs .'>';
$args = wp_parse_args($this->field['args'], array());
@@ -44,7 +44,7 @@ function render(){
echo '</select>';
- echo ($this->field['desc'] != '')?'<br/><span class="description">'.$this->field['desc'].'</span>':'';
+ echo (isset($this->field['desc']) && !empty($this->field['desc']))?'<br/><span class="description">'.$this->field['desc'].'</span>':'';
}//function
View
6 options/fields/pages_select/field_pages_select.php
@@ -29,8 +29,8 @@ function __construct($field = array(), $value ='', $parent){
function render(){
$class = (isset($this->field['class']))?'class="'.$this->field['class'].'" ':'';
-
- echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" '.$class.'rows="6" >';
+ $attrs = $this->_field_attrs($this->field['attrs']);
+ echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" '.$class.'rows="6"' . $attrs .'>';
$args = wp_parse_args($this->field['args'], array());
@@ -41,7 +41,7 @@ function render(){
echo '</select>';
- echo ($this->field['desc'] != '')?' <span class="description">'.$this->field['desc'].'</span>':'';
+ echo (isset($this->field['desc']) && !empty($this->field['desc']))?' <span class="description">'.$this->field['desc'].'</span>':'';
}//function
View
6 options/fields/post_type_select/field_post_type_select.php
@@ -29,8 +29,8 @@ function __construct($field = array(), $value ='', $parent){
function render(){
$class = (isset($this->field['class']))?'class="'.$this->field['class'].'" ':'';
-
- echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" '.$class.' >';
+ $attrs = $this->_field_attrs($this->field['attrs']);
+ echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" '.$class . $attrs .'>';
if(!isset($this->field['args'])){$this->field['args'] = array();}
$args = wp_parse_args($this->field['args'], array('public' => true));
@@ -41,7 +41,7 @@ function render(){
}
echo '</select>';
- echo ($this->field['desc'] != '')?' <span class="description">'.$this->field['desc'].'</span>':'';
+ echo (isset($this->field['desc']) && !empty($this->field['desc']))?' <span class="description">'.$this->field['desc'].'</span>':'';
}//function
View
8 options/fields/posts_multi_select/field_posts_multi_select.php
@@ -29,8 +29,8 @@ function __construct($field = array(), $value ='', $parent){
function render(){
$class = (isset($this->field['class']))?'class="'.$this->field['class'].'" ':'';
-
- echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].'][]" '.$class.'multiple="multiple" >';
+ $attrs = $this->_field_attrs($this->field['attrs']);
+ echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].'][]" '.$class.'multiple="multiple" ' . $attrs .'>';
$args = wp_parse_args($this->field['args'], array('numberposts' => '-1'));
@@ -39,12 +39,10 @@ function render(){
$selected = (is_array($this->value) && in_array($post->ID, $this->value))?' selected="selected"':'';
echo '<option value="'.$post->ID.'"'.$selected.'>'.$post->post_title.'</option>';
}
-
-
echo '</select>';
- echo ($this->field['desc'] != '')?'<br/><span class="description">'.$this->field['desc'].'</span>':'';
+ echo (isset($this->field['desc']) && !empty($this->field['desc']))?'<br/><span class="description">'.$this->field['desc'].'</span>':'';
}//function
View
6 options/fields/posts_select/field_posts_select.php
@@ -29,8 +29,8 @@ function __construct($field = array(), $value ='', $parent){
function render(){
$class = (isset($this->field['class']))?'class="'.$this->field['class'].'" ':'';
-
- echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" '.$class.' >';
+ $attrs = $this->_field_attrs($this->field['attrs']);
+ echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" '.$class . $attrs .'>';
$args = wp_parse_args($this->field['args'], array('numberposts' => '-1'));
@@ -41,7 +41,7 @@ function render(){
echo '</select>';
- echo ($this->field['desc'] != '')?' <span class="description">'.$this->field['desc'].'</span>':'';
+ echo (isset($this->field['desc']) && !empty($this->field['desc']))?' <span class="description">'.$this->field['desc'].'</span>':'';
}//function
View
15 options/fields/radio/field_radio.php
@@ -28,21 +28,28 @@ function __construct($field = array(), $value ='', $parent){
*/
function render(){
- $class = (isset($this->field['class']))?'class="'.$this->field['class'].'" ':'';
+ $class = (isset($this->field['class'])) ? $this->field['class'] : '';
echo '<fieldset>';
foreach($this->field['options'] as $k => $v){
+ $attrs = array_merge($this->field['attrs'], array(
+ 'id' => $this->field['id'] . '_' . array_search($k, array_keys($this->field['options'])),
+ 'name' => $this->args['opt_name'] . '[' . $this->field['id'] . '][' . $k .']',
+ 'class' => $class,
+ 'value' => '1'
+ ));
+
//echo '<option value="'.$k.'" '.selected($this->value, $k, false).'>'.$v.'</option>';
- echo '<label for="'.$this->field['id'].'_'.array_search($k,array_keys($this->field['options'])).'">';
- echo '<input type="radio" id="'.$this->field['id'].'_'.array_search($k,array_keys($this->field['options'])).'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" '.$class.' value="'.$k.'" '.checked($this->value, $k, false).'/>';
+ echo '<label for="' . $attrs['id'] . '">';
+ echo '<input type="radio"' . $attrs . ' ' . checked($this->value, $k, false) . '/>';
echo ' <span>'.$v.'</span>';
echo '</label><br/>';
}//foreach
- echo ($this->field['desc'] != '')?'<span class="description">'.$this->field['desc'].'</span>':'';
+ echo (isset($this->field['desc']) && !empty($this->field['desc']))?'<span class="description">'.$this->field['desc'].'</span>':'';
echo '</fieldset>';
View
3 options/fields/radio_img/field_radio_img.php
@@ -42,10 +42,9 @@ function render(){
echo '<br/><span>'.$v['title'].'</span>';
echo '</label>';
-
}//foreach
- echo ($this->field['desc'] != '')?'<br/><span class="description">'.$this->field['desc'].'</span>':'';
+ echo (isset($this->field['desc']) && !empty($this->field['desc']))?'<br/><span class="description">'.$this->field['desc'].'</span>':'';
echo '</fieldset>';
View
10 options/fields/select/field_select.php
@@ -17,8 +17,8 @@ function __construct($field = array(), $value ='', $parent){
}//function
-
-
+
+
/**
* Field Render Function.
*
@@ -29,8 +29,8 @@ function __construct($field = array(), $value ='', $parent){
function render(){
$class = (isset($this->field['class']))?'class="'.$this->field['class'].'" ':'';
-
- echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" '.$class.'rows="6" >';
+ $attrs = $this->_field_attrs($this->field['attrs']);
+ echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" '.$class.'rows="6"' . $attrs . '>';
foreach($this->field['options'] as $k => $v){
@@ -40,7 +40,7 @@ function render(){
echo '</select>';
- echo ($this->field['desc'] != '')?' <span class="description">'.$this->field['desc'].'</span>':'';
+ echo (isset($this->field['desc']) && !empty($this->field['desc']))?' <span class="description">'.$this->field['desc'].'</span>':'';
}//function
View
6 options/fields/select_hide_below/field_select_hide_below.php
@@ -29,8 +29,8 @@ function __construct($field = array(), $value ='', $parent){
function render(){
$class = (isset($this->field['class']))?$this->field['class']:'';
-
- echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" class="'.$class.' nhp-opts-select-hide-below" >';
+ $attrs = $this->_field_attrs($this->field['attrs']);
+ echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" class="'.$class.' nhp-opts-select-hide-below"' . $attrs . '>';
foreach($this->field['options'] as $k => $v){
@@ -40,7 +40,7 @@ function render(){
echo '</select>';
- echo ($this->field['desc'] != '')?' <span class="description">'.$this->field['desc'].'</span>':'';
+ echo (isset($this->field['desc']) && !empty($this->field['desc']))?' <span class="description">'.$this->field['desc'].'</span>':'';
}//function
View
8 options/fields/tags_multi_select/field_tags_multi_select.php
@@ -29,8 +29,8 @@ function __construct($field = array(), $value ='', $parent){
function render(){
$class = (isset($this->field['class']))?'class="'.$this->field['class'].'" ':'';
-
- echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].'][]" '.$class.'multiple="multiple" >';
+ $attrs = $this->_field_attrs($this->field['attrs']);
+ echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].'][]" '.$class.'multiple="multiple" ' . $attrs .'>';
$args = wp_parse_args($this->field['args'], array());
@@ -39,12 +39,10 @@ function render(){
$selected = (is_array($this->value) && in_array($tag->term_id, $this->value))?' selected="selected"':'';
echo '<option value="'.$tag->term_id.'"'.$selected.'>'.$tag->name.'</option>';
}
-
-
echo '</select>';
- echo ($this->field['desc'] != '')?'<br/><span class="description">'.$this->field['desc'].'</span>':'';
+ echo (isset($this->field['desc']) && !empty($this->field['desc']))?'<br/><span class="description">'.$this->field['desc'].'</span>':'';
}//function
View
6 options/fields/tags_select/field_tags_select.php
@@ -29,8 +29,8 @@ function __construct($field = array(), $value ='', $parent){
function render(){
$class = (isset($this->field['class']))?'class="'.$this->field['class'].'" ':'';
-
- echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" '.$class.' >';
+ $attrs = $this->_field_attrs($this->field['attrs']);
+ echo '<select id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" '.$class . $attrs .'>';
$args = wp_parse_args($this->field['args'], array());
@@ -41,7 +41,7 @@ function render(){
echo '</select>';
- echo ($this->field['desc'] != '')?' <span class="description">'.$this->field['desc'].'</span>':'';
+ echo (isset($this->field['desc']) && !empty($this->field['desc']))?' <span class="description">'.$this->field['desc'].'</span>':'';
}//function
View
14 options/fields/text/field_text.php
@@ -30,9 +30,19 @@ function render(){
$class = (isset($this->field['class']))?$this->field['class']:'regular-text';
- echo '<input type="text" id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" value="'.esc_attr($this->value).'" class="'.$class.'" />';
- echo ($this->field['desc'] != '')?' <span class="description">'.$this->field['desc'].'</span>':'';
+ $attrs = array_merge($this->field['attrs'], array(
+ 'id' => $this->field['id'],
+ 'name' => $this->args['opt_name'] .'[' . $this->field['id'] . ']',
+ 'value' => $this->value,
+ 'class' => $class
+ ));
+
+ $attrs = $this->_field_attrs($attrs);
+
+ echo '<input type="text"' . $attrs . '/>';
+
+ echo (isset($this->field['desc']) && !empty($this->field['desc']))?' <span class="description">'.$this->field['desc'].'</span>':'';
}//function
View
6 options/fields/textarea/field_textarea.php
@@ -29,10 +29,10 @@ function __construct($field = array(), $value ='', $parent){
function render(){
$class = (isset($this->field['class']))?$this->field['class']:'large-text';
+ $attrs = $this->_field_attrs($this->field['attrs']);
+ echo '<textarea id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" class="'.$class.'" rows="6"' . $attrs . '>'.esc_attr($this->value).'</textarea>';
- echo '<textarea id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" class="'.$class.'" rows="6" >'.esc_attr($this->value).'</textarea>';
-
- echo ($this->field['desc'] != '')?'<br/><span class="description">'.$this->field['desc'].'</span>':'';
+ echo (isset($this->field['desc']) && !empty($this->field['desc']))?'<br/><span class="description">'.$this->field['desc'].'</span>':'';
}//function
View
6 options/fields/upload/field_upload.php
@@ -29,8 +29,8 @@ function render(){
$class = (isset($this->field['class']))?$this->field['class']:'regular-text';
-
- echo '<input type="hidden" id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" value="'.$this->value.'" class="'.$class.'" />';
+ $attrs = $this->_field_attrs($this->field['attrs']);
+ echo '<input type="hidden" id="'.$this->field['id'].'" name="'.$this->args['opt_name'].'['.$this->field['id'].']" value="'.$this->value.'" class="'.$class.'"' . $attrs . '/>';
//if($this->value != ''){
echo '<img class="nhp-opts-screenshot" id="nhp-opts-screenshot-'.$this->field['id'].'" src="'.$this->value.'" />';
//}
@@ -39,7 +39,7 @@ function render(){
echo ' <a href="javascript:void(0);" class="nhp-opts-upload button-secondary"'.$upload.' rel-id="'.$this->field['id'].'">'.__('Browse', 'nhp-opts').'</a>';
echo ' <a href="javascript:void(0);" class="nhp-opts-upload-remove"'.$remove.' rel-id="'.$this->field['id'].'">'.__('Remove Upload', 'nhp-opts').'</a>';
- echo ($this->field['desc'] != '')?'<br/><br/><span class="description">'.$this->field['desc'].'</span>':'';
+ echo (isset($this->field['desc']) && !empty($this->field['desc']))?'<br/><br/><span class="description">'.$this->field['desc'].'</span>':'';
}//function
View
32 options/options.php
@@ -23,7 +23,13 @@ class NHP_Options{
public $errors = array();
public $warnings = array();
public $options = array();
-
+ public $field_defaults = array(
+ 'id' => null,
+ 'type' => null,
+ 'desc' => '',
+ 'class' => '',
+ 'attrs' => array()
+ );
/**
@@ -830,7 +836,9 @@ function _section_desc($section){
$id = rtrim($section['id'], '_section');
- echo '<div class="nhp-opts-section-desc">'.$this->sections[$id]['desc'].'</div>';
+ if(isset($this->sections[$id]['desc']) && !empty($this->sections[$id]['desc'])) {
+ echo '<div class="nhp-opts-section-desc">'.$this->sections[$id]['desc'].'</div>';
+ }
}//function
@@ -867,6 +875,10 @@ function _field_input($field){
if(class_exists($field_class)){
$value = (isset($this->options[$field['id']]))?$this->options[$field['id']]:'';
+
+ // merge the incoming field config with the default values
+ $field += $this->field_defaults;
+
do_action('nhp-opts-before-field', $field, $value);
do_action('nhp-opts-before-field-'.$this->args['opt_name'], $field, $value);
$render = '';
@@ -880,6 +892,22 @@ function _field_input($field){
}//function
+ /**
+ * flatten attributes in to a string for use in elements
+ */
+ function _field_attrs(array $attrs = array()) {
+
+ if (empty($attrs)) {
+ return;
+ }
+
+ $attr_pieces = array();
+ foreach($attrs as $attr => $value) {
+ $attr_pieces[] = sprintf('%s="%s"', $attr, esc_attr($value));
+ }
+
+ return " " . implode(" ", $attr_pieces);
+ }
}//class
}//if
View
4 options/validation/date/validation_date.php
@@ -38,13 +38,13 @@ function validate(){
return;
}
- if($this->value[3] != '/'){
+ if($this->value[2] != '/'){
$this->value = (isset($this->current))?$this->current:'';
$this->error = $this->field;
return;
}
- if($this->value[6] != '/'){
+ if($this->value[5] != '/'){
$this->value = (isset($this->current))?$this->current:'';
$this->error = $this->field;
}

No commit comments for this range

Something went wrong with that request. Please try again.