function woothemes_machine($options)
 {
     $counter = 0;
     $menu = '';
     $output = '';
     // Create an array of menu items - multi-dimensional, to accommodate sub-headings.
     $menu_items = array();
     $headings = array();
     foreach ($options as $k => $v) {
         if ($v['type'] == 'heading' || $v['type'] == 'subheading') {
             $headings[] = $v;
         }
     }
     $prev_heading_key = 0;
     foreach ($headings as $k => $v) {
         $token = 'woo-option-' . preg_replace('/[^a-zA-Z0-9\\s]/', '', strtolower(trim(str_replace(' ', '', $v['name']))));
         // Capture the token.
         $v['token'] = $token;
         if ($v['type'] == 'heading') {
             $menu_items[$token] = $v;
             $prev_heading_key = $token;
         }
         if ($v['type'] == 'subheading') {
             $menu_items[$prev_heading_key]['children'][] = $v;
         }
     }
     // Loop through the options.
     foreach ($options as $k => $value) {
         $counter++;
         $val = '';
         //Start Heading
         if ($value['type'] != 'heading' && $value['type'] != 'subheading') {
             $class = '';
             if (isset($value['class'])) {
                 $class = ' ' . $value['class'];
             }
             $output .= '<div class="section section-' . $value['type'] . $class . '">' . "\n";
             $output .= '<h3 class="heading">' . $value['name'] . '</h3>' . "\n";
             $output .= '<div class="option">' . "\n" . '<div class="controls">' . "\n";
         }
         //End Heading
         $select_value = '';
         switch ($value['type']) {
             case 'text':
                 $val = $value['std'];
                 $std = get_option($value['id']);
                 if ($std != "") {
                     $val = $std;
                 }
                 $val = stripslashes($val);
                 // Strip out unwanted slashes.
                 $output .= '<input class="woo-input" name="' . $value['id'] . '" id="' . $value['id'] . '" type="' . $value['type'] . '" value="' . esc_attr($val) . '" />';
                 break;
             case 'select':
                 $output .= '<div class="select_wrapper"><select class="woo-input" name="' . $value['id'] . '" id="' . $value['id'] . '">';
                 $select_value = stripslashes(get_option($value['id']));
                 foreach ($value['options'] as $option) {
                     $selected = '';
                     if ($select_value != '') {
                         if ($select_value == $option) {
                             $selected = ' selected="selected"';
                         }
                     } else {
                         if (isset($value['std'])) {
                             if ($value['std'] == $option) {
                                 $selected = ' selected="selected"';
                             }
                         }
                     }
                     $output .= '<option' . $selected . '>';
                     $output .= $option;
                     $output .= '</option>';
                 }
                 $output .= '</select></div>';
                 break;
             case 'select2':
                 $output .= '<div class="select_wrapper">' . "\n";
                 if (is_array($value['options'])) {
                     $output .= '<select class="woo-input" name="' . $value['id'] . '" id="' . $value['id'] . '">';
                     $select_value = stripslashes(get_option($value['id']));
                     foreach ($value['options'] as $option => $name) {
                         $selected = '';
                         if ($select_value != '') {
                             if ($select_value == $option) {
                                 $selected = ' selected="selected"';
                             }
                         } else {
                             if (isset($value['std'])) {
                                 if ($value['std'] == $option) {
                                     $selected = ' selected="selected"';
                                 }
                             }
                         }
                         $output .= '<option' . $selected . ' value="' . esc_attr($option) . '">';
                         $output .= $name;
                         $output .= '</option>';
                     }
                     $output .= '</select>' . "\n";
                 }
                 $output .= '</div>';
                 break;
             case 'calendar':
                 $val = $value['std'];
                 $std = get_option($value['id']);
                 if ($std != "") {
                     $val = $std;
                 }
                 $output .= '<input class="woo-input-calendar" type="text" name="' . $value['id'] . '" id="' . $value['id'] . '" value="' . esc_attr($val) . '">';
                 $output .= '<input type="hidden" name="datepicker-image" value="' . get_template_directory_uri() . '/functions/images/calendar.gif" />';
                 break;
             case 'time':
                 $val = $value['std'];
                 $std = get_option($value['id']);
                 if ($std != "") {
                     $val = $std;
                 }
                 $output .= '<input class="woo-input-time" name="' . $value['id'] . '" id="' . $value['id'] . '" type="text" value="' . esc_attr($val) . '" />';
                 break;
             case 'textarea':
                 $cols = '8';
                 $ta_value = '';
                 if (isset($value['std'])) {
                     $ta_value = $value['std'];
                     if (isset($value['options'])) {
                         $ta_options = $value['options'];
                         if (isset($ta_options['cols'])) {
                             $cols = $ta_options['cols'];
                         } else {
                             $cols = '8';
                         }
                     }
                 }
                 $std = get_option($value['id']);
                 if ($std != "") {
                     $ta_value = stripslashes($std);
                 }
                 $output .= '<textarea ' . (!current_user_can('unfiltered_html') && in_array($value['id'], woo_disabled_if_not_unfiltered_html_option_keys()) ? 'disabled="disabled" ' : '') . 'class="woo-input" name="' . $value['id'] . '" id="' . $value['id'] . '" cols="' . $cols . '" rows="8">' . esc_textarea($ta_value) . '</textarea>';
                 break;
             case "radio":
                 $select_value = get_option($value['id']);
                 if (is_array($value['options'])) {
                     foreach ($value['options'] as $key => $option) {
                         $checked = '';
                         if ($select_value != '') {
                             if ($select_value == $key) {
                                 $checked = ' checked';
                             }
                         } else {
                             if ($value['std'] == $key) {
                                 $checked = ' checked';
                             }
                         }
                         $output .= '<div class="radio-wrapper"><input class="woo-input woo-radio" type="radio" name="' . $value['id'] . '" value="' . esc_attr($key) . '" ' . $checked . ' /><label>' . $option . '</label></div>';
                     }
                 }
                 break;
             case "checkbox":
                 $std = $value['std'];
                 $saved_std = get_option($value['id']);
                 $checked = '';
                 if (!empty($saved_std)) {
                     if ($saved_std == 'true') {
                         $checked = 'checked="checked"';
                     } else {
                         $checked = '';
                     }
                 } elseif ($std == 'true') {
                     $checked = 'checked="checked"';
                 } else {
                     $checked = '';
                 }
                 $output .= '<input type="checkbox" class="checkbox woo-input" name="' . $value['id'] . '" id="' . $value['id'] . '" value="true" ' . $checked . ' />';
                 break;
             case "multicheck":
                 $std = $value['std'];
                 if (is_array($value['options'])) {
                     foreach ($value['options'] as $key => $option) {
                         $woo_key = $value['id'] . '_' . $key;
                         $saved_std = get_option($woo_key);
                         if (!empty($saved_std)) {
                             if ($saved_std == 'true') {
                                 $checked = 'checked="checked"';
                             } else {
                                 $checked = '';
                             }
                         } elseif ($std == $key) {
                             $checked = 'checked="checked"';
                         } else {
                             $checked = '';
                         }
                         $output .= '<input type="checkbox" class="checkbox woo-input" name="' . $woo_key . '" id="' . $woo_key . '" value="true" ' . $checked . ' /><label for="' . $woo_key . '">' . $option . '</label><br />';
                     }
                 }
                 break;
             case "multicheck2":
                 $std = explode(',', $value['std']);
                 if (is_array($value['options'])) {
                     foreach ($value['options'] as $key => $option) {
                         $woo_key = $value['id'] . '_' . $key;
                         $saved_std = get_option($woo_key);
                         if (!empty($saved_std)) {
                             if ($saved_std == 'true') {
                                 $checked = 'checked="checked"';
                             } else {
                                 $checked = '';
                             }
                         } elseif (in_array($key, $std)) {
                             $checked = 'checked="checked"';
                         } else {
                             $checked = '';
                         }
                         $output .= '<input type="checkbox" class="checkbox woo-input" name="' . $woo_key . '" id="' . $woo_key . '" value="true" ' . $checked . ' /><label for="' . $woo_key . '">' . $option . '</label><br />';
                     }
                 }
                 break;
             case "upload":
                 $output .= woothemes_medialibrary_uploader($value['id'], $value['std'], null);
                 // New AJAX Uploader using Media Library
                 break;
             case "upload_min":
                 $output .= woothemes_medialibrary_uploader($value['id'], $value['std'], 'min');
                 // New AJAX Uploader using Media Library
                 break;
             case "color":
                 $val = $value['std'];
                 $stored = get_option($value['id']);
                 if ($stored != "") {
                     $val = $stored;
                 }
                 $output .= '<div id="' . $value['id'] . '_picker" class="colorSelector"><div></div></div>';
                 $output .= '<input class="woo-color" name="' . $value['id'] . '" id="' . $value['id'] . '" type="text" value="' . esc_attr($val) . '" />';
                 break;
             case "typography":
                 $default = $value['std'];
                 $typography_stored = get_option($value['id']);
                 if (!is_array($typography_stored) || empty($typography_stored)) {
                     $typography_stored = $default;
                 }
                 /* Font Size */
                 $val = $default['size'];
                 if ($typography_stored['size'] != '') {
                     $val = $typography_stored['size'];
                 }
                 if ($typography_stored['unit'] == 'px') {
                     $show_px = '';
                     $show_em = ' style="display:none" ';
                     $name_px = ' name="' . $value['id'] . '_size" ';
                     $name_em = '';
                 } else {
                     if ($typography_stored['unit'] == 'em') {
                         $show_em = '';
                         $show_px = 'style="display:none"';
                         $name_em = ' name="' . $value['id'] . '_size" ';
                         $name_px = '';
                     } else {
                         $show_px = '';
                         $show_em = ' style="display:none" ';
                         $name_px = ' name="' . $value['id'] . '_size" ';
                         $name_em = '';
                     }
                 }
                 $output .= '<select class="woo-typography woo-typography-size woo-typography-size-px"  id="' . $value['id'] . '_size_px" ' . $name_px . $show_px . '>';
                 for ($i = 9; $i < 71; $i++) {
                     if ($val == strval($i)) {
                         $active = 'selected="selected"';
                     } else {
                         $active = '';
                     }
                     $output .= '<option value="' . $i . '" ' . $active . '>' . $i . '</option>';
                 }
                 $output .= '</select>';
                 $output .= '<select class="woo-typography woo-typography-size woo-typography-size-em" id="' . $value['id'] . '_size_em" ' . $name_em . $show_em . '>';
                 $em = 0.5;
                 for ($i = 0; $i < 39; $i++) {
                     if ($i <= 24) {
                         // up to 2.0em in 0.1 increments
                         $em = $em + 0.1;
                     } elseif ($i >= 14 && $i <= 24) {
                         // Above 2.0em to 3.0em in 0.2 increments
                         $em = $em + 0.2;
                     } elseif ($i >= 24) {
                         // Above 3.0em in 0.5 increments
                         $em = $em + 0.5;
                     }
                     if ($val == strval($em)) {
                         $active = 'selected="selected"';
                     } else {
                         $active = '';
                     }
                     //echo ' '. $value['id'] .' val:'.floatval($val). ' -> ' . floatval($em) . ' $<br />' ;
                     $output .= '<option value="' . $em . '" ' . $active . '>' . $em . '</option>';
                 }
                 $output .= '</select>';
                 /* Font Unit */
                 $val = $default['unit'];
                 if ($typography_stored['unit'] != '') {
                     $val = $typography_stored['unit'];
                 }
                 $em = '';
                 $px = '';
                 if ($val == 'em') {
                     $em = 'selected="selected"';
                 }
                 if ($val == 'px') {
                     $px = 'selected="selected"';
                 }
                 $output .= '<select class="woo-typography woo-typography-unit" name="' . $value['id'] . '_unit" id="' . $value['id'] . '_unit">';
                 $output .= '<option value="px" ' . $px . '">px</option>';
                 $output .= '<option value="em" ' . $em . '>em</option>';
                 $output .= '</select>';
                 /* Font Face */
                 $val = $default['face'];
                 if ($typography_stored['face'] != "") {
                     $val = $typography_stored['face'];
                 }
                 $font01 = '';
                 $font02 = '';
                 $font03 = '';
                 $font04 = '';
                 $font05 = '';
                 $font06 = '';
                 $font07 = '';
                 $font08 = '';
                 $font09 = '';
                 $font10 = '';
                 $font11 = '';
                 $font12 = '';
                 $font13 = '';
                 $font14 = '';
                 $font15 = '';
                 $font16 = '';
                 $font17 = '';
                 if (strpos($val, 'Arial, sans-serif') !== false) {
                     $font01 = 'selected="selected"';
                 }
                 if (strpos($val, 'Verdana, Geneva') !== false) {
                     $font02 = 'selected="selected"';
                 }
                 if (strpos($val, 'Trebuchet') !== false) {
                     $font03 = 'selected="selected"';
                 }
                 if (strpos($val, 'Georgia') !== false) {
                     $font04 = 'selected="selected"';
                 }
                 if (strpos($val, 'Times New Roman') !== false) {
                     $font05 = 'selected="selected"';
                 }
                 if (strpos($val, 'Tahoma, Geneva') !== false) {
                     $font06 = 'selected="selected"';
                 }
                 if (strpos($val, 'Palatino') !== false) {
                     $font07 = 'selected="selected"';
                 }
                 if (strpos($val, 'Helvetica') !== false) {
                     $font08 = 'selected="selected"';
                 }
                 if (strpos($val, 'Calibri') !== false) {
                     $font09 = 'selected="selected"';
                 }
                 if (strpos($val, 'Myriad') !== false) {
                     $font10 = 'selected="selected"';
                 }
                 if (strpos($val, 'Lucida') !== false) {
                     $font11 = 'selected="selected"';
                 }
                 if (strpos($val, 'Arial Black') !== false) {
                     $font12 = 'selected="selected"';
                 }
                 if (strpos($val, 'Gill') !== false) {
                     $font13 = 'selected="selected"';
                 }
                 if (strpos($val, 'Geneva, Tahoma') !== false) {
                     $font14 = 'selected="selected"';
                 }
                 if (strpos($val, 'Impact') !== false) {
                     $font15 = 'selected="selected"';
                 }
                 if (strpos($val, 'Courier') !== false) {
                     $font16 = 'selected="selected"';
                 }
                 if (strpos($val, 'Century Gothic') !== false) {
                     $font17 = 'selected="selected"';
                 }
                 $output .= '<select class="woo-typography woo-typography-face" name="' . $value['id'] . '_face" id="' . $value['id'] . '_face">';
                 $output .= '<option value="Arial, sans-serif" ' . $font01 . '>Arial</option>';
                 $output .= '<option value="Verdana, Geneva, sans-serif" ' . $font02 . '>Verdana</option>';
                 $output .= '<option value="&quot;Trebuchet MS&quot;, Tahoma, sans-serif"' . $font03 . '>Trebuchet</option>';
                 $output .= '<option value="Georgia, serif" ' . $font04 . '>Georgia</option>';
                 $output .= '<option value="&quot;Times New Roman&quot;, serif"' . $font05 . '>Times New Roman</option>';
                 $output .= '<option value="Tahoma, Geneva, Verdana, sans-serif"' . $font06 . '>Tahoma</option>';
                 $output .= '<option value="Palatino, &quot;Palatino Linotype&quot;, serif"' . $font07 . '>Palatino</option>';
                 $output .= '<option value="&quot;Helvetica Neue&quot;, Helvetica, sans-serif" ' . $font08 . '>Helvetica*</option>';
                 $output .= '<option value="Calibri, Candara, Segoe, Optima, sans-serif"' . $font09 . '>Calibri*</option>';
                 $output .= '<option value="&quot;Myriad Pro&quot;, Myriad, sans-serif"' . $font10 . '>Myriad Pro*</option>';
                 $output .= '<option value="&quot;Lucida Grande&quot;, &quot;Lucida Sans Unicode&quot;, &quot;Lucida Sans&quot;, sans-serif"' . $font11 . '>Lucida</option>';
                 $output .= '<option value="&quot;Arial Black&quot;, sans-serif" ' . $font12 . '>Arial Black</option>';
                 $output .= '<option value="&quot;Gill Sans&quot;, &quot;Gill Sans MT&quot;, Calibri, sans-serif" ' . $font13 . '>Gill Sans*</option>';
                 $output .= '<option value="Geneva, Tahoma, Verdana, sans-serif" ' . $font14 . '>Geneva*</option>';
                 $output .= '<option value="Impact, Charcoal, sans-serif" ' . $font15 . '>Impact</option>';
                 $output .= '<option value="Courier, &quot;Courier New&quot;, monospace" ' . $font16 . '>Courier</option>';
                 $output .= '<option value="&quot;Century Gothic&quot;, sans-serif" ' . $font17 . '>Century Gothic</option>';
                 // Google webfonts
                 global $google_fonts;
                 sort($google_fonts);
                 $output .= '<option value="">-- Google Fonts --</option>';
                 foreach ($google_fonts as $key => $gfont) {
                     $font[$key] = '';
                     if ($val == $gfont['name']) {
                         $font[$key] = 'selected="selected"';
                     }
                     $name = $gfont['name'];
                     $output .= '<option value="' . $name . '" ' . $font[$key] . '>' . $name . '</option>';
                 }
                 // Custom Font stack
                 $new_stacks = get_option('framework_woo_font_stack');
                 if (!empty($new_stacks)) {
                     $output .= '<option value="">-- Custom Font Stacks --</option>';
                     foreach ($new_stacks as $name => $stack) {
                         if (strpos($val, $stack) !== false) {
                             $fontstack = 'selected="selected"';
                         } else {
                             $fontstack = '';
                         }
                         $output .= '<option value="' . stripslashes(htmlentities($stack)) . '" ' . $fontstack . '>' . str_replace('_', ' ', $name) . '</option>';
                     }
                 }
                 $output .= '</select>';
                 /* Font Weight */
                 $val = $default['style'];
                 if ($typography_stored['style'] != "") {
                     $val = $typography_stored['style'];
                 }
                 $normal = '';
                 $italic = '';
                 $bold = '';
                 $bolditalic = '';
                 if ($val == 'normal') {
                     $normal = 'selected="selected"';
                 }
                 if ($val == 'italic') {
                     $italic = 'selected="selected"';
                 }
                 if ($val == 'bold') {
                     $bold = 'selected="selected"';
                 }
                 if ($val == 'bold italic') {
                     $bolditalic = 'selected="selected"';
                 }
                 $output .= '<select class="woo-typography woo-typography-style" name="' . $value['id'] . '_style" id="' . $value['id'] . '_style">';
                 $output .= '<option value="normal" ' . $normal . '>Normal</option>';
                 $output .= '<option value="italic" ' . $italic . '>Italic</option>';
                 $output .= '<option value="bold" ' . $bold . '>Bold</option>';
                 $output .= '<option value="bold italic" ' . $bolditalic . '>Bold/Italic</option>';
                 $output .= '</select>';
                 /* Font Color */
                 $val = $default['color'];
                 if ($typography_stored['color'] != "") {
                     $val = $typography_stored['color'];
                 }
                 $output .= '<div id="' . $value['id'] . '_color_picker" class="colorSelector"><div></div></div>';
                 $output .= '<input class="woo-color woo-typography woo-typography-color" name="' . $value['id'] . '_color" id="' . $value['id'] . '_color" type="text" value="' . esc_attr($val) . '" />';
                 break;
             case "border":
                 $default = $value['std'];
                 $border_stored = get_option($value['id']);
                 /* Border Width */
                 $val = $default['width'];
                 if ($border_stored['width'] != "") {
                     $val = $border_stored['width'];
                 }
                 $output .= '<select class="woo-border woo-border-width" name="' . $value['id'] . '_width" id="' . $value['id'] . '_width">';
                 for ($i = 0; $i < 21; $i++) {
                     if ($val == $i) {
                         $active = 'selected="selected"';
                     } else {
                         $active = '';
                     }
                     $output .= '<option value="' . $i . '" ' . $active . '>' . $i . 'px</option>';
                 }
                 $output .= '</select>';
                 /* Border Style */
                 $val = $default['style'];
                 if ($border_stored['style'] != "") {
                     $val = $border_stored['style'];
                 }
                 $solid = '';
                 $dashed = '';
                 $dotted = '';
                 if ($val == 'solid') {
                     $solid = 'selected="selected"';
                 }
                 if ($val == 'dashed') {
                     $dashed = 'selected="selected"';
                 }
                 if ($val == 'dotted') {
                     $dotted = 'selected="selected"';
                 }
                 $output .= '<select class="woo-border woo-border-style" name="' . $value['id'] . '_style" id="' . $value['id'] . '_style">';
                 $output .= '<option value="solid" ' . $solid . '>Solid</option>';
                 $output .= '<option value="dashed" ' . $dashed . '>Dashed</option>';
                 $output .= '<option value="dotted" ' . $dotted . '>Dotted</option>';
                 $output .= '</select>';
                 /* Border Color */
                 $val = $default['color'];
                 if ($border_stored['color'] != "") {
                     $val = $border_stored['color'];
                 }
                 $output .= '<div id="' . $value['id'] . '_color_picker" class="colorSelector"><div></div></div>';
                 $output .= '<input class="woo-color woo-border woo-border-color" name="' . $value['id'] . '_color" id="' . $value['id'] . '_color" type="text" value="' . esc_attr($val) . '" />';
                 break;
             case "images":
                 $i = 0;
                 $select_value = get_option($value['id']);
                 foreach ($value['options'] as $key => $option) {
                     $i++;
                     $checked = '';
                     $selected = '';
                     if ($select_value != '') {
                         if ($select_value == $key) {
                             $checked = ' checked';
                             $selected = 'woo-radio-img-selected';
                         }
                     } else {
                         if ($value['std'] == $key) {
                             $checked = ' checked';
                             $selected = 'woo-radio-img-selected';
                         } elseif ($i == 1 && !isset($select_value)) {
                             $checked = ' checked';
                             $selected = 'woo-radio-img-selected';
                         } elseif ($i == 1 && $value['std'] == '') {
                             $checked = ' checked';
                             $selected = 'woo-radio-img-selected';
                         } else {
                             $checked = '';
                         }
                     }
                     $output .= '<span>';
                     $output .= '<input type="radio" id="woo-radio-img-' . $value['id'] . $i . '" class="checkbox woo-radio-img-radio" value="' . esc_attr($key) . '" name="' . $value['id'] . '" ' . $checked . ' />';
                     $output .= '<span class="woo-radio-img-label">' . esc_html($key) . '</span>';
                     $output .= '<img src="' . $option . '" alt="" class="woo-radio-img-img ' . $selected . '" onClick="document.getElementById(\'woo-radio-img-' . $value['id'] . $i . '\').checked = true;" />';
                     $output .= '</span>';
                 }
                 break;
             case "info":
                 $default = $value['std'];
                 $output .= $default;
                 break;
                 // Timestamp field.
             // Timestamp field.
             case 'timestamp':
                 $val = get_option($value['id']);
                 if ($val == '') {
                     $val = time();
                 }
                 $output .= '<input type="hidden" name="datepicker-image" value="' . admin_url('images/date-button.gif') . '" />' . "\n";
                 $output .= '<span class="time-selectors">' . "\n";
                 $output .= ' <span class="woo-timestamp-at">' . __('@', 'woothemes') . '</span> ';
                 $output .= '<select name="' . $value['id'] . '[hour]" class="woo-select-timestamp">' . "\n";
                 for ($i = 0; $i <= 23; $i++) {
                     $j = $i;
                     if ($i < 10) {
                         $j = '0' . $i;
                     }
                     $output .= '<option value="' . $i . '"' . selected(date('H', $val), $j, false) . '>' . $j . '</option>' . "\n";
                 }
                 $output .= '</select>' . "\n";
                 $output .= '<select name="' . $value['id'] . '[minute]" class="woo-select-timestamp">' . "\n";
                 for ($i = 0; $i <= 59; $i++) {
                     $j = $i;
                     if ($i < 10) {
                         $j = '0' . $i;
                     }
                     $output .= '<option value="' . $i . '"' . selected(date('i', $val), $j, false) . '>' . $j . '</option>' . "\n";
                 }
                 $output .= '</select>' . "\n";
                 /*
                 $output .= '<select name="' . $value['id'] . '[second]" class="woo-select-timestamp">' . "\n";
                 	for ( $i = 0; $i <= 59; $i++ ) {
                 		
                 		$j = $i;
                 		if ( $i < 10 ) {
                 			$j = '0' . $i;
                 		}
                 		
                 		$output .= '<option value="' . $i . '"' . selected( date( 's', $val ), $j, false ) . '>' . $j . '</option>' . "\n";
                 	}
                 $output .= '</select>' . "\n";
                 */
                 $output .= '</span><!--/.time-selectors-->' . "\n";
                 $output .= '<input class="woo-input-calendar" type="text" name="' . $value['id'] . '[date]" id="' . $value['id'] . '" value="' . esc_attr(date('m/d/Y', $val)) . '">';
                 break;
             case 'slider':
                 $val = $value['std'];
                 $std = get_option($value['id']);
                 if ($std != "") {
                     $val = $std;
                 }
                 $val = stripslashes($val);
                 // Strip out unwanted slashes.
                 $output .= '<div class="ui-slide" id="' . $value['id'] . '_div" min="' . esc_attr($value['min']) . '" max="' . esc_attr($value['max']) . '" inc="' . esc_attr($value['increment']) . '"></div>';
                 $output .= '<input readonly="readonly" class="woo-input" name="' . $value['id'] . '" id="' . $value['id'] . '" type="' . $value['type'] . '" value="' . esc_attr($val) . '" />';
                 break;
             case "heading":
                 if ($counter >= 2) {
                     $output .= '</div>' . "\n";
                 }
                 $jquery_click_hook = preg_replace('/[^a-zA-Z0-9\\s]/', '', strtolower($value['name']));
                 // $jquery_click_hook = preg_replace( '/[^\p{L}\p{N}]/u', '', strtolower( $value['name'] ) ); // Regex for UTF-8 languages.
                 $jquery_click_hook = str_replace(' ', '', $jquery_click_hook);
                 $jquery_click_hook = "woo-option-" . $jquery_click_hook;
                 $menu .= '<li class="' . $value['icon'] . '"><a title="' . $value['name'] . '" href="#' . $jquery_click_hook . '">' . $value['name'] . '</a></li>';
                 $output .= '<div class="group" id="' . $jquery_click_hook . '"><h1 class="subtitle">' . $value['name'] . '</h1>' . "\n";
                 break;
             case "subheading":
                 if ($counter >= 2) {
                     $output .= '</div>' . "\n";
                 }
                 $jquery_click_hook = preg_replace('/[^a-zA-Z0-9\\s]/', '', strtolower($value['name']));
                 // $jquery_click_hook = preg_replace( '/[^\p{L}\p{N}]/u', '', strtolower( $value['name'] ) ); // Regex for UTF-8 languages.
                 $jquery_click_hook = str_replace(' ', '', $jquery_click_hook);
                 $jquery_click_hook = "woo-option-" . $jquery_click_hook;
                 $menu .= '<li><a title="' . $value['name'] . '" href="#' . $jquery_click_hook . '">' . $value['name'] . '</a></li>';
                 $output .= '<div class="group" id="' . $jquery_click_hook . '"><h1 class="subtitle">' . $value['name'] . '</h1>' . "\n";
                 break;
         }
         // if TYPE is an array, formatted into smaller inputs... ie smaller values
         if (is_array($value['type'])) {
             foreach ($value['type'] as $array) {
                 $id = $array['id'];
                 $std = $array['std'];
                 $saved_std = get_option($id);
                 if ($saved_std != $std) {
                     $std = $saved_std;
                 }
                 $meta = $array['meta'];
                 if ($array['type'] == 'text') {
                     // Only text at this point
                     $output .= '<input class="input-text-small woo-input" name="' . $id . '" id="' . $id . '" type="text" value="' . esc_attr($std) . '" />';
                     $output .= '<span class="meta-two">' . $meta . '</span>';
                 }
             }
         }
         if ($value['type'] != "heading" && $value['type'] != "subheading") {
             if ($value['type'] != "checkbox") {
                 $output .= '<br/>';
             }
             $explain_value = isset($value['desc']) ? $value['desc'] : '';
             if (!current_user_can('unfiltered_html') && isset($value['id']) && in_array($value['id'], woo_disabled_if_not_unfiltered_html_option_keys())) {
                 $explain_value .= '<br /><br /><b>' . __('You are not able to update this option because you lack the <code>unfiltered_html</code> capability.', 'woothemes') . '</b>';
             }
             $output .= '</div><div class="explain">' . $explain_value . '</div>' . "\n";
             $output .= '<div class="clear"> </div></div></div>' . "\n";
         }
     }
     //Checks if is not the Content Builder page
     if (isset($_REQUEST['page']) && $_REQUEST['page'] != 'woothemes_content_builder') {
         $output .= '</div>';
     }
     // Override the menu with a new multi-level menu.
     if (count($menu_items) > 0) {
         $menu = '';
         foreach ($menu_items as $k => $v) {
             $class = '';
             if (isset($v['icon']) && $v['icon'] != '') {
                 $class = $v['icon'];
             }
             if (isset($v['children']) && count($v['children']) > 0) {
                 $class .= ' has-children';
             }
             $menu .= '<li class="top-level ' . $class . '">' . "\n" . '<div class="arrow"><div></div></div>';
             if (isset($v['icon']) && $v['icon'] != '') {
                 $menu .= '<span class="icon"></span>';
             }
             $menu .= '<a title="' . $v['name'] . '" href="#' . $v['token'] . '">' . $v['name'] . '</a>' . "\n";
             if (isset($v['children']) && count($v['children']) > 0) {
                 $menu .= '<ul class="sub-menu">' . "\n";
                 foreach ($v['children'] as $i => $j) {
                     $menu .= '<li class="icon">' . "\n" . '<a title="' . $j['name'] . '" href="#' . $j['token'] . '">' . $j['name'] . '</a></li>' . "\n";
                 }
                 $menu .= '</ul>' . "\n";
             }
             $menu .= '</li>' . "\n";
         }
     }
     return array($output, $menu, $menu_items);
 }
 /**
  * Run logic on the WooFramework settings screen.
  * @access  public
  * @since   6.0.0
  * @return  void
  */
 public function settings_screen_logic()
 {
     if (!empty($_POST) && check_admin_referer($this->_field_obj->__get('token') . '_nonce', $this->_field_obj->__get('token') . '_nonce')) {
         $data = $_POST;
         $data = array_map('stripslashes_deep', $data);
         $page = 'woothemes';
         if (isset($data['page'])) {
             $page = $data['page'];
             unset($data['page']);
         }
         $tab = '';
         if (isset($data['tab'])) {
             $tab = $data['tab'];
             unset($data['tab']);
         }
         $data = $this->_field_obj->validate_fields($data, $tab);
         do_action_ref_array('wf_settings_save_before', $data, $this);
         $options_collection = (array) get_option('woo_options', array());
         $update_tracker = array();
         if (0 < count($data)) {
             foreach ($data as $k => $v) {
                 // Skip over the theme option if it's one of a selection of fields allowing unfiltered HTML, and the user can't edit it.
                 if (!current_user_can('unfiltered_html') && in_array($k, woo_disabled_if_not_unfiltered_html_option_keys())) {
                     continue;
                 }
                 // Handle the saving of the setting.
                 if (true == apply_filters('wf_use_theme_mods', false)) {
                     $update_tracker[$k] = set_theme_mod(esc_attr($k), $v);
                 } else {
                     $update_tracker[$k] = update_option(esc_attr($k), $v);
                 }
                 // Update the options collection, in case any products still use it.
                 $options_collection[$k] = $v;
             }
             // Update the options collection in the database.
             update_option('woo_options', $options_collection);
         }
         do_action_ref_array('wf_settings_save_after', $data, $this);
         // Store the status of the updates, so we can report back.
         set_transient($this->_field_obj->__get('token') . 'update_tracker', $update_tracker, 5);
         $update_status = true;
         if (0 < count($update_tracker)) {
             foreach ($update_tracker as $k => $v) {
                 if (false === $v) {
                     $update_status = false;
                     break;
                 }
             }
         }
         // Redirect on settings save, and exit.
         $url = add_query_arg('page', $page);
         if ('' != $tab) {
             $url = add_query_arg('tab', $tab, $url);
         }
         $url = add_query_arg('updated', 'true', $url);
         /*if ( false === $update_status ) {
         			$url = add_query_arg( 'some_didnt_update', 'true', $url );
         		}*/
         wp_safe_redirect($url);
         exit;
     }
 }
 function woo_update_options_filter($new_value, $old_value)
 {
     if (!current_user_can('unfiltered_html')) {
         // Options that get KSES'd
         foreach (woo_ksesed_option_keys() as $option) {
             $new_value[$option] = wp_kses_post($new_value[$option]);
         }
         // Options that cannot be set without unfiltered HTML
         foreach (woo_disabled_if_not_unfiltered_html_option_keys() as $option) {
             $new_value[$option] = $old_value[$option];
         }
     }
     return $new_value;
 }
 /**
  * Saves woo_options
  *
  * @param array $data
  * @return array $update_tracker
  */
 public function update_woo_options($data)
 {
     $options_collection = get_option('woo_options', array());
     $update_tracker = array();
     if (!empty($data)) {
         foreach ($data as $k => $v) {
             // Skip over the theme option if it's one of a selection of fields allowing unfiltered HTML, and the user can't edit it.
             if (!current_user_can('unfiltered_html') && in_array($k, woo_disabled_if_not_unfiltered_html_option_keys())) {
                 continue;
             }
             $this->woo_options_from_data($options_collection, $update_tracker, $k, $v);
         }
         // Update the options collection in the database.
         update_option('woo_options', $options_collection);
     }
     return $update_tracker;
 }
