Formidable Forms – Form Builder for WordPress - Version 2.03

Version Description

  • New: Add a combined list of all entries on the Formidable -> Entries page instead of defaulting to the first form
  • New: Replace submit input with button for new forms. This allows us to show the loading indicator on top of the button instead of outside. This applies to new forms only. Existing forms will need the submit button HTML adjusted to see this new styling. But we decided it was best for reverse compatability if we don't change it automatically
  • New: Add frm_after_title hook for inserting content between the title and form fields
  • Enhancement: Speed up adding and editing field options and conditional logic in the form builder
  • Enhancement: Don't save the field options until the whole form is saved
  • Tweak: Pass error array in frm_get_paged_fields instead of true/false. If you are using the frm_get_paged_fields hook, it's possible your code may need to be adjusted.
  • Fix: styling issue when select field moves when changing between a blank and not blank option
  • Fix: Make sure "Activate" button for add-ons is specific to subsite in multisite network
  • Removed: pro fields and styling options from the visual styler, extra pro version css, and registering pro scripts. We don't need unused options.
  • Pro Version *
  • New: Add multi page progress bars and rootline to jump to different pages
  • New: Add a page number parameter to the url when the form page changes
  • New: Auto-save drafts on page turn when drafts are enabled
  • New: Add save button to back-end entries. This allows an entry to be saved from any page when editing.
  • New: Break out repeating sections in the email and frm-single-entry shortcode. Now they repeat instead of separate with commas.
  • New: Add options for email content/single entry shortcode: include_extras="section,page,html", include_fields="10,15", exclude_fields="10,15"
  • New: Change the time field to multiple dropdowns that always save in hh:mm format. This allows for secondary sorting by time fields in views. Using h:i A for the time format in a shortcode will be forced to g:i A.
  • Enhancement: Switch the unique time functionality from front-end disabling to back-end validation
  • Enhancement: Hide form on page load and fade it in to prevent conditional fields flashing
  • Enhancement: Order the post type dropdown by post key instead of defaulting to the order of post type creation
  • Enhancement: Make the custom field options more helpful by including custom fields only for the selected post type
  • Enhancement: Add .frm_loading_form class on the form tag while the form is processing
  • Enhancement: Show the dropzone error message all the time instead of only on hover
  • Tweak: Use css to make the conditional logic field options shorter instead of truncating in the form builder
  • Tweak: Use function to convert field object to array during in_section migration.
  • Tweak: Avoid errors after Lookup field is deleted and other fields watched that Lookup field.
  • Fix: Do not delete values in frm_item_metas table for all fields selected in Create Post action (such as the conditional logic).
  • Fix: Show the correct option label for a blank value. Previously option label for "0" saved value was displaying.
  • Fix: Compact file upload field wasn't aligned with other fields in the row
  • Fix: Evaluate date strings the same way in view filters and inline conditions for date fields
Download this release

Release Info

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

Code changes from version 2.02.13 to 2.03

Files changed (58) hide show
  1. classes/controllers/FrmAddonsController.php +2 -2
  2. classes/controllers/FrmAppController.php +14 -13
  3. classes/controllers/FrmEntriesController.php +86 -98
  4. classes/controllers/FrmFieldsController.php +21 -126
  5. classes/controllers/FrmFormActionsController.php +2 -1
  6. classes/controllers/FrmFormsController.php +6 -9
  7. classes/controllers/FrmHooksController.php +0 -4
  8. classes/controllers/FrmSettingsController.php +2 -1
  9. classes/controllers/FrmStylesController.php +20 -3
  10. classes/helpers/FrmAppHelper.php +21 -22
  11. classes/helpers/FrmEntriesListHelper.php +21 -14
  12. classes/helpers/FrmFieldsHelper.php +7 -6
  13. classes/helpers/FrmFormsHelper.php +24 -20
  14. classes/helpers/FrmFormsListHelper.php +1 -1
  15. classes/helpers/FrmListHelper.php +7 -2
  16. classes/helpers/FrmShortcodeHelper.php +2 -2
  17. classes/helpers/FrmStylesHelper.php +135 -0
  18. classes/helpers/FrmXMLHelper.php +25 -4
  19. classes/models/FrmAntiSpam.php +0 -268
  20. classes/models/FrmDb.php +3 -2
  21. classes/models/FrmEntry.php +5 -3
  22. classes/models/FrmEntryFormat.php +217 -88
  23. classes/models/FrmEntryMeta.php +4 -2
  24. classes/models/FrmEntryValidate.php +6 -4
  25. classes/models/FrmForm.php +53 -18
  26. classes/models/FrmNotification.php +8 -6
  27. classes/models/FrmSettings.php +1 -2
  28. classes/models/FrmStyle.php +14 -1
  29. classes/views/frm-entries/form.php +8 -7
  30. classes/views/frm-entries/show.php +2 -1
  31. classes/views/frm-fields/back-end/dropdown-field.php +2 -1
  32. classes/views/frm-fields/front-end/dropdown-field.php +2 -1
  33. classes/views/frm-fields/single-option.php +5 -1
  34. classes/views/frm-form-actions/_action_inside.php +10 -12
  35. classes/views/frm-forms/add_field.php +1 -1
  36. classes/views/frm-forms/add_field_links.php +2 -1
  37. classes/views/frm-forms/settings.php +2 -1
  38. classes/views/styles/_date-fields.php +0 -45
  39. classes/views/styles/_sample_form.php +35 -61
  40. classes/views/styles/_section-fields.php +0 -114
  41. css/_single_theme.css.php +203 -113
  42. css/custom_theme.css.php +74 -670
  43. css/dropzone.css +0 -589
  44. css/frm_admin.css +25 -9
  45. formidable.php +2 -2
  46. js/formidable.js +110 -63
  47. js/formidable.min.js +96 -94
  48. js/formidable_admin.js +200 -51
  49. languages/formidable-az_AZ.mo +0 -0
  50. languages/formidable-az_AZ.po +1173 -1068
  51. languages/formidable-de_DE.mo +0 -0
  52. languages/formidable-de_DE.po +1224 -1117
  53. languages/formidable-es_ES.mo +0 -0
  54. languages/formidable-es_ES.po +1182 -1077
  55. languages/formidable-hu_HU.mo +0 -0
  56. languages/formidable-hu_HU.po +1166 -1061
  57. languages/formidable-it_IT.mo +0 -0
  58. languages/formidable-it_IT.po +305 -174
classes/controllers/FrmAddonsController.php CHANGED
@@ -71,7 +71,7 @@ class FrmAddonsController {
71
  ),
72
  'autoresponder' => array(
73
  'title' => 'Form Action Automation',
74
- 'docs' => 'formidable-autoresponder/',
75
  'excerpt' => 'Schedule email notifications, SMS messages, and API actions.',
76
  ),
