Title: [Plugin: OptionTree] Feature request &#8211; subheader / value/unit-selector
Last modified: August 19, 2016

---

# [Plugin: OptionTree] Feature request – subheader / value/unit-selector

 *  Resolved [youngmicroserf](https://wordpress.org/support/users/youngmicroserf/)
 * (@youngmicroserf)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/plugin-optiontree-feature-request-subheader-valueunit-selector/)
 * Hey,
 * love the plugin. One thing I’m missing the ability to group values under a subheader,
   and another one is the ability to have a combination of “amount” and “unit” (
   say: 10 (input) px (select)) in the same line for the the same item, which is
   very useful for allowing CSS modifications like border width and the like.
 * I may try to extend the plugin myself, but I thought I’d mention this here as
   well.
 * Thanks again!
 * [http://wordpress.org/extend/plugins/option-tree/](http://wordpress.org/extend/plugins/option-tree/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [youngmicroserf](https://wordpress.org/support/users/youngmicroserf/)
 * (@youngmicroserf)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/plugin-optiontree-feature-request-subheader-valueunit-selector/#post-1871552)
 * Hey, if anyone is interested, I made a couple of changes to the code to get a
   value-unit datatype – that is turning a value-unit pair into an array when being
   saved into the options table and adding a form element to display and change 
   the value-unit pair. Maybe there’s a better way to do it, but it works for me…
 * a) new form element ‘valueunit’ as new file ‘valueunit.php’ in [plugin_root]/
   functions/admin/
 * This file is displaying a simple combined element of input and select box. The
   two elements are then saved as variables with the valueunit-key and the respective
   suffix “_value” and “_unit”.
 *     ```
       <?php if (!defined('OT_VERSION')) exit('No direct script access allowed');
       /**
        * Input Option
        *
       **/
   
       function option_tree_valueunit( $value, $settings, $int )
       {
       ?>
         <div class="option option-valueunit">
           <h3><?php echo htmlspecialchars_decode( $value->item_title ); ?></h3>
           <div class="section">
             <div class="element">
               <input type="text" name="<?php echo $value->item_id; ?>_value" id="<?php echo $value->item_id; ?>_value" value="<?php if ( isset($settings[$value->item_id]) ) { echo htmlspecialchars( stripslashes( $settings[$value->item_id[0]] ), ENT_QUOTES); } ?>" />
   
                <div class="select_wrapper">
                   <select name="<?php echo $value->item_id; ?>_unit" class="select unit">
                       <?php
                       echo '<option value="">-- Choose One --</option>';
                   	$units = array(
                           'px' => 'px',
                           '%'  => '%',
                           'em' => 'em',
                           'pt' => 'pt'
       		);
   
       		foreach ( $units as $unit )
                       {
                   	    $selected = '';
         	            if ( $settings[$value->item_id[1]] == trim( $unit ) )
         	                 { $selected = ' selected="selected"'; }
   
       		          echo '<option'.$selected.'>'.trim( $unit ).'</option>';
              			} 
   
       		?>
                 </select>
               </div>
   
       	  </div>
             <div class="description">
               <?php echo htmlspecialchars_decode( $value->item_desc ); ?>
             </div>
           </div>
         </div>
       <?php
       }
       ```
   
 * b) changes made to [plugin_root]/functions/functions_load.php ->
    include the
   new form part. This is to load the new form part in the options panel.
 * `include( 'admin/valueunit.php' );`
 * at the appropriate position.
 * c) changes made to [plugin_root]/admin/settings.php ->
    display the new option-
   type in the select box in the settings form. Added a new array element in the
   types-array after ca. line 113.
 * `'valueunit' => 'ValueUnit',`
 * d) changes made to [plugin_root]/classes/class.admin.php -> function option_tree_array_save.
   Added an else-if condition checking for the new option type “valueunit” and then
   taking the value-unit pair sent and write it into an array using the single original
   key after ca. line 491.
 *     ```
       else if ($value->item_type == "valueunit" ) {
             	$key = trim( $value->item_id );
               $tempkeys = array('_value', '_unit');
   
               foreach ($tempkeys as $tempkey) {
       			$value[]=$_REQUEST[$key.$tempkey];
       		}	
   
       		$new_settings[$key] = $value
             	}
       ```
   
 *  Plugin Author [Derek Herman](https://wordpress.org/support/users/valendesigns/)
 * (@valendesigns)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-optiontree-feature-request-subheader-valueunit-selector/#post-1871576)
 * Looks promising, I’ll look over the code now and include it in the new update
   today if everything is working correctly. Thanks for your contribution.
 *  Plugin Author [Derek Herman](https://wordpress.org/support/users/valendesigns/)
 * (@valendesigns)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-optiontree-feature-request-subheader-valueunit-selector/#post-1871577)
 * It’s been added and the code was updated slightly. I’ll push it to the live server
   later today with the other updates.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘[Plugin: OptionTree] Feature request – subheader / value/unit-selector’
is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/option-tree_363534.svg)
 * [OptionTree](https://wordpress.org/plugins/option-tree/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/option-tree/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/option-tree/)
 * [Active Topics](https://wordpress.org/support/plugin/option-tree/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/option-tree/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/option-tree/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Derek Herman](https://wordpress.org/support/users/valendesigns/)
 * Last activity: [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-optiontree-feature-request-subheader-valueunit-selector/#post-1871577)
 * Status: resolved