ninja_forms_output_tab_metabox

The Ninja Forms ninja forms output tab metabox function.

Description

ninja_forms_output_tab_metabox( $form_id, $slug, $metabox ); 

Parameters (3)

0. $form_id
The form id.
1. $slug
The slug.
2. $metabox
The metabox.

Usage

  1. if ( !function_exists( 'ninja_forms_output_tab_metabox' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ninja-forms/deprecated/includes/admin/output-tab-metabox.php'; 
  3.  
  4. // The form id. 
  5. $form_id = null; 
  6.  
  7. // The slug. 
  8. $slug = null; 
  9.  
  10. // The metabox. 
  11. $metabox = null; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = ninja_forms_output_tab_metabox($form_id, $slug, $metabox); 
  15.  

Defined (1)

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

/deprecated/includes/admin/output-tab-metabox.php  
  1. function ninja_forms_output_tab_metabox($form_id = '', $slug, $metabox) { 
  2. $plugin_settings = nf_get_settings(); 
  3. if($form_id != '') { 
  4. $current_settings = Ninja_Forms()->form($form_id)->get_all_settings(); 
  5. }else{ 
  6. $form_id = ''; 
  7. $current_settings = nf_get_settings(); 
  8.  
  9. $page = $metabox['page']; 
  10. $tab = $metabox['tab']; 
  11.  
  12. $title = $metabox['title']; 
  13. if(isset($metabox['settings'])) { 
  14. $settings = $metabox['settings']; 
  15. }else{ 
  16. $settings = ''; 
  17.  
  18. if(isset($metabox['display_function'])) { 
  19. $display_function = $metabox['display_function']; 
  20. }else{ 
  21. $display_function = ''; 
  22.  
  23. if($metabox['state'] == 'closed') { 
  24. $state = 'display:none;'; 
  25. }else{ 
  26. $state = ''; 
  27.  
  28. if( isset( $plugin_settings['metabox_state'][$page][$tab][$slug] ) ) { 
  29. $state = $plugin_settings['metabox_state'][$page][$tab][$slug]; 
  30.  
  31. if( isset( $metabox['display_container'] ) ) { 
  32. $display_container = $metabox['display_container']; 
  33. }else{ 
  34. $display_container = true; 
  35.  
  36. if( $display_container ) { 
  37. ?> 
  38. <div id="ninja_forms_metabox_<?php echo $slug;?>" class="postbox "> 
  39. <span class="item-controls"> 
  40. <a class="item-edit metabox-item-edit" id="edit_id" title="<?php _e( 'Edit Menu Item', 'ninja-forms' ); ?>" href="#"><?php _e( 'Edit Menu Item', 'ninja-forms' ); ?></a> 
  41. </span> 
  42. <h3 class="hndle"><span><?php _e($title, 'ninja-forms');?></span></h3> 
  43. <div class="inside" style="<?php echo $state;?>"> 
  44. <table class="form-table"> 
  45. <tbody> 
  46. <?php 
  47.  
  48. if( is_array( $settings ) AND !empty( $settings ) ) { 
  49. foreach( $settings as $s ) { 
  50.  
  51. $value = ''; 
  52. if(isset($s['name'])) { 
  53. $name = $s['name']; 
  54. }else{ 
  55. $name = ''; 
  56. $name_array = ''; 
  57. if( strpos( $name, '[') !== false ) { 
  58. $name_array = str_replace( ']', '', $name ); 
  59. $name_array = explode( '[', $name_array ); 
  60. if(isset($s['type'])) { 
  61. $type = $s['type']; 
  62. }else{ 
  63. $type = ''; 
  64. if(isset($s['desc'])) { 
  65. $desc = $s['desc']; 
  66. }else{ 
  67. $desc = ''; 
  68. if(isset($s['help_text'])) { 
  69. $help_text = $s['help_text']; 
  70. }else{ 
  71. $help_text = ''; 
  72. if(isset($s['label'])) { 
  73. $label = $s['label']; 
  74. }else{ 
  75. $label = ''; 
  76. if(isset($s['value'])) { 
  77. $button_text = $s['value']; 
  78. }else{ 
  79. $button_text = $label; 
  80. if(isset($s['class'])) { 
  81. $class = $s['class']; 
  82. }else{ 
  83. $class = 'widefat'; 
  84. if(isset($s['tr_class'])) { 
  85. $tr_class = $s['tr_class']; 
  86. }else{ 
  87. $tr_class = ''; 
  88. if(isset($s['max_file_size'])) { 
  89. $max_file_size = $s['max_file_size']; 
  90. }else{ 
  91. $max_file_size = ''; 
  92. if(isset($s['select_all'])) { 
  93. $select_all = $s['select_all']; 
  94. }else{ 
  95. $select_all = false; 
  96. if(isset($s['default_value'])) { 
  97. $default_value = $s['default_value']; 
  98. }else{ 
  99. $default_value = ''; 
  100. if( isset( $s['style'] ) ) { 
  101. $style = $s['style']; 
  102. }else{ 
  103. $style = ''; 
  104. if(isset($s['size'])) { 
  105. $size = $s['size']; 
  106. }else{ 
  107. $size = ''; 
  108. if(isset($s['min'])) { 
  109. $min = $s['min']; 
  110. }else{ 
  111. $min = 0; 
  112. if(isset($s['max'])) { 
  113. $max = $s['max']; 
  114. }else{ 
  115. $max = ''; 
  116.  
  117. if( is_array( $name_array ) ) { 
  118. $tmp = ''; 
  119. foreach( $name_array as $n ) { 
  120. if( $tmp == '' ) { 
  121. if( isset( $current_settings[$n] ) ) { 
  122. $tmp = $current_settings[$n]; 
  123. }else{ 
  124. if( isset( $tmp[$n] ) ) { 
  125. $tmp = $tmp[$n]; 
  126. $value = (!is_array ($tmp) && !is_object ($tmp)) ? $tmp : ''; 
  127. }else{ 
  128. if(isset($current_settings[$name])) { 
  129. if(is_array($current_settings[$name])) { 
  130. $value = ninja_forms_stripslashes_deep($current_settings[$name]); 
  131. }else{ 
  132. $value = stripslashes($current_settings[$name]); 
  133. }else{ 
  134. $value = ''; 
  135.  
  136. if( $value == '' ) { 
  137. $value = $default_value; 
  138. ?> 
  139.  
  140. <tr id="row_<?php echo $name;?>" <?php if( $tr_class != '' ) { ?>class="<?php echo $tr_class;?>"<?php } ?> <?php if( $style != '' ) { ?> style="<?php echo $style;?>"<?php }?>> 
  141. <?php if ( $s['type'] == 'desc' AND ! $label ) { ?> 
  142. <td colspan="2"> 
  143. <?php } else { ?> 
  144. <th scope="row"> 
  145. <label for="<?php echo $name;?>"><?php echo $label;?></label> 
  146. </th> 
  147. <td> 
  148. <?php } ?> 
  149. <?php 
  150. switch( $s['type'] ) { 
  151. case 'text': 
  152. $value = ninja_forms_esc_html_deep( $value ); 
  153. ?> 
  154.  
  155. <input type="text" class="code <?php echo $class;?>" name="<?php echo $name;?>" id="<?php echo $name;?>" value="<?php echo $value;?>" /> 
  156. <?php if( $help_text != '') { ?> 
  157. <a href="#" class="tooltip"> 
  158. <img id="" class='ninja-forms-help-text' src="<?php echo NINJA_FORMS_URL;?>images/question-ico.gif" title=""> 
  159. <span> 
  160. <img class="callout" src="<?php echo NINJA_FORMS_URL;?>/images/callout.gif" /> 
  161. <?php echo $help_text;?> 
  162. </span> 
  163. </a> 
  164. <?php } 
  165. break; 
  166. case 'number': 
  167. $value = ninja_forms_esc_html_deep( $value ); 
  168. ?> 
  169.  
  170. <input type="number" class="code <?php echo $class;?>" name="<?php echo $name;?>" id="<?php echo $name;?>" value="<?php echo $value;?>" min="<?php echo $min; ?>" max="<?php echo $max; ?>" /> 
  171. <?php if( $help_text != '') { ?> 
  172. <a href="#" class="tooltip"> 
  173. <img id="" class='ninja-forms-help-text' src="<?php echo NINJA_FORMS_URL;?>images/question-ico.gif" title=""> 
  174. <span> 
  175. <img class="callout" src="<?php echo NINJA_FORMS_URL;?>/images/callout.gif" /> 
  176. <?php echo $help_text;?> 
  177. </span> 
  178. </a> 
  179. <?php } 
  180. break; 
  181. case 'select': 
  182. ?> 
  183. <select name="<?php echo $name;?>" id="<?php echo $name;?>" class="<?php echo $class;?>"> 
  184. <?php 
  185. if( is_array( $s['options']) AND !empty( $s['options'] ) ) { 
  186. foreach( $s['options'] as $option ) { 
  187. ?> 
  188. <option value="<?php echo $option['value'];?>" <?php selected($value, $option['value']); ?>><?php echo $option['name'];?></option> 
  189. <?php 
  190. } ?> 
  191. </select> 
  192. <?php if( $help_text != '') { ?> 
  193. <a href="#" class="tooltip"> 
  194. <img id="" class='ninja-forms-help-text' src="<?php echo NINJA_FORMS_URL;?>images/question-ico.gif" title=""> 
  195. <span> 
  196. <img class="callout" src="<?php echo NINJA_FORMS_URL;?>images/callout.gif" /> 
  197. <?php echo $help_text;?> 
  198. </span> 
  199. </a> 
  200. <?php } 
  201. break; 
  202. case 'multi_select': 
  203. if( $value == '' ) { 
  204. $value = array(); 
  205. ?> 
  206.  
  207. <input type="hidden" name="<?php echo $name;?>" value=""> 
  208. <select name="<?php echo $name;?>[]" id="<?php echo $name;?>" class="<?php echo $class;?>" multiple="multiple" size="<?php echo $size;?>"> 
  209. <?php 
  210. if( is_array( $s['options']) AND !empty( $s['options'] ) ) { 
  211. foreach( $s['options'] as $option ) { 
  212. ?> 
  213. <option value="<?php echo $option['value'];?>" <?php selected( in_array( $option['value'], $value ) ); ?>><?php echo $option['name'];?></option> 
  214. <?php 
  215. } ?> 
  216. </select> 
  217. <?php if( $help_text != '') { ?> 
  218. <a href="#" class="tooltip"> 
  219. <img id="" class='ninja-forms-help-text' src="<?php echo NINJA_FORMS_URL;?>images/question-ico.gif" title=""> 
  220. <span> 
  221. <img class="callout" src="<?php echo NINJA_FORMS_URL;?>/images/callout.gif" /> 
  222. <?php echo $help_text;?> 
  223. </span> 
  224. </a> 
  225. <?php } 
  226. break; 
  227. case 'checkbox': 
  228. ?> 
  229. <input type="hidden" name="<?php echo $name;?>" value="0"> 
  230. <input type="checkbox" name="<?php echo $name;?>" value="1" <?php checked($value, 1);?> id="<?php echo $name;?>" class="<?php echo $class;?>"> 
  231. <?php if( $help_text != '') { ?> 
  232. <a href="#" class="tooltip"> 
  233. <img id="" class='ninja-forms-help-text' src="<?php echo NINJA_FORMS_URL;?>images/question-ico.gif" title=""> 
  234. <span> 
  235. <img class="callout" src="<?php echo NINJA_FORMS_URL;?>images/callout.gif" /> 
  236. <?php echo $help_text;?> 
  237. </span> 
  238. </a> 
  239. <?php } 
  240. break; 
  241. case 'checkbox_list': 
  242. if( $value == '' ) { 
  243. $value = array(); 
  244.  
  245. ?> 
  246. <input type="hidden" name="<?php echo $name;?>" value=""> 
  247.  
  248. <?php 
  249. if( $select_all ) { 
  250. ?> 
  251.  
  252. <label> 
  253. <input type="checkbox" name="" value="" id="<?php echo $name;?>_select_all" class="ninja-forms-select-all" title="ninja-forms-<?php echo $name;?>"> 
  254. - <?php _e( 'Select All', 'ninja-forms' );?> 
  255. </label> 
  256.  
  257. <?php 
  258. }else{ 
  259. if( is_array( $s['options'] ) AND isset( $s['options'][0] ) ) { 
  260.  
  261. $option_name = $s['options'][0]['name']; 
  262. $option_value = $s['options'][0]['value']; 
  263.  
  264. ?> 
  265.  
  266. <label> 
  267. <input type="checkbox" class="ninja-forms-<?php echo $name;?> <?php echo $class;?>" name="<?php echo $name;?>[]" value="<?php echo $option_value;?>" <?php checked( in_array( $option_value, $value ) );?> id="<?php echo $option_name;?>"> 
  268. <?php echo $option_name;?> 
  269. </label> 
  270.  
  271. <?php 
  272. ?> 
  273.  
  274. <?php 
  275. if( is_array( $s['options'] ) AND !empty( $s['options'] ) ) { 
  276. $x = 0; 
  277. foreach( $s['options'] as $option ) { 
  278. if( ( !$select_all AND $x > 0 ) OR $select_all ) { 
  279. $option_name = $option['name']; 
  280. $option_value = $option['value']; 
  281. ?> 
  282. <label> 
  283. <input type="checkbox" class="ninja-forms-<?php echo $name;?> <?php echo $class;?>" name="<?php echo $name;?>[]" value="<?php echo $option_value;?>" <?php checked( in_array( $option_value, $value ) );?> id="<?php echo $option_name;?>"> 
  284. <?php echo $option_name;?> 
  285. </label> 
  286. <?php 
  287. $x++; 
  288. break; 
  289. case 'radio': 
  290. if( is_array( $s['options'] ) AND !empty( $s['options'] ) ) { 
  291. $x = 0; ?> 
  292. <?php foreach($s['options'] as $option) { ?> 
  293. <input type="radio" name="<?php echo $name;?>" value="<?php echo $option['value'];?>" id="<?php echo $name."_".$x;?>" <?php checked($value, $option['value']);?> class="<?php echo $class;?>"> <label for="<?php echo $name."_".$x;?>"><?php echo $option['name'];?></label> 
  294. <?php  
  295. $radio_help_text = isset($option['help_text']) ? $option['help_text'] : $help_text; 
  296.  
  297. if( $radio_help_text != '') { ?> 
  298. <a href="#" class="tooltip"> 
  299. <img id="" class='ninja-forms-help-text' src="<?php echo NINJA_FORMS_URL;?>images/question-ico.gif" title=""> 
  300. <span> 
  301. <img class="callout" src="<?php echo NINJA_FORMS_URL;?>images/callout.gif" /> 
  302. <?php echo $radio_help_text;?> 
  303. </span> 
  304. </a> 
  305. <?php } ?> 
  306. <br /> 
  307.  
  308. <?php 
  309. $x++; 
  310. break; 
  311. case 'textarea': 
  312. $value = ninja_forms_esc_html_deep( $value ); 
  313. ?> 
  314. <textarea name="<?php echo $name;?>" id="<?php echo $name;?>" class="<?php echo $class;?>"><?php echo $value;?></textarea> 
  315. <?php 
  316. break; 
  317. case 'rte': 
  318. $args = apply_filters( 'ninja_forms_admin_metabox_rte', array() ); 
  319. wp_editor( $value, $name, $args ); 
  320. break; 
  321. case 'file': 
  322. ?> 
  323. <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_file_size;?>" /> 
  324. <input type="file" name="<?php echo $name;?>" id="<?php echo $name;?>" class="<?php echo $class;?>"> 
  325. <?php 
  326. break; 
  327. case 'desc': 
  328. echo $desc; 
  329. break; 
  330. case 'hidden': 
  331. ?> 
  332. <input type="hidden" name="<?php echo $name;?>" id="<?php echo $name;?>" value="<?php echo $value;?>"> 
  333. <?php 
  334. break; 
  335. case 'submit': 
  336. ?> 
  337. <input type="submit" name="<?php echo $name;?>" class="<?php echo $class; ?>" value="<?php echo $button_text;?>"> 
  338. <?php 
  339. break; 
  340. case 'button': 
  341. // set a default value for $class to maintain the standard WordPress UI 
  342. if( isset( $class ) && empty( $class ) ) { 
  343. $class = "button-secondary"; 
  344. ?> 
  345. <input type="button" name="<?php echo $name;?>" id="<?php echo $name;?>" class="<?php echo $class; ?>" value="<?php echo $button_text;?>"> 
  346. <?php 
  347. break; 
  348.  
  349. default: 
  350. if( isset( $s['display_function'] ) ) { 
  351. $s_display_function = $s['display_function']; 
  352. if( $s_display_function != '' ) { 
  353. $arguments['form_id'] = $form_id; 
  354. $arguments['data'] = $current_settings; 
  355. $arguments['field'] = $s; 
  356. call_user_func_array( $s_display_function, $arguments ); 
  357. break; 
  358.  
  359. if( $desc != '' AND $s['type'] != 'desc' ) { 
  360. ?> 
  361. <p class="description"> 
  362. <?php echo $desc;?> 
  363. </p> 
  364. <?php 
  365. echo '</td></tr>'; 
  366.  
  367.  
  368. if( $display_function != '' ) { 
  369. if( $form_id != '' ) { 
  370. $arguments['form_id'] = $form_id; 
  371. $arguments['metabox'] = $metabox; 
  372. call_user_func_array( $display_function, $arguments ); 
  373.  
  374. if( $display_container ) { 
  375. ?> 
  376. </tbody> 
  377. </table> 
  378. </div> 
  379. </div> 
  380. <?php