Visual Form Builder - Version 2.8.7

Version Description

This version requires at least WordPress 4.3 or higher due to previous use of deprecated functions

Download this release

Release Info

Developer mmuro
Plugin Icon 128x128 Visual Form Builder
Version 2.8.7
Comparing to
See all releases

Code changes from version 2.8.6 to 2.8.7

includes/class-entries-detail.php CHANGED
@@ -43,11 +43,11 @@ class VisualFormBuilder_Entries_Detail{
43
  public function entries_detail(){
44
  global $wpdb;
45
 
46
- $entry_id = absint( $_REQUEST['entry'] );
47
 
48
  $entries = $wpdb->get_results( $wpdb->prepare( "SELECT forms.form_title, entries.* FROM $this->form_table_name AS forms INNER JOIN $this->entries_table_name AS entries ON entries.form_id = forms.form_id WHERE entries.entries_id = %d", $entry_id ) );
49
 
50
- echo '<p>' . sprintf( '<a href="?page=%s" class="view-entry">&laquo; Back to Entries</a>', $_REQUEST['page'] ) . '</p>';
51
 
52
  // Get the date/time format that is saved in the options table
53
  $date_format = get_option('date_format');
@@ -95,7 +95,7 @@ class VisualFormBuilder_Entries_Detail{
95
 
96
  <div id="major-publishing-actions">
97
  <div id="delete-action">
98
- <?php echo sprintf( '<a class="submitdelete deletion entry-delete" href="?page=%2$s&action=%3$s&entry=%4$d">%1$s</a>', __( 'Move to Trash', 'visual-form-builder' ), $_REQUEST['page'], 'trash', $entry_id ); ?>
99
  </div>
100
  <div id="publishing-action">
101
  <?php submit_button( __( 'Print', 'visual-form-builder' ), 'secondary', 'submit', false, array( 'onclick' => 'window.print();return false;' ) ); ?>
43
  public function entries_detail(){
44
  global $wpdb;
45
 
46
+ $entry_id = absint( $_GET['entry'] );
47
 
48
  $entries = $wpdb->get_results( $wpdb->prepare( "SELECT forms.form_title, entries.* FROM $this->form_table_name AS forms INNER JOIN $this->entries_table_name AS entries ON entries.form_id = forms.form_id WHERE entries.entries_id = %d", $entry_id ) );
49
 
50
+ echo '<p>' . sprintf( '<a href="?page=%s" class="view-entry">&laquo; Back to Entries</a>', $_GET['page'] ) . '</p>';
51
 
52
  // Get the date/time format that is saved in the options table
53
  $date_format = get_option('date_format');
95
 
96
  <div id="major-publishing-actions">
97
  <div id="delete-action">
98
+ <?php echo sprintf( '<a class="submitdelete deletion entry-delete" href="?page=%2$s&action=%3$s&entry=%4$d">%1$s</a>', __( 'Move to Trash', 'visual-form-builder' ), $_GET['page'], 'trash', $entry_id ); ?>
99
  </div>
100
  <div id="publishing-action">
101
  <?php submit_button( __( 'Print', 'visual-form-builder' ), 'secondary', 'submit', false, array( 'onclick' => 'window.print();return false;' ) ); ?>
includes/class-entries-list.php CHANGED
@@ -79,13 +79,13 @@ class VisualFormBuilder_Entries_List extends WP_List_Table {
79
 
80
  // Build row actions
81
  if ( !$this->get_entry_status() || 'all' == $this->get_entry_status() )
82
- $actions['view'] = sprintf( '<a href="?page=%s&action=%s&entry=%s" id="%3$s" class="view-entry">View</a>', $_REQUEST['page'], 'view', $item['entry_id'] );
83
 
84
  if ( !$this->get_entry_status() || 'all' == $this->get_entry_status() )
85
- $actions['trash'] = sprintf( '<a href="?page=%s&action=%s&entry=%s">Trash</a>', $_REQUEST['page'], 'trash', $item['entry_id'] );
86
  elseif ( $this->get_entry_status() && 'trash' == $this->get_entry_status() ) {
87
- $actions['restore'] = sprintf( '<a href="?page=%s&action=%s&entry=%s">%s</a>', $_REQUEST['page'], 'restore', $item['entry_id'], __( 'Restore', 'visual-form-builder' ) );
88
- $actions['delete'] = sprintf( '<a href="?page=%s&action=%s&entry=%s">%s</a>', $_REQUEST['page'], 'delete', $item['entry_id'], __( 'Delete Permanently', 'visual-form-builder' ) );
89
  }
90
 
91
  return sprintf( '%1$s %2$s', $item['form'], $this->row_actions( $actions ) );
@@ -161,7 +161,7 @@ class VisualFormBuilder_Entries_List extends WP_List_Table {
161
  $where .= $wpdb->prepare( 'AND forms.form_id = %d', $this->current_filter_action() );
162
 
163
  // Get the month and year from the dropdown
164
- $m = isset( $_REQUEST['m'] ) ? (int) $_REQUEST['m'] : 0;
165
 
166
  // If a month/year has been selected, parse out the month/year and build the clause
167
  if ( $m > 0 ) {
@@ -172,7 +172,7 @@ class VisualFormBuilder_Entries_List extends WP_List_Table {
172
  }
173
 
174
  // Get the month/year from the dropdown
175
- $today = isset( $_REQUEST['today'] ) ? (int) $_REQUEST['today'] : 0;
176
 
177
  // Parse month/year and build the clause
178
  if ( $today > 0 )
@@ -198,10 +198,10 @@ class VisualFormBuilder_Entries_List extends WP_List_Table {
198
  * @returns string Entry status
199
  */
200
  function get_entry_status() {
201
- if ( !isset( $_REQUEST['entry_status'] ) )
202
  return false;
203
 
204
- return esc_html( $_REQUEST['entry_status'] );
205
  }
206
 
207
  /**
@@ -222,7 +222,7 @@ class VisualFormBuilder_Entries_List extends WP_List_Table {
222
  );
223
 
224
  $total_entries = (int) $num_entries->all;
225
- $entry_status = isset( $_REQUEST['entry_status'] ) ? $_REQUEST['entry_status'] : 'all';
226
 
227
  foreach ( $stati as $status => $label ) {
228
  $class = ( $status == $entry_status ) ? ' class="current"' : '';
@@ -323,11 +323,11 @@ class VisualFormBuilder_Entries_List extends WP_List_Table {
323
  $entry_id = '';
324
 
325
  // Set the Entry ID array
326
- if ( isset( $_REQUEST['entry'] ) ) :
327
- if ( is_array( $_REQUEST['entry'] ) )
328
- $entry_id = $_REQUEST['entry'];
329
  else
330
- $entry_id = (array) $_REQUEST['entry'];
331
  endif;
332
 
333
  switch( $this->current_action() ) :
@@ -353,7 +353,7 @@ class VisualFormBuilder_Entries_List extends WP_List_Table {
353
  break;
354
 
355
  case 'delete' :
356
- $entry_id = ( isset( $_REQUEST['entry'] ) && is_array( $_REQUEST['entry'] ) ) ? $_REQUEST['entry'] : array( $_REQUEST['entry'] );
357
 
358
  global $wpdb;
359
 
@@ -415,7 +415,7 @@ class VisualFormBuilder_Entries_List extends WP_List_Table {
415
  if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) )
416
  return;
417
 
418
- $m = isset( $_REQUEST['m'] ) ? (int) $_REQUEST['m'] : 0;
419
  ?>
420
  <select name='m'>
421
  <option<?php selected( $m, 0 ); ?> value='0'><?php _e( 'Show all dates' ); ?></option>
@@ -506,7 +506,7 @@ class VisualFormBuilder_Entries_List extends WP_List_Table {
506
  $this->_column_headers = array($columns, $hidden, $sortable);
507
 
508
  // Get entries search terms
509
- $search_terms = ( !empty( $_REQUEST['s'] ) ) ? explode( ' ', $_REQUEST['s'] ) : array();
510
 
511
  $searchand = $search = '';
512
  // Loop through search terms and build query
@@ -520,8 +520,8 @@ class VisualFormBuilder_Entries_List extends WP_List_Table {
520
  $search = ( !empty($search) ) ? " AND ({$search}) " : '';
521
 
522
  // Set our ORDER BY and ASC/DESC to sort the entries
523
- $orderby = ( !empty( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : 'date';
524
- $order = ( !empty( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : 'desc';
525
 
526
  // Get the sorted entries
527
  $entries = $this->get_entries( $orderby, $order, $per_page, $offset, $search );
@@ -551,7 +551,7 @@ class VisualFormBuilder_Entries_List extends WP_List_Table {
551
  $where .= 'AND form_id = ' . $this->current_filter_action();
552
 
553
  // Get the month/year from the dropdown
554
- $m = isset( $_REQUEST['m'] ) ? (int) $_REQUEST['m'] : 0;
555
 
556
  // Parse month/year and build the clause
557
  if ( $m > 0 ) {
@@ -562,7 +562,7 @@ class VisualFormBuilder_Entries_List extends WP_List_Table {
562
  }
563
 
564
  // Get the month/year from the dropdown
565
- $today = isset( $_REQUEST['today'] ) ? (int) $_REQUEST['today'] : 0;
566
 
567
  // Parse month/year and build the clause
568
  if ( $today > 0 )
@@ -613,7 +613,7 @@ class VisualFormBuilder_Entries_List extends WP_List_Table {
613
  $page_links = array();
614
 
615
  // Added to pick up the months dropdown
616
- $m = isset( $_REQUEST['m'] ) ? (int) $_REQUEST['m'] : 0;
617
 
618
  $disable_first = $disable_last = '';
619
  if ( $current == 1 )
79
 
80
  // Build row actions
81
  if ( !$this->get_entry_status() || 'all' == $this->get_entry_status() )
82
+ $actions['view'] = sprintf( '<a href="?page=%s&action=%s&entry=%s" id="%3$s" class="view-entry">View</a>', $_GET['page'], 'view', $item['entry_id'] );
83
 
84
  if ( !$this->get_entry_status() || 'all' == $this->get_entry_status() )
85
+ $actions['trash'] = sprintf( '<a href="?page=%s&action=%s&entry=%s">Trash</a>', $_GET['page'], 'trash', $item['entry_id'] );
86
  elseif ( $this->get_entry_status() && 'trash' == $this->get_entry_status() ) {
87
+ $actions['restore'] = sprintf( '<a href="?page=%s&action=%s&entry=%s">%s</a>', $_GET['page'], 'restore', $item['entry_id'], __( 'Restore', 'visual-form-builder' ) );
88
+ $actions['delete'] = sprintf( '<a href="?page=%s&action=%s&entry=%s">%s</a>', $_GET['page'], 'delete', $item['entry_id'], __( 'Delete Permanently', 'visual-form-builder' ) );
89
  }
90
 
91
  return sprintf( '%1$s %2$s', $item['form'], $this->row_actions( $actions ) );
161
  $where .= $wpdb->prepare( 'AND forms.form_id = %d', $this->current_filter_action() );
162
 
163
  // Get the month and year from the dropdown
164
+ $m = isset( $_POST['m'] ) ? (int) $_POST['m'] : 0;
165
 
166
  // If a month/year has been selected, parse out the month/year and build the clause
167
  if ( $m > 0 ) {
172
  }
173
 
174
  // Get the month/year from the dropdown
175
+ $today = isset( $_GET['today'] ) ? (int) $_GET['today'] : 0;
176
 
177
  // Parse month/year and build the clause
178
  if ( $today > 0 )
198
  * @returns string Entry status
199
  */
200
  function get_entry_status() {
201
+ if ( !isset( $_GET['entry_status'] ) )
202
  return false;
203
 
204
+ return esc_html( $_GET['entry_status'] );
205
  }
206
 
207
  /**
222
  );
223
 
224
  $total_entries = (int) $num_entries->all;
225
+ $entry_status = isset( $_GET['entry_status'] ) ? $_GET['entry_status'] : 'all';
226
 
227
  foreach ( $stati as $status => $label ) {
228
  $class = ( $status == $entry_status ) ? ' class="current"' : '';
323
  $entry_id = '';
324
 
325
  // Set the Entry ID array
326
+ if ( isset( $_POST['entry'] ) ) :
327
+ if ( is_array( $_POST['entry'] ) )
328
+ $entry_id = $_POST['entry'];
329
  else
330
+ $entry_id = (array) $_POST['entry'];
331
  endif;
332
 
333
  switch( $this->current_action() ) :
353
  break;
354
 
355
  case 'delete' :
356
+ $entry_id = ( isset( $_POST['entry'] ) && is_array( $_POST['entry'] ) ) ? $_POST['entry'] : array( $_POST['entry'] );
357
 
358
  global $wpdb;
359
 
415
  if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) )
416
  return;
417
 
418
+ $m = isset( $_POST['m'] ) ? (int) $_POST['m'] : 0;
419
  ?>
420
  <select name='m'>
421
  <option<?php selected( $m, 0 ); ?> value='0'><?php _e( 'Show all dates' ); ?></option>
506
  $this->_column_headers = array($columns, $hidden, $sortable);
507
 
508
  // Get entries search terms
509
+ $search_terms = ( !empty( $_POST['s'] ) ) ? explode( ' ', $_POST['s'] ) : array();
510
 
511
  $searchand = $search = '';
512
  // Loop through search terms and build query
520
  $search = ( !empty($search) ) ? " AND ({$search}) " : '';
521
 
522
  // Set our ORDER BY and ASC/DESC to sort the entries
523
+ $orderby = ( !empty( $_GET['orderby'] ) ) ? $_GET['orderby'] : 'date';
524
+ $order = ( !empty( $_GET['order'] ) ) ? $_GET['order'] : 'desc';
525
 
526
  // Get the sorted entries
527
  $entries = $this->get_entries( $orderby, $order, $per_page, $offset, $search );
551
  $where .= 'AND form_id = ' . $this->current_filter_action();
552
 
553
  // Get the month/year from the dropdown
554
+ $m = isset( $_POST['m'] ) ? (int) $_POST['m'] : 0;
555
 
556
  // Parse month/year and build the clause
557
  if ( $m > 0 ) {
562
  }
563
 
564
  // Get the month/year from the dropdown
565
+ $today = isset( $_GET['today'] ) ? (int) $_GET['today'] : 0;
566
 
567
  // Parse month/year and build the clause
568
  if ( $today > 0 )
613
  $page_links = array();
614
 
615
  // Added to pick up the months dropdown
616
+ $m = isset( $_POST['m'] ) ? (int) $_POST['m'] : 0;
617
 
618
  $disable_first = $disable_last = '';
619
  if ( $current == 1 )
includes/class-export.php CHANGED
@@ -525,13 +525,13 @@ class VisualFormBuilder_Export {
525
  public function ajax_load_options() {
526
  global $wpdb, $export;
527
 
528
- if ( !isset( $_REQUEST['action'] ) )
529
  return;
530
 
531
- if ( $_REQUEST['action'] !== 'visual_form_builder_export_load_options' )
532
  return;
533
 
534
- $form_id = absint( $_REQUEST['id'] );
535
 
536
  // Safe to get entries now
537
  $entry_ids = $this->get_entry_IDs( $form_id );
@@ -545,11 +545,11 @@ class VisualFormBuilder_Export {
545
  $offset = '';
546
  $limit = 1000;
547
 
548
- if ( isset( $_REQUEST['count'] ) )
549
- $limit = ( $_REQUEST['count'] < 1000 ) ? absint( $_REQUEST['count'] ) : 1000;
550
- elseif ( isset( $_REQUEST['offset'] ) ) {
551
  // Reset offset/page to a zero index
552
- $offset = absint( $_REQUEST['offset'] ) - 1;
553
 
554
  // Calculate the offset
555
  $offset_num = $offset * 1000;
@@ -574,13 +574,13 @@ class VisualFormBuilder_Export {
574
  public function ajax_entries_count() {
575
  global $wpdb, $export;
576
 
577
- if ( !isset( $_REQUEST['action'] ) )
578
  return;
579
 
580
- if ( $_REQUEST['action'] !== 'visual_form_builder_export_entries_count' )
581
  return;
582
 
583
- $form_id = absint( $_REQUEST['id'] );
584
 
585
  echo $export->count_entries( $form_id );
586
 
@@ -620,8 +620,8 @@ class VisualFormBuilder_Export {
620
  * @return string|bool The type of export
621
  */
622
  public function export_action() {
623
- if ( isset( $_REQUEST['vfb-content'] ) )
624
- return $_REQUEST['vfb-content'];
625
 
626
  return false;
627
  }
@@ -636,24 +636,24 @@ class VisualFormBuilder_Export {
636
 
637
  $args = array();
638
 
639
- if ( !isset( $_REQUEST['vfb-content'] ) || 'entries' == $_REQUEST['vfb-content'] ) {
640
  $args['content'] = 'entries';
641
 
642
  $args['format'] = 'csv';
643
 
644
- if ( isset( $_REQUEST['entries_form_id'] ) )
645
- $args['form_id'] = (int) $_REQUEST['entries_form_id'];
646
 
647
- if ( isset( $_REQUEST['entries_start_date'] ) || isset( $_REQUEST['entries_end_date'] ) ) {
648
- $args['start_date'] = $_REQUEST['entries_start_date'];
649
- $args['end_date'] = $_REQUEST['entries_end_date'];
650
  }
651
 
652
- if ( isset( $_REQUEST['entries_columns'] ) )
653
- $args['fields'] = array_map( 'esc_html', $_REQUEST['entries_columns'] );
654
 
655
- if ( isset( $_REQUEST['entries_page'] ) )
656
- $args['page'] = absint( $_REQUEST['entries_page'] );
657
  }
658
 
659
  switch( $this->export_action() ) {
@@ -686,7 +686,7 @@ class VisualFormBuilder_Export {
686
  if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) )
687
  return;
688
 
689
- $m = isset( $_REQUEST['m'] ) ? (int) $_REQUEST['m'] : 0;
690
 
691
  foreach ( $months as $arc_row ) :
692
  if ( 0 == $arc_row->year )
525
  public function ajax_load_options() {
526
  global $wpdb, $export;
527
 
528
+ if ( !isset( $_GET['action'] ) )
529
  return;
530
 
531
+ if ( $_GET['action'] !== 'visual_form_builder_export_load_options' )
532
  return;
533
 
534
+ $form_id = absint( $_GET['id'] );
535
 
536
  // Safe to get entries now
537
  $entry_ids = $this->get_entry_IDs( $form_id );
545
  $offset = '';
546
  $limit = 1000;
547
 
548
+ if ( isset( $_GET['count'] ) )
549
+ $limit = ( $_GET['count'] < 1000 ) ? absint( $_GET['count'] ) : 1000;
550
+ elseif ( isset( $_GET['offset'] ) ) {
551
  // Reset offset/page to a zero index
552
+ $offset = absint( $_GET['offset'] ) - 1;
553
 
554
  // Calculate the offset
555
  $offset_num = $offset * 1000;
574
  public function ajax_entries_count() {
575
  global $wpdb, $export;
576
 
577
+ if ( !isset( $_POST['action'] ) )
578
  return;
579
 
580
+ if ( $_POST['action'] !== 'visual_form_builder_export_entries_count' )
581
  return;
582
 
583
+ $form_id = absint( $_POST['id'] );
584
 
585
  echo $export->count_entries( $form_id );
586
 
620
  * @return string|bool The type of export
621
  */
622
  public function export_action() {
623
+ if ( isset( $_POST['vfb-content'] ) )
624
+ return $_POST['vfb-content'];
625
 
626
  return false;
627
  }
636
 
637
  $args = array();
638
 
639
+ if ( !isset( $_POST['vfb-content'] ) || 'entries' == $_POST['vfb-content'] ) {
640
  $args['content'] = 'entries';
641
 
642
  $args['format'] = 'csv';
643
 
644
+ if ( isset( $_POST['entries_form_id'] ) )
645
+ $args['form_id'] = (int) $_POST['entries_form_id'];
646
 
647
+ if ( isset( $_POST['entries_start_date'] ) || isset( $_POST['entries_end_date'] ) ) {
648
+ $args['start_date'] = $_POST['entries_start_date'];
649
+ $args['end_date'] = $_POST['entries_end_date'];
650
  }
651
 
652
+ if ( isset( $_POST['entries_columns'] ) )
653
+ $args['fields'] = array_map( 'esc_html', $_POST['entries_columns'] );
654
 
655
+ if ( isset( $_POST['entries_page'] ) )
656
+ $args['page'] = absint( $_POST['entries_page'] );
657
  }
658
 
659
  switch( $this->export_action() ) {
686
  if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) )
687
  return;
688
 
689
+ $m = isset( $_POST['m'] ) ? (int) $_POST['m'] : 0;
690
 
691
  foreach ( $months as $arc_row ) :
692
  if ( 0 == $arc_row->year )
includes/class-forms-list.php CHANGED
@@ -80,8 +80,8 @@ class VisualFormBuilder_Forms_List extends WP_List_Table {
80
  $actions = array();
81
 
82
  // Edit Form
83
- $form_title = sprintf( '<strong><a href="?page=%s&form=%s" id="%3$s" class="view-form">%s</a></strong>', $_REQUEST['page'], $item['form_id'], $item['form_title'] );
84
- $actions['edit'] = sprintf( '<a href="?page=%s&action=%s&form=%s" id="%3$s" class="view-form">%s</a>', $_REQUEST['page'], 'edit', $item['form_id'], __( 'Edit', 'visual-form-builder' ) );
85
 
86
  // Duplicate Form
87
  $actions['copy'] = sprintf( '<a href="%s&action=%s&form=%s" id="%3$s" class="view-form">%s</a>', wp_nonce_url( admin_url( 'admin.php?page=visual-form-builder' ), 'copy-form-' . $item['form_id'] ), 'copy_form', $item['form_id'], __( 'Duplicate', 'visual-form-builder' ) );
@@ -187,7 +187,7 @@ class VisualFormBuilder_Forms_List extends WP_List_Table {
187
  );
188
 
189
  $total_entries = (int) $num_forms->all;
190
- $entry_status = isset( $_REQUEST['form_status'] ) ? $_REQUEST['form_status'] : 'all';
191
 
192
  foreach ( $stati as $status => $label ) {
193
  $class = ( $status == $entry_status ) ? ' class="current"' : '';
@@ -315,11 +315,11 @@ class VisualFormBuilder_Forms_List extends WP_List_Table {
315
  $form_id = '';
316
 
317
  // Set the Entry ID array
318
- if ( isset( $_REQUEST['form'] ) ) {
319
- if ( is_array( $_REQUEST['form'] ) )
320
- $form_id = $_REQUEST['form'];
321
  else
322
- $form_id = (array) $_REQUEST['form'];
323
  }
324
 
325
  switch( $this->current_action() ) {
@@ -410,7 +410,7 @@ class VisualFormBuilder_Forms_List extends WP_List_Table {
410
  $this->_column_headers = array($columns, $hidden, $sortable);
411
 
412
  // Get entries search terms
413
- $search_terms = ( !empty( $_REQUEST['s'] ) ) ? explode( ' ', $_REQUEST['s'] ) : array();
414
 
415
  $searchand = $search = '';
416
  // Loop through search terms and build query
@@ -424,8 +424,8 @@ class VisualFormBuilder_Forms_List extends WP_List_Table {
424
  $search = ( !empty($search) ) ? " AND ({$search}) " : '';
425
 
426
  // Set our ORDER BY and ASC/DESC to sort the entries
427
- $orderby = ( !empty( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : 'form_id';
428
- $order = ( !empty( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : 'desc';
429
 
430
  // Get the sorted entries
431
  $forms = $this->get_forms( $orderby, $order, $per_page, $offset, $search );
@@ -497,7 +497,7 @@ class VisualFormBuilder_Forms_List extends WP_List_Table {
497
  $page_links = array();
498
 
499
  // Added to pick up the months dropdown
500
- $m = isset( $_REQUEST['m'] ) ? (int) $_REQUEST['m'] : 0;
501
 
502
  $disable_first = $disable_last = '';
503
  if ( $current == 1 )
80
  $actions = array();
81
 
82
  // Edit Form
83
+ $form_title = sprintf( '<strong><a href="?page=%s&form=%s" id="%3$s" class="view-form">%s</a></strong>', $_GET['page'], $item['form_id'], $item['form_title'] );
84
+ $actions['edit'] = sprintf( '<a href="?page=%s&action=%s&form=%s" id="%3$s" class="view-form">%s</a>', $_GET['page'], 'edit', $item['form_id'], __( 'Edit', 'visual-form-builder' ) );
85
 
86
  // Duplicate Form
87
  $actions['copy'] = sprintf( '<a href="%s&action=%s&form=%s" id="%3$s" class="view-form">%s</a>', wp_nonce_url( admin_url( 'admin.php?page=visual-form-builder' ), 'copy-form-' . $item['form_id'] ), 'copy_form', $item['form_id'], __( 'Duplicate', 'visual-form-builder' ) );
187
  );
188
 
189
  $total_entries = (int) $num_forms->all;
190
+ $entry_status = isset( $_GET['form_status'] ) ? $_GET['form_status'] : 'all';
191
 
192
  foreach ( $stati as $status => $label ) {
193
  $class = ( $status == $entry_status ) ? ' class="current"' : '';
315
  $form_id = '';
316
 
317
  // Set the Entry ID array
318
+ if ( isset( $_POST['form'] ) ) {
319
+ if ( is_array( $_POST['form'] ) )
320
+ $form_id = $_POST['form'];
321
  else
322
+ $form_id = (array) $_POST['form'];
323
  }
324
 
325
  switch( $this->current_action() ) {
410
  $this->_column_headers = array($columns, $hidden, $sortable);
411
 
412
  // Get entries search terms
413
+ $search_terms = ( !empty( $_POST['s'] ) ) ? explode( ' ', $_POST['s'] ) : array();
414
 
415
  $searchand = $search = '';
416
  // Loop through search terms and build query
424
  $search = ( !empty($search) ) ? " AND ({$search}) " : '';
425
 
426
  // Set our ORDER BY and ASC/DESC to sort the entries
427
+ $orderby = ( !empty( $_GET['orderby'] ) ) ? $_GET['orderby'] : 'form_id';
428
+ $order = ( !empty( $_GET['order'] ) ) ? $_GET['order'] : 'desc';
429
 
430
  // Get the sorted entries
431
  $forms = $this->get_forms( $orderby, $order, $per_page, $offset, $search );
497
  $page_links = array();
498
 
499
  // Added to pick up the months dropdown
500
+ $m = isset( $_POST['m'] ) ? (int) $_POST['m'] : 0;
501
 
502
  $disable_first = $disable_last = '';
503
  if ( $current == 1 )
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: mmuro
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=G87A9UN9CLPH4&lc=US&item_name=Visual%20Form%20Builder&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted
4
  Tags: form, forms, contact form, contact forms, form, forms, form to email, email form, email, input, validation, jquery, shortcode, form builder, contact form builder, form manager, form creator
5
- Requires at least: 3.5
6
  Tested up to: 4.3
7
- Stable tag: 2.8.6
8
  License: GPLv2 or later
9
 
10
  Build beautiful, fully functional contact forms in only a few minutes without writing PHP, CSS, or HTML.
@@ -237,6 +237,11 @@ function my_scripts_method() {
237
 
238
  == Changelog ==
239
 
 
 
 
 
 
240
  **Version 2.8.6 - Sep 21, 2015**
241
 
242
  * Update to allow translations to use the WP_LANG_DIR folder for language packs
@@ -673,6 +678,9 @@ function my_scripts_method() {
673
 
674
  == Upgrade Notice ==
675
 
 
 
 
676
  = 2.8.6 =
677
  Update to allow translations to use the WP_LANG_DIR folder for language packs
678
 
2
  Contributors: mmuro
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=G87A9UN9CLPH4&lc=US&item_name=Visual%20Form%20Builder&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted
4
  Tags: form, forms, contact form, contact forms, form, forms, form to email, email form, email, input, validation, jquery, shortcode, form builder, contact form builder, form manager, form creator
5
+ Requires at least: 4.3
6
  Tested up to: 4.3
7
+ Stable tag: 2.8.7
8
  License: GPLv2 or later
9
 
10
  Build beautiful, fully functional contact forms in only a few minutes without writing PHP, CSS, or HTML.
237
 
238
  == Changelog ==
239
 
240
+ **Version 2.8.7 - Mar 30, 2016**
241
+
242
+ * Fix use of deprecated functions
243
+ * Check permissions before adding new forms
244
+
245
  **Version 2.8.6 - Sep 21, 2015**
246
 
247
  * Update to allow translations to use the WP_LANG_DIR folder for language packs
678
 
679
  == Upgrade Notice ==
680
 
681
+ = 2.8.7 =
682
+ This version requires at least WordPress 4.3 or higher due to previous use of deprecated functions
683
+
684
  = 2.8.6 =
685
  Update to allow translations to use the WP_LANG_DIR folder for language packs
686
 
visual-form-builder.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Visual Form Builder
4
  Plugin URI: https://wordpress.org/plugins/visual-form-builder/
5
  Description: Dynamically build forms using a simple interface. Forms include jQuery validation, a basic logic-based verification system, and entry tracking.
6
- Version: 2.8.6
7
  Author: Matthew Muro
8
  Author URI: http://matthewmuro.com
9
  Text Domain: visual-form-builder
@@ -11,7 +11,7 @@ Domain Path: /languages/
11
  */
12
 
13
  // Version number to output as meta tag
14
- define( 'VFB_VERSION', '2.8.6' );
15
 
16
  /*
17
  This program is free software; you can redistribute it and/or modify
@@ -503,7 +503,7 @@ class Visual_Form_Builder{
503
 
504
  case $page_main :
505
 
506
- if ( isset( $_REQUEST['form'] ) ) :
507
  add_screen_option( 'layout_columns', array(
508
  'max' => 2,
509
  'default' => 2
@@ -543,7 +543,7 @@ class Visual_Form_Builder{
543
 
544
  $page_main = $this->_admin_pages[ 'vfb' ];
545
 
546
- if ( $current_screen->id == $page_main && isset( $_REQUEST['form'] ) ) {
547
  add_meta_box( 'vfb_form_items_meta_box', __( 'Form Items', 'visual-form-builder' ), array( &$this, 'meta_box_form_items' ), $page_main, 'side', 'high' );
548
  add_meta_box( 'vfb_form_media_button_tip', __( 'Display Forms', 'visual-form-builder' ), array( &$this, 'meta_box_display_forms' ), $page_main, 'side', 'low' );
549
  }
@@ -603,7 +603,7 @@ class Visual_Form_Builder{
603
  <p><?php _e( 'You may also manually insert the shortcode into a post/page.', 'visual-form-builder' ); ?></p>
604
  <p>
605
  <?php _e( 'Shortcode', 'visual-form-builder' ); ?>
606
- <input value="[vfb id='<?php echo (int) $_REQUEST['form']; ?>']" readonly="readonly" />
607
  </p>
608
  <?php
609
  }
@@ -848,23 +848,26 @@ class Visual_Form_Builder{
848
  public function save_add_new_form() {
849
  global $wpdb;
850
 
851
- if ( !isset( $_REQUEST['action'] ) || !isset( $_GET['page'] ) )
852
  return;
853
 
854
  if ( 'vfb-add-new' !== $_GET['page'] )
855
  return;
856
 
857
- if ( 'create_form' !== $_REQUEST['action'] )
858
  return;
859
 
 
 
 
860
  check_admin_referer( 'create_form' );
861
 
862
- $form_key = sanitize_title( $_REQUEST['form_title'] );
863
- $form_title = esc_html( $_REQUEST['form_title'] );
864
- $form_from_name = esc_html( $_REQUEST['form_email_from_name'] );
865
- $form_subject = esc_html( $_REQUEST['form_email_subject'] );
866
- $form_from = esc_html( $_REQUEST['form_email_from'] );
867
- $form_to = serialize( $_REQUEST['form_email_to'] );
868
 
869
  $newdata = array(
870
  'form_key' => $form_key,
@@ -951,46 +954,46 @@ class Visual_Form_Builder{
951
  public function save_update_form() {
952
  global $wpdb;
953
 
954
- if ( !isset( $_REQUEST['action'] ) || !isset( $_GET['page'] ) )
955
  return;
956
 
957
  if ( 'visual-form-builder' !== $_GET['page'] )
958
  return;
959
 
960
- if ( 'update_form' !== $_REQUEST['action'] )
961
  return;
962
 
963
  check_admin_referer( 'vfb_update_form' );
964
 
965
- $form_id = absint( $_REQUEST['form_id'] );
966
- $form_key = sanitize_title( $_REQUEST['form_title'], $form_id );
967
- $form_title = $_REQUEST['form_title'];
968
- $form_subject = $_REQUEST['form_email_subject'];
969
- $form_to = serialize( array_map( 'sanitize_email', $_REQUEST['form_email_to'] ) );
970
- $form_from = sanitize_email( $_REQUEST['form_email_from'] );
971
- $form_from_name = $_REQUEST['form_email_from_name'];
972
- $form_from_override = isset( $_REQUEST['form_email_from_override'] ) ? $_REQUEST['form_email_from_override'] : '';
973
- $form_from_name_override = isset( $_REQUEST['form_email_from_name_override'] ) ? $_REQUEST['form_email_from_name_override'] : '';
974
- $form_success_type = $_REQUEST['form_success_type'];
975
- $form_notification_setting = isset( $_REQUEST['form_notification_setting'] ) ? $_REQUEST['form_notification_setting'] : '';
976
- $form_notification_email_name = isset( $_REQUEST['form_notification_email_name'] ) ? $_REQUEST['form_notification_email_name'] : '';
977
- $form_notification_email_from = isset( $_REQUEST['form_notification_email_from'] ) ? sanitize_email( $_REQUEST['form_notification_email_from'] ) : '';
978
- $form_notification_email = isset( $_REQUEST['form_notification_email'] ) ? $_REQUEST['form_notification_email'] : '';
979
- $form_notification_subject = isset( $_REQUEST['form_notification_subject'] ) ? $_REQUEST['form_notification_subject'] : '';
980
- $form_notification_message = isset( $_REQUEST['form_notification_message'] ) ? wp_richedit_pre( $_REQUEST['form_notification_message'] ) : '';
981
- $form_notification_entry = isset( $_REQUEST['form_notification_entry'] ) ? $_REQUEST['form_notification_entry'] : '';
982
- $form_label_alignment = $_REQUEST['form_label_alignment'];
983
 
984
  // Add confirmation based on which type was selected
985
  switch ( $form_success_type ) {
986
  case 'text' :
987
- $form_success_message = wp_richedit_pre( $_REQUEST['form_success_message_text'] );
988
  break;
989
  case 'page' :
990
- $form_success_message = $_REQUEST['form_success_message_page'];
991
  break;
992
  case 'redirect' :
993
- $form_success_message = $_REQUEST['form_success_message_redirect'];
994
  break;
995
  }
996
 
@@ -1029,7 +1032,7 @@ class Visual_Form_Builder{
1029
  if ( count( $_POST, COUNT_RECURSIVE ) > $max_post_vars )
1030
  $this->post_max_vars = true;
1031
 
1032
- foreach ( $_REQUEST['field_id'] as $fields ) :
1033
  $field_ids[] = $fields;
1034
  endforeach;
1035
 
@@ -1040,16 +1043,16 @@ class Visual_Form_Builder{
1040
  foreach ( $field_ids as $id ) :
1041
  $id = absint( $id );
1042
 
1043
- $field_name = ( isset( $_REQUEST['field_name-' . $id] ) ) ? trim( $_REQUEST['field_name-' . $id] ) : '';
1044
  $field_key = sanitize_key( sanitize_title( $field_name, $id ) );
1045
- $field_desc = ( isset( $_REQUEST['field_description-' . $id] ) ) ? trim( $_REQUEST['field_description-' . $id] ) : '';
1046
- $field_options = ( isset( $_REQUEST['field_options-' . $id] ) ) ? serialize( array_map( 'trim', $_REQUEST['field_options-' . $id] ) ) : '';
1047
- $field_validation = ( isset( $_REQUEST['field_validation-' . $id] ) ) ? $_REQUEST['field_validation-' . $id] : '';
1048
- $field_required = ( isset( $_REQUEST['field_required-' . $id] ) ) ? $_REQUEST['field_required-' . $id] : '';
1049
- $field_size = ( isset( $_REQUEST['field_size-' . $id] ) ) ? $_REQUEST['field_size-' . $id] : '';
1050
- $field_css = ( isset( $_REQUEST['field_css-' . $id] ) ) ? $_REQUEST['field_css-' . $id] : '';
1051
- $field_layout = ( isset( $_REQUEST['field_layout-' . $id] ) ) ? $_REQUEST['field_layout-' . $id] : '';
1052
- $field_default = ( isset( $_REQUEST['field_default-' . $id] ) ) ? trim( $_REQUEST['field_default-' . $id] ) : '';
1053
 
1054
  $field_data = array(
1055
  'field_key' => $field_key,
@@ -1089,16 +1092,16 @@ class Visual_Form_Builder{
1089
  public function save_trash_delete_form() {
1090
  global $wpdb;
1091
 
1092
- if ( !isset( $_REQUEST['action'] ) || !isset( $_GET['page'] ) )
1093
  return;
1094
 
1095
  if ( 'visual-form-builder' !== $_GET['page'] )
1096
  return;
1097
 
1098
- if ( 'delete_form' !== $_REQUEST['action'] )
1099
  return;
1100
 
1101
- $id = absint( $_REQUEST['form'] );
1102
 
1103
  check_admin_referer( 'delete-form-' . $id );
1104
 
@@ -1122,16 +1125,16 @@ class Visual_Form_Builder{
1122
  public function save_copy_form() {
1123
  global $wpdb;
1124
 
1125
- if ( !isset( $_REQUEST['action'] ) || !isset( $_GET['page'] ) )
1126
  return;
1127
 
1128
  if ( 'visual-form-builder' !== $_GET['page'] )
1129
  return;
1130
 
1131
- if ( 'copy_form' !== $_REQUEST['action'] )
1132
  return;
1133
 
1134
- $id = absint( $_REQUEST['form'] );
1135
 
1136
  check_admin_referer( 'copy-form-' . $id );
1137
 
@@ -1209,6 +1212,10 @@ class Visual_Form_Builder{
1209
  foreach ( $parents as $k => $v ) {
1210
  $wpdb->update( $this->field_table_name, array( 'field_parent' => $v ), array( 'form_id' => $new_form_selected, 'field_parent' => $k ) );
1211
  }
 
 
 
 
1212
  }
1213
 
1214
  /**
@@ -1220,13 +1227,13 @@ class Visual_Form_Builder{
1220
  */
1221
  public function save_settings() {
1222
 
1223
- if ( !isset( $_REQUEST['action'] ) || !isset( $_GET['page'] ) )
1224
  return;
1225
 
1226
  if ( 'vfb-settings' !== $_GET['page'] )
1227
  return;
1228
 
1229
- if ( 'vfb_settings' !== $_REQUEST['action'] )
1230
  return;
1231
 
1232
  check_admin_referer( 'vfb-update-settings' );
@@ -1250,7 +1257,7 @@ class Visual_Form_Builder{
1250
 
1251
  $data = array();
1252
 
1253
- foreach ( $_REQUEST['order'] as $k ) :
1254
  if ( 'root' !== $k['item_id'] && !empty( $k['item_id'] ) ) :
1255
  $data[] = array(
1256
  'field_id' => $k['item_id'],
@@ -1283,16 +1290,16 @@ class Visual_Form_Builder{
1283
  $data = array();
1284
  $field_options = $field_validation = '';
1285
 
1286
- foreach ( $_REQUEST['data'] as $k ) {
1287
  $data[ $k['name'] ] = $k['value'];
1288
  }
1289
 
1290
  check_ajax_referer( 'create-field-' . $data['form_id'], 'nonce' );
1291
 
1292
  $form_id = absint( $data['form_id'] );
1293
- $field_key = sanitize_title( $_REQUEST['field_type'] );
1294
- $field_name = esc_html( $_REQUEST['field_type'] );
1295
- $field_type = strtolower( sanitize_title( $_REQUEST['field_type'] ) );
1296
 
1297
  // Set defaults for validation
1298
  switch ( $field_type ) {
@@ -1373,15 +1380,15 @@ class Visual_Form_Builder{
1373
  public function ajax_delete_field() {
1374
  global $wpdb;
1375
 
1376
- if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'visual_form_builder_delete_field' ) {
1377
- $form_id = absint( $_REQUEST['form'] );
1378
- $field_id = absint( $_REQUEST['field'] );
1379
 
1380
  check_ajax_referer( 'delete-field-' . $form_id, 'nonce' );
1381
 
1382
- if ( isset( $_REQUEST['child_ids'] ) ) {
1383
- foreach ( $_REQUEST['child_ids'] as $children ) {
1384
- $parent = absint( $_REQUEST['parent_id'] );
1385
 
1386
  // Update each child item with the new parent ID
1387
  $wpdb->update( $this->field_table_name, array( 'field_parent' => $parent ), array( 'field_id' => $children ) );
@@ -1401,14 +1408,13 @@ class Visual_Form_Builder{
1401
  * @since 2.2
1402
  */
1403
  public function ajax_form_settings() {
1404
- global $current_user;
1405
- get_currentuserinfo();
1406
 
1407
- if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'visual_form_builder_form_settings' ) {
1408
- $form_id = absint( $_REQUEST['form'] );
1409
- $status = isset( $_REQUEST['status'] ) ? $_REQUEST['status'] : 'opened';
1410
- $accordion = isset( $_REQUEST['accordion'] ) ? $_REQUEST['accordion'] : 'general-settings';
1411
- $user_id = $current_user->ID;
1412
 
1413
  $form_settings = get_user_meta( $user_id, 'vfb-form-settings', true );
1414
 
@@ -1522,13 +1528,13 @@ class Visual_Form_Builder{
1522
  * @since 1.0
1523
  */
1524
  public function admin_notices(){
1525
- if ( !isset( $_REQUEST['action'] ) || !isset( $_GET['page'] ) )
1526
  return;
1527
 
1528
  if ( !in_array( $_GET['page'], array( 'visual-form-builder', 'vfb-add-new', 'vfb-entries', 'vfb-email-design', 'vfb-reports', 'vfb-import', 'vfb-export', 'vfb-settings' ) ) )
1529
  return;
1530
 
1531
- switch( $_REQUEST['action'] ) {
1532
  case 'create_form' :
1533
  echo '<div id="message" class="updated"><p>' . __( 'Form created.' , 'visual-form-builder' ) . '</p></div>';
1534
  break;
@@ -1637,7 +1643,7 @@ class Visual_Form_Builder{
1637
  ?>
1638
  </h2>
1639
  <?php
1640
- if ( isset( $_REQUEST['action'] ) && in_array( $_REQUEST['action'], array( 'view', 'edit', 'update_entry' ) ) ) :
1641
  $entries_detail->entries_detail();
1642
  else :
1643
  $entries_list->views();
@@ -1790,15 +1796,15 @@ class Visual_Form_Builder{
1790
  * @since 1.0
1791
  */
1792
  public function admin() {
1793
- global $wpdb, $current_user;
1794
 
1795
- get_currentuserinfo();
1796
 
1797
  // Save current user ID
1798
- $user_id = $current_user->ID;
1799
 
1800
  // Set variables depending on which tab is selected
1801
- $form_nav_selected_id = ( isset( $_REQUEST['form'] ) ) ? $_REQUEST['form'] : '0';
1802
  ?>
1803
  <div class="wrap">
1804
  <h2>
@@ -1880,9 +1886,9 @@ class Visual_Form_Builder{
1880
  function confirmation(){
1881
  global $wpdb;
1882
 
1883
- $form_id = ( isset( $_REQUEST['form_id'] ) ) ? (int) esc_html( $_REQUEST['form_id'] ) : '';
1884
 
1885
- if ( !isset( $_REQUEST['vfb-submit'] ) )
1886
  return;
1887
 
1888
  // Get forms
3
  Plugin Name: Visual Form Builder
4
  Plugin URI: https://wordpress.org/plugins/visual-form-builder/
5
  Description: Dynamically build forms using a simple interface. Forms include jQuery validation, a basic logic-based verification system, and entry tracking.
6
+ Version: 2.8.7
7
  Author: Matthew Muro
8
  Author URI: http://matthewmuro.com
9
  Text Domain: visual-form-builder
11
  */
12
 
13
  // Version number to output as meta tag
14
+ define( 'VFB_VERSION', '2.8.7' );
15
 
16
  /*
17
  This program is free software; you can redistribute it and/or modify
503
 
504
  case $page_main :
505
 
506
+ if ( isset( $_GET['form'] ) ) :
507
  add_screen_option( 'layout_columns', array(
508
  'max' => 2,
509
  'default' => 2
543
 
544
  $page_main = $this->_admin_pages[ 'vfb' ];
545
 
546
+ if ( $current_screen->id == $page_main && isset( $_GET['form'] ) ) {
547
  add_meta_box( 'vfb_form_items_meta_box', __( 'Form Items', 'visual-form-builder' ), array( &$this, 'meta_box_form_items' ), $page_main, 'side', 'high' );
548
  add_meta_box( 'vfb_form_media_button_tip', __( 'Display Forms', 'visual-form-builder' ), array( &$this, 'meta_box_display_forms' ), $page_main, 'side', 'low' );
549
  }
603
  <p><?php _e( 'You may also manually insert the shortcode into a post/page.', 'visual-form-builder' ); ?></p>
604
  <p>
605
  <?php _e( 'Shortcode', 'visual-form-builder' ); ?>
606
+ <input value="[vfb id='<?php echo (int) $_GET['form']; ?>']" readonly="readonly" />
607
  </p>
608
  <?php
609
  }
848
  public function save_add_new_form() {
849
  global $wpdb;
850
 
851
+ if ( !isset( $_POST['action'] ) || !isset( $_GET['page'] ) )
852
  return;
853
 
854
  if ( 'vfb-add-new' !== $_GET['page'] )
855
  return;
856
 
857
+ if ( 'create_form' !== $_POST['action'] )
858
  return;
859
 
860
+ if ( !current_user_can( 'manage_options' ) )
861
+ wp_die( __( 'You do not have sufficient permissions to create a new form.', 'visual-form-builder' ) );
862
+
863
  check_admin_referer( 'create_form' );
864
 
865
+ $form_key = sanitize_title( $_POST['form_title'] );
866
+ $form_title = esc_html( $_POST['form_title'] );
867
+ $form_from_name = esc_html( $_POST['form_email_from_name'] );
868
+ $form_subject = esc_html( $_POST['form_email_subject'] );
869
+ $form_from = esc_html( $_POST['form_email_from'] );
870
+ $form_to = serialize( $_POST['form_email_to'] );
871
 
872
  $newdata = array(
873
  'form_key' => $form_key,
954
  public function save_update_form() {
955
  global $wpdb;
956
 
957
+ if ( !isset( $_POST['action'] ) || !isset( $_GET['page'] ) )
958
  return;
959
 
960
  if ( 'visual-form-builder' !== $_GET['page'] )
961
  return;
962
 
963
+ if ( 'update_form' !== $_POST['action'] )
964
  return;
965
 
966
  check_admin_referer( 'vfb_update_form' );
967
 
968
+ $form_id = absint( $_POST['form_id'] );
969
+ $form_key = sanitize_title( $_POST['form_title'], $form_id );
970
+ $form_title = $_POST['form_title'];
971
+ $form_subject = $_POST['form_email_subject'];
972
+ $form_to = serialize( array_map( 'sanitize_email', $_POST['form_email_to'] ) );
973
+ $form_from = sanitize_email( $_POST['form_email_from'] );
974
+ $form_from_name = $_POST['form_email_from_name'];
975
+ $form_from_override = isset( $_POST['form_email_from_override'] ) ? $_POST['form_email_from_override'] : '';
976
+ $form_from_name_override = isset( $_POST['form_email_from_name_override'] ) ? $_POST['form_email_from_name_override'] : '';
977
+ $form_success_type = $_POST['form_success_type'];
978
+ $form_notification_setting = isset( $_POST['form_notification_setting'] ) ? $_POST['form_notification_setting'] : '';
979
+ $form_notification_email_name = isset( $_POST['form_notification_email_name'] ) ? $_POST['form_notification_email_name'] : '';
980
+ $form_notification_email_from = isset( $_POST['form_notification_email_from'] ) ? sanitize_email( $_POST['form_notification_email_from'] ) : '';
981
+ $form_notification_email = isset( $_POST['form_notification_email'] ) ? $_POST['form_notification_email'] : '';
982
+ $form_notification_subject = isset( $_POST['form_notification_subject'] ) ? $_POST['form_notification_subject'] : '';
983
+ $form_notification_message = isset( $_POST['form_notification_message'] ) ? format_for_editor( $_POST['form_notification_message'] ) : '';
984
+ $form_notification_entry = isset( $_POST['form_notification_entry'] ) ? $_POST['form_notification_entry'] : '';
985
+ $form_label_alignment = $_POST['form_label_alignment'];
986
 
987
  // Add confirmation based on which type was selected
988
  switch ( $form_success_type ) {
989
  case 'text' :
990
+ $form_success_message = format_for_editor( $_POST['form_success_message_text'] );
991
  break;
992
  case 'page' :
993
+ $form_success_message = $_POST['form_success_message_page'];
994
  break;
995
  case 'redirect' :
996
+ $form_success_message = $_POST['form_success_message_redirect'];
997
  break;
998
  }
999
 
1032
  if ( count( $_POST, COUNT_RECURSIVE ) > $max_post_vars )
1033
  $this->post_max_vars = true;
1034
 
1035
+ foreach ( $_POST['field_id'] as $fields ) :
1036
  $field_ids[] = $fields;
1037
  endforeach;
1038
 
1043
  foreach ( $field_ids as $id ) :
1044
  $id = absint( $id );
1045
 
1046
+ $field_name = isset( $_POST['field_name-' . $id] ) ? trim( $_POST['field_name-' . $id] ) : '';
1047
  $field_key = sanitize_key( sanitize_title( $field_name, $id ) );
1048
+ $field_desc = isset( $_POST['field_description-' . $id] ) ? trim( $_POST['field_description-' . $id] ) : '';
1049
+ $field_options = isset( $_POST['field_options-' . $id] ) ? serialize( array_map( 'trim', $_POST['field_options-' . $id] ) ) : '';
1050
+ $field_validation = isset( $_POST['field_validation-' . $id] ) ? $_POST['field_validation-' . $id] : '';
1051
+ $field_required = isset( $_POST['field_required-' . $id] ) ? $_POST['field_required-' . $id] : '';
1052
+ $field_size = isset( $_POST['field_size-' . $id] ) ? $_POST['field_size-' . $id] : '';
1053
+ $field_css = isset( $_POST['field_css-' . $id] ) ? $_POST['field_css-' . $id] : '';
1054
+ $field_layout = isset( $_POST['field_layout-' . $id] ) ? $_POST['field_layout-' . $id] : '';
1055
+ $field_default = isset( $_POST['field_default-' . $id] ) ? trim( $_POST['field_default-' . $id] ) : '';
1056
 
1057
  $field_data = array(
1058
  'field_key' => $field_key,
1092
  public function save_trash_delete_form() {
1093
  global $wpdb;
1094
 
1095
+ if ( !isset( $_GET['action'] ) || !isset( $_GET['page'] ) )
1096
  return;
1097
 
1098
  if ( 'visual-form-builder' !== $_GET['page'] )
1099
  return;
1100
 
1101
+ if ( 'delete_form' !== $_GET['action'] )
1102
  return;
1103
 
1104
+ $id = absint( $_GET['form'] );
1105
 
1106
  check_admin_referer( 'delete-form-' . $id );
1107
 
1125
  public function save_copy_form() {
1126
  global $wpdb;
1127
 
1128
+ if ( !isset( $_GET['action'] ) || !isset( $_GET['page'] ) )
1129
  return;
1130
 
1131
  if ( 'visual-form-builder' !== $_GET['page'] )
1132
  return;
1133
 
1134
+ if ( 'copy_form' !== $_GET['action'] )
1135
  return;
1136
 
1137
+ $id = absint( $_GET['form'] );
1138
 
1139
  check_admin_referer( 'copy-form-' . $id );
1140
 
1212
  foreach ( $parents as $k => $v ) {
1213
  $wpdb->update( $this->field_table_name, array( 'field_parent' => $v ), array( 'form_id' => $new_form_selected, 'field_parent' => $k ) );
1214
  }
1215
+
1216
+ // Redirect to keep the URL clean (use AJAX in the future?)
1217
+ wp_redirect( 'admin.php?page=visual-form-builder&action=edit&form=' . $new_form_selected );
1218
+ exit();
1219
  }
1220
 
1221
  /**
1227
  */
1228
  public function save_settings() {
1229
 
1230
+ if ( !isset( $_POST['action'] ) || !isset( $_GET['page'] ) )
1231
  return;
1232
 
1233
  if ( 'vfb-settings' !== $_GET['page'] )
1234
  return;
1235
 
1236
+ if ( 'vfb_settings' !== $_POST['action'] )
1237
  return;
1238
 
1239
  check_admin_referer( 'vfb-update-settings' );
1257
 
1258
  $data = array();
1259
 
1260
+ foreach ( $_POST['order'] as $k ) :
1261
  if ( 'root' !== $k['item_id'] && !empty( $k['item_id'] ) ) :
1262
  $data[] = array(
1263
  'field_id' => $k['item_id'],
1290
  $data = array();
1291
  $field_options = $field_validation = '';
1292
 
1293
+ foreach ( $_POST['data'] as $k ) {
1294
  $data[ $k['name'] ] = $k['value'];
1295
  }
1296
 
1297
  check_ajax_referer( 'create-field-' . $data['form_id'], 'nonce' );
1298
 
1299
  $form_id = absint( $data['form_id'] );
1300
+ $field_key = sanitize_title( $_POST['field_type'] );
1301
+ $field_name = esc_html( $_POST['field_type'] );
1302
+ $field_type = strtolower( sanitize_title( $_POST['field_type'] ) );
1303
 
1304
  // Set defaults for validation
1305
  switch ( $field_type ) {
1380
  public function ajax_delete_field() {
1381
  global $wpdb;
1382
 
1383
+ if ( isset( $_POST['action'] ) && $_POST['action'] == 'visual_form_builder_delete_field' ) {
1384
+ $form_id = absint( $_POST['form'] );
1385
+ $field_id = absint( $_POST['field'] );
1386
 
1387
  check_ajax_referer( 'delete-field-' . $form_id, 'nonce' );
1388
 
1389
+ if ( isset( $_POST['child_ids'] ) ) {
1390
+ foreach ( $_POST['child_ids'] as $children ) {
1391
+ $parent = absint( $_POST['parent_id'] );
1392
 
1393
  // Update each child item with the new parent ID
1394
  $wpdb->update( $this->field_table_name, array( 'field_parent' => $parent ), array( 'field_id' => $children ) );
1408
  * @since 2.2
1409
  */
1410
  public function ajax_form_settings() {
1411
+ $current_user = wp_get_current_user();
 
1412
 
1413
+ if ( isset( $_POST['action'] ) && $_POST['action'] == 'visual_form_builder_form_settings' ) {
1414
+ $form_id = absint( $_POST['form'] );
1415
+ $status = isset( $_POST['status'] ) ? $_POST['status'] : 'opened';
1416
+ $accordion = isset( $_POST['accordion'] ) ? $_POST['accordion'] : 'general-settings';
1417
+ $user_id = $current_user instanceof WP_User ? $current_user->ID : 1;
1418
 
1419
  $form_settings = get_user_meta( $user_id, 'vfb-form-settings', true );
1420
 
1528
  * @since 1.0
1529
  */
1530
  public function admin_notices(){
1531
+ if ( !isset( $_POST['action'] ) || !isset( $_GET['page'] ) )
1532
  return;
1533
 
1534
  if ( !in_array( $_GET['page'], array( 'visual-form-builder', 'vfb-add-new', 'vfb-entries', 'vfb-email-design', 'vfb-reports', 'vfb-import', 'vfb-export', 'vfb-settings' ) ) )
1535
  return;
1536
 
1537
+ switch( $_POST['action'] ) {
1538
  case 'create_form' :
1539
  echo '<div id="message" class="updated"><p>' . __( 'Form created.' , 'visual-form-builder' ) . '</p></div>';
1540
  break;
1643
  ?>
1644
  </h2>
1645
  <?php
1646
+ if ( isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'view', 'edit', 'update_entry' ) ) ) :
1647
  $entries_detail->entries_detail();
1648
  else :
1649
  $entries_list->views();
1796
  * @since 1.0
1797
  */
1798
  public function admin() {
1799
+ global $wpdb;
1800
 
1801
+ $current_user = wp_get_current_user();
1802
 
1803
  // Save current user ID
1804
+ $user_id = $current_user instanceof WP_User ? $current_user->ID : 1;
1805
 
1806
  // Set variables depending on which tab is selected
1807
+ $form_nav_selected_id = isset( $_GET['form'] ) ? $_GET['form'] : '0';
1808
  ?>
1809
  <div class="wrap">
1810
  <h2>
1886
  function confirmation(){
1887
  global $wpdb;
1888
 
1889
+ $form_id = isset( $_POST['form_id'] ) ? (int) esc_html( $_POST['form_id'] ) : '';
1890
 
1891
+ if ( !isset( $_POST['vfb-submit'] ) )
1892
  return;
1893
 
1894
  // Get forms