ninja_forms_admin

The Ninja Forms ninja forms admin function.

Description

ninja_forms_admin(); 

Usage

  1. if ( !function_exists( 'ninja_forms_admin' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ninja-forms/deprecated/includes/admin/admin.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = ninja_forms_admin(); 
  7.  

Defined (1)

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

/deprecated/includes/admin/admin.php  
  1. function ninja_forms_admin() { 
  2. global $wpdb, $ninja_forms_tabs, $ninja_forms_sidebars, $current_tab, $ninja_forms_tabs_metaboxes, $ninja_forms_admin_update_message; 
  3.  
  4. $current_tab = ninja_forms_get_current_tab(); 
  5. $current_page = esc_html( $_REQUEST['page'] ); 
  6.  
  7. if( isset ( $_REQUEST['form_id'] ) ) { 
  8. $form_id = absint( $_REQUEST['form_id'] ); 
  9. $data = Ninja_Forms()->form( $form_id )->get_all_settings(); 
  10. $form_title = isset ( $data['form_title'] ) ? $data['form_title'] : ''; 
  11. }else{ 
  12. $form_id = ''; 
  13. $data = ''; 
  14. $form_title = ''; 
  15.  
  16. if( !isset( $ninja_forms_admin_update_message ) AND isset( $_REQUEST['update_message'] ) ) { 
  17. $ninja_forms_admin_update_message = esc_html( $_REQUEST['update_message'] ); 
  18.  
  19. $output_form = isset ( $ninja_forms_tabs[$current_page][$current_tab]['output_form'] ) ? $ninja_forms_tabs[$current_page][$current_tab]['output_form'] : true; 
  20.  
  21. $form_method = isset ( $ninja_forms_tabs[$current_page][$current_tab]['form_method'] ) ? $ninja_forms_tabs[$current_page][$current_tab]['form_method'] : 'post'; 
  22.  
  23. $hidden_fields = isset ( $ninja_forms_tabs[$current_page][$current_tab]['hidden_fields'] ) ? $ninja_forms_tabs[$current_page][$current_tab]['hidden_fields'] : true; 
  24.  
  25. if ( $output_form ) { 
  26. ?> 
  27. <form id="ninja_forms_admin" enctype="multipart/form-data" method="<?php echo $form_method; ?>"> 
  28. <input type="hidden" name="_page" id="_page" value="<?php echo $current_page;?>"> 
  29. <input type="hidden" name="_tab" id="_tab" value="<?php echo $current_tab;?>"> 
  30. <input type="hidden" name="_form_id" id="_form_id" value="<?php echo $form_id;?>"> 
  31. <input type="hidden" name="_fields_order" id="_fields_order" value="same"> 
  32. <?php 
  33. wp_nonce_field('_ninja_forms_save', '_ninja_forms_admin_submit');  
  34. ?> 
  35. <div class="wrap"> 
  36. <?php 
  37. screen_icon( 'ninja-custom-forms' ); 
  38. if(isset($ninja_forms_tabs[$current_page][$current_tab]['title'])) { 
  39. echo $ninja_forms_tabs[$current_page][$current_tab]['title']; 
  40.  
  41. if ( 'form_list' == $current_tab ) { 
  42. $builder_url = esc_url( add_query_arg( array( 'form_id' => 'new', 'tab' => 'builder' ) ) ); 
  43. ?> 
  44. <h2><?php _e( 'Forms', 'ninja-forms' ); ?> <a href="<?php echo $builder_url; ?>" class="add-new-h2"><?php _e( 'Add New', 'ninja-forms'); ?></a></h2> 
  45. <?php 
  46. } else { 
  47.  
  48. ?> 
  49. <h2 id="nf-display-form-title"><?php echo $form_title; ?></h2> 
  50. <?php 
  51.  
  52. if($ninja_forms_tabs[$current_page][$current_tab]['show_tab_links']) { 
  53. ?> 
  54. <h2 class="nav-tab-wrapper"> 
  55. <?php 
  56. if ( ! empty ( $form_id ) ) { 
  57. $preview_link = ninja_forms_preview_link( $form_id, false ); 
  58. $subs_link = admin_url( 'edit.php?post_status=all&post_type=nf_sub&action=-1&m=0&form_id=' . $form_id . '&begin_date&end_date&paged=1&mode=list&=-1' ); 
  59. ?> 
  60. <a href="<?php echo $preview_link; ?>" target="_blank" class="nf-preview button-secondary"><span class="dashicons dashicons-welcome-view-site"></span><?php _e( 'Preview', 'ninja-forms' ); ?></a> 
  61. <a href="<?php echo $subs_link; ?>" target="_blank" class="nf-subs button-secondary"><span class="dashicons dashicons-email-alt"></span><?php _e( 'Submissions', 'ninja-forms' ); ?></a> 
  62. <?php } ?> 
  63. </h2> 
  64. <?php 
  65.  
  66. if( isset( $ninja_forms_admin_update_message ) AND $ninja_forms_admin_update_message != '' ) { 
  67. ?> 
  68. <div id="message" class="updated below-h2"> 
  69. <p> 
  70. <?php echo $ninja_forms_admin_update_message;?> 
  71. </p> 
  72. </div> 
  73. <?php 
  74.  
  75. if(isset($ninja_forms_sidebars[$current_page][$current_tab]) AND is_array($ninja_forms_sidebars[$current_page][$current_tab])) { 
  76.  
  77. ?> 
  78. <div id="nav-menus-frame"> 
  79. <?php ninja_forms_display_sidebars($data); ?> 
  80.  
  81. </div><!-- /#menu-settings-column --> 
  82. <?php 
  83.  
  84. ?> 
  85.  
  86. <div id="poststuff"> 
  87. <div id="post-body"> 
  88. <div id="post-body-content"> 
  89. <?php 
  90.  
  91. //Check to see if the registered tab has an metaboxes registered to it. 
  92. if(isset($ninja_forms_tabs_metaboxes[$current_page][$current_tab]) AND !empty($ninja_forms_tabs_metaboxes[$current_page][$current_tab])) { 
  93. ?> 
  94. <div id="ninja_forms_admin_metaboxes"> 
  95. <?php 
  96. foreach($ninja_forms_tabs_metaboxes[$current_page][$current_tab] as $slug => $metabox) { 
  97. ninja_forms_output_tab_metabox($form_id, $slug, $metabox); 
  98. ?> 
  99. </div> 
  100. <?php 
  101.  
  102. //Check to see if the registered tab has a display function registered. 
  103. if(isset($ninja_forms_tabs[$current_page][$current_tab]['display_function']) AND $ninja_forms_tabs[$current_page][$current_tab]['display_function'] != '') { 
  104. $tab_callback = $ninja_forms_tabs[$current_page][$current_tab]['display_function']; 
  105. $arguments = func_get_args(); 
  106. array_shift($arguments); // We need to remove the first arg ($function_name) 
  107. $arguments['form_id'] = $form_id; 
  108. $arguments['data'] = $data; 
  109. call_user_func_array($tab_callback, $arguments); 
  110.  
  111. if(isset($ninja_forms_tabs[$current_page][$current_tab]['show_save']) AND $ninja_forms_tabs[$current_page][$current_tab]['show_save'] === true) { ?> 
  112. <br /> 
  113. <input class="button-primary menu-save ninja-forms-save-data" id="ninja_forms_save_data_top" type="submit" value="<?php _e( 'Save', 'ninja-forms' ); ?>" /> 
  114. <?php 
  115. ?> 
  116.  
  117. </div><!-- /#post-body-content --> 
  118. </div><!-- /#post-body --> 
  119. </div> 
  120. </div> 
  121. <!-- </div>/.wrap--> 
  122. <?php 
  123. if ( $output_form ) { 
  124. ?> 
  125. </form> 
  126. <?php 
  127. ?> 
  128.  
  129.  
  130. <?php