NF_Forms

Handles adding and removing forms.

Defined (1)

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

/deprecated/classes/forms.php  
  1. class NF_Forms { 
  2.  
  3. /** 
  4. * Store our array of form ids 
  5. *  
  6. * @since 2.9 
  7. */ 
  8. var $forms = array(); 
  9.  
  10. /** 
  11. * Get things started 
  12. *  
  13. * @access public 
  14. * @since 2.9 
  15. * @return void 
  16. */ 
  17. public function __construct() { 
  18. add_action( 'nf_maybe_delete_form', array( $this, 'maybe_delete' ) ); 
  19.  
  20. /** 
  21. * Get all forms 
  22. *  
  23. * @access public 
  24. * @since 2.9 
  25. * @return array $forms 
  26. */ 
  27. public function get_all( $show_new = false ) { 
  28. global $wpdb; 
  29.  
  30. $debug = ! empty ( $_REQUEST['debug'] ) ? true : false; 
  31.  
  32. if ( empty ( $this->forms ) ) { 
  33. $forms = nf_get_objects_by_type( 'form' ); 
  34.  
  35. $tmp_array = array(); 
  36. foreach ( $forms as $form ) { 
  37. $form_id = $form['id']; 
  38.  
  39. $status = Ninja_Forms()->form( $form_id )->get_setting( 'status' ); 
  40. if ( ( $status == 'new' && $show_new ) || $status != 'new' ) { 
  41. $title = Ninja_Forms()->form( $form_id )->get_setting( 'form_title' ); 
  42. if ( strpos( $title, '_' ) === 0 ) { 
  43. if ( $debug ) 
  44. $tmp_array[] = $form_id; 
  45. } else { 
  46. $tmp_array[] = $form_id; 
  47. $this->forms = $tmp_array; 
  48.  
  49. return $this->forms; 
  50.  
  51. /** 
  52. * Delete a form if it is created and not saved within 24 hrs. 
  53. *  
  54. * @access public 
  55. * @since 2.9 
  56. * @return void 
  57. */ 
  58. public function maybe_delete( $form_id ) { 
  59. $status = Ninja_Forms()->form( $form_id )->get_setting( 'status' ); 
  60. if ( 'new' == $status ) { 
  61. Ninja_Forms()->form( $form_id )->delete(); 
  62.  
  63. /** 
  64. * Update cached forms 
  65. *  
  66. * @access public 
  67. * @since 2.9 
  68. * @return void 
  69. */ 
  70. public function update_cache( $debug = false, $show_new = false ) { 
  71. $this->forms = array(); 
  72. $this->get_all( $debug, $show_new );