/deprecated/includes/admin/pages/ninja-forms/tabs/field-settings/field-settings.php

  1. <?php if ( ! defined( 'ABSPATH' ) ) exit; 
  2.  
  3. function ninja_forms_register_tab_field_settings() { 
  4. if(isset($_REQUEST['form_id'])) { 
  5. $form_id = absint( $_REQUEST['form_id'] ); 
  6. }else{ 
  7. $form_id = ''; 
  8.  
  9. $args = array( 
  10. 'name' => __( 'Build Your Form', 'ninja-forms' ),  
  11. 'page' => 'ninja-forms',  
  12. 'display_function' => 'ninja_forms_tab_field_settings',  
  13. 'disable_no_form_id' => true,  
  14. 'show_save' => false,  
  15. 'tab_reload' => false,  
  16. ); 
  17. ninja_forms_register_tab( 'builder', $args ); 
  18.  
  19. add_action('admin_init', 'ninja_forms_register_tab_field_settings'); 
  20.  
  21. function ninja_forms_tab_field_settings() { 
  22. global $wpdb; 
  23.  
  24. if ( isset ( $_REQUEST['form_id'] ) ) { 
  25. $form_id = absint( $_REQUEST['form_id'] ); 
  26. } else { 
  27. $form_id = ''; 
  28.  
  29. if ( ! empty ( $form_id ) && 'new' != $form_id ) { 
  30. do_action( 'ninja_forms_edit_field_before_ul', $form_id ); 
  31. do_action( 'ninja_forms_edit_field_ul', $form_id ); 
  32. do_action( 'ninja_forms_edit_field_after_ul', $form_id ); 
  33.  
  34. ?> 
  35. <div style="display:none;"> 
  36. <div id="nf-save-title"> 
  37. <div id="admin-modal-selector"> 
  38. <div id="admin-modal-options"> 
  39. <div> 
  40. <label><input id="nf-form-title" class="widefat" style="width:100%;" type="text" name="admin-modaltitle" placeholder="<?php _e( 'Give your form a title. This is how you\'ll find the form later.', 'ninja-forms' ); ?>"></label> 
  41. </div> 
  42. </div> 
  43. <div id="nf-insert-submit-div"> 
  44. <div class="admin-modal-target"> 
  45. <p class="howto"><?php _e( 'You have not added a submit button to your form.', 'ninja-forms' ); ?></p> 
  46. <label><span> </span><input type="checkbox" id="nf-insert-submit" value="1" checked> Insert Submit Button</label> 
  47. </div> 
  48. </div> 
  49. </div> 
  50. </div> 
  51.  
  52. <div id="nf-save-title-buttons"> 
  53. <div id="nf-admin-modal-cancel"> 
  54. <a class="submitdelete deletion modal-close" href="#">Cancel</a> 
  55. </div> 
  56. <div id="nf-admin-modal-update"> 
  57. <input type="submit" value="Save" class="button button-secondary" id="nf-save-title-submit" disabled> 
  58. </div> 
  59. </div> 
  60. </div> 
  61. <?php 
  62.  
  63. /** 
  64. * Listen for a new form action and create one if necessary. 
  65. *  
  66. * @since 2.9 
  67. * @return void 
  68. */ 
  69. function nf_create_form_listen() { 
  70. $page = isset ( $_REQUEST['page'] ) ? $_REQUEST['page'] : ''; 
  71. $tab = isset ( $_REQUEST['tab'] ) ? $_REQUEST['tab'] : ''; 
  72. $form_id = isset ( $_REQUEST['form_id'] ) ? $_REQUEST['form_id'] : ''; 
  73.  
  74. if ( 'ninja-forms' == $page && 'builder' == $tab && 'new' == $form_id ) { 
  75. $defaults = apply_filters( 'nf_new_form_defaults', array( 
  76. 'clear_complete' => 1,  
  77. 'hide_complete' => 1,  
  78. 'show_title' => 0,  
  79. 'status' => 'new',  
  80. ) ); 
  81. $form_id = Ninja_Forms()->form()->create( $defaults ); 
  82. $redirect = esc_url_raw( add_query_arg( array( 'form_id' => $form_id ) ) ); 
  83. wp_redirect( $redirect ); 
  84. die();  
  85.  
  86. add_action( 'admin_init', 'nf_create_form_listen', 5 ); 
.