function optionsframework_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; } $output .= '<input class="of-input" name="' . $value['id'] . '" id="' . $value['id'] . '" type="' . $value['type'] . '" value="' . $val . '" />'; break; case 'select': $output .= '<select class="of-input" name="' . $value['id'] . '" id="' . $value['id'] . '">'; $select_value = 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>'; break; case 'select2': $output .= '<select class="of-input" name="' . $value['id'] . '" id="' . $value['id'] . '">'; $select_value = 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="' . $option . '">'; $output .= $name; $output .= '</option>'; } $output .= '</select>'; 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 class="of-input" name="' . $value['id'] . '" id="' . $value['id'] . '" cols="' . $cols . '" rows="8">' . $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="of-input of-radio" type="radio" name="' . $value['id'] . '" value="' . $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 of-input" name="' . $value['id'] . '" id="' . $value['id'] . '" value="true" ' . $checked . ' />'; break; case "multicheck": $std = $value['std']; foreach ($value['options'] as $key => $option) { $of_key = $value['id'] . '_' . $key; $saved_std = get_option($of_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 of-input" name="' . $of_key . '" id="' . $of_key . '" value="true" ' . $checked . ' /><label for="' . $of_key . '">' . $option . '</label><br />'; } break; case "upload": $value['std'] = ''; if (isset($value['std'])) { $output .= optionsframework_uploader_function($value['id'], $value['std'], null); } break; case "upload_min": $output .= optionsframework_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="of-color" name="' . $value['id'] . '" id="' . $value['id'] . '" type="text" value="' . $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']; } $output .= '<select class="of-typography of-typography-size" name="' . $value['id'] . '_size" id="' . $value['id'] . '_size">'; for ($i = 9; $i < 71; $i++) { if ($val == $i) { $active = 'selected="selected"'; } else { $active = ''; } $output .= '<option value="' . $i . '" ' . $active . '>' . $i . 'px</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 = ''; 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"'; } $output .= '<select class="of-typography of-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=""Trebuchet MS", Tahoma, sans-serif"' . $font03 . '>Trebuchet</option>'; $output .= '<option value="Georgia, serif" ' . $font04 . '>Georgia</option>'; $output .= '<option value=""Times New Roman", serif"' . $font05 . '>Times New Roman</option>'; $output .= '<option value="Tahoma, Geneva, Verdana, sans-serif"' . $font06 . '>Tahoma</option>'; $output .= '<option value="Palatino, "Palatino Linotype", serif"' . $font07 . '>Palatino</option>'; $output .= '<option value=""Helvetica Neue", Helvetica, sans-serif" ' . $font08 . '>Helvetica*</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="of-typography of-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="of-color of-typography of-typography-color" name="' . $value['id'] . '_color" id="' . $value['id'] . '_color" type="text" value="' . $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="of-border of-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="of-border of-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="of-color of-border of-border-color" name="' . $value['id'] . '_color" id="' . $value['id'] . '_color" type="text" value="' . $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 = 'of-radio-img-selected'; } } else { if ($value['std'] == $key) { $checked = ' checked'; $selected = 'of-radio-img-selected'; } elseif ($i == 1 && !isset($select_value)) { $checked = ' checked'; $selected = 'of-radio-img-selected'; } elseif ($i == 1 && $value['std'] == '') { $checked = ' checked'; $selected = 'of-radio-img-selected'; } else { $checked = ''; } } $output .= '<span>'; $output .= '<input type="radio" id="of-radio-img-' . $value['id'] . $i . '" class="checkbox of-radio-img-radio" value="' . $key . '" name="' . $value['id'] . '" ' . $checked . ' />'; $output .= '<div class="of-radio-img-label">' . $key . '</div>'; $output .= '<img src="' . $option . '" alt="" class="of-radio-img-img ' . $selected . '" onClick="document.getElementById(\'of-radio-img-' . $value['id'] . $i . '\').checked = true;" />'; $output .= '</span>'; } break; case "info": $default = $value['std']; $output .= $default; break; case "heading": if ($counter >= 2) { $output .= '</div>' . "\n"; } $jquery_click_hook = ereg_replace("[^A-Za-z0-9]", "", strtolower($value['name'])); $jquery_click_hook = "of-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 . '"><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 of-input" name="' . $id . '" id="' . $id . '" type="text" value="' . $std . '" />'; $output .= '<span class="meta-two">' . $meta . '</span>'; } } } if ($value['type'] != "heading") { if ($value['type'] != "checkbox") { $output .= '<br/>'; } if (!isset($value['desc'])) { $explain_value = ''; } else { $explain_value = $value['desc']; } $output .= '</div><div class="explain">' . $explain_value . '</div>' . "\n"; $output .= '<div class="clear"> </div></div></div>' . "\n"; } } $output .= '</div>'; return array($output, $menu); }
function optionsframework_machine($options) { $counter = 0; $menu = ''; $output = ''; foreach ($options as $value) { $counter++; $val = ''; //Start Heading if (!isset($value['type'])) { $value['type'] = ''; } if (!isset($value['name'])) { $value['name'] = ''; } if ($value['type'] != "heading") { $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 = get_option($value['id']); if ($val == '' && isset($value['std'])) { $val = $value['std']; } $output .= '<input class="of-input" name="' . $value['id'] . '" id="' . $value['id'] . '" type="' . $value['type'] . '" value="' . $val . '" />'; break; case 'select': $output .= '<select class="of-input" name="' . $value['id'] . '" id="' . $value['id'] . '">'; $select_value = get_option($value['id']); if ($select_value == '') { $select_value = $value['std']; } $i = 1; foreach ($value['options'] as $option) { $selected = ''; if ($select_value == $i) { $selected = ' selected="selected"'; } $output .= '<option' . $selected . ' value="' . $i . '">'; $output .= $option; $output .= '</option>'; $i++; } $output .= '</select>'; break; case 'select_letters': $output .= '<select class="of-input" name="' . $value['id'] . '" id="' . $value['id'] . '">'; $select_value = get_option($value['id']); if ($select_value == '') { $select_value = $value['std']; } foreach ($value['options'] as $option) { $selected = ''; if ($select_value == $option) { $selected = ' selected="selected"'; } $output .= '<option' . $selected . ' value="' . $option . '">'; $output .= $option; $output .= '</option>'; } $output .= '</select>'; break; case 'select_slideshow': $args = array("post_type" => "gallery", "numberposts" => "-1"); $posts_obj = get_posts($args); $output .= '<select class="of-input" name="' . $value['id'] . '" id="' . $value['id'] . '">'; $selected_value = get_option($value['id']); if (!$selected_value) { $selected_value = $value['std']; } foreach ($posts_obj as $cat) { $selected = ''; if ($selected_value == $cat->ID) { $selected = ' selected="selected"'; } $output .= '<option' . $selected . ' value="' . $cat->ID . '">'; $output .= $cat->post_title; $output .= '</option>'; } $output .= '</select>'; break; case 'select_background': $i = 0; $select_value = get_option($value['id']); $output .= '<ul class="background-pattern-list">'; foreach ($value['options'] as $key => $option) { $i++; $checked = ''; $selected = ''; if ($select_value != '' && $select_value == $option) { $checked = ' checked'; $selected = 'of-radio-img-selected'; } if ($checked == ' checked') { $current = ' class="current"'; } else { $current = ''; } $output .= '<li ' . $current . ' style="background-image:url(' . $option . ')">'; $output .= '<input type="radio" id="of-radio-img-' . $value['id'] . $i . '" class="checkbox of-radio-img-radio" value="' . $option . '" name="' . $value['id'] . '" ' . $checked . ' />'; $output .= '</li>'; } $output .= '</ul>'; 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 class="of-input" name="' . $value['id'] . '" id="' . $value['id'] . '" cols="' . $cols . '" rows="8">' . $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="of-input of-radio" type="radio" name="' . $value['id'] . '" value="' . $key . '" ' . $checked . ' />' . $option . '<br />'; } break; case "color": $val = get_option($value['id']); if (!isset($val)) { $val = $value['std']; } $output .= '<div id="' . $value['id'] . '_picker" class="colorPicker"></div>'; $output .= '<input id="' . $value['id'] . '" type="text" name="' . $value['id'] . '" class="colorInput" value="' . $val . '" /><div class="colorSelector"></div>'; $output .= "<script>\r\n\t\t\tjQuery(document).ready( function(\$) {\r\n\t\t\t\r\n\t\t\t\t\$('#" . $value['id'] . "_picker').farbtastic('#" . $value['id'] . "');\r\n\t\t\t\r\n\t\t\t});\r\n\t\t\t</script>"; break; case 'multiselect': $meta_array = explode(",", get_option($value['id'])); $output .= '<select style="height:120px;" name="' . $value['id'] . '[]" id="' . $value['id'] . '" class="widefat of-input" multiple="multiple">'; foreach ($value['options'] as $option) { $selected = ''; if ($meta_array) { foreach ($meta_array as $a) { if ($a == $option) { $selected = ' selected="selected"'; } } } $output .= '<option' . $selected . ' class="of-input" value="' . $option . '">' . $option . '</option>'; } $output .= '</select>'; /////// break; case "upload": $output .= optionsframework_uploader_function($value['id'], $value['id'], null); break; case "upload_min": $output .= optionsframework_uploader_function($value['id'], $value['std'], 'min'); break; case "range": $output .= '<div class="range-input-container">'; $output .= '<input type="range" name="' . $value['id'] . '" value="'; $val = get_option($value['id']); if ($val == '' || !isset($val)) { $val = $value['std']; } $output .= $val; if (isset($value['min'])) { $output .= '" min="' . $value['min']; } if (isset($value['max'])) { $output .= '" max="' . $value['max']; } if (isset($value['step'])) { $output .= '" step="' . $value['step']; } $output .= '" />'; if (isset($value['unit'])) { $output .= '<span>' . $value['unit'] . '</span>'; } $output .= '</div>'; 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 = 'of-radio-img-selected'; } } else { if ($value['std'] == $key) { $checked = ' checked'; $selected = 'of-radio-img-selected'; } elseif ($i == 1 && !isset($select_value)) { $checked = ' checked'; $selected = 'of-radio-img-selected'; } elseif ($i == 1 && $value['std'] == '') { $checked = ' checked'; $selected = 'of-radio-img-selected'; } else { $checked = ''; } } $output .= '<span>'; $output .= '<input type="radio" id="of-radio-img-' . $value['id'] . $i . '" class="checkbox of-radio-img-radio" value="' . $key . '" name="' . $value['id'] . '" ' . $checked . ' />'; $output .= '<div class="of-radio-img-label">' . $key . '</div>'; $output .= '<img src="' . $option . '" alt="" class="of-radio-img-img ' . $selected . '" onClick="document.getElementById(\'of-radio-img-' . $value['id'] . $i . '\').checked = true;" />'; $output .= '</span>'; } break; case "select_images": $i = 0; $select_value = get_option($value['id']); $output .= '<ul class="checkbox-list">'; foreach ($value['options'] as $key => $option) { $i++; $checked = ''; $selected = ''; if ($select_value != '') { if ($select_value == $key) { $checked = ' checked'; $selected = 'of-radio-img-selected'; } } else { if ($value['std'] == $key) { $checked = ' checked'; $selected = 'of-radio-img-selected'; } elseif ($i == 1 && !isset($select_value)) { $checked = ' checked'; $selected = 'of-radio-img-selected'; } elseif ($i == 1 && $value['std'] == '') { $checked = ' checked'; $selected = 'of-radio-img-selected'; } else { $checked = ''; } } $output .= '<li class="' . $checked . '">'; $output .= '<input type="radio" id="of-radio-img-' . $value['id'] . $i . '" class="checkbox of-radio-img-radio" value="' . $key . '" name="' . $value['id'] . '" ' . $checked . ' />'; $output .= '<img src="' . $option['url'] . '" alt="" class="of-radio-img-img ' . $selected . '" onClick="document.getElementById(\'of-radio-img-' . $value['id'] . $i . '\').checked = true;" />'; $output .= '<div class="of-radio-img-label">' . $option['desc'] . '</div>'; $output .= '</li>'; } $output .= '</ul>'; break; case "custom_sidebar": $custom_sidebars = get_theme_option('custom_sidebars'); if (!empty($custom_sidebars)) { $custom_sidebars_array = explode(',', $custom_sidebars); } else { $custom_sidebars_array = array(); } $output .= '<input type="text" id="sidebar_name"/>'; $output .= '<a id="add_sidebar" class="of-button"/>Create sidebar</a>'; $output .= '<h3 id="sidebar_heading" class="heading">Created Sidebars</h3>'; $output .= '<div id="created_sidebars">'; if (!empty($custom_sidebars)) { for ($i = 0; $i < count($custom_sidebars_array) - 1; $i++) { $output .= '<div class="created_item" data-name="' . $custom_sidebars_array[$i] . '">' . $custom_sidebars_array[$i] . '<a class="of-button"/>delete</a></div>'; } } $output .= '</div>'; $output .= '<input id="custom_sidebars" type="hidden" value="' . $custom_sidebars . '" name="' . $value['id'] . '" />'; break; case "custom_footer": $custom_footers_names = get_theme_option("adm_custom_footers_name"); $custom_footers_layout = get_theme_option("adm_custom_footers_layout"); if (!empty($custom_footers_names)) { $custom_footers_names_array = explode(',', $custom_footers_names); } if (!empty($custom_footers_layout)) { $custom_footers_layout_array = explode(',', $custom_footers_layout); } $output .= '<ul id="adm_footer_layout" class="checkbox-list">'; $output .= '<li>'; $output .= '<input type="radio" name="sex" value="1" />'; $output .= '<img src="' . THEME_ADMIN_IMG . '/layouts/2.png"/>'; $output .= '<div class="of-radio-img-label">1/1</div>'; $output .= '</li>'; $output .= '<li>'; $output .= '<input type="radio" name="sex" value="2" />'; $output .= '<img src="' . THEME_ADMIN_IMG . '/layouts/3.png"/>'; $output .= '<div class="of-radio-img-label">1/2 1/2</div>'; $output .= '</li>'; $output .= '<li>'; $output .= '<input type="radio" name="sex" value="3" />'; $output .= '<img src="' . THEME_ADMIN_IMG . '/layouts/4.png"/>'; $output .= '<div class="of-radio-img-label">1/3 1/3 1/3</div>'; $output .= '</li>'; $output .= '<li>'; $output .= '<input type="radio" name="sex" value="4" />'; $output .= '<img src="' . THEME_ADMIN_IMG . '/layouts/5.png"/>'; $output .= '<div class="of-radio-img-label">1/3 2/3</div>'; $output .= '</li>'; $output .= '<li>'; $output .= '<input type="radio" name="sex" value="5" />'; $output .= '<img src="' . THEME_ADMIN_IMG . '/layouts/6.png"/>'; $output .= '<div class="of-radio-img-label">2/3 1/3</div>'; $output .= '</li>'; $output .= '<li>'; $output .= '<input type="radio" name="sex" value="6" />'; $output .= '<img src="' . THEME_ADMIN_IMG . '/layouts/7.png"/>'; $output .= '<div class="of-radio-img-label">1/4 1/4 1/4 1/4</div>'; $output .= '</li>'; $output .= '<li>'; $output .= '<input type="radio" name="sex" value="7" />'; $output .= '<img src="' . THEME_ADMIN_IMG . '/layouts/8.png"/>'; $output .= '<div class="of-radio-img-label">1/2 1/4 1/4</div>'; $output .= '</li>'; $output .= '<li>'; $output .= '<input type="radio" name="sex" value="8" />'; $output .= '<img src="' . THEME_ADMIN_IMG . '/layouts/9.png"/>'; $output .= '<div class="of-radio-img-label">1/4 1/2 1/4</div>'; $output .= '</li>'; $output .= '<li>'; $output .= '<input type="radio" name="sex" value="9" />'; $output .= '<img src="' . THEME_ADMIN_IMG . '/layouts/10.png"/>'; $output .= '<div class="of-radio-img-label">1/4 1/4 1/2</div>'; $output .= '</li>'; $output .= '<li>'; $output .= '<input type="radio" name="sex" value="10" />'; $output .= '<img src="' . THEME_ADMIN_IMG . '/layouts/11.png"/>'; $output .= '<div class="of-radio-img-label">3/4 1/4</div>'; $output .= '</li>'; $output .= '<li>'; $output .= '<input type="radio" name="sex" value="11" />'; $output .= '<img src="' . THEME_ADMIN_IMG . '/layouts/12.png"/>'; $output .= '<div class="of-radio-img-label">1/4 3/4</div>'; $output .= '</li>'; $output .= '</ul>'; $output .= '<input type="text" id="adm_footer_name" placeholder="Footer Name"/>'; $output .= '<a id="adm_add_footer" class="of-button">Create Footer</a>'; $output .= '<h3 id="sidebar_heading" class="heading">Created Footers</h3>'; $output .= '<div id="created_footers">'; if (!empty($custom_footers_names)) { for ($i = 0; $i < count($custom_footers_names_array) - 1; $i++) { $output .= '<div class="created_item" data-name="' . $custom_footers_names_array[$i] . '" data-layout="' . $custom_footers_layout_array[$i] . '">' . $custom_footers_names_array[$i] . '<a class="of-button">delete</a></div>'; } } $output .= '</div>'; $output .= '<input id="adm_custom_footers_name" type="hidden" value="' . $custom_footers_names . '" name="' . $value['id'] . '" />'; $output .= '<input id="adm_custom_footers_layout" type="hidden" value="' . $custom_footers_layout . '" name="' . THEME_SLUG . 'adm_custom_footers_layout" />'; break; case "heading": if ($counter >= 2) { $output .= '</div>' . "\n"; } $jquery_click_hook = ereg_replace("[^A-Za-z0-9]", "", strtolower($value['name'])); $jquery_click_hook = "of-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 . '"><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 of-input" name="' . $id . '" id="' . $id . '" type="text" value="' . $std . '" />'; $output .= '<span class="meta-two">' . $meta . '</span>'; } } } if ($value['type'] != "heading") { if ($value['type'] != "checkbox") { $output .= '<br/>'; } if (!isset($value['desc'])) { $explain_value = ''; } else { $explain_value = $value['desc']; } $output .= '</div><div class="explain">' . $explain_value . '</div>' . "\n"; $output .= '<div class="clear"> </div></div></div>' . "\n"; } } $output .= '</div>'; return array($output, $menu); }
function create_meta_options($post, $metabox) { global $post; $output = '<input type="hidden" name="mytheme_meta_box_nonce" value="' . wp_create_nonce(basename(__FILE__)) . '" />'; $counter = 0; $menu = ''; foreach ($metabox['args']['var1'] as $value) { $counter++; $val = ''; $class_string = ''; if (isset($value['class'])) { $class = $value['class']; $class = explode(' ', $class); foreach ($class as $c) { $class_string .= 'op_' . $c . ' '; } } $output .= '<div class="section section-' . $value['type'] . ' ' . $class_string . '">' . "\n"; $output .= '<div class="metabox_table">'; $output .= '<div class="heading">'; $output .= '<h4>' . $value['name'] . '</h4>' . "\n"; $output .= '</div>'; $output .= '<div class="option">'; $meta_box_value = get_post_meta($post->ID, $value['id'] . '_value', true); $select_value = ''; switch ($value['type']) { case 'text': //$val = $value['std']; $std = get_option($value['id']); if ($std != "") { $val = $std; } $output .= '<input class="of-input" name="' . $value['id'] . '" id="' . $value['id'] . '" type="' . $value['type'] . '" value="' . $meta_box_value . '" />'; break; case 'select': $output .= '<select class="' . $value['class'] . '" name="' . $value['id'] . '" id="' . $value['id'] . '">'; $selected_value = get_post_meta($post->ID, $value['id'] . '_value', true); $i = 1; foreach ($value['options'] as $option) { $selected = ''; if ($selected_value == $i) { $selected = ' selected="selected"'; } $output .= '<option' . $selected . ' value="' . $i . '">'; $output .= $option; $output .= '</option>'; $i++; } $output .= '</select>'; break; case 'select_letters': $output .= '<select class="' . $value['class'] . '" name="' . $value['id'] . '" id="' . $value['id'] . '">'; $selected_value = get_post_meta($post->ID, $value['id'] . '_value', true); foreach ($value['options'] as $option) { $selected = ''; if ($selected_value == $option) { $selected = ' selected="selected"'; } $output .= '<option' . $selected . ' value="' . $option . '">'; $output .= $option; $output .= '</option>'; } $output .= '</select>'; break; case 'toggle': $post_meta = get_post_meta($post->ID, $value['id'] . '_value', true); if (isset($value['std'])) { if ($value['std'] == 'on') { $checked = ' checked="checked"'; } } if (isset($value['std'])) { if ($value['std'] == 'off') { $checked = ''; } } if ($post_meta == 'on') { $checked = ' checked="checked"'; } if ($post_meta == 'off') { $checked = ''; } $output .= '<input name="' . $value['id'] . '" type="checkbox" class="ibutton" ' . $checked . '/>'; break; case 'multiselect': $of_categories_obj = get_categories('hide_empty=0'); $output .= '<select style="height:5.5em;width:300px;" name="' . $value['id'] . '" id="' . $value['id'] . '" class="widefat" multiple="multiple">'; foreach ($of_categories_obj as $of_cat) { $output .= '<option' . $selected . ' value="' . $of_cat->cat_ID . '">' . $of_cat->cat_name . '</option>'; } $output .= '</select>'; break; case 'multiselect_categories': $vals = get_meta_option('masonry_categories'); $args = array("hide_empty" => 1, "taxonomy" => $value['options']); $categories_obj = get_categories($args); $output .= '<select style="height:120px;" id="' . $value['id'] . '" name="' . $value['id'] . '[]" multiple="multiple">'; foreach ($categories_obj as $cat) { if (is_string($vals)) { if ($vals == $cat->cat_ID) { $selected = ' selected="selected"'; } else { $selected = ''; } } else { if (in_array($cat->cat_ID, $vals)) { $selected = ' selected="selected"'; } else { $selected = ''; } } $output .= '<option ' . $selected . ' value="' . $cat->cat_ID . '">' . $cat->cat_name . '</option>'; } $output .= '</select>'; break; case 'multiselect_post_categories': $args = array("hide_empty" => 0); $of_categories_obj = get_categories($args); $post_meta = get_post_meta($post->ID, $value['id'] . '_value', true); if ($post_meta == '') { $post_meta = explode(',', $post_meta); } $output .= '<select style="height:120px;" name="' . $value['id'] . '[]" id="' . $value['id'] . '" class="widefat of-input" multiple="multiple">'; foreach ($of_categories_obj as $of_cat) { $selected = ''; if ($post_meta != null) { foreach ($post_meta as $a => $b) { if ($b == $of_cat->cat_ID) { $selected = ' selected="selected"'; } } } $output .= '<option' . $selected . ' class="of-input" value="' . $of_cat->cat_ID . '">' . $of_cat->cat_name . '</option>'; } $output .= '</select>'; break; case 'multiselect_portfolio_categories': $args = array("hide_empty" => 1, "taxonomy" => "portfolio_category"); $of_categories_obj = get_categories($args); $post_meta = get_post_meta($post->ID, $value['id'] . '_value', true); $output .= '<select style="height:120px;" name="' . $value['id'] . '[]" id="' . $value['id'] . '" class="widefat of-input" multiple="multiple">'; foreach ($of_categories_obj as $of_cat) { $selected = ''; if ($post_meta) { foreach ($post_meta as $a => $b) { if ($b == $of_cat->cat_ID) { $selected = ' selected="selected"'; } } } $output .= '<option' . $selected . ' class="of-input" value="' . $of_cat->cat_ID . '">' . $of_cat->cat_name . '</option>'; } $output .= '</select>'; break; case 'multiselect_gallery': $args = array("hide_empty" => 1, "taxonomy" => "gallery_category"); $of_categories_obj = get_categories($args); $post_meta = get_post_meta($post->ID, $value['id'] . '_value', true); $output .= '<select style="height:120px;" name="' . $value['id'] . '[]" id="' . $value['id'] . '" class="widefat of-input" multiple="multiple">'; foreach ($of_categories_obj as $of_cat) { $selected = ''; if ($post_meta) { foreach ($post_meta as $a => $b) { if ($b == $of_cat->cat_ID) { $selected = ' selected="selected"'; } } } $output .= '<option' . $selected . ' class="of-input" value="' . $of_cat->cat_ID . '">' . $of_cat->cat_name . '</option>'; } $output .= '</select>'; break; case 'gallery_items': if ($meta_box_value != '') { $meta_box_array = explode(',', $meta_box_value); } $output .= '<input id="gallery_upload" class="button-primary" value="Browse">'; $output .= '<ul class="gallery_items_wrap">'; if (isset($meta_box_array) && count($meta_box_array) != 0) { $i = 0; foreach ($meta_box_array as $id) { $i++; if ($i == 1 || $i == count($meta_box_array)) { continue; } $image_wp = wp_get_attachment_image_src($id, 'thumbnail', true); $output .= '<li><img data-image="' . $id . '" src="' . $image_wp[0] . '"/><a class="image_remove"></a></li>'; } } $output .= '</ul>'; $output .= '<input id="gallery_items" class="hidden" type="text" value="' . $meta_box_value . '" name="gallery_items">'; break; case "range": $output .= '<div class="range-input-container">'; $output .= '<input type="range" name="' . $value['id'] . '" value="'; $val = $value['std']; $std = get_post_meta($post->ID, $value['id'] . '_value', true); if ($std) { $val = $std; } $output .= $val; if (isset($value['min'])) { $output .= '" min="' . $value['min']; } if (isset($value['max'])) { $output .= '" max="' . $value['max']; } if (isset($value['step'])) { $output .= '" step="' . $value['step']; } $output .= '" />'; if (isset($value['unit'])) { $output .= '<span>' . $value['unit'] . '</span>'; } $output .= '</div>'; $output .= '<div class="clearboth"></div>'; break; case 'select_sidebar': $sidebars = get_theme_option('custom_sidebars'); if (!empty($sidebars)) { $sidebars_array = explode(',', $sidebars); } $output .= '<select class="of-input" name="' . $value['id'] . '" id="' . $value['id'] . '">'; $selected_value = get_post_meta($post->ID, $value['id'] . '_value', true); $output .= '<option value="off">off</option>'; if (!empty($sidebars)) { foreach ($sidebars_array as $option) { $selected = ''; if ($selected_value == $option) { $selected = ' selected="selected"'; } $output .= '<option' . $selected . ' value="' . $option . '">'; $output .= $option; $output .= '</option>'; } } $output .= '</select>'; break; case 'select_footer': $footers = get_theme_option("adm_custom_footers_name"); $custom_footer_layout = get_theme_option("adm_custom_footers_layout"); $footers_array = array(); if (!empty($footers)) { $footers_array = explode(',', $footers); } if (!empty($custom_footer_layout)) { $custom_footer_layout_array = explode(',', $custom_footer_layout); } $output .= '<select class="of-input" name="' . $value['id'] . '" id="' . $value['id'] . '">'; $selected_value = get_meta_option($value['id']); for ($i = 0; $i < count($footers_array) - 1; $i++) { $selected = ''; if ($selected_value == $footers_array[$i] . ',' . $custom_footer_layout_array[$i]) { $selected = ' selected="selected"'; } $output .= '<option' . $selected . ' value="' . $footers_array[$i] . ',' . $custom_footer_layout_array[$i] . '">'; $output .= $footers_array[$i]; $output .= '</option>'; } $output .= '</select>'; break; case 'select_slideshow': $args = array("post_type" => "gallery", "numberposts" => "-1"); $posts_obj = get_posts($args); $output .= '<select class="of-input" name="' . $value['id'] . '" id="' . $value['id'] . '">'; $selected_value = get_post_meta($post->ID, $value['id'] . '_value', true); if ($value['id'] == 'back_gallery' || $value['id'] == 'back_slideshow') { if ($selected_value == 'default') { $output .= '<option selected="selected" value="default">default</option>'; } else { $output .= '<option value="default">default</option>'; } } foreach ($posts_obj as $cat) { $selected = ''; if ($selected_value == $cat->ID) { $selected = ' selected="selected"'; } $output .= '<option' . $selected . ' value="' . $cat->ID . '">'; $output .= $cat->post_title; $output .= '</option>'; } $output .= '</select>'; 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 class="of-input" name="' . $value['id'] . '" id="' . $value['id'] . '" cols="' . $cols . '" rows="8">' . $meta_box_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="of-input of-radio" type="radio" name="' . $value['id'] . '" value="' . $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 of-input" name="' . $value['id'] . '" id="' . $value['id'] . '" value="true" ' . $checked . ' />'; break; case "multicheck": $std = $value['std']; foreach ($value['options'] as $key => $option) { $of_key = $value['id'] . '_' . $key; $saved_std = get_option($of_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 of-input" name="' . $of_key . '" id="' . $of_key . '" value="true" ' . $checked . ' /><label for="' . $of_key . '">' . $option . '</label><br />'; } break; case 'upload': $output .= '<div class="op_upload_wrap" >'; $output .= '<input id="' . $value['id'] . '" name="' . $value['id'] . '" value="' . get_meta_option($value['id']) . '" />'; $output .= '<button class="button-primary">Browse</button>'; $output .= '</div>'; break; case "upload_min": $output .= optionsframework_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="of-color" name="' . $value['id'] . '" id="' . $value['id'] . '" type="text" value="' . $meta_box_value . '" />'; break; case "images": $i = 0; $select_value = get_meta_option($value['id']); $output .= '<ul class="checkbox-list">'; foreach ($value['options'] as $key => $option) { $i++; $checked = ''; $selected = ''; if ($select_value != '') { if ($select_value == $key) { $checked = ' checked'; $selected = 'of-radio-img-selected'; } } else { if ($value['std'] == $key) { $checked = ' checked'; $selected = 'of-radio-img-selected'; } elseif ($i == 1 && !isset($select_value)) { $checked = ' checked'; $selected = 'of-radio-img-selected'; } elseif ($i == 1 && $value['std'] == '') { $checked = ' checked'; $selected = 'of-radio-img-selected'; } else { $checked = ''; } } $output .= '<li class="' . $checked . '">'; $output .= '<input type="radio" id="of-radio-img-' . $value['id'] . $i . '" class="checkbox of-radio-img-radio" value="' . $key . '" name="' . $value['id'] . '" ' . $checked . ' />'; $output .= '<img src="' . $option['url'] . '" alt="" class="of-radio-img-img ' . $selected . '" onClick="document.getElementById(\'of-radio-img-' . $value['id'] . $i . '\').checked = true;" />'; $output .= '<div class="of-radio-img-label">' . $option['desc'] . '</div>'; $output .= '</li>'; } $output .= '</ul>'; break; case "info": $default = $value['std']; $output .= $default; break; case "heading": if ($counter >= 2) { $output .= '</div>' . "\n"; } $jquery_click_hook = ereg_replace("[^A-Za-z0-9]", "", strtolower($value['name'])); $jquery_click_hook = "of-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 . '"><h2>' . $value['name'] . '</h2>' . "\n"; break; } $output .= '</div>'; if (!isset($value['desc'])) { $value['desc'] = ''; } $output .= '<div class="description">' . $value['desc'] . '</div>'; $output .= '</div></div>'; } echo $output; }