PageRenderTime 55ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/themes/gentle/massive-panel/theme-interface.php

https://github.com/kikaendeavor/wordpress
PHP | 609 lines | 451 code | 109 blank | 49 comment | 157 complexity | 9edacc7210141ce967befb7c5c8d1682 MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0, AGPL-1.0, LGPL-2.1
  1. <?php
  2. function mp_display_content() {
  3. global $allowedtags;
  4. global $shortname;
  5. $shortname = "gentle";
  6. // get the settings section array
  7. $settings_output = mp_get_settings();
  8. $mp_option_name = $settings_output[$shortname.'_option_name'];
  9. $mp_settings = get_option($mp_option_name);
  10. //print_r($mp_settings);
  11. //echo $mp_option_name;
  12. if(isset($mp_settings['id'])) {
  13. $option_name = $mp_settings['id'];
  14. } else {
  15. $option_name = $mp_option_name;
  16. }
  17. // echo $option_name;
  18. $settings = get_option($option_name);
  19. $options = mp_options();
  20. $counter = 0;
  21. $menu = '<ul>';
  22. $tabs = '';
  23. $output = '';
  24. $header = '';
  25. $section_name = '';
  26. $begin_tabs = true;
  27. $desc = '';
  28. $hide = 'false';
  29. foreach($options as $value) {
  30. $counter++;
  31. $val = ''; // used to store save value of a field;
  32. $select_value = '';
  33. $checked = '';
  34. $desc = 'right';
  35. $hide = 'false';
  36. if (isset( $value['desc-pos'])) {
  37. $desc = $value['desc-pos'];
  38. }
  39. // Wrap all options
  40. if (($value['type'] != "heading") && ($value['type'] != "section") && ($value['type'] != "top-header") && ($value['type'] != "top-socials")) {
  41. // convert ids to lowercase with no spaces
  42. $value['id'] = preg_replace('/\W/', '', strtolower($value['id']) );
  43. $id = 'field-' . $value['id'];
  44. $class = 'field ';
  45. if ( isset( $value['type'] ) ) {
  46. $class .= ' field-' . $value['type'];
  47. }
  48. if ( isset( $value['class'] ) ) {
  49. $class .= ' ' . $value['class'];
  50. }
  51. $output .= '<div id="' . esc_attr( $id ) .'" class="' . esc_attr( $class ) . '">'."\n";
  52. if($value['type'] != 'info')
  53. $output .= '<h4 class="heading">' . esc_html( $value['name'] ) . '</h4>' . "\n";
  54. else
  55. $output .= '<h4 class="heading"></h4>' . "\n";
  56. if($value['type'] == "choose-sidebar") {
  57. $output .= '<div class="option">' . "\n" . '<div class="controls controls-sidebar">' . "\n";
  58. } elseif ($value['type'] == "choose-portfolio") {
  59. $output .= '<div class="option">' . "\n" . '<div class="controls controls-portfolio">' . "\n";
  60. } else {
  61. $output .= '<div class="option">' . "\n" . '<div class="controls">' . "\n";
  62. }
  63. }
  64. // Set default value to $val
  65. if (isset($value['std'])) {
  66. $val = $value['std'];
  67. }
  68. // If the option is already saved, ovveride $val
  69. if (($value['type'] != 'heading') && ($value['type'] != "section") && ($value['type'] != 'info') && ($value['type'] != "top-header") && ($value['type'] != "top-socials") ) {
  70. if ( isset($settings[($value['id'])]) ) {
  71. $val = $settings[($value['id'])];
  72. // Striping slashes of non-array options
  73. if (!is_array($val) ) {
  74. $val = stripslashes($val);
  75. }
  76. }
  77. }
  78. if(isset($value['hide']) && $value['hide']['state'] == 'true') {
  79. $hide = 'true';
  80. //print_r($settings[($value['id'].'_checkbox')]);
  81. if(isset($value['hide']['related'])) {
  82. $output .= '<div class="mp-related-object" style="display: none;">'.$value['hide']['related'].'</div>';
  83. }
  84. if(isset($settings[($value['id'].'_checkbox')])) {
  85. $output .= '<input id="' . esc_attr( $value['id'] ) . '_checkbox" class="checkbox-ios-style of-input hide-checkbox" type="checkbox" name="' . esc_attr( $option_name . '[' . $value['id'] . '_checkbox]' ) . '" '. checked(stripslashes($settings[($value['id'].'_checkbox')]), 1, false) .' />';
  86. } elseif(isset($value['hide']['std']) && $value['hide']['std'] == 'checked') {
  87. $output .= '<input id="' . esc_attr( $value['id'] ) . '_checkbox" class="checkbox-ios-style of-input hide-checkbox" type="checkbox" name="' . esc_attr( $option_name . '[' . $value['id'] . '_checkbox]' ) . '" checked />';
  88. } else {
  89. $output .= '<input id="' . esc_attr( $value['id'] ) . '_checkbox" class="checkbox-ios-style of-input hide-checkbox" type="checkbox" name="' . esc_attr( $option_name . '[' . $value['id'] . '_checkbox]' ) . '"/>';
  90. }
  91. $output .= '<div class="description desc-hide">' . wp_kses( $value['hide']['desc'], $allowedtags) . '</div>'."\n";
  92. $output .= '<div class="'.$value['id'].'_wrap hide-wrap">';
  93. } else {
  94. $hide = 'false';
  95. }
  96. $description = '';
  97. if ( isset( $value['desc'] ) ) {
  98. $description = $value['desc'];
  99. }
  100. if($desc == 'top') {
  101. $output .= '<div class="description-top">' . wp_kses( $description, $allowedtags) . '</div>'."\n";
  102. }
  103. switch ($value['type']) {
  104. // Basic text input
  105. case 'text-small':
  106. $output .= '<input id="' . esc_attr( $value['id'] ) . '" class="mp-input-small mp-input-border" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" type="text" value="' . esc_attr( $val ) . '" />';
  107. break;
  108. case 'text-big':
  109. /*$desc = 'bottom';*/
  110. $output .= '<input id="' . esc_attr( $value['id'] ) . '" class="mp-input-big mp-input-border" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" type="text" value="' . esc_attr( $val ) . '" />';
  111. break;
  112. // Textarea
  113. case 'textarea':
  114. $cols = '35';
  115. $ta_value = '';
  116. $val = stripslashes($val);
  117. $output .= '<textarea id="' . $value['id'] . '" class="mp-textarea mp-input-border displayall" name="' . $option_name . '[' . $value['id'] . ']' . '" cols="'. $cols. '" rows="8">' . $val . '</textarea>';
  118. break;
  119. // Textarea Big
  120. case 'textarea-big':
  121. $cols = '86';
  122. $ta_value = '';
  123. $val = stripslashes($val);
  124. $output .= '<textarea id="' . $value['id'] . '" class="mp-textarea mp-input-border displayall" name="' . $option_name . '[' . $value['id'] . ']' . '" cols="'. $cols. '" rows="8">' . $val . '</textarea>';
  125. break;
  126. // Select Box
  127. case "select":
  128. $output .= '<select class="mp-dropdown" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" id="' . esc_attr( $value['id'] ) . '">';
  129. foreach ($value['options'] as $key => $option ) {
  130. $selected = '';
  131. if( $val != '' ) {
  132. if ( $val == $key) {
  133. $selected = ' selected="selected"';
  134. }
  135. }
  136. $output .= '<option'. $selected .' value="' . esc_attr( $key ) . '">' . esc_html( $option ) . '</option>';
  137. }
  138. $output .= '</select>';
  139. break;
  140. // Radio Box
  141. case "radio":
  142. $name = $option_name .'['. $value['id'] .']';
  143. foreach ($value['options'] as $key => $option) {
  144. $id = $option_name . '-' . $value['id'] .'-'. $key;
  145. $output .= '<input class="mp-radio" type="radio" name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" value="'. esc_attr( $key ) . '" '. checked( $val, $key, false) .' /><label class="mp-radio-label" for="' . esc_attr( $id ) . '">' . esc_html( $option ) . '</label>';
  146. }
  147. break;
  148. // Checkbox
  149. case "checkbox":
  150. $output .= '<input id="' . esc_attr( $value['id'] ) . '" class="checkbox of-input" type="checkbox" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" '. checked($val, 1, false) .' />';
  151. break;
  152. // Checkbox iOS
  153. case "checkbox-ios":
  154. // $output .= '<script type="text/javascript" charset="utf-8"> jQuery(window).load(function($) {';
  155. // $output .= " $(':checkbox').iphoneStyle();";
  156. // $output .= '});</script>';
  157. $output .= '<input id="' . esc_attr( $value['id'] ) . '" class="checkbox-ios-style of-input" type="checkbox" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" '. checked($val, 1, false) .' />';
  158. break;
  159. // Multicheck
  160. case "multicheck":
  161. foreach ($value['options'] as $key => $option) {
  162. $checked = '';
  163. $label = $option;
  164. $option = preg_replace('/\W/', '', strtolower($key));
  165. $id = $option_name . '-' . $value['id'] . '-'. $option;
  166. $name = $option_name . '[' . $value['id'] . '][' . $option .']';
  167. if ( isset($val[$option]) ) {
  168. $checked = checked($val[$option], 1, false);
  169. } else {
  170. $checked = 'false';
  171. }
  172. $output .= '<input id="' . esc_attr( $id ) . '" class="checkbox mp-input-multicheck" type="checkbox" name="' . esc_attr( $name ) . '"checked=" ' . $checked . '" /><label class="mp-input-multicheck-label" for="' . esc_attr( $id ) . '">' . esc_html( $label ) . '</label>';
  173. }
  174. break;
  175. // module to setup sidebar position for each page
  176. case "choose-sidebar":
  177. $output .= '<select class="mp-dropdown mp-dropdown-sidebar" name="' . esc_attr( $option_name . '[' . $value['id'] . '][sb_choose_' . $value['id'] . ']' ) . '" id="' . esc_attr( $value['id'] ) . '_choose_sb">';
  178. //print_r($val);
  179. foreach ($value['options-pages'] as $key => $option) {
  180. $selected = '';
  181. if( $val != '' ) {
  182. if ( $val['sb_choose_' . $value['id']] == $key) {
  183. $selected = ' selected="selected"';
  184. }
  185. }
  186. $output .= '<option'. $selected .' value="' . esc_attr( $key ) . '">' . esc_html( $option ) . '</option>';
  187. }
  188. $output .= '</select>';
  189. // end select
  190. $template_url = get_template_directory_uri();
  191. foreach ($value['options-pages'] as $key => $option) {
  192. $radio_set_index = $key;
  193. $output .= '<div class="radio_set" id="radio_set_' . $radio_set_index . '" style="display:none;">';
  194. $checked = false;
  195. foreach ($value['options-radio'] as $key => $option) {
  196. $name = $option_name.'['. $value['id'] .'][radio_sb_' . $radio_set_index.']';
  197. $id = $option_name . '_' . $value['id'] .'_'. $key. '_' .$radio_set_index ;
  198. //print_r($radio_set_index." / ");
  199. $output .= '<div class="mp-section-sidebar"><img class="mp-image-sidebar" src="' . $template_url . '/massive-panel/images/sidebar-' . $key . '.png"/>';
  200. if(isset($val['radio_sb_' . $radio_set_index]) && $val['radio_sb_' . $radio_set_index] == $key && !$checked){
  201. $output .= '<input class="mp-radio mp-radio-sidebar" type="radio" name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" value="'. esc_attr( $key ) . '" checked/>';
  202. $checked = true;
  203. } elseif($key == "right" && !$checked) { // default checked
  204. $output .= '<input class="mp-radio mp-radio-sidebar" type="radio" name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" value="'. esc_attr( $key ) . '" checked/>';
  205. } else {
  206. $output .= '<input class="mp-radio mp-radio-sidebar" type="radio" name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" value="'. esc_attr( $key ) . '"/>';
  207. }
  208. $output .= '<label class="mp-radio-label mp-label-sidebar" for="' . esc_attr( $id ) . '">' . esc_html( $option ) . '</label></div>';
  209. }
  210. $output .= '</div>';
  211. }
  212. // sidebar checkbox
  213. foreach ($value['options-pages'] as $key => $option) {
  214. $radio_set_index = $key;
  215. $output .= '<div class="layout_sidebar_radio" id="layout_sidebar_radio_' . $radio_set_index . '" style="display:none;">';
  216. $checked = false;
  217. $name = $option_name.'['. $value['id'] .'][sidebar_' . $radio_set_index.']';
  218. $id = $option_name . '_' . $value['id'] .'_' .$radio_set_index. '_sidebar';
  219. if(isset($val['sidebar_' . $radio_set_index]) && $val['sidebar_' . $radio_set_index] == "on" && !$checked){
  220. $output .= '<input class="mp-checkbox mp-radio-sidebar-unique" type="checkbox" name="' .$name. '" id="' . esc_attr( $id ) . '" checked/>';
  221. $checked = true;
  222. } else {
  223. $output .= '<input class="mp-checkbox mp-radio-sidebar-unique" type="checkbox" name="' .$name. '" id="' . esc_attr( $id ) . '" />';
  224. }
  225. $output .= '<label class="mp-layout-label mp-label-sidebar-unique" for="' . esc_attr( $id ) . '">' . esc_html($value['sidebar-unique-description'] ) . '</label></div>';
  226. }
  227. // footer checkbox
  228. foreach ($value['options-pages'] as $key => $option) {
  229. $radio_set_index = $key;
  230. $output .= '<div class="layout_footer_radio" id="layout_footer_radio_' . $radio_set_index . '" style="display:none;">';
  231. $checked = false;
  232. $name = $option_name.'['. $value['id'] .'][footer_' . $radio_set_index.']';
  233. $id = $option_name . '_' . $value['id'] .'_' .$radio_set_index. '_footer';
  234. if(isset($val['footer_' . $radio_set_index]) && $val['footer_' . $radio_set_index] == "on" && !$checked){
  235. $output .= '<input class="mp-checkbox mp-radio-footer-unique" type="checkbox" name="' .$name. '" id="' . esc_attr( $id ) . '" checked/>';
  236. $checked = true;
  237. } else {
  238. $output .= '<input class="mp-checkbox mp-radio-footer-unique" type="checkbox" name="' .$name. '" id="' . esc_attr( $id ) . '" />';
  239. }
  240. $output .= '<label class="mp-layout-label mp-label-footer-unique" for="' . esc_attr( $id ) . '">' . esc_html($value['footer-unique-description'] ) . '</label></div>';
  241. }
  242. // footer columns select
  243. foreach ($value['options-pages'] as $key => $option) {
  244. $columns_set_index = $key;
  245. $output .= '<div id="unique_footer_columns_' .$columns_set_index. '" class="unique_footer_columns" style="display:none;">';
  246. $output .= '<select class="mp-dropdown mp-dropdown-footer-columns" name="' . esc_attr( $option_name . '[' . $value['id'] . '][footer_columns_' . $columns_set_index . ']' ) . '" id="' . esc_attr( $columns_set_index ) . '_choose_columns_number">';
  247. //print_r($val);
  248. foreach ($value['options-columns'] as $key => $option) {
  249. $selected = '';
  250. if( $val != '' ) {
  251. if ( isset($val['footer_columns_' . $columns_set_index]) && $val['footer_columns_' . $columns_set_index] == $key) {
  252. $selected = ' selected="selected"';
  253. }
  254. }
  255. $output .= '<option'. $selected .' value="' . esc_attr( $key ) . '">' . esc_html( $option ) . '</option>';
  256. }
  257. $output .= '</select>';
  258. $output .= '<label class="mp-layout-label mp-label-footer-columns" for="' . esc_attr( $id ) . '">' . esc_html($value['footer-columns-decription'] ) . '</label></div>';
  259. }
  260. break;
  261. case "choose-sidebar-small":
  262. $output .= '<select class="mp-dropdown mp-dropdown-sidebar-small" name="' . esc_attr( $option_name . '[' . $value['id'] . '][sb_choose_' . $value['id'] . ']' ) . '" id="' . esc_attr( $value['id'] ) . '_choose_sb">';
  263. //print_r($val);
  264. foreach ($value['options-pages'] as $key => $option) {
  265. $selected = '';
  266. if( $val != '' ) {
  267. if ( $val['sb_choose_' . $value['id']] == $key) {
  268. $selected = ' selected="selected"';
  269. }
  270. }
  271. $output .= '<option'. $selected .' value="' . esc_attr( $key ) . '">' . esc_html( $option ) . '</option>';
  272. }
  273. $output .= '</select>';
  274. // end select
  275. $template_url = get_template_directory_uri();
  276. foreach ($value['options-pages'] as $key => $option) {
  277. $radio_set_index = $key;
  278. $output .= '<div class="radio_set_small" id="radio_set_small_' . $radio_set_index . '" style="display:none;">';
  279. $checked = false;
  280. foreach ($value['options-radio'] as $key => $option) {
  281. $name = $option_name.'['. $value['id'] .'][radio_sb_' . $radio_set_index.']';
  282. $id = $option_name . '_' . $value['id'] .'_'. $key. '_' .$radio_set_index ;
  283. //print_r($radio_set_index." / ");
  284. $output .= '<div class="mp-section-sidebar"><img class="mp-image-sidebar" src="' . $template_url . '/massive-panel/images/sidebar-' . $key . '.png"/>';
  285. if(isset($val['radio_sb_' . $radio_set_index]) && $val['radio_sb_' . $radio_set_index] == $key && !$checked){
  286. $output .= '<input class="mp-radio mp-radio-sidebar" type="radio" name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" value="'. esc_attr( $key ) . '" checked/>';
  287. $checked = true;
  288. } elseif($key == "right" && !$checked) { // default checked
  289. $output .= '<input class="mp-radio mp-radio-sidebar" type="radio" name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" value="'. esc_attr( $key ) . '" checked/>';
  290. } else {
  291. $output .= '<input class="mp-radio mp-radio-sidebar" type="radio" name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" value="'. esc_attr( $key ) . '"/>';
  292. }
  293. $output .= '<label class="mp-radio-label mp-label-sidebar" for="' . esc_attr( $id ) . '">' . esc_html( $option ) . '</label></div>';
  294. }
  295. $output .= '</div>';
  296. }
  297. break;
  298. // module to setup portfolio settings like number of columns, number of posts ect.
  299. case "choose-portfolio":
  300. //$desc = 'top';
  301. $columns_4 = array("4" => "4", "8" => "8", "12" => "12", "16" => "16" , "20" => "20");
  302. $columns_3 = array("3" => "3", "6" => "6", "9" => "9", "12" => "12");
  303. $columns_2 = array("2" => "2", "4" => "4", "6" => "6", "8" => "8", "10" => "10");
  304. $columns_1 = array("1" => "1", "2" => "2", "3" => "3", "4" => "4", "5" => "5", "6" => "6", "7" => "7", "8" => "8", "9" => "9", "10" => "10" );
  305. $output .= '<div class="portfolio-section"><label class="mp-portfolio-label">' . esc_attr( $value['desc-portfolio-page'] ) . '</label><select class="mp-dropdown mp-dropdown-portfolio" name="' . esc_attr( $option_name . '[' . $value['id'] . '][portfolio_choose_' . $value['id'] . ']' ) . '" id="' . esc_attr( $value['id'] ) . '_choose_portfolio">';
  306. //print_r($val);
  307. foreach ($value['portfolio-pages'] as $key => $option) {
  308. $selected = '';
  309. if( $val != '' ) {
  310. if ( isset($val['portfolio_choose_' . $value['id']]) && $val['portfolio_choose_' . $value['id']] == $key) {
  311. $selected = ' selected="selected"';
  312. }
  313. }
  314. $output .= '<option'. $selected .' value="' . esc_attr( $key ) . '">' . esc_html( $option ) . '</option>';
  315. }
  316. $output .= '</select></div>';
  317. // end select
  318. foreach ($value['portfolio-pages'] as $key => $option) {
  319. $radio_set_index = $key;
  320. $output .= '<div class="portfolio_option_set" id="portfolio_set_' . $radio_set_index . '" style="display:none;">';
  321. //$checked = false;
  322. $output .= '<div class="portfolio-section"><select class="mp-dropdown mp-dropdown-portfolio-columns" name="' . esc_attr( $option_name . '[' . $value['id'] . '][portfolio_columns_' . $radio_set_index . ']' ) . '" id="' . esc_attr( $value['id'] ) . '_portfolio_columns">';
  323. foreach ($value['options-columns'] as $key => $option) {
  324. $selected = '';
  325. if( $val != '' ) {
  326. if ( isset($val['portfolio_columns_' . $radio_set_index]) && $val['portfolio_columns_' . $radio_set_index] == $key) {
  327. $selected = ' selected="selected"';
  328. }
  329. }
  330. $output .= '<option'. $selected .' value="' . esc_attr( $option ) . '">' . esc_html( $option ) . '</option>';
  331. }
  332. $output .= '</select><label class="mp-portfolio-label">' . esc_attr( $value['desc-columns'] ) . '</label></div>';
  333. $array = array();
  334. $output .= '<div class="portfolio-section"><label class="mp-portfolio-label">' . esc_attr( $value['desc-posts'] ) . '</label>';
  335. for($i = 1; $i < 5; $i++){
  336. $output .= '<select class="mp-dropdown mp-dropdown-portfolio-posts mp_portfolio_posts_' . esc_attr( $i ) . '" name="' . esc_attr( $option_name . '[' . $value['id'] . '][portfolio_posts_' . $radio_set_index . '_' . $i . ']' ) . '" id="mp_portfolio_posts_' . esc_attr( $i ) . '" style="display:none;">';
  337. if($i == 1)
  338. $array = $columns_1;
  339. elseif($i == 2)
  340. $array = $columns_2;
  341. elseif($i == 3)
  342. $array = $columns_3;
  343. elseif($i == 4)
  344. $array = $columns_4;
  345. foreach ($array as $key => $option) {
  346. $selected = '';
  347. if( $val != '' ) {
  348. if ( isset($val['portfolio_posts_' . $radio_set_index . '_' . $i ]) && $val['portfolio_posts_' . $radio_set_index . '_' . $i] == $key) {
  349. $selected = ' selected="selected"';
  350. }
  351. }
  352. $output .= '<option'. $selected .' value="' . esc_attr( $option ) . '">' . esc_html( $option ) . '</option>';
  353. }
  354. $output .= '</select>';
  355. }
  356. $output .= '</div>';
  357. $output .= '<div class="portfolio-section"><label class="mp-portfolio-label">' . esc_attr( $value['desc-categories'] ) . '</label>';
  358. $index = 0;
  359. foreach ($value['options-categories'] as $key => $option) {
  360. $name = $option_name.'['. $value['id'] .'][category_portfolio_' . $radio_set_index.'][' . $key . ']';
  361. $id = $option_name . '_' . $value['id'] .'_'. $key. '_' .$radio_set_index ;
  362. $output .= '<div class="mp-checkboxes-portfolio">';
  363. if(isset($val['category_portfolio_' . $radio_set_index]) && isset($val['category_portfolio_' . $radio_set_index][$key]) && $val['category_portfolio_' . $radio_set_index][$key] == $option){
  364. if($index == 0) {
  365. $output .= '<input class="checkbox mp-checkbox checkbox-first" type="checkbox" name="' . esc_attr( $name ) . esc_attr( $key ) . '" id="' . esc_attr( $id ) . '" value="'. esc_attr( $option ) . '" checked/>';
  366. } else {
  367. $output .= '<input class="checkbox mp-checkbox" type="checkbox" name="' . esc_attr( $name ) . esc_attr( $key ) . '" id="' . esc_attr( $id ) . '" value="'. esc_attr( $option ) . '" checked/>';
  368. }
  369. } else {
  370. if($index == 0) {
  371. $output .= '<input class="checkbox mp-checkbox checkbox-first" type="checkbox" name="' . esc_attr( $name ) . esc_attr( $key ) . '" id="' . esc_attr( $id ) . '" value="'. esc_attr( $option ) . '"/>';
  372. } else {
  373. $output .= '<input class="checkbox mp-checkbox" type="checkbox" name="' . esc_attr( $name ) . esc_attr( $key ) . '" id="' . esc_attr( $id ) . '" value="'. esc_attr( $option ) . '"/>';
  374. }
  375. }
  376. if($index == 0){
  377. $output .= '<label class="mp-checkbox-label label-first" for="' . esc_attr( $id ) . '">' . esc_html( $option ) . '</label></div>';
  378. } else {
  379. $output .= '<label class="mp-checkbox-label" for="' . esc_attr( $id ) . '">' . esc_html( $option ) . '</label></div>';
  380. }
  381. $index++;
  382. }
  383. $output .= '</div>';
  384. $output .= '</div>';
  385. }
  386. break;
  387. // multi checkbox
  388. case "multi-checkbox":
  389. foreach ($value['options'] as $key => $option) {
  390. $name = $option_name.'['. $value['id'] .'][' . $key . ']';
  391. $id = $option_name . '_' . $value['id'] .'_'. $key ;
  392. if( isset($val[$key]) && $val[$key] == $option){
  393. $output .= '<input class="multi-checkbox mp-checkbox" type="checkbox" name="' . esc_attr( $name ) . esc_attr( $key ) . '" id="' . esc_attr( $id ) . '" value="'. esc_attr( $option ) . '" checked/>';
  394. } else {
  395. $output .= '<input class="multi-checkbox mp-checkbox" type="checkbox" name="' . esc_attr( $name ) . esc_attr( $key ) . '" id="' . esc_attr( $id ) . '" value="'. esc_attr( $option ) . '"/>';
  396. }
  397. $output .= '<label class="mp-checkbox-label" for="' . esc_attr( $id ) . '">' . esc_html( $option ) . '</label>';
  398. }
  399. break;
  400. // Uploader
  401. case "upload":
  402. $output .= mp_medialibrary_uploader($value['id'], $val, null); // New AJAX Uploader using Media Library
  403. break;
  404. // Multi-Uploader
  405. case "multi-upload":
  406. $output .= mp_medialibrary_multi_uploader($value['id'], $val, null); // New AJAX Uploader using Media Library
  407. break;
  408. // image chooser
  409. case "choose-image":
  410. $name = $option_name .'['. $value['id'] .']';
  411. foreach($value['options'] as $key => $option){
  412. //echo " ".$val." != ".$option." | ";
  413. $output .= '<div class="option-image-element"><div class="option-image-frame"></div><img src="'.get_template_directory_uri().'/massive-panel/images/'.$option. '"/>';
  414. $id = $option_name . '-' . $value['id'] .'-'. $key;
  415. $output .= '<input class="mp-radio" type="radio" name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" value="'. esc_attr( $option ) . '" '. checked( $val, $option, false) .' />';
  416. if($value['image-desc'] == "true")
  417. $output .= '<label class="mp-radio-label" for="' . esc_attr( $id ) . '">' . esc_html( $key ) . '</label>';
  418. $output .= '</div>';
  419. }
  420. break;
  421. // Color picker
  422. case "color":
  423. $output .= '<div id="' . esc_attr( $value['id'] . '_picker' ) . '" class="colorSelector"><div style="' . esc_attr( 'background-color:' . $val ) . '"></div></div>';
  424. $output .= '<input class="mp-color mp-input-border" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" id="' . esc_attr( $value['id'] ) . '" type="text" value="' . esc_attr( $val ) . '" />';
  425. break;
  426. // Info
  427. case "info":
  428. $output .= '<span id="' .esc_attr( $value['id']). '" class="info box-' .$value['color']. '">' .$value['desc']. '</span>';
  429. break;
  430. // Heading for Tabs
  431. case "heading":
  432. if($counter >= 2){
  433. $output .= '</div>'."\n";
  434. }
  435. $jquery_click_hook = preg_replace('/\W/', '', strtolower($value['name']) );
  436. $jquery_click_hook = "mp-option-" . $jquery_click_hook;
  437. if($begin_tabs){
  438. $tabs .= '<ul class="tab-group" id="' .$section_name. '-tab">';
  439. $begin_tabs = false;
  440. }
  441. $tabs .= '<li class="button-tab"><a id="'. esc_attr( $jquery_click_hook ) . '-tab" title="' . esc_attr( $value['name'] ) . '" href="' . esc_attr( '#'. $jquery_click_hook ) . '"><span class="tab-bg-left"></span><span class="tab-bg-center"><span class="tab-text">' . esc_html( $value['name'] ) . '</span></span><span class="tab-bg-right"></span></a></li>';
  442. $output .= '<div class="group" id="' . esc_attr( $jquery_click_hook ) . '">';
  443. break;
  444. // Sidebar navigation
  445. case "section":
  446. if($counter >= 2){
  447. $output .= '</div>'."\n";
  448. $tabs .= '</ul>'; // end tabs;
  449. $begin_tabs = true;
  450. }
  451. $jquery_click_hook = preg_replace('/\W/', '', strtolower($value['name']) );
  452. $jquery_click_hook = "mp-section-" . $jquery_click_hook;
  453. $section_name = $jquery_click_hook;
  454. $menu .= '<li class="button-sidebar"><img class="button-icon" src="'.get_template_directory_uri().'/massive-panel/images/icons/'. $value['icon'] .'"/><a id="'. esc_attr( $jquery_click_hook ) . '-button" title="' . esc_attr( $value['name'] ) . '" href="' . esc_attr( '#'. $jquery_click_hook ) . '"><label>' . esc_html( $value['name'] ) . '</label><span class="button-sidebar-bg"></span><span class="empty"></span></a></li>';
  455. $output .= '<div class="section-group" id="' . esc_attr( $jquery_click_hook ) . '">';
  456. break;
  457. case "top-socials":
  458. $header .= '<ul class="socials">';
  459. foreach($value['options'] as $key) {
  460. $header .= '<li class="social"><a href="' .$key[2]. '"><img src="' .get_template_directory_uri().'/massive-panel/images/icons/social/' . $key[0] . '"/></a><span>' . $key[1] . '</span></li>';
  461. }
  462. $header .= '</ul>';
  463. break;
  464. case "top-header":
  465. $header .= '<h2 class="main-header">' . esc_attr( $value['name'] ) . '</h2>';
  466. $header .= '<h3 class="main-desc">' . esc_attr( $value['desc'] ) . '</h3>';
  467. break;
  468. }
  469. if (($value['type'] != "heading") && ($value['type'] != "section") && ($value['type'] != "top-header") && ($value['type'] != "top-socials")) {
  470. if ($value['type'] != "checkbox") {
  471. $output .= '<br/>';
  472. }
  473. // this code is for the descript & help
  474. if (isset($value['help']) && $value['help'] == "true") {
  475. $output .= '</div><div class="help-icon"></div>';
  476. } else {
  477. $output .= '</div>';
  478. }
  479. $description = '';
  480. if ( isset( $value['desc'] ) ) {
  481. $description = $value['desc'];
  482. }
  483. if($desc == 'bottom' && ($value['type'] != "info")) {
  484. $output .= '<div class="description-bottom">' . wp_kses( $description, $allowedtags) . '</div>'."\n";
  485. } elseif($desc == 'right' && ($value['type'] != "info")) {
  486. $output .= '<div class="description">' . wp_kses( $description, $allowedtags) . '</div>'."\n";
  487. }
  488. // the end of description code
  489. if($hide == 'true') {
  490. $output .= '</div>';
  491. }
  492. $output .= '<div class="clear"></div></div></div>'."\n";
  493. }
  494. }
  495. $tabs .= '</ul>';
  496. $menu .= '</ul>';
  497. $output .= '</div>';
  498. return array($output, $menu, $tabs, $header);
  499. }
  500. ?>