Formidable Forms – Form Builder for WordPress - Version 2.0.05

Version Description

  • Remove deprecated jQuery toggle() calls
  • Add html ids to hidden fields
  • Make sure the entry name doesn't exceed allowed database field size
  • Adjust user agent displayed values
  • Update Bootstrap javascript to v3.3.4
  • Clear more caching for forms, fields, and entries when changes are made
  • Lite only: Remove the entry search box on the entries page since the functionality is in pro
  • Pro: Fix issue with the CSV export on the Import/Export page
  • Pro: Allow for FRMRULES to be on the page multiple times for ajax-loaded forms
  • Pro: Add frmThemeOverride_jsErrors function hook
  • Pro: Conditionally require fields in a conditional embedded form
  • Pro: Fix date calculations and calculations across multiple pages
  • Pro: Show the user display name by default with dynamic fields using a user ID field
  • Pro: Fix read-only date fields on form submitted with ajax
  • Pro: Fix issue with browsing view revisions
  • Pro: Fix numeric phone formats without other characters
  • Pro: Update masked input js to v1.4
  • Pro: Fix issue with NaN showing instead of 0 in values without a number
  • Pro: Fix conflict with Easy Digital download auto-updating
  • Pro: Include list dynamic fields in the CSV and default email message
  • Pro: Match up logic when an option with & is selected
Download this release

Release Info

Developer sswells
Plugin Icon 128x128 Formidable Forms – Form Builder for WordPress
Version 2.0.05
Comparing to
See all releases

Code changes from version 2.0.04 to 2.0.05

Files changed (70) hide show
  1. classes/controllers/FrmAppController.php +3 -3
  2. classes/controllers/FrmEntriesController.php +10 -10
  3. classes/controllers/FrmFieldsController.php +1 -1
  4. classes/controllers/FrmFormActionsController.php +11 -3
  5. classes/controllers/FrmFormsController.php +20 -22
  6. classes/controllers/FrmSettingsController.php +10 -1
  7. classes/controllers/FrmStatisticsController.php +2 -2
  8. classes/controllers/FrmStylesController.php +2 -2
  9. classes/controllers/FrmXMLController.php +5 -13
  10. classes/helpers/FrmAppHelper.php +19 -15
  11. classes/helpers/FrmEntriesHelper.php +34 -19
  12. classes/helpers/FrmEntriesListHelper.php +1 -64
  13. classes/helpers/FrmFieldsHelper.php +18 -18
  14. classes/helpers/FrmFormActionsHelper.php +3 -13
  15. classes/helpers/FrmFormsHelper.php +11 -11
  16. classes/helpers/FrmFormsListHelper.php +3 -3
  17. classes/helpers/FrmStylesHelper.php +6 -6
  18. classes/helpers/FrmXMLHelper.php +55 -54
  19. classes/models/FrmDb.php +16 -9
  20. classes/models/FrmEntry.php +40 -24
  21. classes/models/FrmEntryMeta.php +30 -10
  22. classes/models/FrmField.php +11 -10
  23. classes/models/FrmForm.php +24 -24
  24. classes/models/FrmFormAction.php +38 -29
  25. classes/models/FrmNotification.php +18 -18
  26. classes/models/FrmSettings.php +2 -2
  27. classes/models/FrmStyle.php +12 -12
  28. classes/views/frm-entries/errors.php +5 -5
  29. classes/views/frm-entries/form.php +2 -6
  30. classes/views/frm-fields/import_choices.php +2 -2
  31. classes/views/frm-fields/input.php +10 -10
  32. classes/views/frm-fields/show-build.php +2 -2
  33. classes/views/frm-form-actions/_email_settings.php +3 -3
  34. classes/views/frm-forms/_publish_box.php +5 -5
  35. classes/views/frm-forms/add_field.php +7 -7
  36. classes/views/frm-forms/add_field_links.php +1 -1
  37. classes/views/frm-forms/settings.php +7 -7
  38. classes/views/frm-settings/license_box.php +1 -1
  39. classes/views/shared/mb_adv_info.php +6 -5
  40. classes/views/styles/_date-fields.php +1 -1
  41. classes/views/styles/_field-colors.php +1 -1
  42. classes/views/xml/forms_xml.php +1 -1
  43. classes/views/xml/import_form.php +3 -3
  44. classes/views/xml/xml.php +3 -3
  45. css/_single_theme.css.php +15 -10
  46. css/custom_theme.css.php +10 -2
  47. css/frm_admin.css +8 -6
  48. formidable.php +1 -1
  49. js/bootstrap.min.js +7 -3
  50. js/formidable.min.js +54 -52
  51. js/formidable_admin.js +45 -17
  52. languages/formidable-da_DK.mo +0 -0
  53. languages/formidable-da_DK.po +398 -407
  54. languages/formidable-de_DE.mo +0 -0
  55. languages/formidable-de_DE.po +398 -407
  56. languages/formidable-en_US.po +398 -407
  57. languages/formidable-es_ES.mo +0 -0
  58. languages/formidable-es_ES.po +398 -407
  59. languages/formidable-fr_FR.mo +0 -0
  60. languages/formidable-fr_FR.po +834 -843
  61. languages/formidable-it_IT.mo +0 -0
  62. languages/formidable-it_IT.po +398 -407
  63. languages/formidable-nl_NL.mo +0 -0
  64. languages/formidable-nl_NL.po +398 -407
  65. languages/formidable-pl_PL.mo +0 -0
  66. languages/formidable-pl_PL.po +398 -407
  67. languages/formidable-pt_BR.mo +0 -0
  68. languages/formidable-pt_BR.po +398 -407
  69. languages/formidable-sr_RS.mo +0 -0
  70. languages/formidable-sr_RS.po +95 -95
classes/controllers/FrmAppController.php CHANGED
@@ -27,7 +27,7 @@ class FrmAppController {
27
  public static function get_form_nav( $form, $show_nav = '', $title = 'show' ) {
28
  global $pagenow, $frm_vars;
29
 
30
- $show_nav = FrmAppHelper::get_param( 'show_nav', $show_nav );
31
  if ( empty($show_nav) ) {
32
  return;
33
  }
@@ -67,7 +67,7 @@ class FrmAppController {
67
  FrmAppHelper::load_admin_wide_js();
68
 
69
  // user is authorized, but running free version
70
- $inst_install_url = 'http://formidablepro.com/knowledgebase/manually-install-formidable-pro/';
71
  ?>
72
  <div class="error" class="frm_previous_install">
73
  <?php
@@ -134,7 +134,7 @@ class FrmAppController {
134
  'bootstrap_tooltip', 'bootstrap-multiselect',
135
  ), $version, true );
136
  wp_register_style( 'formidable-admin', FrmAppHelper::plugin_url() .'/css/frm_admin.css', array(), $version );
137
- wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() .'/js/bootstrap.min.js', array( 'jquery' ), '3.3.2' );
138
 
139
  // load multselect js
140
  wp_register_script( 'bootstrap-multiselect', FrmAppHelper::plugin_url() .'/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip' ), '0.9.8', true );
27
  public static function get_form_nav( $form, $show_nav = '', $title = 'show' ) {
28
  global $pagenow, $frm_vars;
29
 
30
+ $show_nav = FrmAppHelper::get_param( 'show_nav', $show_nav, 'get', 'absint' );
31
  if ( empty($show_nav) ) {
32
  return;
33
  }
67
  FrmAppHelper::load_admin_wide_js();
68
 
69
  // user is authorized, but running free version
70
+ $inst_install_url = 'https://formidablepro.com/knowledgebase/install-formidable-forms/';
71
  ?>
72
  <div class="error" class="frm_previous_install">
73
  <?php
134
  'bootstrap_tooltip', 'bootstrap-multiselect',
135
  ), $version, true );
136
  wp_register_style( 'formidable-admin', FrmAppHelper::plugin_url() .'/css/frm_admin.css', array(), $version );
137
+ wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() .'/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' );
138
 
139
  // load multselect js
140
  wp_register_script( 'bootstrap-multiselect', FrmAppHelper::plugin_url() .'/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip' ), '0.9.8', true );