77
  'modal' => array(
@@ -140,7 +140,7 @@ class FrmAddonsController {
140
  private static function prepare_addons( &$addons ) {
141
  $activate_url = '';
142
  if ( current_user_can( 'activate_plugins' ) ) {
143
- $activate_url = add_query_arg( array( 'action' => 'activate' ), network_admin_url( 'plugins.php' ) );
144
  }
145
 
146
  $loop_addons = $addons;
71
  ),
72
  'autoresponder' => array(
73
  'title' => 'Form Action Automation',
74
+ 'docs' => 'schedule-autoresponder/',
75
  'excerpt' => 'Schedule email notifications, SMS messages, and API actions.',
76
  ),
77
  'modal' => array(
140
  private static function prepare_addons( &$addons ) {
141
  $activate_url = '';
142
  if ( current_user_can( 'activate_plugins' ) ) {
143
+ $activate_url = add_query_arg( array( 'action' => 'activate' ), admin_url( 'plugins.php' ) );
144
  }
145
 
146
  $loop_addons = $addons;
classes/controllers/FrmAppController.php CHANGED
@@ -163,8 +163,11 @@ class FrmAppController {
163
  */
164
  public static function needs_update() {
165
  $db_version = (int) get_option( 'frm_db_version' );
166
- $pro_db_version = FrmAppHelper::pro_is_installed() ? get_option( 'frmpro_db_version' ) : false;
167
- return ( ( $db_version < FrmAppHelper::$db_version ) || ( FrmAppHelper::pro_is_installed() && (int) $pro_db_version < FrmAppHelper::$pro_db_version ) );
 
 
 
168
  }
169
 
170
  /**
@@ -234,7 +237,6 @@ class FrmAppController {
234
  wp_register_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css', array(), $version );
235
  wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' );
236
  wp_register_style( 'formidable-grids', FrmAppHelper::plugin_url() . '/css/frm_grids.css', array(), $version );
237
- wp_register_style( 'formidable-dropzone', FrmAppHelper::plugin_url() . '/css/dropzone.css', array(), $version );
238
 
239
  // load multselect js
240
  wp_register_script( 'bootstrap-multiselect', FrmAppHelper::plugin_url() . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip' ), '0.9.8', true );
@@ -294,16 +296,15 @@ class FrmAppController {
294
  return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content );
295
  }
296
 
297
- public static function front_head() {
298
- if ( is_multisite() ) {
299
- $old_db_version = get_option( 'frm_db_version' );
300
- $pro_db_version = FrmAppHelper::pro_is_installed() ? get_option( 'frmpro_db_version' ) : false;
301
- if ( ( (int) $old_db_version < (int) FrmAppHelper::$db_version ) ||
302
- ( FrmAppHelper::pro_is_installed() && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) {
303
- self::install( $old_db_version );
304
- }
305
- }
306
- }
307
 
308
  public static function localize_script( $location ) {
309
  _deprecated_function( __FUNCTION__, '2.0.9', 'FrmAppHelper::localize_script' );
163
  */
164
  public static function needs_update() {
165
  $db_version = (int) get_option( 'frm_db_version' );
166
+ $needs_upgrade = ( (int) $db_version < (int) FrmAppHelper::$db_version );
167
+ if ( ! $needs_upgrade ) {
168
+ $needs_upgrade = apply_filters( 'frm_db_needs_upgrade', $needs_upgrade );
169
+ }
170
+ return $needs_upgrade;
171
  }
172
 
173
  /**
237
  wp_register_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css', array(), $version );
238
  wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' );
239
  wp_register_style( 'formidable-grids', FrmAppHelper::plugin_url() . '/css/frm_grids.css', array(), $version );
 
240
 
241
  // load multselect js
242
  wp_register_script( 'bootstrap-multiselect', FrmAppHelper::plugin_url() . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip' ), '0.9.8', true );
296
  return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content );
297
  }
298
 
299
+ /**
300
+ * Deprecated in favor of wpmu_upgrade_site
301
+ */
302
+ public static function front_head() {
303
+ _deprecated_function( __FUNCTION__, '2.3' );
304
+ if ( is_multisite() && self::needs_update() ) {
305
+ self::install();
306
+ }
307
+ }
 
308
 
309
  public static function localize_script( $location ) {
310
  _deprecated_function( __FUNCTION__, '2.0.9', 'FrmAppHelper::localize_script' );
classes/controllers/FrmEntriesController.php CHANGED
@@ -65,49 +65,19 @@ class FrmEntriesController {
65
  }
66
 
67
  public static function manage_columns( $columns ) {
68
- global $frm_vars, $wpdb;
69
  $form_id = FrmForm::get_current_form_id();
70
 
71
  $columns[ $form_id . '_id' ] = 'ID';
72
  $columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' );
73
 
74
- if ( ! $form_id ) {
75
- return $columns;
76
- }
77
-
78
- $form_cols = FrmField::get_all_for_form($form_id, '', 'include');
79
-
80
- foreach ( $form_cols as $form_col ) {
81
- if ( FrmField::is_no_save_field( $form_col->type ) ) {
82
- continue;
83
- }
84
-
85
- if ( $form_col->type == 'form' && isset( $form_col->field_options['form_select'] ) && ! empty( $form_col->field_options['form_select'] ) ) {
86
- $sub_form_cols = FrmField::get_all_for_form( $form_col->field_options['form_select'] );
87
-
88
- if ( $sub_form_cols ) {
89
- foreach ( $sub_form_cols as $k => $sub_form_col ) {
90
- if ( FrmField::is_no_save_field( $sub_form_col->type ) ) {
91
- unset( $sub_form_cols[ $k ] );
92
- continue;
93
- }
94
- $columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
95
- unset($sub_form_col);
96
- }
97
- }
98
- unset($sub_form_cols);
99
- } else {
100
- $col_id = $form_col->field_key;
101
- if ( $form_col->form_id != $form_id ) {
102
- $col_id .= '-_-form' . $form_col->form_id;
103
- }
104
-
105
- if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) {
106
- $columns[ $form_id . '_frmsep_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
107
- }
108
- $columns[ $form_id . '_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
109
- }
110
- }
111
 
112
  $columns[ $form_id . '_created_at' ] = __( 'Entry creation date', 'formidable' );
113
  $columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' );
@@ -123,6 +93,42 @@ class FrmEntriesController {
123
  return $columns;
124
  }
125
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  public static function check_hidden_cols( $check, $object_id, $meta_key, $meta_value, $prev_value ) {
127
  $menu_name = FrmAppHelper::get_menu_name();
128
  $this_page_name = 'manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden';
@@ -157,7 +163,7 @@ class FrmEntriesController {
157
 
158
  foreach ( $meta_value as $mk => $mv ) {
159
  //remove blank values
160
- if ( empty( $mv ) ) {
161
  unset( $meta_value[ $mk ] );
162
  }
163
  }
@@ -256,14 +262,17 @@ class FrmEntriesController {
256
  $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
257
  }
258
 
259
- if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) {
 
260
  $result = $frm_vars['current_form']->options['hidden_cols'];
261
  } else {
262
  $cols = $frm_vars['cols'];
263
  $cols = array_reverse($cols, true);
264
 
265
- $result[] = $form_id . '_id';
266
- $i--;
 
 
267
 
268
  $result[] = $form_id . '_item_key';
269
  $i--;
@@ -284,19 +293,14 @@ class FrmEntriesController {
284
  public static function display_list( $message = '', $errors = array() ) {
285
  global $wpdb, $frm_vars;
286
 
287
- $form = FrmForm::get_current_form();
288
  $params = FrmForm::get_admin_params( $form );
289
 
290
  if ( $form ) {
291
  $params['form'] = $form->id;
292
  $frm_vars['current_form'] = $form;
293
 
294
- if ( 'trash' == $form->status ) {
295
- $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
296
- $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? ( $form->options['trash_time'] ) : time() ) );
297
- $errors['trash'] = sprintf( __( 'This form is in the trash and is scheduled to be deleted permanently in %s along with any entries.', 'formidable' ), $time_to_delete );
298
- unset( $time_to_delete, $delete_timestamp );
299
- }
300
  }
301
 
302
  $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' );
@@ -325,6 +329,14 @@ class FrmEntriesController {
325
  require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php' );
326
  }
327
 
 
 
 
 
 
 
 
 
328
  /* Back End CRUD */
329
  public static function show( $id = 0 ) {
330
  FrmAppHelper::permission_check('frm_view_entries');
@@ -497,17 +509,7 @@ class FrmEntriesController {
497
  return FrmEntryFormat::show_entry( $atts );
498
  }
499
 
500
- public static function &filter_email_value( $value, $meta, $entry, $atts = array() ) {
501
- $field = FrmField::getOne($meta->field_id);
502
- if ( ! $field ) {
503
- return $value;
504
- }
505
-
506
- $value = self::filter_display_value($value, $field, $atts);
507
- return $value;
508
- }
509
-
510
- public static function &filter_shortcode_value( $value, $tag, $atts, $field ) {
511
  $plain_text = add_filter('frm_plain_text_email', true);
512
  FrmEntryFormat::textarea_display_value( $field->type, $plain_text, $value );
513
 
@@ -515,44 +517,6 @@ class FrmEntriesController {
515
  return $value;
516
  }
517
 
518
- return self::filter_display_value($value, $field, $atts);
519
- }
520
-
521
- public static function &filter_display_value( $value, $field, $atts = array() ) {
522
- $saved_value = ( isset($atts['saved_value']) && $atts['saved_value'] ) ? true : false;
523
- if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'radio', 'select' ) ) || ! FrmField::is_option_true( $field, 'separate_value' ) || $saved_value ) {
524
- return $value;
525
- }
526
-
527
- $f_values = $f_labels = array();
528
-
529
- foreach ( $field->options as $opt_key => $opt ) {
530
- if ( ! is_array($opt) ) {
531
- continue;
532
- }
533
-
534
- $f_labels[ $opt_key ] = isset( $opt['label'] ) ? $opt['label'] : reset($opt);
535
- $f_values[ $opt_key ] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[ $opt_key ];
536
- if ( $f_labels[ $opt_key ] == $f_values[ $opt_key ] ) {
537
- unset( $f_values[ $opt_key ], $f_labels[ $opt_key ] );
538
- }
539
- unset($opt_key, $opt);
540
- }
541
-
542
- if ( ! empty($f_values) ) {
543
- foreach ( (array) $value as $v_key => $val ) {
544
- if ( in_array($val, $f_values) ) {
545
- $opt = array_search($val, $f_values);
546
- if ( is_array($value) ) {
547
- $value[ $v_key ] = $f_labels[ $opt ];
548
- } else {
549
- $value = $f_labels[ $opt ];
550
- }
551
- }
552
- unset($v_key, $val);
553
- }
554
- }
555
-
556
  return $value;
557
  }
558
 
@@ -571,4 +535,28 @@ class FrmEntriesController {
571
 
572
  include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' );
573
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
574
  }
65
  }
66
 
67
  public static function manage_columns( $columns ) {
68
+ global $frm_vars;
69
  $form_id = FrmForm::get_current_form_id();
70
 
71
  $columns[ $form_id . '_id' ] = 'ID';
72
  $columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' );
73
 
74
+ if ( $form_id ) {
75
+ self::get_columns_for_form( $form_id, $columns );
76
+ } else {
77
+ $columns[ $form_id . '_form_id' ] = __( 'Form', 'formidable' );
78
+ $columns[ $form_id . '_name' ] = __( 'Entry Name', 'formidable' );
79
+ $columns[ $form_id . '_user_id' ] = __( 'Created By', 'formidable' );
80
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
 
82
  $columns[ $form_id . '_created_at' ] = __( 'Entry creation date', 'formidable' );
83
  $columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' );
93
  return $columns;
94
  }
95
 
96
+ private static function get_columns_for_form( $form_id, &$columns ) {
97
+ $form_cols = FrmField::get_all_for_form( $form_id, '', 'include' );
98
+
99
+ foreach ( $form_cols as $form_col ) {
100
+ if ( FrmField::is_no_save_field( $form_col->type ) ) {
101
+ continue;
102
+ }
103
+
104
+ if ( $form_col->type == 'form' && isset( $form_col->field_options['form_select'] ) && ! empty( $form_col->field_options['form_select'] ) ) {
105
+ $sub_form_cols = FrmField::get_all_for_form( $form_col->field_options['form_select'] );
106
+
107
+ if ( $sub_form_cols ) {
108
+ foreach ( $sub_form_cols as $k => $sub_form_col ) {
109
+ if ( FrmField::is_no_save_field( $sub_form_col->type ) ) {
110
+ unset( $sub_form_cols[ $k ] );
111
+ continue;
112
+ }
113
+ $columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
114
+ unset($sub_form_col);
115
+ }
116
+ }
117
+ unset($sub_form_cols);
118
+ } else {
119
+ $col_id = $form_col->field_key;
120
+ if ( $form_col->form_id != $form_id ) {
121
+ $col_id .= '-_-form' . $form_col->form_id;
122
+ }
123
+
124
+ if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) {
125
+ $columns[ $form_id . '_frmsep_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
126
+ }
127
+ $columns[ $form_id . '_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
128
+ }
129
+ }
130
+ }
131
+
132
  public static function check_hidden_cols( $check, $object_id, $meta_key, $meta_value, $prev_value ) {
133
  $menu_name = FrmAppHelper::get_menu_name();
134
  $this_page_name = 'manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden';
163
 
164
  foreach ( $meta_value as $mk => $mv ) {
165
  //remove blank values
166
+ if ( empty( $mv ) ) {
167
  unset( $meta_value[ $mk ] );
168
  }
169
  }
262
  $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
263
  }
264
 
265
+ $has_custom_hidden_columns = ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] && isset( $frm_vars['current_form']->options['hidden_cols'] ) && ! empty( $frm_vars['current_form']->options['hidden_cols'] ) );
266
+ if ( $has_custom_hidden_columns ) {
267
  $result = $frm_vars['current_form']->options['hidden_cols'];
268
  } else {
269
  $cols = $frm_vars['cols'];
270
  $cols = array_reverse($cols, true);
271
 
272
+ if ( $form_id ) {
273
+ $result[] = $form_id . '_id';
274
+ $i--;
275
+ }
276
 
277
  $result[] = $form_id . '_item_key';
278
  $i--;
293
  public static function display_list( $message = '', $errors = array() ) {
294
  global $wpdb, $frm_vars;
295
 
296
+ $form = FrmForm::maybe_get_current_form();
297
  $params = FrmForm::get_admin_params( $form );
298
 
299
  if ( $form ) {
300
  $params['form'] = $form->id;
301
  $frm_vars['current_form'] = $form;
302
 
303
+ self::get_delete_form_time( $form, $errors );
 
 
 
 
 
304
  }
305
 
306
  $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' );
329
  require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php' );
330
  }
331
 
332
+ private static function get_delete_form_time( $form, &$errors ) {
333
+ if ( 'trash' == $form->status ) {
334
+ $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
335
+ $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? ( $form->options['trash_time'] ) : time() ) );
336
+ $errors['trash'] = sprintf( __( 'This form is in the trash and is scheduled to be deleted permanently in %s along with any entries.', 'formidable' ), $time_to_delete );
337
+ }
338
+ }
339
+
340
  /* Back End CRUD */
341
  public static function show( $id = 0 ) {
342
  FrmAppHelper::permission_check('frm_view_entries');
509
  return FrmEntryFormat::show_entry( $atts );
510
  }
511
 
512
+ public static function filter_shortcode_value( $value, $tag, $atts, $field ) {
 
 
 
 
 
 
 
 
 
 
513
  $plain_text = add_filter('frm_plain_text_email', true);
514
  FrmEntryFormat::textarea_display_value( $field->type, $plain_text, $value );
515
 
517
  return $value;
518
  }
519
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
520
  return $value;
521
  }
522
 
535
 
536
  include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' );
537
  }
538
+
539
+ /***********************************************************************
540
+ * Deprecated Functions
541
+ ************************************************************************/
542
+
543
+ /**
544
+ * @deprecated 2.02.14
545
+ *
546
+ * @return mixed
547
+ */
548
+ public static function filter_email_value( $value ) {
549
+ _deprecated_function( __FUNCTION__, '2.02.14', 'FrmProEntriesController::filter_value_in_single_entry_table' );
550
+ return $value;
551
+ }
552
+
553
+ /**
554
+ * @deprecated 2.02.14
555
+ *
556
+ * @return mixed
557
+ */
558
+ public static function filter_display_value( $value ) {
559
+ _deprecated_function( __FUNCTION__, '2.02.14', 'FrmProEntriesController::filter_display_value' );
560
+ return $value;
561
+ }
562
  }
classes/controllers/FrmFieldsController.php CHANGED
@@ -172,9 +172,10 @@ class FrmFieldsController {
172
 
173
  $values = apply_filters( 'frm_prepare_single_field_for_duplication', $values );
174
 
175
- if ( ! $field_id = FrmField::create($values) ) {
176
- wp_die();
177
- }
 
178
 
179
  self::include_single_field($field_id, $values);
180
 
@@ -216,57 +217,30 @@ class FrmFieldsController {
216
 
217
  $id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
218
  $opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' );
 
219
 
220
- //Get the field
221
  $field = FrmField::getOne($id);
222
 
223
- if ( ! empty( $field->options ) ) {
224
- $keys = array_keys( $field->options );
225
- $last = str_replace( 'other_', '', end( $keys ) );
226
- } else {
227
- $last = 0;
228
- }
229
- $opt_key = $last + 1;
230
-
231
  if ( 'other' == $opt_type ) {
232
- $opt = esc_html__( 'Other', 'formidable' );
233
  $other_val = '';
234
  $opt_key = 'other_' . $opt_key;
235
-
236
- //Update value of "other" in DB
237
- $field_options = maybe_unserialize( $field->field_options );
238
- $field_options['other'] = 1;
239
- FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) );
240
  } else {
241
- $first_opt = reset( $field->options );
242
- $next_opt = count( $field->options );
243
- if ( $first_opt != '' ) {
244
- $next_opt++;
245
- }
246
- $opt = esc_html__( 'Option', 'formidable' ) . ' ' . $next_opt;
247
- unset($next_opt);
248
  }
249
  $field_val = $opt;
250
- $field->options[ $opt_key ] = $opt;
251
-
252
- //Update options in DB
253
- FrmField::update( $id, array( 'options' => $field->options ) );
254
 
255
  $field_data = $field;
256
- $field = array(
257
- 'type' => $field_data->type,
258
- 'id' => $id,
259
- 'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0,
260
- 'form_id' => $field_data->form_id,
261
- 'field_key' => $field_data->field_key,
262
- );
263
 
264
  $field_name = 'item_meta[' . $id . ']';
265
- $html_id = FrmFieldsHelper::get_html_id($field);
266
  $checked = '';
267
 
268
  if ( 'other' == $opt_type ) {
269
- require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' );
270
  } else {
271
  require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' );
272
  }
@@ -274,90 +248,11 @@ class FrmFieldsController {
274
  }
275
 
276
  public static function edit_option() {
277
- FrmAppHelper::permission_check('frm_edit_forms');
278
- check_ajax_referer( 'frm_ajax', 'nonce' );
279
-
280
- $element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
281
- $ids = explode( '-', $element_id );
282
- $id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
283
-
284
- $orig_update_value = $update_value = trim( FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ) );
285
- if ( strpos( $element_id, 'key_' ) ) {
286
- $new_value = $update_value;
287
- } else {
288
- $new_label = $update_value;
289
- }
290
-
291
- $field = FrmField::getOne($id);
292
- $separate_values = FrmField::is_option_true( $field, 'separate_value' );
293
-
294
- $this_opt_id = end($ids);
295
- $this_opt = (array) $field->options[ $this_opt_id ];
296
- $other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false );
297
-
298
- $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt);
299
- $value = isset($this_opt['value']) ? $this_opt['value'] : '';
300
-
301
- if ( ! isset( $new_label ) ) {
302
- $new_label = $label;
303
- }
304
-
305
- if ( isset($new_value) || isset($value) ) {
306
- $update_value = isset($new_value) ? $new_value : $value;
307
- }
308
-
309
- if ( $update_value != $new_label && $other_opt === false && $separate_values ) {
310
- $field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label );
311
- } else {
312
- $field->options[ $this_opt_id ] = $orig_update_value;
313
- }
314
-
315
- FrmField::update( $field->id, array( 'options' => $field->options ) );
316
- echo ( $orig_update_value == '' ) ? esc_html__( '(Blank)', 'formidable' ) : stripslashes( $orig_update_value );
317
- wp_die();
318
  }
