inkthemes_optionsframework_machine

-----------------------------------------------------------------------------------.

Description

inkthemes_optionsframework_machine( $options ); 

Parameters (1)

0. $options
The options.

Usage

  1. if ( !function_exists( 'inkthemes_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 = inkthemes_optionsframework_machine($options); 
  9.  

Defined (1)

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

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