classes/controllers/FrmEntriesController.php CHANGED
@@ -21,7 +21,7 @@ class FrmEntriesController {
21
 
22
  /* Display in Back End */
23
  public static function route() {
24
- $action = FrmAppHelper::get_param('frm_action');
25
 
26
  switch ( $action ) {
27
  case 'show':
@@ -119,7 +119,7 @@ class FrmEntriesController {
119
  $frm_vars['cols'] = $columns;
120
 
121
  $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
122
- if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && ( $action == 'list' || $action == 'destroy' ) ) {
123
  add_screen_option( 'per_page', array( 'label' => __( 'Entries', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_entries_per_page' ) );
124
  }
125
 
@@ -329,14 +329,14 @@ class FrmEntriesController {
329
  }
330
 
331
  /* Back End CRUD */
332
- public static function show($id = false) {
333
  FrmAppHelper::permission_check('frm_view_entries');
334
 
335
  if ( ! $id ) {
336
- $id = FrmAppHelper::get_param('id');
337
 
338
  if ( ! $id ) {
339
- $id = FrmAppHelper::get_param('item_id');
340
  }
341
  }
342
 
@@ -617,7 +617,7 @@ class FrmEntriesController {
617
  }
618
 
619
  $action_var = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
620
- $action = apply_filters('frm_show_new_entry_page', FrmAppHelper::get_param($action_var, 'new'), $form);
621
 
622
  $default_values = array(
623
  'id' => '', 'form_name' => '', 'paged' => 1, 'form' => $form->id, 'form_id' => $form->id,
@@ -625,16 +625,16 @@ class FrmEntriesController {
625
  );
626
 
627
  $values = array();
628
- $values['posted_form_id'] = FrmAppHelper::get_param('form_id');
629
- if ( ! is_numeric($values['posted_form_id']) ) {
630
- $values['posted_form_id'] = FrmAppHelper::get_param('form');
631
  }
632
 
633
  if ( $form->id == $values['posted_form_id'] ) {
634
  //if there are two forms on the same page, make sure not to submit both
635
  foreach ( $default_values as $var => $default ) {
636
  if ( $var == 'action' ) {
637
- $values[ $var ] = FrmAppHelper::get_param( $action_var, $default );
638
  } else {
639
  $values[ $var ] = FrmAppHelper::get_param( $var, $default );
640
  }
21
 
22
  /* Display in Back End */
23
  public static function route() {
24
+ $action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' );
25
 
26
  switch ( $action ) {
27
  case 'show':
119
  $frm_vars['cols'] = $columns;
120
 
121
  $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
122
+ if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $action, array( '', 'list', 'destroy' ) ) ) {
123
  add_screen_option( 'per_page', array( 'label' => __( 'Entries', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_entries_per_page' ) );
124
  }
125
 
329
  }
330
 
331
  /* Back End CRUD */
332
+ public static function show( $id = 0 ) {
333
  FrmAppHelper::permission_check('frm_view_entries');
334
 
335
  if ( ! $id ) {
336
+ $id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
337
 
338
  if ( ! $id ) {
339
+ $id = FrmAppHelper::get_param( 'item_id', 0, 'get', 'absint' );
340
  }
341
  }
342
 
617
  }
618
 
619
  $action_var = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
620
+ $action = apply_filters( 'frm_show_new_entry_page', FrmAppHelper::get_param( $action_var, 'new', 'get', 'sanitize_title' ), $form );
621
 
622
  $default_values = array(
623
  'id' => '', 'form_name' => '', 'paged' => 1, 'form' => $form->id, 'form_id' => $form->id,
625
  );
626
 
627
  $values = array();
628
+ $values['posted_form_id'] = FrmAppHelper::get_param( 'form_id', '', 'get', 'absint' );
629
+ if ( ! $values['posted_form_id'] ) {
630
+ $values['posted_form_id'] = FrmAppHelper::get_param( 'form', '', 'get', 'absint' );
631
  }
632
 
633
  if ( $form->id == $values['posted_form_id'] ) {
634
  //if there are two forms on the same page, make sure not to submit both
635
  foreach ( $default_values as $var => $default ) {
636
  if ( $var == 'action' ) {
637
+ $values[ $var ] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' );
638
  } else {
639
  $values[ $var ] = FrmAppHelper::get_param( $var, $default );
640
  }
classes/controllers/FrmFieldsController.php CHANGED
@@ -500,7 +500,7 @@ class FrmFieldsController {
500
  }
501
 
502
  public static function display_field_options($display) {
503
- switch($display['type']) {
504
  case 'captcha':
505
  $display['required'] = false;
506
  $display['invalid'] = true;
500
  }
501
 
502
  public static function display_field_options($display) {
503
+ switch ( $display['type'] ) {
504
  case 'captcha':
505
  $display['required'] = false;
506
  $display['invalid'] = true;
classes/controllers/FrmFormActionsController.php CHANGED
@@ -72,7 +72,7 @@ class FrmFormActionsController {
72
  return $a;
73
  }
74
 
75
- $actions[$a->id_base] = $a;
76
  }
77
  unset( $temp_actions, $a );
78
 
@@ -86,7 +86,7 @@ class FrmFormActionsController {
86
  arsort( $temp_actions );
87
  foreach ( $temp_actions as $type => $a ) {
88
  if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) {
89
- unset( $actions[$type] );
90
  if ( count( $actions ) <= $action_limit ) {
91
  break;
92
  }
@@ -97,12 +97,19 @@ class FrmFormActionsController {
97
  return $actions;
98
  }
99
 
 
 
 
100
  public static function list_actions( $form, $values ) {
101
  if ( empty( $form ) ) {
102
  return;
103
  }
104
 
105
- do_action( 'frm_before_list_actions', $form ); // use this hook to migrate old settings into a new action
 
 
 
 
106
 
107
  $form_actions = FrmFormActionsHelper::get_action_for_form( $form->id );
108
 
@@ -217,6 +224,7 @@ class FrmFormActionsController {
217
  foreach ( $old_actions as $old_id ) {
218
  wp_delete_post( $old_id );
219
  }
 
220
  }
221
  }
222
 
72
  return $a;
73
  }
74
 
75
+ $actions[ $a->id_base ] = $a;
76
  }
77
  unset( $temp_actions, $a );
78
 
86
  arsort( $temp_actions );
87
  foreach ( $temp_actions as $type => $a ) {
88
  if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) {
89
+ unset( $actions[ $type ] );
90
  if ( count( $actions ) <= $action_limit ) {
91
  break;
92
  }
97
  return $actions;
98
  }
99
 
100
+ /**
101
+ * @since 2.0
102
+ */
103
  public static function list_actions( $form, $values ) {
104
  if ( empty( $form ) ) {
105
  return;
106
  }
107
 
108
+ /**
109
+ * use this hook to migrate old settings into a new action
110
+ * @since 2.0
111
+ */
112
+ do_action( 'frm_before_list_actions', $form );
113
 
114
  $form_actions = FrmFormActionsHelper::get_action_for_form( $form->id );
115
 
224
  foreach ( $old_actions as $old_id ) {
225
  wp_delete_post( $old_id );
226
  }
227
+ FrmAppHelper::cache_delete_group( 'frm_actions' );
228
  }
229
  }
230
 
classes/controllers/FrmFormsController.php CHANGED
@@ -44,11 +44,11 @@ class FrmFormsController {
44
  global $frm_vars;
45
 
46
  $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
47
- $action = empty( $values ) ? sanitize_title( FrmAppHelper::get_param( $action ) ) : $values[ $action ];
48
 
49
- if ($action == 'create') {
50
  return self::create($values);
51
- } else if ($action == 'new') {
52
  $frm_field_selection = FrmFieldsHelper::field_selection();
53
  $values = FrmFormsHelper::setup_new_vars($values);
54
  $id = FrmForm::create( $values );
@@ -78,7 +78,7 @@ class FrmFormsController {
78
  $values = FrmProEntry::mod_other_vals( $values, 'back' );
79
  }
80
 
81
- $id = isset($values['id']) ? absint( $values['id'] ) : absint( FrmAppHelper::get_param( 'id' ) );
82
 
83
  if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
84
  $frm_settings = FrmAppHelper::get_settings();
@@ -106,7 +106,7 @@ class FrmFormsController {
106
  public static function edit( $values = false ) {
107
  FrmAppHelper::permission_check('frm_edit_forms');
108
 
109
- $id = isset( $values['id'] ) ? absint( $values['id'] ) : absint( FrmAppHelper::get_param( 'id' ) );
110
  return self::get_edit_vars($id);
111
  }
112
 
@@ -114,7 +114,7 @@ class FrmFormsController {
114
  FrmAppHelper::permission_check('frm_edit_forms');
115
 
116
  if ( ! $id || ! is_numeric($id) ) {
117
- $id = absint( FrmAppHelper::get_param( 'id' ) );
118
  }
119
  return self::get_settings_vars($id, '', $message);
120
  }
@@ -122,7 +122,7 @@ class FrmFormsController {
122
  public static function update_settings() {
123
  FrmAppHelper::permission_check('frm_edit_forms');
124
 
125
- $id = absint( FrmAppHelper::get_param( 'id' ) );
126
 
127
  $errors = FrmForm::validate($_POST);
128
  if ( count($errors) > 0 ) {
@@ -176,7 +176,7 @@ class FrmFormsController {
176
  $errors['form'] = $permission_error;
177
  }
178
 
179
- $id = isset( $values['id'] ) ? (int) $values['id'] : (int) FrmAppHelper::get_param( 'id' );
180
 
181
  if ( count( $errors ) > 0 ) {
182
  return self::get_edit_vars( $id, $errors );
@@ -208,8 +208,8 @@ class FrmFormsController {
208
  public static function _create_from_template() {
209
  check_ajax_referer( 'frm_ajax', 'nonce' );
210
 
211
- $current_form = (int) FrmAppHelper::get_param( 'this_form' );
212
- $template_id = (int) FrmAppHelper::get_param( 'id' );
213
 
214
  if ( $current_form ) {
215
  FrmForm::destroy( $current_form );
@@ -265,8 +265,6 @@ class FrmFormsController {
265
 
266
  header( 'Content-Type: text/html; charset='. get_option( 'blog_charset' ) );
267
 
268
- $plugin = FrmAppHelper::get_param('plugin');
269
- $controller = FrmAppHelper::get_param('controller');
270
  $key = (isset($_GET['form']) ? $_GET['form'] : (isset($_POST['form']) ? $_POST['form'] : ''));
271
  $form = FrmForm::getAll( array( 'form_key' => $key), '', 1);
272
  if ( empty($form) ) {
@@ -397,7 +395,7 @@ class FrmFormsController {
397
  }
398
 
399
  public static function insert_form_popup() {
400
- $page = basename($_SERVER['PHP_SELF']);
401
  if ( ! in_array($page, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php') ) ) {
402
  return;
403
  }
@@ -426,7 +424,7 @@ class FrmFormsController {
426
 
427
  $form_id = '';
428
  $opts = array();
429
- switch( $shortcode ) {
430
  case 'formidable':
431
  $opts = array(
432
  'form_id' => 'id',
@@ -682,9 +680,9 @@ class FrmFormsController {
682
  return $errors;
683
  }
684
 
685
- $bulkaction = FrmAppHelper::get_param( 'action' );
686
  if ( $bulkaction == -1 ) {
687
- $bulkaction = FrmAppHelper::get_param( 'action2' );
688
  }
689
 
690
  if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) {
@@ -737,7 +735,7 @@ class FrmFormsController {
737
  $path = untrailingslashit(trim($path));
738
  $templates = glob( $path .'/*.php' );
739
 
740
- for($i = count($templates) - 1; $i >= 0; $i--) {
741
  $filename = str_replace( '.php', '', str_replace( $path.'/', '', $templates[ $i ] ) );
742
  $template_query = array( 'form_key' => $filename);
743
  if ( $template ) {
@@ -783,7 +781,7 @@ class FrmFormsController {
783
  $json_vars = json_decode($json_vars, true);
784
  if ( empty($json_vars) ) {
785
  // json decoding failed so we should return an error message
786
- $action = FrmAppHelper::get_param($action);
787
  if ( 'edit' == $action ) {
788
  $action = 'update';
789
  }
@@ -796,7 +794,7 @@ class FrmFormsController {
796
  unset( $_REQUEST['frm_compact_fields'] );
797
  }
798
  } else {
799
- $action = FrmAppHelper::get_param($action);
800
  if ( isset( $_REQUEST['delete_all'] ) ) {
801
  // override the action for this page
802
  $action = 'delete_all';
@@ -826,9 +824,9 @@ class FrmFormsController {
826
  return;
827
  }
828
 
829
- $action = FrmAppHelper::get_param('action');
830
  if ( $action == -1 ) {
831
- $action = FrmAppHelper::get_param('action2');
832
  }
833
 
834
  if ( strpos($action, 'bulk_') === 0 ) {
@@ -852,7 +850,7 @@ class FrmFormsController {
852
  }
853
 
854
  public static function admin_bar_configure() {
855
- if ( is_admin() || !current_user_can('frm_edit_forms') ) {
856
  return;
857
  }
858
 
44
  global $frm_vars;
45
 
46
  $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
47
+ $action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ];
48
 
49
+ if ( $action == 'create' ) {
50
  return self::create($values);
51
+ } else if ( $action == 'new' ) {
52
  $frm_field_selection = FrmFieldsHelper::field_selection();
53
  $values = FrmFormsHelper::setup_new_vars($values);
54
  $id = FrmForm::create( $values );
78
  $values = FrmProEntry::mod_other_vals( $values, 'back' );
79
  }
80
 
81
+ $id = isset($values['id']) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
82
 
83
  if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
84
  $frm_settings = FrmAppHelper::get_settings();
106
  public static function edit( $values = false ) {
107
  FrmAppHelper::permission_check('frm_edit_forms');
108
 
109
+ $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
110
  return self::get_edit_vars($id);
111
  }
112
 
114
  FrmAppHelper::permission_check('frm_edit_forms');
115
 
116
  if ( ! $id || ! is_numeric($id) ) {
117
+ $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
118
  }
119
  return self::get_settings_vars($id, '', $message);
120
  }
122
  public static function update_settings() {
123
  FrmAppHelper::permission_check('frm_edit_forms');
124
 
125
+ $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
126
 
127
  $errors = FrmForm::validate($_POST);
128
  if ( count($errors) > 0 ) {
176
  $errors['form'] = $permission_error;
177
  }
178
 
179
+ $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
180
 
181
  if ( count( $errors ) > 0 ) {
182
  return self::get_edit_vars( $id, $errors );
208
  public static function _create_from_template() {
209
  check_ajax_referer( 'frm_ajax', 'nonce' );
210
 
211
+ $current_form = FrmAppHelper::get_param( 'this_form', '', 'get', 'absint' );
212
+ $template_id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
213
 
214
  if ( $current_form ) {
215
  FrmForm::destroy( $current_form );
265
 
266
  header( 'Content-Type: text/html; charset='. get_option( 'blog_charset' ) );
267
 
 
 
268
  $key = (isset($_GET['form']) ? $_GET['form'] : (isset($_POST['form']) ? $_POST['form'] : ''));
269
  $form = FrmForm::getAll( array( 'form_key' => $key), '', 1);
270
  if ( empty($form) ) {
395
  }
396
 
397
  public static function insert_form_popup() {
398
+ $page = basename( FrmAppHelper::get_server_value( 'PHP_SELF' ) );
399
  if ( ! in_array($page, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php') ) ) {
400
  return;
401
  }
424
 
425
  $form_id = '';
426
  $opts = array();
427
+ switch ( $shortcode ) {
428
  case 'formidable':
429
  $opts = array(
430
  'form_id' => 'id',
680
  return $errors;
681
  }
682
 
683
+ $bulkaction = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_title' );
684
  if ( $bulkaction == -1 ) {
685
+ $bulkaction = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
686
  }
687
 
688
  if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) {
735
  $path = untrailingslashit(trim($path));
736
  $templates = glob( $path .'/*.php' );
737
 
738
+ for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) {
739
  $filename = str_replace( '.php', '', str_replace( $path.'/', '', $templates[ $i ] ) );
740
  $template_query = array( 'form_key' => $filename);
741
  if ( $template ) {
781
  $json_vars = json_decode($json_vars, true);
782
  if ( empty($json_vars) ) {
783
  // json decoding failed so we should return an error message
784
+ $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
785
  if ( 'edit' == $action ) {
786
  $action = 'update';
787
  }
794
  unset( $_REQUEST['frm_compact_fields'] );
795
  }
796
  } else {
797
+ $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
798
  if ( isset( $_REQUEST['delete_all'] ) ) {
799
  // override the action for this page
800
  $action = 'delete_all';
824
  return;
825
  }
826
 
827
+ $action = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_title' );
828
  if ( $action == -1 ) {
829
+ $action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
830
  }
831
 
832
  if ( strpos($action, 'bulk_') === 0 ) {
850
  }
851
 
852
  public static function admin_bar_configure() {
853
+ if ( is_admin() || ! current_user_can( 'frm_edit_forms' ) ) {
854
  return;
855
  }
856
 
classes/controllers/FrmSettingsController.php CHANGED
@@ -3,6 +3,15 @@
3
  class FrmSettingsController {
4
 
5
  public static function menu() {
 
 
 
 
 
 
 
 
 
6
  add_submenu_page('formidable', 'Formidable | '. __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route');
7
  }
8
 
@@ -60,7 +69,7 @@ class FrmSettingsController {
60
 
61
  public static function route( $stop_load = false ) {
62
  $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
63
- $action = FrmAppHelper::get_param( $action );
64
  if ( $action == 'process-form' ) {
65
  return self::process_form( $stop_load );
66
  } else if ( $stop_load != 'stop_load' ) {
3
  class FrmSettingsController {
4
 
5
  public static function menu() {
6
+ // Make sure admins can see the menu items
7
+ if ( current_user_can( 'administrator' ) && ! current_user_can( 'frm_change_settings' ) ) {
8
+ $role = get_role( 'administrator' );
9
+ $frm_roles = FrmAppHelper::frm_capabilities();
10
+ foreach ( $frm_roles as $frm_role => $frm_role_description ) {
11
+ $role->add_cap( $frm_role );
12
+ }
13
+ }
14
+
15
  add_submenu_page('formidable', 'Formidable | '. __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route');
16
  }
17
 
69
 
70
  public static function route( $stop_load = false ) {
71
  $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
72
+ $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
73
  if ( $action == 'process-form' ) {
74
  return self::process_form( $stop_load );
75
  } else if ( $stop_load != 'stop_load' ) {
classes/controllers/FrmStatisticsController.php CHANGED
@@ -8,12 +8,12 @@ class FrmStatisticsController {
8
 
9
  public static function list_reports() {
10
  add_filter('frm_form_stop_action_reports', '__return_true');
11
- $form = FrmAppHelper::get_param('form', false);
12
  require(FrmAppHelper::plugin_path() .'/classes/views/frm-statistics/list.php');
13
  }
14
 
15
  public static function list_displays() {
16
- $form = FrmAppHelper::get_param('form', false);
17
  require(FrmAppHelper::plugin_path() .'/classes/views/frm-statistics/list_displays.php');
18
  }
19
 
8
 
9
  public static function list_reports() {
10
  add_filter('frm_form_stop_action_reports', '__return_true');
11
+ $form = FrmAppHelper::get_param( 'form', false, 'get', 'absint' );
12
  require(FrmAppHelper::plugin_path() .'/classes/views/frm-statistics/list.php');
13
  }
14
 
15
  public static function list_displays() {
16
+ $form = FrmAppHelper::get_param( 'form', false, 'get', 'sanitize_title' );
17
  require(FrmAppHelper::plugin_path() .'/classes/views/frm-statistics/list_displays.php');
18
  }
19
 
classes/controllers/FrmStylesController.php CHANGED
@@ -71,7 +71,7 @@ class FrmStylesController {
71
 
72
  public static function edit($style_id = false, $message = '') {
73
  if ( ! $style_id ) {
74
- $style_id = FrmAppHelper::get_param('id');
75
  if ( empty($style_id) ) {
76
  $style_id = 'default';
77
  }
@@ -185,7 +185,7 @@ class FrmStylesController {
185
  }
186
 
187
  public static function route() {
188
- $action = FrmAppHelper::get_param('frm_action');
189
 
190
  switch ( $action ) {
191
  case 'edit':
71
 
72
  public static function edit($style_id = false, $message = '') {
73
  if ( ! $style_id ) {
74
+ $style_id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
75
  if ( empty($style_id) ) {
76
  $style_id = 'default';
77
  }
185
  }
186
 
187
  public static function route() {
188
+ $action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' );
189
 
190
  switch ( $action ) {
191
  case 'edit':
classes/controllers/FrmXMLController.php CHANGED
@@ -7,7 +7,7 @@ class FrmXMLController {
7
  }
8
 
9
  public static function add_default_templates() {
10
- if ( !function_exists( 'libxml_disable_entity_loader' ) ) {
11
  // XML import is not enabled on your server
12
  return;
13
  }
@@ -36,7 +36,7 @@ class FrmXMLController {
36
 
37
  public static function route() {
38
  $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
39
- $action = FrmAppHelper::get_param( $action );
40
  if ( $action == 'import_xml' ) {
41
  return self::import_xml();
42
  } else if ( $action == 'export_xml' ) {
@@ -137,17 +137,9 @@ class FrmXMLController {
137
  wp_die( $error );
138
  }
139
 
140
- $ids = array();
141
- if ( isset($_POST['frm_export_forms']) ) {
142
- $ids = $_POST['frm_export_forms'];
143
- }
144
-
145
- $type = false;
146
- if ( isset($_POST['type']) ) {
147
- $type = $_POST['type'];
148
- }
149
-
150
- $format = isset($_POST['format']) ? $_POST['format'] : 'xml';
151
 
152
  if ( ! headers_sent() && ! $type ) {
153
  wp_redirect( esc_url_raw( admin_url( 'admin.php?page=formidable-import' ) ) );
7
  }
8
 
9
  public static function add_default_templates() {
10
+ if ( ! function_exists( 'libxml_disable_entity_loader' ) ) {
11
  // XML import is not enabled on your server
12
  return;
13
  }
36
 
37
  public static function route() {
38
  $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
39
+ $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
40
  if ( $action == 'import_xml' ) {
41
  return self::import_xml();
42
  } else if ( $action == 'export_xml' ) {
137
  wp_die( $error );
138
  }
139
 
140
+ $ids = isset( $_POST['frm_export_forms'] ) ? $_POST['frm_export_forms'] : array();
141
+ $type = isset( $_POST['type'] ) ? $_POST['type'] : array();
142
+ $format = FrmAppHelper::get_post_param( 'format', 'xml', 'sanitize_title' );
 
 
 
 
 
 
 
 
143
 
144
  if ( ! headers_sent() && ! $type ) {
145
  wp_redirect( esc_url_raw( admin_url( 'admin.php?page=formidable-import' ) ) );
classes/helpers/FrmAppHelper.php CHANGED
@@ -4,13 +4,13 @@ if ( ! defined('ABSPATH') ) {
4
  }
5
 
6
  class FrmAppHelper {
7
- public static $db_version = 25; //version of the database we are moving to
8
  public static $pro_db_version = 27;
9
 
10
  /**
11
  * @since 2.0
12
  */
13
- public static $plug_version = '2.0.04';
14
 
15
  /**
16
  * @since 1.07.02
@@ -36,9 +36,9 @@ class FrmAppHelper {
36
  $url = plugins_url('', self::plugin_folder() .'/formidable.php');
37
  }
38
 
39
- if ( is_ssl() && !preg_match('/^https:\/\/.*\..*$/', $url) ) {
40
- $url = str_replace('http://', 'https://', $url);
41
- }
42
 
43
  return $url;
44
  }
@@ -209,6 +209,7 @@ class FrmAppHelper {
209
  if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
210
  $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) );
211
  }
 
212
  } else {
213
  $value = self::get_post_param( $param, $default, $sanitize );
214
  }
@@ -231,13 +232,16 @@ class FrmAppHelper {
231
  $val = $default;
232
  if ( isset( $_POST[ $param ] ) ) {
233
  $val = stripslashes_deep( maybe_unserialize( $_POST[ $param ] ) );
234
- if ( ! empty( $sanitize ) ) {
235
- $val = call_user_func( $sanitize, $val );
236
- }
237
  }
238
  return $val;
239
  }
240
 
 
 
 
 
 
241
  /**
242
  * @since 2.0
243
  * @param string $action
@@ -292,7 +296,7 @@ class FrmAppHelper {
292
 
293
  $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
294
  if ( ! empty( $new_action ) ) {
295
- $_SERVER['REQUEST_URI'] = str_replace( '&action='. $new_action, '', $_SERVER['REQUEST_URI'] );
296
  }
297
  }
298
 
@@ -506,7 +510,7 @@ class FrmAppHelper {
506
  'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ),
507
  );
508
 
509
- if ( ! self::pro_is_installed() && 'pro' != $type) {
510
  return $cap;
511
  }
512
 
@@ -659,7 +663,7 @@ class FrmAppHelper {
659
  if ( FrmFieldsHelper::is_field_with_multiple_values( $field ) ) {
660
  $other_val = isset( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ? $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] : '';
661
  } else {
662
- $other_val = $_POST['item_meta']['other'][ $field['id'] ];
663
  }
664
  return $other_val;
665
  }
@@ -713,7 +717,7 @@ class FrmAppHelper {
713
  */
714
  public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) {
715
  //Check if this is an "Other" option
716
- if ( !self::is_other_opt( $args['opt_key'] ) ) {
717
  return;
718
  }
719
 
@@ -1243,8 +1247,8 @@ class FrmAppHelper {
1243
  $diff = (int) ($to - $from);
1244
 
1245
  // Something went wrong with date calculation and we ended up with a negative date.
1246
- if ( $diff < 1) {
1247
- return '0 ' . __( 'seconds', 'formidable' );
1248
  }
1249
 
1250
  /**
@@ -1257,7 +1261,7 @@ class FrmAppHelper {
1257
  $count = 0;
1258
 
1259
  //Step one: the first chunk
1260
- for ( $i = 0, $j = count($chunks); $i < $j; $i++) {
1261
  $seconds = $chunks[ $i ][0];
1262
 
1263
  // Finding the biggest chunk (if the chunk fits, break)
4
  }
5
 
6
  class FrmAppHelper {
7
+ public static $db_version = 26; //version of the database we are moving to
8
  public static $pro_db_version = 27;
9
 
10
  /**
11
  * @since 2.0
12
  */
13
+ public static $plug_version = '2.0.05';
14
 
15
  /**
16
  * @since 1.07.02
36
  $url = plugins_url('', self::plugin_folder() .'/formidable.php');
37
  }
38
 
39
+ if ( is_ssl() && ! preg_match( '/^https:\/\/.*\..*$/', $url ) ) {
40
+ $url = str_replace( 'http://', 'https://', $url );
41
+ }
42
 
43
  return $url;
44
  }
209
  if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
210
  $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) );
211
  }
212
+ self::sanitize_value( $value, $sanitize );
213
  } else {
214
  $value = self::get_post_param( $param, $default, $sanitize );
215
  }
232
  $val = $default;
233
  if ( isset( $_POST[ $param ] ) ) {
234
  $val = stripslashes_deep( maybe_unserialize( $_POST[ $param ] ) );
235
+ self::sanitize_value( $value, $sanitize );
 
 
236
  }
237
  return $val;
238
  }
239
 
240
+ public static function sanitize_value( &$value, $sanitize ) {
241
+ if ( ! empty( $sanitize ) ) {
242
+ $value = call_user_func( $sanitize, $value );
243
+ }
244
+ }
245
  /**
246
  * @since 2.0
247
  * @param string $action
296
 
297
  $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
298
  if ( ! empty( $new_action ) ) {
299
+ $_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) );
300
  }
301
  }
302
 
510
  'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ),
511
  );
512
 
513
+ if ( ! self::pro_is_installed() && 'pro' != $type ) {
514
  return $cap;
515
  }
516
 
663
  if ( FrmFieldsHelper::is_field_with_multiple_values( $field ) ) {
664
  $other_val = isset( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ? $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] : '';
665
  } else {
666
+ $other_val = sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ] );
667
  }
668
  return $other_val;
669
  }
717
  */
718
  public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) {
719
  //Check if this is an "Other" option
720
+ if ( ! self::is_other_opt( $args['opt_key'] ) ) {
721
  return;
722
  }
723
 
1247
  $diff = (int) ($to - $from);
1248
 
1249
  // Something went wrong with date calculation and we ended up with a negative date.
1250
+ if ( $diff < 1 ) {
1251
+ return '0 ' . __( 'seconds', 'formidable' );
1252
  }
1253
 
1254
  /**
1261
  $count = 0;
1262
 
1263
  //Step one: the first chunk
1264
+ for ( $i = 0, $j = count( $chunks ); $i < $j; $i++ ) {
1265
  $seconds = $chunks[ $i ][0];
1266
 
1267
  // Finding the biggest chunk (if the chunk fits, break)
classes/helpers/FrmEntriesHelper.php CHANGED
@@ -64,6 +64,7 @@ class FrmEntriesHelper {
64
 
65
  $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
66
  $opt_defaults['required_indicator'] = '';
 
67
 
68
  foreach ( $opt_defaults as $opt => $default_opt ) {
69
  $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt;
@@ -151,7 +152,7 @@ class FrmEntriesHelper {
151
  return $frm_vars['current_form'];
152
  }
153
 
154
- $form_id = (int) FrmAppHelper::get_param('form', $form_id);
155
  return self::set_current_form($form_id);
156
  }
157
 
@@ -174,7 +175,7 @@ class FrmEntriesHelper {
174
  }
175
 
176
  public static function fill_entry_values($atts, $f, array &$values) {
177
- if ( FrmFieldsHelper::is_no_save_field($f->type) ) {
178
  return;
179
  }
180
 
@@ -215,6 +216,10 @@ class FrmEntriesHelper {
215
  self::flatten_multi_file_upload( $val, $f );
216
  $atts['entry']->metas[ $f->id ] = $val;
217
  }
 
 
 
 
218
  }
219
  }
220
  }
@@ -464,6 +469,7 @@ class FrmEntriesHelper {
464
  'type' => '', 'html' => false, 'show_filename' => true,
465
  'truncate' => false, 'sep' => ', ', 'post_id' => 0,
466
  'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0,
 
467
  );
468
 
469
  $atts = wp_parse_args( $atts, $defaults );
@@ -509,7 +515,7 @@ class FrmEntriesHelper {
509
 
510
  if ( ! empty($new_value) ) {
511
  $value = $new_value;
512
- } else if ( is_array($value) && $atts['type'] != 'file' ) {
513
  $value = implode($atts['sep'], $value);
514
  }
515
 
@@ -631,13 +637,20 @@ class FrmEntriesHelper {
631
  // Multi-select dropdown
632
  if ( is_array( $value ) ) {
633
  $o_key = array_search( $field->options[ $other_key ], $value );
634
- if ( $o_key ) {
635
- // Modify original value so key is preserved
636
- $value[ $other_key ] = $value[ $o_key ];
637
- unset( $value[ $o_key ] );
638
- $args['temp_value'] = $value;
639
- $value[ $other_key ] = reset( $other_vals );
640
- }
 
 
 
 
 
 
 
641
  } else if ( $field->options[ $other_key ] == $value ) {
642
  $value = $other_vals;
643
  }
@@ -675,14 +688,16 @@ class FrmEntriesHelper {
675
  $platform = __( 'Unknown', 'formidable' );
676
  $ub = '';
677
 
678
- //First get the platform?
679
- if ( preg_match('/linux/i', $u_agent) ) {
680
- $platform = 'Linux';
681
- } else if ( preg_match('/macintosh|mac os x/i', $u_agent) ) {
682
- $platform = 'Mac';
683
- } else if ( preg_match('/windows|win32/i', $u_agent) ) {
684
- $platform = 'Windows';
685
- }
 
 
686
 
687
  $agent_options = array(
688
  'Firefox' => 'Mozilla Firefox',
@@ -726,7 +741,7 @@ class FrmEntriesHelper {
726
  }
727
 
728
  // check if we have a number
729
- if ( $version == '') {
730
  $version = '?';
731
  }
732
 
64
 
65
  $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
66
  $opt_defaults['required_indicator'] = '';
67
+ $opt_defaults['original_type'] = $field->type;
68
 
69
  foreach ( $opt_defaults as $opt => $default_opt ) {
70
  $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt;
152
  return $frm_vars['current_form'];
153
  }
154
 
155
+ $form_id = FrmAppHelper::get_param('form', $form_id, 'get', 'absint' );
156
  return self::set_current_form($form_id);
157
  }
158
 
175
  }
176
 
177
  public static function fill_entry_values($atts, $f, array &$values) {
178
+ if ( FrmFieldsHelper::is_no_save_field( $f->type ) ) {
179
  return;
180
  }
181
 
216
  self::flatten_multi_file_upload( $val, $f );
217
  $atts['entry']->metas[ $f->id ] = $val;
218
  }
219
+ } else {
220
+ $val = '';
221
+ FrmProEntriesHelper::get_dfe_values( $f, $atts['entry'], $val );
222
+ $atts['entry']->metas[ $f->id ] = $val;
223
  }
224
  }
225
  }
469
  'type' => '', 'html' => false, 'show_filename' => true,
470
  'truncate' => false, 'sep' => ', ', 'post_id' => 0,
471
  'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0,
472
+ 'return_array' => false,
473
  );
474
 
475
  $atts = wp_parse_args( $atts, $defaults );
515
 
516
  if ( ! empty($new_value) ) {
517
  $value = $new_value;
518
+ } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
519
  $value = implode($atts['sep'], $value);
520
  }
521
 
637
  // Multi-select dropdown
638
  if ( is_array( $value ) ) {
639
  $o_key = array_search( $field->options[ $other_key ], $value );
640
+
641
+ if ( $o_key !== false ) {
642
+ // Modify the original value so other key will be preserved
643
+ $value[ $other_key ] = $value[ $o_key ];
644
+
645
+ // By default, the array keys will be numeric for multi-select dropdowns
646
+ // If going backwards and forwards between pages, the array key will match the other key
647
+ if ( $o_key != $other_key ) {
648
+ unset( $value[ $o_key ] );
649
+ }
650
+
651
+ $args['temp_value'] = $value;
652
+ $value[ $other_key ] = reset( $other_vals );
653
+ }
654
  } else if ( $field->options[ $other_key ] == $value ) {
655
  $value = $other_vals;
656
  }
688
  $platform = __( 'Unknown', 'formidable' );
689
  $ub = '';
690
 
691
+ // Get the operating system
692
+ if ( preg_match('/windows|win32/i', $u_agent) ) {
693
+ $platform = 'Windows';
694
+ } else if ( preg_match('/android/i', $u_agent) ) {
695
+ $platform = 'Android';
696
+ } else if ( preg_match('/linux/i', $u_agent) ) {
697
+ $platform = 'Linux';
698
+ } else if ( preg_match('/macintosh|mac os x/i', $u_agent) ) {
699
+ $platform = 'OS X';
700
+ }
701
 
702
  $agent_options = array(
703
  'Firefox' => 'Mozilla Firefox',
741
  }
742
 
743
  // check if we have a number
744
+ if ( $version == '' ) {
745
  $version = '?';
746
  }
747
 
classes/helpers/FrmEntriesListHelper.php CHANGED
@@ -67,70 +67,7 @@ class FrmEntriesListHelper extends FrmListHelper {
67
  }
68
 
69
  public function search_box( $text, $input_id ) {
70
- if ( ! $this->has_items() && ! isset( $_REQUEST['s'] ) ) {
71
- return;
72
- }
73
-
74
- if ( isset($this->params['form']) ) {
75
- $form = FrmForm::getOne($this->params['form']);
76
- } else {
77
- $form = FrmForm::get_published_forms( array(), 1 );
78
- }
79
-
80
- if ( $form ) {
81
- $field_list = FrmField::getAll( array( 'fi.form_id' => $form->id, 'fi.type not' => FrmFieldsHelper::no_save_fields() ), 'field_order');
82
- }
83
-
84
- $fid = isset($_REQUEST['fid']) ? esc_attr( stripslashes( $_REQUEST['fid'] ) ) : '';
85
- $input_id = $input_id . '-search-input';
86
- $search_str = isset($_REQUEST['s']) ? esc_attr( stripslashes( $_REQUEST['s'] ) ) : '';
87
-
88
- foreach ( array( 'orderby', 'order') as $get_var ) {
89
- if ( ! empty( $_REQUEST[ $get_var ] ) ) {
90
- echo '<input type="hidden" name="'. esc_attr( $get_var ) .'" value="' . esc_attr( $_REQUEST[ $get_var ] ) . '" />';
91
- }
92
- }
93
-
94
- ?>
95
- <div class="search-box frm_sidebar">
96
- <label class="screen-reader-text" for="<?php echo esc_attr( $input_id ) ?>"><?php echo esc_attr( $text ); ?>:</label>
97
- <input type="text" id="<?php echo esc_attr( $input_id ) ?>" name="s" value="<?php echo esc_attr( $search_str ); ?>" />
98
- <?php
99
- if ( isset( $field_list ) && ! empty( $field_list ) ) { ?>
100
- <select name="fid" class="hide-if-js">
101
- <option value="">&mdash; <?php _e( 'All Fields', 'formidable' ) ?> &mdash;</option>
102
- <option value="created_at" <?php selected($fid, 'created_at') ?>><?php _e( 'Entry creation date', 'formidable' ) ?></option>
103
- <option value="id" <?php selected($fid, 'id') ?>><?php _e( 'Entry ID', 'formidable' ) ?></option>
104
- <?php foreach ( $field_list as $f ) { ?>
105
- <option value="<?php echo ($f->type == 'user_id') ? 'user_id' : $f->id ?>" <?php selected($fid, $f->id) ?>><?php echo FrmAppHelper::truncate($f->name, 30); ?></option>
106
- <?php } ?>
107
- </select>
108
-
109
- <div class="button dropdown hide-if-no-js">
110
- <a href="#" id="frm-fid-search" class="frm-dropdown-toggle" data-toggle="dropdown"><?php _e( 'Search', 'formidable' ) ?> <b class="caret"></b></a>
111
- <ul class="frm-dropdown-menu pull-right" id="frm-fid-search-menu" role="menu" aria-labelledby="frm-fid-search">
112
- <li><a href="#" id="fid-">&mdash; <?php _e( 'All Fields', 'formidable' ) ?> &mdash;</a></li>
113
- <li><a href="#" id="fid-created_at"><?php _e( 'Entry creation date', 'formidable' ) ?></a></li>
114
- <li><a href="#" id="fid-id"><?php _e( 'Entry ID', 'formidable' ) ?></a></li>
115
- <?php
116
- foreach ( $field_list as $f ) { ?>
117
- <li><a href="#" id="fid-<?php echo ($f->type == 'user_id') ? 'user_id' : $f->id ?>"><?php echo FrmAppHelper::truncate($f->name, 30); ?></a></li>
118
- <?php
119
- unset($f);
120
- } ?>
121
- </ul>
122
- </div>
123
- <?php submit_button( $text, 'button hide-if-js', false, false, array( 'id' => 'search-submit') );
124
- } else {
125
- submit_button( $text, 'button', false, false, array( 'id' => 'search-submit') );
126
- if ( ! empty( $search_str ) ) { ?>
127
- <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-entries&frm_action=list&form=' . $form->id ) ) ?>"><?php _e( 'Reset', 'formidable' ) ?></a>
128
- <?php
129
- }
130
- } ?>
131
-
132
- </div>
133
- <?php
134
  }
135
 
136
  public function single_row( $item, $style = '' ) {
67
  }
68
 
69
  public function search_box( $text, $input_id ) {
70
+ // Searching is a pro feature
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  }
72
 
73
  public function single_row( $item, $style = '' ) {
classes/helpers/FrmFieldsHelper.php CHANGED
@@ -174,7 +174,7 @@ class FrmFieldsHelper {
174
  $defaults = array( 'name' => $record->name, 'description' => $record->description);
175
  $default_opts = array(
176
  'field_key' => $record->field_key, 'type' => $record->type,
177
- 'default_value'=> $record->default_value, 'field_order' => $record->field_order,
178
  'required' => $record->required,
179
  );
180
 
@@ -183,7 +183,7 @@ class FrmFieldsHelper {
183
  $values['form_name'] = '';
184
  } else {
185
  foreach ( $defaults as $var => $default ) {
186
- $values[ $var ] = htmlspecialchars( FrmAppHelper::get_param( $var, $default ) );
187
  unset($var, $default);
188
  }
189
 
@@ -240,8 +240,8 @@ class FrmFieldsHelper {
240
  $frm_settings = FrmAppHelper::get_settings();
241
  return array(
242
  'name' => __( 'Untitled', 'formidable' ), 'description' => '',
243
- 'field_key' => $key, 'type' => $type, 'options'=>'', 'default_value'=>'',
244
- 'field_order' => $field_count+1, 'required' => false,
245
  'blank' => $frm_settings->blank_msg, 'unique_msg' => $frm_settings->unique_msg,
246
  'invalid' => __( 'This field is invalid', 'formidable' ), 'form_id' => $form_id,
247
  'field_options' => $field_options,
@@ -284,7 +284,7 @@ class FrmFieldsHelper {
284
  }
285
 
286
  public static function get_default_html( $type = 'text' ) {
287
- if (apply_filters('frm_normal_field_type_html', true, $type)) {
288
  $input = (in_array($type, array( 'radio', 'checkbox', 'data'))) ? '<div class="frm_opt_container">[input]</div>' : '[input]';
289
  $for = '';
290
  if ( ! in_array( $type, array( 'radio', 'checkbox', 'data', 'scale') ) ) {
@@ -345,7 +345,7 @@ DEFAULT_HTML;
345
  if ( ! is_array( $errors ) ) {
346
  $errors = array();
347
  }
348
- $error = isset($errors['field'. $field_id]) ? $errors['field'. $field_id] : false;
349
 
350
  //If field type is section heading, add class so a bottom margin can be added to either the h3 or description
351
  if ( $field['type'] == 'divider' ) {
@@ -356,7 +356,7 @@ DEFAULT_HTML;
356
  }
357
  }
358
 
359
- foreach ( array( 'description' => $field['description'], 'required_label' => $required, 'error' => $error) as $code => $value) {
360
  self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html );
361
  }
362
 
@@ -373,7 +373,7 @@ DEFAULT_HTML;
373
  $html = str_replace('[field_name]', $field['name'], $html);
374
 
375
  //replace [error_class]
376
- $error_class = isset ( $errors['field'. $field_id] ) ? ' frm_blank_field' : '';
377
  self::get_more_field_classes( $error_class, $field, $field_id, $html );
378
  if ( $field['type'] == 'html' && strpos( $html, '[error_class]' ) === false ) {
379
  // there is no error_class shortcode to use for addign fields
@@ -442,8 +442,8 @@ DEFAULT_HTML;
442
  }
443
 
444
  // remove [collapse_this] when running the free version
445
- if (preg_match('/\[(collapse_this)\]/s', $html)) {
446
- $html = str_replace('[collapse_this]', '', $html);
447
  }
448
 
449
  return $html;
@@ -1143,39 +1143,39 @@ DEFAULT_HTML;
1143
  }
1144
 
1145
  public static function get_bulk_prefilled_opts(array &$prepop) {
1146
- $prepop[__( 'Countries', 'formidable' )] = FrmFieldsHelper::get_countries();
1147
 
1148
  $states = FrmFieldsHelper::get_us_states();
1149
  $state_abv = array_keys($states);
1150
  sort($state_abv);
1151
- $prepop[__( 'U.S. State Abbreviations', 'formidable' )] = $state_abv;
1152
 
1153
  $states = array_values($states);
1154
  sort($states);
1155
- $prepop[__( 'U.S. States', 'formidable' )] = $states;
1156
  unset($state_abv, $states);
1157
 
1158
- $prepop[__( 'Age', 'formidable' )] = array(
1159
  __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1160
  __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1161
  __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1162
  );
1163
 
1164
- $prepop[__( 'Satisfaction', 'formidable' )] = array(
1165
  __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1166
  __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1167
  );
1168
 
1169
- $prepop[__( 'Importance', 'formidable' )] = array(
1170
  __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1171
  __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1172
  );
1173
 
1174
- $prepop[__( 'Agreement', 'formidable' )] = array(
1175
  __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1176
  __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1177
  );
1178
 
1179
- $prepop = apply_filters('frm_bulk_field_choices', $prepop);
1180
  }
1181
  }
174
  $defaults = array( 'name' => $record->name, 'description' => $record->description);
175
  $default_opts = array(
176
  'field_key' => $record->field_key, 'type' => $record->type,
177
+ 'default_value' => $record->default_value, 'field_order' => $record->field_order,
178
  'required' => $record->required,
179
  );
180
 
183
  $values['form_name'] = '';
184
  } else {
185
  foreach ( $defaults as $var => $default ) {
186
+ $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' );
187
  unset($var, $default);
188
  }
189
 
240
  $frm_settings = FrmAppHelper::get_settings();
241
  return array(
242
  'name' => __( 'Untitled', 'formidable' ), 'description' => '',
243
+ 'field_key' => $key, 'type' => $type, 'options' => '', 'default_value' => '',
244
+ 'field_order' => $field_count + 1, 'required' => false,
245
  'blank' => $frm_settings->blank_msg, 'unique_msg' => $frm_settings->unique_msg,
246
  'invalid' => __( 'This field is invalid', 'formidable' ), 'form_id' => $form_id,
247
  'field_options' => $field_options,
284
  }
285
 
286
  public static function get_default_html( $type = 'text' ) {
287
+ if ( apply_filters( 'frm_normal_field_type_html', true, $type ) ) {
288
  $input = (in_array($type, array( 'radio', 'checkbox', 'data'))) ? '<div class="frm_opt_container">[input]</div>' : '[input]';
289
  $for = '';
290
  if ( ! in_array( $type, array( 'radio', 'checkbox', 'data', 'scale') ) ) {
345
  if ( ! is_array( $errors ) ) {
346
  $errors = array();
347
  }
348
+ $error = isset( $errors[ 'field' . $field_id ] ) ? $errors[ 'field' . $field_id ] : false;
349
 
350
  //If field type is section heading, add class so a bottom margin can be added to either the h3 or description
351
  if ( $field['type'] == 'divider' ) {
356
  }
357
  }
358
 
359
+ foreach ( array( 'description' => $field['description'], 'required_label' => $required, 'error' => $error ) as $code => $value ) {
360
  self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html );
361
  }
362
 
373
  $html = str_replace('[field_name]', $field['name'], $html);
374
 
375
  //replace [error_class]
376
+ $error_class = isset ( $errors[ 'field' . $field_id ] ) ? ' frm_blank_field' : '';
377
  self::get_more_field_classes( $error_class, $field, $field_id, $html );
378
  if ( $field['type'] == 'html' && strpos( $html, '[error_class]' ) === false ) {
379
  // there is no error_class shortcode to use for addign fields
442
  }
443
 
444
  // remove [collapse_this] when running the free version
445
+ if ( preg_match( '/\[(collapse_this)\]/s', $html ) ) {
446
+ $html = str_replace( '[collapse_this]', '', $html );
447
  }
448
 
449
  return $html;
1143
  }
1144
 
1145
  public static function get_bulk_prefilled_opts(array &$prepop) {
1146
+ $prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1147
 
1148
  $states = FrmFieldsHelper::get_us_states();
1149
  $state_abv = array_keys($states);
1150
  sort($state_abv);
1151
+ $prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1152
 
1153
  $states = array_values($states);
1154
  sort($states);
1155
+ $prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1156
  unset($state_abv, $states);
1157
 
1158
+ $prepop[ __( 'Age', 'formidable' ) ] = array(
1159
  __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1160
  __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1161
  __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1162
  );
1163
 
1164
+ $prepop[ __( 'Satisfaction', 'formidable' ) ] = array(
1165
  __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1166
  __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1167
  );
1168
 
1169
+ $prepop[ __( 'Importance', 'formidable' ) ] = array(
1170
  __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1171
  __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1172
  );
1173
 
1174
+ $prepop[ __( 'Agreement', 'formidable' ) ] = array(
1175
  __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1176
  __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1177
  );
1178
 
1179
+ $prepop = apply_filters( 'frm_bulk_field_choices', $prepop );
1180
  }
1181
  }
classes/helpers/FrmFormActionsHelper.php CHANGED
@@ -16,7 +16,7 @@ class FrmFormActionsHelper {
16
  return $action_controls->get_all( $form_id, $limit );
17
  }
18
 
19
- $args = self::action_args( $form_id );
20
  $actions = FrmAppHelper::check_cache( serialize( $args ), 'frm_actions', $args, 'get_posts' );
21
 
22
  if ( ! $actions ) {
@@ -41,11 +41,11 @@ class FrmFormActionsHelper {
41
  return $settings;
42
  }
43
 
44
- public static function action_args( $form_id = 0 ) {
45
  $args = array(
46
  'post_type' => FrmFormActionsController::$action_post_type,
47
  'post_status' => 'publish',
48
- 'numberposts' => 99,
49
  'orderby' => 'title',
50
  'order' => 'ASC',
51
  );
@@ -57,16 +57,6 @@ class FrmFormActionsHelper {
57
  return $args;
58
  }
59
 
60
- /**
61
- * Delete the action cache when a form action is created, deleted, or updated
62
- *
63
- * @since 2.0.4
64
- */
65
- public static function clear_action_cache( $form_id ) {
66
- $args = self::action_args( $form_id );
67
- wp_cache_delete( serialize( $args ), 'frm_actions' );
68
- }
69
-
70
  public static function action_conditions_met($action, $entry) {
71
  $notification = $action->post_content;
72
  $stop = false;
16
  return $action_controls->get_all( $form_id, $limit );
17
  }
18
 
19
+ $args = self::action_args( $form_id, $limit );
20
  $actions = FrmAppHelper::check_cache( serialize( $args ), 'frm_actions', $args, 'get_posts' );
21
 
22
  if ( ! $actions ) {
41
  return $settings;
42
  }
43
 
44
+ public static function action_args( $form_id = 0, $limit = 99 ) {
45
  $args = array(
46
  'post_type' => FrmFormActionsController::$action_post_type,
47
  'post_status' => 'publish',
48
+ 'numberposts' => $limit,
49
  'orderby' => 'title',
50
  'order' => 'ASC',
51
  );
57
  return $args;
58
  }
59
 
 
 
 
 
 
 
 
 
 
 
60
  public static function action_conditions_met($action, $entry) {
61
  $notification = $action->post_content;
62
  $stop = false;
classes/helpers/FrmFormsHelper.php CHANGED
@@ -123,7 +123,7 @@ class FrmFormsHelper {
123
  $post_values = isset($_POST) ? $_POST : array();
124
  }
125
 
126
- foreach ( array( 'name' => '', 'description' => '') as $var => $default) {
127
  if ( ! isset( $values[ $var ] ) ) {
128
  $values[ $var ] = FrmAppHelper::get_param( $var, $default );
129
  }
@@ -131,7 +131,7 @@ class FrmFormsHelper {
131
 
132
  $values['description'] = FrmAppHelper::use_wpautop($values['description']);
133
 
134
- foreach ( array( 'form_id' => '', 'logged_in' => '', 'editable' => '', 'default_template' => 0, 'is_template' => 0, 'status' => 'draft', 'parent_form_id' => 0) as $var => $default) {
135
  if ( ! isset( $values[ $var ] ) ) {
136
  $values[ $var ] = FrmAppHelper::get_param( $var, $default );
137
  }
@@ -193,7 +193,7 @@ class FrmFormsHelper {
193
  unset($k, $v);
194
  }
195
  } else {
196
- $values[$var] = ($post_values && isset($post_values['options'][$var])) ? $post_values['options'][$var] : (($record && isset($record->options[$var])) ? $record->options[$var] : $default);
197
  }
198
 
199
  unset($var, $default);
@@ -344,7 +344,7 @@ BEFORE_HTML;
344
  }
345
 
346
  public static function replace_shortcodes( $html, $form, $title = false, $description = false, $values = array() ) {
347
- foreach ( array( 'form_name' => $title, 'form_description' => $description, 'entry_key' => true) as $code => $show) {
348
  if ( $code == 'form_name' ) {
349
  $replace_with = $form->name;
350
  } else if ( $code == 'form_description' ) {
@@ -534,7 +534,7 @@ BEFORE_HTML;
534
  $status = 'publish';
535
  }
536
 
537
- $name = $nice_names[$status];
538
 
539
  return $name;
540
  }
@@ -542,7 +542,7 @@ BEFORE_HTML;
542
  public static function get_params() {
543
  $values = array();
544
  foreach ( array( 'template' => 0, 'id' => '', 'paged' => 1, 'form' => '', 'search' => '', 'sort' => '', 'sdir' => '') as $var => $default ) {
545
- $values[$var] = FrmAppHelper::get_param($var, $default);
546
  }
547
 
548
  return $values;
@@ -563,11 +563,11 @@ BEFORE_HTML;
563
  ),
564
  );
565
 
566
- if ( ! isset($available_status[$status]) ) {
567
  return;
568
  }
569
 
570
- FrmAppHelper::permission_check($available_status[$status]['permission']);
571
 
572
  $params = self::get_params();
573
 
@@ -575,15 +575,15 @@ BEFORE_HTML;
575
  check_admin_referer($status .'_form_' . $params['id']);
576
 
577
  $count = 0;
578
- if ( FrmForm::set_status( $params['id'], $available_status[$status]['new_status'] ) ) {
579
  $count++;
580
  }
581
 
582
  $available_status['untrash']['message'] = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count );
583
  $available_status['trash']['message'] = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=untrash&form_type='. ( isset( $_REQUEST['form_type'] ) ? sanitize_title( $_REQUEST['form_type'] ) : '' ) . '&id=' . $params['id'], 'untrash_form_' . $params['id'] ) ) . '">', '</a>' );
584
 
585
- $message = $available_status[$status]['message'];
586
 
587
- FrmFormsController::display_forms_list($params, $message, 1);
588
  }
589
  }
123
  $post_values = isset($_POST) ? $_POST : array();
124
  }
125
 
126
+ foreach ( array( 'name' => '', 'description' => '' ) as $var => $default ) {
127
  if ( ! isset( $values[ $var ] ) ) {
128
  $values[ $var ] = FrmAppHelper::get_param( $var, $default );
129
  }
131
 
132
  $values['description'] = FrmAppHelper::use_wpautop($values['description']);
133
 
134
+ foreach ( array( 'form_id' => '', 'logged_in' => '', 'editable' => '', 'default_template' => 0, 'is_template' => 0, 'status' => 'draft', 'parent_form_id' => 0 ) as $var => $default ) {
135
  if ( ! isset( $values[ $var ] ) ) {
136
  $values[ $var ] = FrmAppHelper::get_param( $var, $default );
137
  }
193
  unset($k, $v);
194
  }
195
  } else {
196
+ $values[ $var ] = ( $post_values && isset( $post_values['options'][ $var ] ) ) ? $post_values['options'][ $var ] : ( ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : $default );
197
  }
198
 
199
  unset($var, $default);
344
  }
345
 
346
  public static function replace_shortcodes( $html, $form, $title = false, $description = false, $values = array() ) {
347
+ foreach ( array( 'form_name' => $title, 'form_description' => $description, 'entry_key' => true ) as $code => $show ) {
348
  if ( $code == 'form_name' ) {
349
  $replace_with = $form->name;
350
  } else if ( $code == 'form_description' ) {
534
  $status = 'publish';
535
  }
536
 
537
+ $name = $nice_names[ $status ];
538
 
539
  return $name;
540
  }
542
  public static function get_params() {
543
  $values = array();
544
  foreach ( array( 'template' => 0, 'id' => '', 'paged' => 1, 'form' => '', 'search' => '', 'sort' => '', 'sdir' => '') as $var => $default ) {
545
+ $values[ $var ] = FrmAppHelper::get_param( $var, $default );
546
  }
547
 
548
  return $values;
563
  ),
564
  );
565
 
566
+ if ( ! isset( $available_status[ $status ] ) ) {
567
  return;
568
  }
569
 
570
+ FrmAppHelper::permission_check( $available_status[ $status ]['permission'] );
571
 
572
  $params = self::get_params();
573
 
575
  check_admin_referer($status .'_form_' . $params['id']);
576
 
577
  $count = 0;
578
+ if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) {
579
  $count++;
580
  }
581
 
582
  $available_status['untrash']['message'] = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count );
583
  $available_status['trash']['message'] = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=untrash&form_type='. ( isset( $_REQUEST['form_type'] ) ? sanitize_title( $_REQUEST['form_type'] ) : '' ) . '&id=' . $params['id'], 'untrash_form_' . $params['id'] ) ) . '">', '</a>' );
584
 
585
+ $message = $available_status[ $status ]['message'];
586
 
587
+ FrmFormsController::display_forms_list( $params, $message, 1 );
588
  }
589
  }
classes/helpers/FrmFormsListHelper.php CHANGED
@@ -180,7 +180,7 @@ class FrmFormsListHelper extends FrmListHelper {
180
  }
181
 
182
  if ( $counts->{$status} || 'published' == $status ) {
183
- $links[$status] = '<a href="?page=formidable&form_type='. $status .'" '. $class .'>'. sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) .'</a>';
184
  }
185
 
186
  unset($status, $name);
@@ -252,9 +252,9 @@ class FrmFormsListHelper extends FrmListHelper {
252
  $val = '<abbr title="' . esc_attr( date( 'Y/m/d g:i:s A', strtotime( $item->created_at ) ) ) . '">' . $date . '</abbr>';
253
  break;
254
  case 'shortcode':
255
- $val = '<input type="text" readonly="true" class="frm_select_box" value="'. esc_attr("[formidable id={$item->id}]") .'" /><br/>';
256
  if ( 'excerpt' == $mode ) {
257
- $val .= '<input type="text" readonly="true" class="frm_select_box" value="'. esc_attr("[formidable key={$item->form_key}]") .'" />';
258
  }
259
  break;
260
  case 'entries':
180
  }
181
 
182
  if ( $counts->{$status} || 'published' == $status ) {
183
+ $links[ $status ] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>';
184
  }
185
 
186
  unset($status, $name);
252
  $val = '<abbr title="' . esc_attr( date( 'Y/m/d g:i:s A', strtotime( $item->created_at ) ) ) . '">' . $date . '</abbr>';
253
  break;
254
  case 'shortcode':
255
+ $val = '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( "[formidable id=' . $item->id .']" ) . '" /><br/>';
256
  if ( 'excerpt' == $mode ) {
257
+ $val .= '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( "[formidable key=' . $item->form_key . ']" ) . '" />';
258
  }
259
  break;
260
  case 'entries':
classes/helpers/FrmStylesHelper.php CHANGED
@@ -12,7 +12,7 @@ class FrmStylesHelper {
12
  'overcast' => 'Overcast',
13
  'le-frog' => 'Le Frog',
14
  'flick' => 'Flick',
15
- 'pepper-grinder'=> 'Pepper Grinder',
16
  'eggplant' => 'Eggplant',
17
  'dark-hive' => 'Dark Hive',
18
  'cupertino' => 'Cupertino',
@@ -118,12 +118,12 @@ class FrmStylesHelper {
118
  if ( 'arrow' == $type && is_numeric($key) ) {
119
  //frm_arrowup6_icon
120
  $arrow = array( '-' => 'down', '+' => 'up');
121
- $class = 'frm_arrow'. $arrow[$icon];
122
  } else {
123
  //frm_minus1_icon
124
  $key = str_replace('p', '', $key);
125
  $plus = array( '-' => 'minus', '+' => 'plus');
126
- $class = 'frm_'. $plus[$icon];
127
  }
128
 
129
  if ( $key ) {
@@ -143,7 +143,7 @@ class FrmStylesHelper {
143
  ?>
144
  <select name="<?php echo esc_attr( $frm_style->get_field_name($name) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js">
145
  <?php foreach ( $icons as $key => $icon ) { ?>
146
- <option value="<?php echo esc_attr( $key ) ?>" <?php selected( $style->post_content[$name], $key ) ?>>
147
  <?php echo '&#xe'. $icon['+'] .'; &#xe'. $icon['-'] .';'; ?>
148
  </option>
149
  <?php } ?>
@@ -151,8 +151,8 @@ class FrmStylesHelper {
151
 
152
  <div class="btn-group hide-if-no-js" id="frm_<?php echo esc_attr( $name ) ?>_select">
153
  <button class="multiselect dropdown-toggle btn btn-default" data-toggle="dropdown" type="button">
154
- <i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[$name], '+', $type ) ) ?>"></i>
155
- <i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[$name], '-', $type ) ) ?>"></i>
156
  <b class="caret"></b>
157
  </button>
158
  <ul class="multiselect-container frm-dropdown-menu">
12
  'overcast' => 'Overcast',
13
  'le-frog' => 'Le Frog',
14
  'flick' => 'Flick',
15
+ 'pepper-grinder' => 'Pepper Grinder',
16
  'eggplant' => 'Eggplant',
17
  'dark-hive' => 'Dark Hive',
18
  'cupertino' => 'Cupertino',
118
  if ( 'arrow' == $type && is_numeric($key) ) {
119
  //frm_arrowup6_icon
120
  $arrow = array( '-' => 'down', '+' => 'up');
121
+ $class = 'frm_arrow' . $arrow[ $icon ];
122
  } else {
123
  //frm_minus1_icon
124
  $key = str_replace('p', '', $key);
125
  $plus = array( '-' => 'minus', '+' => 'plus');
126
+ $class = 'frm_' . $plus[ $icon ];
127
  }
128
 
129
  if ( $key ) {
143
  ?>
144
  <select name="<?php echo esc_attr( $frm_style->get_field_name($name) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js">
145
  <?php foreach ( $icons as $key => $icon ) { ?>
146
+ <option value="<?php echo esc_attr( $key ) ?>" <?php selected( $style->post_content[ $name ], $key ) ?>>
147
  <?php echo '&#xe'. $icon['+'] .'; &#xe'. $icon['-'] .';'; ?>
148
  </option>
149
  <?php } ?>
151
 
152
  <div class="btn-group hide-if-no-js" id="frm_<?php echo esc_attr( $name ) ?>_select">
153
  <button class="multiselect dropdown-toggle btn btn-default" data-toggle="dropdown" type="button">
154
+ <i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[ $name ], '+', $type ) ) ?>"></i>
155
+ <i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[ $name ], '-', $type ) ) ?>"></i>
156
  <b class="caret"></b>
157
  </button>
158
  <ul class="multiselect-container frm-dropdown-menu">
classes/helpers/FrmXMLHelper.php CHANGED
@@ -9,12 +9,13 @@ class FrmXMLHelper {
9
  if ( is_array( $opt ) ) {
10
  foreach ( $opt as $ok => $ov ) {
11
  echo "\n" . $padding;
12
- echo '<' . ( is_numeric( $ok ) ? 'key:' : '' ) . $ok . '>';
 
13
  self::get_xml_values( $ov, $padding .' ' );
14
  if ( is_array( $ov ) ) {
15
  echo "\n" . $padding;
16
  }
17
- echo '</' . ( is_numeric( $ok ) ? 'key:' : '' ) . $ok . '>';
18
  }
19
  } else {
20
  echo self::cdata( $opt );
@@ -36,11 +37,11 @@ class FrmXMLHelper {
36
 
37
  unset($defaults);
38
 
39
- if ( !defined('WP_IMPORTING') ) {
40
  define('WP_IMPORTING', true);
41
  }
42
 
43
- if ( !class_exists('DOMDocument') ) {
44
  return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() );
45
  }
46
 
@@ -125,9 +126,9 @@ class FrmXMLHelper {
125
  $edit_query['created_at'] = $form['created_at'];
126
  }
127
 
128
- if ( ! empty($form['parent_form_id']) && isset($imported['forms'][$form['parent_form_id']]) ) {
129
  // replace the old parent id with the new one
130
- $form['parent_form_id'] = $imported['forms'][$form['parent_form_id']];
131
  }
132
 
133
  $edit_query = apply_filters('frm_match_xml_form', $edit_query, $form);
@@ -140,13 +141,13 @@ class FrmXMLHelper {
140
  FrmForm::update($form_id, $form );
141
  $imported['updated']['forms']++;
142
  // Keep track of whether this specific form was updated or not
143
- $imported['form_status'][$form_id] = 'updated';
144
 
145
  $form_fields = FrmField::get_all_for_form( $form_id );
146
  $old_fields = array();
147
  foreach ( $form_fields as $f ) {
148
- $old_fields[$f->id] = $f;
149
- $old_fields[$f->field_key] = $f->id;
150
  unset($f);
151
  }
152
  $form_fields = $old_fields;
@@ -158,7 +159,7 @@ class FrmXMLHelper {
158
  if ( $form_id ) {
159
  $imported['imported']['forms']++;
160
  // Keep track of whether this specific form was updated or not
161
- $imported['form_status'][$form_id] = 'imported';
162
 
163
  // Check if any repeating sections form_select need to be updated
164
  if ( isset( $repeat_fields[ $form['id'] ] ) ) {
@@ -204,25 +205,25 @@ class FrmXMLHelper {
204
 
205
  if ( ! empty($this_form) ) {
206
  // check for field to edit by field id
207
- if ( isset($form_fields[$f['id']]) ) {
208
  FrmField::update( $f['id'], $f );
209
  $imported['updated']['fields']++;
210
 
211
- unset($form_fields[$f['id']]);
212
 
213
  //unset old field key
214
- if ( isset($form_fields[$f['field_key']]) ) {
215
- unset($form_fields[$f['field_key']]);
216
- }
217
- } else if ( isset($form_fields[$f['field_key']]) ) {
218
  // check for field to edit by field key
219
  unset($f['id']);
220
 
221
- FrmField::update( $form_fields[$f['field_key']], $f );
222
  $imported['updated']['fields']++;
223
 
224
- unset($form_fields[$form_fields[$f['field_key']]]); //unset old field id
225
- unset($form_fields[$f['field_key']]); //unset old field key
226
  } else {
227
  $new_id = FrmField::create( $f );
228
  if ( $new_id == false ) {
@@ -262,7 +263,7 @@ class FrmXMLHelper {
262
  // Update field ids/keys to new ones
263
  do_action('frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id));
264
 
265
- $imported['forms'][ (int) $item->id] = $form_id;
266
 
267
  // Send pre 2.0 form options through function that creates actions
268
  self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, $switch = true );
@@ -334,8 +335,8 @@ class FrmXMLHelper {
334
  self::update_postmeta($post, $post_id);
335
 
336
  $this_type = 'posts';
337
- if ( isset($post_types[$post['post_type']]) ) {
338
- $this_type = $post_types[$post['post_type']];
339
  }
340
 
341
  if ( isset($post['ID']) && $post_id == $post['ID'] ) {
@@ -346,7 +347,7 @@ class FrmXMLHelper {
346
 
347
  unset($post);
348
 
349
- $imported['posts'][ (int) $old_id] = $post_id;
350
  }
351
 
352
  return $imported;
@@ -393,8 +394,8 @@ class FrmXMLHelper {
393
  } else if ( $m['key'] == 'frm_options' ) {
394
 
395
  foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) {
396
- if ( isset($m['value'][$setting_name]) && is_numeric($m['value'][$setting_name]) && isset($frm_duplicate_ids[$m['value'][$setting_name]]) ) {
397
- $m['value'][$setting_name] = $frm_duplicate_ids[$m['value'][$setting_name]];
398
  }
399
  }
400
 
@@ -412,9 +413,9 @@ class FrmXMLHelper {
412
  }
413
 
414
  foreach ( $check_dup_array as $check_k ) {
415
- foreach ( (array) $m['value'][$check_k] as $mk => $mv ) {
416
- if ( isset($frm_duplicate_ids[$mv]) ) {
417
- $m['value'][$check_k][$mk] = $frm_duplicate_ids[$mv];
418
  }
419
  unset($mk, $mv);
420
  }
@@ -454,11 +455,11 @@ class FrmXMLHelper {
454
  $name = (string) $c;
455
  }
456
 
457
- if ( ! isset($post['tax_input'][$taxonomy]) ) {
458
- $post['tax_input'][$taxonomy] = array();
459
- }
460
 
461
- $post['tax_input'][$taxonomy][] = $name;
462
  unset($name);
463
  }
464
  }
@@ -524,7 +525,7 @@ class FrmXMLHelper {
524
 
525
  $message = '<ul>';
526
  foreach ( $result as $type => $results ) {
527
- if ( ! isset($t_strings[$type]) ) {
528
  // only print imported and updated
529
  continue;
530
  }
@@ -536,7 +537,7 @@ class FrmXMLHelper {
536
  }
537
 
538
  if ( ! empty($s_message) ) {
539
- $message .= '<li><strong>'. $t_strings[$type] .':</strong> ';
540
  $message .= implode(', ', $s_message);
541
  $message .= '</li>';
542
  }
@@ -566,14 +567,14 @@ class FrmXMLHelper {
566
  'actions' => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
567
  );
568
 
569
- $s_message[] = isset($strings[$type]) ? $strings[$type] : ' '. $m .' '. ucfirst($type);
570
  }
571
 
572
  public static function cdata( $str ) {
573
  $str = maybe_unserialize($str);
574
  if ( is_array($str) ) {
575
  $str = json_encode($str);
576
- } else if (seems_utf8( $str ) == false ) {
577
  $str = utf8_encode( $str );
578
  }
579
 
@@ -630,8 +631,8 @@ class FrmXMLHelper {
630
  );
631
 
632
  foreach ( $post_settings as $post_setting ) {
633
- if ( isset( $form_options[$post_setting] ) ) {
634
- $new_action['post_content'][$post_setting] = $form_options[$post_setting];
635
  }
636
  unset($post_setting);
637
  }
@@ -690,11 +691,11 @@ class FrmXMLHelper {
690
  foreach ( $post_content as $key => $setting ) {
691
  if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
692
  // Replace old IDs with new IDs
693
- $post_content[$key] = str_replace( $old, $new, $setting );
694
  } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
695
  foreach ( $setting as $k => $val ) {
696
  // Replace old IDs with new IDs
697
- $post_content[$key][$k] = str_replace( $old, $new, $val );
698
  }
699
  }
700
  unset( $key, $setting );
@@ -791,12 +792,12 @@ class FrmXMLHelper {
791
  // Format the reply to email and name
792
  $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' );
793
  foreach ( $reply_fields as $f => $val ) {
794
- if ( isset( $notification[$f] ) ) {
795
- $atts[$f] = $notification[$f];
796
- if ( 'custom' == $notification[$f] ) {
797
- $atts[$f] = $notification['cust_' . $f];
798
- } else if ( is_numeric( $atts[$f] ) && ! empty( $atts[$f] ) ) {
799
- $atts[$f] = '['. $atts[$f] .']';
800
  }
801
  }
802
  unset( $f, $val );
@@ -827,13 +828,13 @@ class FrmXMLHelper {
827
  foreach ( $atts['email_to'] as $key => $email_field ) {
828
 
829
  if ( is_numeric( $email_field ) ) {
830
- $atts['email_to'][$key] = '['. $email_field .']';
831
  }
832
 
833
  if ( strpos( $email_field, '|') ) {
834
  $email_opt = explode( '|', $email_field );
835
  if ( isset( $email_opt[0] ) ) {
836
- $atts['email_to'][$key] = '['. $email_opt[0] .' show='. $email_opt[1] .']';
837
  }
838
  unset( $email_opt );
839
  }
@@ -854,12 +855,12 @@ class FrmXMLHelper {
854
  // Add more fields to the new notification
855
  $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
856
  foreach ( $add_fields as $add_field ) {
857
- if ( isset ( $notification[$add_field] ) ) {
858
- $new_notification['post_content'][$add_field] = $notification[$add_field];
859
  } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
860
- $new_notification['post_content'][$add_field] = 0;
861
  } else {
862
- $new_notification['post_content'][$add_field] = '';
863
  }
864
  unset( $add_field );
865
  }
@@ -868,7 +869,7 @@ class FrmXMLHelper {
868
  $new_notification['post_content']['reply_to'] = $atts['reply_to'];
869
 
870
  // Set from
871
- if ( !empty( $atts['reply_to'] ) || !empty( $atts['reply_to_name'] ) ) {
872
  $new_notification['post_content']['from'] = ( empty($atts['reply_to_name']) ? '[sitename]' : $atts['reply_to_name'] ) .' <'. ( empty($atts['reply_to']) ? '[admin_email]' : $atts['reply_to'] ) .'>';
873
  }
874
  }
@@ -883,7 +884,7 @@ class FrmXMLHelper {
883
  if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) {
884
  foreach ( $post_content['conditions'] as $email_key => $val ) {
885
  if ( is_numeric( $email_key ) ) {
886
- $post_content['conditions'][$email_key] = self::switch_action_field_ids( $val, array( 'hide_field' ) );
887
  }
888
  unset( $email_key, $val);
889
  }
9
  if ( is_array( $opt ) ) {
10
  foreach ( $opt as $ok => $ov ) {
11
  echo "\n" . $padding;
12
+ $tag = ( is_numeric( $ok ) ? 'key:' : '' ) . $ok;
13
+ echo '<' . $tag . '>';
14
  self::get_xml_values( $ov, $padding .' ' );
15
  if ( is_array( $ov ) ) {
16
  echo "\n" . $padding;
17
  }
18
+ echo '</' . $tag . '>';
19
  }
20
  } else {
21
  echo self::cdata( $opt );
37
 
38
  unset($defaults);
39
 
40
+ if ( ! defined( 'WP_IMPORTING' ) ) {
41
  define('WP_IMPORTING', true);
42
  }
43
 
44
+ if ( ! class_exists( 'DOMDocument' ) ) {
45
  return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() );
46
  }
47
 
126
  $edit_query['created_at'] = $form['created_at'];
127
  }
128
 
129
+ if ( ! empty( $form['parent_form_id'] ) && isset( $imported['forms'][ $form['parent_form_id'] ] ) ) {
130
  // replace the old parent id with the new one
131
+ $form['parent_form_id'] = $imported['forms'][ $form['parent_form_id'] ];
132
  }
133
 
134
  $edit_query = apply_filters('frm_match_xml_form', $edit_query, $form);
141
  FrmForm::update($form_id, $form );
142
  $imported['updated']['forms']++;
143
  // Keep track of whether this specific form was updated or not
144
+ $imported['form_status'][ $form_id ] = 'updated';
145
 
146
  $form_fields = FrmField::get_all_for_form( $form_id );
147
  $old_fields = array();
148
  foreach ( $form_fields as $f ) {
149
+ $old_fields[ $f->id ] = $f;
150
+ $old_fields[ $f->field_key ] = $f->id;
151
  unset($f);
152
  }
153
  $form_fields = $old_fields;
159
  if ( $form_id ) {
160
  $imported['imported']['forms']++;
161
  // Keep track of whether this specific form was updated or not
162
+ $imported['form_status'][ $form_id ] = 'imported';
163
 
164
  // Check if any repeating sections form_select need to be updated
165
  if ( isset( $repeat_fields[ $form['id'] ] ) ) {
205
 
206
  if ( ! empty($this_form) ) {
207
  // check for field to edit by field id
208
+ if ( isset( $form_fields[ $f['id'] ] ) ) {
209
  FrmField::update( $f['id'], $f );
210
  $imported['updated']['fields']++;
211
 
212
+ unset( $form_fields[ $f['id'] ] );
213
 
214
  //unset old field key
215
+ if ( isset( $form_fields[ $f['field_key'] ] ) ) {
216
+ unset( $form_fields[ $f['field_key'] ] );
217
+ }
218
+ } else if ( isset( $form_fields[ $f['field_key'] ] ) ) {
219
  // check for field to edit by field key
220
  unset($f['id']);
221
 
222
+ FrmField::update( $form_fields[ $f['field_key'] ], $f );
223
  $imported['updated']['fields']++;
224
 
225
+ unset( $form_fields[ $form_fields[ $f['field_key'] ] ] ); //unset old field id
226
+ unset( $form_fields[ $f['field_key'] ] ); //unset old field key
227
  } else {
228
  $new_id = FrmField::create( $f );
229
  if ( $new_id == false ) {
263
  // Update field ids/keys to new ones
264
  do_action('frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id));
265
 
266
+ $imported['forms'][ (int) $item->id ] = $form_id;
267
 
268
  // Send pre 2.0 form options through function that creates actions
269
  self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, $switch = true );
335
  self::update_postmeta($post, $post_id);
336
 
337
  $this_type = 'posts';
338
+ if ( isset( $post_types[ $post['post_type'] ] ) ) {
339
+ $this_type = $post_types[ $post['post_type'] ];
340
  }
341
 
342
  if ( isset($post['ID']) && $post_id == $post['ID'] ) {
347
 
348
  unset($post);
349
 
350
+ $imported['posts'][ (int) $old_id ] = $post_id;
351
  }
352
 
353
  return $imported;
394
  } else if ( $m['key'] == 'frm_options' ) {
395
 
396
  foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) {
397
+ if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) {
398
+ $m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ];
399
  }
400
  }
401
 
413
  }
414
 
415
  foreach ( $check_dup_array as $check_k ) {
416
+ foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) {
417
+ if ( isset( $frm_duplicate_ids[ $mv ] ) ) {
418
+ $m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ];
419
  }
420
  unset($mk, $mv);
421
  }
455
  $name = (string) $c;
456
  }
457
 
458
+ if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) {
459
+ $post['tax_input'][ $taxonomy ] = array();
460
+ }
461
 
462
+ $post['tax_input'][ $taxonomy ][] = $name;
463
  unset($name);
464
  }
465
  }
525
 
526
  $message = '<ul>';
527
  foreach ( $result as $type => $results ) {
528
+ if ( ! isset( $t_strings[ $type ] ) ) {
529
  // only print imported and updated
530
  continue;
531
  }
537
  }
538
 
539
  if ( ! empty($s_message) ) {
540
+ $message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> ';
541
  $message .= implode(', ', $s_message);
542
  $message .= '</li>';
543
  }
567
  'actions' => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
568
  );
569
 
570
+ $s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type );
571
  }
572
 
573
  public static function cdata( $str ) {
574
  $str = maybe_unserialize($str);
575
  if ( is_array($str) ) {
576
  $str = json_encode($str);
577
+ } else if ( seems_utf8( $str ) == false ) {
578
  $str = utf8_encode( $str );
579
  }
580
 
631
  );
632
 
633
  foreach ( $post_settings as $post_setting ) {
634
+ if ( isset( $form_options[ $post_setting ] ) ) {
635
+ $new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ];
636
  }
637
  unset($post_setting);
638
  }
691
  foreach ( $post_content as $key => $setting ) {
692
  if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
693
  // Replace old IDs with new IDs
694
+ $post_content[ $key ] = str_replace( $old, $new, $setting );
695
  } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
696
  foreach ( $setting as $k => $val ) {
697
  // Replace old IDs with new IDs
698
+ $post_content[ $key ][ $k ] = str_replace( $old, $new, $val );
699
  }
700
  }
701
  unset( $key, $setting );
792
  // Format the reply to email and name
793
  $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' );
794
  foreach ( $reply_fields as $f => $val ) {
795
+ if ( isset( $notification[ $f ] ) ) {
796
+ $atts[ $f ] = $notification[ $f ];
797
+ if ( 'custom' == $notification[ $f ] ) {
798
+ $atts[ $f ] = $notification[ 'cust_' . $f ];
799
+ } else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) {
800
+ $atts[ $f ] = '[' . $atts[ $f ] . ']';
801
  }
802
  }
803
  unset( $f, $val );
828
  foreach ( $atts['email_to'] as $key => $email_field ) {
829
 
830
  if ( is_numeric( $email_field ) ) {
831
+ $atts['email_to'][ $key ] = '[' . $email_field . ']';
832
  }
833
 
834
  if ( strpos( $email_field, '|') ) {
835
  $email_opt = explode( '|', $email_field );
836
  if ( isset( $email_opt[0] ) ) {
837
+ $atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
838
  }
839
  unset( $email_opt );
840
  }
855
  // Add more fields to the new notification
856
  $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
857
  foreach ( $add_fields as $add_field ) {
858
+ if ( isset ( $notification[ $add_field ] ) ) {
859
+ $new_notification['post_content'][ $add_field ] = $notification[ $add_field ];
860
  } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
861
+ $new_notification['post_content'][ $add_field ] = 0;
862
  } else {
863
+ $new_notification['post_content'][ $add_field ] = '';
864
  }
865
  unset( $add_field );
866
  }
869
  $new_notification['post_content']['reply_to'] = $atts['reply_to'];
870
 
871
  // Set from
872
+ if ( ! empty( $atts['reply_to'] ) || ! empty( $atts['reply_to_name'] ) ) {
873
  $new_notification['post_content']['from'] = ( empty($atts['reply_to_name']) ? '[sitename]' : $atts['reply_to_name'] ) .' <'. ( empty($atts['reply_to']) ? '[admin_email]' : $atts['reply_to'] ) .'>';
874
  }
875
  }
884
  if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) {
885
  foreach ( $post_content['conditions'] as $email_key => $val ) {
886
  if ( is_numeric( $email_key ) ) {
887
+ $post_content['conditions'][ $email_key ] = self::switch_action_field_ids( $val, array( 'hide_field' ) );
888
  }
889
  unset( $email_key, $val);
890
  }
classes/models/FrmDb.php CHANGED
@@ -400,12 +400,15 @@ class FrmDb {
400
  * @param string $group
401
  */
402
  private static function get_group_and_table_name( &$table, &$group ) {
403
- global $wpdb;
404
 
405
  $table_parts = explode(' ', $table);
406
  $group = reset($table_parts);
407
  $group = str_replace( $wpdb->prefix, '', $group );
408
 
 
 
 
409
  if ( $group == $table ) {
410
  $table = $wpdb->prefix . $table;
411
  }
@@ -430,22 +433,22 @@ class FrmDb {
430
  $temp_args = $args;
431
  foreach ( $temp_args as $k => $v ) {
432
  if ( $v == '' ) {
433
- unset($args[$k]);
434
  continue;
435
  }
436
 
437
  if ( $k == 'limit' ) {
438
- $args[$k] = FrmAppHelper::esc_limit( $v );
439
  }
440
  $db_name = strtoupper( str_replace( '_', ' ', $k ) );
441
  if ( strpos( $v, $db_name ) === false ) {
442
- $args[$k] = $db_name .' '. $v;
443
  }
444
  }
445
  }
446
 
447
  public function uninstall() {
448
- if ( !current_user_can('administrator') ) {
449
  $frm_settings = FrmAppHelper::get_settings();
450
  wp_die($frm_settings->admin_permission);
451
  }
@@ -473,8 +476,13 @@ class FrmDb {
473
  unset($roles, $frm_roles);
474
 
475
  // delete actions, views, and styles
 
 
 
 
 
476
  $post_ids = $wpdb->get_col( $wpdb->prepare( 'SELECT ID FROM ' . $wpdb->posts .' WHERE post_type in (%s, %s, %s)', FrmFormActionsController::$action_post_type, FrmStylesController::$post_type, 'frm_display' ) );
477
- foreach( $post_ids as $post_id ) {
478
  // Delete's each post.
479
  wp_delete_post( $post_id, true );
480
  }
@@ -485,8 +493,7 @@ class FrmDb {
485
  delete_transient( 'frm_options' );
486
  delete_transient( 'frmpro_options' );
487
 
488
- $query = 'DELETE FROM '. $wpdb->options .' WHERE option_name LIKE "_transient_timeout_frm_form_fields_%" OR option_name LIKE "_transient_frm_form_fields_%"';
489
- $wpdb->query( $query );
490
 
491
  do_action('frm_after_uninstall');
492
  return true;
@@ -572,7 +579,7 @@ class FrmDb {
572
  }
573
  $size = round( $pixel_conversion * (int) $widget['size'] );
574
  $size .= 'px';
575
- $widgets[$k]['size'] = $size;
576
  }
577
  update_option('widget_frm_show_form', $widgets);
578
  }
400
  * @param string $group
401
  */
402
  private static function get_group_and_table_name( &$table, &$group ) {
403
+ global $wpdb, $wpmuBaseTablePrefix;
404
 
405
  $table_parts = explode(' ', $table);
406
  $group = reset($table_parts);
407
  $group = str_replace( $wpdb->prefix, '', $group );
408
 
409
+ $prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix : $wpdb->base_prefix;
410
+ $group = str_replace( $prefix, '', $group );
411
+
412
  if ( $group == $table ) {
413
  $table = $wpdb->prefix . $table;
414
  }
433
  $temp_args = $args;
434
  foreach ( $temp_args as $k => $v ) {
435
  if ( $v == '' ) {
436
+ unset( $args[ $k ] );
437
  continue;
438
  }
439
 
440
  if ( $k == 'limit' ) {
441
+ $args[ $k ] = FrmAppHelper::esc_limit( $v );
442
  }
443
  $db_name = strtoupper( str_replace( '_', ' ', $k ) );
444
  if ( strpos( $v, $db_name ) === false ) {
445
+ $args[ $k ] = $db_name . ' ' . $v;
446
  }
447
  }
448
  }
449
 
450
  public function uninstall() {
451
+ if ( ! current_user_can( 'administrator' ) ) {
452
  $frm_settings = FrmAppHelper::get_settings();
453
  wp_die($frm_settings->admin_permission);
454
  }
476
  unset($roles, $frm_roles);
477
 
478
  // delete actions, views, and styles
479
+
480
+ // prevent the post deletion from triggering entries to be deleted
481
+ remove_action( 'before_delete_post', 'FrmProDisplaysController::before_delete_post' );
482
+ remove_action( 'deleted_post', 'FrmProEntriesController::delete_entry' );
483
+
484
  $post_ids = $wpdb->get_col( $wpdb->prepare( 'SELECT ID FROM ' . $wpdb->posts .' WHERE post_type in (%s, %s, %s)', FrmFormActionsController::$action_post_type, FrmStylesController::$post_type, 'frm_display' ) );
485
+ foreach ( $post_ids as $post_id ) {
486
  // Delete's each post.
487
  wp_delete_post( $post_id, true );
488
  }
493
  delete_transient( 'frm_options' );
494
  delete_transient( 'frmpro_options' );
495
 
496
+ $wpdb->query( $wpdb->prepare( 'DELETE FROM '. $wpdb->options .' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) );
 
497
 
498
  do_action('frm_after_uninstall');
499
  return true;
579
  }
580
  $size = round( $pixel_conversion * (int) $widget['size'] );
581
  $size .= 'px';
582
+ $widgets[ $k ]['size'] = $size;
583
  }
584
  update_option('widget_frm_show_form', $widgets);
585
  }
classes/models/FrmEntry.php CHANGED
@@ -18,7 +18,7 @@ class FrmEntry {
18
 
19
  $new_values = array(
20
  'item_key' => FrmAppHelper::get_unique_key($values['item_key'], $wpdb->prefix .'frm_items', 'item_key'),
21
- 'name' => isset($values['name']) ? $values['name'] : $values['item_key'],
22
  'ip' => FrmAppHelper::get_ip_address(),
23
  'is_draft' => ( ( isset($values['frm_saving_draft']) && $values['frm_saving_draft'] == 1 ) || ( isset($values['is_draft']) && $values['is_draft'] == 1) ) ? 1 : 0,
24
  'form_id' => isset($values['form_id']) ? (int) $values['form_id']: null,
@@ -78,6 +78,8 @@ class FrmEntry {
78
  FrmEntryMeta::update_entry_metas($entry_id, $values['item_meta']);
79
  }
80
 
 
 
81
  // this is a child entry
82
  $is_child = isset( $values['parent_form_id'] ) && isset( $values['parent_nonce'] ) && ! empty( $values['parent_form_id'] ) && wp_verify_nonce( $values['parent_nonce'], 'parent' );
83
 
@@ -122,7 +124,7 @@ class FrmEntry {
122
  $metas = FrmEntryMeta::get_entry_meta_info($entry_exist);
123
  $field_metas = array();
124
  foreach ( $metas as $meta ) {
125
- $field_metas[$meta->field_id] = $meta->meta_value;
126
  }
127
 
128
  // If prev entry is empty and current entry is not, they are not duplicates
@@ -174,6 +176,7 @@ class FrmEntry {
174
  $frm_vars['saved_entries'][] = (int) $entry_id;
175
 
176
  FrmEntryMeta::duplicate_entry_metas($id, $entry_id);
 
177
 
178
  do_action('frm_after_duplicate_entry', $entry_id, $new_values['form_id'], array( 'old_id' => $id));
179
  return $entry_id;
@@ -217,8 +220,7 @@ class FrmEntry {
217
  $query_results = $wpdb->update( $wpdb->prefix .'frm_items', $new_values, compact('id') );
218
 
219
  if ( $query_results ) {
220
- wp_cache_delete( $id .'_nometa', 'frm_entry');
221
- wp_cache_delete( $id, 'frm_entry');
222
  }
223
 
224
  if ( ! isset( $frm_vars['saved_entries'] ) ) {
@@ -247,10 +249,11 @@ class FrmEntry {
247
 
248
  do_action('frm_before_destroy_entry', $id, $entry);
249
 
250
- wp_cache_delete( $id .'_nometa', 'frm_entry');
251
- wp_cache_delete( $id, 'frm_entry');
252
  $wpdb->query( $wpdb->prepare('DELETE FROM ' . $wpdb->prefix .'frm_item_metas WHERE item_id=%d', $id) );
253
  $result = $wpdb->query( $wpdb->prepare('DELETE FROM ' . $wpdb->prefix .'frm_items WHERE id=%d', $id) );
 
 
 
254
  return $result;
255
  }
256
 
@@ -259,11 +262,24 @@ class FrmEntry {
259
  $form_id = isset($value) ? $form_id : null;
260
  $result = $wpdb->update( $wpdb->prefix .'frm_items', array( 'form_id' => $form_id), array( 'id' => $id ) );
261
  if ( $result ) {
262
- wp_cache_delete( $id, 'frm_entry');
263
  }
264
  return $result;
265
  }
266
 
 
 
 
 
 
 
 
 
 
 
 
 
 
267
  public static function getOne( $id, $meta = false) {
268
  global $wpdb;
269
 
@@ -303,7 +319,7 @@ class FrmEntry {
303
  $include_key = apply_filters( 'frm_include_meta_keys', false );
304
  foreach ( $metas as $meta_val ) {
305
  if ( $meta_val->item_id == $entry->id ) {
306
- $entry->metas[$meta_val->field_id] = maybe_unserialize($meta_val->meta_value);
307
  if ( $include_key ) {
308
  $entry->metas[ $meta_val->field_key ] = $entry->metas[ $meta_val->field_id ];
309
  }
@@ -311,11 +327,11 @@ class FrmEntry {
311
  }
312
 
313
  // include sub entries in an array
314
- if ( ! isset( $entry_metas[$meta_val->field_id]) ) {
315
- $entry->metas[$meta_val->field_id] = array();
316
  }
317
 
318
- $entry->metas[$meta_val->field_id][] = maybe_unserialize($meta_val->meta_value);
319
 
320
  unset($meta_val);
321
  }
@@ -411,10 +427,10 @@ class FrmEntry {
411
  }
412
 
413
  if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) {
414
- $entries[$meta_val->item_id]->metas = array();
415
  }
416
 
417
- $entries[$meta_val->item_id]->metas[$meta_val->field_id] = maybe_unserialize($meta_val->meta_value);
418
 
419
  unset($m_key, $meta_val);
420
  }
@@ -468,7 +484,7 @@ class FrmEntry {
468
  return $errors;
469
  }
470
 
471
- if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values['frm_submit_entry_'. $values['form_id'] ] ) || ! wp_verify_nonce($values['frm_submit_entry_'. $values['form_id']], 'frm_submit_entry_nonce') ) ) {
472
  $errors['form'] = __( 'You do not have permission to do that', 'formidable' );
473
  }
474
 
@@ -536,7 +552,7 @@ class FrmEntry {
536
  $args = wp_parse_args( $args, $defaults );
537
 
538
  if ( empty($args['parent_field_id']) ) {
539
- $value = isset($values['item_meta'][$args['id']]) ? $values['item_meta'][$args['id']] : '';
540
  } else {
541
  // value is from a nested form
542
  $value = $values;
@@ -557,7 +573,7 @@ class FrmEntry {
557
 
558
  if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) {
559
  $frm_settings = FrmAppHelper::get_settings();
560
- $errors['field'. $args['id']] = ( ! isset( $posted_field->field_options['blank'] ) || $posted_field->field_options['blank'] == '') ? $frm_settings->blank_msg : $posted_field->field_options['blank'];
561
  } else if ( $posted_field->type == 'text' && ! isset( $_POST['name'] ) ) {
562
  $_POST['name'] = $value;
563
  }
@@ -586,7 +602,7 @@ class FrmEntry {
586
 
587
  //validate the url format
588
  if ( ! preg_match('/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value) ) {
589
- $errors['field'. $args['id']] = FrmFieldsHelper::get_error_msg($field, 'invalid');
590
  }
591
  }
592
 
@@ -597,7 +613,7 @@ class FrmEntry {
597
 
598
  //validate the email format
599
  if ( ! is_email($value) ) {
600
- $errors['field'. $args['id']] = FrmFieldsHelper::get_error_msg($field, 'invalid');
601
  }
602
  }
603
 
@@ -616,7 +632,7 @@ class FrmEntry {
616
  // If captcha is missing, check if it was already verified
617
  if ( ! isset( $_POST['recaptcha_checked'] ) || ! wp_verify_nonce( $_POST['recaptcha_checked'], 'frm_ajax' ) ) {
618
  // There was no captcha submitted
619
- $errors['field'. $args['id']] = __( 'The captcha is missing from this form', 'formidable' );
620
  }
621
  return;
622
  }
@@ -633,7 +649,7 @@ class FrmEntry {
633
 
634
  if ( isset( $response['success'] ) && ! $response['success'] ) {
635
  // What happens when the CAPTCHA was entered incorrectly
636
- $errors['field'. $args['id']] = ( ! isset($field->field_options['invalid']) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid'];
637
  }
638
  }
639
 
@@ -739,8 +755,8 @@ class FrmEntry {
739
  private static function parse_akismet_array( &$datas, $content ) {
740
  $datas['blog'] = FrmAppHelper::site_url();
741
  $datas['user_ip'] = preg_replace( '/[^0-9., ]/', '', FrmAppHelper::get_ip_address() );
742
- $datas['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
743
- $datas['referrer'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : false;
744
  $datas['comment_type'] = 'formidable';
745
  $datas['comment_content'] = $content;
746
 
@@ -750,9 +766,9 @@ class FrmEntry {
750
 
751
  foreach ( $_SERVER as $key => $value ) {
752
  if ( ! in_array($key, array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW')) && is_string($value) ) {
753
- $datas[$key] = $value;
754
  } else {
755
- $datas[$key] = '';
756
  }
757
 
758
  unset($key, $value);
18
 
19
  $new_values = array(
20
  'item_key' => FrmAppHelper::get_unique_key($values['item_key'], $wpdb->prefix .'frm_items', 'item_key'),
21
+ 'name' => FrmAppHelper::truncate( ( isset( $values['name'] ) ? $values['name'] : $values['item_key'] ), 255, 1, '' ),
22
  'ip' => FrmAppHelper::get_ip_address(),
23
  'is_draft' => ( ( isset($values['frm_saving_draft']) && $values['frm_saving_draft'] == 1 ) || ( isset($values['is_draft']) && $values['is_draft'] == 1) ) ? 1 : 0,
24
  'form_id' => isset($values['form_id']) ? (int) $values['form_id']: null,
78
  FrmEntryMeta::update_entry_metas($entry_id, $values['item_meta']);
79
  }
80
 
81
+ self::clear_cache();
82
+
83
  // this is a child entry
84
  $is_child = isset( $values['parent_form_id'] ) && isset( $values['parent_nonce'] ) && ! empty( $values['parent_form_id'] ) && wp_verify_nonce( $values['parent_nonce'], 'parent' );
85
 
124
  $metas = FrmEntryMeta::get_entry_meta_info($entry_exist);
125
  $field_metas = array();
126
  foreach ( $metas as $meta ) {
127
+ $field_metas[ $meta->field_id ] = $meta->meta_value;
128
  }
129
 
130
  // If prev entry is empty and current entry is not, they are not duplicates
176
  $frm_vars['saved_entries'][] = (int) $entry_id;
177
 
178
  FrmEntryMeta::duplicate_entry_metas($id, $entry_id);
179
+ self::clear_cache();
180
 
181
  do_action('frm_after_duplicate_entry', $entry_id, $new_values['form_id'], array( 'old_id' => $id));
182
  return $entry_id;
220
  $query_results = $wpdb->update( $wpdb->prefix .'frm_items', $new_values, compact('id') );
221
 
222
  if ( $query_results ) {
223
+ self::clear_cache();
 
224
  }
225
 
226
  if ( ! isset( $frm_vars['saved_entries'] ) ) {
249
 
250
  do_action('frm_before_destroy_entry', $id, $entry);
251
 
 
 
252
  $wpdb->query( $wpdb->prepare('DELETE FROM ' . $wpdb->prefix .'frm_item_metas WHERE item_id=%d', $id) );
253
  $result = $wpdb->query( $wpdb->prepare('DELETE FROM ' . $wpdb->prefix .'frm_items WHERE id=%d', $id) );
254
+
255
+ self::clear_cache();
256
+
257
  return $result;
258
  }
259
 
262
  $form_id = isset($value) ? $form_id : null;
263
  $result = $wpdb->update( $wpdb->prefix .'frm_items', array( 'form_id' => $form_id), array( 'id' => $id ) );
264
  if ( $result ) {
265
+ self::clear_cache();
266
  }
267
  return $result;
268
  }
269
 
270
+ /**
271
+ * Clear entry caching
272
+ * Called when an entry is changed
273
+ *
274
+ * @since 2.0.5
275
+ */
276
+ public static function clear_cache() {
277
+ FrmAppHelper::cache_delete_group( 'frm_entry' );
278
+ FrmAppHelper::cache_delete_group( 'frm_item' );
279
+ FrmAppHelper::cache_delete_group( 'frm_entry_meta' );
280
+ FrmAppHelper::cache_delete_group( 'frm_item_meta' );
281
+ }
282
+
283
  public static function getOne( $id, $meta = false) {
284
  global $wpdb;
285
 
319
  $include_key = apply_filters( 'frm_include_meta_keys', false );
320
  foreach ( $metas as $meta_val ) {
321
  if ( $meta_val->item_id == $entry->id ) {
322
+ $entry->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value );
323
  if ( $include_key ) {
324
  $entry->metas[ $meta_val->field_key ] = $entry->metas[ $meta_val->field_id ];
325
  }
327
  }
328
 
329
  // include sub entries in an array
330
+ if ( ! isset( $entry_metas[ $meta_val->field_id ] ) ) {
331
+ $entry->metas[ $meta_val->field_id ] = array();
332
  }
333
 
334
+ $entry->metas[ $meta_val->field_id ][] = maybe_unserialize( $meta_val->meta_value );
335
 
336
  unset($meta_val);
337
  }
427
  }
428
 
429
  if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) {
430
+ $entries[ $meta_val->item_id ]->metas = array();
431
  }
432
 
433
+ $entries[ $meta_val->item_id ]->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value );
434
 
435
  unset($m_key, $meta_val);
436
  }
484
  return $errors;
485
  }
486
 
487
+ if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) {
488
  $errors['form'] = __( 'You do not have permission to do that', 'formidable' );
489
  }
490
 
552
  $args = wp_parse_args( $args, $defaults );
553
 
554
  if ( empty($args['parent_field_id']) ) {
555
+ $value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : '';
556
  } else {
557
  // value is from a nested form
558
  $value = $values;
573
 
574
  if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) {
575
  $frm_settings = FrmAppHelper::get_settings();
576
+ $errors[ 'field' . $args['id'] ] = ( ! isset( $posted_field->field_options['blank'] ) || $posted_field->field_options['blank'] == '' ) ? $frm_settings->blank_msg : $posted_field->field_options['blank'];
577
  } else if ( $posted_field->type == 'text' && ! isset( $_POST['name'] ) ) {
578
  $_POST['name'] = $value;
579
  }
602
 
603
  //validate the url format
604
  if ( ! preg_match('/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value) ) {
605
+ $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
606
  }
607
  }
608
 
613
 
614
  //validate the email format
615
  if ( ! is_email($value) ) {
616
+ $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
617
  }
618
  }
619
 
632
  // If captcha is missing, check if it was already verified
633
  if ( ! isset( $_POST['recaptcha_checked'] ) || ! wp_verify_nonce( $_POST['recaptcha_checked'], 'frm_ajax' ) ) {
634
  // There was no captcha submitted
635
+ $errors[ 'field' . $args['id'] ] = __( 'The captcha is missing from this form', 'formidable' );
636
  }
637
  return;
638
  }
649
 
650
  if ( isset( $response['success'] ) && ! $response['success'] ) {
651
  // What happens when the CAPTCHA was entered incorrectly
652
+ $errors[ 'field' . $args['id'] ] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid'];
653
  }
654
  }
655
 
755
  private static function parse_akismet_array( &$datas, $content ) {
756
  $datas['blog'] = FrmAppHelper::site_url();
757
  $datas['user_ip'] = preg_replace( '/[^0-9., ]/', '', FrmAppHelper::get_ip_address() );
758
+ $datas['user_agent'] = FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' );
759
+ $datas['referrer'] = isset( $_SERVER['HTTP_REFERER'] ) ? FrmAppHelper::get_server_value( 'HTTP_REFERER' ) : false;
760
  $datas['comment_type'] = 'formidable';
761
  $datas['comment_content'] = $content;
762