319
 
320
  public static function delete_option() {
321
- FrmAppHelper::permission_check('frm_edit_forms');
322
- check_ajax_referer( 'frm_ajax', 'nonce' );
323
-
324
- $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
325
- $field = FrmField::getOne( $field_id );
326
- // Opt key will NOT be numeric for "Other" options
327
- $opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' );
328
-
329
- $options = $field->options;
330
- unset( $options[ $opt_key ] );
331
- $response = array( 'other' => true );
332
-
333
- //If the deleted option is an "other" option
334
- if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) {
335
- //Assume all other options are gone, unless proven otherwise
336
- $other = false;
337
-
338
- //Check if all other options are really gone
339
- foreach ( $options as $o_key => $o_val ) {
340
- //If there is still an other option in the field, set other to true
341
- if ( FrmFieldsHelper::is_other_opt( $o_key ) ) {
342
- $other = true;
343
- break;
344
- }
345
- unset( $o_key, $o_val );
346
- }
347
-
348
- //If all other options are gone
349
- if ( false === $other ) {
350
- $field_options = maybe_unserialize( $field->field_options );
351
- $field_options['other'] = 0;
352
- FrmField::update( $field_id, array( 'field_options' => maybe_serialize( $field_options ) ) );
353
- $response = array( 'other' => false );
354
- }
355
- }
356
- echo json_encode( $response );
357
-
358
- FrmField::update( $field_id, array( 'options' => maybe_serialize( $options ) ) );
359
-
360
- wp_die();
361
  }
362
 
363
  public static function import_choices() {
@@ -377,7 +272,8 @@ class FrmFieldsController {
377
  register_admin_color_schemes();
378
  }
379
 
380
- $hook_suffix = $admin_body_class = '';
 
381
 
382
  if ( get_user_setting( 'mfold' ) == 'f' ) {
383
  $admin_body_class .= ' folded';
@@ -452,15 +348,14 @@ class FrmFieldsController {
452
  }
453
  }
454
 
455
- FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) );
456
-
457
  $field['options'] = $opts;
458
- $field_name = $field['name'];
459
-
460
- // Get html_id which will be used in single-option.php
461
- $html_id = FrmFieldsHelper::get_html_id( $field );
462
 
463
  if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
 
 
 
 
 
464
  require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' );