Example #5
0
function woothemes_machine($options) {

    $counter = 0;
	$menu = '';
	$output = '';
	foreach ($options as $value) {

		$counter++;
		$val = '';
		//Start Heading
		 if ( $value['type'] != "heading" )
		 {
		 	$class = ''; if(isset( $value['class'] )) { $class = $value['class']; }
			//$output .= '<div class="section section-'. $value['type'] .'">'."\n".'<div class="option-inner">'."\n";
			$output .= '<div class="section section-'.$value['type'].' '. $class .'">'."\n";
			$output .= '<h3 class="heading">'. $value['name'] .'</h3>'."\n";
			$output .= '<div class="option">'."\n" . '<div class="controls">'."\n";

		 }
		 //End Heading
		$select_value = '';
		switch ( $value['type'] ) {

		case 'text':
			$val = $value['std'];
			$std = get_option($value['id']);
			if ( $std != "") { $val = $std; }
			$val = stripslashes( $val ); // Strip out unwanted slashes.
			$output .= '<input class="woo-input" name="'. $value['id'] .'" id="'. $value['id'] .'" type="'. $value['type'] .'" value="'. esc_attr( $val ) .'" />';
		break;

		case 'select':

			$output .= '<div class="select_wrapper"><select class="woo-input" name="'. $value['id'] .'" id="'. $value['id'] .'">';

			$select_value = stripslashes(get_option($value['id']));

			foreach ($value['options'] as $option) {

				$selected = '';

				 if($select_value != '') {
					 if ( $select_value == $option) { $selected = ' selected="selected"';}
			     } else {
					 if ( isset($value['std']) )
						 if ($value['std'] == $option) { $selected = ' selected="selected"'; }
				 }

				 $output .= '<option'. $selected .'>';
				 $output .= $option;
				 $output .= '</option>';

			 }
			 $output .= '</select></div>';


		break;
		case 'select2':

			$output .= '<div class="select_wrapper"><select class="woo-input" name="'. $value['id'] .'" id="'. $value['id'] .'">';

			$select_value = stripslashes(get_option($value['id']));

			foreach ($value['options'] as $option => $name) {

				$selected = '';

				 if($select_value != '') {
					 if ( $select_value == $option) { $selected = ' selected="selected"';}
			     } else {
					 if ( isset($value['std']) )
						 if ($value['std'] == $option) { $selected = ' selected="selected"'; }
				 }

				 $output .= '<option'. $selected .' value="'.esc_attr($option).'">';
				 $output .= $name;
				 $output .= '</option>';

			 }
			 $output .= '</select></div>';


		break;
		case 'calendar':

			$val = $value['std'];
			$std = get_option($value['id']);
			if ( $std != "") { $val = $std; }
            $output .= '<input class="woo-input-calendar" type="text" name="'.$value['id'].'" id="'.$value['id'].'" value="'.esc_attr($val).'">';

		break;
		case 'time':
			$val = $value['std'];
			$std = get_option($value['id']);
			if ( $std != "") { $val = $std; }
			$output .= '<input class="woo-input-time" name="'. $value['id'] .'" id="'. $value['id'] .'" type="text" value="'. esc_attr($val) .'" />';
		break;
		case 'textarea':

			$cols = '8';
			$ta_value = '';

			if(isset($value['std'])) {

				$ta_value = $value['std'];

				if(isset($value['options'])){
					$ta_options = $value['options'];
					if(isset($ta_options['cols'])){
					$cols = $ta_options['cols'];
					} else { $cols = '8'; }
				}

			}
				$std = get_option($value['id']);
				if( $std != "") { $ta_value = stripslashes( $std ); }
				$output .= '<textarea ' . ( !current_user_can( 'unfiltered_html' ) && in_array( $value['id'], woo_disabled_if_not_unfiltered_html_option_keys() ) ? 'disabled="disabled" ' : '' ) . 'class="woo-input" name="'. $value['id'] .'" id="'. $value['id'] .'" cols="'. $cols .'" rows="8">'.esc_textarea( $ta_value ).'</textarea>';


		break;
		case "radio":

			 $select_value = get_option( $value['id']);

			 foreach ($value['options'] as $key => $option)
			 {

				 $checked = '';
				   if($select_value != '') {
						if ( $select_value == $key) { $checked = ' checked'; }
				   } else {
					if ($value['std'] == $key) { $checked = ' checked'; }
				   }
				$output .= '<input class="woo-input woo-radio" type="radio" name="'. $value['id'] .'" value="'. esc_attr( $key ) .'" '. $checked .' />' . $option .'<br />';

			}

		break;
		case "checkbox":

		   $std = $value['std'];

		   $saved_std = get_option($value['id']);

		   $checked = '';

			if(!empty($saved_std)) {
				if($saved_std == 'true') {
				$checked = 'checked="checked"';
				}
				else{
				   $checked = '';
				}
			}
			elseif( $std == 'true') {
			   $checked = 'checked="checked"';
			}
			else {
				$checked = '';
			}
			$output .= '<input type="checkbox" class="checkbox woo-input" name="'.  $value['id'] .'" id="'. $value['id'] .'" value="true" '. $checked .' />';

		break;
		case "multicheck":

			$std =  $value['std'];

			foreach ($value['options'] as $key => $option) {

			$woo_key = $value['id'] . '_' . $key;
			$saved_std = get_option($woo_key);

			if(!empty($saved_std))
			{
				  if($saved_std == 'true'){
					 $checked = 'checked="checked"';
				  }
				  else{
					  $checked = '';
				  }
			}
			elseif( $std == $key) {
			   $checked = 'checked="checked"';
			}
			else {
				$checked = '';                                                                                    }
			$output .= '<input type="checkbox" class="checkbox woo-input" name="'. $woo_key .'" id="'. $woo_key .'" value="true" '. $checked .' /><label for="'. $woo_key .'">'. $option .'</label><br />';

			}
		break;
		case "multicheck2":

			$std =  explode( ',',$value['std']);

			foreach ($value['options'] as $key => $option) {

			$woo_key = $value['id'] . '_' . $key;
			$saved_std = get_option($woo_key);

			if(!empty($saved_std))
			{
				  if($saved_std == 'true'){
					 $checked = 'checked="checked"';
				  }
				  else{
					  $checked = '';
				  }
			}
			elseif( in_array($key,$std)) {
			   $checked = 'checked="checked"';
			}
			else {
				$checked = '';                                                                                    }
			$output .= '<input type="checkbox" class="checkbox woo-input" name="'. $woo_key .'" id="'. $woo_key .'" value="true" '. $checked .' /><label for="'. $woo_key .'">'. $option .'</label><br />';

			}
		break;
		case "upload":

			if ( function_exists( 'woothemes_medialibrary_uploader' ) ) {

				$output .= woothemes_medialibrary_uploader( $value['id'], $value['std'], null ); // New AJAX Uploader using Media Library

			} else {

				$output .= woothemes_uploader_function($value['id'],$value['std'],null); // Original AJAX Uploader

			} // End IF Statement

		break;
		case "upload_min":

			if ( function_exists( 'woothemes_medialibrary_uploader' ) ) {

				$output .= woothemes_medialibrary_uploader( $value['id'], $value['std'], 'min' ); // New AJAX Uploader using Media Library

			} else {

				$output .= woothemes_uploader_function($value['id'],$value['std'],'min' ); // Original AJAX Uploader

			} // End IF Statement

			// $output .= woothemes_uploader_function($value['id'],$value['std'],'min' );

		break;
		case "color":
			$val = $value['std'];
			$stored  = get_option( $value['id'] );
			if ( $stored != "") { $val = $stored; }
			$output .= '<div id="' . $value['id'] . '_picker" class="colorSelector"><div></div></div>';
			$output .= '<input class="woo-color" name="'. $value['id'] .'" id="'. $value['id'] .'" type="text" value="'. esc_attr( $val ) .'" />';
		break;

		case "typography":

			$default = $value['std'];
			$typography_stored = get_option($value['id']);

			/* Font Size */
			$val = $default['size'];
			if ( $typography_stored['size'] != "") { $val = $typography_stored['size']; }
			if ( $typography_stored['unit'] == 'px'){ $show_px = ''; $show_em = ' style="display:none" '; $name_px = ' name="'. $value['id'].'_size" '; $name_em = ''; }
			else if ( $typography_stored['unit'] == 'em'){ $show_em = ''; $show_px = 'style="display:none"'; $name_em = ' name="'. $value['id'].'_size" '; $name_px = ''; }
			else { $show_px = ''; $show_em = ' style="display:none" '; $name_px = ' name="'. $value['id'].'_size" '; $name_em = ''; }
			$output .= '<select class="woo-typography woo-typography-size woo-typography-size-px"  id="'. $value['id'].'_size_px" '. $name_px . $show_px .'>';
				for ($i = 9; $i < 71; $i++){
					if($val == strval($i)){ $active = 'selected="selected"'; } else { $active = ''; }
					$output .= '<option value="'. $i .'" ' . $active . '>'. $i .'</option>'; }
			$output .= '</select>';

			$output .= '<select class="woo-typography woo-typography-size woo-typography-size-em" id="'. $value['id'].'_size_em" '. $name_em . $show_em.'>';
				$em = 0.5;
				for ($i = 0; $i < 39; $i++){
					if ($i <= 24)			// up to 2.0em in 0.1 increments
						$em = $em + 0.1;
					elseif ($i >= 14 && $i <= 24)		// Above 2.0em to 3.0em in 0.2 increments
						$em = $em + 0.2;
					elseif ($i >= 24)		// Above 3.0em in 0.5 increments
						$em = $em + 0.5;
					if($val == strval($em)){ $active = 'selected="selected"'; } else { $active = ''; }
					//echo ' '. $value['id'] .' val:'.floatval($val). ' -> ' . floatval($em) . ' $<br />' ;
					$output .= '<option value="'. $em .'" ' . $active . '>'. $em .'</option>'; }
			$output .= '</select>';

			/* Font Unit */
			$val = $default['unit'];
			if ( $typography_stored['unit'] != "") { $val = $typography_stored['unit']; }
				$em = ''; $px = '';
			if($val == 'em'){ $em = 'selected="selected"'; }
			if($val == 'px'){ $px = 'selected="selected"'; }
			$output .= '<select class="woo-typography woo-typography-unit" name="'. $value['id'].'_unit" id="'. $value['id'].'_unit">';
			$output .= '<option value="px" '. $px .'">px</option>';
			$output .= '<option value="em" '. $em .'>em</option>';
			$output .= '</select>';

			/* Font Face */
			$val = $default['face'];
			if ( $typography_stored['face'] != "")
				$val = $typography_stored['face'];

			$font01 = '';
			$font02 = '';
			$font03 = '';
			$font04 = '';
			$font05 = '';
			$font06 = '';
			$font07 = '';
			$font08 = '';
			$font09 = '';
			$font10 = '';
			$font11 = '';
			$font12 = '';
			$font13 = '';
			$font14 = '';
			$font15 = '';
			$font16 = '';

			if (strpos($val, 'Arial, sans-serif') !== false){ $font01 = 'selected="selected"'; }
			if (strpos($val, 'Verdana, Geneva') !== false){ $font02 = 'selected="selected"'; }
			if (strpos($val, 'Trebuchet') !== false){ $font03 = 'selected="selected"'; }
			if (strpos($val, 'Georgia') !== false){ $font04 = 'selected="selected"'; }
			if (strpos($val, 'Times New Roman') !== false){ $font05 = 'selected="selected"'; }
			if (strpos($val, 'Tahoma, Geneva') !== false){ $font06 = 'selected="selected"'; }
			if (strpos($val, 'Palatino') !== false){ $font07 = 'selected="selected"'; }
			if (strpos($val, 'Helvetica') !== false){ $font08 = 'selected="selected"'; }
			if (strpos($val, 'Calibri') !== false){ $font09 = 'selected="selected"'; }
			if (strpos($val, 'Myriad') !== false){ $font10 = 'selected="selected"'; }
			if (strpos($val, 'Lucida') !== false){ $font11 = 'selected="selected"'; }
			if (strpos($val, 'Arial Black') !== false){ $font12 = 'selected="selected"'; }
			if (strpos($val, 'Gill') !== false){ $font13 = 'selected="selected"'; }
			if (strpos($val, 'Geneva, Tahoma') !== false){ $font14 = 'selected="selected"'; }
			if (strpos($val, 'Impact') !== false){ $font15 = 'selected="selected"'; }
			if (strpos($val, 'Courier') !== false){ $font16 = 'selected="selected"'; }

			$output .= '<select class="woo-typography woo-typography-face" name="'. $value['id'].'_face" id="'. $value['id'].'_face">';
			$output .= '<option value="Arial, sans-serif" '. $font01 .'>Arial</option>';
			$output .= '<option value="Verdana, Geneva, sans-serif" '. $font02 .'>Verdana</option>';
			$output .= '<option value="&quot;Trebuchet MS&quot;, Tahoma, sans-serif"'. $font03 .'>Trebuchet</option>';
			$output .= '<option value="Georgia, serif" '. $font04 .'>Georgia</option>';
			$output .= '<option value="&quot;Times New Roman&quot;, serif"'. $font05 .'>Times New Roman</option>';
			$output .= '<option value="Tahoma, Geneva, Verdana, sans-serif"'. $font06 .'>Tahoma</option>';
			$output .= '<option value="Palatino, &quot;Palatino Linotype&quot;, serif"'. $font07 .'>Palatino</option>';
			$output .= '<option value="&quot;Helvetica Neue&quot;, Helvetica, sans-serif" '. $font08 .'>Helvetica*</option>';
			$output .= '<option value="Calibri, Candara, Segoe, Optima, sans-serif"'. $font09 .'>Calibri*</option>';
			$output .= '<option value="&quot;Myriad Pro&quot;, Myriad, sans-serif"'. $font10 .'>Myriad Pro*</option>';
			$output .= '<option value="&quot;Lucida Grande&quot;, &quot;Lucida Sans Unicode&quot;, &quot;Lucida Sans&quot;, sans-serif"'. $font11 .'>Lucida</option>';
			$output .= '<option value="&quot;Arial Black&quot;, sans-serif" '. $font12 .'>Arial Black</option>';
			$output .= '<option value="&quot;Gill Sans&quot;, &quot;Gill Sans MT&quot;, Calibri, sans-serif" '. $font13 .'>Gill Sans*</option>';
			$output .= '<option value="Geneva, Tahoma, Verdana, sans-serif" '. $font14 .'>Geneva*</option>';
			$output .= '<option value="Impact, Charcoal, sans-serif" '. $font15 .'>Impact</option>';
			$output .= '<option value="Courier, &quot;Courier New&quot;, monospace" '. $font16 .'>Courier</option>';

			// Google webfonts
		 	global $google_fonts;
			sort ($google_fonts);

			$output .= '<option value="">-- Google Fonts --</option>';
			foreach ( $google_fonts as $key => $gfont ) :
		 		$font[$key] = '';
				if ($val == $gfont['name']){ $font[$key] = 'selected="selected"'; }
				$name = $gfont['name'];
				$output .= '<option value="'.$name.'" '. $font[$key] .'>'.$name.'</option>';
			endforeach;

			// Custom Font stack
			$new_stacks = get_option( 'framework_woo_font_stack' );
			if(!empty($new_stacks)){
				$output .= '<option value="">-- Custom Font Stacks --</option>';
				foreach($new_stacks as $name => $stack){
					if (strpos($val, $stack) !== false){ $fontstack = 'selected="selected"'; } else { $fontstack = ''; }
					$output .= '<option value="'. stripslashes(htmlentities($stack)) .'" '.$fontstack.'>'. str_replace( '_',' ',$name).'</option>';
				}
			}

			$output .= '</select>';

			/* Font Weight */
			$val = $default['style'];
			if ( $typography_stored['style'] != "") { $val = $typography_stored['style']; }
				$normal = ''; $italic = ''; $bold = ''; $bolditalic = '';
			if($val == 'normal'){ $normal = 'selected="selected"'; }
			if($val == 'italic'){ $italic = 'selected="selected"'; }
			if($val == 'bold'){ $bold = 'selected="selected"'; }
			if($val == 'bold italic'){ $bolditalic = 'selected="selected"'; }

			$output .= '<select class="woo-typography woo-typography-style" name="'. $value['id'].'_style" id="'. $value['id'].'_style">';
			$output .= '<option value="normal" '. $normal .'>Normal</option>';
			$output .= '<option value="italic" '. $italic .'>Italic</option>';
			$output .= '<option value="bold" '. $bold .'>Bold</option>';
			$output .= '<option value="bold italic" '. $bolditalic .'>Bold/Italic</option>';
			$output .= '</select>';

			/* Font Color */
			$val = $default['color'];
			if ( $typography_stored['color'] != "") { $val = $typography_stored['color']; }
			$output .= '<div id="' . $value['id'] . '_color_picker" class="colorSelector"><div></div></div>';
			$output .= '<input class="woo-color woo-typography woo-typography-color" name="'. $value['id'] .'_color" id="'. $value['id'] .'_color" type="text" value="'. esc_attr( $val ) .'" />';

		break;

		case "border":

			$default = $value['std'];
			$border_stored = get_option( $value['id'] );

			/* Border Width */
			$val = $default['width'];
			if ( $border_stored['width'] != "") { $val = $border_stored['width']; }
			$output .= '<select class="woo-border woo-border-width" name="'. $value['id'].'_width" id="'. $value['id'].'_width">';
				for ($i = 0; $i < 21; $i++){
					if($val == $i){ $active = 'selected="selected"'; } else { $active = ''; }
					$output .= '<option value="'. $i .'" ' . $active . '>'. $i .'px</option>'; }
			$output .= '</select>';

			/* Border Style */
			$val = $default['style'];
			if ( $border_stored['style'] != "") { $val = $border_stored['style']; }
				$solid = ''; $dashed = ''; $dotted = '';
			if($val == 'solid'){ $solid = 'selected="selected"'; }
			if($val == 'dashed'){ $dashed = 'selected="selected"'; }
			if($val == 'dotted'){ $dotted = 'selected="selected"'; }

			$output .= '<select class="woo-border woo-border-style" name="'. $value['id'].'_style" id="'. $value['id'].'_style">';
			$output .= '<option value="solid" '. $solid .'>Solid</option>';
			$output .= '<option value="dashed" '. $dashed .'>Dashed</option>';
			$output .= '<option value="dotted" '. $dotted .'>Dotted</option>';
			$output .= '</select>';

			/* Border Color */
			$val = $default['color'];
			if ( $border_stored['color'] != "") { $val = $border_stored['color']; }
			$output .= '<div id="' . $value['id'] . '_color_picker" class="colorSelector"><div></div></div>';
			$output .= '<input class="woo-color woo-border woo-border-color" name="'. $value['id'] .'_color" id="'. $value['id'] .'_color" type="text" value="'. esc_attr( $val ) .'" />';

		break;

		case "images":
			$i = 0;
			$select_value = get_option( $value['id']);

			foreach ($value['options'] as $key => $option)
			 {
			 $i++;

				 $checked = '';
				 $selected = '';
				   if($select_value != '') {
						if ( $select_value == $key) { $checked = ' checked'; $selected = 'woo-radio-img-selected'; }
				    } else {
						if ($value['std'] == $key) { $checked = ' checked'; $selected = 'woo-radio-img-selected'; }
						elseif ($i == 1  && !isset($select_value)) { $checked = ' checked'; $selected = 'woo-radio-img-selected'; }
						elseif ($i == 1  && $value['std'] == '') { $checked = ' checked'; $selected = 'woo-radio-img-selected'; }
						else { $checked = ''; }
					}

				$output .= '<span>';
				$output .= '<input type="radio" id="woo-radio-img-' . $value['id'] . $i . '" class="checkbox woo-radio-img-radio" value="'. esc_attr( $key ) .'" name="'. $value['id'].'" '.$checked.' />';
				$output .= '<div class="woo-radio-img-label">'. esc_html($key) .'</div>';
				$output .= '<img src="'.$option.'" alt="" class="woo-radio-img-img '. $selected .'" onClick="document.getElementById(\'woo-radio-img-'. $value['id'] . $i.'\').checked = true;" />';
				$output .= '</span>';

			}

		break;

		case "info":
			$default = $value['std'];
			$output .= $default;
		break;

		case "string_builder":
			$desc = $value['std'];
			$output .= '<div id="'.$value['id'].'">';
			$output .= 'Name<input class="woo-input woo-ignore" name="name" id="'. $value['id'] .'_name" type="text" />';
			$output .= 'Font Stack<input class="woo-input woo-ignore" name="value" id="'. $value['id'] .'_value" type="text" />';
			$output .= '<div class="add_button"><a class="button string_builder_add" href="#" class="string_builder" id="'.$value['id'].'">Add</a></div>';

			$output .= '<div id="'.$value['id'].'_return" class="string_builder_return">';
			$output .= '<h3>'.$desc.'</h3>';
			$saved_data = get_option($value['id']);
			if(!empty($saved_data)){
				foreach($saved_data as $name => $data){
					$data = stripslashes($data);
					$output .= '<div class="string_option" id="string_builer_option_'.str_replace( ' ','_',$name).'"><a class="delete" rel="'.$name.'" href="#"><img src="' . get_template_directory_uri() . '/functions/images/ico-close.png" /></a><span>'.str_replace( '_',' ',$name) .':</span> '. $data .'</div>';
				}
			}
			$output .= '<div style="display:none" class="string_builder_empty">Nothing added yet.</div>';
			$output .= '</div>';
			$output .= '</div>';

		break;

		case "heading":

			if($counter >= 2){
			   $output .= '</div>'."\n";
			}
			$jquery_click_hook = preg_replace( '/[^a-zA-Z0-9\s]/', '', strtolower( $value['name'] ) );			
			$jquery_click_hook = str_replace(' ', '', $jquery_click_hook);

			$jquery_click_hook = "woo-option-" . $jquery_click_hook;
//			$jquery_click_hook = "woo-option-" . str_replace( "&","",str_replace( "/","",str_replace( ".","",str_replace( ")","",str_replace( "( ","",str_replace( " ","",strtolower($value['name'])))))));
			$menu .= '<li class="'.$value['icon'].'"><a title="'.  $value['name'] .'" href="#'.  $jquery_click_hook  .'">'.  $value['name'] .'</a></li>';
			$output .= '<div class="group" id="'. $jquery_click_hook  .'"><h2>'.$value['name'].'</h2>'."\n";
		break;
		}

		// if TYPE is an array, formatted into smaller inputs... ie smaller values
		if ( is_array($value['type'])) {
			foreach($value['type'] as $array){

					$id = $array['id'];
					$std = $array['std'];
					$saved_std = get_option($id);
					if($saved_std != $std){$std = $saved_std;}
					$meta = $array['meta'];

					if($array['type'] == 'text') { // Only text at this point

						 $output .= '<input class="input-text-small woo-input" name="'. $id .'" id="'. $id .'" type="text" value="'. esc_attr( $std ) .'" />';
						 $output .= '<span class="meta-two">'.$meta.'</span>';
					}
				}
		}
		if ( $value['type'] != "heading" ) {
			if ( $value['type'] != "checkbox" )
				{
				$output .= '<br/>';
				}
			$explain_value = ( isset( $value['desc'] ) ) ? $value['desc'] : '';
			if ( !current_user_can( 'unfiltered_html' ) && isset( $value['id'] ) && in_array( $value['id'], woo_disabled_if_not_unfiltered_html_option_keys() ) )
				$explain_value .= '<br /><br /><b>' . __( 'You are not able to update this option because you lack the <code>unfiltered_html</code> capability.', 'woothemes' ) . '</b>';
			$output .= '</div><div class="explain">'. $explain_value .'</div>'."\n";
			$output .= '<div class="clear"> </div></div></div>'."\n";
			}

	}

    //Checks if is not the Content Builder page
    if ( isset($_REQUEST['page']) && $_REQUEST['page'] != 'woothemes_content_builder' ) {
		$output .= '</div>';
	}

    return array($output,$menu);

}