Visual Form Builder - Version 2.9.6

Version Description

Download this release

Release Info

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

Code changes from version 2.9.5 to 2.9.6

Files changed (3) hide show
  1. admin/class-export.php +44 -40
  2. readme.txt +6 -2
  3. visual-form-builder.php +2 -2
admin/class-export.php CHANGED
@@ -20,6 +20,9 @@ class Visual_Form_Builder_Export {
20
  */
21
  public $default_cols;
22
 
 
 
 
23
  public function __construct(){
24
  global $wpdb;
25
 
@@ -60,22 +63,22 @@ class Visual_Form_Builder_Export {
60
  $where = apply_filters( 'vfb_pre_get_forms_export', '' );
61
  $forms = $wpdb->get_results( "SELECT form_id, form_key, form_title FROM " . VFB_WP_FORMS_TABLE_NAME . " WHERE 1=1 $where ORDER BY $order" );
62
 
63
- if ( !$forms ) :
64
  echo sprintf(
65
  '<div class="vfb-form-alpha-list"><h3 id="vfb-no-forms">You currently do not have any forms. Click on the <a href="%1$s">New Form</a> button to get started.</h3></div>',
66
  esc_url( admin_url( 'admin.php?page=vfb-add-new' ) )
67
  );
68
 
69
  return;
70
- endif;
71
 
72
  $entries_count = $this->count_entries( $forms[0]->form_id );
73
 
74
  // Return nothing if no entries found
75
- if ( !$entries_count ) :
76
  $no_entries = __( 'No entries to pull field names from.', 'visual-form-builder' );
77
- else :
78
-
79
  $limit = $entries_count > 1000 ? 1000 : $entries_count;
80
 
81
  // Safe to get entries now
@@ -86,8 +89,7 @@ class Visual_Form_Builder_Export {
86
 
87
  // Get JSON data
88
  $data = json_decode( $columns, true );
89
- endif;
90
-
91
  ?>
92
  <form method="post" id="vfb-export">
93
  <p><?php _e( 'Backup and save some or all of your Visual Form Builder data.', 'visual-form-builder' ); ?></p>
@@ -115,14 +117,14 @@ class Visual_Form_Builder_Export {
115
  <label class="vfb-export-label" for="form_id"><?php _e( 'Form', 'visual-form-builder' ); ?>:</label>
116
  <select id="vfb-export-entries-forms" name="entries_form_id">
117
  <?php
118
- foreach ( $forms as $form ) :
119
  echo sprintf(
120
  '<option value="%1$d" id="%2$s">%1$d - %3$s</option>',
121
  $form->form_id,
122
  $form->form_key,
123
  stripslashes( $form->form_title )
124
  );
125
- endforeach;
126
  ?>
127
  </select>
128
  </li>
@@ -269,10 +271,8 @@ class Visual_Form_Builder_Export {
269
  $output = array();
270
 
271
  // Loop through all entries
272
- foreach ( $entries as $entry ) :
273
-
274
- foreach ( $entry as $key => $value ) :
275
-
276
  switch ( $key ) {
277
  case 'entries_id':
278
  case 'date_submitted':
@@ -294,7 +294,7 @@ class Visual_Form_Builder_Export {
294
  // Make sure there are no errors with unserializing before proceeding
295
  if ( is_array( $fields ) ) {
296
  // Loop through our submitted data
297
- foreach ( $fields as $field_key => $field_value ) :
298
  // Cast each array as an object
299
  $obj = (object) $field_value;
300
 
@@ -332,13 +332,13 @@ class Visual_Form_Builder_Export {
332
 
333
  break;
334
  } //end $obj switch
335
- endforeach; // end $fields loop
336
  }
337
  break;
338
  } //end $key switch
339
- endforeach; // end $entry loop
340
  $row++;
341
- endforeach; //end $entries loop
342
 
343
  return json_encode( $output );
344
  }
@@ -411,14 +411,12 @@ class Visual_Form_Builder_Export {
411
 
412
  $where = '';
413
 
414
- if ( $form_id ) :
415
  $where .= $wpdb->prepare( " AND form_id = %d", $form_id );
416
 
417
  $count = $this->count_entries( $form_id );
418
  $where .= " LIMIT $count";
419
- endif;
420
-
421
-
422
 
423
  $entry_ids = $wpdb->get_col( "SELECT DISTINCT entries_id FROM " . VFB_WP_ENTRIES_TABLE_NAME . " WHERE entry_approved = 1 $where" );
424
 
@@ -443,20 +441,20 @@ class Visual_Form_Builder_Export {
443
  $rows = $fields_clean = $fields_header = array();
444
 
445
  // Decode special characters
446
- foreach ( $fields as $field ) :
447
  // Strip unique ID for a clean header
448
  $search = preg_replace( '/{{(\d+)}}/', '', $field );
449
  $fields_header[] = wp_specialchars_decode( $search, ENT_QUOTES );
450
 
451
  // Field with unique ID to use as matching data
452
  $fields_clean[] = wp_specialchars_decode( $field, ENT_QUOTES );
453
- endforeach;
454
 
455
  // Build headers
456
  fputcsv( $fh, $fields_header, $this->delimiter );
457
 
458
  // Build table rows and cells
459
- foreach ( $data as $row ) :
460
 
461
  foreach ( $fields_clean as $label ) {
462
  $label = wp_specialchars_decode( $label );
@@ -464,8 +462,7 @@ class Visual_Form_Builder_Export {
464
  }
465
 
466
  fputcsv( $fh, $rows, $this->delimiter );
467
-
468
- endforeach;
469
 
470
  // Close the file
471
  fclose( $fh );
@@ -481,7 +478,7 @@ class Visual_Form_Builder_Export {
481
  * @return string Either no entries or the entry headers
482
  */
483
  public function ajax_load_options() {
484
- global $wpdb, $export;
485
 
486
  if ( !isset( $_GET['action'] ) )
487
  return;
@@ -503,8 +500,9 @@ class Visual_Form_Builder_Export {
503
  $offset = '';
504
  $limit = 1000;
505
 
506
- if ( isset( $_GET['count'] ) )
507
  $limit = ( $_GET['count'] < 1000 ) ? absint( $_GET['count'] ) : 1000;
 
508
  elseif ( isset( $_GET['offset'] ) ) {
509
  // Reset offset/page to a zero index
510
  $offset = absint( $_GET['offset'] ) - 1;
@@ -519,7 +517,7 @@ class Visual_Form_Builder_Export {
519
  $entries = $wpdb->get_results( "SELECT data FROM " . VFB_WP_ENTRIES_TABLE_NAME . " WHERE form_id = $form_id AND entry_approved = 1 LIMIT $limit $offset", ARRAY_A );
520
 
521
  // Get columns
522
- $columns = $export->get_cols( $entries );
523
 
524
  // Get JSON data
525
  $data = json_decode( $columns, true );
@@ -529,8 +527,12 @@ class Visual_Form_Builder_Export {
529
  wp_die();
530
  }
531
 
 
 
 
 
532
  public function ajax_entries_count() {
533
- global $wpdb, $export;
534
 
535
  if ( !isset( $_GET['action'] ) )
536
  return;
@@ -540,32 +542,36 @@ class Visual_Form_Builder_Export {
540
 
541
  $form_id = absint( $_GET['id'] );
542
 
543
- echo $export->count_entries( $form_id );
544
 
545
  wp_die();
546
  }
547
 
 
 
 
 
 
548
  public function build_options( $data ) {
549
-
550
  $output = '';
551
 
552
  $array = array();
553
- foreach ( $data as $row ) :
554
  $array = array_merge( $row, $array );
555
- endforeach;
556
 
557
  $array = array_keys( $array );
558
  $array = array_values( array_merge( $this->default_cols, $array ) );
559
  $array = array_map( 'stripslashes', $array );
560
 
561
- foreach ( $array as $k => $v ) :
562
  $selected = ( in_array( $v, $this->default_cols ) ) ? ' checked="checked"' : '';
563
 
564
  // Strip unique ID for a clean list
565
  $search = preg_replace( '/{{(\d+)}}/', '', $v );
566
 
567
  $output .= sprintf( '<label for="vfb-display-entries-val-%1$d"><input name="entries_columns[]" class="vfb-display-entries-vals" id="vfb-display-entries-val-%1$d" type="checkbox" value="%4$s" %3$s> %2$s</label><br>', $k, $search, $selected, esc_attr( $v ) );
568
- endforeach;
569
 
570
  return $output;
571
  }
@@ -591,7 +597,6 @@ class Visual_Form_Builder_Export {
591
  *
592
  */
593
  public function process_export_action() {
594
-
595
  $args = array();
596
 
597
  if ( !isset( $_POST['vfb-content'] ) || 'entries' == $_POST['vfb-content'] ) {
@@ -646,7 +651,7 @@ class Visual_Form_Builder_Export {
646
 
647
  $m = isset( $_POST['m'] ) ? (int) $_POST['m'] : 0;
648
 
649
- foreach ( $months as $arc_row ) :
650
  if ( 0 == $arc_row->year )
651
  continue;
652
 
@@ -657,7 +662,6 @@ class Visual_Form_Builder_Export {
657
  esc_attr( $arc_row->year . '-' . $month ),
658
  sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $month ), $year )
659
  );
660
- endforeach;
661
-
662
  }
663
  }
20
  */
21
  public $default_cols;
22
 
23
+ /**
24
+ * [__construct description]
25
+ */
26
  public function __construct(){
27
  global $wpdb;
28
 
63
  $where = apply_filters( 'vfb_pre_get_forms_export', '' );
64
  $forms = $wpdb->get_results( "SELECT form_id, form_key, form_title FROM " . VFB_WP_FORMS_TABLE_NAME . " WHERE 1=1 $where ORDER BY $order" );
65
 
66
+ if ( !$forms ) {
67
  echo sprintf(
68
  '<div class="vfb-form-alpha-list"><h3 id="vfb-no-forms">You currently do not have any forms. Click on the <a href="%1$s">New Form</a> button to get started.</h3></div>',
69
  esc_url( admin_url( 'admin.php?page=vfb-add-new' ) )
70
  );
71
 
72
  return;
73
+ }
74
 
75
  $entries_count = $this->count_entries( $forms[0]->form_id );
76
 
77
  // Return nothing if no entries found
78
+ if ( !$entries_count ) {
79
  $no_entries = __( 'No entries to pull field names from.', 'visual-form-builder' );
80
+ }
81
+ else {
82
  $limit = $entries_count > 1000 ? 1000 : $entries_count;
83
 
84
  // Safe to get entries now
89
 
90
  // Get JSON data
91
  $data = json_decode( $columns, true );
92
+ }
 
93
  ?>
94
  <form method="post" id="vfb-export">
95
  <p><?php _e( 'Backup and save some or all of your Visual Form Builder data.', 'visual-form-builder' ); ?></p>
117
  <label class="vfb-export-label" for="form_id"><?php _e( 'Form', 'visual-form-builder' ); ?>:</label>
118
  <select id="vfb-export-entries-forms" name="entries_form_id">
119
  <?php
120
+ foreach ( $forms as $form ) {
121
  echo sprintf(
122
  '<option value="%1$d" id="%2$s">%1$d - %3$s</option>',
123
  $form->form_id,
124
  $form->form_key,
125
  stripslashes( $form->form_title )
126
  );
127
+ }
128
  ?>
129
  </select>
130
  </li>
271
  $output = array();
272
 
273
  // Loop through all entries
274
+ foreach ( $entries as $entry ) {
275
+ foreach ( $entry as $key => $value ) {
 
 
276
  switch ( $key ) {
277
  case 'entries_id':
278
  case 'date_submitted':
294
  // Make sure there are no errors with unserializing before proceeding
295
  if ( is_array( $fields ) ) {
296
  // Loop through our submitted data
297
+ foreach ( $fields as $field_key => $field_value ) {
298
  // Cast each array as an object
299
  $obj = (object) $field_value;
300
 
332
 
333
  break;
334
  } //end $obj switch
335
+ } // end $fields loop
336
  }
337
  break;
338
  } //end $key switch
339
+ } // end $entry loop
340
  $row++;
341
+ } //end $entries loop
342
 
343
  return json_encode( $output );
344
  }
411
 
412
  $where = '';
413
 
414
+ if ( $form_id ) {
415
  $where .= $wpdb->prepare( " AND form_id = %d", $form_id );
416
 
417
  $count = $this->count_entries( $form_id );
418
  $where .= " LIMIT $count";
419
+ }
 
 
420
 
421
  $entry_ids = $wpdb->get_col( "SELECT DISTINCT entries_id FROM " . VFB_WP_ENTRIES_TABLE_NAME . " WHERE entry_approved = 1 $where" );
422
 
441
  $rows = $fields_clean = $fields_header = array();
442
 
443
  // Decode special characters
444
+ foreach ( $fields as $field ) {
445
  // Strip unique ID for a clean header
446
  $search = preg_replace( '/{{(\d+)}}/', '', $field );
447
  $fields_header[] = wp_specialchars_decode( $search, ENT_QUOTES );
448
 
449
  // Field with unique ID to use as matching data
450
  $fields_clean[] = wp_specialchars_decode( $field, ENT_QUOTES );
451
+ }
452
 
453
  // Build headers
454
  fputcsv( $fh, $fields_header, $this->delimiter );
455
 
456
  // Build table rows and cells
457
+ foreach ( $data as $row ) {
458
 
459
  foreach ( $fields_clean as $label ) {
460
  $label = wp_specialchars_decode( $label );
462
  }
463
 
464
  fputcsv( $fh, $rows, $this->delimiter );
465
+ }
 
466
 
467
  // Close the file
468
  fclose( $fh );
478
  * @return string Either no entries or the entry headers
479
  */
480
  public function ajax_load_options() {
481
+ global $wpdb;
482
 
483
  if ( !isset( $_GET['action'] ) )
484
  return;
500
  $offset = '';
501
  $limit = 1000;
502
 
503
+ if ( isset( $_GET['count'] ) ) {
504
  $limit = ( $_GET['count'] < 1000 ) ? absint( $_GET['count'] ) : 1000;
505
+ }
506
  elseif ( isset( $_GET['offset'] ) ) {
507
  // Reset offset/page to a zero index
508
  $offset = absint( $_GET['offset'] ) - 1;
517
  $entries = $wpdb->get_results( "SELECT data FROM " . VFB_WP_ENTRIES_TABLE_NAME . " WHERE form_id = $form_id AND entry_approved = 1 LIMIT $limit $offset", ARRAY_A );
518
 
519
  // Get columns
520
+ $columns = $this->get_cols( $entries );
521
 
522
  // Get JSON data
523
  $data = json_decode( $columns, true );
527
  wp_die();
528
  }
529
 
530
+ /**
531
+ * [ajax_entries_count description]
532
+ * @return [type] [description]
533
+ */
534
  public function ajax_entries_count() {
535
+ global $wpdb;
536
 
537
  if ( !isset( $_GET['action'] ) )
538
  return;
542
 
543
  $form_id = absint( $_GET['id'] );
544
 
545
+ echo $this->count_entries( $form_id );
546
 
547
  wp_die();
548
  }
549
 
550
+ /**
551
+ * [build_options description]
552
+ * @param [type] $data [description]
553
+ * @return [type] [description]
554
+ */
555
  public function build_options( $data ) {
 
556
  $output = '';
557
 
558
  $array = array();
559
+ foreach ( $data as $row ) {
560
  $array = array_merge( $row, $array );
561
+ }
562
 
563
  $array = array_keys( $array );
564
  $array = array_values( array_merge( $this->default_cols, $array ) );
565
  $array = array_map( 'stripslashes', $array );
566
 
567
+ foreach ( $array as $k => $v ) {
568
  $selected = ( in_array( $v, $this->default_cols ) ) ? ' checked="checked"' : '';
569
 
570
  // Strip unique ID for a clean list
571
  $search = preg_replace( '/{{(\d+)}}/', '', $v );
572
 
573
  $output .= sprintf( '<label for="vfb-display-entries-val-%1$d"><input name="entries_columns[]" class="vfb-display-entries-vals" id="vfb-display-entries-val-%1$d" type="checkbox" value="%4$s" %3$s> %2$s</label><br>', $k, $search, $selected, esc_attr( $v ) );
574
+ }
575
 
576
  return $output;
577
  }
597
  *
598
  */
599
  public function process_export_action() {
 
600
  $args = array();
601
 
602
  if ( !isset( $_POST['vfb-content'] ) || 'entries' == $_POST['vfb-content'] ) {
651
 
652
  $m = isset( $_POST['m'] ) ? (int) $_POST['m'] : 0;
653
 
654
+ foreach ( $months as $arc_row ) {
655
  if ( 0 == $arc_row->year )
656
  continue;
657
 
662
  esc_attr( $arc_row->year . '-' . $month ),
663
  sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $month ), $year )
664
  );
665
+ }
 
666
  }
667
  }
readme.txt CHANGED
@@ -3,8 +3,8 @@ 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.9.2
7
- Stable tag: 2.9.5
8
  License: GPLv2 or later
9
 
10
  Build beautiful, fully functional contact forms in only a few minutes without writing PHP, CSS, or HTML.
@@ -230,6 +230,10 @@ function my_scripts_method() {
230
 
231
  == Changelog ==
232
 
 
 
 
 
233
  **Version 2.9.5 - Feb 11, 2018**
234
 
235
  * Refactor structure of plugin
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.9.4
7
+ Stable tag: 2.9.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.
230
 
231
  == Changelog ==
232
 
233
+ **Version 2.9.6 - Feb 12, 2018**
234
+
235
+ * Fix bug with export
236
+
237
  **Version 2.9.5 - Feb 11, 2018**
238
 
239
  * Refactor structure of plugin
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.9.5
7
  Author: Matthew Muro
8
  Author URI: http://vfbpro.com
9
  Text Domain: visual-form-builder
@@ -26,7 +26,7 @@ class Visual_Form_Builder {
26
  * The current version of the plugin.
27
  * @var [type]
28
  */
29
- protected $version = '2.9.5';
30
 
31
  /**
32
  * The current DB version. Used if we need to update the DB later.
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.9.6
7
  Author: Matthew Muro
8
  Author URI: http://vfbpro.com
9
  Text Domain: visual-form-builder
26
  * The current version of the plugin.
27
  * @var [type]
28
  */
29
+ protected $version = '2.9.6';
30
 
31
  /**
32
  * The current DB version. Used if we need to update the DB later.