465
  } else {
466
  FrmFieldsHelper::show_single_option($field);
172
 
173
  $values = apply_filters( 'frm_prepare_single_field_for_duplication', $values );
174
 
175
+ $field_id = FrmField::create( $values );
176
+ if ( ! $field_id ) {
177
+ wp_die();
178
+ }
179
 
180
  self::include_single_field($field_id, $values);
181
 
217
 
218
  $id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
219
  $opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' );
220
+ $opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'absint' );
221
 
 
222
  $field = FrmField::getOne($id);
223
 
 
 
 
 
 
 
 
 
224
  if ( 'other' == $opt_type ) {
225
+ $opt = __( 'Other', 'formidable' );
226
  $other_val = '';
227
  $opt_key = 'other_' . $opt_key;
 
 
 
 
 
228
  } else {
229
+ $opt = __( 'New Option', 'formidable' );
 
 
 
 
 
 
230
  }
231
  $field_val = $opt;
 
 
 
 
232
 
233
  $field_data = $field;
234
+ $field = (array) $field;
235
+ $field['separate_value'] = isset( $field_data->field_options['separate_value'] ) ? $field_data->field_options['separate_value'] : 0;
236
+ unset( $field_data );
 
 
 
 
237
 
238
  $field_name = 'item_meta[' . $id . ']';
239
+ $html_id = FrmFieldsHelper::get_html_id( $field );
240
  $checked = '';
241
 
242
  if ( 'other' == $opt_type ) {
243
+ include( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' );
244
  } else {
245
  require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' );
246
  }
248
  }
249
 
