/deprecated/includes/register.php

  1. <?php if ( ! defined( 'ABSPATH' ) ) exit; 
  2. function ninja_forms_register_field($slug, $args = array()) { 
  3. global $ninja_forms_fields; 
  4.  
  5. if( !isset( $ninja_forms_fields ) ) { 
  6. $ninja_forms_fields = array(); 
  7.  
  8. $defaults = array( 
  9. 'conditional' => '',  
  10. 'default_label' => '',  
  11. 'default_label_pos' => '',  
  12. 'default_value' => '',  
  13. 'display_function' => '',  
  14. 'display_label' => true,  
  15. 'display_wrap' => true,  
  16. 'edit_autocomplete_off' => false,  
  17. 'edit_conditional' => true,  
  18. 'edit_custom_class' => true,  
  19. 'edit_function' => '',  
  20. 'edit_help' => true,  
  21. 'edit_label' => true,  
  22. 'edit_label_pos' => true,  
  23. 'edit_meta' => true,  
  24. 'edit_options' => '',  
  25. 'edit_placeholder' => false,  
  26. 'edit_req' => true,  
  27. 'edit_settings' => '',  
  28. 'edit_sub_post_process' => '',  
  29. 'edit_sub_pre_process' => '',  
  30. 'edit_sub_process' => '',  
  31. 'esc_html' => true,  
  32. 'group' => '',  
  33. 'interact' => true,  
  34. 'label_pos_options' => '',  
  35. 'li_class' => '',  
  36. 'limit' => '',  
  37. 'name' => $slug,  
  38. 'nesting' => false,  
  39. 'post_process' => '',  
  40. 'pre_process' => '',  
  41. 'process' => '',  
  42. 'process_field' => true,  
  43. 'req' => false,  
  44. 'req_validation' => '',  
  45. 'save_function' => '',  
  46. 'save_sub' => true,  
  47. 'show_fav' => true,  
  48. 'show_field_id' => true,  
  49. 'show_remove' => true,  
  50. 'sub_edit' => 'text',  
  51. 'sub_edit_function' => '',  
  52. 'use_li' => true,  
  53. 'visible' => 1,  
  54. ); 
  55.  
  56. // Parse incomming $args into an array and merge it with $defaults 
  57. $args = wp_parse_args( $args, $defaults ); 
  58.  
  59. foreach( $args as $key => $val ) { 
  60. $ninja_forms_fields[$slug][$key] = $val; 
  61.  
  62.  
  63. function ninja_forms_register_field_type_group( $slug, $args ) { 
  64. global $ninja_forms_field_type_groups; 
  65.  
  66. foreach( $args as $key => $val ) { 
  67. $ninja_forms_field_type_groups[$slug][$key] = $val; 
  68.  
  69. function ninja_forms_register_tab( $slug, $args ) { 
  70. global $ninja_forms_tabs; 
  71.  
  72. if(!is_array($ninja_forms_tabs)) { 
  73. $ninja_forms_tabs = array(); 
  74.  
  75. $defaults = array( 
  76. 'active_class' => '',  
  77. 'add_form_id' => true,  
  78. 'disable_no_form_id' => false,  
  79. 'display_function' => '',  
  80. 'inactive_class' => '',  
  81. 'name' => '',  
  82. 'page' => '',  
  83. 'save_function' => '',  
  84. 'show_on_no_form_id' => true,  
  85. 'show_save' => true,  
  86. 'show_tab_links' => true,  
  87. 'show_this_tab_link' => true,  
  88. 'tab_reload' => false,  
  89. ); 
  90.  
  91. // Parse incomming $args into an array and merge it with $defaults 
  92. $args = wp_parse_args( $args, $defaults ); 
  93.  
  94. $page = $args['page']; 
  95.  
  96. foreach( $args as $key => $val ) { 
  97. $ninja_forms_tabs[$page][$slug][$key] = $val; 
  98.  
  99. function ninja_forms_register_sidebar( $slug, $args ) { 
  100. global $ninja_forms_sidebars; 
  101.  
  102. if( !is_array($ninja_forms_sidebars ) ) { 
  103. $ninja_forms_sidebars = array(); 
  104.  
  105. $defaults = array( 
  106. 'display_function' => 'ninja_forms_sidebar_display_fields',  
  107. 'name' => '',  
  108. 'order' => '',  
  109. 'save_function' => '',  
  110. 'settings' => '' 
  111. ); 
  112.  
  113.  
  114.  
  115. // Parse incomming $args into an array and merge it with $defaults 
  116. $args = wp_parse_args( $args, $defaults ); 
  117.  
  118. extract( $args ); 
  119.  
  120. foreach( $args as $key => $val ) { 
  121. $ninja_forms_sidebars[$page][$tab][$slug][$key] = $val; 
  122.  
  123.  
  124. function ninja_forms_register_sidebar_option( $slug, $args ) { 
  125. global $ninja_forms_sidebars; 
  126.  
  127. if( !is_array($ninja_forms_sidebars ) ) { 
  128. $ninja_forms_sidebars = array(); 
  129.  
  130. $defaults = array( 
  131. 'desc' => '',  
  132. 'display_function' => '',  
  133. 'help' => '',  
  134. 'name' => '' 
  135. ); 
  136.  
  137. // Parse incomming $args into an array and merge it with $defaults 
  138. $args = wp_parse_args( $args, $defaults ); 
  139.  
  140. extract( $args ); 
  141.  
  142. foreach( $args as $key => $val ) { 
  143. $ninja_forms_sidebars[$page][$tab][$sidebar]['settings'][$slug][$key] = $val; 
  144.  
  145. function ninja_forms_register_sidebar_options( $args ) { 
  146. global $ninja_forms_sidebars; 
  147.  
  148. extract( $args ); 
  149.  
  150. foreach( $args['settings'] as $setting ) { 
  151.  
  152. $defaults = array( 
  153. 'desc' => '',  
  154. 'display_function' => '',  
  155. 'help' => '',  
  156. 'name' => '' 
  157. ); 
  158.  
  159. $slug = $setting['name']; 
  160.  
  161. // Parse incomming $setting into an array and merge it with $defaults 
  162. $setting = wp_parse_args( $setting, $defaults ); 
  163.  
  164. foreach( $setting as $key => $val ) { 
  165. $ninja_forms_sidebars[$page][$tab][$sidebar]['settings'][$slug][$key] = $val; 
  166.  
  167.  
  168. function ninja_forms_field_edit( $slug ) { 
  169. global $ninja_forms_fields; 
  170. $function_name = $ninja_forms_fields[$slug]['edit_function']; 
  171. $arguments = func_get_args(); 
  172. array_shift( $arguments ); // We need to remove the first arg ($function_name) 
  173. call_user_func_array( $function_name, $arguments ); 
  174.  
  175. //Screen option registration function 
  176. function ninja_forms_register_screen_option( $id, $args ) { 
  177. global $ninja_forms_screen_options; 
  178.  
  179. $defaults = array( 
  180. 'display_function' => '',  
  181. 'order' => '',  
  182. 'page' => '',  
  183. 'save_function' => '',  
  184. 'tab' => '',  
  185. ); 
  186.  
  187. // Parse incomming $args into an array and merge it with $defaults 
  188. $args = wp_parse_args( $args, $defaults ); 
  189.  
  190. extract( $args ); 
  191.  
  192. if($page == '' AND $tab == '') { 
  193. $ninja_forms_screen_options['_universal_'][$id]['display_function'] = $display_function; 
  194. $ninja_forms_screen_options['_universal_'][$id]['save_function'] = $save_function; 
  195. }elseif($page != '' AND $tab == '') { 
  196. $ninja_forms_screen_options[$page]['_universal_'][$id]['display_function'] = $display_function; 
  197. $ninja_forms_screen_options[$page]['_universal_'][$id]['save_function'] = $save_function; 
  198. }elseif($page != '' AND $tab != '') { 
  199. $ninja_forms_screen_options[$page][$tab][$id]['display_function'] = $display_function; 
  200. $ninja_forms_screen_options[$page][$tab][$id]['save_function'] = $save_function; 
  201.  
  202. //Help tab registration function 
  203. function ninja_forms_register_help_screen_tab( $id, $args ) { 
  204. global $ninja_forms_help_screen_tabs; 
  205.  
  206. $defaults = array( 
  207. 'display_function' => '',  
  208. 'order' => '',  
  209. 'page' => '',  
  210. 'tab' => '',  
  211. 'title' => '',  
  212. ); 
  213.  
  214. // Parse incomming $args into an array and merge it with $defaults 
  215. $args = wp_parse_args( $args, $defaults ); 
  216.  
  217. extract( $args ); 
  218.  
  219. if($page == '' AND $tab == '') { 
  220. $ninja_forms_help_screen_tabs['_universal_'][$id]['title'] = $title; 
  221. $ninja_forms_help_screen_tabs['_universal_'][$id]['content'] = $display_function; 
  222. }elseif($page != '' AND $tab == '') { 
  223. $ninja_forms_help_screen_tabs[$page]['_universal_'][$id]['title'] = $title; 
  224. $ninja_forms_help_screen_tabs[$page]['_universal_'][$id]['content'] = $display_function; 
  225. }elseif($page != '' AND $tab != '') { 
  226. $ninja_forms_help_screen_tabs[$page][$tab][$id]['title'] = $title; 
  227. $ninja_forms_help_screen_tabs[$page][$tab][$id]['content'] = $display_function; 
  228.  
  229. //Tab - Metaboxes Registration function 
  230. function ninja_forms_register_tab_metabox($args = array()) { 
  231. global $ninja_forms_tabs_metaboxes; 
  232.  
  233. $defaults = array( 
  234. 'display_container' => true,  
  235. 'save_function' => '',  
  236. 'state' => '' 
  237. ); 
  238.  
  239. // Parse incomming $args into an array and merge it with $defaults 
  240. $args = wp_parse_args( $args, $defaults ); 
  241.  
  242. extract( $args ); 
  243.  
  244. foreach($args as $key => $val) { 
  245. $ninja_forms_tabs_metaboxes[$page][$tab][$slug][$key] = $val; 
  246.  
  247. //Register Tab Metabox Options 
  248. function ninja_forms_register_tab_metabox_options( $args = array() ) { 
  249. global $ninja_forms_tabs_metaboxes; 
  250.  
  251. extract( $args ); 
  252.  
  253. $new_settings = $args['settings']; 
  254.  
  255. if( isset( $ninja_forms_tabs_metaboxes[$page][$tab][$slug]['settings'] ) ) { 
  256. $settings = $ninja_forms_tabs_metaboxes[$page][$tab][$slug]['settings']; 
  257. }else{ 
  258. $settings = array(); 
  259.  
  260. if( is_array( $new_settings ) AND !empty( $new_settings ) ) { 
  261. foreach( $new_settings as $s ) { 
  262. if( is_array( $settings ) ) { 
  263. array_push( $settings, $s ); 
  264.  
  265. $ninja_forms_tabs_metaboxes[$page][$tab][$slug]['settings'] = $settings; 
.