optionsframework_machine

The ColorWay Theme optionsframework machine function.

Description

optionsframework_machine( $options ); 

Parameters (1)

0. $options
The options.

Usage

  1. if ( !function_exists( 'optionsframework_machine' ) ) { 
  2. require_once '/functions/admin-interface.php'; 
  3.  
  4. // The options. 
  5. $options = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = optionsframework_machine($options); 
  9.  

Defined (1)

The function is defined in the following location(s).

/functions/admin-interface.php  
  1. function optionsframework_machine($options) { 
  2.  
  3. $counter = 0; 
  4. $menu = ''; 
  5. $output = ''; 
  6. foreach ($options as $value) { 
  7.  
  8. $counter++; 
  9. $val = ''; 
  10. //Start Heading 
  11. if ( $value['type'] != "heading" ) 
  12. $class = ''; if(isset( $value['class'] )) { $class = $value['class']; } 
  13. //$output .= '<div class="section section-'. $value['type'] .'">'."\n".'<div class="option-inner">'."\n"; 
  14. $output .= '<div class="section section-'.$value['type'].' '. $class .'">'."\n"; 
  15. $output .= '<h3 class="heading">'. $value['name'] .'</h3>'."\n"; 
  16. $output .= '<div class="option">'."\n" . '<div class="controls">'."\n"; 
  17.  
  18. }  
  19. //End Heading 
  20. $select_value = '';  
  21. switch ( $value['type'] ) { 
  22.  
  23. case 'text': 
  24. $val = $value['std']; 
  25. $std = get_option($value['id']); 
  26. if ( $std != "") { $val = $std; } 
  27. $output .= '<input class="of-input" name="'. $value['id'] .'" id="'. $value['id'] .'" type="'. $value['type'] .'" value="'. $val .'" />'; 
  28. break; 
  29.  
  30. case 'select': 
  31.  
  32. $output .= '<select class="of-input" name="'. $value['id'] .'" id="'. $value['id'] .'">'; 
  33.  
  34. $select_value = get_option($value['id']); 
  35.  
  36. foreach ($value['options'] as $option) { 
  37.  
  38. $selected = ''; 
  39.  
  40. if($select_value != '') { 
  41. if ( $select_value == $option) { $selected = ' selected="selected"';}  
  42. } else { 
  43. if ( isset($value['std']) ) 
  44. if ($value['std'] == $option) { $selected = ' selected="selected"'; } 
  45.  
  46. $output .= '<option'. $selected .'>'; 
  47. $output .= $option; 
  48. $output .= '</option>'; 
  49.  
  50. }  
  51. $output .= '</select>'; 
  52.  
  53.  
  54. break; 
  55. case 'select2': 
  56.  
  57. $output .= '<select class="of-input" name="'. $value['id'] .'" id="'. $value['id'] .'">'; 
  58.  
  59. $select_value = get_option($value['id']); 
  60.  
  61. foreach ($value['options'] as $option => $name) { 
  62.  
  63. $selected = ''; 
  64.  
  65. if($select_value != '') { 
  66. if ( $select_value == $option) { $selected = ' selected="selected"';}  
  67. } else { 
  68. if ( isset($value['std']) ) 
  69. if ($value['std'] == $option) { $selected = ' selected="selected"'; } 
  70.  
  71. $output .= '<option'. $selected .' value="'.$option.'">'; 
  72. $output .= $name; 
  73. $output .= '</option>'; 
  74.  
  75. }  
  76. $output .= '</select>'; 
  77.  
  78.  
  79. break; 
  80. case 'textarea': 
  81.  
  82. $cols = '8'; 
  83. $ta_value = ''; 
  84.  
  85. if(isset($value['std'])) { 
  86.  
  87. $ta_value = $value['std'];  
  88.  
  89. if(isset($value['options'])) { 
  90. $ta_options = $value['options']; 
  91. if(isset($ta_options['cols'])) { 
  92. $cols = $ta_options['cols']; 
  93. } else { $cols = '8'; } 
  94.  
  95. $std = get_option($value['id']); 
  96. if( $std != "") { $ta_value = stripslashes( $std ); } 
  97. $output .= '<textarea class="of-input" name="'. $value['id'] .'" id="'. $value['id'] .'" cols="'. $cols .'" rows="8">'.$ta_value.'</textarea>'; 
  98.  
  99.  
  100. break; 
  101. case "radio": 
  102.  
  103. $select_value = get_option( $value['id']); 
  104.  
  105. foreach ($value['options'] as $key => $option)  
  106. {  
  107.  
  108. $checked = ''; 
  109. if($select_value != '') { 
  110. if ( $select_value == $key) { $checked = ' checked'; }  
  111. } else { 
  112. if ($value['std'] == $key) { $checked = ' checked'; } 
  113. $output .= '<input class="of-input of-radio" type="radio" name="'. $value['id'] .'" value="'. $key .'" '. $checked .' />' . $option .'<br />'; 
  114.  
  115.  
  116. break; 
  117. case "checkbox":  
  118.  
  119. $std = $value['std'];  
  120.  
  121. $saved_std = get_option($value['id']); 
  122.  
  123. $checked = ''; 
  124.  
  125. if(!empty($saved_std)) { 
  126. if($saved_std == 'true') { 
  127. $checked = 'checked="checked"'; 
  128. else{ 
  129. $checked = ''; 
  130. elseif( $std == 'true') { 
  131. $checked = 'checked="checked"'; 
  132. else { 
  133. $checked = ''; 
  134. $output .= '<input type="checkbox" class="checkbox of-input" name="'. $value['id'] .'" id="'. $value['id'] .'" value="true" '. $checked .' />'; 
  135.  
  136. break; 
  137. case "multicheck": 
  138.  
  139. $std = $value['std'];  
  140.  
  141. foreach ($value['options'] as $key => $option) { 
  142.  
  143. $of_key = $value['id'] . '_' . $key; 
  144. $saved_std = get_option($of_key); 
  145.  
  146. if(!empty($saved_std))  
  147. {  
  148. if($saved_std == 'true') { 
  149. $checked = 'checked="checked"';  
  150. }  
  151. else{ 
  152. $checked = '';  
  153. }  
  154. }  
  155. elseif( $std == $key) { 
  156. $checked = 'checked="checked"'; 
  157. else { 
  158. $checked = ''; } 
  159. $output .= '<input type="checkbox" class="checkbox of-input" name="'. $of_key .'" id="'. $of_key .'" value="true" '. $checked .' /><label for="'. $of_key .'">'. $option .'</label><br />'; 
  160.  
  161. break; 
  162. case "upload": 
  163.  
  164. $output .= optionsframework_uploader_function($value['id'], $value['std'], null); 
  165.  
  166. break; 
  167. case "upload_min": 
  168.  
  169. $output .= optionsframework_uploader_function($value['id'], $value['std'], 'min'); 
  170.  
  171. break; 
  172. case "color": 
  173. $val = $value['std']; 
  174. $stored = get_option( $value['id'] ); 
  175. if ( $stored != "") { $val = $stored; } 
  176. $output .= '<div id="' . $value['id'] . '_picker" class="colorSelector"><div></div></div>'; 
  177. $output .= '<input class="of-color" name="'. $value['id'] .'" id="'. $value['id'] .'" type="text" value="'. $val .'" />'; 
  178. break;  
  179.  
  180. case "typography": 
  181.  
  182. $default = $value['std']; 
  183. $typography_stored = get_option($value['id']); 
  184.  
  185. /** Font Size */ 
  186. $val = $default['size']; 
  187. if ( $typography_stored['size'] != "") { $val = $typography_stored['size']; } 
  188. $output .= '<select class="of-typography of-typography-size" name="'. $value['id'].'_size" id="'. $value['id'].'_size">'; 
  189. for ($i = 9; $i < 71; $i++) {  
  190. if($val == $i) { $active = 'selected="selected"'; } else { $active = ''; } 
  191. $output .= '<option value="'. $i .'" ' . $active . '>'. $i .'px</option>'; } 
  192. $output .= '</select>'; 
  193.  
  194. /** Font Face */ 
  195. $val = $default['face']; 
  196. if ( $typography_stored['face'] != "")  
  197. $val = $typography_stored['face'];  
  198.  
  199. $font01 = '';  
  200. $font02 = '';  
  201. $font03 = '';  
  202. $font04 = '';  
  203. $font05 = '';  
  204. $font06 = '';  
  205. $font07 = '';  
  206. $font08 = ''; 
  207. $font09 = ''; 
  208.  
  209. if (strpos($val, 'Arial, sans-serif') !== false) { $font01 = 'selected="selected"'; } 
  210. if (strpos($val, 'Verdana, Geneva') !== false) { $font02 = 'selected="selected"'; } 
  211. if (strpos($val, 'Trebuchet') !== false) { $font03 = 'selected="selected"'; } 
  212. if (strpos($val, 'Georgia') !== false) { $font04 = 'selected="selected"'; } 
  213. if (strpos($val, 'Times New Roman') !== false) { $font05 = 'selected="selected"'; } 
  214. if (strpos($val, 'Tahoma, Geneva') !== false) { $font06 = 'selected="selected"'; } 
  215. if (strpos($val, 'Palatino') !== false) { $font07 = 'selected="selected"'; } 
  216. if (strpos($val, 'Helvetica') !== false) { $font08 = 'selected="selected"'; } 
  217.  
  218. $output .= '<select class="of-typography of-typography-face" name="'. $value['id'].'_face" id="'. $value['id'].'_face">'; 
  219. $output .= '<option value="Arial, sans-serif" '. $font01 .'>Arial</option>'; 
  220. $output .= '<option value="Verdana, Geneva, sans-serif" '. $font02 .'>Verdana</option>'; 
  221. $output .= '<option value=""Trebuchet MS", Tahoma, sans-serif"'. $font03 .'>Trebuchet</option>'; 
  222. $output .= '<option value="Georgia, serif" '. $font04 .'>Georgia</option>'; 
  223. $output .= '<option value=""Times New Roman", serif"'. $font05 .'>Times New Roman</option>'; 
  224. $output .= '<option value="Tahoma, Geneva, Verdana, sans-serif"'. $font06 .'>Tahoma</option>'; 
  225. $output .= '<option value="Palatino, "Palatino Linotype", serif"'. $font07 .'>Palatino</option>'; 
  226. $output .= '<option value=""Helvetica Neue", Helvetica, sans-serif" '. $font08 .'>Helvetica*</option>'; 
  227. $output .= '</select>'; 
  228.  
  229. /** Font Weight */ 
  230. $val = $default['style']; 
  231. if ( $typography_stored['style'] != "") { $val = $typography_stored['style']; } 
  232. $normal = ''; $italic = ''; $bold = ''; $bolditalic = ''; 
  233. if($val == 'normal') { $normal = 'selected="selected"'; } 
  234. if($val == 'italic') { $italic = 'selected="selected"'; } 
  235. if($val == 'bold') { $bold = 'selected="selected"'; } 
  236. if($val == 'bold italic') { $bolditalic = 'selected="selected"'; } 
  237.  
  238. $output .= '<select class="of-typography of-typography-style" name="'. $value['id'].'_style" id="'. $value['id'].'_style">'; 
  239. $output .= '<option value="normal" '. $normal .'>Normal</option>'; 
  240. $output .= '<option value="italic" '. $italic .'>Italic</option>'; 
  241. $output .= '<option value="bold" '. $bold .'>Bold</option>'; 
  242. $output .= '<option value="bold italic" '. $bolditalic .'>Bold/Italic</option>'; 
  243. $output .= '</select>'; 
  244.  
  245. /** Font Color */ 
  246. $val = $default['color']; 
  247. if ( $typography_stored['color'] != "") { $val = $typography_stored['color']; }  
  248. $output .= '<div id="' . $value['id'] . '_color_picker" class="colorSelector"><div></div></div>'; 
  249. $output .= '<input class="of-color of-typography of-typography-color" name="'. $value['id'] .'_color" id="'. $value['id'] .'_color" type="text" value="'. $val .'" />'; 
  250.  
  251. break;  
  252.  
  253. case "border": 
  254.  
  255. $default = $value['std']; 
  256. $border_stored = get_option( $value['id'] ); 
  257.  
  258. /** Border Width */ 
  259. $val = $default['width']; 
  260. if ( $border_stored['width'] != "") { $val = $border_stored['width']; } 
  261. $output .= '<select class="of-border of-border-width" name="'. $value['id'].'_width" id="'. $value['id'].'_width">'; 
  262. for ($i = 0; $i < 21; $i++) {  
  263. if($val == $i) { $active = 'selected="selected"'; } else { $active = ''; } 
  264. $output .= '<option value="'. $i .'" ' . $active . '>'. $i .'px</option>'; } 
  265. $output .= '</select>'; 
  266.  
  267. /** Border Style */ 
  268. $val = $default['style']; 
  269. if ( $border_stored['style'] != "") { $val = $border_stored['style']; } 
  270. $solid = ''; $dashed = ''; $dotted = ''; 
  271. if($val == 'solid') { $solid = 'selected="selected"'; } 
  272. if($val == 'dashed') { $dashed = 'selected="selected"'; } 
  273. if($val == 'dotted') { $dotted = 'selected="selected"'; } 
  274.  
  275. $output .= '<select class="of-border of-border-style" name="'. $value['id'].'_style" id="'. $value['id'].'_style">'; 
  276. $output .= '<option value="solid" '. $solid .'>Solid</option>'; 
  277. $output .= '<option value="dashed" '. $dashed .'>Dashed</option>'; 
  278. $output .= '<option value="dotted" '. $dotted .'>Dotted</option>'; 
  279. $output .= '</select>'; 
  280.  
  281. /** Border Color */ 
  282. $val = $default['color']; 
  283. if ( $border_stored['color'] != "") { $val = $border_stored['color']; }  
  284. $output .= '<div id="' . $value['id'] . '_color_picker" class="colorSelector"><div></div></div>'; 
  285. $output .= '<input class="of-color of-border of-border-color" name="'. $value['id'] .'_color" id="'. $value['id'] .'_color" type="text" value="'. $val .'" />'; 
  286.  
  287. break;  
  288.  
  289. case "images": 
  290. $i = 0; 
  291. $select_value = get_option( $value['id']); 
  292.  
  293. foreach ($value['options'] as $key => $option)  
  294. {  
  295. $i++; 
  296.  
  297. $checked = ''; 
  298. $selected = ''; 
  299. if($select_value != '') { 
  300. if ( $select_value == $key) { $checked = ' checked'; $selected = 'of-radio-img-selected'; }  
  301. } else { 
  302. if ($value['std'] == $key) { $checked = ' checked'; $selected = 'of-radio-img-selected'; } 
  303. elseif ($i == 1 && !isset($select_value)) { $checked = ' checked'; $selected = 'of-radio-img-selected'; } 
  304. elseif ($i == 1 && $value['std'] == '') { $checked = ' checked'; $selected = 'of-radio-img-selected'; } 
  305. else { $checked = ''; } 
  306. }  
  307.  
  308. $output .= '<span>'; 
  309. $output .= '<input type="radio" id="of-radio-img-' . $value['id'] . $i . '" class="checkbox of-radio-img-radio" value="'.$key.'" name="'. $value['id'].'" '.$checked.' />'; 
  310. $output .= '<div class="of-radio-img-label">'. $key .'</div>'; 
  311. $output .= '<img src="'.$option.'" alt="" class="of-radio-img-img '. $selected .'" onClick="document.getElementById(\'of-radio-img-'. $value['id'] . $i.'\').checked = true;" />'; 
  312. $output .= '</span>'; 
  313.  
  314.  
  315. break;  
  316.  
  317. case "info": 
  318. $default = $value['std']; 
  319. $output .= $default; 
  320. break;  
  321.  
  322. case "heading": 
  323.  
  324. if($counter >= 2) { 
  325. $output .= '</div>'."\n"; 
  326. $jquery_click_hook = ereg_replace("[^A-Za-z0-9]", "", strtolower($value['name']) ); 
  327. $jquery_click_hook = "of-option-" . $jquery_click_hook; 
  328. $menu .= '<li><a title="'. $value['name'] .'" href="#'. $jquery_click_hook .'">'. $value['name'] .'</a></li>'; 
  329. $output .= '<div class="group" id="'. $jquery_click_hook .'"><h2>'.$value['name'].'</h2>'."\n"; 
  330. break;  
  331. }  
  332.  
  333. // if TYPE is an array, formatted into smaller inputs... ie smaller values 
  334. if ( is_array($value['type'])) { 
  335. foreach($value['type'] as $array) { 
  336.  
  337. $id = $array['id'];  
  338. $std = $array['std']; 
  339. $saved_std = get_option($id); 
  340. if($saved_std != $std) {$std = $saved_std;}  
  341. $meta = $array['meta']; 
  342.  
  343. if($array['type'] == 'text') { // Only text at this point 
  344.  
  345. $output .= '<input class="input-text-small of-input" name="'. $id .'" id="'. $id .'" type="text" value="'. $std .'" />';  
  346. $output .= '<span class="meta-two">'.$meta.'</span>'; 
  347. if ( $value['type'] != "heading" ) {  
  348. if ( $value['type'] != "checkbox" )  
  349. {  
  350. $output .= '<br/>'; 
  351. if(!isset($value['desc'])) { $explain_value = ''; } else{ $explain_value = $value['desc']; }  
  352. $output .= '</div><div class="explain">'. $explain_value .'</div>'."\n"; 
  353. $output .= '<div class="clear"> </div></div></div>'."\n"; 
  354.  
  355. $output .= '</div>'; 
  356. return array($output, $menu); 
  357.