250
  public static function edit_option() {
251
+ _deprecated_function( __FUNCTION__, '2.3' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
252
  }
253
 
254
  public static function delete_option() {
255
+ _deprecated_function( __FUNCTION__, '2.3' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
256
  }
257
 
258
  public static function import_choices() {
272
  register_admin_color_schemes();
273
  }
274
 
275
+ $hook_suffix = '';
276
+ $admin_body_class = '';
277
 
278
  if ( get_user_setting( 'mfold' ) == 'f' ) {
279
  $admin_body_class .= ' folded';
348
  }
349
  }
350
 
 
 
351
  $field['options'] = $opts;
 
 
 
 
352
 
353
  if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
354
+ $field_name = 'item_meta[' . $field['id'] . ']';
355
+
356
+ // Get html_id which will be used in single-option.php
357
+ $html_id = FrmFieldsHelper::get_html_id( $field );
358
+
359
  require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' );
360
  } else {
361
  FrmFieldsHelper::show_single_option($field);
classes/controllers/FrmFormActionsController.php CHANGED
@@ -259,7 +259,8 @@ class FrmFormActionsController {
259
  $link_settings = array( $type => $link_settings );
260
  }
261
 
262
- $stored_actions = $action_priority = array();
 
263
 
264
  if ( in_array( $event, array( 'create', 'update' ) ) && defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
265
  $this_event = 'import';
259
  $link_settings = array( $type => $link_settings );
260
  }
261
 
262
+ $stored_actions = array();
263
+ $action_priority = array();
264
 
265
  if ( in_array( $event, array( 'create', 'update' ) ) && defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
266
  $this_event = 'import';
classes/controllers/FrmFormsController.php CHANGED
@@ -288,8 +288,6 @@ class FrmFormsController {
288
  $wp->register_globals();
289
  }
290
 
291
- self::register_pro_scripts();
292
-
293
  header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
294
 
295
  $key = FrmAppHelper::simple_get( 'form', 'sanitize_title' );
@@ -307,11 +305,9 @@ class FrmFormsController {
307
  }
308
 
309
  public static function register_pro_scripts() {
 
310
  if ( FrmAppHelper::pro_is_installed() ) {
311
- wp_register_script( 'jquery-frm-rating', FrmAppHelper::plugin_url() . '/pro/js/jquery.rating.min.js', array( 'jquery' ), '4.11', true );
312
- wp_register_script( 'jquery-maskedinput', FrmAppHelper::plugin_url() . '/pro/js/jquery.maskedinput.min.js', array( 'jquery' ), '1.4', true );
313
- wp_register_script( 'jquery-chosen', FrmAppHelper::plugin_url() . '/pro/js/chosen.jquery.min.js', array( 'jquery' ), '1.5.1', true );
314
- wp_register_script( 'dropzone', FrmAppHelper::plugin_url() . '/pro/js/dropzone.js', array( 'jquery' ), '4.3.0', true );
315
  }
316
  }
317
 
@@ -1148,14 +1144,15 @@ class FrmFormsController {
1148
 
1149
  $user_ID = get_current_user_id();
1150
  $params = FrmForm::get_params( $form );
1151
- $message = $errors = '';
 
1152
 
1153
  if ( $params['posted_form_id'] == $form->id && $_POST ) {
1154
  $errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array();
1155
  }
1156
 
1157
  $include_form_tag = apply_filters( 'frm_include_form_tag', true, $form );
1158
- $fields = FrmFieldsHelper::get_form_fields( $form->id, ( isset( $errors ) && ! empty( $errors ) ) );
1159
 
1160
  if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) {
1161
  do_action('frm_display_form_action', $params, $fields, $form, $title, $description);
@@ -1179,7 +1176,7 @@ class FrmFormsController {
1179
 
1180
  $values = FrmEntriesHelper::setup_new_vars($fields, $form, true);
1181
  $created = self::just_created_entry( $form->id );
1182
- $conf_method = apply_filters('frm_success_filter', 'message', $form, $form->options, 'create');
1183
 
1184
  if ( $created && is_numeric($created) && $conf_method != 'message' ) {
1185
  do_action('frm_success_action', $conf_method, $form, $form->options, $created);
288
  $wp->register_globals();
289
  }
290
 
 
 
291
  header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
292
 
293
  $key = FrmAppHelper::simple_get( 'form', 'sanitize_title' );
305
  }
306
 
307
  public static function register_pro_scripts() {
308
+ _deprecated_function( __FUNCTION__, '2.03', 'FrmProEntriesController::register_scripts' );
309
  if ( FrmAppHelper::pro_is_installed() ) {
310
+ FrmProEntriesController::register_scripts();
 
 
 
311
  }
312
  }
313
 
1144
 
1145
  $user_ID = get_current_user_id();
1146
  $params = FrmForm::get_params( $form );
1147
+ $message = '';
1148
+ $errors = array();
1149
 
1150
  if ( $params['posted_form_id'] == $form->id && $_POST ) {
1151
  $errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array();
1152
  }
1153
 
1154
  $include_form_tag = apply_filters( 'frm_include_form_tag', true, $form );
1155
+ $fields = FrmFieldsHelper::get_form_fields( $form->id, $errors );
1156
 
1157
  if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) {
1158
  do_action('frm_display_form_action', $params, $fields, $form, $title, $description);
1176
 
1177
  $values = FrmEntriesHelper::setup_new_vars($fields, $form, true);
1178
  $created = self::just_created_entry( $form->id );
1179
+ $conf_method = apply_filters('frm_success_filter', 'message', $form, 'create');
1180
 
1181
  if ( $created && is_numeric($created) && $conf_method != 'message' ) {
1182
  do_action('frm_success_action', $conf_method, $form, $form->options, $created);
classes/controllers/FrmHooksController.php CHANGED
@@ -55,7 +55,6 @@ class FrmHooksController {
55
  add_action( 'wp_loaded', 'FrmEntriesController::process_entry', 10, 0 );
56
  add_filter( 'frm_redirect_url', 'FrmEntriesController::delete_entry_before_redirect', 50, 3 );
57
  add_action( 'frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100 );
58
- add_filter( 'frm_email_value', 'FrmEntriesController::filter_email_value', 10, 3 );
59
  add_filter( 'frmpro_fields_replace_shortcodes', 'FrmEntriesController::filter_shortcode_value', 10, 4 );
60
 
61
  // Form Actions Controller
@@ -152,8 +151,6 @@ class FrmHooksController {
152
  add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' );
153
  add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' );
154
  add_action( 'wp_ajax_frm_add_field_option', 'FrmFieldsController::add_option' );
155
- add_action( 'wp_ajax_frm_field_option_ipe', 'FrmFieldsController::edit_option' );
156
- add_action( 'wp_ajax_frm_delete_field_option', 'FrmFieldsController::delete_option' );
157
  add_action( 'wp_ajax_frm_import_choices', 'FrmFieldsController::import_choices' );
158
  add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' );
159
  add_action( 'wp_ajax_frm_update_field_order', 'FrmFieldsController::update_order' );
@@ -205,7 +202,6 @@ class FrmHooksController {
205
  }
206
 
207
  public static function load_multisite_hooks() {
208
- add_action( 'init', 'FrmAppController::front_head' );
209
  add_action( 'wpmu_upgrade_site', 'FrmAppController::network_upgrade_site' );
210
 
211
  // drop tables when mu site is deleted
55
  add_action( 'wp_loaded', 'FrmEntriesController::process_entry', 10, 0 );
56
  add_filter( 'frm_redirect_url', 'FrmEntriesController::delete_entry_before_redirect', 50, 3 );
57
  add_action( 'frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100 );
 
58
  add_filter( 'frmpro_fields_replace_shortcodes', 'FrmEntriesController::filter_shortcode_value', 10, 4 );
59
 
60
  // Form Actions Controller
151
  add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' );
152
  add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' );
153
  add_action( 'wp_ajax_frm_add_field_option', 'FrmFieldsController::add_option' );
 
 
154
  add_action( 'wp_ajax_frm_import_choices', 'FrmFieldsController::import_choices' );
155
  add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' );
156
  add_action( 'wp_ajax_frm_update_field_order', 'FrmFieldsController::update_order' );
202
  }
203
 
204
  public static function load_multisite_hooks() {
 
205
  add_action( 'wpmu_upgrade_site', 'FrmAppController::network_upgrade_site' );
206
 
207
  // drop tables when mu site is deleted
classes/controllers/FrmSettingsController.php CHANGED
@@ -51,7 +51,8 @@ class FrmSettingsController {
51
  $message = '';
52
 
53
  if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) {
54
- //$errors = $frm_settings->validate($_POST,array());
 
55
  $frm_settings->update( stripslashes_deep( $_POST ) );
56
 
57
  if ( empty( $errors ) ) {
51
  $message = '';
52
 
53
  if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) {
54
+ $errors = $frm_settings->validate( $_POST, array() );
55
+
56
  $frm_settings->update( stripslashes_deep( $_POST ) );
57
 
58
  if ( empty( $errors ) ) {
classes/controllers/FrmStylesController.php CHANGED
@@ -334,6 +334,7 @@ class FrmStylesController {
334
 
335
  $frm_style = new FrmStyle();
336
  $defaults = $frm_style->get_defaults();
 
337
 
338
  // remove the # from the colors
339
  foreach ( $_GET['frm_style_setting']['post_content'] as $k => $v ) {
@@ -360,12 +361,16 @@ class FrmStylesController {
360
  'field-colors' => __( 'Field Colors', 'formidable' ),
361
  'field-sizes' => __( 'Field Settings', 'formidable' ),
362
  'check-box-radio-fields' => __( 'Check Box & Radio Fields', 'formidable' ),
363
- 'section-fields' => __( 'Section Fields', 'formidable' ),
364
- 'date-fields' => __( 'Date Fields', 'formidable' ),
365
  'buttons' => __( 'Buttons', 'formidable' ),
366
  'form-messages' => __( 'Form Messages', 'formidable' ),
367
  );
368
 
 
 
 
 
 
 
369
  foreach ( $meta_boxes as $nicename => $name ) {
370
  add_meta_box( $nicename . '-style', $name, 'FrmStylesController::include_style_section', self::$screen, 'side', 'default', $nicename );
371
  unset($nicename, $name);
@@ -375,7 +380,18 @@ class FrmStylesController {
375
  public static function include_style_section( $atts, $sec ) {
376
  extract($atts);
377
  $current_tab = FrmAppHelper::simple_get( 'page-tab', 'sanitize_title', 'default' );
378
- include( FrmAppHelper::plugin_path() . '/classes/views/styles/_' . $sec['args'] . '.php' );
 
 
 
 
 
 
 
 
 
 
 
379
  }
380
 
381
  public static function load_css() {
@@ -383,6 +399,7 @@ class FrmStylesController {
383
 
384
  $frm_style = new FrmStyle();
385
  $defaults = $frm_style->get_defaults();
 
386
 
387
  include( FrmAppHelper::plugin_path() . '/css/_single_theme.css.php' );
388
  wp_die();
334
 
335
  $frm_style = new FrmStyle();
336
  $defaults = $frm_style->get_defaults();
337
+ $style = '';
338
 
339
  // remove the # from the colors
340
  foreach ( $_GET['frm_style_setting']['post_content'] as $k => $v ) {
361
  'field-colors' => __( 'Field Colors', 'formidable' ),
362
  'field-sizes' => __( 'Field Settings', 'formidable' ),
363
  'check-box-radio-fields' => __( 'Check Box & Radio Fields', 'formidable' ),
 
 
364
  'buttons' => __( 'Buttons', 'formidable' ),
365
  'form-messages' => __( 'Form Messages', 'formidable' ),
366
  );
367
 
368
+ /**
369
+ * Add custom boxes to the styling settings
370
+ * @since 2.3
371
+ */
372
+ $meta_boxes = apply_filters( 'frm_style_boxes', $meta_boxes );
373
+
374
  foreach ( $meta_boxes as $nicename => $name ) {
375
  add_meta_box( $nicename . '-style', $name, 'FrmStylesController::include_style_section', self::$screen, 'side', 'default', $nicename );
376
  unset($nicename, $name);
380
  public static function include_style_section( $atts, $sec ) {
381
  extract($atts);
382
  $current_tab = FrmAppHelper::simple_get( 'page-tab', 'sanitize_title', 'default' );
383
+ $file_name = FrmAppHelper::plugin_path() . '/classes/views/styles/_' . $sec['args'] . '.php';
384
+
385
+ /**
386
+ * Set the location of custom styling settings right before
387
+ * loading onto the page. If your style box was named "progress",
388
+ * this hook name will be frm_style_settings_progress.
389
+ *
390
+ * @since 2.3
391
+ */
392
+ $file_name = apply_filters( 'frm_style_settings_' . $sec['args'], $file_name );
393
+
394
+ include( $file_name );
395
  }
396
 
397
  public static function load_css() {
399
 
400
  $frm_style = new FrmStyle();
401
  $defaults = $frm_style->get_defaults();
402
+ $style = '';
403
 
404
  include( FrmAppHelper::plugin_path() . '/css/_single_theme.css.php' );
405
  wp_die();
classes/helpers/FrmAppHelper.php CHANGED
@@ -4,13 +4,13 @@ if ( ! defined('ABSPATH') ) {
4
  }
5
 
6
  class FrmAppHelper {
7
- public static $db_version = 35; //version of the database we are moving to
8
- public static $pro_db_version = 37;
9
 
10
  /**
11
  * @since 2.0
12
  */
13
- public static $plug_version = '2.02.13';
14
 
15
  /**
16
  * @since 1.07.02
@@ -864,7 +864,7 @@ class FrmAppHelper {
864
  * @return string The base Google APIS url for the current version of jQuery UI
865
  */
866
  public static function jquery_ui_base_url() {
867
- $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version('jquery-ui-core');
868
  $url = apply_filters('frm_jquery_ui_base_url', $url);
869
  return $url;
870
  }
@@ -872,25 +872,24 @@ class FrmAppHelper {
872
  /**
873
  * @param string $handle
874
  */
875
- public static function script_version( $handle ) {
876
- global $wp_scripts;
877
- if ( ! $wp_scripts ) {
878
- return false;
879
- }
880
-
881
- $ver = 0;
882
 
883
- if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
884
- return $ver;
885
- }
 
886
 
887
- $query = $wp_scripts->registered[ $handle ];
888
- if ( is_object( $query ) ) {
889
- $ver = $query->ver;
890
- }
891
 
892
- return $ver;
893
- }
894
 
895
  public static function js_redirect( $url ) {
896
  return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>';
@@ -963,7 +962,7 @@ class FrmAppHelper {
963
  $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
964
  $key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column );
965
  $suffix++;
966
- } while ($key_check || is_numeric($key_check));
967
  $key = $alt_post_name;
968
  }
969
  return $key;
@@ -1148,7 +1147,7 @@ class FrmAppHelper {
1148
  * @return boolean|int
1149
  */
1150
  public static function custom_style_value( $post_values ) {
1151
- if ( $post_values && isset( $post_values['options']['custom_style'] ) ) {
1152
  $custom_style = absint( $post_values['options']['custom_style'] );
1153
  } else {
1154
  $frm_settings = FrmAppHelper::get_settings();
4
  }
5
 
6
  class FrmAppHelper {
7
+ public static $db_version = 41; //version of the database we are moving to
8
+ public static $pro_db_version = 37; //deprecated
9
 
10
  /**
11
  * @since 2.0
12
  */
13
+ public static $plug_version = '2.03';
14
 
15
  /**
16
  * @since 1.07.02
864
  * @return string The base Google APIS url for the current version of jQuery UI
865
  */
866
  public static function jquery_ui_base_url() {
867
+ $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' );
868
  $url = apply_filters('frm_jquery_ui_base_url', $url);
869
  return $url;
870
  }
872
  /**
873
  * @param string $handle
874
  */
875
+ public static function script_version( $handle, $default = 0 ) {
876
+ global $wp_scripts;
877
+ if ( ! $wp_scripts ) {
878
+ return $default;
879
+ }
 
 
880
 
881
+ $ver = $default;
882
+ if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
883
+ return $ver;
884
+ }
885
 
886
+ $query = $wp_scripts->registered[ $handle ];
887
+ if ( is_object( $query ) ) {
888
+ $ver = $query->ver;
889
+ }
890
 
891
+ return $ver;
892
+ }
893
 
894
  public static function js_redirect( $url ) {
895
  return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>';
962
  $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
963
  $key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column );
964
  $suffix++;
965
+ } while ( $key_check || is_numeric( $key_check ) );
966
  $key = $alt_post_name;
967
  }
968
  return $key;
1147
  * @return boolean|int
1148
  */
1149
  public static function custom_style_value( $post_values ) {
1150
+ if ( ! empty( $post_values ) && isset( $post_values['options']['custom_style'] ) ) {
1151
  $custom_style = absint( $post_values['options']['custom_style'] );
1152
  } else {
1153
  $frm_settings = FrmAppHelper::get_settings();
classes/helpers/FrmEntriesListHelper.php CHANGED
@@ -6,30 +6,24 @@ class FrmEntriesListHelper extends FrmListHelper {
6
  protected $field;
7
 
8
  public function prepare_items() {
9
- global $wpdb, $per_page;
10
 
11
  $per_page = $this->get_items_per_page( 'formidable_page_formidable_entries_per_page' );
12
-
13
  $form_id = $this->params['form'];
14
- if ( ! $form_id ) {
15
- $this->items = array();
16
- $this->set_pagination_args( array(
17
- 'total_items' => 0,
18
- 'per_page' => $per_page,
19
- ) );
20
- return;
21
- }
22
 
23
  $default_orderby = 'id';
24
  $default_order = 'DESC';
 
25
 
26
- $s_query = array( 'it.form_id' => $form_id );
 
 
27
 
28
  $s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : '';
29
 
30
  if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
31
  $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : '';
32
- $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid);
33
  }
34
 
35
  $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby;
@@ -60,7 +54,9 @@ class FrmEntriesListHelper extends FrmListHelper {
60
  return;
61
  }
62
 
63
- $form_id = $form = $this->params['form'];
 
 
64
  if ( $form_id ) {
65
  $form = FrmForm::getOne($form_id);
66
  }
@@ -73,6 +69,16 @@ class FrmEntriesListHelper extends FrmListHelper {
73
  // Searching is a pro feature
74
  }
75
 
 
 
 
 
 
 
 
 
 
 
76
  /**
77
  * Gets the name of the primary column in the Entries screen
78
  *
@@ -130,7 +136,8 @@ class FrmEntriesListHelper extends FrmListHelper {
130
  unset($class);
131
  $attributes .= ' data-colname="' . $column_display_name . '"';
132
 
133
- $col_name = preg_replace( '/^(' . $this->params['form'] . '_)/', '', $column_name );
 
134
  $this->column_name = $col_name;
135
 
136
  switch ( $col_name ) {
6
  protected $field;
7
 
8
  public function prepare_items() {
9
+ global $per_page;
10
 
11
  $per_page = $this->get_items_per_page( 'formidable_page_formidable_entries_per_page' );
 
12
  $form_id = $this->params['form'];
 
 
 
 
 
 
 
 
13
 
14
  $default_orderby = 'id';
15
  $default_order = 'DESC';
16
+ $s_query = array();
17
 
18
+ if ( $form_id ) {
19
+ $s_query['it.form_id'] = $form_id;
20
+ }
21
 
22
  $s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : '';
23
 
24
  if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
25
  $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : '';
26
+ $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid );
27
  }
28
 
29
  $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby;
54
  return;
55
  }
56
 
57
+ $form_id = $this->params['form'];
58
+ $form = $this->params['form'];
59
+
60
  if ( $form_id ) {
61
  $form = FrmForm::getOne($form_id);
62
  }
69
  // Searching is a pro feature
70
  }
71
 
72
+ protected function extra_tablenav( $which ) {
73
+ $form_id = FrmAppHelper::simple_get( 'form', 'absint' );
74
+ if ( $which == 'top' && empty( $form_id ) ) {
75
+ echo '<div class="alignleft actions">';
76
+ echo FrmFormsHelper::forms_dropdown( 'form', $form_id, array( 'blank' => __( 'View all forms', 'formidable' ) ) );
77
+ submit_button( __( 'Filter' ), 'filter_action', '', false, array( 'id' => "post-query-submit" ) );
78
+ echo '</div>';
79
+ }
80
+ }
81
+
82
  /**
83
  * Gets the name of the primary column in the Entries screen
84
  *
136
  unset($class);
137
  $attributes .= ' data-colname="' . $column_display_name . '"';
138
 
139
+ $form_id = $this->params['form'] ? $this->params['form'] : 0;
140
+ $col_name = preg_replace( '/^(' . $form_id . '_)/', '', $column_name );
141
  $this->column_name = $col_name;
142
 
143
  switch ( $col_name ) {
classes/helpers/FrmFieldsHelper.php CHANGED
@@ -183,11 +183,11 @@ class FrmFieldsHelper {
183
  return $msg;
184
  }
185
 
186
- public static function get_form_fields( $form_id, $error = false ) {
187
- $fields = FrmField::get_all_for_form($form_id);
188
- $fields = apply_filters('frm_get_paged_fields', $fields, $form_id, $error);
189
- return $fields;
190
- }
191
 
192
  public static function get_default_html( $type = 'text' ) {
193
  if ( apply_filters( 'frm_normal_field_type_html', true, $type ) ) {
@@ -1028,7 +1028,8 @@ DEFAULT_HTML;
1028
  * @since 2.0.6
1029
  */
1030
  private static function set_other_value( $args, &$other_args ) {
1031
- $parent = $pointer = '';
 
1032
 
1033
  // Check for parent ID and pointer
1034
  $temp_array = explode( '[', $args['field_name'] );
183
  return $msg;
184
  }
185
 
186
+ public static function get_form_fields( $form_id, $error = array() ) {
187
+ $fields = FrmField::get_all_for_form( $form_id );
188
+ $fields = apply_filters( 'frm_get_paged_fields', $fields, $form_id, $error );
189
+ return $fields;
190
+ }
191
 
192
  public static function get_default_html( $type = 'text' ) {
193
  if ( apply_filters( 'frm_normal_field_type_html', true, $type ) ) {
1028
  * @since 2.0.6
1029
  */
1030
  private static function set_other_value( $args, &$other_args ) {
1031
+ $parent = '';
1032
+ $pointer = '';
1033
 
1034
  // Check for parent ID and pointer
1035
  $temp_array = explode( '[', $args['field_name'] );
classes/helpers/FrmFormsHelper.php CHANGED
@@ -265,14 +265,11 @@ class FrmFormsHelper {
265
  */
266
  public static function get_default_html( $loc ) {
267
  if ( $loc == 'submit' ) {
268
- $sending = __( 'Sending', 'formidable' );
269
  $draft_link = self::get_draft_link();
270
- $img = '[frmurl]/images/ajax_loader.gif';
271
  $default_html = <<<SUBMIT_HTML
272
  <div class="frm_submit">
273
- [if back_button]<input type="button" value="[back_label]" name="frm_prev_page" formnovalidate="formnovalidate" class="frm_prev_page" [back_hook] />[/if back_button]
274
- <input type="submit" value="[button_label]" [button_action] />
275
- <img class="frm_ajax_loading" src="$img" alt="$sending"/>
276
  $draft_link
277
  </div>
278
  SUBMIT_HTML;
@@ -295,23 +292,29 @@ BEFORE_HTML;
295
  }
296
 
297
  public static function get_custom_submit( $html, $form, $submit, $form_action, $values ) {
298
- $button = self::replace_shortcodes($html, $form, $submit, $form_action, $values);
299
- if ( ! strpos($button, '[button_action]') ) {
300
- return;
301
- }
 
302
 
303
- $button_parts = explode('[button_action]', $button);
304
- echo $button_parts[0];
305
- //echo ' id="frm_submit_"';
306
 
307
- $classes = apply_filters('frm_submit_button_class', array(), $form);
308
- if ( ! empty($classes) ) {
309
- echo ' class="' . esc_attr( implode( ' ', $classes ) ) . '"';
310
- }
 
 
 
 
 
 
311
 
312
- do_action('frm_submit_button_action', $form, $form_action);
313
- echo $button_parts[1];
314
- }
 
315
 
316
  /**
317
  * Automatically add end section fields if they don't exist (2.0 migration)
@@ -325,7 +328,8 @@ BEFORE_HTML;
325
  }
326
 
327
  $end_section_values = apply_filters( 'frm_before_field_created', FrmFieldsHelper::setup_new_vars( 'end_divider', $form->id ) );
328
- $open = $prev_order = false;
 
329
  $add_order = 0;
330
  $last_field = false;
331
  foreach ( $fields as $field ) {
265
  */
266
  public static function get_default_html( $loc ) {
267
  if ( $loc == 'submit' ) {
 
268
  $draft_link = self::get_draft_link();
 
269
  $default_html = <<<SUBMIT_HTML
270
  <div class="frm_submit">
271
+ [if back_button]<button type="submit" name="frm_prev_page" formnovalidate="formnovalidate" class="frm_prev_page" [back_hook]>[back_label]</button>[/if back_button]
272
+ <button class="frm_button_submit" type="submit" [button_action]>[button_label]</button>
 
273
  $draft_link
274
  </div>
275
  SUBMIT_HTML;
292
  }
293
 
294
  public static function get_custom_submit( $html, $form, $submit, $form_action, $values ) {
295
+ $button = self::replace_shortcodes( $html, $form, $submit, $form_action, $values );
296
+ if ( ! strpos( $button, '[button_action]' ) ) {
297
+ echo $button;
298
+ return;
299
+ }
300
 
301
+ $button_parts = explode( '[button_action]', $button );
 
 
302
 
303
+ $classes = apply_filters( 'frm_submit_button_class', array(), $form );
304
+ if ( ! empty( $classes ) ) {
305
+ $classes = implode( ' ', $classes );
306
+ $button_class = ' class="frm_button_submit';
307
+ if ( strpos( $button_parts[0], $button_class ) !== false ) {
308
+ $button_parts[0] = str_replace( $button_class, $button_class . ' ' . esc_attr( $classes ), $button_parts[0] );
309
+ } else {
310
+ $button_parts[0] .= ' class="' . esc_attr( $classes ) . '"';
311
+ }
312
+ }
313
 
314
+ echo $button_parts[0];
315
+ do_action( 'frm_submit_button_action', $form, $form_action );
316
+ echo $button_parts[1];
317
+ }
318
 
319
  /**
320
  * Automatically add end section fields if they don't exist (2.0 migration)
328
  }
329
 
330
  $end_section_values = apply_filters( 'frm_before_field_created', FrmFieldsHelper::setup_new_vars( 'end_divider', $form->id ) );
331
+ $open = false;
332
+ $prev_order = false;
333
  $add_order = 0;
334
  $last_field = false;
335
  foreach ( $fields as $field ) {
classes/helpers/FrmFormsListHelper.php CHANGED
@@ -4,7 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) {
4
  }
5
 
6
  class FrmFormsListHelper extends FrmListHelper {
7
- var $status = '';
8
 
9
  public function __construct( $args ) {
10
  $this->status = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
4
  }
5
 
6
  class FrmFormsListHelper extends FrmListHelper {
7
+ public $status = '';
8
 
9
  public function __construct( $args ) {
10
  $this->status = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
classes/helpers/FrmListHelper.php CHANGED
@@ -327,7 +327,9 @@ class FrmListHelper {
327
  */
328
  protected function bulk_actions( $which = '' ) {
329
  if ( is_null( $this->_actions ) ) {
330
- $no_new_actions = $this->_actions = $this->get_bulk_actions();
 
 
331
  /**
332
  * Filter the list table Bulk Actions drop-down.
333
  *
@@ -541,7 +543,10 @@ class FrmListHelper {
541
  $total_pages_before = '<span class="paging-input">';
542
  $total_pages_after = '</span>';
543
 
544
- $disable_first = $disable_last = $disable_prev = $disable_next = false;
 
 
 
545
 
546
  if ( $current == 1 ) {
547
  $disable_first = true;
327
  */
328
  protected function bulk_actions( $which = '' ) {
329
  if ( is_null( $this->_actions ) ) {
330
+ $no_new_actions = $this->get_bulk_actions();
331
+ $this->_actions = $no_new_actions;
332
+
333
  /**
334
  * Filter the list table Bulk Actions drop-down.
335
  *
543
  $total_pages_before = '<span class="paging-input">';
544
  $total_pages_after = '</span>';
545
 
546
+ $disable_first = false;
547
+ $disable_last = false;
548
+ $disable_prev = false;
549
+ $disable_next = false;
550
 
551
  if ( $current == 1 ) {
552
  $disable_first = true;
classes/helpers/FrmShortcodeHelper.php CHANGED
@@ -3,7 +3,7 @@
3
  * @since 2.02.12
4
  */
5
 
6
- class FrmShortcodeHelper{
7
 
8
  /**
9
  * Get the shortcode attributes in key/value pairs from a string
@@ -25,4 +25,4 @@ class FrmShortcodeHelper{
25
 
26
  return $atts;
27
  }
28
- }
3
  * @since 2.02.12
4
  */
5
 
6
+ class FrmShortcodeHelper {
7
 
8
  /**
9
  * Get the shortcode attributes in key/value pairs from a string
25
 
26
  return $atts;
27
  }
28
+ }
classes/helpers/FrmStylesHelper.php CHANGED
@@ -205,4 +205,139 @@ class FrmStylesHelper {
205
  return implode(',', $rgb); // returns the rgb values separated by commas
206
  //return $rgb; // returns an array with the rgb values
207
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
  }
205
  return implode(',', $rgb); // returns the rgb values separated by commas
206
  //return $rgb; // returns an array with the rgb values
207
  }
208
+
209
+ /**
210
+ * @param $hex string - The original color in hex format #ffffff
211
+ * @param $steps integer - should be between -255 and 255. Negative = darker, positive = lighter
212
+ * @since 2.3
213
+ */
214
+ public static function adjust_brightness( $hex, $steps ) {
215
+ $steps = max( -255, min( 255, $steps ) );
216
+
217
+ // Normalize into a six character long hex string
218
+ $hex = str_replace( '#', '', $hex );
219
+ if ( strlen( $hex ) == 3 ) {
220
+ $hex = str_repeat( substr( $hex, 0, 1 ), 2 );
221
+ $hex .= str_repeat( substr( $hex, 1, 1 ), 2 );
222
+ $hex .= str_repeat( substr( $hex, 2, 1 ), 2 );
223
+ }
224
+
225
+ // Split into three parts: R, G and B
226
+ $color_parts = str_split( $hex, 2 );
227
+ $return = '#';
228
+
229
+ foreach ( $color_parts as $color ) {
230
+ $color = hexdec( $color ); // Convert to decimal
231
+ $color = max( 0,min( 255,$color + $steps ) ); // Adjust color
232
+ $return .= str_pad( dechex( $color ), 2, '0', STR_PAD_LEFT ); // Make two char hex code
233
+ }
234
+
235
+ return $return;
236
+ }
237
+
238
+ /**
239
+ * @since 2.3
240
+ */
241
+ public static function get_settings_for_output( $style ) {
242
+ if ( self::previewing_style() ) {
243
+ if ( isset( $_GET['frm_style_setting'] ) ) {
244
+ $settings = $_GET['frm_style_setting']['post_content'];
245
+ } else {
246
+ $settings = $_GET;
247
+ }
248
+ FrmAppHelper::sanitize_value( 'sanitize_text_field', $settings );
249
+
250
+ $style_name = FrmAppHelper::simple_get( 'style_name', 'sanitize_title' );
251
+ $settings['style_class'] = '';
252
+ if ( ! empty( $style_name ) ) {
253
+ $settings['style_class'] = $style_name . '.';
254
+ }
255
+ } else {
256
+ $settings = $style->post_content;
257
+ $settings['style_class'] = 'frm_style_' . $style->post_name . '.';
258
+ }
259
+
260
+ $settings['style_class'] .= 'with_frm_style';
261
+ $settings['font'] = stripslashes( $settings['font'] );
262
+ $settings['change_margin'] = self::description_margin_for_screensize( $settings['width'] );
263
+
264
+ $checkbox_opts = array( 'important_style', 'auto_width', 'submit_style', 'collapse_icon', 'center_form' );
265
+ foreach ( $checkbox_opts as $opt ) {
266
+ if ( ! isset( $settings[ $opt ] ) ) {
267
+ $settings[ $opt ] = 0;
268
+ }
269
+ }
270
+
271
+ self::prepare_color_output( $settings );
272
+
273
+ return $settings;
274
+ }
275
+
276
+ /**
277
+ * @since 2.3
278
+ */
279
+ private static function prepare_color_output( &$settings ) {
280
+ $colors = self::allow_color_override();
281
+ foreach ( $colors as $css => $opts ) {
282
+ foreach ( $opts as $opt ) {
283
+ self::get_color_output( $css, $settings[ $opt ] );
284
+ }
285
+ }
286
+ }
287
+
288
+ /**
289
+ * @since 2.3
290
+ */
291
+ private static function allow_color_override() {
292
+ return array(
293
+ 'transparent' => array(
294
+ 'fieldset_color', 'fieldset_bg_color', 'bg_color',
295
+ 'bg_color_disabled', 'bg_color_active', 'bg_color_error',
296
+ 'section_bg_color', 'error_bg', 'success_bg_color',
297
+ 'progress_bg_color', 'progress_active_bg_color',
298
+ ),
299
+ '' => array(
300
+ 'title_color', 'section_color', 'submit_text_color',
301
+ 'label_color', 'check_label_color', 'form_desc_color',
302
+ 'description_color', 'text_color', 'text_color_disabled',
303
+ 'border_color', 'submit_bg_color', 'submit_border_color',
304
+ 'error_text', 'progress_border_color', 'progress_color',
305
+ 'progress_active_color',
306
+ 'submit_hover_bg_color', 'submit_hover_border_color', 'submit_hover_color',
307
+ 'submit_active_color', 'submit_active_border_color', 'submit_active_bg_color',
308
+ ),
309
+ );
310
+ }
311
+
312
+ /**
313
+ * @since 2.3
314
+ */
315
+ private static function get_color_output( $default, &$color ) {
316
+ $color = ( trim( $color ) == '' ) ? $default : '#' . $color;
317
+ }
318
+
319
+ /**
320
+ * If left/right label is over a certain size,
321
+ * adjust the field description margin at a different screen size
322
+ * @since 2.3
323
+ */
324
+ private static function description_margin_for_screensize( $width ) {
325
+ $temp_label_width = str_replace( 'px', '', $width );
326
+ $change_margin = false;
327
+ if ( $temp_label_width >= 230 ) {
328
+ $change_margin = '800px';
329
+ } else if ( $width >= 215 ) {
330
+ $change_margin = '700px';
331
+ } else if ( $width >= 180 ) {
332
+ $change_margin = '650px';
333
+ }
334
+ return $change_margin;
335
+ }
336
+
337
+ /**
338
+ * @since 2.3
339
+ */
340
+ public static function previewing_style() {
341
+ return isset( $_GET['frm_style_setting'] ) || isset( $_GET['flat'] );
342
+ }
343
  }
classes/helpers/FrmXMLHelper.php CHANGED
@@ -133,9 +133,11 @@ class FrmXMLHelper {
133
 
134
  $this_form = self::maybe_get_form( $form );
135
 
136
- $old_id = $form_fields = false;
 
137
  if ( ! empty( $this_form ) ) {
138
- $form_id = $old_id = $this_form->id;
 
139
  self::update_form( $this_form, $form, $imported );
140
 
141
  $form_fields = self::get_form_fields( $form_id );
@@ -159,7 +161,7 @@ class FrmXMLHelper {
159
  $imported['forms'][ (int) $item->id ] = $form_id;
160
 
161
  // Send pre 2.0 form options through function that creates actions
162
- self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, $switch = true );
163
 
164
  do_action( 'frm_after_import_form', $form_id, $form );
165
 
@@ -558,10 +560,12 @@ class FrmXMLHelper {
558
  } else if ( $post['post_type'] == 'frm_styles' ) {
559
  // Properly encode post content before inserting the post
560
  $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
 
561
  $post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] );
562
 
563
  // Create/update post now
564
  $post_id = wp_insert_post( $post );
 
565
  } else {
566
  // Create/update post now
567
  $post_id = wp_insert_post( $post );
@@ -749,6 +753,23 @@ class FrmXMLHelper {
749
  }
750
  }
751
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
752
  private static function maybe_update_stylesheet( $imported ) {
753
  $new_styles = isset( $imported['imported']['styles'] ) && ! empty( $imported['imported']['styles'] );
754
  $updated_styles = isset( $imported['updated']['styles'] ) && ! empty( $imported['updated']['styles'] );
@@ -1020,7 +1041,7 @@ class FrmXMLHelper {
1020
  // Migrate autoresponders
1021
  self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications );
1022
 
1023
- if ( empty( $notifications ) ) {
1024
  return;
1025
  }
1026
 
133
 
134
  $this_form = self::maybe_get_form( $form );
135
 
136
+ $old_id = false;
137
+ $form_fields = false;
138
  if ( ! empty( $this_form ) ) {
139
+ $form_id = $this_form->id;
140
+ $old_id = $this_form->id;
141
  self::update_form( $this_form, $form, $imported );
142
 
143
  $form_fields = self::get_form_fields( $form_id );
161
  $imported['forms'][ (int) $item->id ] = $form_id;
162
 
163
  // Send pre 2.0 form options through function that creates actions
164
+ self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true );
165
 
166
  do_action( 'frm_after_import_form', $form_id, $form );
167
 
560
  } else if ( $post['post_type'] == 'frm_styles' ) {
561
  // Properly encode post content before inserting the post
562
  $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
563
+ $custom_css = isset( $post['post_content']['custom_css'] ) ? $post['post_content']['custom_css'] : '';
564
  $post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] );
565
 
566
  // Create/update post now
567
  $post_id = wp_insert_post( $post );
568
+ self::maybe_update_custom_css( $custom_css );
569
  } else {
570
  // Create/update post now
571
  $post_id = wp_insert_post( $post );
753
  }
754
  }
755
 
756
+ /**
757
+ * If a template includes custom css, let's include it.
758
+ * The custom css is included on the default style.
759
+ *
760
+ * @since 2.03
761
+ */
762
+ private static function maybe_update_custom_css( $custom_css ) {
763
+ if ( empty( $custom_css ) ) {
764
+ return;
765
+ }
766
+
767
+ $frm_style = new FrmStyle();
768
+ $default_style = $frm_style->get_default_style();
769
+ $default_style->post_content['custom_css'] .= "\r\n\r\n" . $custom_css;
770
+ $frm_style->save( $default_style );
771
+ }
772
+
773
  private static function maybe_update_stylesheet( $imported ) {
774
  $new_styles = isset( $imported['imported']['styles'] ) && ! empty( $imported['imported']['styles'] );
775
  $updated_styles = isset( $imported['updated']['styles'] ) && ! empty( $imported['updated']['styles'] );
1041
  // Migrate autoresponders
1042
  self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications );
1043
 
1044
+ if ( empty( $notifications ) ) {
1045
  return;
1046
  }
1047
 
classes/models/FrmAntiSpam.php DELETED
@@ -1,268 +0,0 @@
1
- <?php
2
-
3
- if ( ! defined( 'ABSPATH' ) ) {
4
- die( 'You are not allowed to call this page directly.' );
5
- }
6
-
7
- class FrmAntiSpam {
8
-
9
- private static function is_spam( $comment ) {
10
- $url = $email = $author = $body = $comment; // TODO: get values from form
11
- $options = array(
12
- 'time_check' => 1, 'bbcode_check' => 1,
13
- 'advanced_check' => 1, 'regexp_check' => 1,
14
- 'dnsbl_check' => 1,
15
- );
16
-
17
- $response = array( 'spam' => false );
18
-
19
- /* Check if logged in */
20
- if ( is_user_logged_in() ) {
21
- return $response;
22
- }
23
-
24
- /* Honeypot */
25
- if ( ! empty( $_POST['ab_spam__hidden_field'] ) ) {
26
- $response['reason'] = 'css';
27
- return $response;
28
- }
29
-
30
- $ip = FrmAppHelper::get_ip_address();
31
- if ( empty( $ip ) ) {
32
- $response['reason'] = 'empty';
33
- return $response;
34
- }
35
-
36
- /* Action time */
37
- if ( $options['time_check'] && self::_is_shortest_time() ) {
38
- $response['reason'] = 'time';
39
- return $response;
40
- }
41
-
42
- /* BBCode Spam */
43
- if ( $options['bbcode_check'] && self::_is_bbcode_spam( $body ) ) {
44
- $response['reason'] = 'bbcode';
45
- return $response;
46
- }
47
-
48
- if ( $options['advanced_check'] && self::_is_fake_ip( $ip ) ) {
49
- $response['reason'] = 'server';
50
- return $response;
51
- }
52
-
53
- /* Regexp for Spam */
54
- if ( $options['regexp_check'] ) {
55
- $is_spam = self::_is_regexp_spam( array(
56
- 'ip' => $ip,
57
- 'host' => parse_url( $url, PHP_URL_HOST ),
58
- 'body' => $body,
59
- 'email' => $email,
60
- 'author' => $author,
61
- ) );
62
- if ( $is_spam ) {
63
- $response['reason'] = 'regexp';
64
- return $response;
65
- }
66
- }
67
-
68
- /* DNSBL Spam */
69
- if ( $options['dnsbl_check'] && self::_is_dnsbl_spam( $ip ) ) {
70
- $response['reason'] = 'dnsbl';
71
- return $response;
72
- }
73
- }
74
-
75
- /**
76
- * Check for form submission time
77
- *
78
- * @return boolean TRUE if the action time is less than 5 seconds
79
- */
80
-
81
- private static function _is_shortest_time() {
82
- $too_short = false;
83
- $start_time = FrmAppHelper::get_post_param( 'ab_init_time', 0, 'absint' );
84
-
85
- if ( $start_time ) {
86
- // Compare time values
87
- $min_seconds = apply_filters( 'frm_spam_time_limit', 5 );
88
- $total_time = time() - $start_time;
89
- if ( $total_time < $min_seconds ) {
90
- $too_short = true;
91
- }
92
- }
93
-
94
- return $too_short;
95
- }
96
-
97
- private static function _is_bbcode_spam( $body ) {
98
- return (bool) preg_match( '/\[url[=\]].*\[\/url\]/is', $body );
99
- }
100
-
101
- private static function _is_fake_ip( $client_ip, $client_host = false ) {
102
- /* Remote Host */
103
- $host_by_ip = gethostbyaddr( $client_ip );
104
-
105
- /* IPv6 */
106
- if ( self::_is_ipv6( $client_ip ) ) {
107
- return $client_ip != $host_by_ip;
108
- }
109
-
110
- /* IPv4 */
111
- if ( empty( $client_host ) ) {
112
- $ip_by_host = gethostbyname( $host_by_ip );
113
-
114
- if ( $ip_by_host === $host_by_ip ) {
115
- return false;
116
- }
117
- } else {
118
- /* IPv4 / API */
119
- if ( $host_by_ip === $client_ip ) {
120
- return true;
121
- }
122
-
123
- $ip_by_host = gethostbyname( $client_host );
124
- }
125
-
126
- if ( strpos( $client_ip, self::_cut_ip( $ip_by_host ) ) === false ) {
127
- return true;
128
- }
129
-
130
- return false;
131
- }
132
-
133
- /**
134
- * Check for an IPv6 address
135
- *
136
- * @param string $ip IP to validate
137
- * @return boolean TRUE if IPv6
138
- */
139
-
140
- private static function _is_ipv6( $ip ) {
141
- if ( function_exists('filter_var') ) {
142
- return filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6 ) !== false;
143
- } else {
144
- return ! self::_is_ipv4( $ip );
145
- }
146
- }
147
-
148
- /**
149
- * Check for an IPv4 address
150
- *
151
- * @param string $ip IP to validate
152
- * @return integer TRUE if IPv4
153
- */
154
- private static function _is_ipv4( $ip ) {
155
- if ( function_exists('filter_var') ) {
156
- return filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) !== false;
157
- } else {
158
- return preg_match( '/^\d{1,3}(\.\d{1,3}){3,3}$/', $ip );
159
- }
160
- }
161
-
162
- private static function _cut_ip( $ip, $cut_end = true ) {
163
- $separator = ( self::_is_ipv4( $ip ) ? '.' : ':' );
164
- $part = ( $cut_end ? strrchr( $ip, $separator ) : strstr( $ip, $separator ) );
165
-
166
- return str_replace( $part, '', $ip );
167
- }
168
-
169
- private static function _is_regexp_spam( $comment ) {
170
- /* Felder */
171
- $fields = array(
172
- 'ip',
173
- 'host',
174
- 'body',
175
- 'email',
176
- 'author',
177
- );
178
-
179
- /* Regexp */
180
- $patterns = array(
181
- 0 => array(
182
- 'host' => '^(www\.)?\d+\w+\.com$',
183
- 'body' => '^\w+\s\d+$',
184
- 'email' => '@gmail.com$',
185
- ),
186
- 1 => array(
187
- 'body' => '\<\!.+?mfunc.+?\>',
188
- ),
189
- );
190
-
191
- /* Spammy author */
192
- if ( $quoted_author = preg_quote( $comment['author'], '/' ) ) {
193
- $patterns[] = array(
194
- 'body' => sprintf( '<a.+?>%s<\/a>$', $quoted_author ),
195
- );
196
- $patterns[] = array(
197
- 'body' => sprintf( '%s https?:.+?$', $quoted_author ),
198
- );
199
- $patterns[] = array(
200
- 'email' => '@gmail.com$',
201
- 'author' => '^[a-z0-9-\.]+\.[a-z]{2,6}$',
202
- 'host' => sprintf( '^%s$', $quoted_author ),
203
- );
204
- }
205
-
206
- /* Hook */
207
- $patterns = apply_filters( 'antispam_bee_patterns', $patterns );
208
-
209
- if ( ! $patterns ) {
210
- return false;
211
- }
212
-
213
- foreach ( $patterns as $pattern ) {
214
- $hits = array();
215
-
216
- foreach ( $pattern as $field => $regexp ) {
217
- $is_empty = ( empty( $field ) || ! in_array( $field, $fields ) || empty( $regexp ) );
218
- if ( $is_empty ) {
219
- continue;
220
- }
221
-
222
- /* Ignore non utf-8 chars */
223
- $comment[ $field ] = ( function_exists('iconv') ? iconv( 'utf-8', 'utf-8//TRANSLIT', $comment[ $field ] ) : $comment[ $field ] );
224
-
225
- if ( empty( $comment[ $field ] ) ) {
226
- continue;
227
- }
228
-
229
- /* Perform regex */
230
- if ( preg_match( '/' . $regexp . '/isu', $comment[ $field ] ) ) {
231
- $hits[ $field ] = true;
232
- }
233
- }
234
-
235
- if ( count( $hits ) === count( $pattern ) ) {
236
- return true;
237
- }
238
- }
239
-
240
- return false;
241
- }
242
-
243
- private static function _is_dnsbl_spam( $ip ) {
244
-
245
- $response = wp_safe_remote_request(
246
- esc_url_raw(
247
- sprintf( 'http://www.stopforumspam.com/api?ip=%s&f=json', $ip ),
248
- 'http'
249
- )
250
- );
251
-
252
- if ( is_wp_error( $response ) ) {
253
- return false;
254
- }
255
-
256
- /* Get JSON */
257
- $json = wp_remote_retrieve_body( $response );
258
-
259
- $result = json_decode( $json );
260
-
261
- if ( empty( $result->success ) ) {
262
- return false;
263
- }
264
-
265
- $status = (bool) $result->ip->appears;
266
- return $status;
267
- }
268
- }