Formidable Forms – Form Builder for WordPress - Version 3.01.01

Version Description

  • New: Replace the jQuery colorpicker with the WordPress colorpicker in the visual form styler
  • New: Process shortcodes in the redirect url after form submission
  • New: frm_override_default_styles and frm_default_style_settings hooks
  • Fix: Prevent shortcodes inside field values from being processed in more places including the redirect url. This is a security precaution.
  • Fix: A default contact form was being added with each update. This update ensures the contact form is only generated once.
  • Fix: Allow the visual form styler to show instant changes to the sample contact form since server limits of url size were being hit in some cases.
  • Fix: HTML was being stripped from some field settings on the form creator page like validation messages
Download this release

Release Info

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

Code changes from version 3.01 to 3.01.01

Files changed (78) hide show
  1. classes/controllers/FrmAppController.php +13 -7
  2. classes/controllers/FrmFieldsController.php +1 -1
  3. classes/controllers/FrmFormActionsController.php +23 -23
  4. classes/controllers/FrmFormsController.php +91 -90
  5. classes/controllers/FrmSettingsController.php +1 -1
  6. classes/controllers/FrmStylesController.php +4 -12
  7. classes/helpers/FrmAppHelper.php +143 -139
  8. classes/helpers/FrmEntriesHelper.php +35 -35
  9. classes/helpers/FrmEntriesListHelper.php +7 -7
  10. classes/helpers/FrmFieldsHelper.php +96 -91
  11. classes/helpers/FrmFormActionsHelper.php +1 -1
  12. classes/helpers/FrmFormsHelper.php +49 -49
  13. classes/helpers/FrmFormsListHelper.php +26 -26
  14. classes/helpers/FrmListHelper.php +1 -1
  15. classes/helpers/FrmShortcodeHelper.php +2 -2
  16. classes/helpers/FrmStylesHelper.php +36 -22
  17. classes/helpers/FrmXMLHelper.php +92 -92
  18. classes/models/FrmAddon.php +1 -1
  19. classes/models/FrmCreateFile.php +8 -8
  20. classes/models/FrmDb.php +11 -11
  21. classes/models/FrmDbDeprecated.php +2 -2
  22. classes/models/FrmEntry.php +51 -51
  23. classes/models/FrmEntryMeta.php +54 -54
  24. classes/models/FrmEntryValidate.php +7 -7
  25. classes/models/FrmField.php +43 -43
  26. classes/models/FrmFieldFormHtml.php +12 -12
  27. classes/models/FrmForm.php +73 -73
  28. classes/models/FrmFormAction.php +54 -54
  29. classes/models/FrmMigrate.php +28 -21
  30. classes/models/FrmSettings.php +55 -55
  31. classes/models/FrmStyle.php +52 -36
  32. classes/models/fields/FrmFieldCheckbox.php +1 -1
  33. classes/models/fields/FrmFieldRadio.php +1 -1
  34. classes/models/fields/FrmFieldTextarea.php +1 -1
  35. classes/models/fields/FrmFieldType.php +17 -10
  36. classes/views/addons/upgrade_to_pro.php +3 -3
  37. classes/views/frm-entries/_sidebar-shared-pub.php +2 -2
  38. classes/views/frm-entries/errors.php +4 -4
  39. classes/views/frm-entries/form.php +15 -15
  40. classes/views/frm-entries/sidebar-shared.php +4 -4
  41. classes/views/frm-fields/back-end/field-captcha.php +3 -2
  42. classes/views/frm-fields/front-end/checkbox-field.php +1 -1
  43. classes/views/frm-fields/front-end/dropdown-field.php +3 -3
  44. classes/views/frm-fields/front-end/radio-field.php +2 -2
  45. classes/views/frm-form-actions/_action_inside.php +8 -7
  46. classes/views/frm-form-actions/default_actions.php +6 -6
  47. classes/views/frm-form-actions/email_action.php +3 -3
  48. classes/views/frm-form-actions/form_action.php +3 -3
  49. classes/views/frm-forms/add_field.php +2 -2
  50. classes/views/frm-forms/form.php +3 -3
  51. classes/views/frm-forms/mb_html_tab.php +2 -2
  52. classes/views/frm-forms/settings.php +8 -6
  53. classes/views/frm-forms/shortcode_opts.php +1 -1
  54. classes/views/frm-forms/sidebar-settings.php +1 -1
  55. classes/views/frm-settings/form.php +8 -8
  56. classes/views/shared/mb_adv_info.php +11 -11
  57. classes/views/styles/_field-colors.php +2 -2
  58. classes/views/styles/_field-labels.php +9 -9
  59. classes/views/styles/_field-sizes.php +8 -8
  60. classes/views/styles/_general.php +10 -9
  61. classes/views/styles/custom_css.php +5 -5
  62. classes/views/styles/manage.php +1 -1
  63. classes/views/xml/forms_xml.php +12 -12
  64. classes/views/xml/import_form.php +1 -1
  65. classes/widgets/FrmShowForm.php +1 -1
  66. css/_single_theme.css.php +20 -36
  67. css/custom_theme.css.php +2 -2
  68. css/frm_admin.css +15 -47
  69. formidable.php +4 -4
  70. images/styler/marker.png +0 -0
  71. images/styler/mask.png +0 -0
  72. images/styler/wheel.png +0 -0
  73. js/formidable.js +11 -1
  74. js/formidable.min.js +35 -35
  75. js/formidable_admin.js +157 -5
  76. js/jquery/jquery-ui-themepicker.js +0 -395
  77. js/jquery/jquery-ui-themepicker.min.js +0 -1
  78. readme.txt +10 -1
classes/controllers/FrmAppController.php CHANGED
@@ -177,7 +177,7 @@ class FrmAppController {
177
  <div class="update-nag frm-update-to-pro">
178
  <?php echo FrmAppHelper::kses( $tip['tip'] ); ?>
179
  <span><?php echo FrmAppHelper::kses( $tip['call'] ); ?></span>
180
- <a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidableforms.com?banner=1&tip=' . absint( $tip['num'] ) ) ); ?>" class="button">Upgrade to Pro</a>
181
  </div>
182
  <?php
183
  }
@@ -291,7 +291,7 @@ class FrmAppController {
291
  $version = FrmAppHelper::plugin_version();
292
  FrmAppHelper::load_admin_wide_js( false );
293
 
294
- wp_register_script( 'formidable_admin', FrmAppHelper::plugin_url() . '/js/formidable_admin.js', array(
295
  'formidable_admin_global',
296
  'formidable',
297
  'jquery',
@@ -300,7 +300,13 @@ class FrmAppController {
300
  'jquery-ui-sortable',
301
  'bootstrap_tooltip',
302
  'bootstrap-multiselect',
303
- ), $version, true );
 
 
 
 
 
 
304
  wp_register_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css', array(), $version );
305
  wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' );
306
  wp_register_style( 'formidable-grids', FrmAppHelper::plugin_url() . '/css/frm_grids.css', array(), $version );
@@ -467,13 +473,13 @@ class FrmAppController {
467
  self::install();
468
  }
469
 
470
- public static function install( $old_db_version = false ) {
471
  $frmdb = new FrmMigrate();
472
- $frmdb->upgrade( $old_db_version );
473
  }
474
 
475
  public static function uninstall() {
476
- FrmAppHelper::permission_check('administrator');
477
  check_ajax_referer( 'frm_ajax', 'nonce' );
478
 
479
  $frmdb = new FrmMigrate();
@@ -513,7 +519,7 @@ class FrmAppController {
513
  }
514
 
515
  public static function deauthorize() {
516
- FrmAppHelper::permission_check('frm_change_settings');
517
  check_ajax_referer( 'frm_ajax', 'nonce' );
518
 
519
  delete_option( 'frmpro-credentials' );
177
  <div class="update-nag frm-update-to-pro">
178
  <?php echo FrmAppHelper::kses( $tip['tip'] ); ?>
179
  <span><?php echo FrmAppHelper::kses( $tip['call'] ); ?></span>
180
+ <a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com?banner=1&tip=' . absint( $tip['num'] ) ) ); ?>" class="button">Upgrade to Pro</a>
181
  </div>
182
  <?php
183
  }
291
  $version = FrmAppHelper::plugin_version();
292
  FrmAppHelper::load_admin_wide_js( false );
293
 
294
+ $dependecies = array(
295
  'formidable_admin_global',
296
  'formidable',
297
  'jquery',
300
  'jquery-ui-sortable',
301
  'bootstrap_tooltip',
302
  'bootstrap-multiselect',
303
+ );
304
+
305
+ if ( FrmAppHelper::is_admin_page( 'formidable-styles' ) ) {
306
+ $dependecies[] = 'wp-color-picker';
307
+ }
308
+
309
+ wp_register_script( 'formidable_admin', FrmAppHelper::plugin_url() . '/js/formidable_admin.js', $dependecies, $version, true );
310
  wp_register_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css', array(), $version );
311
  wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' );
312
  wp_register_style( 'formidable-grids', FrmAppHelper::plugin_url() . '/css/frm_grids.css', array(), $version );
473
  self::install();
474
  }
475
 
476
+ public static function install() {
477
  $frmdb = new FrmMigrate();
478
+ $frmdb->upgrade();
479
  }
480
 
481
  public static function uninstall() {
482
+ FrmAppHelper::permission_check( 'administrator' );
483
  check_ajax_referer( 'frm_ajax', 'nonce' );
484
 
485
  $frmdb = new FrmMigrate();
519
  }
520
 
521
  public static function deauthorize() {
522
+ FrmAppHelper::permission_check( 'frm_change_settings' );
523
  check_ajax_referer( 'frm_ajax', 'nonce' );
524
 
525
  delete_option( 'frmpro-credentials' );
classes/controllers/FrmFieldsController.php CHANGED
@@ -530,7 +530,7 @@ class FrmFieldsController {
530
  return;
531
  }
532
 
533
- if ( FrmAppHelper::is_admin_page('formidable' ) ) {
534
  return;
535
  }
536
 
530
  return;
531
  }
532
 
533
+ if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
534
  return;
535
  }
536
 
classes/controllers/FrmFormActionsController.php CHANGED
@@ -45,17 +45,17 @@ class FrmFormActionsController {
45
  'highrise' => 'FrmDefHrsAction',
46
  ) );
47
 
48
- include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php');
49
- include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php');
50
 
51
  foreach ( $action_classes as $action_class ) {
52
- self::$registered_actions->register($action_class);
53
  }
54
  }
55
 
56
  public static function get_form_actions( $action = 'all' ) {
57
  $temp_actions = self::$registered_actions;
58
- if ( empty($temp_actions) ) {
59
  self::actions_init();
60
  $temp_actions = self::$registered_actions->actions;
61
  } else {
@@ -129,12 +129,12 @@ class FrmFormActionsController {
129
  }
130
 
131
  public static function action_control( $form_action, $form, $action_key, $action_control, $values ) {
132
- $action_control->_set($action_key);
133
  include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' );
134
  }
135
 
136
  public static function add_form_action() {
137
- FrmAppHelper::permission_check('frm_edit_forms');
138
  check_ajax_referer( 'frm_ajax', 'nonce' );
139
 
140
  global $frm_vars;
@@ -143,58 +143,58 @@ class FrmFormActionsController {
143
  $action_type = sanitize_text_field( $_POST['type'] );
144
 
145
  $action_control = self::get_form_actions( $action_type );
146
- $action_control->_set($action_key);
147
 
148
  $form_id = absint( $_POST['form_id'] );
149
 
150
- $form_action = $action_control->prepare_new($form_id);
151
 
152
  $values = array();
153
- $form = self::fields_to_values($form_id, $values);
154
 
155
  include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' );
156
  wp_die();
157
  }
158
 
159
  public static function fill_action() {
160
- FrmAppHelper::permission_check('frm_edit_forms');
161
  check_ajax_referer( 'frm_ajax', 'nonce' );
162
 
163
  $action_key = absint( $_POST['action_id'] );
164
  $action_type = sanitize_text_field( $_POST['action_type'] );
165
 
166
  $action_control = self::get_form_actions( $action_type );
167
- if ( empty($action_control) ) {
168
  wp_die();
169
  }
170
 
171
  $form_action = $action_control->get_single_action( $action_key );
172
 
173
  $values = array();
174
- $form = self::fields_to_values($form_action->menu_order, $values);
175
 
176
  include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_inside.php' );
177
  wp_die();
178
  }
179
 
180
  private static function fields_to_values( $form_id, array &$values ) {
181
- $form = FrmForm::getOne($form_id);
182
 
183
  $values = array(
184
  'fields' => array(),
185
  'id' => $form->id,
186
  );
187
 
188
- $fields = FrmField::get_all_for_form($form->id);
189
  foreach ( $fields as $k => $f ) {
190
  $f = (array) $f;
191
  $opts = (array) $f['field_options'];
192
- $f = array_merge($opts, $f);
193
  if ( ! isset( $f['post_field'] ) ) {
194
  $f['post_field'] = '';
195
  }
196
  $values['fields'][] = $f;
197
- unset($k, $f);
198
  }
199
 
200
  return $form;
@@ -212,7 +212,7 @@ class FrmFormActionsController {
212
  $new_actions = array();
213
 
214
  foreach ( $registered_actions as $registered_action ) {
215
- $action_ids = $registered_action->update_callback($form_id);
216
  if ( ! empty( $action_ids ) ) {
217
  $new_actions[] = $action_ids;
218
  }
@@ -307,11 +307,11 @@ class FrmFormActionsController {
307
  $stored_actions[ $action->ID ] = $action;
308
  $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority'];
309
 
310
- unset($action);
311
  }
312
 
313
  if ( ! empty( $stored_actions ) ) {
314
- asort($action_priority);
315
 
316
  // make sure hooks are loaded
317
  new FrmNotification();
@@ -323,14 +323,14 @@ class FrmFormActionsController {
323
 
324
  // If post is created, get updated $entry object
325
  if ( $action->post_excerpt == 'wppost' && $event == 'create' ) {
326
- $entry = FrmEntry::getOne($entry->id, true);
327
  }
328
  }
329
  }
330
  }
331
 
332
  public static function duplicate_form_actions( $form_id, $values, $args = array() ) {
333
- if ( ! isset($args['old_id']) || empty($args['old_id']) ) {
334
  // continue if we know which actions to copy
335
  return;
336
  }
@@ -369,12 +369,12 @@ class Frm_Form_Action_Factory {
369
 
370
  public function unregister( $action_class ) {
371
  if ( isset( $this->actions[ $action_class ] ) ) {
372
- unset($this->actions[ $action_class ]);
373
  }
374
  }
375
 
376
  public function _register_actions() {
377
- $keys = array_keys($this->actions);
378
 
379
  foreach ( $keys as $key ) {
380
  // don't register new action if old action with the same id is already registered
45
  'highrise' => 'FrmDefHrsAction',
46
  ) );
47
 
48
+ include_once( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php' );
49
+ include_once( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php' );
50
 
51
  foreach ( $action_classes as $action_class ) {
52
+ self::$registered_actions->register( $action_class );
53
  }
54
  }
55
 
56
  public static function get_form_actions( $action = 'all' ) {
57
  $temp_actions = self::$registered_actions;
58
+ if ( empty( $temp_actions ) ) {
59
  self::actions_init();
60
  $temp_actions = self::$registered_actions->actions;
61
  } else {
129
  }
130
 
131
  public static function action_control( $form_action, $form, $action_key, $action_control, $values ) {
132
+ $action_control->_set( $action_key );
133
  include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' );
134
  }
135
 
136
  public static function add_form_action() {
137
+ FrmAppHelper::permission_check( 'frm_edit_forms' );
138
  check_ajax_referer( 'frm_ajax', 'nonce' );
139
 
140
  global $frm_vars;
143
  $action_type = sanitize_text_field( $_POST['type'] );
144
 
145
  $action_control = self::get_form_actions( $action_type );
146
+ $action_control->_set( $action_key );
147
 
148
  $form_id = absint( $_POST['form_id'] );
149
 
150
+ $form_action = $action_control->prepare_new( $form_id );
151
 
152
  $values = array();
153
+ $form = self::fields_to_values( $form_id, $values );
154
 
155
  include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' );
156
  wp_die();
157
  }
158
 
159
  public static function fill_action() {
160
+ FrmAppHelper::permission_check( 'frm_edit_forms' );
161
  check_ajax_referer( 'frm_ajax', 'nonce' );
162
 
163
  $action_key = absint( $_POST['action_id'] );
164
  $action_type = sanitize_text_field( $_POST['action_type'] );
165
 
166
  $action_control = self::get_form_actions( $action_type );
167
+ if ( empty( $action_control ) ) {
168
  wp_die();
169
  }
170
 
171
  $form_action = $action_control->get_single_action( $action_key );
172
 
173
  $values = array();
174
+ $form = self::fields_to_values( $form_action->menu_order, $values );
175
 
176
  include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_inside.php' );
177
  wp_die();
178
  }
179
 
180
  private static function fields_to_values( $form_id, array &$values ) {
181
+ $form = FrmForm::getOne( $form_id );
182
 
183
  $values = array(
184
  'fields' => array(),
185
  'id' => $form->id,
186
  );
187
 
188
+ $fields = FrmField::get_all_for_form( $form->id );
189
  foreach ( $fields as $k => $f ) {
190
  $f = (array) $f;
191
  $opts = (array) $f['field_options'];
192
+ $f = array_merge( $opts, $f );
193
  if ( ! isset( $f['post_field'] ) ) {
194
  $f['post_field'] = '';
195
  }
196
  $values['fields'][] = $f;
197
+ unset( $k, $f );
198
  }
199
 
200
  return $form;
212
  $new_actions = array();
213
 
214
  foreach ( $registered_actions as $registered_action ) {
215
+ $action_ids = $registered_action->update_callback( $form_id );
216
  if ( ! empty( $action_ids ) ) {
217
  $new_actions[] = $action_ids;
218
  }
307
  $stored_actions[ $action->ID ] = $action;
308
  $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority'];
309
 
310
+ unset( $action );
311
  }
312
 
313
  if ( ! empty( $stored_actions ) ) {
314
+ asort( $action_priority );
315
 
316
  // make sure hooks are loaded
317
  new FrmNotification();
323
 
324
  // If post is created, get updated $entry object
325
  if ( $action->post_excerpt == 'wppost' && $event == 'create' ) {
326
+ $entry = FrmEntry::getOne( $entry->id, true );
327
  }
328
  }
329
  }
330
  }
331
 
332
  public static function duplicate_form_actions( $form_id, $values, $args = array() ) {
333
+ if ( ! isset( $args['old_id'] ) || empty( $args['old_id'] ) ) {
334
  // continue if we know which actions to copy
335
  return;
336
  }
369
 
370
  public function unregister( $action_class ) {
371
  if ( isset( $this->actions[ $action_class ] ) ) {
372
+ unset( $this->actions[ $action_class ] );
373
  }
374
  }
375
 
376
  public function _register_actions() {
377
+ $keys = array_keys( $this->actions );
378
 
379
  foreach ( $keys as $key ) {
380
  // don't register new action if old action with the same id is already registered
classes/controllers/FrmFormsController.php CHANGED
@@ -7,7 +7,7 @@ class FrmFormsController {
7
  if ( ! FrmAppHelper::pro_is_installed() ) {
8
  $menu_label .= ' (Lite)';
9
  }
10
- add_submenu_page('formidable', 'Formidable | ' . $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' );
11
 
12
  self::maybe_load_listing_hooks();
13
  }
@@ -25,17 +25,17 @@ class FrmFormsController {
25
  }
26
 
27
  public static function head() {
28
- wp_enqueue_script('formidable-editinplace');
29
 
30
  if ( wp_is_mobile() ) {
31
  wp_enqueue_script( 'jquery-touch-punch' );
32
  }
33
  }
34
 
35
- public static function register_widgets() {
36
- require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php');
37
- register_widget('FrmShowForm');
38
- }
39
 
40
  /**
41
  * By default, Divi processes form shortcodes on the edit post page.
@@ -48,32 +48,32 @@ class FrmFormsController {
48
  return $shortcodes;
49
  }
50
 
51
- public static function list_form() {
52
- FrmAppHelper::permission_check('frm_view_forms');
53
 
54
  $params = FrmForm::list_page_params();
55
- $errors = self::process_bulk_form_actions( array());
56
- $errors = apply_filters('frm_admin_list_form_action', $errors);
57
 
58
  return self::display_forms_list( $params, '', $errors );
59
- }
60
 
61
  public static function new_form( $values = array() ) {
62
- FrmAppHelper::permission_check('frm_edit_forms');
63
 
64
  global $frm_vars;
65
 
66
- $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
67
  $action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ];
68
 
69
  if ( $action == 'create' ) {
70
- self::create($values);
71
  return;
72
  } else if ( $action == 'new' ) {
73
  $frm_field_selection = FrmField::field_selection();
74
- $values = FrmFormsHelper::setup_new_vars($values);
75
  $id = FrmForm::create( $values );
76
- $form = FrmForm::getOne($id);
77
 
78
  self::create_default_email_action( $form );
79
 
@@ -101,7 +101,7 @@ class FrmFormsController {
101
  }
102
 
103
  public static function create( $values = array() ) {
104
- FrmAppHelper::permission_check('frm_edit_forms');
105
 
106
  global $frm_vars;
107
  if ( empty( $values ) ) {
@@ -113,22 +113,22 @@ class FrmFormsController {
113
  $values = FrmProEntry::mod_other_vals( $values, 'back' );
114
  }
115
 
116
- $id = isset($values['id']) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
117
 
118
  if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
119
  $frm_settings = FrmAppHelper::get_settings();
120
  $errors = array( 'form' => $frm_settings->admin_permission );
121
  } else {
122
- $errors = FrmForm::validate($values);
123
  }
124
 
125
- if ( count($errors) > 0 ) {
126
  $hide_preview = true;
127
  $frm_field_selection = FrmField::field_selection();
128
  $form = FrmForm::getOne( $id );
129
- $fields = FrmField::get_all_for_form($id);
130
 
131
- $values = FrmAppHelper::setup_edit_vars($form, 'forms', '', true);
132
  $values['fields'] = $fields;
133
  $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
134
 
@@ -141,32 +141,32 @@ class FrmFormsController {
141
  }
142
 
143
  public static function edit( $values = false ) {
144
- FrmAppHelper::permission_check('frm_edit_forms');
145
 
146
  $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
147
- return self::get_edit_vars($id);
148
  }
149
 
150
  public static function settings( $id = false, $message = '' ) {
151
- FrmAppHelper::permission_check('frm_edit_forms');
152
 
153
- if ( ! $id || ! is_numeric($id) ) {
154
  $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
155
  }
156
  return self::get_settings_vars( $id, array(), $message );
157
  }
158
 
159
  public static function update_settings() {
160
- FrmAppHelper::permission_check('frm_edit_forms');
161
 
162
  $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
163
 
164
- $errors = FrmForm::validate($_POST);
165
- if ( count($errors) > 0 ) {
166
- return self::get_settings_vars($id, $errors);
167
- }
168
 
169
- do_action('frm_before_update_form_settings', $id);
170
 
171
  FrmForm::update( $id, $_POST );
172
 
@@ -210,7 +210,7 @@ class FrmFormsController {
210
  * @since 2.0
211
  */
212
  public static function _create_from_template() {
213
- FrmAppHelper::permission_check('frm_edit_forms');
214
  check_ajax_referer( 'frm_ajax', 'nonce' );
215
 
216
  $current_form = FrmAppHelper::get_param( 'this_form', '', 'get', 'absint' );
@@ -225,7 +225,7 @@ class FrmFormsController {
225
  }
226
 
227
  public static function duplicate() {
228
- FrmAppHelper::permission_check('frm_edit_forms');
229
 
230
  $params = FrmForm::list_page_params();
231
  $form = FrmForm::duplicate( $params['id'], $params['template'], true );
@@ -233,7 +233,7 @@ class FrmFormsController {
233
  if ( $form ) {
234
  return self::get_edit_vars( $form, array(), $message, true );
235
  } else {
236
- return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' ));
237
  }
238
  }
239
 
@@ -375,11 +375,11 @@ class FrmFormsController {
375
  }
376
 
377
  public static function bulk_untrash( $ids ) {
378
- FrmAppHelper::permission_check('frm_edit_forms');
379
 
380
  $count = FrmForm::set_status( $ids, 'published' );
381
 
382
- $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
383
  return $message;
384
  }
385
 
@@ -425,7 +425,7 @@ class FrmFormsController {
425
  'type' => 'request',
426
  ) );
427
 
428
- $available_status['untrash']['message'] = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count );
429
  $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=' . $form_type . '&id=' . $params['id'], 'untrash_form_' . $params['id'] ) ) . '">', '</a>' );
430
 
431
  $message = $available_status[ $status ]['message'];
@@ -434,7 +434,7 @@ class FrmFormsController {
434
  }
435
 
436
  public static function bulk_trash( $ids ) {
437
- FrmAppHelper::permission_check('frm_delete_forms');
438
 
439
  $count = 0;
440
  foreach ( $ids as $id ) {
@@ -453,25 +453,25 @@ class FrmFormsController {
453
  }
454
 
455
  public static function destroy() {
456
- FrmAppHelper::permission_check('frm_delete_forms');
457
 
458
  $params = FrmForm::list_page_params();
459
 
460
  //check nonce url
461
- check_admin_referer('destroy_form_' . $params['id']);
462
 
463
  $count = 0;
464
  if ( FrmForm::destroy( $params['id'] ) ) {
465
  $count++;
466
  }
467
 
468
- $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
469
 
470
  self::display_forms_list( $params, $message );
471
  }
472
 
473
  public static function bulk_destroy( $ids ) {
474
- FrmAppHelper::permission_check('frm_delete_forms');
475
 
476
  $count = 0;
477
  foreach ( $ids as $id ) {
@@ -481,21 +481,21 @@ class FrmFormsController {
481
  }
482
  }
483
 
484
- $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
485
 
486
  return $message;
487
  }
488
 
489
  private static function delete_all() {
490
  //check nonce url
491
- $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable');
492
  if ( $permission_error !== false ) {
493
  self::display_forms_list( array(), '', array( $permission_error ) );
494
  return;
495
  }
496
 
497
  $count = FrmForm::scheduled_delete( time() );
498
- $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
499
 
500
  self::display_forms_list( array(), $message );
501
  }
@@ -507,7 +507,7 @@ class FrmFormsController {
507
  * @since 2.0.15
508
  */
509
  public static function insert_form_button() {
510
- if ( current_user_can('frm_view_forms') ) {
511
  $menu_name = FrmAppHelper::get_menu_name();
512
  $content = '<a href="#TB_inline?width=50&height=50&inlineId=frm_insert_form" class="thickbox button add_media frm_insert_form" title="' . esc_attr__( 'Add forms and content', 'formidable' ) . '">
513
  <span class="frm-buttons-icon wp-media-buttons-icon"></span> ' .
@@ -531,17 +531,17 @@ class FrmFormsController {
531
  ),
532
  );
533
 
534
- $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes);
535
 
536
  include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' );
537
  }
538
 
539
  public static function get_shortcode_opts() {
540
- FrmAppHelper::permission_check('frm_view_forms');
541
  check_ajax_referer( 'frm_ajax', 'nonce' );
542
 
543
  $shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' );
544
- if ( empty($shortcode) ) {
545
  wp_die();
546
  }
547
 
@@ -680,11 +680,11 @@ class FrmFormsController {
680
  }
681
 
682
  if ( $form->parent_form_id ) {
683
- wp_die( sprintf( __( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form->parent_form_id ) ) . '">', '</a>' ));
684
  }
685
 
686
  $frm_field_selection = FrmField::field_selection();
687
- $fields = FrmField::get_all_for_form($form->id);
688
 
689
  // Automatically add end section fields if they don't exist (2.0 migration)
690
  $reset_fields = false;
@@ -694,7 +694,7 @@ class FrmFormsController {
694
  $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
695
  }
696
 
697
- unset($end_section_values, $last_order, $open, $reset_fields);
698
 
699
  $args = array( 'parent_form_id' => $form->id );
700
  $values = FrmAppHelper::setup_edit_vars( $form, 'forms', '', true, array(), $args );
@@ -708,8 +708,8 @@ class FrmFormsController {
708
  $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
709
 
710
  if ( $form->default_template ) {
711
- wp_die(__( 'That template cannot be edited', 'formidable' ));
712
- } else if ( defined('DOING_AJAX') ) {
713
  wp_die();
714
  } else if ( $create_link ) {
715
  require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
@@ -725,21 +725,21 @@ class FrmFormsController {
725
 
726
  $form = FrmForm::getOne( $id );
727
 
728
- $fields = FrmField::get_all_for_form($id);
729
- $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
730
 
731
- if ( isset($values['default_template']) && $values['default_template'] ) {
732
- wp_die(__( 'That template cannot be edited', 'formidable' ));
733
- }
734
 
735
  self::clean_submit_html( $values );
736
 
737
  $action_controls = FrmFormActionsController::get_form_actions();
738
 
739
- $sections = apply_filters('frm_add_form_settings_section', array(), $values);
740
  $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
741
 
742
- $styles = apply_filters('frm_get_style_opts', array());
743
 
744
  $first_h3 = 'frm_first_h3';
745
 
@@ -760,10 +760,10 @@ class FrmFormsController {
760
  }
761
 
762
  public static function mb_tags_box( $form_id, $class = '' ) {
763
- $fields = FrmField::get_all_for_form($form_id, '', 'include');
764
  $linked_forms = array();
765
  $col = 'one';
766
- $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false;
767
 
768
  $cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() );
769
  $adv_shortcodes = self::get_advanced_shortcodes();
@@ -838,7 +838,7 @@ class FrmFormsController {
838
  * Insert the form class setting into the form
839
  */
840
  public static function form_classes( $form ) {
841
- if ( isset($form->options['form_class']) ) {
842
  echo esc_attr( sanitize_text_field( $form->options['form_class'] ) );
843
  }
844
 
@@ -946,7 +946,7 @@ class FrmFormsController {
946
  public static function add_default_templates( $path, $default = true, $template = true ) {
947
  _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' );
948
 
949
- $path = untrailingslashit(trim($path));
950
  $templates = glob( $path . '/*.php' );
951
 
952
  for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) {
@@ -971,9 +971,9 @@ class FrmFormsController {
971
  include( $templates[ $i ] );
972
 
973
  //get updated form
974
- if ( isset($form) && ! empty($form) ) {
975
  $old_id = $form->id;
976
- $form = FrmForm::getOne($form->id);
977
  } else {
978
  $old_id = false;
979
  $form = FrmForm::getAll( $template_query, '', 1 );
@@ -986,23 +986,23 @@ class FrmFormsController {
986
  }
987
 
988
  public static function route() {
989
- $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
990
  $vars = array();
991
  if ( isset( $_POST['frm_compact_fields'] ) ) {
992
  FrmAppHelper::permission_check( 'frm_edit_forms' );
993
 
994
- $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('&quot;', '\\\"', $_POST['frm_compact_fields'] ))));
995
- $json_vars = json_decode($json_vars, true);
996
- if ( empty($json_vars) ) {
997
  // json decoding failed so we should return an error message
998
  $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
999
  if ( 'edit' == $action ) {
1000
  $action = 'update';
1001
  }
1002
 
1003
- add_filter('frm_validate_form', 'FrmFormsController::json_error');
1004
  } else {
1005
- $vars = FrmAppHelper::json_to_array($json_vars);
1006
  $action = $vars[ $action ];
1007
  unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] );
1008
  $_REQUEST = array_merge( $_REQUEST, $vars );
@@ -1021,7 +1021,7 @@ class FrmFormsController {
1021
 
1022
  switch ( $action ) {
1023
  case 'new':
1024
- return self::new_form($vars);
1025
  case 'create':
1026
  case 'edit':
1027
  case 'update':
@@ -1044,7 +1044,7 @@ class FrmFormsController {
1044
  $action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
1045
  }
1046
 
1047
- if ( strpos($action, 'bulk_') === 0 ) {
1048
  FrmAppHelper::remove_get_action();
1049
  return self::list_form();
1050
  }
@@ -1071,21 +1071,21 @@ class FrmFormsController {
1071
 
1072
  public static function admin_bar_configure() {
1073
  global $frm_vars;
1074
- if ( empty($frm_vars['forms_loaded']) ) {
1075
  return;
1076
  }
1077
 
1078
  $actions = array();
1079
- foreach ( $frm_vars['forms_loaded'] as $form ) {
1080
- if ( is_object($form) ) {
1081
- $actions[ $form->id ] = $form->name;
1082
- }
1083
- unset($form);
1084
- }
1085
 
1086
- if ( empty($actions) ) {
1087
- return;
1088
- }
1089
 
1090
  self::add_menu_to_admin_bar();
1091
  self::add_forms_to_admin_bar( $actions );
@@ -1129,7 +1129,7 @@ class FrmFormsController {
1129
  //formidable shortcode
1130
  public static function get_form_shortcode( $atts ) {
1131
  global $frm_vars;
1132
- if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) {
1133
  $sc = '[formidable';
1134
  if ( ! empty( $atts ) ) {
1135
  foreach ( $atts as $k => $v ) {
@@ -1399,6 +1399,7 @@ class FrmFormsController {
1399
  $opt = $args['success_opt'];
1400
  $success_url = trim( $args['form']->options[ $opt . '_url' ] );
1401
  $success_url = apply_filters( 'frm_content', $success_url, $args['form'], $args['entry_id'] );
 
1402
 
1403
  $success_msg = isset( $args['form']->options[ $opt . '_msg' ] ) ? $args['form']->options[ $opt . '_msg' ] : __( 'Please wait while you are redirected.', 'formidable' );
1404
 
@@ -1408,7 +1409,7 @@ class FrmFormsController {
1408
  FrmEntriesController::delete_entry_before_redirect( $success_url, $args['form'], $args );
1409
 
1410
  add_filter( 'frm_redirect_url', 'FrmEntriesController::prepare_redirect_url' );
1411
- $success_url = apply_filters( 'frm_redirect_url', $success_url, $args['form'], $args);
1412
 
1413
  $doing_ajax = FrmAppHelper::doing_ajax();
1414
 
@@ -1434,7 +1435,7 @@ class FrmFormsController {
1434
  */
1435
  private static function get_redirect_message( $success_url, $success_msg, $args ) {
1436
  $redirect_msg = '<div class="' . esc_attr( FrmFormsHelper::get_form_style_class( $args['form'] ) ) . '"><div class="frm-redirect-msg frm_message">' . $success_msg . '<br/>' .
1437
- sprintf( __( '%1$sClick here%2$s if you are not automatically redirected.', 'formidable' ), '<a href="' . esc_url( $success_url ) . '">', '</a>') .
1438
  '</div></div>';
1439
 
1440
  return apply_filters( 'frm_redirect_msg', $redirect_msg, array(
@@ -1668,7 +1669,7 @@ class FrmFormsController {
1668
  private static function edit_in_place_value( $field ) {
1669
  _deprecated_function( __METHOD__, '3.0' );
1670
  check_ajax_referer( 'frm_ajax', 'nonce' );
1671
- FrmAppHelper::permission_check('frm_edit_forms', 'hide');
1672
 
1673
  $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
1674
  $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_filter_post_kses' );
7
  if ( ! FrmAppHelper::pro_is_installed() ) {
8
  $menu_label .= ' (Lite)';
9
  }
10
+ add_submenu_page( 'formidable', 'Formidable | ' . $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' );
11
 
12
  self::maybe_load_listing_hooks();
13
  }
25
  }
26
 
27
  public static function head() {
28
+ wp_enqueue_script( 'formidable-editinplace' );
29
 
30
  if ( wp_is_mobile() ) {
31
  wp_enqueue_script( 'jquery-touch-punch' );
32
  }
33
  }
34
 
35
+ public static function register_widgets() {
36
+ require_once( FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php' );
37
+ register_widget( 'FrmShowForm' );
38
+ }
39
 
40
  /**
41
  * By default, Divi processes form shortcodes on the edit post page.
48
  return $shortcodes;
49
  }
50
 
51
+ public static function list_form() {
52
+ FrmAppHelper::permission_check( 'frm_view_forms' );
53
 
54
  $params = FrmForm::list_page_params();
55
+ $errors = self::process_bulk_form_actions( array() );
56
+ $errors = apply_filters( 'frm_admin_list_form_action', $errors );
57
 
58
  return self::display_forms_list( $params, '', $errors );
59
+ }
60
 
61
  public static function new_form( $values = array() ) {
62
+ FrmAppHelper::permission_check( 'frm_edit_forms' );
63
 
64
  global $frm_vars;
65
 
66
+ $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
67
  $action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ];
68
 
69
  if ( $action == 'create' ) {
70
+ self::create( $values );
71
  return;
72
  } else if ( $action == 'new' ) {
73
  $frm_field_selection = FrmField::field_selection();
74
+ $values = FrmFormsHelper::setup_new_vars( $values );
75
  $id = FrmForm::create( $values );
76
+ $form = FrmForm::getOne( $id );
77
 
78
  self::create_default_email_action( $form );
79
 
101
  }
102
 
103
  public static function create( $values = array() ) {
104
+ FrmAppHelper::permission_check( 'frm_edit_forms' );
105
 
106
  global $frm_vars;
107
  if ( empty( $values ) ) {
113
  $values = FrmProEntry::mod_other_vals( $values, 'back' );
114
  }
115
 
116
+ $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
117
 
118
  if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
119
  $frm_settings = FrmAppHelper::get_settings();
120
  $errors = array( 'form' => $frm_settings->admin_permission );
121
  } else {
122
+ $errors = FrmForm::validate( $values );
123
  }
124
 
125
+ if ( count( $errors ) > 0 ) {
126
  $hide_preview = true;
127
  $frm_field_selection = FrmField::field_selection();
128
  $form = FrmForm::getOne( $id );
129
+ $fields = FrmField::get_all_for_form( $id );
130
 
131
+ $values = FrmAppHelper::setup_edit_vars( $form, 'forms', '', true );
132
  $values['fields'] = $fields;
133
  $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
134
 
141
  }
142
 
143
  public static function edit( $values = false ) {
144
+ FrmAppHelper::permission_check( 'frm_edit_forms' );
145
 
146
  $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
147
+ return self::get_edit_vars( $id );
148
  }
149
 
150
  public static function settings( $id = false, $message = '' ) {
151
+ FrmAppHelper::permission_check( 'frm_edit_forms' );
152
 
153
+ if ( ! $id || ! is_numeric( $id ) ) {
154
  $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
155
  }
156
  return self::get_settings_vars( $id, array(), $message );
157
  }
158
 
159
  public static function update_settings() {
160
+ FrmAppHelper::permission_check( 'frm_edit_forms' );
161
 
162
  $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
163
 
164
+ $errors = FrmForm::validate( $_POST );
165
+ if ( count( $errors ) > 0 ) {
166
+ return self::get_settings_vars( $id, $errors );
167
+ }
168
 
169
+ do_action( 'frm_before_update_form_settings', $id );
170
 
171
  FrmForm::update( $id, $_POST );
172
 
210
  * @since 2.0
211
  */
212
  public static function _create_from_template() {
213
+ FrmAppHelper::permission_check( 'frm_edit_forms' );
214
  check_ajax_referer( 'frm_ajax', 'nonce' );
215
 
216
  $current_form = FrmAppHelper::get_param( 'this_form', '', 'get', 'absint' );
225
  }
226
 
227
  public static function duplicate() {
228
+ FrmAppHelper::permission_check( 'frm_edit_forms' );
229
 
230
  $params = FrmForm::list_page_params();
231
  $form = FrmForm::duplicate( $params['id'], $params['template'], true );
233
  if ( $form ) {
234
  return self::get_edit_vars( $form, array(), $message, true );
235
  } else {
236
+ return self::display_forms_list( $params, __( 'There was a problem creating the new template.', 'formidable' ) );
237
  }
238
  }
239
 
375
  }
376
 
377
  public static function bulk_untrash( $ids ) {
378
+ FrmAppHelper::permission_check( 'frm_edit_forms' );
379
 
380
  $count = FrmForm::set_status( $ids, 'published' );
381
 
382
+ $message = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
383
  return $message;
384
  }
385
 
425
  'type' => 'request',
426
  ) );
427
 
428
+ $available_status['untrash']['message'] = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count );
429
  $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=' . $form_type . '&id=' . $params['id'], 'untrash_form_' . $params['id'] ) ) . '">', '</a>' );
430
 
431
  $message = $available_status[ $status ]['message'];
434
  }
435
 
436
  public static function bulk_trash( $ids ) {
437
+ FrmAppHelper::permission_check( 'frm_delete_forms' );
438
 
439
  $count = 0;
440
  foreach ( $ids as $id ) {
453
  }
454
 
455
  public static function destroy() {
456
+ FrmAppHelper::permission_check( 'frm_delete_forms' );
457
 
458
  $params = FrmForm::list_page_params();
459
 
460
  //check nonce url
461
+ check_admin_referer( 'destroy_form_' . $params['id'] );
462
 
463
  $count = 0;
464
  if ( FrmForm::destroy( $params['id'] ) ) {
465
  $count++;
466
  }
467
 
468
+ $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
469
 
470
  self::display_forms_list( $params, $message );
471
  }
472
 
473
  public static function bulk_destroy( $ids ) {
474
+ FrmAppHelper::permission_check( 'frm_delete_forms' );
475
 
476
  $count = 0;
477
  foreach ( $ids as $id ) {
481
  }
482
  }
483
 
484
+ $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
485
 
486
  return $message;
487
  }
488
 
489
  private static function delete_all() {
490
  //check nonce url
491
+ $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable' );
492
  if ( $permission_error !== false ) {
493
  self::display_forms_list( array(), '', array( $permission_error ) );
494
  return;
495
  }
496
 
497
  $count = FrmForm::scheduled_delete( time() );
498
+ $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
499
 
500
  self::display_forms_list( array(), $message );
501
  }
507
  * @since 2.0.15
508
  */
509
  public static function insert_form_button() {
510
+ if ( current_user_can( 'frm_view_forms' ) ) {
511
  $menu_name = FrmAppHelper::get_menu_name();
512
  $content = '<a href="#TB_inline?width=50&height=50&inlineId=frm_insert_form" class="thickbox button add_media frm_insert_form" title="' . esc_attr__( 'Add forms and content', 'formidable' ) . '">
513
  <span class="frm-buttons-icon wp-media-buttons-icon"></span> ' .
531
  ),
532
  );
533
 
534
+ $shortcodes = apply_filters( 'frm_popup_shortcodes', $shortcodes );
535
 
536
  include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' );
537
  }
538
 
539
  public static function get_shortcode_opts() {
540
+ FrmAppHelper::permission_check( 'frm_view_forms' );
541
  check_ajax_referer( 'frm_ajax', 'nonce' );
542
 
543
  $shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' );
544
+ if ( empty( $shortcode ) ) {
545
  wp_die();
546
  }
547
 
680
  }
681
 
682
  if ( $form->parent_form_id ) {
683
+ wp_die( sprintf( __( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form->parent_form_id ) ) . '">', '</a>' ) );
684
  }
685
 
686
  $frm_field_selection = FrmField::field_selection();
687
+ $fields = FrmField::get_all_for_form( $form->id );
688
 
689
  // Automatically add end section fields if they don't exist (2.0 migration)
690
  $reset_fields = false;
694
  $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
695
  }
696
 
697
+ unset( $end_section_values, $last_order, $open, $reset_fields );
698
 
699
  $args = array( 'parent_form_id' => $form->id );
700
  $values = FrmAppHelper::setup_edit_vars( $form, 'forms', '', true, array(), $args );
708
  $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
709
 
710
  if ( $form->default_template ) {
711
+ wp_die( __( 'That template cannot be edited', 'formidable' ) );
712
+ } elseif ( defined( 'DOING_AJAX' ) ) {
713
  wp_die();
714
  } else if ( $create_link ) {
715
  require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
725
 
726
  $form = FrmForm::getOne( $id );
727
 
728
+ $fields = FrmField::get_all_for_form( $id );
729
+ $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true );
730
 
731
+ if ( isset( $values['default_template'] ) && $values['default_template'] ) {
732
+ wp_die( __( 'That template cannot be edited', 'formidable' ) );
733
+ }
734
 
735
  self::clean_submit_html( $values );
736
 
737
  $action_controls = FrmFormActionsController::get_form_actions();
738
 
739
+ $sections = apply_filters( 'frm_add_form_settings_section', array(), $values );
740
  $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
741
 
742
+ $styles = apply_filters( 'frm_get_style_opts', array() );
743
 
744
  $first_h3 = 'frm_first_h3';
745
 
760
  }
761
 
762
  public static function mb_tags_box( $form_id, $class = '' ) {
763
+ $fields = FrmField::get_all_for_form( $form_id, '', 'include' );
764
  $linked_forms = array();
765
  $col = 'one';
766
+ $settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false;
767
 
768
  $cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() );
769
  $adv_shortcodes = self::get_advanced_shortcodes();
838
  * Insert the form class setting into the form
839
  */
840
  public static function form_classes( $form ) {
841
+ if ( isset( $form->options['form_class'] ) ) {
842
  echo esc_attr( sanitize_text_field( $form->options['form_class'] ) );
843
  }
844
 
946
  public static function add_default_templates( $path, $default = true, $template = true ) {
947
  _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' );
948
 
949
+ $path = untrailingslashit( trim( $path ) );
950
  $templates = glob( $path . '/*.php' );
951
 
952
  for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) {
971
  include( $templates[ $i ] );
972
 
973
  //get updated form
974
+ if ( isset( $form ) && ! empty( $form ) ) {
975
  $old_id = $form->id;
976
+ $form = FrmForm::getOne( $form->id );
977
  } else {
978
  $old_id = false;
979
  $form = FrmForm::getAll( $template_query, '', 1 );
986
  }
987
 
988
  public static function route() {
989
+ $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
990
  $vars = array();
991
  if ( isset( $_POST['frm_compact_fields'] ) ) {
992
  FrmAppHelper::permission_check( 'frm_edit_forms' );
993
 
994
+ $json_vars = htmlspecialchars_decode( nl2br( stripslashes( str_replace( '&quot;', '\\\"', $_POST['frm_compact_fields'] ) ) ) );
995
+ $json_vars = json_decode( $json_vars, true );
996
+ if ( empty( $json_vars ) ) {
997
  // json decoding failed so we should return an error message
998
  $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
999
  if ( 'edit' == $action ) {
1000
  $action = 'update';
1001
  }
1002
 
1003
+ add_filter( 'frm_validate_form', 'FrmFormsController::json_error' );
1004
  } else {
1005
+ $vars = FrmAppHelper::json_to_array( $json_vars );
1006
  $action = $vars[ $action ];
1007
  unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] );
1008
  $_REQUEST = array_merge( $_REQUEST, $vars );
1021
 
1022
  switch ( $action ) {
1023
  case 'new':
1024
+ return self::new_form( $vars );
1025
  case 'create':
1026
  case 'edit':
1027
  case 'update':
1044
  $action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
1045
  }
1046
 
1047
+ if ( strpos( $action, 'bulk_' ) === 0 ) {
1048
  FrmAppHelper::remove_get_action();
1049
  return self::list_form();
1050
  }
1071
 
1072
  public static function admin_bar_configure() {
1073
  global $frm_vars;
1074
+ if ( empty( $frm_vars['forms_loaded'] ) ) {
1075
  return;
1076
  }
1077
 
1078
  $actions = array();
1079
+ foreach ( $frm_vars['forms_loaded'] as $form ) {
1080
+ if ( is_object( $form ) ) {
1081
+ $actions[ $form->id ] = $form->name;
1082
+ }
1083
+ unset( $form );
1084
+ }
1085
 
1086
+ if ( empty( $actions ) ) {
1087
+ return;
1088
+ }
1089
 
1090
  self::add_menu_to_admin_bar();
1091
  self::add_forms_to_admin_bar( $actions );
1129
  //formidable shortcode
1130
  public static function get_form_shortcode( $atts ) {
1131
  global $frm_vars;
1132
+ if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) {
1133
  $sc = '[formidable';
1134
  if ( ! empty( $atts ) ) {
1135
  foreach ( $atts as $k => $v ) {
1399
  $opt = $args['success_opt'];
1400
  $success_url = trim( $args['form']->options[ $opt . '_url' ] );
1401
  $success_url = apply_filters( 'frm_content', $success_url, $args['form'], $args['entry_id'] );
1402
+ $success_url = do_shortcode( $success_url );
1403
 
1404
  $success_msg = isset( $args['form']->options[ $opt . '_msg' ] ) ? $args['form']->options[ $opt . '_msg' ] : __( 'Please wait while you are redirected.', 'formidable' );
1405
 
1409
  FrmEntriesController::delete_entry_before_redirect( $success_url, $args['form'], $args );
1410
 
1411
  add_filter( 'frm_redirect_url', 'FrmEntriesController::prepare_redirect_url' );
1412
+ $success_url = apply_filters( 'frm_redirect_url', $success_url, $args['form'], $args );
1413
 
1414
  $doing_ajax = FrmAppHelper::doing_ajax();
1415
 
1435
  */
1436
  private static function get_redirect_message( $success_url, $success_msg, $args ) {
1437
  $redirect_msg = '<div class="' . esc_attr( FrmFormsHelper::get_form_style_class( $args['form'] ) ) . '"><div class="frm-redirect-msg frm_message">' . $success_msg . '<br/>' .
1438
+ sprintf( __( '%1$sClick here%2$s if you are not automatically redirected.', 'formidable' ), '<a href="' . esc_url( $success_url ) . '">', '</a>' ) .
1439
  '</div></div>';
1440
 
1441
  return apply_filters( 'frm_redirect_msg', $redirect_msg, array(
1669
  private static function edit_in_place_value( $field ) {
1670
  _deprecated_function( __METHOD__, '3.0' );
1671
  check_ajax_referer( 'frm_ajax', 'nonce' );
1672
+ FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
1673
 
1674
  $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
1675
  $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_filter_post_kses' );
classes/controllers/FrmSettingsController.php CHANGED
@@ -46,7 +46,7 @@ class FrmSettingsController {
46
  }
47
 
48
  public static function load_settings_tab() {
49
- FrmAppHelper::permission_check('frm_change_settings');
50
  check_ajax_referer( 'frm_ajax', 'nonce' );
51
 
52
  $section = FrmAppHelper::get_post_param( 'tab', '', 'sanitize_text_field' );
46
  }
47
 
48
  public static function load_settings_tab() {
49
+ FrmAppHelper::permission_check( 'frm_change_settings' );
50
  check_ajax_referer( 'frm_ajax', 'nonce' );
51
 
52
  $section = FrmAppHelper::get_post_param( 'tab', '', 'sanitize_text_field' );
classes/controllers/FrmStylesController.php CHANGED
@@ -58,11 +58,7 @@ class FrmStylesController {
58
  }
59
 
60
  wp_enqueue_script( 'jquery-ui-datepicker' );
61
-
62
- $version = FrmAppHelper::plugin_version();
63
- $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
64
- wp_enqueue_script( 'jquery-frm-themepicker', FrmAppHelper::plugin_url() . '/js/jquery/jquery-ui-themepicker' . $suffix . '.js', array( 'jquery' ), $version );
65
-
66
  wp_enqueue_style( 'frm-custom-theme', admin_url( 'admin-ajax.php?action=frmpro_css' ) );
67
 
68
  $style = apply_filters( 'frm_style_head', false );
@@ -365,13 +361,6 @@ class FrmStylesController {
365
  $defaults = $frm_style->get_defaults();
366
  $style = '';
367
 
368
- // remove the # from the colors
369
- foreach ( $_GET['frm_style_setting']['post_content'] as $k => $v ) {
370
- if ( ! is_array( $v ) && strpos( $v, '#' ) === 0 ) {
371
- $_GET['frm_style_setting']['post_content'][ $k ] = str_replace( '#', '', $v );
372
- }
373
- }
374
-
375
  echo '<style type="text/css">';
376
  include( FrmAppHelper::plugin_path() . '/css/_single_theme.css.php' );
377
  echo '</style>';
@@ -408,6 +397,9 @@ class FrmStylesController {
408
 
409
  public static function include_style_section( $atts, $sec ) {
410
  extract( $atts );
 
 
 
411
  $current_tab = FrmAppHelper::simple_get( 'page-tab', 'sanitize_title', 'default' );
412
  $file_name = FrmAppHelper::plugin_path() . '/classes/views/styles/_' . $sec['args'] . '.php';
413
 
58
  }
59
 
60
  wp_enqueue_script( 'jquery-ui-datepicker' );
61
+ wp_enqueue_style( 'wp-color-picker' );
 
 
 
 
62
  wp_enqueue_style( 'frm-custom-theme', admin_url( 'admin-ajax.php?action=frmpro_css' ) );
63
 
64
  $style = apply_filters( 'frm_style_head', false );
361
  $defaults = $frm_style->get_defaults();
362
  $style = '';
363
 
 
 
 
 
 
 
 
364
  echo '<style type="text/css">';
365
  include( FrmAppHelper::plugin_path() . '/css/_single_theme.css.php' );
366
  echo '</style>';
397
 
398
  public static function include_style_section( $atts, $sec ) {
399
  extract( $atts );
400
+ $style = $atts['style'];
401
+ FrmStylesHelper::prepare_color_output( $style->post_content, false );
402
+
403
  $current_tab = FrmAppHelper::simple_get( 'page-tab', 'sanitize_title', 'default' );
404
  $file_name = FrmAppHelper::plugin_path() . '/classes/views/styles/_' . $sec['args'] . '.php';
405
 
classes/helpers/FrmAppHelper.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- if ( ! defined('ABSPATH') ) {
3
  die( 'You are not allowed to call this page directly.' );
4
  }
5
 
@@ -11,7 +11,7 @@ class FrmAppHelper {
11
  /**
12
  * @since 2.0
13
  */
14
- public static $plug_version = '3.01';
15
 
16
  /**
17
  * @since 1.07.02
@@ -23,13 +23,13 @@ class FrmAppHelper {
23
  return self::$plug_version;
24
  }
25
 
26
- public static function plugin_folder() {
27
- return basename(self::plugin_path());
28
- }
29
 
30
- public static function plugin_path() {
31
- return dirname(dirname(dirname(__FILE__)));
32
- }
33
 
34
  public static function plugin_url() {
35
  //prevously FRM_URL constant
@@ -54,9 +54,9 @@ class FrmAppHelper {
54
  * @since 2.0
55
  * @return string
56
  */
57
- public static function site_name() {
58
- return get_option('blogname');
59
- }
60
 
61
  public static function make_affiliate_url( $url ) {
62
  $affiliate_id = self::get_affiliate();
@@ -79,13 +79,13 @@ class FrmAppHelper {
79
  * @param None
80
  * @return FrmSettings $frm_setings
81
  */
82
- public static function get_settings() {
83
- global $frm_settings;
84
- if ( empty($frm_settings) ) {
85
- $frm_settings = new FrmSettings();
86
- }
87
- return $frm_settings;
88
- }
89
 
90
  public static function get_menu_name() {
91
  $frm_settings = FrmAppHelper::get_settings();
@@ -100,9 +100,9 @@ class FrmAppHelper {
100
  return ! $frm_settings->no_ips;
101
  }
102
 
103
- public static function pro_is_installed() {
104
- return apply_filters('frm_pro_installed', false);
105
- }
106
 
107
  public static function is_formidable_admin() {
108
  $page = self::simple_get( 'page', 'sanitize_title' );
@@ -170,13 +170,13 @@ class FrmAppHelper {
170
 
171
  /**
172
  * Use the WP 4.7 wp_doing_ajax function
173
- * @sine 2.05.07
174
  */
175
  public static function wp_doing_ajax() {
176
  if ( function_exists( 'wp_doing_ajax' ) ) {
177
  $doing_ajax = wp_doing_ajax();
178
  } else {
179
- $doing_ajax = defined('DOING_AJAX') && DOING_AJAX;
180
  }
181
  return $doing_ajax;
182
  }
@@ -242,9 +242,9 @@ class FrmAppHelper {
242
  }
243
 
244
  foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
245
- $ip = trim($ip); // just to be safe
246
 
247
- if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
248
  return sanitize_text_field( $ip );
249
  }
250
  }
@@ -254,8 +254,8 @@ class FrmAppHelper {
254
  }
255
 
256
  public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
257
- if ( strpos($param, '[') ) {
258
- $params = explode('[', $param);
259
  $param = $params[0];
260
  }
261
 
@@ -275,15 +275,15 @@ class FrmAppHelper {
275
  }
276
 
277
  if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) {
278
- foreach ( $params as $k => $p ) {
279
- if ( ! $k || ! is_array($value) ) {
280
- continue;
281
- }
282
 
283
- $p = trim($p, ']');
284
- $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
285
- }
286
- }
287
 
288
  return $value;
289
  }
@@ -518,10 +518,10 @@ class FrmAppHelper {
518
  * Used when switching the action for a bulk action
519
  * @since 2.0
520
  */
521
- public static function remove_get_action() {
522
- if ( ! isset($_GET) ) {
523
- return;
524
- }
525
 
526
  $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
527
  if ( ! empty( $new_action ) ) {
@@ -637,10 +637,10 @@ class FrmAppHelper {
637
  $pages = self::get_pages();
638
  $selected = self::get_post_param( $field_name, $page_id, 'absint' );
639
  ?>
640
- <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown">
641
  <option value=""> </option>
642
  <?php foreach ( $pages as $page ) { ?>
643
- <option value="<?php echo esc_attr($page->ID); ?>" <?php selected( $selected, $page->ID ) ?>>
644
  <?php echo esc_html( $truncate ? self::truncate( $page->post_title, $truncate ) : $page->post_title ); ?>
645
  </option>
646
  <?php } ?>
@@ -649,7 +649,7 @@ class FrmAppHelper {
649
  }
650
 
651
  public static function post_edit_link( $post_id ) {
652
- $post = get_post($post_id);
653
  if ( $post ) {
654
  $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
655
  return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
@@ -659,7 +659,7 @@ class FrmAppHelper {
659
 
660
  public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
661
  ?>
662
- <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php echo ( 'multiple' === $multiple ) ? 'multiple="multiple"' : ''; ?> class="frm_multiselect">
663
  <?php self::roles_options( $capability ); ?>
664
  </select>
665
  <?php
@@ -667,7 +667,7 @@ class FrmAppHelper {
667
 
668
  public static function roles_options( $capability ) {
669
  global $frm_vars;
670
- if ( isset($frm_vars['editable_roles']) ) {
671
  $editable_roles = $frm_vars['editable_roles'];
672
  } else {
673
  $editable_roles = get_editable_roles();
@@ -677,9 +677,9 @@ class FrmAppHelper {
677
  foreach ( $editable_roles as $role => $details ) {
678
  $name = translate_user_role( $details['name'] );
679
  ?>
680
- <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option>
681
  <?php
682
- unset($role, $details);
683
  }
684
  }
685
 
@@ -735,16 +735,16 @@ class FrmAppHelper {
735
  public static function maybe_add_permissions() {
736
  self::force_capability( 'frm_view_entries' );
737
 
738
- if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
739
- return;
740
- }
741
 
742
  $user_id = get_current_user_id();
743
  $user = new WP_User( $user_id );
744
  $frm_roles = self::frm_capabilities();
745
  foreach ( $frm_roles as $frm_role => $frm_role_description ) {
746
  $user->add_cap( $frm_role );
747
- unset($frm_role, $frm_role_description);
748
  }
749
  }
750
 
@@ -769,12 +769,12 @@ class FrmAppHelper {
769
  * @param string $permission
770
  */
771
  public static function permission_check( $permission, $show_message = 'show' ) {
772
- $permission_error = self::permission_nonce_error($permission);
773
  if ( $permission_error !== false ) {
774
  if ( 'hide' == $show_message ) {
775
  $permission_error = '';
776
  }
777
- wp_die($permission_error);
778
  }
779
  }
780
 
@@ -791,7 +791,7 @@ class FrmAppHelper {
791
  }
792
 
793
  $error = false;
794
- if ( empty($nonce_name) ) {
795
  return $error;
796
  }
797
 
@@ -851,7 +851,7 @@ class FrmAppHelper {
851
  public static function array_flatten( $array, $keys = 'keep' ) {
852
  $return = array();
853
  foreach ( $array as $key => $value ) {
854
- if ( is_array($value) ) {
855
  $return = array_merge( $return, self::array_flatten( $value, $keys ) );
856
  } else {
857
  if ( $keys == 'keep' ) {
@@ -878,11 +878,11 @@ class FrmAppHelper {
878
  * @since 2.0
879
  */
880
  public static function use_wpautop( $content ) {
881
- if ( apply_filters('frm_use_wpautop', true) ) {
882
- $content = wpautop(str_replace( '<br>', '<br />', $content));
883
- }
884
- return $content;
885
- }
886
 
887
  public static function replace_quotes( $val ) {
888
  //Replace double quotes
@@ -898,7 +898,7 @@ class FrmAppHelper {
898
  */
899
  public static function jquery_ui_base_url() {
900
  $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' );
901
- $url = apply_filters('frm_jquery_ui_base_url', $url);
902
  return $url;
903
  }
904
 
@@ -929,7 +929,7 @@ class FrmAppHelper {
929
  }
930
 
931
  public static function get_user_id_param( $user_id ) {
932
- if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
933
  return $user_id;
934
  }
935
 
@@ -937,33 +937,33 @@ class FrmAppHelper {
937
  if ( $user_id == 'current' ) {
938
  $user_id = get_current_user_id();
939
  } else {
940
- if ( is_email($user_id) ) {
941
- $user = get_user_by('email', $user_id);
942
- } else {
943
- $user = get_user_by('login', $user_id);
944
- }
945
 
946
  if ( $user ) {
947
  $user_id = $user->ID;
948
  }
949
- unset($user);
950
  }
951
 
952
  return $user_id;
953
  }
954
 
955
  public static function get_file_contents( $filename, $atts = array() ) {
956
- if ( ! is_file($filename) ) {
957
- return false;
958
- }
959
 
960
- extract($atts);
961
- ob_start();
962
- include($filename);
963
- $contents = ob_get_contents();
964
- ob_end_clean();
965
- return $contents;
966
- }
967
 
968
  /**
969
  * @param string $table_name
@@ -975,16 +975,16 @@ class FrmAppHelper {
975
  $key = '';
976
 
977
  if ( ! empty( $name ) ) {
978
- $key = sanitize_key($name);
979
  }
980
 
981
  if ( empty( $key ) ) {
982
- $max_slug_value = pow(36, $num_chars);
983
  $min_slug_value = 37; // we want to have at least 2 characters in the slug
984
- $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
985
  }
986
 
987
- if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
988
  $key = $key . 'a';
989
  }
990
 
@@ -993,7 +993,7 @@ class FrmAppHelper {
993
  'ID !' => $id,
994
  ), $column );
995
 
996
- if ( $key_check || is_numeric($key_check) ) {
997
  $suffix = 2;
998
  do {
999
  $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
@@ -1018,9 +1018,9 @@ class FrmAppHelper {
1018
  return false;
1019
  }
1020
 
1021
- if ( empty($post_values) ) {
1022
- $post_values = stripslashes_deep($_POST);
1023
- }
1024
 
1025
  $values = array(
1026
  'id' => $record->id,
@@ -1028,14 +1028,14 @@ class FrmAppHelper {
1028
  );
1029
 
1030
  foreach ( array( 'name', 'description' ) as $var ) {
1031
- $default_val = isset($record->{$var}) ? $record->{$var} : '';
1032
  $values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
1033
- unset($var, $default_val);
1034
- }
1035
 
1036
- $values['description'] = self::use_wpautop($values['description']);
1037
 
1038
- self::fill_form_opts($record, $table, $post_values, $values);
1039
 
1040
  self::prepare_field_arrays( $fields, $record, $values, array_merge( $args, compact( 'default', 'post_values' ) ) );
1041
 
@@ -1051,7 +1051,7 @@ class FrmAppHelper {
1051
  private static function prepare_field_arrays( $fields, $record, array &$values, $args ) {
1052
  if ( ! empty( $fields ) ) {
1053
  foreach ( (array) $fields as $field ) {
1054
- $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
1055
  $args['parent_form_id'] = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
1056
  self::fill_field_defaults( $field, $record, $values, $args );
1057
  }
@@ -1064,8 +1064,8 @@ class FrmAppHelper {
1064
  if ( $args['default'] ) {
1065
  $meta_value = $field->default_value;
1066
  } else {
1067
- if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1068
- if ( ! isset($field->field_options['custom_field']) ) {
1069
  $field->field_options['custom_field'] = '';
1070
  }
1071
  $meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array(
@@ -1091,7 +1091,7 @@ class FrmAppHelper {
1091
 
1092
  FrmFieldsHelper::prepare_edit_front_field( $field_array, $field, $values['id'], $args );
1093
 
1094
- if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1095
  $field_array['unique_msg'] = '';
1096
  }
1097
 
@@ -1134,18 +1134,18 @@ class FrmAppHelper {
1134
  return;
1135
  }
1136
 
1137
- $values['form_name'] = isset($record->form_id) ? $form->name : '';
1138
  $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
1139
 
1140
- if ( ! is_array($form->options) ) {
1141
- return;
1142
- }
1143
 
1144
  foreach ( $form->options as $opt => $value ) {
1145
  $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1146
  }
1147
 
1148
- self::fill_form_defaults($post_values, $values);
1149
  }
1150
 
1151
  /**
@@ -1159,7 +1159,7 @@ class FrmAppHelper {
1159
  $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1160
  }
1161
 
1162
- unset($opt, $defaut);
1163
  }
1164
 
1165
  if ( ! isset( $values['custom_style'] ) ) {
@@ -1170,7 +1170,7 @@ class FrmAppHelper {
1170
  if ( ! isset( $values[ $h . '_html' ] ) ) {
1171
  $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1172
  }
1173
- unset($h);
1174
  }
1175
  }
1176
 
@@ -1197,9 +1197,9 @@ class FrmAppHelper {
1197
  }
1198
  ?>
1199
  <li>
1200
- <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['id']) ?>" >[<?php echo esc_attr( $args['id'] ) ?>]</a>
1201
- <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['key']) ?>" >[<?php echo esc_attr( self::truncate($args['key'], 10) ) ?>]</a>
1202
- <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr($args['id']) ?>" ><?php echo esc_attr( self::truncate($args['name'], 60) ) ?></a>
1203
  </li>
1204
  <?php
1205
  }
@@ -1228,18 +1228,18 @@ class FrmAppHelper {
1228
  foreach ( $words as $word ) {
1229
  $part = ( ( $sub != '' ) ? ' ' : '' ) . $word;
1230
  $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1231
- if ( $total_len > $length && str_word_count($sub) ) {
1232
  break;
1233
  }
1234
 
1235
  $sub .= $part;
1236
  $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1237
 
1238
- if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1239
  break;
1240
  }
1241
 
1242
- unset($total_len, $word);
1243
  }
1244
 
1245
  return $sub . ( ( $len < $original_len ) ? $continue : '' );
@@ -1255,17 +1255,17 @@ class FrmAppHelper {
1255
  }
1256
 
1257
  public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1258
- if ( empty($date) ) {
1259
  return $date;
1260
  }
1261
 
1262
- if ( empty($date_format) ) {
1263
- $date_format = get_option('date_format');
1264
- }
1265
 
1266
- if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1267
  $frmpro_settings = new FrmProSettings();
1268
- $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1269
  }
1270
 
1271
  $formatted = self::get_localized_date( $date_format, $date );
@@ -1280,7 +1280,7 @@ class FrmAppHelper {
1280
 
1281
  private static function add_time_to_date( $time_format, $date ) {
1282
  if ( empty( $time_format ) ) {
1283
- $time_format = get_option('time_format');
1284
  }
1285
 
1286
  $trimmed_format = trim( $time_format );
@@ -1384,21 +1384,21 @@ class FrmAppHelper {
1384
  public static function json_to_array( $json_vars ) {
1385
  $vars = array();
1386
  foreach ( $json_vars as $jv ) {
1387
- $jv_name = explode('[', $jv['name']);
1388
- $last = count($jv_name) - 1;
1389
- foreach ( $jv_name as $p => $n ) {
1390
- $name = trim($n, ']');
1391
- if ( ! isset($l1) ) {
1392
- $l1 = $name;
1393
- }
1394
 
1395
- if ( ! isset($l2) ) {
1396
- $l2 = $name;
1397
- }
1398
 
1399
- if ( ! isset($l3) ) {
1400
- $l3 = $name;
1401
- }
1402
 
1403
  $this_val = ( $p == $last ) ? $jv['value'] : array();
1404
 
@@ -1423,10 +1423,10 @@ class FrmAppHelper {
1423
  self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1424
  }
1425
 
1426
- unset($this_val, $n);
1427
  }
1428
 
1429
- unset($last, $jv);
1430
  }
1431
 
1432
  return $vars;
@@ -1536,17 +1536,17 @@ class FrmAppHelper {
1536
  }
1537
 
1538
  public static function maybe_json_decode( $string ) {
1539
- if ( is_array($string) ) {
1540
  return $string;
1541
  }
1542
 
1543
- $new_string = json_decode($string, true);
1544
- if ( function_exists('json_last_error') ) {
1545
  // php 5.3+
1546
  if ( json_last_error() == JSON_ERROR_NONE ) {
1547
  $string = $new_string;
1548
  }
1549
- } else if ( isset($new_string) ) {
1550
  // php < 5.3 fallback
1551
  $string = $new_string;
1552
  }
@@ -1562,11 +1562,11 @@ class FrmAppHelper {
1562
  public static function maybe_highlight_menu( $post_type ) {
1563
  global $post;
1564
 
1565
- if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1566
  return;
1567
  }
1568
 
1569
- if ( is_object($post) && $post->post_type != $post_type ) {
1570
  return;
1571
  }
1572
 
@@ -1619,6 +1619,7 @@ class FrmAppHelper {
1619
  'id' => __( 'ID', 'formidable' ),
1620
  'no_results' => __( 'No results match', 'formidable' ),
1621
  'file_spam' => __( 'That file looks like Spam.', 'formidable' ),
 
1622
  'empty_fields' => __( 'Please complete the preceding required fields before uploading a file.', 'formidable' ),
1623
  ) );
1624
 
@@ -1655,6 +1656,9 @@ class FrmAppHelper {
1655
  'private' => __( 'Private' ),
1656
  'jquery_ui_url' => self::jquery_ui_base_url(),
1657
  'no_licenses' => __( 'No new licenses were found', 'formidable' ),
 
 
 
1658
  'repeat_limit_min' => __( 'Please enter a Repeat Limit that is greater than 1.', 'formidable' ),
1659
  ) );
1660
  }
@@ -1670,11 +1674,11 @@ class FrmAppHelper {
1670
  $frm_version = self::plugin_version();
1671
 
1672
  // check if Formidable meets minimum requirements
1673
- if ( version_compare($frm_version, $min_version, '>=') ) {
1674
  return;
1675
  }
1676
 
1677
- $wp_list_table = _get_list_table('WP_Plugins_List_Table');
1678
  echo '<tr class="plugin-update-tr active"><th colspan="' . absint( $wp_list_table->get_column_count() ) . '" class="check-column plugin-update colspanchange"><div class="update-message">' .
1679
  __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1680
  '</div></td></tr>';
@@ -1756,8 +1760,8 @@ class FrmAppHelper {
1756
  $unset = array( 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', 'es-419', 'tr' );
1757
  }
1758
 
1759
- $locales = array_diff_key($locales, array_flip($unset));
1760
- $locales = apply_filters('frm_locales', $locales);
1761
 
1762
  return $locales;
1763
  }
1
  <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
  die( 'You are not allowed to call this page directly.' );
4
  }
5
 
11
  /**
12
  * @since 2.0
13
  */
14
+ public static $plug_version = '3.01.01';
15
 
16
  /**
17
  * @since 1.07.02
23
  return self::$plug_version;
24
  }
25
 
26
+ public static function plugin_folder() {
27
+ return basename( self::plugin_path() );
28
+ }
29
 
30
+ public static function plugin_path() {
31
+ return dirname( dirname( dirname( __FILE__ ) ) );
32
+ }
33
 
34
  public static function plugin_url() {
35
  //prevously FRM_URL constant
54
  * @since 2.0
55
  * @return string
56
  */
57
+ public static function site_name() {
58
+ return get_option( 'blogname' );
59
+ }
60
 
61
  public static function make_affiliate_url( $url ) {
62
  $affiliate_id = self::get_affiliate();
79
  * @param None
80
  * @return FrmSettings $frm_setings
81
  */
82
+ public static function get_settings() {
83
+ global $frm_settings;
84
+ if ( empty( $frm_settings ) ) {
85
+ $frm_settings = new FrmSettings();
86
+ }
87
+ return $frm_settings;
88
+ }
89
 
90
  public static function get_menu_name() {
91
  $frm_settings = FrmAppHelper::get_settings();
100
  return ! $frm_settings->no_ips;
101
  }
102
 
103
+ public static function pro_is_installed() {
104
+ return apply_filters( 'frm_pro_installed', false );
105
+ }
106
 
107
  public static function is_formidable_admin() {
108
  $page = self::simple_get( 'page', 'sanitize_title' );
170
 
171
  /**
172
  * Use the WP 4.7 wp_doing_ajax function
173
+ * @since 2.05.07
174
  */
175
  public static function wp_doing_ajax() {
176
  if ( function_exists( 'wp_doing_ajax' ) ) {
177
  $doing_ajax = wp_doing_ajax();
178
  } else {
179
+ $doing_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
180
  }
181
  return $doing_ajax;
182
  }
242
  }
243
 
244
  foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
245
+ $ip = trim( $ip ); // just to be safe
246
 
247
+ if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) {
248
  return sanitize_text_field( $ip );
249
  }
250
  }
254
  }
255
 
256
  public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
257
+ if ( strpos( $param, '[' ) ) {
258
+ $params = explode( '[', $param );
259
  $param = $params[0];
260
  }
261
 
275
  }
276
 
277
  if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) {
278
+ foreach ( $params as $k => $p ) {
279
+ if ( ! $k || ! is_array( $value ) ) {
280
+ continue;
281
+ }
282
 
283
+ $p = trim( $p, ']' );
284
+ $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
285
+ }
286
+ }
287
 
288
  return $value;
289
  }
518
  * Used when switching the action for a bulk action
519
  * @since 2.0
520
  */
521
+ public static function remove_get_action() {
522
+ if ( ! isset( $_GET ) ) {
523
+ return;
524
+ }
525
 
526
  $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
527
  if ( ! empty( $new_action ) ) {
637
  $pages = self::get_pages();
638
  $selected = self::get_post_param( $field_name, $page_id, 'absint' );
639
  ?>
640
+ <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown">
641
  <option value=""> </option>
642
  <?php foreach ( $pages as $page ) { ?>
643
+ <option value="<?php echo esc_attr( $page->ID ); ?>" <?php selected( $selected, $page->ID ); ?>>
644
  <?php echo esc_html( $truncate ? self::truncate( $page->post_title, $truncate ) : $page->post_title ); ?>
645
  </option>
646
  <?php } ?>
649
  }
650
 
651
  public static function post_edit_link( $post_id ) {
652
+ $post = get_post( $post_id );
653
  if ( $post ) {
654
  $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
655
  return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
659
 
660
  public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
661
  ?>
662
+ <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" <?php echo ( 'multiple' === $multiple ) ? 'multiple="multiple"' : ''; ?> class="frm_multiselect">
663
  <?php self::roles_options( $capability ); ?>
664
  </select>
665
  <?php
667
 
668
  public static function roles_options( $capability ) {
669
  global $frm_vars;
670
+ if ( isset( $frm_vars['editable_roles'] ) ) {
671
  $editable_roles = $frm_vars['editable_roles'];
672
  } else {
673
  $editable_roles = get_editable_roles();
677
  foreach ( $editable_roles as $role => $details ) {
678
  $name = translate_user_role( $details['name'] );
679
  ?>
680
+ <option value="<?php echo esc_attr( $role ); ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ); ?> </option>
681
  <?php
682
+ unset( $role, $details );
683
  }
684
  }
685
 
735
  public static function maybe_add_permissions() {
736
  self::force_capability( 'frm_view_entries' );
737
 
738
+ if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) {
739
+ return;
740
+ }
741
 
742
  $user_id = get_current_user_id();
743
  $user = new WP_User( $user_id );
744
  $frm_roles = self::frm_capabilities();
745
  foreach ( $frm_roles as $frm_role => $frm_role_description ) {
746
  $user->add_cap( $frm_role );
747
+ unset( $frm_role, $frm_role_description );
748
  }
749
  }
750
 
769
  * @param string $permission
770
  */
771
  public static function permission_check( $permission, $show_message = 'show' ) {
772
+ $permission_error = self::permission_nonce_error( $permission );
773
  if ( $permission_error !== false ) {
774
  if ( 'hide' == $show_message ) {
775
  $permission_error = '';
776
  }
777
+ wp_die( $permission_error );
778
  }
779
  }
780
 
791
  }
792
 
793
  $error = false;
794
+ if ( empty( $nonce_name ) ) {
795
  return $error;
796
  }
797
 
851
  public static function array_flatten( $array, $keys = 'keep' ) {
852
  $return = array();
853
  foreach ( $array as $key => $value ) {
854
+ if ( is_array( $value ) ) {
855
  $return = array_merge( $return, self::array_flatten( $value, $keys ) );
856
  } else {
857
  if ( $keys == 'keep' ) {
878
  * @since 2.0
879
  */
880
  public static function use_wpautop( $content ) {
881
+ if ( apply_filters( 'frm_use_wpautop', true ) ) {
882
+ $content = wpautop( str_replace( '<br>', '<br />', $content ) );
883
+ }
884
+ return $content;
885
+ }
886
 
887
  public static function replace_quotes( $val ) {
888
  //Replace double quotes
898
  */
899
  public static function jquery_ui_base_url() {
900
  $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' );
901
+ $url = apply_filters( 'frm_jquery_ui_base_url', $url );
902
  return $url;
903
  }
904
 
929
  }
930
 
931
  public static function get_user_id_param( $user_id ) {
932
+ if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) {
933
  return $user_id;
934
  }
935
 
937
  if ( $user_id == 'current' ) {
938
  $user_id = get_current_user_id();
939
  } else {
940
+ if ( is_email( $user_id ) ) {
941
+ $user = get_user_by( 'email', $user_id );
942
+ } else {
943
+ $user = get_user_by( 'login', $user_id );
944
+ }
945
 
946
  if ( $user ) {
947
  $user_id = $user->ID;
948
  }
949
+ unset( $user );
950
  }
951
 
952
  return $user_id;
953
  }
954
 
955
  public static function get_file_contents( $filename, $atts = array() ) {
956
+ if ( ! is_file( $filename ) ) {
957
+ return false;
958
+ }
959
 
960
+ extract( $atts );
961
+ ob_start();
962
+ include( $filename );
963
+ $contents = ob_get_contents();
964
+ ob_end_clean();
965
+ return $contents;
966
+ }
967
 
968
  /**
969
  * @param string $table_name
975
  $key = '';
976
 
977
  if ( ! empty( $name ) ) {
978
+ $key = sanitize_key( $name );
979
  }
980
 
981
  if ( empty( $key ) ) {
982
+ $max_slug_value = pow( 36, $num_chars );
983
  $min_slug_value = 37; // we want to have at least 2 characters in the slug
984
+ $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
985
  }
986
 
987
+ if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
988
  $key = $key . 'a';
989
  }
990
 
993
  'ID !' => $id,
994
  ), $column );
995
 
996
+ if ( $key_check || is_numeric( $key_check ) ) {
997
  $suffix = 2;
998
  do {
999
  $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
1018
  return false;
1019
  }
1020
 
1021
+ if ( empty( $post_values ) ) {
1022
+ $post_values = stripslashes_deep( $_POST );
1023
+ }
1024
 
1025
  $values = array(
1026
  'id' => $record->id,
1028
  );
1029
 
1030
  foreach ( array( 'name', 'description' ) as $var ) {
1031
+ $default_val = isset( $record->{$var} ) ? $record->{$var} : '';
1032
  $values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
1033
+ unset( $var, $default_val );
1034
+ }
1035
 
1036
+ $values['description'] = self::use_wpautop( $values['description'] );
1037
 
1038
+ self::fill_form_opts( $record, $table, $post_values, $values );
1039
 
1040
  self::prepare_field_arrays( $fields, $record, $values, array_merge( $args, compact( 'default', 'post_values' ) ) );
1041
 
1051
  private static function prepare_field_arrays( $fields, $record, array &$values, $args ) {
1052
  if ( ! empty( $fields ) ) {
1053
  foreach ( (array) $fields as $field ) {
1054
+ $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true );
1055
  $args['parent_form_id'] = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
1056
  self::fill_field_defaults( $field, $record, $values, $args );
1057
  }
1064
  if ( $args['default'] ) {
1065
  $meta_value = $field->default_value;
1066
  } else {
1067
+ if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) {
1068
+ if ( ! isset( $field->field_options['custom_field'] ) ) {
1069
  $field->field_options['custom_field'] = '';
1070
  }
1071
  $meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array(
1091
 
1092
  FrmFieldsHelper::prepare_edit_front_field( $field_array, $field, $values['id'], $args );
1093
 
1094
+ if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) {
1095
  $field_array['unique_msg'] = '';
1096
  }
1097
 
1134
  return;
1135
  }
1136
 
1137
+ $values['form_name'] = isset( $record->form_id ) ? $form->name : '';
1138
  $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
1139
 
1140
+ if ( ! is_array( $form->options ) ) {
1141
+ return;
1142
+ }
1143
 
1144
  foreach ( $form->options as $opt => $value ) {
1145
  $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1146
  }
1147
 
1148
+ self::fill_form_defaults( $post_values, $values );
1149
  }
1150
 
1151
  /**
1159
  $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1160
  }
1161
 
1162
+ unset( $opt, $default );
1163
  }
1164
 
1165
  if ( ! isset( $values['custom_style'] ) ) {
1170
  if ( ! isset( $values[ $h . '_html' ] ) ) {
1171
  $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1172
  }
1173
+ unset( $h );
1174
  }
1175
  }
1176
 
1197
  }
1198
  ?>
1199
  <li>
1200
+ <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr( $class ); ?>" data-code="<?php echo esc_attr( $args['id'] ); ?>" >[<?php echo esc_attr( $args['id'] ); ?>]</a>
1201
+ <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr( $class ); ?>" data-code="<?php echo esc_attr( $args['key'] ); ?>" >[<?php echo esc_attr( self::truncate( $args['key'], 10 ) ); ?>]</a>
1202
+ <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ); ?>" data-code="<?php echo esc_attr( $args['id'] ); ?>" ><?php echo esc_attr( self::truncate( $args['name'], 60 ) ); ?></a>
1203
  </li>
1204
  <?php
1205
  }
1228
  foreach ( $words as $word ) {
1229
  $part = ( ( $sub != '' ) ? ' ' : '' ) . $word;
1230
  $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1231
+ if ( $total_len > $length && str_word_count( $sub ) ) {
1232
  break;
1233
  }
1234
 
1235
  $sub .= $part;
1236
  $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1237
 
1238
+ if ( str_word_count( $sub ) > $minword && $total_len >= $length ) {
1239
  break;
1240
  }
1241
 
1242
+ unset( $total_len, $word );
1243
  }
1244
 
1245
  return $sub . ( ( $len < $original_len ) ? $continue : '' );
1255
  }
1256
 
1257
  public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1258
+ if ( empty( $date ) ) {
1259
  return $date;
1260
  }
1261
 
1262
+ if ( empty( $date_format ) ) {
1263
+ $date_format = get_option( 'date_format' );
1264
+ }
1265
 
1266
+ if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) {
1267
  $frmpro_settings = new FrmProSettings();
1268
+ $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' );
1269
  }
1270
 
1271
  $formatted = self::get_localized_date( $date_format, $date );
1280
 
1281
  private static function add_time_to_date( $time_format, $date ) {
1282
  if ( empty( $time_format ) ) {
1283
+ $time_format = get_option( 'time_format' );
1284
  }
1285
 
1286
  $trimmed_format = trim( $time_format );
1384
  public static function json_to_array( $json_vars ) {
1385
  $vars = array();
1386
  foreach ( $json_vars as $jv ) {
1387
+ $jv_name = explode( '[', $jv['name'] );
1388
+ $last = count( $jv_name ) - 1;
1389
+ foreach ( $jv_name as $p => $n ) {
1390
+ $name = trim( $n, ']' );
1391
+ if ( ! isset( $l1 ) ) {
1392
+ $l1 = $name;
1393
+ }
1394
 
1395
+ if ( ! isset( $l2 ) ) {
1396
+ $l2 = $name;
1397
+ }
1398
 
1399
+ if ( ! isset( $l3 ) ) {
1400
+ $l3 = $name;
1401
+ }
1402
 
1403
  $this_val = ( $p == $last ) ? $jv['value'] : array();
1404
 
1423
  self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1424
  }
1425
 
1426
+ unset( $this_val, $n );
1427
  }
1428
 
1429
+ unset( $last, $jv );
1430
  }
1431
 
1432
  return $vars;
1536
  }
1537
 
1538
  public static function maybe_json_decode( $string ) {
1539
+ if ( is_array( $string ) ) {
1540
  return $string;
1541
  }
1542
 
1543
+ $new_string = json_decode( $string, true );
1544
+ if ( function_exists( 'json_last_error' ) ) {
1545
  // php 5.3+
1546
  if ( json_last_error() == JSON_ERROR_NONE ) {
1547
  $string = $new_string;
1548
  }
1549
+ } elseif ( isset( $new_string ) ) {
1550
  // php < 5.3 fallback
1551
  $string = $new_string;
1552
  }
1562
  public static function maybe_highlight_menu( $post_type ) {
1563
  global $post;
1564
 
1565
+ if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) {
1566
  return;
1567
  }
1568
 
1569
+ if ( is_object( $post ) && $post->post_type != $post_type ) {
1570
  return;
1571
  }
1572
 
1619
  'id' => __( 'ID', 'formidable' ),
1620
  'no_results' => __( 'No results match', 'formidable' ),
1621
  'file_spam' => __( 'That file looks like Spam.', 'formidable' ),
1622
+ 'calc_error' => __( 'There is an error in the calculation in the field with key', 'formidable' ),
1623
  'empty_fields' => __( 'Please complete the preceding required fields before uploading a file.', 'formidable' ),
1624
  ) );
1625
 
1656
  'private' => __( 'Private' ),
1657
  'jquery_ui_url' => self::jquery_ui_base_url(),
1658
  'no_licenses' => __( 'No new licenses were found', 'formidable' ),
1659
+ 'unmatched_parens' => __( 'This calculation has at least one unmatched ( ) { } [ ].', 'formidable' ),
1660
+ 'view_shortcodes' => __( 'This calculation may have shortcodes that work in Views but not forms.', 'formidable' ),
1661
+ 'text_shortcodes' => __( 'This calculation may have shortcodes that work in text calculations but not numeric calculations.', 'formidable' ),
1662
  'repeat_limit_min' => __( 'Please enter a Repeat Limit that is greater than 1.', 'formidable' ),
1663
  ) );
1664
  }
1674
  $frm_version = self::plugin_version();
1675
 
1676
  // check if Formidable meets minimum requirements
1677
+ if ( version_compare( $frm_version, $min_version, '>=' ) ) {
1678
  return;
1679
  }
1680
 
1681
+ $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
1682
  echo '<tr class="plugin-update-tr active"><th colspan="' . absint( $wp_list_table->get_column_count() ) . '" class="check-column plugin-update colspanchange"><div class="update-message">' .
1683
  __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1684
  '</div></td></tr>';
1760
  $unset = array( 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', 'es-419', 'tr' );
1761
  }
1762
 
1763
+ $locales = array_diff_key( $locales, array_flip( $unset ) );
1764
+ $locales = apply_filters( 'frm_locales', $locales );
1765
 
1766
  return $locales;
1767
  }
classes/helpers/FrmEntriesHelper.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- if ( ! defined('ABSPATH') ) {
3
  die( 'You are not allowed to call this page directly.' );
4
  }
5
 
@@ -13,9 +13,9 @@ class FrmEntriesHelper {
13
  );
14
 
15
  $values['fields'] = array();
16
- if ( empty($fields) ) {
17
- return apply_filters('frm_setup_new_entry', $values);
18
- }
19
 
20
  foreach ( (array) $fields as $field ) {
21
  $original_default = $field->default_value;
@@ -36,9 +36,9 @@ class FrmEntriesHelper {
36
 
37
  $values['fields'][] = $field_array;
38
 
39
- if ( ! $form || ! isset($form->id) ) {
40
- $form = FrmForm::getOne($field->form_id);
41
- }
42
  }
43
 
44
  $form->options = maybe_unserialize( $form->options );
@@ -98,7 +98,7 @@ class FrmEntriesHelper {
98
  }
99
 
100
  if ( ! is_array( $new_value ) ) {
101
- $new_value = str_replace('"', '&quot;', $new_value);
102
  }
103
 
104
  return $new_value;
@@ -131,26 +131,26 @@ class FrmEntriesHelper {
131
  $values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' );
132
  $values['form_id'] = $record->form_id;
133
  $values['is_draft'] = $record->is_draft;
134
- return apply_filters('frm_setup_edit_entry_vars', $values, $record);
135
  }
136
 
137
  public static function replace_default_message( $message, $atts ) {
138
- if ( strpos($message, '[default-message') === false &&
139
- strpos($message, '[default_message') === false &&
140
  ! empty( $message ) ) {
141
  return $message;
142
  }
143
 
144
- if ( empty($message) ) {
145
  $message = '[default-message]';
146
  }
147
 
148
- preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER);
149
 
150
  foreach ( $shortcodes[0] as $short_key => $tag ) {
151
  $add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
152
  if ( ! empty( $add_atts ) ) {
153
- $this_atts = array_merge($atts, $add_atts);
154
  } else {
155
  $this_atts = $atts;
156
  }
@@ -171,14 +171,14 @@ class FrmEntriesHelper {
171
  FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
172
  }
173
 
174
- if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) {
175
- return self::display_value($field_value, $field, $atts);
176
- }
177
 
178
  // this is an embeded form
179
  $val = '';
180
 
181
- if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
182
  //this is a repeating section
183
  $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) );
184
  } else {
@@ -192,7 +192,7 @@ class FrmEntriesHelper {
192
 
193
  $field_value = array();
194
 
195
- if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
196
  return $val;
197
  }
198
 
@@ -201,17 +201,17 @@ class FrmEntriesHelper {
201
  $atts['post_id'] = $child_entry->post_id;
202
 
203
  // get the value for this field -- check for post values as well
204
- $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
205
 
206
  if ( $entry_val ) {
207
  // foreach entry get display_value
208
- $field_value[] = self::display_value($entry_val, $field, $atts);
209
  }
210
 
211
- unset($child_entry);
212
  }
213
 
214
- $val = implode(', ', (array) $field_value );
215
  return FrmAppHelper::kses( $val, 'all' );
216
  }
217
 
@@ -246,22 +246,22 @@ class FrmEntriesHelper {
246
  $atts['html'] = true;
247
  }
248
 
249
- $atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
250
 
251
- if ( ! isset($field->field_options['post_field']) ) {
252
  $field->field_options['post_field'] = '';
253
  }
254
 
255
- if ( ! isset($field->field_options['custom_field']) ) {
256
  $field->field_options['custom_field'] = '';
257
  }
258
 
259
  if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
260
  $atts['pre_truncate'] = $atts['truncate'];
261
  $atts['truncate'] = true;
262
- $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
263
 
264
- $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
265
  $atts['truncate'] = $atts['pre_truncate'];
266
  }
267
 
@@ -270,7 +270,7 @@ class FrmEntriesHelper {
270
  }
271
 
272
  $unfiltered_value = maybe_unserialize( $value );
273
- $value = apply_filters('frm_display_value_custom', $unfiltered_value, $field, $atts);
274
  $value = apply_filters( 'frm_display_' . $field->type . '_value_custom', $value, compact( 'field', 'atts' ) );
275
 
276
  if ( $value == $unfiltered_value ) {
@@ -278,7 +278,7 @@ class FrmEntriesHelper {
278
  }
279
 
280
  if ( $atts['truncate'] && $atts['type'] != 'url' ) {
281
- $value = FrmAppHelper::truncate($value, 50);
282
  }
283
 
284
  if ( ! $atts['keepjs'] && ! is_array( $value ) ) {
@@ -293,7 +293,7 @@ class FrmEntriesHelper {
293
  if ( isset( $args['other'] ) && $args['other'] ) {
294
  $value = $args['temp_value'];
295
  }
296
- if ( empty($args['parent_field_id']) ) {
297
  $_POST['item_meta'][ $field->id ] = $value;
298
  } else {
299
  $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
@@ -303,7 +303,7 @@ class FrmEntriesHelper {
303
  public static function get_posted_value( $field, &$value, $args ) {
304
  $field_id = is_object( $field ) ? $field->id : $field;
305
 
306
- if ( empty($args['parent_field_id']) ) {
307
  $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
308
  } else {
309
  $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
@@ -395,7 +395,7 @@ class FrmEntriesHelper {
395
  }
396
  } else {
397
  // Radio and dropdowns
398
- $other_key = array_filter( array_keys($field->options), 'is_string');
399
  $other_key = reset( $other_key );
400
 
401
  // Multi-select dropdown
@@ -432,7 +432,7 @@ class FrmEntriesHelper {
432
  $content .= "\n\n";
433
  }
434
 
435
- if ( is_array($val) ) {
436
  $val = FrmAppHelper::array_flatten( $val );
437
  $val = implode( ', ', $val );
438
  }
@@ -496,7 +496,7 @@ class FrmEntriesHelper {
496
  preg_match_all( $pattern, $u_agent, $matches ); // get the matching numbers
497
 
498
  // see how many we have
499
- $i = count($matches['browser']);
500
 
501
  if ( $i > 1 ) {
502
  //we will have two since we are not using 'other' argument yet
1
  <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
  die( 'You are not allowed to call this page directly.' );
4
  }
5
 
13
  );
14
 
15
  $values['fields'] = array();
16
+ if ( empty( $fields ) ) {
17
+ return apply_filters( 'frm_setup_new_entry', $values );
18
+ }
19
 
20
  foreach ( (array) $fields as $field ) {
21
  $original_default = $field->default_value;
36
 
37
  $values['fields'][] = $field_array;
38
 
39
+ if ( ! $form || ! isset( $form->id ) ) {
40
+ $form = FrmForm::getOne( $field->form_id );
41
+ }
42
  }
43
 
44
  $form->options = maybe_unserialize( $form->options );
98
  }
99
 
100
  if ( ! is_array( $new_value ) ) {
101
+ $new_value = str_replace( '"', '&quot;', $new_value );
102
  }
103
 
104
  return $new_value;
131
  $values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' );
132
  $values['form_id'] = $record->form_id;
133
  $values['is_draft'] = $record->is_draft;
134
+ return apply_filters( 'frm_setup_edit_entry_vars', $values, $record );
135
  }
136
 
137
  public static function replace_default_message( $message, $atts ) {
138
+ if ( strpos( $message, '[default-message' ) === false &&
139
+ strpos( $message, '[default_message' ) === false &&
140
  ! empty( $message ) ) {
141
  return $message;
142
  }
143
 
144
+ if ( empty( $message ) ) {
145
  $message = '[default-message]';
146
  }
147
 
148
+ preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER );
149
 
150
  foreach ( $shortcodes[0] as $short_key => $tag ) {
151
  $add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
152
  if ( ! empty( $add_atts ) ) {
153
+ $this_atts = array_merge( $atts, $add_atts );
154
  } else {
155
  $this_atts = $atts;
156
  }
171
  FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
172
  }
173
 
174
+ if ( $field->form_id == $entry->form_id || empty( $atts['embedded_field_id'] ) ) {
175
+ return self::display_value( $field_value, $field, $atts );
176
+ }
177
 
178
  // this is an embeded form
179
  $val = '';
180
 
181
+ if ( strpos( $atts['embedded_field_id'], 'form' ) === 0 ) {
182
  //this is a repeating section
183
  $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) );
184
  } else {
192
 
193
  $field_value = array();
194
 
195
+ if ( ! isset( $child_entries ) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
196
  return $val;
197
  }
198
 
201
  $atts['post_id'] = $child_entry->post_id;
202
 
203
  // get the value for this field -- check for post values as well
204
+ $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value( $child_entry, $field );
205
 
206
  if ( $entry_val ) {
207
  // foreach entry get display_value
208
+ $field_value[] = self::display_value( $entry_val, $field, $atts );
209
  }
210
 
211
+ unset( $child_entry );
212
  }
213
 
214
+ $val = implode( ', ', (array) $field_value );
215
  return FrmAppHelper::kses( $val, 'all' );
216
  }
217
 
246
  $atts['html'] = true;
247
  }
248
 
249
+ $atts = apply_filters( 'frm_display_value_atts', $atts, $field, $value );
250
 
251
+ if ( ! isset( $field->field_options['post_field'] ) ) {
252
  $field->field_options['post_field'] = '';
253
  }
254
 
255
+ if ( ! isset( $field->field_options['custom_field'] ) ) {
256
  $field->field_options['custom_field'] = '';
257
  }
258
 
259
  if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
260
  $atts['pre_truncate'] = $atts['truncate'];
261
  $atts['truncate'] = true;
262
+ $atts['exclude_cat'] = isset( $field->field_options['exclude_cat'] ) ? $field->field_options['exclude_cat'] : 0;
263
 
264
+ $value = FrmProEntryMetaHelper::get_post_value( $atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts );
265
  $atts['truncate'] = $atts['pre_truncate'];
266
  }
267
 
270
  }
271
 
272
  $unfiltered_value = maybe_unserialize( $value );
273
+ $value = apply_filters( 'frm_display_value_custom', $unfiltered_value, $field, $atts );
274
  $value = apply_filters( 'frm_display_' . $field->type . '_value_custom', $value, compact( 'field', 'atts' ) );
275
 
276
  if ( $value == $unfiltered_value ) {
278
  }
279
 
280
  if ( $atts['truncate'] && $atts['type'] != 'url' ) {
281
+ $value = FrmAppHelper::truncate( $value, 50 );
282
  }
283
 
284
  if ( ! $atts['keepjs'] && ! is_array( $value ) ) {
293
  if ( isset( $args['other'] ) && $args['other'] ) {
294
  $value = $args['temp_value'];
295
  }
296
+ if ( empty( $args['parent_field_id'] ) ) {
297
  $_POST['item_meta'][ $field->id ] = $value;
298
  } else {
299
  $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
303
  public static function get_posted_value( $field, &$value, $args ) {
304
  $field_id = is_object( $field ) ? $field->id : $field;
305
 
306
+ if ( empty( $args['parent_field_id'] ) ) {
307
  $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
308
  } else {
309
  $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
395
  }
396
  } else {
397
  // Radio and dropdowns
398
+ $other_key = array_filter( array_keys( $field->options ), 'is_string' );
399
  $other_key = reset( $other_key );
400
 
401
  // Multi-select dropdown
432
  $content .= "\n\n";
433
  }
434
 
435
+ if ( is_array( $val ) ) {
436
  $val = FrmAppHelper::array_flatten( $val );
437
  $val = implode( ', ', $val );
438
  }
496
  preg_match_all( $pattern, $u_agent, $matches ); // get the matching numbers
497
 
498
  // see how many we have
499
+ $i = count( $matches['browser'] );
500
 
501
  if ( $i > 1 ) {
502
  //we will have two since we are not using 'other' argument yet
classes/helpers/FrmEntriesListHelper.php CHANGED
@@ -61,7 +61,7 @@ class FrmEntriesListHelper extends FrmListHelper {
61
 
62
  $limit = FrmDb::esc_limit( $start . ',' . $per_page );
63
  $this->items = FrmEntry::getAll( $s_query, $order, $limit, true, $join_form_in_query );
64
- $total_items = FrmEntry::getRecordCount($s_query);
65
 
66
  $this->set_pagination_args( array(
67
  'total_items' => $total_items,
@@ -74,7 +74,7 @@ class FrmEntriesListHelper extends FrmListHelper {
74
  'param' => 's',
75
  'sanitize' => 'sanitize_text_field',
76
  ) );
77
- if ( ! empty($s) ) {
78
  esc_html_e( 'No Entries Found', 'formidable' );
79
  return;
80
  }
@@ -83,7 +83,7 @@ class FrmEntriesListHelper extends FrmListHelper {
83
  $form = $this->params['form'];
84
 
85
  if ( $form_id ) {
86
- $form = FrmForm::getOne($form_id);
87
  }
88
  $colspan = $this->get_column_count();
89
 
@@ -158,7 +158,7 @@ class FrmEntriesListHelper extends FrmListHelper {
158
  }
159
 
160
  $attributes = 'class="' . esc_attr( $class ) . '"';
161
- unset($class);
162
  $attributes .= ' data-colname="' . $column_display_name . '"';
163
 
164
  $form_id = $this->params['form'] ? $this->params['form'] : 0;
@@ -183,7 +183,7 @@ class FrmEntriesListHelper extends FrmListHelper {
183
  }
184
  $r .= '</td>';
185
  }
186
- unset($val);
187
  }
188
  $r .= '</tr>';
189
 
@@ -240,12 +240,12 @@ class FrmEntriesListHelper extends FrmListHelper {
240
  private function get_actions( &$actions, $item, $view_link ) {
241
  $actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>';
242
 
243
- if ( current_user_can('frm_delete_entries') ) {
244
  $delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form'];
245
  $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" data-frmverify="' . esc_attr__( 'Are you sure?', 'formidable' ) . '">' . __( 'Delete' ) . '</a>';
246
  }
247
 
248
- $actions = apply_filters('frm_row_actions', $actions, $item);
249
  }
250
 
251
  private function get_column_value( $item, &$val ) {
61
 
62
  $limit = FrmDb::esc_limit( $start . ',' . $per_page );
63
  $this->items = FrmEntry::getAll( $s_query, $order, $limit, true, $join_form_in_query );
64
+ $total_items = FrmEntry::getRecordCount( $s_query );
65
 
66
  $this->set_pagination_args( array(
67
  'total_items' => $total_items,
74
  'param' => 's',
75
  'sanitize' => 'sanitize_text_field',
76
  ) );
77
+ if ( ! empty( $s ) ) {
78
  esc_html_e( 'No Entries Found', 'formidable' );
79
  return;
80
  }
83
  $form = $this->params['form'];
84
 
85
  if ( $form_id ) {
86
+ $form = FrmForm::getOne( $form_id );
87
  }
88
  $colspan = $this->get_column_count();
89
 
158
  }
159
 
160
  $attributes = 'class="' . esc_attr( $class ) . '"';
161
+ unset( $class );
162
  $attributes .= ' data-colname="' . $column_display_name . '"';
163
 
164
  $form_id = $this->params['form'] ? $this->params['form'] : 0;
183
  }
184
  $r .= '</td>';
185
  }
186
+ unset( $val );
187
  }
188
  $r .= '</tr>';
189
 
240
  private function get_actions( &$actions, $item, $view_link ) {
241
  $actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>';
242
 
243
+ if ( current_user_can( 'frm_delete_entries' ) ) {
244
  $delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form'];
245
  $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" data-frmverify="' . esc_attr__( 'Are you sure?', 'formidable' ) . '">' . __( 'Delete' ) . '</a>';
246
  }
247
 
248
+ $actions = apply_filters( 'frm_row_actions', $actions, $item );
249
  }
250
 
251
  private function get_column_value( $item, &$val ) {
classes/helpers/FrmFieldsHelper.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- if ( ! defined('ABSPATH') ) {
3
  die( 'You are not allowed to call this page directly.' );
4
  }
5
 
@@ -7,9 +7,9 @@ class FrmFieldsHelper {
7
 
8
  public static function setup_new_vars( $type = '', $form_id = '' ) {
9
 
10
- if ( strpos($type, '|') ) {
11
- list($type, $setting) = explode('|', $type);
12
- }
13
 
14
  $values = self::get_default_field( $type );
15
 
@@ -244,8 +244,8 @@ class FrmFieldsHelper {
244
 
245
  $values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' );
246
  $values['form_id'] = $form_id;
247
- $values['options'] = maybe_serialize($field->options);
248
- $values['default_value'] = maybe_serialize($field->default_value);
249
 
250
  foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
251
  $values[ $col ] = $field->{$col};
@@ -269,11 +269,11 @@ class FrmFieldsHelper {
269
  $defaults = array(
270
  'unique_msg' => array(
271
  'full' => $default_settings['unique_msg'],
272
- 'part' => sprintf( __('%s must be unique', 'formidable' ), $field_name ),
273
  ),
274
  'invalid' => array(
275
  'full' => __( 'This field is invalid', 'formidable' ),
276
- 'part' => sprintf( __('%s is invalid', 'formidable' ), $field_name ),
277
  ),
278
  'blank' => array(
279
  'full' => $frm_settings->blank_msg,
@@ -305,7 +305,7 @@ class FrmFieldsHelper {
305
  $default_html = apply_filters( 'frm_other_custom_html', '', $type );
306
  }
307
 
308
- return apply_filters('frm_custom_html', $default_html, $type);
309
  }
310
 
311
  /**
@@ -439,7 +439,7 @@ class FrmFieldsHelper {
439
  // Get string for Other text field, if needed
440
  $other_val = self::get_other_val( compact( 'opt_key', 'field' ) );
441
 
442
- $checked = ( $other_val || isset( $field['value'] ) && ( ( ! is_array( $field['value'] ) && $field['value'] == $field_val ) || ( is_array($field['value'] ) && in_array( $field_val, $field['value'] ) ) ) ) ? ' checked="checked"' : '';
443
 
444
  // If this is an "Other" option, get the HTML for it
445
  if ( self::is_other_opt( $opt_key ) ) {
@@ -470,7 +470,7 @@ class FrmFieldsHelper {
470
  * @return string
471
  */
472
  public static function get_term_link( $tax_id ) {
473
- $tax = get_taxonomy($tax_id);
474
  if ( ! $tax ) {
475
  return '';
476
  }
@@ -479,7 +479,7 @@ class FrmFieldsHelper {
479
  __( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
480
  '<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>'
481
  );
482
- unset($tax);
483
 
484
  return $link;
485
  }
@@ -488,27 +488,31 @@ class FrmFieldsHelper {
488
  $hide_opt = self::get_value_for_comparision( $hide_opt );
489
  $observed_value = self::get_value_for_comparision( $observed_value );
490
 
491
- if ( is_array($observed_value) ) {
492
- return self::array_value_condition($observed_value, $cond, $hide_opt);
493
  }
494
 
495
  $m = false;
496
- if ( $cond == '==' ) {
497
- $m = $observed_value == $hide_opt;
498
- } else if ( $cond == '!=' ) {
499
- $m = $observed_value != $hide_opt;
500
- } else if ( $cond == '>' ) {
501
- $m = $observed_value > $hide_opt;
502
- } else if ( $cond == '<' ) {
503
- $m = $observed_value < $hide_opt;
504
- } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
505
- $m = stripos($observed_value, $hide_opt);
506
- if ( $cond == 'not LIKE' ) {
507
- $m = ( $m === false ) ? true : false;
508
- } else {
509
- $m = ( $m === false ) ? false : true;
510
- }
511
- }
 
 
 
 
512
  return $m;
513
  }
514
 
@@ -528,28 +532,28 @@ class FrmFieldsHelper {
528
  public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
529
  $m = false;
530
  if ( $cond == '==' ) {
531
- if ( is_array($hide_opt) ) {
532
- $m = array_intersect($hide_opt, $observed_value);
533
- $m = empty($m) ? false : true;
534
- } else {
535
- $m = in_array($hide_opt, $observed_value);
536
- }
537
- } else if ( $cond == '!=' ) {
538
- $m = ! in_array($hide_opt, $observed_value);
539
- } else if ( $cond == '>' ) {
540
- $min = min($observed_value);
541
- $m = $min > $hide_opt;
542
- } else if ( $cond == '<' ) {
543
- $max = max($observed_value);
544
- $m = $max < $hide_opt;
545
- } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
546
- foreach ( $observed_value as $ob ) {
547
- $m = strpos($ob, $hide_opt);
548
- if ( $m !== false ) {
549
- $m = true;
550
- break;
551
- }
552
- }
553
 
554
  if ( $cond == 'not LIKE' ) {
555
  $m = ( $m === false ) ? true : false;
@@ -565,20 +569,20 @@ class FrmFieldsHelper {
565
  * @return string
566
  */
567
  public static function basic_replace_shortcodes( $value, $form, $entry ) {
568
- if ( strpos($value, '[sitename]') !== false ) {
569
  $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
570
- $value = str_replace('[sitename]', $new_value, $value);
571
  }
572
 
573
- $value = apply_filters('frm_content', $value, $form, $entry);
574
- $value = do_shortcode($value);
575
 
576
  return $value;
577
  }
578
 
579
  public static function get_shortcodes( $content, $form_id ) {
580
  if ( FrmAppHelper::pro_is_installed() ) {
581
- return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
582
  }
583
 
584
  $fields = FrmField::getAll( array(
@@ -586,9 +590,9 @@ class FrmFieldsHelper {
586
  'fi.type not' => FrmField::no_save_fields(),
587
  ) );
588
 
589
- $tagregexp = self::allowed_shortcodes($fields);
590
 
591
- preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
592
 
593
  return $matches;
594
  }
@@ -601,7 +605,7 @@ class FrmFieldsHelper {
601
  $tagregexp[] = $field->field_key;
602
  }
603
 
604
- $tagregexp = implode('|', $tagregexp);
605
  return $tagregexp;
606
  }
607
 
@@ -619,6 +623,7 @@ class FrmFieldsHelper {
619
  $replace_with = self::get_value_for_shortcode( $atts );
620
 
621
  if ( $replace_with !== null ) {
 
622
  $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
623
  }
624
 
@@ -676,7 +681,7 @@ class FrmFieldsHelper {
676
  if ( isset( $atts['format'] ) ) {
677
  $time_format = ' ';
678
  } else {
679
- $atts['format'] = get_option('date_format');
680
  $time_format = '';
681
  }
682
 
@@ -730,7 +735,7 @@ class FrmFieldsHelper {
730
  $new_value = '';
731
  switch ( $tag ) {
732
  case 'admin_email':
733
- $new_value = get_option('admin_email');
734
  break;
735
  case 'siteurl':
736
  $new_value = FrmAppHelper::site_url();
@@ -755,29 +760,29 @@ class FrmFieldsHelper {
755
  * @return string|array
756
  */
757
  public static function process_get_shortcode( $atts, $return_array = false ) {
758
- if ( ! isset($atts['param']) ) {
759
  return '';
760
  }
761
 
762
- if ( strpos($atts['param'], '&#91;') ) {
763
- $atts['param'] = str_replace('&#91;', '[', $atts['param']);
764
- $atts['param'] = str_replace('&#93;', ']', $atts['param']);
765
- }
766
 
767
  $new_value = FrmAppHelper::get_param( $atts['param'], '', 'get', 'sanitize_text_field' );
768
  $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
769
 
770
  if ( $new_value == '' ) {
771
- if ( ! isset($atts['prev_val']) ) {
772
  $atts['prev_val'] = '';
773
  }
774
 
775
- $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
776
  }
777
 
778
- if ( is_array($new_value) && ! $return_array ) {
779
- $new_value = implode(', ', $new_value);
780
- }
781
 
782
  return $new_value;
783
  }
@@ -817,9 +822,9 @@ class FrmFieldsHelper {
817
  'size' => 96,
818
  );
819
 
820
- $args = wp_parse_args($args, $defaults);
821
 
822
- $user = get_userdata($user_id);
823
  $info = '';
824
 
825
  if ( $user ) {
@@ -828,7 +833,7 @@ class FrmFieldsHelper {
828
  } elseif ( $user_info == 'author_link' ) {
829
  $info = get_author_posts_url( $user_id );
830
  } else {
831
- $info = isset($user->$user_info) ? $user->$user_info : '';
832
  }
833
 
834
  if ( 'display_name' === $user_info && empty( $info ) && ! $args['blank'] ) {
@@ -837,7 +842,7 @@ class FrmFieldsHelper {
837
  }
838
 
839
  if ( $args['link'] ) {
840
- $info = '<a href="' . esc_url( admin_url('user-edit.php?user_id=' . $user_id ) ) . '">' . $info . '</a>';
841
  }
842
 
843
  return $info;
@@ -851,13 +856,13 @@ class FrmFieldsHelper {
851
  $field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() );
852
 
853
  $field_types = array();
854
- if ( in_array($type, $single_input) ) {
855
  self::field_types_for_input( $single_input, $field_selection, $field_types );
856
- } else if ( in_array($type, $multiple_input) ) {
857
  self::field_types_for_input( $multiple_input, $field_selection, $field_types );
858
- } else if ( in_array($type, $other_type) ) {
859
  self::field_types_for_input( $other_type, $field_selection, $field_types );
860
- } else if ( isset( $field_selection[ $type ] ) ) {
861
  $field_types[ $type ] = $field_selection[ $type ];
862
  }
863
 
@@ -868,7 +873,7 @@ class FrmFieldsHelper {
868
  private static function field_types_for_input( $inputs, $fields, &$field_types ) {
869
  foreach ( $inputs as $input ) {
870
  $field_types[ $input ] = $fields[ $input ];
871
- unset($input);
872
  }
873
  }
874
 
@@ -1009,7 +1014,7 @@ class FrmFieldsHelper {
1009
  private static function set_other_name( $args, &$other_args ) {
1010
  //Set up name for other field
1011
  $other_args['name'] = str_replace( '[]', '', $args['field_name'] );
1012
- $other_args['name'] = preg_replace('/\[' . $args['field']['id'] . '\]$/', '', $other_args['name']);
1013
  $other_args['name'] = $other_args['name'] . '[other]' . '[' . $args['field']['id'] . ']';
1014
 
1015
  //Converts item_meta[field_id] => item_meta[other][field_id] and
@@ -1036,7 +1041,7 @@ class FrmFieldsHelper {
1036
  // Count should only be greater than 3 if inside of a repeating section
1037
  if ( count( $temp_array ) > 3 ) {
1038
  $parent = str_replace( ']', '', $temp_array[1] );
1039
- $pointer = str_replace( ']', '', $temp_array[2]);
1040
  }
1041
 
1042
  // Get text for "other" text field
@@ -1170,15 +1175,15 @@ class FrmFieldsHelper {
1170
  $replace_with[] = '[' . $new . ']';
1171
  $replace[] = '[' . $old . ' ';
1172
  $replace_with[] = '[' . $new . ' ';
1173
- unset($old, $new);
1174
  }
1175
  if ( is_array( $val ) ) {
1176
  foreach ( $val as $k => $v ) {
1177
  $val[ $k ] = str_replace( $replace, $replace_with, $v );
1178
- unset($k, $v);
1179
  }
1180
  } else {
1181
- $val = str_replace($replace, $replace_with, $val);
1182
  }
1183
 
1184
  return $val;
@@ -1248,14 +1253,14 @@ class FrmFieldsHelper {
1248
  $prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1249
 
1250
  $states = FrmFieldsHelper::get_us_states();
1251
- $state_abv = array_keys($states);
1252
- sort($state_abv);
1253
  $prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1254
 
1255
- $states = array_values($states);
1256
- sort($states);
1257
  $prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1258
- unset($state_abv, $states);
1259
 
1260
  $prepop[ __( 'Age', 'formidable' ) ] = array(
1261
  __( 'Under 18', 'formidable' ),
1
  <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
  die( 'You are not allowed to call this page directly.' );
4
  }
5
 
7
 
8
  public static function setup_new_vars( $type = '', $form_id = '' ) {
9
 
10
+ if ( strpos( $type, '|' ) ) {
11
+ list( $type, $setting ) = explode( '|', $type );
12
+ }
13
 
14
  $values = self::get_default_field( $type );
15
 
244
 
245
  $values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' );
246
  $values['form_id'] = $form_id;
247
+ $values['options'] = maybe_serialize( $field->options );
248
+ $values['default_value'] = maybe_serialize( $field->default_value );
249
 
250
  foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
251
  $values[ $col ] = $field->{$col};
269
  $defaults = array(
270
  'unique_msg' => array(
271
  'full' => $default_settings['unique_msg'],
272
+ 'part' => sprintf( __( '%s must be unique', 'formidable' ), $field_name ),
273
  ),
274
  'invalid' => array(
275
  'full' => __( 'This field is invalid', 'formidable' ),
276
+ 'part' => sprintf( __( '%s is invalid', 'formidable' ), $field_name ),
277
  ),
278
  'blank' => array(
279
  'full' => $frm_settings->blank_msg,
305
  $default_html = apply_filters( 'frm_other_custom_html', '', $type );
306
  }
307
 
308
+ return apply_filters( 'frm_custom_html', $default_html, $type );
309
  }
310
 
311
  /**
439
  // Get string for Other text field, if needed
440
  $other_val = self::get_other_val( compact( 'opt_key', 'field' ) );
441
 
442
+ $checked = ( $other_val || isset( $field['value'] ) && ( ( ! is_array( $field['value'] ) && $field['value'] == $field_val ) || ( is_array( $field['value'] ) && in_array( $field_val, $field['value'] ) ) ) ) ? ' checked="checked"' : '';
443
 
444
  // If this is an "Other" option, get the HTML for it
445
  if ( self::is_other_opt( $opt_key ) ) {
470
  * @return string
471
  */
472
  public static function get_term_link( $tax_id ) {
473
+ $tax = get_taxonomy( $tax_id );
474
  if ( ! $tax ) {
475
  return '';
476
  }
479
  __( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
480
  '<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>'
481
  );
482
+ unset( $tax );
483
 
484
  return $link;
485
  }
488
  $hide_opt = self::get_value_for_comparision( $hide_opt );
489
  $observed_value = self::get_value_for_comparision( $observed_value );
490
 
491
+ if ( is_array( $observed_value ) ) {
492
+ return self::array_value_condition( $observed_value, $cond, $hide_opt );
493
  }
494
 
495
  $m = false;
496
+ if ( $cond == '==' ) {
497
+ $m = $observed_value == $hide_opt;
498
+ } elseif ( $cond == '!=' ) {
499
+ $m = $observed_value != $hide_opt;
500
+ } elseif ( $cond == '>' ) {
501
+ $m = $observed_value > $hide_opt;
502
+ } elseif ( $cond == '>=' ) {
503
+ $m = $observed_value >= $hide_opt;
504
+ } elseif ( $cond == '<' ) {
505
+ $m = $observed_value < $hide_opt;
506
+ } elseif ( $cond == '<=' ) {
507
+ $m = $observed_value <= $hide_opt;
508
+ } elseif ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
509
+ $m = stripos( $observed_value, $hide_opt );
510
+ if ( $cond == 'not LIKE' ) {
511
+ $m = ( $m === false ) ? true : false;
512
+ } else {
513
+ $m = ( $m === false ) ? false : true;
514
+ }
515
+ }
516
  return $m;
517
  }
518
 
532
  public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
533
  $m = false;
534
  if ( $cond == '==' ) {
535
+ if ( is_array( $hide_opt ) ) {
536
+ $m = array_intersect( $hide_opt, $observed_value );
537
+ $m = empty( $m ) ? false : true;
538
+ } else {
539
+ $m = in_array( $hide_opt, $observed_value );
540
+ }
541
+ } elseif ( $cond == '!=' ) {
542
+ $m = ! in_array( $hide_opt, $observed_value );
543
+ } elseif ( $cond == '>' ) {
544
+ $min = min( $observed_value );
545
+ $m = $min > $hide_opt;
546
+ } elseif ( $cond == '<' ) {
547
+ $max = max( $observed_value );
548
+ $m = $max < $hide_opt;
549
+ } elseif ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
550
+ foreach ( $observed_value as $ob ) {
551
+ $m = strpos( $ob, $hide_opt );
552
+ if ( $m !== false ) {
553
+ $m = true;
554
+ break;
555
+ }
556
+ }
557
 
558
  if ( $cond == 'not LIKE' ) {
559
  $m = ( $m === false ) ? true : false;
569
  * @return string
570
  */
571
  public static function basic_replace_shortcodes( $value, $form, $entry ) {
572
+ if ( strpos( $value, '[sitename]' ) !== false ) {
573
  $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
574
+ $value = str_replace( '[sitename]', $new_value, $value );
575
  }
576
 
577
+ $value = apply_filters( 'frm_content', $value, $form, $entry );
578
+ $value = do_shortcode( $value );
579
 
580
  return $value;
581
  }
582
 
583
  public static function get_shortcodes( $content, $form_id ) {
584
  if ( FrmAppHelper::pro_is_installed() ) {
585
+ return FrmProDisplaysHelper::get_shortcodes( $content, $form_id );
586
  }
587
 
588
  $fields = FrmField::getAll( array(
590
  'fi.type not' => FrmField::no_save_fields(),
591
  ) );
592
 
593
+ $tagregexp = self::allowed_shortcodes( $fields );
594
 
595
+ preg_match_all( "/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER );
596
 
597
  return $matches;
598
  }
605
  $tagregexp[] = $field->field_key;
606
  }
607
 
608
+ $tagregexp = implode( '|', $tagregexp );
609
  return $tagregexp;
610
  }
611
 
623
  $replace_with = self::get_value_for_shortcode( $atts );
624
 
625
  if ( $replace_with !== null ) {
626
+ $replace_with = str_replace( '[', '&#91;', $replace_with ); // prevent shortcodes in fields from being processed
627
  $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
628
  }
629
 
681
  if ( isset( $atts['format'] ) ) {
682
  $time_format = ' ';
683
  } else {
684
+ $atts['format'] = get_option( 'date_format' );
685
  $time_format = '';
686
  }
687
 
735
  $new_value = '';
736
  switch ( $tag ) {
737
  case 'admin_email':
738
+ $new_value = get_option( 'admin_email' );
739
  break;
740
  case 'siteurl':
741
  $new_value = FrmAppHelper::site_url();
760
  * @return string|array
761
  */
762
  public static function process_get_shortcode( $atts, $return_array = false ) {
763
+ if ( ! isset( $atts['param'] ) ) {
764
  return '';
765
  }
766
 
767
+ if ( strpos( $atts['param'], '&#91;' ) ) {
768
+ $atts['param'] = str_replace( '&#91;', '[', $atts['param'] );
769
+ $atts['param'] = str_replace( '&#93;', ']', $atts['param'] );
770
+ }
771
 
772
  $new_value = FrmAppHelper::get_param( $atts['param'], '', 'get', 'sanitize_text_field' );
773
  $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
774
 
775
  if ( $new_value == '' ) {
776
+ if ( ! isset( $atts['prev_val'] ) ) {
777
  $atts['prev_val'] = '';
778
  }
779
 
780
+ $new_value = isset( $atts['default'] ) ? $atts['default'] : $atts['prev_val'];
781
  }
782
 
783
+ if ( is_array( $new_value ) && ! $return_array ) {
784
+ $new_value = implode( ', ', $new_value );
785
+ }
786
 
787
  return $new_value;
788
  }
822
  'size' => 96,
823
  );
824
 
825
+ $args = wp_parse_args( $args, $defaults );
826
 
827
+ $user = get_userdata( $user_id );
828
  $info = '';
829
 
830
  if ( $user ) {
833
  } elseif ( $user_info == 'author_link' ) {
834
  $info = get_author_posts_url( $user_id );
835
  } else {
836
+ $info = isset( $user->$user_info ) ? $user->$user_info : '';
837
  }
838
 
839
  if ( 'display_name' === $user_info && empty( $info ) && ! $args['blank'] ) {
842
  }
843
 
844
  if ( $args['link'] ) {
845
+ $info = '<a href="' . esc_url( admin_url( 'user-edit.php?user_id=' . $user_id ) ) . '">' . $info . '</a>';
846
  }
847
 
848
  return $info;
856
  $field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() );
857
 
858
  $field_types = array();
859
+ if ( in_array( $type, $single_input ) ) {
860
  self::field_types_for_input( $single_input, $field_selection, $field_types );
861
+ } elseif ( in_array( $type, $multiple_input ) ) {
862
  self::field_types_for_input( $multiple_input, $field_selection, $field_types );
863
+ } elseif ( in_array( $type, $other_type ) ) {
864
  self::field_types_for_input( $other_type, $field_selection, $field_types );
865
+ } elseif ( isset( $field_selection[ $type ] ) ) {
866
  $field_types[ $type ] = $field_selection[ $type ];
867
  }
868
 
873
  private static function field_types_for_input( $inputs, $fields, &$field_types ) {
874
  foreach ( $inputs as $input ) {
875
  $field_types[ $input ] = $fields[ $input ];
876
+ unset( $input );
877
  }
878
  }
879
 
1014
  private static function set_other_name( $args, &$other_args ) {
1015
  //Set up name for other field
1016
  $other_args['name'] = str_replace( '[]', '', $args['field_name'] );
1017
+ $other_args['name'] = preg_replace( '/\[' . $args['field']['id'] . '\]$/', '', $other_args['name'] );
1018
  $other_args['name'] = $other_args['name'] . '[other]' . '[' . $args['field']['id'] . ']';
1019
 
1020
  //Converts item_meta[field_id] => item_meta[other][field_id] and
1041
  // Count should only be greater than 3 if inside of a repeating section
1042
  if ( count( $temp_array ) > 3 ) {
1043
  $parent = str_replace( ']', '', $temp_array[1] );
1044
+ $pointer = str_replace( ']', '', $temp_array[2] );
1045
  }
1046
 
1047
  // Get text for "other" text field
1175
  $replace_with[] = '[' . $new . ']';
1176
  $replace[] = '[' . $old . ' ';
1177
  $replace_with[] = '[' . $new . ' ';
1178
+ unset( $old, $new );
1179
  }
1180
  if ( is_array( $val ) ) {
1181
  foreach ( $val as $k => $v ) {
1182
  $val[ $k ] = str_replace( $replace, $replace_with, $v );
1183
+ unset( $k, $v );
1184
  }
1185
  } else {
1186
+ $val = str_replace( $replace, $replace_with, $val );
1187
  }
1188
 
1189
  return $val;
1253
  $prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1254
 
1255
  $states = FrmFieldsHelper::get_us_states();
1256
+ $state_abv = array_keys( $states );
1257
+ sort( $state_abv );
1258
  $prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1259
 
1260
+ $states = array_values( $states );
1261
+ sort( $states );
1262
  $prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1263
+ unset( $state_abv, $states );
1264
 
1265
  $prepop[ __( 'Age', 'formidable' ) ] = array(
1266
  __( 'Under 18', 'formidable' ),
classes/helpers/FrmFormActionsHelper.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- if ( ! defined('ABSPATH') ) {
3
  die( 'You are not allowed to call this page directly.' );
4
  }
5
 
1
  <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
  die( 'You are not allowed to call this page directly.' );
4
  }
5
 
classes/helpers/FrmFormsHelper.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- if ( ! defined('ABSPATH') ) {
3
  die( 'You are not allowed to call this page directly.' );
4
  }
5
 
@@ -14,7 +14,7 @@ class FrmFormsHelper {
14
 
15
  public static function get_direct_link( $key, $form = false ) {
16
  $target_url = esc_url( admin_url( 'admin-ajax.php?action=frm_forms_preview&form=' . $key ) );
17
- $target_url = apply_filters('frm_direct_link', $target_url, $key, $form);
18
 
19
  return $target_url;
20
  }
@@ -39,7 +39,7 @@ class FrmFormsHelper {
39
  $query['id !'] = $args['exclude'];
40
  }
41
 
42
- $where = apply_filters('frm_forms_dropdown', $query, $field_name);
43
  $forms = FrmForm::get_published_forms( $where, 999, $args['inc_children'] );
44
  $add_html = array();
45
  self::add_html_attr( $args['onchange'], 'onchange', $add_html );
@@ -82,7 +82,7 @@ class FrmFormsHelper {
82
  );
83
  if ( isset( $_GET['id'] ) && ! isset( $_GET['form'] ) ) {
84
  unset( $args['form'] );
85
- } else if ( isset( $_GET['form']) && ! isset( $_GET['id'] ) ) {
86
  unset( $args['id'] );
87
  }
88
 
@@ -90,11 +90,11 @@ class FrmFormsHelper {
90
  if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $frm_action, array( 'edit', 'show', 'destroy_all' ) ) ) {
91
  $args['frm_action'] = 'list';
92
  $args['form'] = 0;
93
- } else if ( FrmAppHelper::is_admin_page('formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) {
94
  $args['frm_action'] = 'edit';
95
  } else if ( isset( $_GET['post'] ) ) {
96
  $args['form'] = 0;
97
- $base = admin_url('edit.php?post_type=frm_display');
98
  }
99
 
100
  ?>
@@ -179,7 +179,7 @@ class FrmFormsHelper {
179
  $post_values = $values;
180
  } else {
181
  $values = array();
182
- $post_values = isset($_POST) ? $_POST : array();
183
  }
184
 
185
  $defaults = array(
@@ -192,7 +192,7 @@ class FrmFormsHelper {
192
  }
193
  }
194
 
195
- $values['description'] = FrmAppHelper::use_wpautop($values['description']);
196
 
197
  $defaults = array(
198
  'form_id' => '',
@@ -217,7 +217,7 @@ class FrmFormsHelper {
217
  $values = self::fill_default_opts( $values, false, $post_values );
218
  $values['custom_style'] = FrmAppHelper::custom_style_value( $post_values );
219
 
220
- return apply_filters('frm_setup_new_form_vars', $values);
221
  }
222
 
223
  /**
@@ -228,21 +228,21 @@ class FrmFormsHelper {
228
  $post_values = stripslashes_deep( $_POST );
229
  }
230
 
231
- $values['form_key'] = isset($post_values['form_key']) ? $post_values['form_key'] : $record->form_key;
232
- $values['default_template'] = isset($post_values['default_template']) ? $post_values['default_template'] : $record->default_template;
233
- $values['is_template'] = isset($post_values['is_template']) ? $post_values['is_template'] : $record->is_template;
234
  $values['status'] = $record->status;
235
 
236
- $values = self::fill_default_opts($values, $record, $post_values);
237
 
238
- return apply_filters('frm_setup_edit_form_vars', $values);
239
  }
240
 
241
  public static function fill_default_opts( $values, $record, $post_values ) {
242
 
243
  $defaults = self::get_default_opts();
244
  foreach ( $defaults as $var => $default ) {
245
- if ( is_array($default) ) {
246
  if ( ! isset( $values[ $var ] ) ) {
247
  $values[ $var ] = ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : array();
248
  }
@@ -257,13 +257,13 @@ class FrmFormsHelper {
257
  }
258
  }
259
 
260
- unset($k, $v);
261
  }
262
  } else {
263
  $values[ $var ] = ( $post_values && isset( $post_values['options'][ $var ] ) ) ? $post_values['options'][ $var ] : ( ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : $default );
264
  }
265
 
266
- unset($var, $default);
267
  }
268
 
269
  return $values;
@@ -445,24 +445,24 @@ BEFORE_HTML;
445
  'entry_key' => true,
446
  );
447
  foreach ( $codes as $code => $show ) {
448
- if ( $code == 'form_name' ) {
449
- $replace_with = $form->name;
450
- } else if ( $code == 'form_description' ) {
451
- $replace_with = FrmAppHelper::use_wpautop($form->description);
452
- } else if ( $code == 'entry_key' && isset($_GET) && isset($_GET['entry']) ) {
453
- $replace_with = FrmAppHelper::simple_get( 'entry' );
454
- } else {
455
- $replace_with = '';
456
- }
457
 
458
  FrmShortcodeHelper::remove_inline_conditions( ( FrmAppHelper::is_true( $show ) && $replace_with != '' ), $code, $replace_with, $html );
459
  }
460
 
461
- //replace [form_key]
462
- $html = str_replace('[form_key]', $form->form_key, $html);
463
 
464
- //replace [frmurl]
465
- $html = str_replace('[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html);
466
 
467
  if ( strpos( $html, '[button_label]' ) ) {
468
  add_filter( 'frm_submit_button', 'FrmFormsHelper::submit_button_label', 1 );
@@ -471,7 +471,7 @@ BEFORE_HTML;
471
  $html = str_replace( '[button_label]', $submit_label, $html );
472
  }
473
 
474
- $html = apply_filters('frm_form_replace_shortcodes', $html, $form, $values);
475
 
476
  if ( strpos( $html, '[if back_button]' ) ) {
477
  $html = preg_replace( '/(\[if\s+back_button\])(.*?)(\[\/if\s+back_button\])/mis', '', $html );
@@ -489,7 +489,7 @@ BEFORE_HTML;
489
  }
490
 
491
  public static function submit_button_label( $submit ) {
492
- if ( ! $submit || empty($submit) ) {
493
  $frm_settings = FrmAppHelper::get_settings();
494
  $submit = $frm_settings->submit_value;
495
  }
@@ -512,19 +512,19 @@ BEFORE_HTML;
512
  }
513
 
514
  public static function get_form_style_class( $form = false ) {
515
- $style = self::get_form_style($form);
516
- $class = ' with_frm_style';
517
 
518
- if ( empty($style) ) {
519
- if ( FrmAppHelper::is_admin_page('formidable-entries') ) {
520
- return $class;
521
- } else {
522
- return;
523
- }
524
- }
525
 
526
  //If submit button needs to be inline or centered
527
- if ( is_object($form) ) {
528
  $form = $form->options;
529
  }
530
 
@@ -537,7 +537,7 @@ BEFORE_HTML;
537
  $class .= ' frm_center_submit';
538
  }
539
 
540
- $class = apply_filters('frm_add_form_style_class', $class, $style);
541
 
542
  return $class;
543
  }
@@ -692,7 +692,7 @@ BEFORE_HTML;
692
  * @since 3.0
693
  */
694
  public static function actions_dropdown( $atts ) {
695
- if ( FrmAppHelper::is_admin_page('formidable' ) ) {
696
  $status = $atts['status'];
697
  $form_id = isset( $atts['id'] ) ? $atts['id'] : FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
698
  $trash_link = self::delete_trash_info( $form_id, $status );
@@ -714,7 +714,7 @@ BEFORE_HTML;
714
  if ( 'trash' == $form->status ) {
715
  $actions['restore'] = $trash_links['restore'];
716
 
717
- if ( current_user_can('frm_delete_forms') ) {
718
  $actions['trash'] = $trash_links['delete'];
719
  }
720
  } elseif ( current_user_can( 'frm_edit_forms' ) ) {
@@ -740,12 +740,12 @@ BEFORE_HTML;
740
  }
741
 
742
  public static function edit_form_link( $form_id ) {
743
- if ( is_object($form_id) ) {
744
  $form = $form_id;
745
  $name = $form->name;
746
  $form_id = $form->id;
747
  } else {
748
- $name = FrmForm::getName($form_id);
749
  }
750
 
751
  if ( $form_id ) {
@@ -791,7 +791,7 @@ BEFORE_HTML;
791
 
792
  if ( 'trash' == $status ) {
793
  $info = $labels['restore'];
794
- } elseif ( current_user_can('frm_delete_forms') ) {
795
  if ( EMPTY_TRASH_DAYS ) {
796
  $info = $labels['trash'];
797
  } else {
@@ -941,7 +941,7 @@ BEFORE_HTML;
941
  'publish' => __( 'Published', 'formidable' ),
942
  );
943
 
944
- if ( ! in_array($status, array_keys($nice_names)) ) {
945
  $status = 'publish';
946
  }
947
 
1
  <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
  die( 'You are not allowed to call this page directly.' );
4
  }
5
 
14
 
15
  public static function get_direct_link( $key, $form = false ) {
16
  $target_url = esc_url( admin_url( 'admin-ajax.php?action=frm_forms_preview&form=' . $key ) );
17
+ $target_url = apply_filters( 'frm_direct_link', $target_url, $key, $form );
18
 
19
  return $target_url;
20
  }
39
  $query['id !'] = $args['exclude'];
40
  }
41
 
42
+ $where = apply_filters( 'frm_forms_dropdown', $query, $field_name );
43
  $forms = FrmForm::get_published_forms( $where, 999, $args['inc_children'] );
44
  $add_html = array();
45
  self::add_html_attr( $args['onchange'], 'onchange', $add_html );
82
  );
83
  if ( isset( $_GET['id'] ) && ! isset( $_GET['form'] ) ) {
84
  unset( $args['form'] );
85
+ } elseif ( isset( $_GET['form'] ) && ! isset( $_GET['id'] ) ) {
86
  unset( $args['id'] );
87
  }
88
 
90
  if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $frm_action, array( 'edit', 'show', 'destroy_all' ) ) ) {
91
  $args['frm_action'] = 'list';
92
  $args['form'] = 0;
93
+ } elseif ( FrmAppHelper::is_admin_page( 'formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) {
94
  $args['frm_action'] = 'edit';
95
  } else if ( isset( $_GET['post'] ) ) {
96
  $args['form'] = 0;
97
+ $base = admin_url( 'edit.php?post_type=frm_display' );
98
  }
99
 
100
  ?>
179
  $post_values = $values;
180
  } else {
181
  $values = array();
182
+ $post_values = isset( $_POST ) ? $_POST : array();
183
  }
184
 
185
  $defaults = array(
192
  }
193
  }
194
 
195
+ $values['description'] = FrmAppHelper::use_wpautop( $values['description'] );
196
 
197
  $defaults = array(
198
  'form_id' => '',
217
  $values = self::fill_default_opts( $values, false, $post_values );
218
  $values['custom_style'] = FrmAppHelper::custom_style_value( $post_values );
219
 
220
+ return apply_filters( 'frm_setup_new_form_vars', $values );
221
  }
222
 
223
  /**
228
  $post_values = stripslashes_deep( $_POST );
229
  }
230
 
231
+ $values['form_key'] = isset( $post_values['form_key'] ) ? $post_values['form_key'] : $record->form_key;
232
+ $values['default_template'] = isset( $post_values['default_template'] ) ? $post_values['default_template'] : $record->default_template;
233
+ $values['is_template'] = isset( $post_values['is_template'] ) ? $post_values['is_template'] : $record->is_template;
234
  $values['status'] = $record->status;
235
 
236
+ $values = self::fill_default_opts( $values, $record, $post_values );
237
 
238
+ return apply_filters( 'frm_setup_edit_form_vars', $values );
239
  }
240
 
241
  public static function fill_default_opts( $values, $record, $post_values ) {
242
 
243
  $defaults = self::get_default_opts();
244
  foreach ( $defaults as $var => $default ) {
245
+ if ( is_array( $default ) ) {
246
  if ( ! isset( $values[ $var ] ) ) {
247
  $values[ $var ] = ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : array();
248
  }
257
  }
258
  }
259
 
260
+ unset( $k, $v );
261
  }
262
  } else {
263
  $values[ $var ] = ( $post_values && isset( $post_values['options'][ $var ] ) ) ? $post_values['options'][ $var ] : ( ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : $default );
264
  }
265
 
266
+ unset( $var, $default );
267
  }
268
 
269
  return $values;
445
  'entry_key' => true,
446
  );
447
  foreach ( $codes as $code => $show ) {
448
+ if ( $code == 'form_name' ) {
449
+ $replace_with = $form->name;
450
+ } elseif ( $code == 'form_description' ) {
451
+ $replace_with = FrmAppHelper::use_wpautop( $form->description );
452
+ } elseif ( $code == 'entry_key' && isset( $_GET ) && isset( $_GET['entry'] ) ) {
453
+ $replace_with = FrmAppHelper::simple_get( 'entry' );
454
+ } else {
455
+ $replace_with = '';
456
+ }
457
 
458
  FrmShortcodeHelper::remove_inline_conditions( ( FrmAppHelper::is_true( $show ) && $replace_with != '' ), $code, $replace_with, $html );
459
  }
460
 
461
+ //replace [form_key]
462
+ $html = str_replace( '[form_key]', $form->form_key, $html );
463
 
464
+ //replace [frmurl]
465
+ $html = str_replace( '[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html );
466
 
467
  if ( strpos( $html, '[button_label]' ) ) {
468
  add_filter( 'frm_submit_button', 'FrmFormsHelper::submit_button_label', 1 );
471
  $html = str_replace( '[button_label]', $submit_label, $html );
472
  }
473
 
474
+ $html = apply_filters( 'frm_form_replace_shortcodes', $html, $form, $values );
475
 
476
  if ( strpos( $html, '[if back_button]' ) ) {
477
  $html = preg_replace( '/(\[if\s+back_button\])(.*?)(\[\/if\s+back_button\])/mis', '', $html );
489
  }
490
 
491
  public static function submit_button_label( $submit ) {
492
+ if ( ! $submit || empty( $submit ) ) {
493
  $frm_settings = FrmAppHelper::get_settings();
494
  $submit = $frm_settings->submit_value;
495
  }
512
  }
513
 
514
  public static function get_form_style_class( $form = false ) {
515
+ $style = self::get_form_style( $form );
516
+ $class = ' with_frm_style';
517
 
518
+ if ( empty( $style ) ) {
519
+ if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) ) {
520
+ return $class;
521
+ } else {
522
+ return;
523
+ }
524
+ }
525
 
526
  //If submit button needs to be inline or centered
527
+ if ( is_object( $form ) ) {
528
  $form = $form->options;
529
  }
530
 
537
  $class .= ' frm_center_submit';
538
  }
539
 
540
+ $class = apply_filters( 'frm_add_form_style_class', $class, $style );
541
 
542
  return $class;
543
  }
692
  * @since 3.0
693
  */
694
  public static function actions_dropdown( $atts ) {
695
+ if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
696
  $status = $atts['status'];
697
  $form_id = isset( $atts['id'] ) ? $atts['id'] : FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
698
  $trash_link = self::delete_trash_info( $form_id, $status );
714
  if ( 'trash' == $form->status ) {
715
  $actions['restore'] = $trash_links['restore'];
716
 
717
+ if ( current_user_can( 'frm_delete_forms' ) ) {
718
  $actions['trash'] = $trash_links['delete'];
719
  }
720
  } elseif ( current_user_can( 'frm_edit_forms' ) ) {
740
  }
741
 
742
  public static function edit_form_link( $form_id ) {
743
+ if ( is_object( $form_id ) ) {
744
  $form = $form_id;
745
  $name = $form->name;
746
  $form_id = $form->id;
747
  } else {
748
+ $name = FrmForm::getName( $form_id );
749
  }
750
 
751
  if ( $form_id ) {
791
 
792
  if ( 'trash' == $status ) {
793
  $info = $labels['restore'];
794
+ } elseif ( current_user_can( 'frm_delete_forms' ) ) {
795
  if ( EMPTY_TRASH_DAYS ) {
796
  $info = $labels['trash'];
797
  } else {
941
  'publish' => __( 'Published', 'formidable' ),
942
  );
943
 
944
+ if ( ! in_array( $status, array_keys( $nice_names ) ) ) {
945
  $status = 'publish';
946
  }
947
 
classes/helpers/FrmFormsListHelper.php CHANGED
@@ -65,8 +65,8 @@ class FrmFormsListHelper extends FrmListHelper {
65
  'sanitize' => 'sanitize_text_field',
66
  ) );
67
  if ( $s != '' ) {
68
- preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
69
- $search_terms = array_map('trim', $matches[0]);
70
  foreach ( (array) $search_terms as $term ) {
71
  $s_query[] = array(
72
  'or' => true,
@@ -102,17 +102,17 @@ class FrmFormsListHelper extends FrmListHelper {
102
  $actions = array();
103
 
104
  if ( 'trash' == $this->status ) {
105
- if ( current_user_can('frm_edit_forms') ) {
106
  $actions['bulk_untrash'] = __( 'Restore', 'formidable' );
107
  }
108
 
109
- if ( current_user_can('frm_delete_forms') ) {
110
  $actions['bulk_delete'] = __( 'Delete Permanently', 'formidable' );
111
  }
112
- } else if ( EMPTY_TRASH_DAYS && current_user_can('frm_delete_forms') ) {
113
  $actions['bulk_trash'] = __( 'Move to Trash', 'formidable' );
114
- } else if ( current_user_can('frm_delete_forms') ) {
115
- $actions['bulk_delete'] = __( 'Delete');
116
  }
117
 
118
  return $actions;
@@ -123,7 +123,7 @@ class FrmFormsListHelper extends FrmListHelper {
123
  return;
124
  }
125
 
126
- if ( 'trash' == $this->status && current_user_can('frm_delete_forms') ) {
127
  ?>
128
  <div class="alignleft actions frm_visible_overflow">
129
  <?php submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); ?>
@@ -139,7 +139,7 @@ class FrmFormsListHelper extends FrmListHelper {
139
  $where = apply_filters( 'frm_forms_dropdown', array(), '' );
140
  $forms = FrmForm::get_published_forms( $where );
141
 
142
- $base = admin_url('admin.php?page=formidable&form_type=template');
143
  $args = array(
144
  'frm_action' => 'duplicate',
145
  'template' => true,
@@ -161,7 +161,7 @@ class FrmFormsListHelper extends FrmListHelper {
161
  ?>
162
  <li><a href="<?php echo esc_url( add_query_arg( $args, $base ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 33 ) ); ?></a></li>
163
  <?php
164
- unset($form);
165
  }
166
  }
167
  ?>
@@ -199,7 +199,7 @@ class FrmFormsListHelper extends FrmListHelper {
199
  $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>';
200
  }
201
 
202
- unset($status, $name);
203
  }
204
 
205
  return $links;
@@ -264,7 +264,7 @@ class FrmFormsListHelper extends FrmListHelper {
264
 
265
  break;
266
  case 'created_at':
267
- $date = date($format, strtotime($item->created_at));
268
  $val = '<abbr title="' . esc_attr( date( 'Y/m/d g:i:s A', strtotime( $item->created_at ) ) ) . '">' . $date . '</abbr>';
269
  break;
270
  case 'shortcode':
@@ -275,24 +275,24 @@ class FrmFormsListHelper extends FrmListHelper {
275
  break;
276
  case 'entries':
277
  if ( isset( $item->options['no_save'] ) && $item->options['no_save'] ) {
278
- $val = '<i class="frm_icon_font frm_forbid_icon frm_bstooltip" title="' . esc_attr('Saving entries is disabled for this form', 'formidable' ) . '"></i>';
279
- } else {
280
- $text = FrmEntry::getRecordCount($item->id);
281
- $val = current_user_can('frm_view_entries') ? '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&form=' . $item->id ) ) . '">' . $text . '</a>' : $text;
282
- unset($text);
283
- }
284
  break;
285
  case 'type':
286
  $val = ( $item->is_template && $item->default_template ) ? __( 'Default', 'formidable' ) : __( 'Custom', 'formidable' );
287
  break;
288
  }
289
 
290
- if ( isset($val) ) {
291
  $r .= "<td $attributes>";
292
  $r .= $val;
293
  $r .= '</td>';
294
  }
295
- unset($val);
296
  }
297
  $r .= '</tr>';
298
 
@@ -313,7 +313,7 @@ class FrmFormsListHelper extends FrmListHelper {
313
  return;
314
  }
315
 
316
- if ( current_user_can('frm_edit_forms') ) {
317
  if ( ! $item->is_template || ! $item->default_template ) {
318
  $actions['frm_edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit' ) . '</a>';
319
  }
@@ -324,7 +324,7 @@ class FrmFormsListHelper extends FrmListHelper {
324
  }
325
 
326
  $actions = array_merge( $actions, $new_actions );
327
- $actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview') . '</a>';
328
  }
329
 
330
  /**
@@ -332,9 +332,9 @@ class FrmFormsListHelper extends FrmListHelper {
332
  */
333
  private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) {
334
  $form_name = $item->name;
335
- if ( trim($form_name) == '' ) {
336
- $form_name = __( '(no title)');
337
- }
338
  $form_name = FrmAppHelper::kses( $form_name );
339
  if ( 'excerpt' != $mode ) {
340
  $form_name = FrmAppHelper::truncate( $form_name, 50 );
@@ -370,7 +370,7 @@ class FrmFormsListHelper extends FrmListHelper {
370
  private function add_form_description( $item, &$val ) {
371
  global $mode;
372
  if ( 'excerpt' == $mode ) {
373
- $val .= FrmAppHelper::truncate(strip_tags($item->description), 50);
374
  }
375
  }
376
  }
65
  'sanitize' => 'sanitize_text_field',
66
  ) );
67
  if ( $s != '' ) {
68
+ preg_match_all( '/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches );
69
+ $search_terms = array_map( 'trim', $matches[0] );
70
  foreach ( (array) $search_terms as $term ) {
71
  $s_query[] = array(
72
  'or' => true,
102
  $actions = array();
103
 
104
  if ( 'trash' == $this->status ) {
105
+ if ( current_user_can( 'frm_edit_forms' ) ) {
106
  $actions['bulk_untrash'] = __( 'Restore', 'formidable' );
107
  }
108
 
109
+ if ( current_user_can( 'frm_delete_forms' ) ) {
110
  $actions['bulk_delete'] = __( 'Delete Permanently', 'formidable' );
111
  }
112
+ } elseif ( EMPTY_TRASH_DAYS && current_user_can( 'frm_delete_forms' ) ) {
113
  $actions['bulk_trash'] = __( 'Move to Trash', 'formidable' );
114
+ } elseif ( current_user_can( 'frm_delete_forms' ) ) {
115
+ $actions['bulk_delete'] = __( 'Delete' );
116
  }
117
 
118
  return $actions;
123
  return;
124
  }
125
 
126
+ if ( 'trash' == $this->status && current_user_can( 'frm_delete_forms' ) ) {
127
  ?>
128
  <div class="alignleft actions frm_visible_overflow">
129
  <?php submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); ?>
139
  $where = apply_filters( 'frm_forms_dropdown', array(), '' );
140
  $forms = FrmForm::get_published_forms( $where );
141
 
142
+ $base = admin_url( 'admin.php?page=formidable&form_type=template' );
143
  $args = array(
144
  'frm_action' => 'duplicate',
145
  'template' => true,
161
  ?>
162
  <li><a href="<?php echo esc_url( add_query_arg( $args, $base ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 33 ) ); ?></a></li>
163
  <?php
164
+ unset( $form );
165
  }
166
  }
167
  ?>
199
  $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>';
200
  }
201
 
202
+ unset( $status, $name );
203
  }
204
 
205
  return $links;
264
 
265
  break;
266
  case 'created_at':
267
+ $date = date( $format, strtotime( $item->created_at ) );
268
  $val = '<abbr title="' . esc_attr( date( 'Y/m/d g:i:s A', strtotime( $item->created_at ) ) ) . '">' . $date . '</abbr>';
269
  break;
270
  case 'shortcode':
275
  break;
276
  case 'entries':
277
  if ( isset( $item->options['no_save'] ) && $item->options['no_save'] ) {
278
+ $val = '<i class="frm_icon_font frm_forbid_icon frm_bstooltip" title="' . esc_attr( 'Saving entries is disabled for this form', 'formidable' ) . '"></i>';
279
+ } else {
280
+ $text = FrmEntry::getRecordCount( $item->id );
281
+ $val = current_user_can( 'frm_view_entries' ) ? '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&form=' . $item->id ) ) . '">' . $text . '</a>' : $text;
282
+ unset( $text );
283
+ }
284
  break;
285
  case 'type':
286
  $val = ( $item->is_template && $item->default_template ) ? __( 'Default', 'formidable' ) : __( 'Custom', 'formidable' );
287
  break;
288
  }
289
 
290
+ if ( isset( $val ) ) {
291
  $r .= "<td $attributes>";
292
  $r .= $val;
293
  $r .= '</td>';
294
  }
295
+ unset( $val );
296
  }
297
  $r .= '</tr>';
298
 
313
  return;
314
  }
315
 
316
+ if ( current_user_can( 'frm_edit_forms' ) ) {
317
  if ( ! $item->is_template || ! $item->default_template ) {
318
  $actions['frm_edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit' ) . '</a>';
319
  }
324
  }
325
 
326
  $actions = array_merge( $actions, $new_actions );
327
+ $actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview' ) . '</a>';
328
  }
329
 
330
  /**
332
  */
333
  private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) {
334
  $form_name = $item->name;
335
+ if ( trim( $form_name ) == '' ) {
336
+ $form_name = __( '(no title)' );
337
+ }
338
  $form_name = FrmAppHelper::kses( $form_name );
339
  if ( 'excerpt' != $mode ) {
340
  $form_name = FrmAppHelper::truncate( $form_name, 50 );
370
  private function add_form_description( $item, &$val ) {
371
  global $mode;
372
  if ( 'excerpt' == $mode ) {
373
+ $val .= FrmAppHelper::truncate( strip_tags( $item->description ), 50 );
374
  }
375
  }
376
  }
classes/helpers/FrmListHelper.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- if ( ! defined('ABSPATH') ) {
3
  die( 'You are not allowed to call this page directly.' );
4
  }
5
 
1
  <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
  die( 'You are not allowed to call this page directly.' );
4
  }
5
 
classes/helpers/FrmShortcodeHelper.php CHANGED
@@ -58,10 +58,10 @@ class FrmShortcodeHelper {
58
  $with_tags = $args['conditional_check'] ? 3 : 2;
59
  if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
60
  $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
61
- $tag = str_replace(']', '', $tag);
62
  $tag = str_replace( chr( 194 ) . chr( 160 ), ' ', $tag );
63
  $tags = preg_split( '/\s+/', $tag, 2 );
64
- if ( is_array($tags) ) {
65
  $tag = $tags[0];
66
  }
67
  } else {
58
  $with_tags = $args['conditional_check'] ? 3 : 2;
59
  if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
60
  $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
61
+ $tag = str_replace( ']', '', $tag );
62
  $tag = str_replace( chr( 194 ) . chr( 160 ), ' ', $tag );
63
  $tags = preg_split( '/\s+/', $tag, 2 );
64
+ if ( is_array( $tags ) ) {
65
  $tag = $tags[0];
66
  }
67
  } else {
classes/helpers/FrmStylesHelper.php CHANGED
@@ -29,7 +29,7 @@ class FrmStylesHelper {
29
  'swanky-purse' => 'Swanky Purse',
30
  );
31
 
32
- $themes = apply_filters('frm_jquery_themes', $themes);
33
  return $themes;
34
  }
35
 
@@ -40,12 +40,12 @@ class FrmStylesHelper {
40
 
41
  if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) {
42
  $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css';
43
- } else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) {
44
  $css_file = $theme_css;
45
  } else {
46
  $uploads = self::get_upload_base();
47
  $file_path = '/formidable/css/' . $theme_css . '/jquery-ui.css';
48
- if ( file_exists($uploads['basedir'] . $file_path) ) {
49
  $css_file = $uploads['baseurl'] . $file_path;
50
  } else {
51
  $css_file = FrmAppHelper::jquery_ui_base_url() . '/themes/' . $theme_css . '/jquery-ui.min.css';
@@ -59,7 +59,7 @@ class FrmStylesHelper {
59
  $form = self::get_form_for_page();
60
  $theme_css = FrmStylesController::get_style_val( 'theme_css', $form );
61
  if ( $theme_css != -1 ) {
62
- wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version());
63
  }
64
  }
65
 
@@ -77,21 +77,21 @@ class FrmStylesHelper {
77
  return $form_id;
78
  }
79
 
80
- public static function get_upload_base() {
81
- $uploads = wp_upload_dir();
82
- if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) {
83
- $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']);
84
- }
85
 
86
- return $uploads;
87
- }
88
 
89
  public static function style_menu( $active = '' ) {
90
  ?>
91
  <h2 class="nav-tab-wrapper">
92
  <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles' ) ) ?>" class="nav-tab <?php echo ( '' == $active ) ? 'nav-tab-active' : '' ?>"><?php esc_html_e( 'Edit Styles', 'formidable' ) ?></a>
93
  <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=manage' ) ) ?>" class="nav-tab <?php echo ( 'manage' == $active ) ? 'nav-tab-active' : '' ?>"><?php esc_html_e( 'Manage Form Styles', 'formidable' ) ?></a>
94
- <a href="<?php echo esc_url( admin_url('admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php esc_html_e( 'Custom CSS', 'formidable' ) ?></a>
95
  </h2>
96
  <?php
97
  }
@@ -223,7 +223,7 @@ class FrmStylesHelper {
223
 
224
  $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon';
225
  ?>
226
- <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">
227
  <?php foreach ( $icons as $key => $icon ) { ?>
228
  <option value="<?php echo esc_attr( $key ) ?>" <?php selected( $style->post_content[ $name ], $key ) ?>>
229
  <?php echo '&#xe' . $icon['+'] . '; &#xe' . $icon['-'] . ';'; ?>
@@ -299,14 +299,14 @@ class FrmStylesHelper {
299
  */
300
  public static function get_settings_for_output( $style ) {
301
  if ( self::previewing_style() ) {
302
- if ( isset( $_GET['frm_style_setting'] ) ) {
303
- $settings = $_GET['frm_style_setting']['post_content'];
304
  } else {
305
- $settings = $_GET;
306
  }
307
  FrmAppHelper::sanitize_value( 'sanitize_text_field', $settings );
308
 
309
- $style_name = FrmAppHelper::simple_get( 'style_name', 'sanitize_title' );
310
  $settings['style_class'] = '';
311
  if ( ! empty( $style_name ) ) {
312
  $settings['style_class'] = $style_name . '.';
@@ -335,9 +335,12 @@ class FrmStylesHelper {
335
  /**
336
  * @since 2.3
337
  */
338
- private static function prepare_color_output( &$settings ) {
339
  $colors = self::allow_color_override();
340
  foreach ( $colors as $css => $opts ) {
 
 
 
341
  foreach ( $opts as $opt ) {
342
  self::get_color_output( $css, $settings[ $opt ] );
343
  }
@@ -348,9 +351,14 @@ class FrmStylesHelper {
348
  * @since 2.3
349
  */
350
  private static function allow_color_override() {
 
 
 
 
 
351
  return array(
352
- 'transparent' => array( 'fieldset_color', 'fieldset_bg_color', 'bg_color', 'section_bg_color', 'error_bg', 'success_bg_color', 'progress_bg_color', 'progress_active_bg_color' ),
353
- '' => array( 'title_color', 'section_color', 'submit_text_color', 'label_color', 'check_label_color', 'form_desc_color', 'description_color', 'text_color', 'text_color_disabled', 'border_color', 'submit_bg_color', 'submit_border_color', 'error_text', 'progress_border_color', 'progress_color', 'progress_active_color', 'submit_hover_bg_color', 'submit_hover_border_color', 'submit_hover_color', 'submit_active_color', 'submit_active_border_color', 'submit_active_bg_color' ),
354
  );
355
  }
356
 
@@ -358,7 +366,12 @@ class FrmStylesHelper {
358
  * @since 2.3
359
  */
360
  private static function get_color_output( $default, &$color ) {
361
- $color = ( trim( $color ) == '' ) ? $default : '#' . $color;
 
 
 
 
 
362
  }
363
 
364
  /**
@@ -380,10 +393,11 @@ class FrmStylesHelper {
380
  }
381
 
382
  /**
 
383
  * @since 2.3
384
  */
385
  public static function previewing_style() {
386
- return isset( $_GET['frm_style_setting'] ) || isset( $_GET['flat'] );
387
  }
388
 
389
  /**
29
  'swanky-purse' => 'Swanky Purse',
30
  );
31
 
32
+ $themes = apply_filters( 'frm_jquery_themes', $themes );
33
  return $themes;
34
  }
35
 
40
 
41
  if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) {
42
  $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css';
43
+ } elseif ( preg_match( '/^http.?:\/\/.*\..*$/', $theme_css ) ) {
44
  $css_file = $theme_css;
45
  } else {
46
  $uploads = self::get_upload_base();
47
  $file_path = '/formidable/css/' . $theme_css . '/jquery-ui.css';
48
+ if ( file_exists( $uploads['basedir'] . $file_path ) ) {
49
  $css_file = $uploads['baseurl'] . $file_path;
50
  } else {
51
  $css_file = FrmAppHelper::jquery_ui_base_url() . '/themes/' . $theme_css . '/jquery-ui.min.css';
59
  $form = self::get_form_for_page();
60
  $theme_css = FrmStylesController::get_style_val( 'theme_css', $form );
61
  if ( $theme_css != -1 ) {
62
+ wp_enqueue_style( 'jquery-theme', self::jquery_css_url( $theme_css ), array(), FrmAppHelper::plugin_version() );
63
  }
64
  }
65
 
77
  return $form_id;
78
  }
79
 
80
+ public static function get_upload_base() {
81
+ $uploads = wp_upload_dir();
82
+ if ( is_ssl() && ! preg_match( '/^https:\/\/.*\..*$/', $uploads['baseurl'] ) ) {
83
+ $uploads['baseurl'] = str_replace( 'http://', 'https://', $uploads['baseurl'] );
84
+ }
85
 
86
+ return $uploads;
87
+ }
88
 
89
  public static function style_menu( $active = '' ) {
90
  ?>
91
  <h2 class="nav-tab-wrapper">
92
  <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles' ) ) ?>" class="nav-tab <?php echo ( '' == $active ) ? 'nav-tab-active' : '' ?>"><?php esc_html_e( 'Edit Styles', 'formidable' ) ?></a>
93
  <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=manage' ) ) ?>" class="nav-tab <?php echo ( 'manage' == $active ) ? 'nav-tab-active' : '' ?>"><?php esc_html_e( 'Manage Form Styles', 'formidable' ) ?></a>
94
+ <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=custom_css' ) ); ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : ''; ?>"><?php esc_html_e( 'Custom CSS', 'formidable' ); ?></a>
95
  </h2>
96
  <?php
97
  }
223
 
224
  $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon';
225
  ?>
226
+ <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">
227
  <?php foreach ( $icons as $key => $icon ) { ?>
228
  <option value="<?php echo esc_attr( $key ) ?>" <?php selected( $style->post_content[ $name ], $key ) ?>>
229
  <?php echo '&#xe' . $icon['+'] . '; &#xe' . $icon['-'] . ';'; ?>
299
  */
300
  public static function get_settings_for_output( $style ) {
301
  if ( self::previewing_style() ) {
302
+ if ( isset( $_POST['frm_style_setting'] ) ) {
303
+ $settings = $_POST['frm_style_setting']['post_content'];
304
  } else {
305
+ $settings = $_POST;
306
  }
307
  FrmAppHelper::sanitize_value( 'sanitize_text_field', $settings );
308
 
309
+ $style_name = FrmAppHelper::get_post_param( 'style_name', '', 'sanitize_title' );
310
  $settings['style_class'] = '';
311
  if ( ! empty( $style_name ) ) {
312
  $settings['style_class'] = $style_name . '.';
335
  /**
336
  * @since 2.3
337
  */
338
+ public static function prepare_color_output( &$settings, $allow_transparent = true ) {
339
  $colors = self::allow_color_override();
340
  foreach ( $colors as $css => $opts ) {
341
+ if ( $css === 'transparent' && ! $allow_transparent ) {
342
+ $css = '';
343
+ }
344
  foreach ( $opts as $opt ) {
345
  self::get_color_output( $css, $settings[ $opt ] );
346
  }
351
  * @since 2.3
352
  */
353
  private static function allow_color_override() {
354
+ $frm_style = new FrmStyle();
355
+ $colors = $frm_style->get_color_settings();
356
+
357
+ $transparent = array( 'fieldset_color', 'fieldset_bg_color', 'bg_color', 'section_bg_color', 'error_bg', 'success_bg_color', 'progress_bg_color', 'progress_active_bg_color' );
358
+
359
  return array(
360
+ 'transparent' => $transparent,
361
+ '' => array_diff( $colors, $transparent ),
362
  );
363
  }
364
 
366
  * @since 2.3
367
  */
368
  private static function get_color_output( $default, &$color ) {
369
+ $color = trim( $color );
370
+ if ( empty( $color ) ) {
371
+ $color = $default;
372
+ } elseif ( strpos( $color, '#' ) === false ) {
373
+ $color = '#' . $color;
374
+ }
375
  }
376
 
377
  /**
393
  }
394
 
395
  /**
396
+ * Where is 'flat' being used?
397
  * @since 2.3
398
  */
399
  public static function previewing_style() {
400
+ return isset( $_POST['frm_style_setting'] ) || isset( $_POST['flat'] ) || isset( $_GET['flat'] );
401
  }
402
 
403
  /**
classes/helpers/FrmXMLHelper.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- if ( ! defined('ABSPATH') ) {
3
  die( 'You are not allowed to call this page directly.' );
4
  }
5
 
@@ -40,10 +40,10 @@ class FrmXMLHelper {
40
  'terms' => array(),
41
  );
42
 
43
- unset($defaults);
44
 
45
  if ( ! defined( 'WP_IMPORTING' ) ) {
46
- define('WP_IMPORTING', true);
47
  }
48
 
49
  if ( ! class_exists( 'DOMDocument' ) ) {
@@ -56,7 +56,7 @@ class FrmXMLHelper {
56
  return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() );
57
  }
58
 
59
- if ( ! function_exists('simplexml_import_dom') ) {
60
  return new WP_Error( 'SimpleXML_parse_error', __( 'Your server is missing the simplexml_import_dom function', 'formidable' ), libxml_get_errors() );
61
  }
62
 
@@ -71,14 +71,14 @@ class FrmXMLHelper {
71
  // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order
72
  foreach ( array( 'term', 'form', 'view' ) as $item_type ) {
73
  // grab cats, tags, and terms, or forms or posts
74
- if ( isset($xml->{$item_type} ) ) {
75
  $function_name = 'import_xml_' . $item_type . 's';
76
  $imported = self::$function_name( $xml->{$item_type}, $imported );
77
  unset( $function_name, $xml->{$item_type} );
78
  }
79
  }
80
 
81
- $return = apply_filters('frm_importing_xml', $imported, $xml );
82
 
83
  return $return;
84
  }
@@ -169,7 +169,7 @@ class FrmXMLHelper {
169
 
170
  do_action( 'frm_after_import_form', $form_id, $form );
171
 
172
- unset($form, $item);
173
  }
174
 
175
  self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms );
@@ -225,7 +225,7 @@ class FrmXMLHelper {
225
  foreach ( $form_fields as $f ) {
226
  $old_fields[ $f->id ] = $f;
227
  $old_fields[ $f->field_key ] = $f->id;
228
- unset($f);
229
  }
230
  $form_fields = $old_fields;
231
  return $form_fields;
@@ -256,7 +256,7 @@ class FrmXMLHelper {
256
  $regular_forms = array();
257
 
258
  foreach ( $forms as $form ) {
259
- $parent_form_id = isset( $form->parent_form_id) ? (int) $form->parent_form_id : 0;
260
 
261
  if ( $parent_form_id ) {
262
  $child_forms[] = $form;
@@ -327,7 +327,7 @@ class FrmXMLHelper {
327
  self::maybe_update_form_select( $f, $imported );
328
  self::maybe_update_get_values_form_setting( $imported, $f );
329
 
330
- if ( ! empty($this_form) ) {
331
  // check for field to edit by field id
332
  if ( isset( $form_fields[ $f['id'] ] ) ) {
333
  FrmField::update( $f['id'], $f );
@@ -341,7 +341,7 @@ class FrmXMLHelper {
341
  }
342
  } else if ( isset( $form_fields[ $f['field_key'] ] ) ) {
343
  // check for field to edit by field key
344
- unset($f['id']);
345
 
346
  FrmField::update( $form_fields[ $f['field_key'] ], $f );
347
  $imported['updated']['fields']++;
@@ -366,11 +366,11 @@ class FrmXMLHelper {
366
  'name' => (string) $field->name,
367
  'description' => (string) $field->description,
368
  'type' => (string) $field->type,
369
- 'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value),
370
  'field_order' => (int) $field->field_order,
371
  'form_id' => (int) $form_id,
372
  'required' => (int) $field->required,
373
- 'options' => FrmAppHelper::maybe_json_decode( (string) $field->options),
374
  'field_options' => FrmAppHelper::maybe_json_decode( (string) $field->field_options ),
375
  );
376
  }
@@ -550,9 +550,9 @@ class FrmXMLHelper {
550
  );
551
 
552
  $old_id = $post['post_id'];
553
- self::populate_post($post, $item, $imported);
554
 
555
- unset($item);
556
 
557
  $post_id = false;
558
  if ( $post['post_type'] == $form_action_type ) {
@@ -560,7 +560,7 @@ class FrmXMLHelper {
560
  if ( $action_control && is_object( $action_control ) ) {
561
  $post_id = $action_control->maybe_create_action( $post, $imported['form_status'] );
562
  }
563
- unset($action_control);
564
  } else if ( $post['post_type'] == 'frm_styles' ) {
565
  // Properly encode post content before inserting the post
566
  $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
@@ -575,18 +575,18 @@ class FrmXMLHelper {
575
  $post_id = wp_insert_post( $post );
576
  }
577
 
578
- if ( ! is_numeric($post_id) ) {
579
  continue;
580
  }
581
 
582
- self::update_postmeta($post, $post_id);
583
 
584
  $this_type = 'posts';
585
  if ( isset( $post_types[ $post['post_type'] ] ) ) {
586
  $this_type = $post_types[ $post['post_type'] ];
587
  }
588
 
589
- if ( isset($post['ID']) && $post_id == $post['ID'] ) {
590
  $imported['updated'][ $this_type ]++;
591
  } else {
592
  $imported['imported'][ $this_type ]++;
@@ -605,7 +605,7 @@ class FrmXMLHelper {
605
  }
606
 
607
  private static function populate_post( &$post, $item, $imported ) {
608
- if ( isset($item->attachment_url) ) {
609
  $post['attachment_url'] = (string) $item->attachment_url;
610
  }
611
 
@@ -620,13 +620,13 @@ class FrmXMLHelper {
620
  }
621
 
622
  foreach ( $item->postmeta as $meta ) {
623
- self::populate_postmeta($post, $meta, $imported);
624
- unset($meta);
625
  }
626
 
627
- self::populate_taxonomies($post, $item);
628
 
629
- self::maybe_editing_post($post);
630
  }
631
 
632
  private static function populate_postmeta( &$post, $meta, $imported ) {
@@ -638,15 +638,15 @@ class FrmXMLHelper {
638
  );
639
 
640
  //switch old form and field ids to new ones
641
- if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) {
642
  $m['value'] = $imported['forms'][ (int) $m['value'] ];
643
  } else {
644
- $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
645
 
646
- if ( ! empty($frm_duplicate_ids) ) {
647
 
648
  if ( $m['key'] == 'frm_dyncontent' ) {
649
- $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
650
  } else if ( $m['key'] == 'frm_options' ) {
651
 
652
  foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) {
@@ -673,15 +673,15 @@ class FrmXMLHelper {
673
  if ( isset( $frm_duplicate_ids[ $mv ] ) ) {
674
  $m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ];
675
  }
676
- unset($mk, $mv);
677
  }
678
  }
679
  }
680
  }
681
  }
682
 
683
- if ( ! is_array($m['value']) ) {
684
- $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
685
  }
686
 
687
  $post['postmeta'][ (string) $meta->meta_key ] = $m['value'];
@@ -700,13 +700,13 @@ class FrmXMLHelper {
700
  }
701
 
702
  $taxonomy = (string) $att['domain'];
703
- if ( is_taxonomy_hierarchical($taxonomy) ) {
704
  $name = (string) $att['nicename'];
705
- $h_term = get_term_by('slug', $name, $taxonomy);
706
  if ( $h_term ) {
707
  $name = $h_term->term_id;
708
  }
709
- unset($h_term);
710
  } else {
711
  $name = (string) $c;
712
  }
@@ -716,7 +716,7 @@ class FrmXMLHelper {
716
  }
717
 
718
  $post['tax_input'][ $taxonomy ][] = $name;
719
- unset($name);
720
  }
721
  }
722
 
@@ -733,30 +733,30 @@ class FrmXMLHelper {
733
 
734
  if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) {
735
  $match_by['include'] = $post['post_id'];
736
- unset($match_by['name']);
737
  }
738
 
739
- $editing = get_posts($match_by);
740
 
741
- if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
742
- // set the id of the post to edit
743
- $post['ID'] = current($editing)->ID;
744
- }
745
  }
746
 
747
  private static function update_postmeta( &$post, $post_id ) {
748
  foreach ( $post['postmeta'] as $k => $v ) {
749
  if ( '_edit_last' == $k ) {
750
- $v = FrmAppHelper::get_user_id_param($v);
751
  } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
752
  //change the attachment ID
753
  $field_obj = FrmFieldFactory::get_field_type( 'file' );
754
  $v = $field_obj->get_file_id( $v );
755
  }
756
 
757
- update_post_meta($post_id, $k, $v);
758
 
759
- unset($k, $v);
760
  }
761
  }
762
 
@@ -795,13 +795,13 @@ class FrmXMLHelper {
795
  * @param string $message
796
  */
797
  public static function parse_message( $result, &$message, &$errors ) {
798
- if ( is_wp_error($result) ) {
799
  $errors[] = $result->get_error_message();
800
  } else if ( ! $result ) {
801
  return;
802
  }
803
 
804
- if ( ! is_array($result) ) {
805
  $message = is_string( $result ) ? $result : htmlentities( print_r( $result, 1 ) );
806
  return;
807
  }
@@ -818,17 +818,17 @@ class FrmXMLHelper {
818
  continue;
819
  }
820
 
821
- $s_message = array();
822
- foreach ( $results as $k => $m ) {
823
- self::item_count_message($m, $k, $s_message);
824
- unset($k, $m);
825
- }
826
 
827
- if ( ! empty($s_message) ) {
828
  $message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> ';
829
- $message .= implode(', ', $s_message);
830
- $message .= '</li>';
831
- }
832
  }
833
 
834
  if ( $message == '<ul>' ) {
@@ -887,20 +887,20 @@ class FrmXMLHelper {
887
  }
888
 
889
  public static function cdata( $str ) {
890
- $str = maybe_unserialize($str);
891
- if ( is_array($str) ) {
892
- $str = json_encode($str);
893
  } else if ( seems_utf8( $str ) == false ) {
894
  $str = utf8_encode( $str );
895
  }
896
 
897
- if ( is_numeric($str) ) {
898
  return $str;
899
  }
900
 
901
  self::remove_invalid_characters_from_xml( $str );
902
 
903
- // $str = ent2ncr(esc_html($str));
904
  $str = '<![CDATA[' . str_replace( ']]>', ']]]]><![CDATA[>', $str ) . ']]>';
905
 
906
  return $str;
@@ -939,7 +939,7 @@ class FrmXMLHelper {
939
  * @param string $post_type
940
  */
941
  private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
942
- if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
943
  return;
944
  }
945
 
@@ -959,7 +959,7 @@ class FrmXMLHelper {
959
  if ( isset( $form_options[ $post_setting ] ) ) {
960
  $new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ];
961
  }
962
- unset($post_setting);
963
  }
964
 
965
  $new_action['event'] = array( 'create', 'update' );
@@ -973,7 +973,7 @@ class FrmXMLHelper {
973
 
974
  $new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields );
975
  }
976
- $new_action['post_content'] = json_encode($new_action['post_content']);
977
 
978
  $exists = get_posts( array(
979
  'name' => $new_action['post_name'],
@@ -1073,11 +1073,11 @@ class FrmXMLHelper {
1073
  'numberposts' => 1,
1074
  ) );
1075
 
1076
- if ( empty($exists) ) {
1077
  FrmDb::save_json_post( $new_notification );
1078
  $imported['imported']['actions']++;
1079
  }
1080
- unset($new_notification);
1081
  }
1082
 
1083
  self::remove_deprecated_notification_settings( $form_id, $form_options );
@@ -1110,7 +1110,7 @@ class FrmXMLHelper {
1110
  $form_options['notification'] = array( 0 => $form_options['notification'] );
1111
  }
1112
 
1113
- if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
1114
  foreach ( $form_options['notification'] as $email_key => $notification ) {
1115
 
1116
  $atts = array(
@@ -1163,7 +1163,7 @@ class FrmXMLHelper {
1163
  $atts['event'] = array( 'create' );
1164
  if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
1165
  $atts['event'][] = 'update';
1166
- } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
1167
  $atts['event'] = array( 'update' );
1168
  }
1169
  }
@@ -1187,7 +1187,7 @@ class FrmXMLHelper {
1187
  $atts['email_to'][ $key ] = '[' . $email_field . ']';
1188
  }
1189
 
1190
- if ( strpos( $email_field, '|') ) {
1191
  $email_opt = explode( '|', $email_field );
1192
  if ( isset( $email_opt[0] ) ) {
1193
  $atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
@@ -1195,7 +1195,7 @@ class FrmXMLHelper {
1195
  unset( $email_opt );
1196
  }
1197
  }
1198
- $atts['email_to'] = implode(', ', $atts['email_to']);
1199
  }
1200
 
1201
  private static function setup_new_notification( &$new_notification, $notification, $atts ) {
@@ -1242,41 +1242,41 @@ class FrmXMLHelper {
1242
  if ( is_numeric( $email_key ) ) {
1243
  $post_content['conditions'][ $email_key ] = self::switch_action_field_ids( $val, array( 'hide_field' ) );
1244
  }
1245
- unset( $email_key, $val);
1246
  }
1247
  }
1248
  }
1249
 
1250
  private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1251
- if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) {
1252
- // migrate autoresponder
1253
-
1254
- $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0;
1255
- if ( strpos($email_field, '|') ) {
1256
- // data from entries field
1257
- $email_field = explode('|', $email_field);
1258
- if ( isset($email_field[1]) ) {
1259
- $email_field = $email_field[1];
1260
- }
1261
- }
1262
- if ( is_numeric($email_field) && ! empty($email_field) ) {
1263
  $email_field = '[' . $email_field . ']';
1264
- }
1265
 
1266
  $notification = $form_options;
1267
  $new_notification2 = array(
1268
- 'post_content' => array(
1269
- 'email_message' => $notification['ar_email_message'],
1270
- 'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '',
1271
- 'email_to' => $email_field,
1272
- 'plain_text' => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0,
1273
- 'inc_user_info' => 0,
1274
- ),
1275
  'post_name' => $form_id . '_email_' . count( $notifications ),
1276
  );
1277
 
1278
- $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1279
- $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1280
 
1281
  if ( ! empty( $reply_to ) ) {
1282
  $new_notification2['post_content']['reply_to'] = $reply_to;
1
  <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
  die( 'You are not allowed to call this page directly.' );
4
  }
5
 
40
  'terms' => array(),
41
  );
42
 
43
+ unset( $defaults );
44
 
45
  if ( ! defined( 'WP_IMPORTING' ) ) {
46
+ define( 'WP_IMPORTING', true );
47
  }
48
 
49
  if ( ! class_exists( 'DOMDocument' ) ) {
56
  return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() );
57
  }
58
 
59
+ if ( ! function_exists( 'simplexml_import_dom' ) ) {
60
  return new WP_Error( 'SimpleXML_parse_error', __( 'Your server is missing the simplexml_import_dom function', 'formidable' ), libxml_get_errors() );
61
  }
62
 
71
  // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order
72
  foreach ( array( 'term', 'form', 'view' ) as $item_type ) {
73
  // grab cats, tags, and terms, or forms or posts
74
+ if ( isset( $xml->{$item_type} ) ) {
75
  $function_name = 'import_xml_' . $item_type . 's';
76
  $imported = self::$function_name( $xml->{$item_type}, $imported );
77
  unset( $function_name, $xml->{$item_type} );
78
  }
79
  }
80
 
81
+ $return = apply_filters( 'frm_importing_xml', $imported, $xml );
82
 
83
  return $return;
84
  }
169
 
170
  do_action( 'frm_after_import_form', $form_id, $form );
171
 
172
+ unset( $form, $item );
173
  }
174
 
175
  self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms );
225
  foreach ( $form_fields as $f ) {
226
  $old_fields[ $f->id ] = $f;
227
  $old_fields[ $f->field_key ] = $f->id;
228
+ unset( $f );
229
  }
230
  $form_fields = $old_fields;
231
  return $form_fields;
256
  $regular_forms = array();
257
 
258
  foreach ( $forms as $form ) {
259
+ $parent_form_id = isset( $form->parent_form_id ) ? (int) $form->parent_form_id : 0;
260
 
261
  if ( $parent_form_id ) {
262
  $child_forms[] = $form;
327
  self::maybe_update_form_select( $f, $imported );
328
  self::maybe_update_get_values_form_setting( $imported, $f );
329
 
330
+ if ( ! empty( $this_form ) ) {
331
  // check for field to edit by field id
332
  if ( isset( $form_fields[ $f['id'] ] ) ) {
333
  FrmField::update( $f['id'], $f );
341
  }
342
  } else if ( isset( $form_fields[ $f['field_key'] ] ) ) {
343
  // check for field to edit by field key
344
+ unset( $f['id'] );
345
 
346
  FrmField::update( $form_fields[ $f['field_key'] ], $f );
347
  $imported['updated']['fields']++;
366
  'name' => (string) $field->name,
367
  'description' => (string) $field->description,
368
  'type' => (string) $field->type,
369
+ 'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value ),
370
  'field_order' => (int) $field->field_order,
371
  'form_id' => (int) $form_id,
372
  'required' => (int) $field->required,
373
+ 'options' => FrmAppHelper::maybe_json_decode( (string) $field->options ),
374
  'field_options' => FrmAppHelper::maybe_json_decode( (string) $field->field_options ),
375
  );
376
  }
550
  );
551
 
552
  $old_id = $post['post_id'];
553
+ self::populate_post( $post, $item, $imported );
554
 
555
+ unset( $item );
556
 
557
  $post_id = false;
558
  if ( $post['post_type'] == $form_action_type ) {
560
  if ( $action_control && is_object( $action_control ) ) {
561
  $post_id = $action_control->maybe_create_action( $post, $imported['form_status'] );
562
  }
563
+ unset( $action_control );
564
  } else if ( $post['post_type'] == 'frm_styles' ) {
565
  // Properly encode post content before inserting the post
566
  $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
575
  $post_id = wp_insert_post( $post );
576
  }
577
 
578
+ if ( ! is_numeric( $post_id ) ) {
579
  continue;
580
  }
581
 
582
+ self::update_postmeta( $post, $post_id );
583
 
584
  $this_type = 'posts';
585
  if ( isset( $post_types[ $post['post_type'] ] ) ) {
586
  $this_type = $post_types[ $post['post_type'] ];
587
  }
588
 
589
+ if ( isset( $post['ID'] ) && $post_id == $post['ID'] ) {
590
  $imported['updated'][ $this_type ]++;
591
  } else {
592
  $imported['imported'][ $this_type ]++;
605
  }
606
 
607
  private static function populate_post( &$post, $item, $imported ) {
608
+ if ( isset( $item->attachment_url ) ) {
609
  $post['attachment_url'] = (string) $item->attachment_url;
610
  }
611
 
620
  }
621
 
622
  foreach ( $item->postmeta as $meta ) {
623
+ self::populate_postmeta( $post, $meta, $imported );
624
+ unset( $meta );
625
  }
626
 
627
+ self::populate_taxonomies( $post, $item );
628
 
629
+ self::maybe_editing_post( $post );
630
  }
631
 
632
  private static function populate_postmeta( &$post, $meta, $imported ) {
638
  );
639
 
640
  //switch old form and field ids to new ones
641
+ if ( $m['key'] == 'frm_form_id' && isset( $imported['forms'][ (int) $m['value'] ] ) ) {
642
  $m['value'] = $imported['forms'][ (int) $m['value'] ];
643
  } else {
644
+ $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] );
645
 
646
+ if ( ! empty( $frm_duplicate_ids ) ) {
647
 
648
  if ( $m['key'] == 'frm_dyncontent' ) {
649
+ $m['value'] = FrmFieldsHelper::switch_field_ids( $m['value'] );
650
  } else if ( $m['key'] == 'frm_options' ) {
651
 
652
  foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) {
673
  if ( isset( $frm_duplicate_ids[ $mv ] ) ) {
674
  $m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ];
675
  }
676
+ unset( $mk, $mv );
677
  }
678
  }
679
  }
680
  }
681
  }
682
 
683
+ if ( ! is_array( $m['value'] ) ) {
684
+ $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] );
685
  }
686
 
687
  $post['postmeta'][ (string) $meta->meta_key ] = $m['value'];
700
  }
701
 
702
  $taxonomy = (string) $att['domain'];
703
+ if ( is_taxonomy_hierarchical( $taxonomy ) ) {
704
  $name = (string) $att['nicename'];
705
+ $h_term = get_term_by( 'slug', $name, $taxonomy );
706
  if ( $h_term ) {
707
  $name = $h_term->term_id;
708
  }
709
+ unset( $h_term );
710
  } else {
711
  $name = (string) $c;
712
  }
716
  }
717
 
718
  $post['tax_input'][ $taxonomy ][] = $name;
719
+ unset( $name );
720
  }
721
  }
722
 
733
 
734
  if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) {
735
  $match_by['include'] = $post['post_id'];
736
+ unset( $match_by['name'] );
737
  }
738
 
739
+ $editing = get_posts( $match_by );
740
 
741
+ if ( ! empty( $editing ) && current( $editing )->post_date == $post['post_date'] ) {
742
+ // set the id of the post to edit
743
+ $post['ID'] = current( $editing )->ID;
744
+ }
745
  }
746
 
747
  private static function update_postmeta( &$post, $post_id ) {
748
  foreach ( $post['postmeta'] as $k => $v ) {
749
  if ( '_edit_last' == $k ) {
750
+ $v = FrmAppHelper::get_user_id_param( $v );
751
  } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
752
  //change the attachment ID
753
  $field_obj = FrmFieldFactory::get_field_type( 'file' );
754
  $v = $field_obj->get_file_id( $v );
755
  }
756
 
757
+ update_post_meta( $post_id, $k, $v );
758
 
759
+ unset( $k, $v );
760
  }
761
  }
762
 
795
  * @param string $message
796
  */
797
  public static function parse_message( $result, &$message, &$errors ) {
798
+ if ( is_wp_error( $result ) ) {
799
  $errors[] = $result->get_error_message();
800
  } else if ( ! $result ) {
801
  return;
802
  }
803
 
804
+ if ( ! is_array( $result ) ) {
805
  $message = is_string( $result ) ? $result : htmlentities( print_r( $result, 1 ) );
806
  return;
807
  }
818
  continue;
819
  }
820
 
821
+ $s_message = array();
822
+ foreach ( $results as $k => $m ) {
823
+ self::item_count_message( $m, $k, $s_message );
824
+ unset( $k, $m );
825
+ }
826
 
827
+ if ( ! empty( $s_message ) ) {
828
  $message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> ';
829
+ $message .= implode( ', ', $s_message );
830
+ $message .= '</li>';
831
+ }
832
  }
833
 
834
  if ( $message == '<ul>' ) {
887
  }
888
 
889
  public static function cdata( $str ) {
890
+ $str = maybe_unserialize( $str );
891
+ if ( is_array( $str ) ) {
892
+ $str = json_encode( $str );
893
  } else if ( seems_utf8( $str ) == false ) {
894
  $str = utf8_encode( $str );
895
  }
896
 
897
+ if ( is_numeric( $str ) ) {
898
  return $str;
899
  }
900
 
901
  self::remove_invalid_characters_from_xml( $str );
902
 
903
+ // $str = ent2ncr(esc_html( $str));
904
  $str = '<![CDATA[' . str_replace( ']]>', ']]]]><![CDATA[>', $str ) . ']]>';
905
 
906
  return $str;
939
  * @param string $post_type
940
  */
941
  private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
942
+ if ( ! isset( $form_options['create_post'] ) || ! $form_options['create_post'] ) {
943
  return;
944
  }
945
 
959
  if ( isset( $form_options[ $post_setting ] ) ) {
960
  $new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ];
961
  }
962
+ unset( $post_setting );
963
  }
964
 
965
  $new_action['event'] = array( 'create', 'update' );
973
 
974
  $new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields );
975
  }
976
+ $new_action['post_content'] = json_encode( $new_action['post_content'] );
977
 
978
  $exists = get_posts( array(
979
  'name' => $new_action['post_name'],
1073
  'numberposts' => 1,
1074
  ) );
1075
 
1076
+ if ( empty( $exists ) ) {
1077
  FrmDb::save_json_post( $new_notification );
1078
  $imported['imported']['actions']++;
1079
  }
1080
+ unset( $new_notification );
1081
  }
1082
 
1083
  self::remove_deprecated_notification_settings( $form_id, $form_options );
1110
  $form_options['notification'] = array( 0 => $form_options['notification'] );
1111
  }
1112
 
1113
+ if ( isset( $form_options['notification'] ) && is_array( $form_options['notification'] ) ) {
1114
  foreach ( $form_options['notification'] as $email_key => $notification ) {
1115
 
1116
  $atts = array(
1163
  $atts['event'] = array( 'create' );
1164
  if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
1165
  $atts['event'][] = 'update';
1166
+ } elseif ( isset( $notification['update_email'] ) && 2 == $notification['update_email'] ) {
1167
  $atts['event'] = array( 'update' );
1168
  }
1169
  }
1187
  $atts['email_to'][ $key ] = '[' . $email_field . ']';
1188
  }
1189
 
1190
+ if ( strpos( $email_field, '|' ) ) {
1191
  $email_opt = explode( '|', $email_field );
1192
  if ( isset( $email_opt[0] ) ) {
1193
  $atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1195
  unset( $email_opt );
1196
  }
1197
  }
1198
+ $atts['email_to'] = implode( ', ', $atts['email_to'] );
1199
  }
1200
 
1201
  private static function setup_new_notification( &$new_notification, $notification, $atts ) {
1242
  if ( is_numeric( $email_key ) ) {
1243
  $post_content['conditions'][ $email_key ] = self::switch_action_field_ids( $val, array( 'hide_field' ) );
1244
  }
1245
+ unset( $email_key, $val );
1246
  }
1247
  }
1248
  }
1249
 
1250
  private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1251
+ if ( isset( $form_options['auto_responder'] ) && $form_options['auto_responder'] && isset( $form_options['ar_email_message'] ) && $form_options['ar_email_message'] ) {
1252
+ // migrate autoresponder
1253
+
1254
+ $email_field = isset( $form_options['ar_email_to'] ) ? $form_options['ar_email_to'] : 0;
1255
+ if ( strpos( $email_field, '|' ) ) {
1256
+ // data from entries field
1257
+ $email_field = explode( '|', $email_field );
1258
+ if ( isset( $email_field[1] ) ) {
1259
+ $email_field = $email_field[1];
1260
+ }
1261
+ }
1262
+ if ( is_numeric( $email_field ) && ! empty( $email_field ) ) {
1263
  $email_field = '[' . $email_field . ']';
1264
+ }
1265
 
1266
  $notification = $form_options;
1267
  $new_notification2 = array(
1268
+ 'post_content' => array(
1269
+ 'email_message' => $notification['ar_email_message'],
1270
+ 'email_subject' => isset( $notification['ar_email_subject'] ) ? $notification['ar_email_subject'] : '',
1271
+ 'email_to' => $email_field,
1272
+ 'plain_text' => isset( $notification['ar_plain_text'] ) ? $notification['ar_plain_text'] : 0,
1273
+ 'inc_user_info' => 0,
1274
+ ),
1275
  'post_name' => $form_id . '_email_' . count( $notifications ),
1276
  );
1277
 
1278
+ $reply_to = isset( $notification['ar_reply_to'] ) ? $notification['ar_reply_to'] : '';
1279
+ $reply_to_name = isset( $notification['ar_reply_to_name'] ) ? $notification['ar_reply_to_name'] : '';
1280
 
1281
  if ( ! empty( $reply_to ) ) {
1282
  $new_notification2['post_content']['reply_to'] = $reply_to;
classes/models/FrmAddon.php CHANGED
@@ -155,7 +155,7 @@ class FrmAddon {
155
  echo '<tr class="plugin-update-tr active"><td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange"><div class="update-message">';
156
 
157
  /* translators: %1$s: Plugin name, %2$s: Start link HTML, %3$s: end link HTML */
158
- printf( esc_html__( 'Your %1$s license key is missing. Please add it on the %2$slicenses page%3$s.', 'formidable' ), esc_html( $this->plugin_name ), '<a href="' . esc_url( admin_url('admin.php?page=formidable-settings&t=licenses_settings' ) ) . '">', '</a>' );
159
  $id = sanitize_title( $plugin['Name'] );
160
  echo '<script type="text/javascript">var d = document.getElementById("' . esc_attr( $id ) . '");if ( d !== null ){ d.className = d.className + " update"; }</script>';
161
  echo '</div></td></tr>';
155
  echo '<tr class="plugin-update-tr active"><td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange"><div class="update-message">';
156
 
157
  /* translators: %1$s: Plugin name, %2$s: Start link HTML, %3$s: end link HTML */
158
+ printf( esc_html__( 'Your %1$s license key is missing. Please add it on the %2$slicenses page%3$s.', 'formidable' ), esc_html( $this->plugin_name ), '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-settings&t=licenses_settings' ) ) . '">', '</a>' );
159
  $id = sanitize_title( $plugin['Name'] );
160
  echo '<script type="text/javascript">var d = document.getElementById("' . esc_attr( $id ) . '");if ( d !== null ){ d.className = d.className + " update"; }</script>';
161
  echo '</div></td></tr>';
classes/models/FrmCreateFile.php CHANGED
@@ -21,8 +21,8 @@ class FrmCreateFile {
21
  $this->error_message = isset( $atts['error_message'] ) ? $atts['error_message'] : '';
22
  $this->uploads = wp_upload_dir();
23
  $this->set_new_file_path( $atts );
24
- $this->chmod_dir = defined('FS_CHMOD_DIR') ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 );
25
- $this->chmod_file = defined('FS_CHMOD_FILE') ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 );
26
 
27
  $this->check_permission();
28
  }
@@ -153,7 +153,7 @@ class FrmCreateFile {
153
  }
154
 
155
  private function get_creds() {
156
- if ( ! function_exists('get_filesystem_method') ) {
157
  include_once( ABSPATH . 'wp-admin/includes/file.php' );
158
  }
159
 
@@ -172,13 +172,13 @@ class FrmCreateFile {
172
  'username' => '',
173
  ) );
174
 
175
- $credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : $credentials['hostname'];
176
- $credentials['username'] = defined('FTP_USER') ? FTP_USER : $credentials['username'];
177
- $credentials['password'] = defined('FTP_PASS') ? FTP_PASS : '';
178
 
179
  // Check to see if we are setting the public/private keys for ssh
180
- $credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : '';
181
- $credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : '';
182
 
183
  // Sanitize the hostname, Some people might pass in odd-data:
184
  $credentials['hostname'] = preg_replace( '|\w+://|', '', $credentials['hostname'] ); //Strip any schemes off
21
  $this->error_message = isset( $atts['error_message'] ) ? $atts['error_message'] : '';
22
  $this->uploads = wp_upload_dir();
23
  $this->set_new_file_path( $atts );
24
+ $this->chmod_dir = defined( 'FS_CHMOD_DIR' ) ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 );
25
+ $this->chmod_file = defined( 'FS_CHMOD_FILE' ) ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 );
26
 
27
  $this->check_permission();
28
  }
153
  }
154
 
155
  private function get_creds() {
156
+ if ( ! function_exists( 'get_filesystem_method' ) ) {
157
  include_once( ABSPATH . 'wp-admin/includes/file.php' );
158
  }
159
 
172
  'username' => '',
173
  ) );
174
 
175
+ $credentials['hostname'] = defined( 'FTP_HOST' ) ? FTP_HOST : $credentials['hostname'];
176
+ $credentials['username'] = defined( 'FTP_USER' ) ? FTP_USER : $credentials['username'];
177
+ $credentials['password'] = defined( 'FTP_PASS' ) ? FTP_PASS : '';
178
 
179
  // Check to see if we are setting the public/private keys for ssh
180
+ $credentials['public_key'] = defined( 'FTP_PUBKEY' ) ? FTP_PUBKEY : '';
181
+ $credentials['private_key'] = defined( 'FTP_PRIKEY' ) ? FTP_PRIKEY : '';
182
 
183
  // Sanitize the hostname, Some people might pass in odd-data:
184
  $credentials['hostname'] = preg_replace( '|\w+://|', '', $credentials['hostname'] ); //Strip any schemes off
classes/models/FrmDb.php CHANGED
@@ -7,9 +7,9 @@ class FrmDb {
7
  public $entry_metas;
8
 
9
  public function __construct() {
10
- if ( ! defined('ABSPATH') ) {
11
- die('You are not allowed to call this page directly.');
12
- }
13
 
14
  _deprecated_function( __METHOD__, '2.05.06', 'FrmMigrate' );
15
  global $wpdb;
@@ -26,7 +26,7 @@ class FrmDb {
26
  * @param string $starts_with
27
  */
28
  public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) {
29
- if ( empty($args) ) {
30
  // add an arg to prevent prepare from failing
31
  $args = array(
32
  'where' => $starts_with . '1=%d',
@@ -94,7 +94,7 @@ class FrmDb {
94
  $key = trim( $key );
95
 
96
  if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false ) {
97
- $k = explode(' ', $key);
98
  $where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key );
99
  $values[] = '%Y-%m-%d %H:%i:%s';
100
  } else {
@@ -107,7 +107,7 @@ class FrmDb {
107
  if ( is_array( $value ) ) {
108
  // translate array of values to "in"
109
  if ( strpos( $lowercase_key, 'like' ) !== false ) {
110
- $where = preg_replace('/' . $key . '$/', '', $where);
111
  $where .= '(';
112
  $start = true;
113
  foreach ( $value as $v ) {
@@ -316,8 +316,8 @@ class FrmDb {
316
  private static function get_group_and_table_name( &$table, &$group ) {
317
  global $wpdb, $wpmuBaseTablePrefix;
318
 
319
- $table_parts = explode(' ', $table);
320
- $group = reset($table_parts);
321
  $group = str_replace( $wpdb->prefix, '', $group );
322
 
323
  $prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix : $wpdb->base_prefix;
@@ -332,7 +332,7 @@ class FrmDb {
332
  }
333
 
334
  private static function convert_options_to_array( &$args, $order_by = '', $limit = '' ) {
335
- if ( ! is_array($args) ) {
336
  $args = array( 'order_by' => $args );
337
  }
338
 
@@ -694,11 +694,11 @@ class FrmDb {
694
  * @deprecated 2.05.06
695
  * @codeCoverageIgnore
696
  */
697
- public function upgrade( $old_db_version = false ) {
698
  _deprecated_function( __METHOD__, '2.05.06', 'FrmMigrate::upgrade' );
699
 
700
  $db = new FrmMigrate();
701
- $db->upgrade( $old_db_version );
702
  }
703
 
704
  /**
7
  public $entry_metas;
8
 
9
  public function __construct() {
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ die( 'You are not allowed to call this page directly.' );
12
+ }
13
 
14
  _deprecated_function( __METHOD__, '2.05.06', 'FrmMigrate' );
15
  global $wpdb;
26
  * @param string $starts_with
27
  */
28
  public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) {
29
+ if ( empty( $args ) ) {
30
  // add an arg to prevent prepare from failing
31
  $args = array(
32
  'where' => $starts_with . '1=%d',
94
  $key = trim( $key );
95
 
96
  if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false ) {
97
+ $k = explode( ' ', $key );
98
  $where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key );
99
  $values[] = '%Y-%m-%d %H:%i:%s';
100
  } else {
107
  if ( is_array( $value ) ) {
108
  // translate array of values to "in"
109
  if ( strpos( $lowercase_key, 'like' ) !== false ) {
110
+ $where = preg_replace( '/' . $key . '$/', '', $where );
111
  $where .= '(';
112
  $start = true;
113
  foreach ( $value as $v ) {
316
  private static function get_group_and_table_name( &$table, &$group ) {
317
  global $wpdb, $wpmuBaseTablePrefix;
318
 
319
+ $table_parts = explode( ' ', $table );
320
+ $group = reset( $table_parts );
321
  $group = str_replace( $wpdb->prefix, '', $group );
322
 
323
  $prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix : $wpdb->base_prefix;
332
  }
333
 
334
  private static function convert_options_to_array( &$args, $order_by = '', $limit = '' ) {
335
+ if ( ! is_array( $args ) ) {
336
  $args = array( 'order_by' => $args );
337
  }
338
 
694
  * @deprecated 2.05.06
695
  * @codeCoverageIgnore
696
  */
697
+ public function upgrade() {
698
  _deprecated_function( __METHOD__, '2.05.06', 'FrmMigrate::upgrade' );
699
 
700
  $db = new FrmMigrate();
701
+ $db->upgrade();
702
  }
703
 
704
  /**
classes/models/FrmDbDeprecated.php CHANGED
@@ -27,11 +27,11 @@ class FrmDbDeprecated {
27
  /**
28
  * @deprecated 2.03.05
29
  */
30
- public function upgrade( $old_db_version = false ) {
31
  _deprecated_function( __FUNCTION__, '2.03.05', 'FrmDb::upgrade( $old_db_version )' );
32
 
33
  $db = new FrmMigrate();
34
- $db->upgrade( $old_db_version );
35
  }
36
 
37
  /**
27
  /**
28
  * @deprecated 2.03.05
29
  */
30
+ public function upgrade() {
31
  _deprecated_function( __FUNCTION__, '2.03.05', 'FrmDb::upgrade( $old_db_version )' );
32
 
33
  $db = new FrmMigrate();
34
+ $db->upgrade();
35
  }
36
 
37
  /**
classes/models/FrmEntry.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- if ( ! defined('ABSPATH') ) {
3
  die( 'You are not allowed to call this page directly.' );
4
  }
5
 
@@ -55,13 +55,13 @@ class FrmEntry {
55
  unset( $check_val['is_draft'], $check_val['id'], $check_val['item_key'] );
56
 
57
  if ( $new_values['item_key'] == $new_values['name'] ) {
58
- unset($check_val['name']);
59
  }
60
 
61
  global $wpdb;
62
  $entry_exists = FrmDb::get_col( $wpdb->prefix . 'frm_items', $check_val, 'id', array( 'order_by' => 'created_at DESC' ) );
63
 
64
- if ( ! $entry_exists || empty($entry_exists) || ! isset($values['item_meta']) ) {
65
  return false;
66
  }
67
 
@@ -70,7 +70,7 @@ class FrmEntry {
70
  $is_duplicate = true;
71
 
72
  //add more checks here to make sure it's a duplicate
73
- $metas = FrmEntryMeta::get_entry_meta_info($entry_exist);
74
  $field_metas = array();
75
  foreach ( $metas as $meta ) {
76
  $field_metas[ $meta->field_id ] = $meta->meta_value;
@@ -82,9 +82,9 @@ class FrmEntry {
82
  return false;
83
  }
84
 
85
- $diff = array_diff_assoc($field_metas, array_map('maybe_serialize', $values['item_meta']));
86
  foreach ( $diff as $field_id => $meta_value ) {
87
- if ( ! empty($meta_value) ) {
88
  $is_duplicate = false;
89
  continue;
90
  }
@@ -113,7 +113,7 @@ class FrmEntry {
113
  }
114
 
115
  // If CSV is importing, don't check for duplicates
116
- if ( defined('WP_IMPORTING') && WP_IMPORTING ) {
117
  return false;
118
  }
119
 
@@ -148,12 +148,12 @@ class FrmEntry {
148
  $entry_id = $wpdb->insert_id;
149
 
150
  global $frm_vars;
151
- if ( ! isset($frm_vars['saved_entries']) ) {
152
  $frm_vars['saved_entries'] = array();
153
  }
154
  $frm_vars['saved_entries'][] = (int) $entry_id;
155
 
156
- FrmEntryMeta::duplicate_entry_metas($id, $entry_id);
157
  self::clear_cache();
158
 
159
  do_action( 'frm_after_duplicate_entry', $entry_id, $new_values['form_id'], array( 'old_id' => $id ) );
@@ -192,7 +192,7 @@ class FrmEntry {
192
 
193
  $new_values = self::package_entry_to_update( $id, $values );
194
 
195
- $query_results = $wpdb->update( $wpdb->prefix . 'frm_items', $new_values, compact('id') );
196
 
197
  self::after_update_entry( $query_results, $id, $values, $new_values );
198
 
@@ -209,7 +209,7 @@ class FrmEntry {
209
  return $result;
210
  }
211
 
212
- do_action('frm_before_destroy_entry', $id, $entry);
213
 
214
  $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE item_id=%d', $id ) );
215
  $result = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_items WHERE id=%d', $id ) );
@@ -221,7 +221,7 @@ class FrmEntry {
221
 
222
  public static function update_form( $id, $value, $form_id ) {
223
  global $wpdb;
224
- $form_id = isset($value) ? $form_id : null;
225
  $result = $wpdb->update( $wpdb->prefix . 'frm_items', array( 'form_id' => $form_id ), array( 'id' => $id ) );
226
  if ( $result ) {
227
  self::clear_cache();
@@ -274,24 +274,24 @@ class FrmEntry {
274
  $query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it
275
  LEFT OUTER JOIN {$wpdb->prefix}frm_forms fr ON it.form_id=fr.id WHERE ";
276
 
277
- $query .= is_numeric($id) ? 'it.id=%d' : 'it.item_key=%s';
278
  $query_args = array( $id );
279
  $query = $wpdb->prepare( $query, $query_args );
280
 
281
  if ( ! $meta ) {
282
  $entry = FrmDb::check_cache( $id . '_nometa', 'frm_entry', $query, 'get_row' );
283
- return stripslashes_deep($entry);
284
  }
285
 
286
- $entry = FrmDb::check_cache( $id, 'frm_entry' );
287
- if ( $entry !== false ) {
288
- return stripslashes_deep($entry);
289
- }
290
 
291
- $entry = $wpdb->get_row( $query );
292
- $entry = self::get_meta($entry);
293
 
294
- return stripslashes_deep($entry);
295
  }
296
 
297
  public static function get_meta( $entry ) {
@@ -324,9 +324,9 @@ class FrmEntry {
324
 
325
  $entry->metas[ $meta_val->field_id ][] = maybe_unserialize( $meta_val->meta_value );
326
 
327
- unset($meta_val);
328
  }
329
- unset($metas);
330
 
331
  FrmDb::set_cache( $entry->id, $entry, 'frm_entry' );
332
 
@@ -344,7 +344,7 @@ class FrmEntry {
344
  return $exists;
345
  }
346
 
347
- if ( is_numeric($id) ) {
348
  $where = array( 'id' => $id );
349
  } else {
350
  $where = array( 'item_key' => $id );
@@ -357,10 +357,10 @@ class FrmEntry {
357
  public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) {
358
  global $wpdb;
359
 
360
- $limit = FrmDb::esc_limit($limit);
361
 
362
- $cache_key = maybe_serialize($where) . $order_by . $limit . $inc_form;
363
- $entries = wp_cache_get($cache_key, 'frm_entry');
364
 
365
  if ( false === $entries ) {
366
  $fields = 'it.id, it.item_key, it.name, it.ip, it.form_id, it.post_id, it.user_id, it.parent_item_id, it.updated_by, it.created_at, it.updated_at, it.is_draft';
@@ -379,25 +379,25 @@ class FrmEntry {
379
  }
380
 
381
  // prepare the query
382
- $query = 'SELECT ' . $fields . ' FROM ' . $table . FrmDb::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
383
 
384
- $entries = $wpdb->get_results($query, OBJECT_K);
385
- unset($query);
386
 
387
  FrmDb::set_cache( $cache_key, $entries, 'frm_entry' );
388
  }
389
 
390
  if ( ! $meta || ! $entries ) {
391
- return stripslashes_deep($entries);
392
  }
393
- unset($meta);
394
 
395
- if ( ! is_array( $where ) && preg_match('/^it\.form_id=\d+$/', $where) ) {
396
  $where = array( 'it.form_id' => substr( $where, 11 ) );
397
  }
398
 
399
  $meta_where = array( 'field_id !' => 0 );
400
- if ( $limit == '' && is_array($where) && count($where) == 1 && isset($where['it.form_id']) ) {
401
  $meta_where['fi.form_id'] = $where['it.form_id'];
402
  } else {
403
  $meta_where['item_id'] = array_keys( $entries );
@@ -408,7 +408,7 @@ class FrmEntry {
408
  unset( $meta_where );
409
 
410
  if ( ! $metas ) {
411
- return stripslashes_deep($entries);
412
  }
413
 
414
  foreach ( $metas as $m_key => $meta_val ) {
@@ -422,7 +422,7 @@ class FrmEntry {
422
 
423
  $entries[ $meta_val->item_id ]->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value );
424
 
425
- unset($m_key, $meta_val);
426
  }
427
 
428
  if ( ! FrmAppHelper::prevent_caching() ) {
@@ -432,7 +432,7 @@ class FrmEntry {
432
  }
433
  }
434
 
435
- return stripslashes_deep($entries);
436
  }
437
 
438
  // Pagination Methods
@@ -440,7 +440,7 @@ class FrmEntry {
440
  global $wpdb;
441
  $table_join = $wpdb->prefix . 'frm_items it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id';
442
 
443
- if ( is_numeric($where) ) {
444
  $table_join = 'frm_items';
445
  $where = array( 'form_id' => $where );
446
  }
@@ -482,7 +482,7 @@ class FrmEntry {
482
  self::sanitize_entry_post( $values );
483
 
484
  if ( $type != 'xml' ) {
485
- $values = apply_filters('frm_pre_create_entry', $values);
486
  }
487
 
488
  $new_values = self::package_entry_data( $values );
@@ -562,7 +562,7 @@ class FrmEntry {
562
  'user_id' => self::get_entry_user_id( $values ),
563
  );
564
 
565
- $new_values['updated_by'] = isset($values['updated_by']) ? $values['updated_by'] : $new_values['user_id'];
566
 
567
  return $new_values;
568
  }
@@ -585,7 +585,7 @@ class FrmEntry {
585
  }
586
 
587
  $ip = FrmAppHelper::get_ip_address();
588
- if ( defined('WP_IMPORTING') && WP_IMPORTING ) {
589
  $ip = self::get_entry_value( $values, 'ip', $ip );
590
  }
591
  return $ip;
@@ -698,7 +698,7 @@ class FrmEntry {
698
  private static function add_new_entry_to_frm_vars( $entry_id ) {
699
  global $frm_vars;
700
 
701
- if ( ! isset($frm_vars['saved_entries']) ) {
702
  $frm_vars['saved_entries'] = array();
703
  }
704
 
@@ -713,7 +713,7 @@ class FrmEntry {
713
  * @param int $entry_id
714
  */
715
  private static function maybe_add_entry_metas( $values, $entry_id ) {
716
- if ( isset($values['item_meta']) ) {
717
  FrmEntryMeta::update_entry_metas( $entry_id, $values['item_meta'] );
718
  }
719
  }
@@ -771,7 +771,7 @@ class FrmEntry {
771
  }
772
 
773
  if ( $update && $update_type != 'xml' ) {
774
- $values = apply_filters('frm_pre_update_entry', $values, $id);
775
  }
776
 
777
  return $update;
@@ -792,27 +792,27 @@ class FrmEntry {
792
  'name' => self::get_new_entry_name( $values ),
793
  'form_id' => (int) self::get_entry_value( $values, 'form_id', null ),
794
  'is_draft' => self::get_is_draft_value( $values ),
795
- 'updated_at' => current_time('mysql', 1),
796
- 'updated_by' => isset($values['updated_by']) ? $values['updated_by'] : get_current_user_id(),
797
  );
798
 
799
- if ( isset($values['post_id']) ) {
800
  $new_values['post_id'] = (int) $values['post_id'];
801
  }
802
 
803
- if ( isset($values['item_key']) ) {
804
  $new_values['item_key'] = FrmAppHelper::get_unique_key( $values['item_key'], $wpdb->prefix . 'frm_items', 'item_key', $id );
805
  }
806
 
807
- if ( isset($values['parent_item_id']) ) {
808
  $new_values['parent_item_id'] = (int) $values['parent_item_id'];
809
  }
810
 
811
- if ( isset($values['frm_user_id']) && is_numeric($values['frm_user_id']) ) {
812
  $new_values['user_id'] = $values['frm_user_id'];
813
  }
814
 
815
- $new_values = apply_filters('frm_update_entry', $new_values, $id);
816
 
817
  return $new_values;
818
  }
1
  <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
  die( 'You are not allowed to call this page directly.' );
4
  }
5
 
55
  unset( $check_val['is_draft'], $check_val['id'], $check_val['item_key'] );
56
 
57
  if ( $new_values['item_key'] == $new_values['name'] ) {
58
+ unset( $check_val['name'] );
59
  }
60
 
61
  global $wpdb;
62
  $entry_exists = FrmDb::get_col( $wpdb->prefix . 'frm_items', $check_val, 'id', array( 'order_by' => 'created_at DESC' ) );
63
 
64
+ if ( ! $entry_exists || empty( $entry_exists ) || ! isset( $values['item_meta'] ) ) {
65
  return false;
66
  }
67
 
70
  $is_duplicate = true;
71
 
72
  //add more checks here to make sure it's a duplicate
73
+ $metas = FrmEntryMeta::get_entry_meta_info( $entry_exist );
74
  $field_metas = array();
75
  foreach ( $metas as $meta ) {
76
  $field_metas[ $meta->field_id ] = $meta->meta_value;
82
  return false;
83
  }
84
 
85
+ $diff = array_diff_assoc( $field_metas, array_map( 'maybe_serialize', $values['item_meta'] ) );
86
  foreach ( $diff as $field_id => $meta_value ) {
87
+ if ( ! empty( $meta_value ) ) {
88
  $is_duplicate = false;
89
  continue;
90
  }
113
  }
114
 
115
  // If CSV is importing, don't check for duplicates
116
+ if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
117
  return false;
118
  }
119
 
148
  $entry_id = $wpdb->insert_id;
149
 
150
  global $frm_vars;
151
+ if ( ! isset( $frm_vars['saved_entries'] ) ) {
152
  $frm_vars['saved_entries'] = array();
153
  }
154
  $frm_vars['saved_entries'][] = (int) $entry_id;
155
 
156
+ FrmEntryMeta::duplicate_entry_metas( $id, $entry_id );
157
  self::clear_cache();
158
 
159
  do_action( 'frm_after_duplicate_entry', $entry_id, $new_values['form_id'], array( 'old_id' => $id ) );
192
 
193
  $new_values = self::package_entry_to_update( $id, $values );
194
 
195
+ $query_results = $wpdb->update( $wpdb->prefix . 'frm_items', $new_values, compact( 'id' ) );
196
 
197
  self::after_update_entry( $query_results, $id, $values, $new_values );
198
 
209
  return $result;
210
  }
211
 
212
+ do_action( 'frm_before_destroy_entry', $id, $entry );
213
 
214
  $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE item_id=%d', $id ) );
215
  $result = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_items WHERE id=%d', $id ) );
221
 
222
  public static function update_form( $id, $value, $form_id ) {
223
  global $wpdb;
224
+ $form_id = isset( $value ) ? $form_id : null;
225
  $result = $wpdb->update( $wpdb->prefix . 'frm_items', array( 'form_id' => $form_id ), array( 'id' => $id ) );
226
  if ( $result ) {
227
  self::clear_cache();
274
  $query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it
275
  LEFT OUTER JOIN {$wpdb->prefix}frm_forms fr ON it.form_id=fr.id WHERE ";
276
 
277
+ $query .= is_numeric( $id ) ? 'it.id=%d' : 'it.item_key=%s';
278
  $query_args = array( $id );
279
  $query = $wpdb->prepare( $query, $query_args );
280
 
281
  if ( ! $meta ) {
282
  $entry = FrmDb::check_cache( $id . '_nometa', 'frm_entry', $query, 'get_row' );
283
+ return stripslashes_deep( $entry );
284
  }
285
 
286
+ $entry = FrmDb::check_cache( $id, 'frm_entry' );
287
+ if ( $entry !== false ) {
288
+ return stripslashes_deep( $entry );
289
+ }
290
 
291
+ $entry = $wpdb->get_row( $query );
292
+ $entry = self::get_meta( $entry );
293
 
294
+ return stripslashes_deep( $entry );
295
  }
296
 
297
  public static function get_meta( $entry ) {
324
 
325
  $entry->metas[ $meta_val->field_id ][] = maybe_unserialize( $meta_val->meta_value );
326
 
327
+ unset( $meta_val );
328
  }
329
+ unset( $metas );
330
 
331
  FrmDb::set_cache( $entry->id, $entry, 'frm_entry' );
332
 
344
  return $exists;
345
  }
346
 
347
+ if ( is_numeric( $id ) ) {
348
  $where = array( 'id' => $id );
349
  } else {
350
  $where = array( 'item_key' => $id );
357
  public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) {
358
  global $wpdb;
359
 
360
+ $limit = FrmDb::esc_limit( $limit );
361
 
362
+ $cache_key = maybe_serialize( $where ) . $order_by . $limit . $inc_form;
363
+ $entries = wp_cache_get( $cache_key, 'frm_entry' );
364
 
365
  if ( false === $entries ) {
366
  $fields = 'it.id, it.item_key, it.name, it.ip, it.form_id, it.post_id, it.user_id, it.parent_item_id, it.updated_by, it.created_at, it.updated_at, it.is_draft';
379
  }
380
 
381
  // prepare the query
382
+ $query = 'SELECT ' . $fields . ' FROM ' . $table . FrmDb::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
383
 
384
+ $entries = $wpdb->get_results( $query, OBJECT_K );
385
+ unset( $query );
386
 
387
  FrmDb::set_cache( $cache_key, $entries, 'frm_entry' );
388
  }
389
 
390
  if ( ! $meta || ! $entries ) {
391
+ return stripslashes_deep( $entries );
392
  }
393
+ unset( $meta );
394
 
395
+ if ( ! is_array( $where ) && preg_match( '/^it\.form_id=\d+$/', $where ) ) {
396
  $where = array( 'it.form_id' => substr( $where, 11 ) );
397
  }
398
 
399
  $meta_where = array( 'field_id !' => 0 );
400
+ if ( $limit == '' && is_array( $where ) && count( $where ) == 1 && isset( $where['it.form_id'] ) ) {
401
  $meta_where['fi.form_id'] = $where['it.form_id'];
402
  } else {
403
  $meta_where['item_id'] = array_keys( $entries );
408
  unset( $meta_where );
409
 
410
  if ( ! $metas ) {
411
+ return stripslashes_deep( $entries );
412
  }
413
 
414
  foreach ( $metas as $m_key => $meta_val ) {
422
 
423
  $entries[ $meta_val->item_id ]->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value );
424
 
425
+ unset( $m_key, $meta_val );
426
  }
427
 
428
  if ( ! FrmAppHelper::prevent_caching() ) {
432
  }
433
  }
434
 
435
+ return stripslashes_deep( $entries );
436
  }
437
 
438
  // Pagination Methods
440
  global $wpdb;
441
  $table_join = $wpdb->prefix . 'frm_items it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id';
442
 
443
+ if ( is_numeric( $where ) ) {
444
  $table_join = 'frm_items';
445
  $where = array( 'form_id' => $where );
446
  }
482
  self::sanitize_entry_post( $values );
483
 
484
  if ( $type != 'xml' ) {
485
+ $values = apply_filters( 'frm_pre_create_entry', $values );
486
  }
487
 
488
  $new_values = self::package_entry_data( $values );
562
  'user_id' => self::get_entry_user_id( $values ),
563
  );
564
 
565
+ $new_values['updated_by'] = isset( $values['updated_by'] ) ? $values['updated_by'] : $new_values['user_id'];
566
 
567
  return $new_values;
568
  }
585
  }
586
 
587
  $ip = FrmAppHelper::get_ip_address();
588
+ if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
589
  $ip = self::get_entry_value( $values, 'ip', $ip );
590
  }
591
  return $ip;
698
  private static function add_new_entry_to_frm_vars( $entry_id ) {
699
  global $frm_vars;
700
 
701
+ if ( ! isset( $frm_vars['saved_entries'] ) ) {
702
  $frm_vars['saved_entries'] = array();
703
  }
704
 
713
  * @param int $entry_id
714
  */
715
  private static function maybe_add_entry_metas( $values, $entry_id ) {
716
+ if ( isset( $values['item_meta'] ) ) {
717
  FrmEntryMeta::update_entry_metas( $entry_id, $values['item_meta'] );
718
  }
719
  }
771
  }
772
 
773
  if ( $update && $update_type != 'xml' ) {
774
+ $values = apply_filters( 'frm_pre_update_entry', $values, $id );
775
  }
776
 
777
  return $update;
792
  'name' => self::get_new_entry_name( $values ),
793
  'form_id' => (int) self::get_entry_value( $values, 'form_id', null ),
794
  'is_draft' => self::get_is_draft_value( $values ),
795
+ 'updated_at' => current_time( 'mysql', 1 ),
796
+ 'updated_by' => isset( $values['updated_by'] ) ? $values['updated_by'] : get_current_user_id(),
797
  );
798
 
799
+ if ( isset( $values['post_id'] ) ) {
800
  $new_values['post_id'] = (int) $values['post_id'];
801
  }
802
 
803
+ if ( isset( $values['item_key'] ) ) {
804
  $new_values['item_key'] = FrmAppHelper::get_unique_key( $values['item_key'], $wpdb->prefix . 'frm_items', 'item_key', $id );
805
  }
806
 
807
+ if ( isset( $values['parent_item_id'] ) ) {
808
  $new_values['parent_item_id'] = (int) $values['parent_item_id'];
809
  }
810
 
811
+ if ( isset( $values['frm_user_id'] ) && is_numeric( $values['frm_user_id'] ) ) {
812
  $new_values['user_id'] = $values['frm_user_id'];
813
  }
814
 
815
+ $new_values = apply_filters( 'frm_update_entry', $new_values, $id );
816
 
817
  return $new_values;
818
  }
classes/models/FrmEntryMeta.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- if ( ! defined('ABSPATH') ) {
3
  die( 'You are not allowed to call this page directly.' );
4
  }
5
 
@@ -20,11 +20,11 @@ class FrmEntryMeta {
20
  'meta_value' => is_array( $meta_value ) ? serialize( array_filter( $meta_value, 'FrmAppHelper::is_not_empty_value' ) ) : trim( $meta_value ),
21
  'item_id' => $entry_id,
22
  'field_id' => $field_id,
23
- 'created_at' => current_time('mysql', 1),
24
  );
25
 
26
  self::set_value_before_save( $new_values );
27
- $new_values = apply_filters('frm_add_entry_meta', $new_values);
28
 
29
  $query_results = $wpdb->insert( $wpdb->prefix . 'frm_item_metas', $new_values );
30
 
@@ -61,14 +61,14 @@ class FrmEntryMeta {
61
  $where_values = $values;
62
  $values['meta_value'] = $meta_value;
63
  self::set_value_before_save( $values );
64
- $values = apply_filters('frm_update_entry_meta', $values);
65
 
66
- if ( is_array($values['meta_value']) ) {
67
  $values['meta_value'] = array_filter( $values['meta_value'], 'FrmAppHelper::is_not_empty_value' );
68
  }
69
- $meta_value = maybe_serialize($values['meta_value']);
70
 
71
- wp_cache_delete( $entry_id, 'frm_entry');
72
  self::clear_cache();
73
 
74
  return $wpdb->update( $wpdb->prefix . 'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values );
@@ -116,7 +116,7 @@ class FrmEntryMeta {
116
 
117
  self::get_value_to_save( compact( 'field', 'field_id', 'entry_id' ), $meta_value );
118
 
119
- if ( $prev_values && in_array($field_id, $prev_values) ) {
120
 
121
  if ( ( is_array( $meta_value ) && empty( $meta_value ) ) || ( ! is_array( $meta_value ) && trim( $meta_value ) == '' ) ) {
122
  // remove blank fields
@@ -131,15 +131,15 @@ class FrmEntryMeta {
131
  }
132
  }
133
 
134
- if ( empty($prev_values) ) {
135
- return;
136
- }
137
 
138
- $prev_values = array_diff($prev_values, array_keys($values));
139
 
140
- if ( empty($prev_values) ) {
141
- return;
142
- }
143
 
144
  // prepare the query
145
  $where = array(
@@ -154,18 +154,18 @@ class FrmEntryMeta {
154
  }
155
 
156
  public static function duplicate_entry_metas( $old_id, $new_id ) {
157
- $metas = self::get_entry_meta_info($old_id);
158
- foreach ( $metas as $meta ) {
159
- self::add_entry_meta($new_id, $meta->field_id, null, $meta->meta_value);
160
- unset($meta);
161
- }
162
  self::clear_cache();
163
- }
164
 
165
  public static function delete_entry_meta( $entry_id, $field_id ) {
166
  global $wpdb;
167
  self::clear_cache();
168
- return $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id));
169
  }
170
 
171
  /**
@@ -204,12 +204,12 @@ class FrmEntryMeta {
204
 
205
  if ( $cached && isset( $cached->metas ) && isset( $cached->metas[ $field_id ] ) ) {
206
  $result = $cached->metas[ $field_id ];
207
- return stripslashes_deep($result);
208
  }
209
 
210
  $get_table = $wpdb->prefix . 'frm_item_metas';
211
  $query = array( 'item_id' => $entry_id );
212
- if ( is_numeric($field_id) ) {
213
  $query['field_id'] = $field_id;
214
  } else {
215
  $get_table .= ' it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id';
@@ -217,8 +217,8 @@ class FrmEntryMeta {
217
  }
218
 
219
  $result = FrmDb::get_var( $get_table, $query, 'meta_value' );
220
- $result = maybe_unserialize($result);
221
- $result = stripslashes_deep($result);
222
 
223
  return $result;
224
  }
@@ -233,11 +233,11 @@ class FrmEntryMeta {
233
  $args = wp_parse_args( $args, $defaults );
234
 
235
  $query = array();
236
- self::meta_field_query($field_id, $order, $limit, $args, $query);
237
- $query = implode(' ', $query);
238
 
239
  $cache_key = 'entry_metas_for_field_' . $field_id . $order . $limit . maybe_serialize( $args );
240
- $values = FrmDb::check_cache($cache_key, 'frm_entry', $query, 'get_col');
241
 
242
  if ( ! $args['stripslashes'] ) {
243
  return $values;
@@ -245,10 +245,10 @@ class FrmEntryMeta {
245
 
246
  foreach ( $values as $k => $v ) {
247
  $values[ $k ] = maybe_unserialize( $v );
248
- unset($k, $v);
249
  }
250
 
251
- return stripslashes_deep($values);
252
  }
253
 
254
  /**
@@ -265,9 +265,9 @@ class FrmEntryMeta {
265
  $query[] = 'INNER JOIN ' . $wpdb->prefix . 'frm_items e ON (e.id=em.item_id)';
266
  }
267
 
268
- if ( is_numeric($field_id) ) {
269
- $query[] = $wpdb->prepare('WHERE em.field_id=%d', $field_id);
270
- } else {
271
  $query[] = $wpdb->prepare( 'LEFT JOIN ' . $wpdb->prefix . 'frm_fields fi ON (em.field_id = fi.id) WHERE fi.field_key=%s', $field_id );
272
  }
273
 
@@ -276,7 +276,7 @@ class FrmEntryMeta {
276
  }
277
 
278
  if ( $args['value'] ) {
279
- $query[] = $wpdb->prepare(' AND meta_value=%s', $args['value']);
280
  }
281
  $query[] = $order . $limit;
282
  }
@@ -290,7 +290,7 @@ class FrmEntryMeta {
290
  $query = 'SELECT it.*, fi.type as field_type, fi.field_key as field_key,
291
  fi.required as required, fi.form_id as field_form_id, fi.name as field_name, fi.options as fi_options
292
  FROM ' . $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id' .
293
- FrmDb::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
294
 
295
  $cache_key = 'all_' . maybe_serialize( $where ) . $order_by . $limit;
296
  $results = FrmDb::check_cache( $cache_key, 'frm_entry', $query, ( $limit == ' LIMIT 1' ? 'get_row' : 'get_results' ) );
@@ -313,11 +313,11 @@ class FrmEntryMeta {
313
  'user_id' => '',
314
  'group_by' => '',
315
  );
316
- $args = wp_parse_args($args, $defaults);
317
 
318
  $query = array();
319
- self::get_ids_query($where, $order_by, $limit, $unique, $args, $query );
320
- $query = implode(' ', $query);
321
 
322
  $cache_key = 'ids_' . maybe_serialize( $where ) . $order_by . 'l' . $limit . 'u' . $unique . maybe_serialize( $args );
323
  return FrmDb::check_cache( $cache_key, 'frm_entry', $query, ( $limit == ' LIMIT 1' ? 'get_var' : 'get_col' ) );
@@ -344,17 +344,17 @@ class FrmEntryMeta {
344
  $query[] = 'FROM ' . $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id';
345
 
346
  $query[] = 'INNER JOIN ' . $wpdb->prefix . 'frm_items e ON (e.id=it.item_id)';
347
- if ( is_array($where) ) {
348
  if ( ! $args['is_draft'] ) {
349
  $where['e.is_draft'] = 0;
350
  } else if ( $args['is_draft'] == 1 ) {
351
  $where['e.is_draft'] = 1;
352
  }
353
 
354
- if ( ! empty($args['user_id']) ) {
355
  $where['e.user_id'] = $args['user_id'];
356
  }
357
- $query[] = FrmDb::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
358
 
359
  if ( $args['group_by'] ) {
360
  $query[] = ' GROUP BY ' . sanitize_text_field( $args['group_by'] );
@@ -370,13 +370,13 @@ class FrmEntryMeta {
370
  $draft_where = $wpdb->prepare( ' AND e.is_draft=%d', 1 );
371
  }
372
 
373
- if ( ! empty($args['user_id']) ) {
374
- $user_where = $wpdb->prepare(' AND e.user_id=%d', $args['user_id']);
375
- }
376
 
377
- if ( strpos($where, ' GROUP BY ') ) {
378
- // don't inject WHERE filtering after GROUP BY
379
- $parts = explode(' GROUP BY ', $where);
380
  $where = $parts[0];
381
  $where .= $draft_where . $user_where;
382
  $where .= ' GROUP BY ' . $parts[1];
@@ -385,12 +385,12 @@ class FrmEntryMeta {
385
  }
386
 
387
  // The query has already been prepared
388
- $query[] = FrmDb::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
389
  }
390
 
391
  public static function search_entry_metas( $search, $field_id = '', $operator ) {
392
  $cache_key = 'search_' . maybe_serialize( $search ) . $field_id . $operator;
393
- $results = wp_cache_get($cache_key, 'frm_entry');
394
  if ( false !== $results ) {
395
  return $results;
396
  }
@@ -413,18 +413,18 @@ class FrmEntryMeta {
413
  case 'day':
414
  $value = '%' . $value . '%';
415
  }
416
- $where .= $wpdb->prepare(' meta_value ' . $operator . ' %s and', $value );
417
  }
418
- $where .= $wpdb->prepare(' field_id=%d', $field_id);
419
  $query = 'SELECT DISTINCT item_id FROM ' . $wpdb->prefix . 'frm_item_metas' . FrmDb::prepend_and_or_where( ' WHERE ', $where );
420
  } else {
421
  if ( $operator == 'LIKE' ) {
422
  $search = '%' . $search . '%';
423
  }
424
- $query = $wpdb->prepare("SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id);
425
  }
426
 
427
- $results = $wpdb->get_col($query, 0);
428
  FrmDb::set_cache( $cache_key, $results, 'frm_entry' );
429
 
430
  return $results;
1
  <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
  die( 'You are not allowed to call this page directly.' );
4
  }
5
 
20
  'meta_value' => is_array( $meta_value ) ? serialize( array_filter( $meta_value, 'FrmAppHelper::is_not_empty_value' ) ) : trim( $meta_value ),
21
  'item_id' => $entry_id,
22
  'field_id' => $field_id,
23
+ 'created_at' => current_time( 'mysql', 1 ),
24
  );
25
 
26
  self::set_value_before_save( $new_values );
27
+ $new_values = apply_filters( 'frm_add_entry_meta', $new_values );
28
 
29
  $query_results = $wpdb->insert( $wpdb->prefix . 'frm_item_metas', $new_values );
30
 
61
  $where_values = $values;
62
  $values['meta_value'] = $meta_value;
63
  self::set_value_before_save( $values );
64
+ $values = apply_filters( 'frm_update_entry_meta', $values );
65
 
66
+ if ( is_array( $values['meta_value'] ) ) {
67
  $values['meta_value'] = array_filter( $values['meta_value'], 'FrmAppHelper::is_not_empty_value' );
68
  }
69
+ $meta_value = maybe_serialize( $values['meta_value'] );
70
 
71
+ wp_cache_delete( $entry_id, 'frm_entry' );
72
  self::clear_cache();
73
 
74
  return $wpdb->update( $wpdb->prefix . 'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values );
116
 
117
  self::get_value_to_save( compact( 'field', 'field_id', 'entry_id' ), $meta_value );
118
 
119
+ if ( $prev_values && in_array( $field_id, $prev_values ) ) {
120
 
121
  if ( ( is_array( $meta_value ) && empty( $meta_value ) ) || ( ! is_array( $meta_value ) && trim( $meta_value ) == '' ) ) {
122
  // remove blank fields
131
  }
132
  }
133
 
134
+ if ( empty( $prev_values ) ) {
135
+ return;
136
+ }
137
 
138
+ $prev_values = array_diff( $prev_values, array_keys( $values ) );
139
 
140
+ if ( empty( $prev_values ) ) {
141
+ return;
142
+ }
143
 
144
  // prepare the query
145
  $where = array(
154
  }
155
 
156
  public static function duplicate_entry_metas( $old_id, $new_id ) {
157
+ $metas = self::get_entry_meta_info( $old_id );
158
+ foreach ( $metas as $meta ) {
159
+ self::add_entry_meta( $new_id, $meta->field_id, null, $meta->meta_value );
160
+ unset( $meta );
161
+ }
162
  self::clear_cache();
163
+ }
164
 
165
  public static function delete_entry_meta( $entry_id, $field_id ) {
166
  global $wpdb;
167
  self::clear_cache();
168
+ return $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id ) );
169
  }
170
 
171
  /**
204
 
205
  if ( $cached && isset( $cached->metas ) && isset( $cached->metas[ $field_id ] ) ) {
206
  $result = $cached->metas[ $field_id ];
207
+ return stripslashes_deep( $result );
208
  }
209
 
210
  $get_table = $wpdb->prefix . 'frm_item_metas';
211
  $query = array( 'item_id' => $entry_id );
212
+ if ( is_numeric( $field_id ) ) {
213
  $query['field_id'] = $field_id;
214
  } else {
215
  $get_table .= ' it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id';
217
  }
218
 
219
  $result = FrmDb::get_var( $get_table, $query, 'meta_value' );
220
+ $result = maybe_unserialize( $result );
221
+ $result = stripslashes_deep( $result );
222
 
223
  return $result;
224
  }
233
  $args = wp_parse_args( $args, $defaults );
234
 
235
  $query = array();
236
+ self::meta_field_query( $field_id, $order, $limit, $args, $query );
237
+ $query = implode( ' ', $query );
238
 
239
  $cache_key = 'entry_metas_for_field_' . $field_id . $order . $limit . maybe_serialize( $args );
240
+ $values = FrmDb::check_cache( $cache_key, 'frm_entry', $query, 'get_col' );
241
 
242
  if ( ! $args['stripslashes'] ) {
243
  return $values;
245
 
246
  foreach ( $values as $k => $v ) {
247
  $values[ $k ] = maybe_unserialize( $v );
248
+ unset( $k, $v );
249
  }
250
 
251
+ return stripslashes_deep( $values );
252
  }
253
 
254
  /**
265
  $query[] = 'INNER JOIN ' . $wpdb->prefix . 'frm_items e ON (e.id=em.item_id)';
266
  }
267
 
268
+ if ( is_numeric( $field_id ) ) {
269
+ $query[] = $wpdb->prepare( 'WHERE em.field_id=%d', $field_id );
270
+ } else {
271
  $query[] = $wpdb->prepare( 'LEFT JOIN ' . $wpdb->prefix . 'frm_fields fi ON (em.field_id = fi.id) WHERE fi.field_key=%s', $field_id );
272
  }
273
 
276
  }
277
 
278
  if ( $args['value'] ) {
279
+ $query[] = $wpdb->prepare( ' AND meta_value=%s', $args['value'] );
280
  }
281
  $query[] = $order . $limit;
282
  }
290
  $query = 'SELECT it.*, fi.type as field_type, fi.field_key as field_key,
291
  fi.required as required, fi.form_id as field_form_id, fi.name as field_name, fi.options as fi_options
292
  FROM ' . $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id' .
293
+ FrmDb::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
294
 
295
  $cache_key = 'all_' . maybe_serialize( $where ) . $order_by . $limit;
296
  $results = FrmDb::check_cache( $cache_key, 'frm_entry', $query, ( $limit == ' LIMIT 1' ? 'get_row' : 'get_results' ) );
313
  'user_id' => '',
314
  'group_by' => '',
315
  );
316
+ $args = wp_parse_args( $args, $defaults );
317
 
318
  $query = array();
319
+ self::get_ids_query( $where, $order_by, $limit, $unique, $args, $query );
320
+ $query = implode( ' ', $query );
321
 
322
  $cache_key = 'ids_' . maybe_serialize( $where ) . $order_by . 'l' . $limit . 'u' . $unique . maybe_serialize( $args );
323
  return FrmDb::check_cache( $cache_key, 'frm_entry', $query, ( $limit == ' LIMIT 1' ? 'get_var' : 'get_col' ) );
344
  $query[] = 'FROM ' . $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id';
345
 
346
  $query[] = 'INNER JOIN ' . $wpdb->prefix . 'frm_items e ON (e.id=it.item_id)';
347
+ if ( is_array( $where ) ) {
348
  if ( ! $args['is_draft'] ) {
349
  $where['e.is_draft'] = 0;
350
  } else if ( $args['is_draft'] == 1 ) {
351
  $where['e.is_draft'] = 1;
352
  }
353
 
354
+ if ( ! empty( $args['user_id'] ) ) {
355
  $where['e.user_id'] = $args['user_id'];
356
  }
357
+ $query[] = FrmDb::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
358
 
359
  if ( $args['group_by'] ) {
360
  $query[] = ' GROUP BY ' . sanitize_text_field( $args['group_by'] );
370
  $draft_where = $wpdb->prepare( ' AND e.is_draft=%d', 1 );
371
  }
372
 
373
+ if ( ! empty( $args['user_id'] ) ) {
374
+ $user_where = $wpdb->prepare( ' AND e.user_id=%d', $args['user_id'] );
375
+ }
376
 
377
+ if ( strpos( $where, ' GROUP BY ' ) ) {
378
+ // don't inject WHERE filtering after GROUP BY
379
+ $parts = explode( ' GROUP BY ', $where );
380
  $where = $parts[0];
381
  $where .= $draft_where . $user_where;
382
  $where .= ' GROUP BY ' . $parts[1];
385
  }
386
 
387
  // The query has already been prepared
388
+ $query[] = FrmDb::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
389
  }
390
 
391
  public static function search_entry_metas( $search, $field_id = '', $operator ) {
392
  $cache_key = 'search_' . maybe_serialize( $search ) . $field_id . $operator;
393
+ $results = wp_cache_get( $cache_key, 'frm_entry' );
394
  if ( false !== $results ) {
395
  return $results;
396
  }
413
  case 'day':
414
  $value = '%' . $value . '%';
415
  }
416
+ $where .= $wpdb->prepare( ' meta_value ' . $operator . ' %s and', $value );
417
  }
418
+ $where .= $wpdb->prepare( ' field_id=%d', $field_id );
419
  $query = 'SELECT DISTINCT item_id FROM ' . $wpdb->prefix . 'frm_item_metas' . FrmDb::prepend_and_or_where( ' WHERE ', $where );
420
  } else {
421
  if ( $operator == 'LIKE' ) {
422
  $search = '%' . $search . '%';
423
  }
424
+ $query = $wpdb->prepare( "SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id );
425
  }
426
 
427
+ $results = $wpdb->get_col( $query, 0 );
428
  FrmDb::set_cache( $cache_key, $results, 'frm_entry' );
429
 
430
  return $results;
classes/models/FrmEntryValidate.php CHANGED
@@ -5,7 +5,7 @@ class FrmEntryValidate {
5
  FrmEntry::sanitize_entry_post( $values );
6
  $errors = array();
7
 
8
- if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) {
9
  $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' );
10
  return $errors;
11
  }
@@ -66,7 +66,7 @@ class FrmEntryValidate {
66
  );
67
  $args = wp_parse_args( $args, $defaults );
68
 
69
- if ( empty($args['parent_field_id']) ) {
70
  $value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : '';
71
  } else {
72
  // value is from a nested form
@@ -79,8 +79,8 @@ class FrmEntryValidate {
79
  self::maybe_clear_value_for_default_blank_setting( $posted_field, $value );
80
 
81
  // Reset arrays with only one value if it's not a field where array keys need to be preserved
82
- if ( is_array($value) && count( $value ) == 1 && isset( $value[0] ) ) {
83
- $value = reset($value);
84
  }
85
 
86
  if ( ! is_array( $value ) ) {
@@ -302,7 +302,7 @@ class FrmEntryValidate {
302
 
303
  private static function is_akismet_spam( $values ) {
304
  global $wpcom_api_key;
305
- return ( is_callable('Akismet::http_post') && ( get_option('wordpress_api_key') || $wpcom_api_key ) && self::akismet( $values ) );
306
  }
307
 
308
  private static function is_akismet_enabled_for_user( $form_id ) {
@@ -311,7 +311,7 @@ class FrmEntryValidate {
311
  }
312
 
313
  public static function blacklist_check( $values ) {
314
- if ( ! apply_filters('frm_check_blacklist', true, $values) ) {
315
  return false;
316
  }
317
 
@@ -370,7 +370,7 @@ class FrmEntryValidate {
370
  $datas['user_agent'] = FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' );
371
  $datas['referrer'] = isset( $_SERVER['HTTP_REFERER'] ) ? FrmAppHelper::get_server_value( 'HTTP_REFERER' ) : false;
372
  $datas['blog_lang'] = get_locale();
373
- $datas['blog_charset'] = get_option('blog_charset');
374
 
375
  if ( akismet_test_mode() ) {
376
  $datas['is_test'] = 'true';
5
  FrmEntry::sanitize_entry_post( $values );
6
  $errors = array();
7
 
8
+ if ( ! isset( $values['form_id'] ) || ! isset( $values['item_meta'] ) ) {
9
  $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' );
10
  return $errors;
11
  }
66
  );
67
  $args = wp_parse_args( $args, $defaults );
68
 
69
+ if ( empty( $args['parent_field_id'] ) ) {
70
  $value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : '';
71
  } else {
72
  // value is from a nested form
79
  self::maybe_clear_value_for_default_blank_setting( $posted_field, $value );
80
 
81
  // Reset arrays with only one value if it's not a field where array keys need to be preserved
82
+ if ( is_array( $value ) && count( $value ) == 1 && isset( $value[0] ) ) {
83
+ $value = reset( $value );
84
  }
85
 
86
  if ( ! is_array( $value ) ) {
302
 
303
  private static function is_akismet_spam( $values ) {
304
  global $wpcom_api_key;
305
+ return ( is_callable( 'Akismet::http_post' ) && ( get_option( 'wordpress_api_key' ) || $wpcom_api_key ) && self::akismet( $values ) );
306
  }
307
 
308
  private static function is_akismet_enabled_for_user( $form_id ) {
311
  }
312
 
313
  public static function blacklist_check( $values ) {
314
+ if ( ! apply_filters( 'frm_check_blacklist', true, $values ) ) {
315
  return false;
316
  }
317
 
370
  $datas['user_agent'] = FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' );
371
  $datas['referrer'] = isset( $_SERVER['HTTP_REFERER'] ) ? FrmAppHelper::get_server_value( 'HTTP_REFERER' ) : false;
372
  $datas['blog_lang'] = get_locale();
373
+ $datas['blog_charset'] = get_option( 'blog_charset' );
374
 
375
  if ( akismet_test_mode() ) {
376
  $datas['is_test'] = 'true';
classes/models/FrmField.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- if ( ! defined('ABSPATH') ) {
3
  die( 'You are not allowed to call this page directly.' );
4
  }
5
 
@@ -152,7 +152,7 @@ class FrmField {
152
  global $wpdb, $frm_duplicate_ids;
153
 
154
  $new_values = array();
155
- $key = isset($values['field_key']) ? $values['field_key'] : $values['name'];
156
  $new_values['field_key'] = FrmAppHelper::get_unique_key( $key, $wpdb->prefix . 'frm_fields', 'field_key' );
157
 
158
  foreach ( array( 'name', 'description', 'type', 'default_value' ) as $col ) {
@@ -161,15 +161,15 @@ class FrmField {
161
 
162
  $new_values['options'] = $values['options'];
163
 
164
- $new_values['field_order'] = isset($values['field_order']) ? (int) $values['field_order'] : null;
165
- $new_values['required'] = isset($values['required']) ? (int) $values['required'] : 0;
166
- $new_values['form_id'] = isset($values['form_id']) ? (int) $values['form_id'] : null;
167
  $new_values['field_options'] = $values['field_options'];
168
- $new_values['created_at'] = current_time('mysql', 1);
169
 
170
  if ( isset( $values['id'] ) ) {
171
  $frm_duplicate_ids[ $values['field_key'] ] = $new_values['field_key'];
172
- $new_values = apply_filters('frm_duplicated_field', $new_values);
173
  }
174
 
175
  self::preserve_format_option_backslashes( $new_values );
@@ -219,9 +219,9 @@ class FrmField {
219
 
220
  foreach ( (array) $fields as $field ) {
221
  $new_key = $copy_keys ? $field->field_key : '';
222
- if ( $copy_keys && substr($field->field_key, -1) == 2 ) {
223
- $new_key = rtrim($new_key, 2);
224
- }
225
 
226
  $values = array();
227
  FrmFieldsHelper::fill_field( $values, $field, $form_id, $new_key );
@@ -246,11 +246,11 @@ class FrmField {
246
  $values['form_id'] = $new_repeat_form_id;
247
  }
248
 
249
- $values = apply_filters('frm_duplicated_field', $values);
250
- $new_id = self::create($values);
251
- $frm_duplicate_ids[ $field->id ] = $new_id;
252
- $frm_duplicate_ids[ $field->field_key ] = $new_id;
253
- unset($field);
254
  }
255
  }
256
 
@@ -263,7 +263,7 @@ class FrmField {
263
  $values['field_key'] = FrmAppHelper::get_unique_key( $values['field_key'], $wpdb->prefix . 'frm_fields', 'field_key', $id );
264
  }
265
 
266
- if ( isset($values['required']) ) {
267
  $values['required'] = (int) $values['required'];
268
  }
269
 
@@ -291,13 +291,13 @@ class FrmField {
291
  if ( isset( $values['form_id'] ) ) {
292
  $form_id = absint( $values['form_id'] );
293
  } else {
294
- $field = self::getOne($id);
295
  if ( $field ) {
296
  $form_id = $field->form_id;
297
  }
298
- unset($field);
299
  }
300
- unset($values);
301
 
302
  if ( $query_results ) {
303
  wp_cache_delete( $id, 'frm_field' );
@@ -350,7 +350,7 @@ class FrmField {
350
 
351
  FrmDb::cache_delete_group( 'frm_field' );
352
 
353
- $form = FrmForm::getOne($form_id);
354
  if ( $form && $form->parent_form_id && $form->parent_form_id != $form_id ) {
355
  self::delete_form_transient( $form->parent_form_id );
356
  }
@@ -372,16 +372,16 @@ class FrmField {
372
 
373
  global $wpdb;
374
 
375
- $where = is_numeric($id) ? 'id=%d' : 'field_key=%s';
376
  $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'frm_fields WHERE ' . $where, $id );
377
 
378
  $results = FrmDb::check_cache( $id, 'frm_field', $query, 'get_row', 0 );
379
 
380
- if ( empty($results) ) {
381
  return $results;
382
  }
383
 
384
- if ( is_numeric($id) ) {
385
  FrmDb::set_cache( $results->field_key, $results, 'frm_field' );
386
  } else if ( $results ) {
387
  FrmDb::set_cache( $results->id, $results, 'frm_field' );
@@ -389,7 +389,7 @@ class FrmField {
389
 
390
  self::prepare_options( $results );
391
 
392
- return stripslashes_deep($results);
393
  }
394
 
395
  /**
@@ -437,13 +437,13 @@ class FrmField {
437
  break;
438
  }
439
 
440
- if ( ! empty($limit) && $count >= $limit ) {
441
  break;
442
  }
443
 
444
- unset($result);
445
- }
446
- return stripslashes_deep($fields);
447
  }
448
 
449
  self::$use_cache = false;
@@ -455,7 +455,7 @@ class FrmField {
455
  self::maybe_include_repeating_fields( $inc_sub, $where );
456
  $results = self::getAll( $where, 'field_order', $limit );
457
  self::$use_cache = true;
458
- self::include_sub_fields($results, $inc_sub, $type);
459
 
460
  return $results;
461
  }
@@ -470,7 +470,7 @@ class FrmField {
470
  'inc_repeat' => $inc_repeat,
471
  ) );
472
  if ( ! empty( $results ) ) {
473
- if ( empty($limit) ) {
474
  return $results;
475
  }
476
 
@@ -479,7 +479,7 @@ class FrmField {
479
  foreach ( $results as $result ) {
480
  $count++;
481
  $fields[ $result->id ] = $result;
482
- if ( ! empty($limit) && $count >= $limit ) {
483
  break;
484
  }
485
  }
@@ -497,7 +497,7 @@ class FrmField {
497
 
498
  self::include_sub_fields( $results, $inc_embed, 'all' );
499
 
500
- if ( empty($limit) ) {
501
  self::set_field_transient( $results, $form_id, 0, array(
502
  'inc_embed' => $inc_embed,
503
  'inc_repeat' => $inc_repeat,
@@ -533,22 +533,22 @@ class FrmField {
533
  $form_fields = $results;
534
  $index_offset = 1;
535
  foreach ( $form_fields as $k => $field ) {
536
- if ( 'form' != $field->type || ! isset($field->field_options['form_select']) ) {
537
  continue;
538
  }
539
 
540
  if ( $type == 'all' ) {
541
  $sub_fields = self::get_all_for_form( $field->field_options['form_select'] );
542
  } else {
543
- $sub_fields = self::get_all_types_in_form($field->form_id, $type);
544
  }
545
 
546
- if ( ! empty($sub_fields) ) {
547
  $index = $k + $index_offset;
548
  $index_offset += count( $sub_fields );
549
- array_splice($results, $index, 0, $sub_fields);
550
- }
551
- unset($field, $sub_fields);
552
  }
553
  }
554
 
@@ -556,9 +556,9 @@ class FrmField {
556
  $cache_key = maybe_serialize( $where ) . $order_by . 'l' . $limit . 'b' . $blog_id;
557
  if ( self::$use_cache ) {
558
  // make sure old cache doesn't get saved as a transient
559
- $results = wp_cache_get($cache_key, 'frm_field');
560
  if ( false !== $results ) {
561
- return stripslashes_deep($results);
562
  }
563
  }
564
 
@@ -596,7 +596,7 @@ class FrmField {
596
  $results = FrmDb::get_var( $table_name . ' fi LEFT OUTER JOIN ' . $form_table_name . ' fr ON fi.form_id=fr.id', $where, 'fi.*, fr.name as form_name', $args, '', $query_type );
597
  } else {
598
  // if the query is not an array, then it has already been prepared
599
- $query .= FrmDb::prepend_and_or_where(' WHERE ', $where ) . $order_by . $limit;
600
 
601
  $function_name = ( $query_type == 'row' ) ? 'get_row' : 'get_results';
602
  $results = $wpdb->$function_name( $query );
@@ -640,8 +640,8 @@ class FrmField {
640
  private static function prepare_options( &$results ) {
641
  $results->field_options = maybe_unserialize( $results->field_options );
642
 
643
- $results->options = maybe_unserialize($results->options);
644
- $results->default_value = maybe_unserialize($results->default_value);
645
  }
646
 
647
  /**
1
  <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
  die( 'You are not allowed to call this page directly.' );
4
  }
5
 
152
  global $wpdb, $frm_duplicate_ids;
153
 
154
  $new_values = array();
155
+ $key = isset( $values['field_key'] ) ? $values['field_key'] : $values['name'];
156
  $new_values['field_key'] = FrmAppHelper::get_unique_key( $key, $wpdb->prefix . 'frm_fields', 'field_key' );
157
 
158
  foreach ( array( 'name', 'description', 'type', 'default_value' ) as $col ) {
161
 
162
  $new_values['options'] = $values['options'];
163
 
164
+ $new_values['field_order'] = isset( $values['field_order'] ) ? (int) $values['field_order'] : null;
165
+ $new_values['required'] = isset( $values['required'] ) ? (int) $values['required'] : 0;
166
+ $new_values['form_id'] = isset( $values['form_id'] ) ? (int) $values['form_id'] : null;
167
  $new_values['field_options'] = $values['field_options'];
168
+ $new_values['created_at'] = current_time( 'mysql', 1 );
169
 
170
  if ( isset( $values['id'] ) ) {
171
  $frm_duplicate_ids[ $values['field_key'] ] = $new_values['field_key'];
172
+ $new_values = apply_filters( 'frm_duplicated_field', $new_values );
173
  }
174
 
175
  self::preserve_format_option_backslashes( $new_values );
219
 
220
  foreach ( (array) $fields as $field ) {
221
  $new_key = $copy_keys ? $field->field_key : '';
222
+ if ( $copy_keys && substr( $field->field_key, -1 ) == 2 ) {
223
+ $new_key = rtrim( $new_key, 2 );
224
+ }
225
 
226
  $values = array();
227
  FrmFieldsHelper::fill_field( $values, $field, $form_id, $new_key );
246
  $values['form_id'] = $new_repeat_form_id;
247
  }
248
 
249
+ $values = apply_filters( 'frm_duplicated_field', $values );
250
+ $new_id = self::create( $values );
251
+ $frm_duplicate_ids[ $field->id ] = $new_id;
252
+ $frm_duplicate_ids[ $field->field_key ] = $new_id;
253
+ unset( $field );
254
  }
255
  }
256
 
263
  $values['field_key'] = FrmAppHelper::get_unique_key( $values['field_key'], $wpdb->prefix . 'frm_fields', 'field_key', $id );
264
  }
265
 
266
+ if ( isset( $values['required'] ) ) {
267
  $values['required'] = (int) $values['required'];
268
  }
269
 
291
  if ( isset( $values['form_id'] ) ) {
292
  $form_id = absint( $values['form_id'] );
293
  } else {
294
+ $field = self::getOne( $id );
295
  if ( $field ) {
296
  $form_id = $field->form_id;
297
  }
298
+ unset( $field );
299
  }
300
+ unset( $values );
301
 
302
  if ( $query_results ) {
303
  wp_cache_delete( $id, 'frm_field' );
350
 
351
  FrmDb::cache_delete_group( 'frm_field' );
352
 
353
+ $form = FrmForm::getOne( $form_id );
354
  if ( $form && $form->parent_form_id && $form->parent_form_id != $form_id ) {
355
  self::delete_form_transient( $form->parent_form_id );
356
  }
372
 
373
  global $wpdb;
374
 
375
+ $where = is_numeric( $id ) ? 'id=%d' : 'field_key=%s';
376
  $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'frm_fields WHERE ' . $where, $id );
377
 
378
  $results = FrmDb::check_cache( $id, 'frm_field', $query, 'get_row', 0 );
379
 
380
+ if ( empty( $results ) ) {
381
  return $results;
382
  }
383
 
384
+ if ( is_numeric( $id ) ) {
385
  FrmDb::set_cache( $results->field_key, $results, 'frm_field' );
386
  } else if ( $results ) {
387
  FrmDb::set_cache( $results->id, $results, 'frm_field' );
389
 
390
  self::prepare_options( $results );
391
 
392
+ return stripslashes_deep( $results );
393
  }
394
 
395
  /**
437
  break;
438
  }
439
 
440
+ if ( ! empty( $limit ) && $count >= $limit ) {
441
  break;
442
  }
443
 
444
+ unset( $result );
445
+ }
446
+ return stripslashes_deep( $fields );
447
  }
448
 
449
  self::$use_cache = false;
455
  self::maybe_include_repeating_fields( $inc_sub, $where );
456
  $results = self::getAll( $where, 'field_order', $limit );
457
  self::$use_cache = true;
458
+ self::include_sub_fields( $results, $inc_sub, $type );
459
 
460
  return $results;
461
  }
470
  'inc_repeat' => $inc_repeat,
471
  ) );
472
  if ( ! empty( $results ) ) {
473
+ if ( empty( $limit ) ) {
474
  return $results;
475
  }
476
 
479
  foreach ( $results as $result ) {
480
  $count++;
481
  $fields[ $result->id ] = $result;
482
+ if ( ! empty( $limit ) && $count >= $limit ) {
483
  break;
484
  }
485
  }
497
 
498
  self::include_sub_fields( $results, $inc_embed, 'all' );
499
 
500
+ if ( empty( $limit ) ) {
501
  self::set_field_transient( $results, $form_id, 0, array(
502
  'inc_embed' => $inc_embed,
503
  'inc_repeat' => $inc_repeat,
533
  $form_fields = $results;
534
  $index_offset = 1;
535
  foreach ( $form_fields as $k => $field ) {
536
+ if ( 'form' != $field->type || ! isset( $field->field_options['form_select'] ) ) {
537
  continue;
538
  }
539
 
540
  if ( $type == 'all' ) {
541
  $sub_fields = self::get_all_for_form( $field->field_options['form_select'] );
542
  } else {
543
+ $sub_fields = self::get_all_types_in_form( $field->form_id, $type );
544
  }
545
 
546
+ if ( ! empty( $sub_fields ) ) {
547
  $index = $k + $index_offset;
548
  $index_offset += count( $sub_fields );
549
+ array_splice( $results, $index, 0, $sub_fields );
550
+ }
551
+ unset( $field, $sub_fields );
552
  }
553
  }
554
 
556
  $cache_key = maybe_serialize( $where ) . $order_by . 'l' . $limit . 'b' . $blog_id;
557
  if ( self::$use_cache ) {
558
  // make sure old cache doesn't get saved as a transient
559
+ $results = wp_cache_get( $cache_key, 'frm_field' );
560
  if ( false !== $results ) {
561
+ return stripslashes_deep( $results );
562
  }
563
  }
564
 
596
  $results = FrmDb::get_var( $table_name . ' fi LEFT OUTER JOIN ' . $form_table_name . ' fr ON fi.form_id=fr.id', $where, 'fi.*, fr.name as form_name', $args, '', $query_type );
597
  } else {
598
  // if the query is not an array, then it has already been prepared
599
+ $query .= FrmDb::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
600
 
601
  $function_name = ( $query_type == 'row' ) ? 'get_row' : 'get_results';
602
  $results = $wpdb->$function_name( $query );
640
  private static function prepare_options( &$results ) {
641
  $results->field_options = maybe_unserialize( $results->field_options );
642
 
643
+ $results->options = maybe_unserialize( $results->options );
644
+ $results->default_value = maybe_unserialize( $results->default_value );
645
  }
646
 
647
  /**
classes/models/FrmFieldFormHtml.php CHANGED
@@ -140,17 +140,17 @@ class FrmFieldFormHtml {
140
  $this->html = str_replace( 'field_[key]', $this->html_id, $this->html );
141
 
142
  //replace [key]
143
- $this->html = str_replace( '[key]', $this->field_obj->get_field_column('field_key'), $this->html );
144
 
145
  //replace [field_name]
146
- $this->html = str_replace('[field_name]', $this->field_obj->get_field_column('name'), $this->html );
147
  }
148
 
149
  /**
150
  * @since 3.0
151
  */
152
  private function replace_required_label_shortcode() {
153
- $required = FrmField::is_required( $this->field_obj->get_field() ) ? $this->field_obj->get_field_column('required_indicator') : '';
154
  FrmShortcodeHelper::remove_inline_conditions( ! empty( $required ), 'required_label', $required, $this->html );
155
  }
156
 
@@ -173,7 +173,7 @@ class FrmFieldFormHtml {
173
  */
174
  private function replace_description_shortcode() {
175
  $this->maybe_add_description_id();
176
- $description = $this->field_obj->get_field_column('description');
177
  FrmShortcodeHelper::remove_inline_conditions( ( $description && $description != '' ), 'description', $description, $this->html );
178
  }
179
 
@@ -183,7 +183,7 @@ class FrmFieldFormHtml {
183
  * @since 3.0
184
  */
185
  private function maybe_add_description_id() {
186
- $description = $this->field_obj->get_field_column('description');
187
  if ( $description != '' ) {
188
 
189
  preg_match_all( '/(\[if\s+description\])(.*?)(\[\/if\s+description\])/mis', $this->html, $inner_html );
@@ -237,7 +237,7 @@ class FrmFieldFormHtml {
237
  $this->html .= "\n";
238
 
239
  // Stop html filtering on confirmation field to prevent loop
240
- if ( $this->field_obj->get_field_column('conf_field') != 'stop' ) {
241
  $this->filter_for_more_shortcodes();
242
  }
243
  }
@@ -274,7 +274,7 @@ class FrmFieldFormHtml {
274
  * @since 3.0
275
  */
276
  private function replace_shortcodes_with_atts() {
277
- preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $this->html, $shortcodes, PREG_PATTERN_ORDER);
278
 
279
  foreach ( $shortcodes[0] as $short_key => $tag ) {
280
  $shortcode_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
@@ -333,7 +333,7 @@ class FrmFieldFormHtml {
333
  private function add_class_to_label() {
334
  $label_class = $this->field_obj->get_label_class();
335
  $this->html = str_replace( '[label_position]', $label_class, $this->html );
336
- if ( $this->field_obj->get_field_column('label') == 'inside' && $this->field_obj->get_field_column('value') != '' ) {
337
  $this->html = str_replace( 'frm_primary_label', 'frm_primary_label frm_visible', $this->html );
338
  }
339
  }
@@ -356,7 +356,7 @@ class FrmFieldFormHtml {
356
  private function add_field_div_classes() {
357
  $classes = $this->get_field_div_classes();
358
 
359
- if ( $this->field_obj->get_field_column('type') == 'html' && strpos( $this->html, '[error_class]' ) === false ) {
360
  // there is no error_class shortcode for HTML fields
361
  $this->html = str_replace( 'class="frm_form_field', 'class="frm_form_field ' . $classes, $this->html );
362
  }
@@ -378,13 +378,13 @@ class FrmFieldFormHtml {
378
  // Add label position class
379
  $settings = $this->field_obj->display_field_settings();
380
  if ( isset( $settings['label_position'] ) && $settings['label_position'] ) {
381
- $classes .= ' frm_' . $this->field_obj->get_field_column('label') . '_container';
382
  }
383
 
384
  // Add CSS layout classes
385
- $extra_classes = $this->field_obj->get_field_column('classes');
386
  if ( ! empty( $extra_classes ) ) {
387
- if ( ! strpos( $this->html, 'frm_form_field ') ) {
388
  $classes .= ' frm_form_field';
389
  }
390
  $classes .= ' ' . $extra_classes;
140
  $this->html = str_replace( 'field_[key]', $this->html_id, $this->html );
141
 
142
  //replace [key]
143
+ $this->html = str_replace( '[key]', $this->field_obj->get_field_column( 'field_key' ), $this->html );
144
 
145
  //replace [field_name]
146
+ $this->html = str_replace( '[field_name]', $this->field_obj->get_field_column( 'name' ), $this->html );
147
  }
148
 
149
  /**
150
  * @since 3.0
151
  */
152
  private function replace_required_label_shortcode() {
153
+ $required = FrmField::is_required( $this->field_obj->get_field() ) ? $this->field_obj->get_field_column( 'required_indicator' ) : '';
154
  FrmShortcodeHelper::remove_inline_conditions( ! empty( $required ), 'required_label', $required, $this->html );
155
  }
156
 
173
  */
174
  private function replace_description_shortcode() {
175
  $this->maybe_add_description_id();
176
+ $description = $this->field_obj->get_field_column( 'description' );
177
  FrmShortcodeHelper::remove_inline_conditions( ( $description && $description != '' ), 'description', $description, $this->html );
178
  }
179
 
183
  * @since 3.0
184
  */
185
  private function maybe_add_description_id() {
186
+ $description = $this->field_obj->get_field_column( 'description' );
187
  if ( $description != '' ) {
188
 
189
  preg_match_all( '/(\[if\s+description\])(.*?)(\[\/if\s+description\])/mis', $this->html, $inner_html );
237
  $this->html .= "\n";
238
 
239
  // Stop html filtering on confirmation field to prevent loop
240
+ if ( $this->field_obj->get_field_column( 'conf_field' ) != 'stop' ) {
241
  $this->filter_for_more_shortcodes();
242
  }
243
  }
274
  * @since 3.0
275
  */
276
  private function replace_shortcodes_with_atts() {
277
+ preg_match_all( "/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $this->html, $shortcodes, PREG_PATTERN_ORDER );
278
 
279
  foreach ( $shortcodes[0] as $short_key => $tag ) {
280
  $shortcode_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
333
  private function add_class_to_label() {
334
  $label_class = $this->field_obj->get_label_class();
335
  $this->html = str_replace( '[label_position]', $label_class, $this->html );
336
+ if ( $this->field_obj->get_field_column( 'label' ) == 'inside' && $this->field_obj->get_field_column( 'value' ) != '' ) {
337
  $this->html = str_replace( 'frm_primary_label', 'frm_primary_label frm_visible', $this->html );
338
  }
339
  }
356
  private function add_field_div_classes() {
357
  $classes = $this->get_field_div_classes();
358
 
359
+ if ( $this->field_obj->get_field_column( 'type' ) == 'html' && strpos( $this->html, '[error_class]' ) === false ) {
360
  // there is no error_class shortcode for HTML fields
361
  $this->html = str_replace( 'class="frm_form_field', 'class="frm_form_field ' . $classes, $this->html );
362
  }
378
  // Add label position class
379
  $settings = $this->field_obj->display_field_settings();
380
  if ( isset( $settings['label_position'] ) && $settings['label_position'] ) {
381
+ $classes .= ' frm_' . $this->field_obj->get_field_column( 'label' ) . '_container';
382
  }
383
 
384
  // Add CSS layout classes
385
+ $extra_classes = $this->field_obj->get_field_column( 'classes' );
386
  if ( ! empty( $extra_classes ) ) {
387
+ if ( ! strpos( $this->html, 'frm_form_field ' ) ) {
388
  $classes .= ' frm_form_field';
389
  }
390
  $classes .= ' ' . $extra_classes;
classes/models/FrmForm.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
- if ( ! defined('ABSPATH') ) {
3
- die('You are not allowed to call this page directly.');
4
  }
5
 
6
  class FrmForm {
@@ -11,28 +11,28 @@ class FrmForm {
11
  public static function create( $values ) {
12
  global $wpdb;
13
 
14
- $new_values = array(
15
  'form_key' => FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key' ),
16
- 'name' => $values['name'],
17
- 'description' => $values['description'],
18
- 'status' => isset($values['status']) ? $values['status'] : 'draft',
19
- 'logged_in' => isset($values['logged_in']) ? $values['logged_in'] : 0,
20
- 'is_template' => isset($values['is_template']) ? (int) $values['is_template'] : 0,
21
  'parent_form_id' => isset( $values['parent_form_id'] ) ? absint( $values['parent_form_id'] ) : 0,
22
- 'editable' => isset($values['editable']) ? (int) $values['editable'] : 0,
23
- 'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0,
24
- 'created_at' => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1),
25
- );
26
 
27
  $options = isset( $values['options'] ) ? (array) $values['options'] : array();
28
  FrmFormsHelper::fill_form_options( $options, $values );
29
 
30
- $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
31
- $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
32
- $options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
33
 
34
- $options = apply_filters('frm_form_options_before_update', $options, $values);
35
- $new_values['options'] = serialize($options);
36
 
37
  //if(isset($values['id']) && is_numeric($values['id']))
38
  // $new_values['id'] = $values['id'];
@@ -67,23 +67,23 @@ class FrmForm {
67
  'status' => $template ? 'published' : 'draft',
68
  'logged_in' => $values->logged_in ? $values->logged_in : 0,
69
  'editable' => $values->editable ? $values->editable : 0,
70
- 'created_at' => current_time('mysql', 1),
71
  'is_template' => $template ? 1 : 0,
72
  );
73
 
74
  if ( $blog_id ) {
75
  $new_values['status'] = 'published';
76
- $new_options = maybe_unserialize($values->options);
77
- $new_options['email_to'] = get_option('admin_email');
78
  $new_options['copy'] = false;
79
  $new_values['options'] = $new_options;
80
  } else {
81
  $new_values['options'] = $values->options;
82
  }
83
 
84
- if ( is_array($new_values['options']) ) {
85
- $new_values['options'] = serialize($new_values['options']);
86
- }
87
 
88
  $query_results = $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values );
89
 
@@ -92,7 +92,7 @@ class FrmForm {
92
  self::clear_form_cache();
93
 
94
  $form_id = $wpdb->insert_id;
95
- FrmField::duplicate($id, $form_id, $copy_keys, $blog_id);
96
 
97
  // update form settings after fields are created
98
  do_action( 'frm_after_duplicate_form', $form_id, $new_values, array( 'old_id' => $id ) );
@@ -106,11 +106,11 @@ class FrmForm {
106
  $new_opts = maybe_unserialize( $values['options'] );
107
  $values['options'] = $new_opts;
108
 
109
- if ( isset($new_opts['success_msg']) ) {
110
- $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']);
111
- }
112
 
113
- $new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id);
114
 
115
  if ( $new_opts != $values['options'] ) {
116
  global $wpdb;
@@ -128,13 +128,13 @@ class FrmForm {
128
  $values['status'] = 'published';
129
  }
130
 
131
- if ( isset($values['form_key']) ) {
132
  $values['form_key'] = FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key', $id );
133
  }
134
 
135
  $form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' );
136
 
137
- $new_values = self::set_update_options( array(), $values);
138
 
139
  foreach ( $values as $value_key => $value ) {
140
  if ( $value_key && in_array( $value_key, $form_fields ) ) {
@@ -154,9 +154,9 @@ class FrmForm {
154
  } else {
155
  $query_results = true;
156
  }
157
- unset($new_values);
158
 
159
- $values = self::update_fields($id, $values);
160
 
161
  do_action( 'frm_update_form', $id, $values );
162
  do_action( 'frm_update_form_' . $id, $values );
@@ -168,7 +168,7 @@ class FrmForm {
168
  * @return array
169
  */
170
  public static function set_update_options( $new_values, $values ) {
171
- if ( ! isset($values['options']) ) {
172
  return $new_values;
173
  }
174
 
@@ -192,34 +192,34 @@ class FrmForm {
192
  */
193
  public static function update_fields( $id, $values ) {
194
 
195
- if ( ! isset($values['item_meta']) && ! isset($values['field_options']) ) {
196
  return $values;
197
  }
198
 
199
- $all_fields = FrmField::get_all_for_form($id);
200
- if ( empty($all_fields) ) {
201
- return $values;
202
- }
203
 
204
- if ( ! isset($values['item_meta']) ) {
205
- $values['item_meta'] = array();
206
- }
207
 
208
  $field_array = array();
209
- $existing_keys = array_keys($values['item_meta']);
210
  foreach ( $all_fields as $fid ) {
211
- if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) {
212
  $values['item_meta'][ $fid->id ] = '';
213
  }
214
  $field_array[ $fid->id ] = $fid;
215
  }
216
- unset($all_fields);
217
 
218
  foreach ( $values['item_meta'] as $field_id => $default_value ) {
219
  if ( isset( $field_array[ $field_id ] ) ) {
220
  $field = $field_array[ $field_id ];
221
  } else {
222
- $field = FrmField::getOne($field_id);
223
  }
224
 
225
  if ( ! $field ) {
@@ -243,11 +243,11 @@ class FrmForm {
243
  foreach ( $update_options as $opt => $default ) {
244
  $field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? $values['field_options'][ $opt . '_' . $field_id ] : $default;
245
  if ( is_string( $field->field_options[ $opt ] ) ) {
246
- $field->field_options[ $opt ] = trim( sanitize_text_field( $field->field_options[ $opt ] ) );
247
  }
248
  }
249
 
250
- $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values);
251
  $default_value = maybe_serialize( $values['item_meta'][ $field_id ] );
252
 
253
  $new_field = array(
@@ -259,7 +259,7 @@ class FrmForm {
259
 
260
  FrmField::update( $field_id, $new_field );
261
 
262
- FrmField::delete_form_transient($field->form_id);
263
  }
264
  self::clear_form_cache();
265
 
@@ -307,7 +307,7 @@ class FrmForm {
307
  */
308
  public static function set_status( $id, $status ) {
309
  if ( 'trash' == $status ) {
310
- return self::trash($id);
311
  }
312
 
313
  $statuses = array( 'published', 'draft', 'trash' );
@@ -317,7 +317,7 @@ class FrmForm {
317
 
318
  global $wpdb;
319
 
320
- if ( is_array($id) ) {
321
  $where = array(
322
  'id' => $id,
323
  'parent_form_id' => $id,
@@ -347,7 +347,7 @@ class FrmForm {
347
  return self::destroy( $id );
348
  }
349
 
350
- $form = self::getOne($id);
351
  if ( ! $form ) {
352
  return false;
353
  }
@@ -391,7 +391,7 @@ class FrmForm {
391
  public static function destroy( $id ) {
392
  global $wpdb;
393
 
394
- $form = self::getOne($id);
395
  if ( ! $form ) {
396
  return false;
397
  }
@@ -399,10 +399,10 @@ class FrmForm {
399
 
400
  // Disconnect the entries from this form
401
  $entries = FrmDb::get_col( $wpdb->prefix . 'frm_items', array( 'form_id' => $id ) );
402
- foreach ( $entries as $entry_id ) {
403
- FrmEntry::destroy($entry_id);
404
- unset($entry_id);
405
- }
406
 
407
  // Disconnect the fields from this form
408
  $wpdb->query( $wpdb->prepare( 'DELETE fi FROM ' . $wpdb->prefix . 'frm_fields AS fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id) WHERE fi.form_id=%d OR parent_form_id=%d', $id, $id ) );
@@ -411,7 +411,7 @@ class FrmForm {
411
  if ( $query_results ) {
412
  // Delete all form actions linked to this form
413
  $action_control = FrmFormActionsController::get_form_actions( 'email' );
414
- $action_control->destroy($id, 'all');
415
 
416
  // Clear form caching
417
  self::clear_form_cache();
@@ -459,13 +459,13 @@ class FrmForm {
459
  public static function getName( $id ) {
460
  $form = FrmDb::check_cache( $id, 'frm_form' );
461
  if ( $form ) {
462
- $r = stripslashes($form->name);
463
  return $r;
464
  }
465
 
466
  $query_key = is_numeric( $id ) ? 'id' : 'form_key';
467
  $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' );
468
- $r = stripslashes($r);
469
 
470
  return $r;
471
  }
@@ -541,17 +541,17 @@ class FrmForm {
541
  $table_name = $prefix . 'frm_forms';
542
  } else {
543
  $table_name = $wpdb->prefix . 'frm_forms';
544
- $cache = wp_cache_get($id, 'frm_form');
545
  if ( $cache ) {
546
- if ( isset($cache->options) ) {
547
- $cache->options = maybe_unserialize($cache->options);
548
  }
549
 
550
- return stripslashes_deep($cache);
551
  }
552
  }
553
 
554
- if ( is_numeric($id) ) {
555
  $where = array( 'id' => $id );
556
  } else {
557
  $where = array( 'form_key' => $id );
@@ -559,11 +559,11 @@ class FrmForm {
559
 
560
  $results = FrmDb::get_row( $table_name, $where );
561
 
562
- if ( isset($results->options) ) {
563
  FrmDb::set_cache( $results->id, $results, 'frm_form' );
564
- $results->options = maybe_unserialize($results->options);
565
  }
566
- return stripslashes_deep($results);
567
  }
568
 
569
  /**
@@ -595,7 +595,7 @@ class FrmForm {
595
  $results = reset( $results );
596
  }
597
 
598
- return stripslashes_deep($results);
599
  }
600
 
601
  /**
@@ -651,7 +651,7 @@ class FrmForm {
651
  $counts['draft']++;
652
  }
653
 
654
- unset($row);
655
  }
656
 
657
  $counts = (object) $counts;
@@ -677,7 +677,7 @@ class FrmForm {
677
  public static function validate( $values ) {
678
  $errors = array();
679
 
680
- return apply_filters('frm_validate_form', $errors, $values);
681
  }
682
 
683
  public static function get_params( $form = null ) {
@@ -693,7 +693,7 @@ class FrmForm {
693
  return $frm_vars['form_params'][ $form->id ];
694
  }
695
 
696
- $action_var = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
697
  $action = apply_filters( 'frm_show_new_entry_page', FrmAppHelper::get_param( $action_var, 'new', 'get', 'sanitize_title' ), $form );
698
 
699
  $default_values = array(
@@ -836,7 +836,7 @@ class FrmForm {
836
  $small_form = new stdClass();
837
  foreach ( array( 'id', 'form_key', 'name' ) as $var ) {
838
  $small_form->{$var} = $form->{$var};
839
- unset($var);
840
  }
841
 
842
  $frm_vars['forms_loaded'][] = $small_form;
@@ -846,7 +846,7 @@ class FrmForm {
846
  $frm_vars['load_css'] = true;
847
  }
848
 
849
- return ( ( ! isset($frm_vars['css_loaded']) || ! $frm_vars['css_loaded'] ) && $global_load );
850
  }
851
 
852
  public static function show_submit( $form ) {
1
  <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ die( 'You are not allowed to call this page directly.' );
4
  }
5
 
6
  class FrmForm {
11
  public static function create( $values ) {
12
  global $wpdb;
13
 
14
+ $new_values = array(
15
  'form_key' => FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key' ),
16
+ 'name' => $values['name'],
17
+ 'description' => $values['description'],
18
+ 'status' => isset( $values['status'] ) ? $values['status'] : 'draft',
19
+ 'logged_in' => isset( $values['logged_in'] ) ? $values['logged_in'] : 0,
20
+ 'is_template' => isset( $values['is_template'] ) ? (int) $values['is_template'] : 0,
21
  'parent_form_id' => isset( $values['parent_form_id'] ) ? absint( $values['parent_form_id'] ) : 0,
22
+ 'editable' => isset( $values['editable'] ) ? (int) $values['editable'] : 0,
23
+ 'default_template' => isset( $values['default_template'] ) ? (int) $values['default_template'] : 0,
24
+ 'created_at' => isset( $values['created_at'] ) ? $values['created_at'] : current_time( 'mysql', 1 ),
25
+ );
26
 
27
  $options = isset( $values['options'] ) ? (array) $values['options'] : array();
28
  FrmFormsHelper::fill_form_options( $options, $values );
29
 
30
+ $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' );
31
+ $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' );
32
+ $options['submit_html'] = isset( $values['options']['submit_html'] ) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' );
33
 
34
+ $options = apply_filters( 'frm_form_options_before_update', $options, $values );
35
+ $new_values['options'] = serialize( $options );
36
 
37
  //if(isset($values['id']) && is_numeric($values['id']))
38
  // $new_values['id'] = $values['id'];
67
  'status' => $template ? 'published' : 'draft',
68
  'logged_in' => $values->logged_in ? $values->logged_in : 0,
69
  'editable' => $values->editable ? $values->editable : 0,
70
+ 'created_at' => current_time( 'mysql', 1 ),
71
  'is_template' => $template ? 1 : 0,
72
  );
73
 
74
  if ( $blog_id ) {
75
  $new_values['status'] = 'published';
76
+ $new_options = maybe_unserialize( $values->options );
77
+ $new_options['email_to'] = get_option( 'admin_email' );
78
  $new_options['copy'] = false;
79
  $new_values['options'] = $new_options;
80
  } else {
81
  $new_values['options'] = $values->options;
82
  }
83
 
84
+ if ( is_array( $new_values['options'] ) ) {
85
+ $new_values['options'] = serialize( $new_values['options'] );
86
+ }
87
 
88
  $query_results = $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values );
89
 
92
  self::clear_form_cache();
93
 
94
  $form_id = $wpdb->insert_id;
95
+ FrmField::duplicate( $id, $form_id, $copy_keys, $blog_id );
96
 
97
  // update form settings after fields are created
98
  do_action( 'frm_after_duplicate_form', $form_id, $new_values, array( 'old_id' => $id ) );
106
  $new_opts = maybe_unserialize( $values['options'] );
107
  $values['options'] = $new_opts;
108
 
109
+ if ( isset( $new_opts['success_msg'] ) ) {
110
+ $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids( $new_opts['success_msg'] );
111
+ }
112
 
113
+ $new_opts = apply_filters( 'frm_after_duplicate_form_values', $new_opts, $form_id );
114
 
115
  if ( $new_opts != $values['options'] ) {
116
  global $wpdb;
128
  $values['status'] = 'published';
129
  }
130
 
131
+ if ( isset( $values['form_key'] ) ) {
132
  $values['form_key'] = FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key', $id );
133
  }
134
 
135
  $form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' );
136
 
137
+ $new_values = self::set_update_options( array(), $values );
138
 
139
  foreach ( $values as $value_key => $value ) {
140
  if ( $value_key && in_array( $value_key, $form_fields ) ) {
154
  } else {
155
  $query_results = true;
156
  }
157
+ unset( $new_values );
158
 
159
+ $values = self::update_fields( $id, $values );
160
 
161
  do_action( 'frm_update_form', $id, $values );
162
  do_action( 'frm_update_form_' . $id, $values );
168
  * @return array
169
  */
170
  public static function set_update_options( $new_values, $values ) {
171
+ if ( ! isset( $values['options'] ) ) {
172
  return $new_values;
173
  }
174
 
192
  */
193
  public static function update_fields( $id, $values ) {
194
 
195
+ if ( ! isset( $values['item_meta'] ) && ! isset( $values['field_options'] ) ) {
196
  return $values;
197
  }
198
 
199
+ $all_fields = FrmField::get_all_for_form( $id );
200
+ if ( empty( $all_fields ) ) {
201
+ return $values;
202
+ }
203
 
204
+ if ( ! isset( $values['item_meta'] ) ) {
205
+ $values['item_meta'] = array();
206
+ }
207
 
208
  $field_array = array();
209
+ $existing_keys = array_keys( $values['item_meta'] );
210
  foreach ( $all_fields as $fid ) {
211
+ if ( ! in_array( $fid->id, $existing_keys ) && ( isset( $values['frm_fields_submitted'] ) && in_array( $fid->id, $values['frm_fields_submitted'] ) ) || isset( $values['options'] ) ) {
212
  $values['item_meta'][ $fid->id ] = '';
213
  }
214
  $field_array[ $fid->id ] = $fid;
215
  }
216
+ unset( $all_fields );
217
 
218
  foreach ( $values['item_meta'] as $field_id => $default_value ) {
219
  if ( isset( $field_array[ $field_id ] ) ) {
220
  $field = $field_array[ $field_id ];
221
  } else {
222
+ $field = FrmField::getOne( $field_id );
223
  }
224
 
225
  if ( ! $field ) {
243
  foreach ( $update_options as $opt => $default ) {
244
  $field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? $values['field_options'][ $opt . '_' . $field_id ] : $default;
245
  if ( is_string( $field->field_options[ $opt ] ) ) {
246
+ $field->field_options[ $opt ] = trim( FrmAppHelper::kses( $field->field_options[ $opt ], 'all' ) );
247
  }
248
  }
249
 
250
+ $field->field_options = apply_filters( 'frm_update_field_options', $field->field_options, $field, $values );
251
  $default_value = maybe_serialize( $values['item_meta'][ $field_id ] );
252
 
253
  $new_field = array(
259
 
260
  FrmField::update( $field_id, $new_field );
261
 
262
+ FrmField::delete_form_transient( $field->form_id );
263
  }
264
  self::clear_form_cache();
265
 
307
  */
308
  public static function set_status( $id, $status ) {
309
  if ( 'trash' == $status ) {
310
+ return self::trash( $id );
311
  }
312
 
313
  $statuses = array( 'published', 'draft', 'trash' );
317
 
318
  global $wpdb;
319
 
320
+ if ( is_array( $id ) ) {
321
  $where = array(
322
  'id' => $id,
323
  'parent_form_id' => $id,
347
  return self::destroy( $id );
348
  }
349
 
350
+ $form = self::getOne( $id );
351
  if ( ! $form ) {
352
  return false;
353
  }
391
  public static function destroy( $id ) {
392
  global $wpdb;
393
 
394
+ $form = self::getOne( $id );
395
  if ( ! $form ) {
396
  return false;
397
  }
399
 
400
  // Disconnect the entries from this form
401
  $entries = FrmDb::get_col( $wpdb->prefix . 'frm_items', array( 'form_id' => $id ) );
402
+ foreach ( $entries as $entry_id ) {
403
+ FrmEntry::destroy( $entry_id );
404
+ unset( $entry_id );
405
+ }
406
 
407
  // Disconnect the fields from this form
408
  $wpdb->query( $wpdb->prepare( 'DELETE fi FROM ' . $wpdb->prefix . 'frm_fields AS fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id) WHERE fi.form_id=%d OR parent_form_id=%d', $id, $id ) );
411
  if ( $query_results ) {
412
  // Delete all form actions linked to this form
413
  $action_control = FrmFormActionsController::get_form_actions( 'email' );
414
+ $action_control->destroy( $id, 'all' );
415
 
416
  // Clear form caching
417
  self::clear_form_cache();
459
  public static function getName( $id ) {
460
  $form = FrmDb::check_cache( $id, 'frm_form' );
461
  if ( $form ) {
462
+ $r = stripslashes( $form->name );
463
  return $r;
464
  }
465
 
466
  $query_key = is_numeric( $id ) ? 'id' : 'form_key';
467
  $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' );
468
+ $r = stripslashes( $r );
469
 
470
  return $r;
471
  }
541
  $table_name = $prefix . 'frm_forms';
542
  } else {
543
  $table_name = $wpdb->prefix . 'frm_forms';
544
+ $cache = wp_cache_get( $id, 'frm_form' );
545
  if ( $cache ) {
546
+ if ( isset( $cache->options ) ) {
547
+ $cache->options = maybe_unserialize( $cache->options );
548
  }
549
 
550
+ return stripslashes_deep( $cache );
551
  }
552
  }
553
 
554
+ if ( is_numeric( $id ) ) {
555
  $where = array( 'id' => $id );
556
  } else {
557
  $where = array( 'form_key' => $id );
559
 
560
  $results = FrmDb::get_row( $table_name, $where );
561
 
562
+ if ( isset( $results->options ) ) {
563
  FrmDb::set_cache( $results->id, $results, 'frm_form' );
564
+ $results->options = maybe_unserialize( $results->options );
565
  }
566
+ return stripslashes_deep( $results );
567
  }
568
 
569
  /**
595
  $results = reset( $results );
596
  }
597
 
598
+ return stripslashes_deep( $results );
599
  }
600
 
601
  /**
651
  $counts['draft']++;
652
  }
653
 
654
+ unset( $row );
655
  }
656
 
657
  $counts = (object) $counts;
677
  public static function validate( $values ) {
678
  $errors = array();
679
 
680
+ return apply_filters( 'frm_validate_form', $errors, $values );
681
  }
682
 
683
  public static function get_params( $form = null ) {
693
  return $frm_vars['form_params'][ $form->id ];
694
  }
695
 
696
+ $action_var = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
697
  $action = apply_filters( 'frm_show_new_entry_page', FrmAppHelper::get_param( $action_var, 'new', 'get', 'sanitize_title' ), $form );
698
 
699
  $default_values = array(
836
  $small_form = new stdClass();
837
  foreach ( array( 'id', 'form_key', 'name' ) as $var ) {
838
  $small_form->{$var} = $form->{$var};
839
+ unset( $var );
840
  }
841
 
842
  $frm_vars['forms_loaded'][] = $small_form;
846
  $frm_vars['load_css'] = true;
847
  }
848
 
849
+ return ( ( ! isset( $frm_vars['css_loaded'] ) || ! $frm_vars['css_loaded'] ) && $global_load );
850
  }
851
 
852
  public static function show_submit( $form ) {
classes/models/FrmFormAction.php CHANGED
@@ -69,11 +69,11 @@ class FrmFormAction {
69
  * - height: currently not used but may be needed in the future
70
  */
71
  public function __construct( $id_base, $name, $action_options = array(), $control_options = array() ) {
72
- if ( ! defined('ABSPATH') ) {
73
- die('You are not allowed to call this page directly.');
74
- }
75
 
76
- $this->id_base = strtolower($id_base);
77
  $this->name = $name;
78
  $this->option_name = 'frm_' . $this->id_base . '_action';
79
 
@@ -142,12 +142,12 @@ class FrmFormAction {
142
  $post_content = array();
143
  $default_values = $this->get_global_defaults();
144
 
145
- // fill default values
146
- $post_content = wp_parse_args( $post_content, $default_values);
147
 
148
- if ( ! isset($post_content['event']) && ! $this->action_options['force_event'] ) {
149
- $post_content['event'] = array( reset($this->action_options['event']) );
150
- }
151
 
152
  $form_action = array(
153
  'post_title' => $this->name,
@@ -159,7 +159,7 @@ class FrmFormAction {
159
  'post_name' => $this->form_id . '_' . $this->id_base . '_' . $this->number,
160
  'menu_order' => $this->form_id,
161
  );
162
- unset($post_content);
163
 
164
  return (object) $form_action;
165
  }
@@ -169,7 +169,7 @@ class FrmFormAction {
169
 
170
  $action = $this->prepare_new();
171
 
172
- return $this->save_settings($action);
173
  }
174
 
175
  public function duplicate_form_actions( $form_id, $old_id ) {
@@ -183,8 +183,8 @@ class FrmFormAction {
183
 
184
  $this->form_id = $form_id;
185
  foreach ( $actions as $action ) {
186
- $this->duplicate_one($action, $form_id);
187
- unset($action);
188
  }
189
  }
190
 
@@ -201,9 +201,9 @@ class FrmFormAction {
201
  $action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] );
202
  $post_id = $this->save_settings( $action );
203
  } else {
204
- // Create action
205
- $action['post_content'] = FrmAppHelper::maybe_json_decode($action['post_content']);
206
- $post_id = $this->duplicate_one( (object) $action, $action['menu_order']);
207
  }
208
  return $post_id;
209
  }
@@ -229,20 +229,20 @@ class FrmFormAction {
229
  }
230
  }
231
 
232
- unset($key, $val);
233
- }
234
- unset($action->ID);
235
 
236
- return $this->save_settings($action);
237
  }
238
 
239
  private function duplicate_array_walk( $action, $subkey, $val ) {
240
  global $frm_duplicate_ids;
241
 
242
- if ( is_array($subkey) ) {
243
  foreach ( $subkey as $subkey2 ) {
244
  foreach ( (array) $val as $ck => $cv ) {
245
- if ( is_array($cv) ) {
246
  $action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey2, $cv );
247
  } else if ( isset( $cv[ $subkey ] ) && is_numeric( $cv[ $subkey ] ) && isset( $frm_duplicate_ids[ $cv[ $subkey ] ] ) ) {
248
  $action[ $ck ][ $subkey ] = $frm_duplicate_ids[ $cv[ $subkey ] ];
@@ -251,7 +251,7 @@ class FrmFormAction {
251
  }
252
  } else {
253
  foreach ( (array) $val as $ck => $cv ) {
254
- if ( is_array($cv) ) {
255
  $action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey, $cv );
256
  } else if ( $ck == $subkey && isset( $frm_duplicate_ids[ $cv ] ) ) {
257
  $action[ $ck ] = $frm_duplicate_ids[ $cv ];
@@ -287,9 +287,9 @@ class FrmFormAction {
287
  $action_ids = array();
288
 
289
  foreach ( $settings as $number => $new_instance ) {
290
- $this->_set($number);
291
 
292
- if ( ! isset($new_instance['post_title']) ) {
293
  // settings were never opened, so don't update
294
  $action_ids[] = $new_instance['ID'];
295
  $this->updated = true;
@@ -321,14 +321,14 @@ class FrmFormAction {
321
  */
322
  $instance = apply_filters( 'frm_action_update_callback', $instance, $new_instance, $old_instance, $this );
323
 
324
- $instance['post_content'] = apply_filters('frm_before_save_action', $instance['post_content'], $instance, $new_instance, $old_instance, $this);
325
  $instance['post_content'] = apply_filters( 'frm_before_save_' . $this->id_base . '_action', $new_instance['post_content'], $instance, $new_instance, $old_instance, $this );
326
 
327
  if ( false !== $instance ) {
328
  $all_instances[ $number ] = $instance;
329
  }
330
 
331
- $action_ids[] = $this->save_settings($instance);
332
 
333
  $this->updated = true;
334
  }
@@ -342,7 +342,7 @@ class FrmFormAction {
342
  }
343
 
344
  public function get_single_action( $id ) {
345
- $action = get_post($id);
346
  if ( $action ) {
347
  $action = $this->prepare_action( $action );
348
  $this->_set( $id );
@@ -351,12 +351,12 @@ class FrmFormAction {
351
  }
352
 
353
  public function get_one( $form_id ) {
354
- return $this->get_all($form_id, 1);
355
  }
356
 
357
  public static function get_action_for_form( $form_id, $type = 'all', $limit = 99 ) {
358
  $action_controls = FrmFormActionsController::get_form_actions( $type );
359
- if ( empty($action_controls) ) {
360
  // don't continue if there are no available actions
361
  return array();
362
  }
@@ -392,7 +392,7 @@ class FrmFormAction {
392
  }
393
 
394
  if ( 1 === $limit ) {
395
- $settings = reset($settings);
396
  }
397
 
398
  return $settings;
@@ -434,27 +434,27 @@ class FrmFormAction {
434
  $query['suppress_filters'] = false;
435
 
436
  $actions = FrmDb::check_cache( serialize( $query ) . '_type_' . $type, 'frm_actions', $query, 'get_posts' );
437
- unset($query);
438
 
439
  remove_filter( 'posts_where', 'FrmFormActionsController::limit_by_type' );
440
 
441
- if ( empty($actions) ) {
442
  return array();
443
  }
444
 
445
  $settings = array();
446
  foreach ( $actions as $action ) {
447
- if ( count($settings) >= $limit ) {
448
  continue;
449
  }
450
 
451
- $action = $this->prepare_action($action);
452
 
453
  $settings[ $action->ID ] = $action;
454
  }
455
 
456
  if ( 1 === $limit ) {
457
- $settings = reset($settings);
458
  }
459
 
460
  return $settings;
@@ -477,7 +477,7 @@ class FrmFormAction {
477
  }
478
 
479
  public function prepare_action( $action ) {
480
- $action->post_content = (array) FrmAppHelper::maybe_json_decode($action->post_content);
481
  $action->post_excerpt = sanitize_title( $action->post_excerpt );
482
 
483
  $default_values = $this->get_global_defaults();
@@ -486,7 +486,7 @@ class FrmFormAction {
486
  $action->post_content += $default_values;
487
 
488
  foreach ( $default_values as $k => $vals ) {
489
- if ( is_array($vals) && ! empty($vals) ) {
490
  if ( 'event' == $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[ $k ] ) ) {
491
  continue;
492
  }
@@ -494,9 +494,9 @@ class FrmFormAction {
494
  }
495
  }
496
 
497
- if ( ! is_array($action->post_content['event']) ) {
498
- $action->post_content['event'] = explode(',', $action->post_content['event']);
499
- }
500
 
501
  return $action;
502
  }
@@ -517,7 +517,7 @@ class FrmFormAction {
517
  $post_ids = FrmDb::get_col( $wpdb->posts, $query, 'ID' );
518
 
519
  foreach ( $post_ids as $id ) {
520
- wp_delete_post($id);
521
  }
522
  self::clear_cache();
523
  }
@@ -538,11 +538,11 @@ class FrmFormAction {
538
  public function get_global_defaults() {
539
  $defaults = $this->get_defaults();
540
 
541
- if ( ! isset($defaults['event']) ) {
542
  $defaults['event'] = array( 'create' );
543
  }
544
 
545
- if ( ! isset($defaults['conditions']) ) {
546
  $defaults['conditions'] = array(
547
  'send_stop' => '',
548
  'any_all' => '',
@@ -562,8 +562,8 @@ class FrmFormAction {
562
  * Migrate settings from form->options into new action.
563
  */
564
  public function migrate_to_2( $form, $update = 'update' ) {
565
- $action = $this->prepare_new($form->id);
566
- $form->options = maybe_unserialize($form->options);
567
 
568
  // fill with existing options
569
  foreach ( $action->post_content as $name => $val ) {
@@ -573,7 +573,7 @@ class FrmFormAction {
573
  }
574
  }
575
 
576
- $action = $this->migrate_values($action, $form);
577
 
578
  // check if action already exists
579
  $post_id = get_posts( array(
@@ -583,14 +583,14 @@ class FrmFormAction {
583
  'numberposts' => 1,
584
  ) );
585
 
586
- if ( empty($post_id) ) {
587
- // create action now
588
- $post_id = $this->save_settings($action);
589
- }
590
 
591
  if ( $post_id && 'update' == $update ) {
592
  global $wpdb;
593
- $form->options = maybe_serialize($form->options);
594
 
595
  // update form options
596
  $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => $form->options ), array( 'id' => $form->id ) );
@@ -622,7 +622,7 @@ class FrmFormAction {
622
 
623
  $observed_value = self::get_value_from_entry( $entry, $condition['hide_field'] );
624
 
625
- $stop = FrmFieldsHelper::value_meets_condition($observed_value, $condition['hide_field_cond'], $condition['hide_opt']);
626
 
627
  if ( $notification['conditions']['send_stop'] == 'send' ) {
628
  $stop = $stop ? false : true;
@@ -633,7 +633,7 @@ class FrmFormAction {
633
 
634
  if ( $notification['conditions']['any_all'] == 'all' && ! empty( $met ) && isset( $met[0] ) && isset( $met[1] ) ) {
635
  $stop = ( $notification['conditions']['send_stop'] == 'send' );
636
- } else if ( $notification['conditions']['any_all'] == 'any' && $notification['conditions']['send_stop'] == 'send' && isset($met[0]) ) {
637
  $stop = false;
638
  }
639
 
69
  * - height: currently not used but may be needed in the future
70
  */
71
  public function __construct( $id_base, $name, $action_options = array(), $control_options = array() ) {
72
+ if ( ! defined( 'ABSPATH' ) ) {
73
+ die( 'You are not allowed to call this page directly.' );
74
+ }
75
 
76
+ $this->id_base = strtolower( $id_base );
77
  $this->name = $name;
78
  $this->option_name = 'frm_' . $this->id_base . '_action';
79
 
142
  $post_content = array();
143
  $default_values = $this->get_global_defaults();
144
 
145
+ // fill default values
146
+ $post_content = wp_parse_args( $post_content, $default_values );
147
 
148
+ if ( ! isset( $post_content['event'] ) && ! $this->action_options['force_event'] ) {
149
+ $post_content['event'] = array( reset( $this->action_options['event'] ) );
150
+ }
151
 
152
  $form_action = array(
153
  'post_title' => $this->name,
159
  'post_name' => $this->form_id . '_' . $this->id_base . '_' . $this->number,
160
  'menu_order' => $this->form_id,
161
  );
162
+ unset( $post_content );
163
 
164
  return (object) $form_action;
165
  }
169
 
170
  $action = $this->prepare_new();
171
 
172
+ return $this->save_settings( $action );
173
  }
174
 
175
  public function duplicate_form_actions( $form_id, $old_id ) {
183
 
184
  $this->form_id = $form_id;
185
  foreach ( $actions as $action ) {
186
+ $this->duplicate_one( $action, $form_id );
187
+ unset( $action );
188
  }
189
  }
190
 
201
  $action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] );
202
  $post_id = $this->save_settings( $action );
203
  } else {
204
+ // Create action
205
+ $action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] );
206
+ $post_id = $this->duplicate_one( (object) $action, $action['menu_order'] );
207
  }
208
  return $post_id;
209
  }
229
  }
230
  }
231
 
232
+ unset( $key, $val );
233
+ }
234
+ unset( $action->ID );
235
 
236
+ return $this->save_settings( $action );
237
  }
238
 
239
  private function duplicate_array_walk( $action, $subkey, $val ) {
240
  global $frm_duplicate_ids;
241
 
242
+ if ( is_array( $subkey ) ) {
243
  foreach ( $subkey as $subkey2 ) {
244
  foreach ( (array) $val as $ck => $cv ) {
245
+ if ( is_array( $cv ) ) {
246
  $action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey2, $cv );
247
  } else if ( isset( $cv[ $subkey ] ) && is_numeric( $cv[ $subkey ] ) && isset( $frm_duplicate_ids[ $cv[ $subkey ] ] ) ) {
248
  $action[ $ck ][ $subkey ] = $frm_duplicate_ids[ $cv[ $subkey ] ];
251
  }
252
  } else {
253
  foreach ( (array) $val as $ck => $cv ) {
254
+ if ( is_array( $cv ) ) {
255
  $action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey, $cv );
256
  } else if ( $ck == $subkey && isset( $frm_duplicate_ids[ $cv ] ) ) {
257
  $action[ $ck ] = $frm_duplicate_ids[ $cv ];
287
  $action_ids = array();
288
 
289
  foreach ( $settings as $number => $new_instance ) {
290
+ $this->_set( $number );
291
 
292
+ if ( ! isset( $new_instance['post_title'] ) ) {
293
  // settings were never opened, so don't update
294
  $action_ids[] = $new_instance['ID'];
295
  $this->updated = true;
321
  */
322
  $instance = apply_filters( 'frm_action_update_callback', $instance, $new_instance, $old_instance, $this );
323
 
324
+ $instance['post_content'] = apply_filters( 'frm_before_save_action', $instance['post_content'], $instance, $new_instance, $old_instance, $this );
325
  $instance['post_content'] = apply_filters( 'frm_before_save_' . $this->id_base . '_action', $new_instance['post_content'], $instance, $new_instance, $old_instance, $this );
326
 
327
  if ( false !== $instance ) {
328
  $all_instances[ $number ] = $instance;
329
  }
330
 
331
+ $action_ids[] = $this->save_settings( $instance );
332
 
333
  $this->updated = true;
334
  }
342
  }
343
 
344
  public function get_single_action( $id ) {
345
+ $action = get_post( $id );
346
  if ( $action ) {
347
  $action = $this->prepare_action( $action );
348
  $this->_set( $id );
351
  }
352
 
353
  public function get_one( $form_id ) {
354
+ return $this->get_all( $form_id, 1 );
355
  }
356
 
357
  public static function get_action_for_form( $form_id, $type = 'all', $limit = 99 ) {
358
  $action_controls = FrmFormActionsController::get_form_actions( $type );
359
+ if ( empty( $action_controls ) ) {
360
  // don't continue if there are no available actions
361
  return array();
362
  }
392
  }
393
 
394
  if ( 1 === $limit ) {
395
+ $settings = reset( $settings );
396
  }
397
 
398
  return $settings;
434
  $query['suppress_filters'] = false;
435
 
436
  $actions = FrmDb::check_cache( serialize( $query ) . '_type_' . $type, 'frm_actions', $query, 'get_posts' );
437
+ unset( $query );
438
 
439
  remove_filter( 'posts_where', 'FrmFormActionsController::limit_by_type' );
440
 
441
+ if ( empty( $actions ) ) {
442
  return array();
443
  }
444
 
445
  $settings = array();
446
  foreach ( $actions as $action ) {
447
+ if ( count( $settings ) >= $limit ) {
448
  continue;
449
  }
450
 
451
+ $action = $this->prepare_action( $action );
452
 
453
  $settings[ $action->ID ] = $action;
454
  }
455
 
456
  if ( 1 === $limit ) {
457
+ $settings = reset( $settings );
458
  }
459
 
460
  return $settings;
477
  }
478
 
479
  public function prepare_action( $action ) {
480
+ $action->post_content = (array) FrmAppHelper::maybe_json_decode( $action->post_content );
481
  $action->post_excerpt = sanitize_title( $action->post_excerpt );
482
 
483
  $default_values = $this->get_global_defaults();
486
  $action->post_content += $default_values;
487
 
488
  foreach ( $default_values as $k => $vals ) {
489
+ if ( is_array( $vals ) && ! empty( $vals ) ) {
490
  if ( 'event' == $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[ $k ] ) ) {
491
  continue;
492
  }
494
  }
495
  }
496
 
497
+ if ( ! is_array( $action->post_content['event'] ) ) {
498
+ $action->post_content['event'] = explode( ',', $action->post_content['event'] );
499
+ }
500
 
501
  return $action;
502
  }
517
  $post_ids = FrmDb::get_col( $wpdb->posts, $query, 'ID' );
518
 
519
  foreach ( $post_ids as $id ) {
520
+ wp_delete_post( $id );
521
  }
522
  self::clear_cache();
523
  }
538
  public function get_global_defaults() {
539
  $defaults = $this->get_defaults();
540
 
541
+ if ( ! isset( $defaults['event'] ) ) {
542
  $defaults['event'] = array( 'create' );
543
  }
544
 
545
+ if ( ! isset( $defaults['conditions'] ) ) {
546
  $defaults['conditions'] = array(
547
  'send_stop' => '',
548
  'any_all' => '',
562
  * Migrate settings from form->options into new action.
563
  */
564
  public function migrate_to_2( $form, $update = 'update' ) {
565
+ $action = $this->prepare_new( $form->id );
566
+ $form->options = maybe_unserialize( $form->options );
567
 
568
  // fill with existing options
569
  foreach ( $action->post_content as $name => $val ) {
573
  }
574
  }
575
 
576
+ $action = $this->migrate_values( $action, $form );
577
 
578
  // check if action already exists
579
  $post_id = get_posts( array(
583
  'numberposts' => 1,
584
  ) );
585
 
586
+ if ( empty( $post_id ) ) {
587
+ // create action now
588
+ $post_id = $this->save_settings( $action );
589
+ }
590
 
591
  if ( $post_id && 'update' == $update ) {
592
  global $wpdb;
593
+ $form->options = maybe_serialize( $form->options );
594
 
595
  // update form options
596
  $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => $form->options ), array( 'id' => $form->id ) );
622
 
623
  $observed_value = self::get_value_from_entry( $entry, $condition['hide_field'] );
624
 
625
+ $stop = FrmFieldsHelper::value_meets_condition( $observed_value, $condition['hide_field_cond'], $condition['hide_opt'] );
626
 
627
  if ( $notification['conditions']['send_stop'] == 'send' ) {
628
  $stop = $stop ? false : true;
633
 
634
  if ( $notification['conditions']['any_all'] == 'all' && ! empty( $met ) && isset( $met[0] ) && isset( $met[1] ) ) {
635
  $stop = ( $notification['conditions']['send_stop'] == 'send' );
636
+ } elseif ( $notification['conditions']['any_all'] == 'any' && $notification['conditions']['send_stop'] == 'send' && isset( $met[0] ) ) {
637
  $stop = false;
638
  }
639
 
classes/models/FrmMigrate.php CHANGED
@@ -7,8 +7,8 @@ class FrmMigrate {
7
  public $entry_metas;
8
 
9
  public function __construct() {
10
- if ( ! defined('ABSPATH') ) {
11
- die('You are not allowed to call this page directly.');
12
  }
13
 
14
  global $wpdb;
@@ -18,7 +18,7 @@ class FrmMigrate {
18
  $this->entry_metas = $wpdb->prefix . 'frm_item_metas';
19
  }
20
 
21
- public function upgrade( $old_db_version = false ) {
22
  do_action( 'frm_before_install' );
23
 
24
  global $wpdb, $frm_vars;
@@ -37,6 +37,8 @@ class FrmMigrate {
37
 
38
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
39
 
 
 
40
  $this->create_tables();
41
  $this->migrate_data( $old_db_version );
42
 
@@ -51,7 +53,7 @@ class FrmMigrate {
51
  }
52
  }
53
 
54
- do_action('frm_after_install');
55
 
56
  $frm_vars['doing_upgrade'] = false;
57
 
@@ -165,13 +167,18 @@ class FrmMigrate {
165
  global $wpdb;
166
  $wpdb->query( $q . $charset_collate );
167
  }
168
- unset($q);
169
  }
170
  }
171
 
172
  private function maybe_create_contact_form() {
173
  $template_id = FrmForm::get_id_by_key( 'contact' );
174
  if ( $template_id ) {
 
 
 
 
 
175
  $form_id = FrmForm::duplicate( $template_id, false, true );
176
  if ( $form_id ) {
177
  $values = array(
@@ -212,7 +219,7 @@ class FrmMigrate {
212
  public function uninstall() {
213
  if ( ! current_user_can( 'administrator' ) ) {
214
  $frm_settings = FrmAppHelper::get_settings();
215
- wp_die($frm_settings->admin_permission);
216
  }
217
 
218
  global $wpdb, $wp_roles;
@@ -222,8 +229,8 @@ class FrmMigrate {
222
  $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entries );
223
  $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entry_metas );
224
 
225
- delete_option('frm_options');
226
- delete_option('frm_db_version');
227
 
228
  //delete roles
229
  $frm_roles = FrmAppHelper::frm_capabilities();
@@ -231,11 +238,11 @@ class FrmMigrate {
231
  foreach ( $frm_roles as $frm_role => $frm_role_description ) {
232
  foreach ( $roles as $role => $details ) {
233
  $wp_roles->remove_cap( $role, $frm_role );
234
- unset($role, $details);
235
- }
236
- unset($frm_role, $frm_role_description);
237
  }
238
- unset($roles, $frm_roles);
239
 
240
  // delete actions, views, and styles
241
 
@@ -257,7 +264,7 @@ class FrmMigrate {
257
 
258
  $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_%' ) );
259
 
260
- do_action('frm_after_uninstall');
261
  return true;
262
  }
263
 
@@ -469,8 +476,8 @@ class FrmMigrate {
469
  continue;
470
  }
471
 
472
- // Format form options
473
- $form_options = maybe_unserialize($form->options);
474
 
475
  // Migrate settings to actions
476
  FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id );
@@ -480,7 +487,7 @@ class FrmMigrate {
480
  private function migrate_to_11() {
481
  global $wpdb;
482
 
483
- $forms = FrmDb::get_results( $this->forms, array(), 'id, options');
484
 
485
  $sending = __( 'Sending', 'formidable' );
486
  $img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif';
@@ -491,13 +498,13 @@ class FrmMigrate {
491
  <img class="frm_ajax_loading" src="$img" alt="$sending" style="visibility:hidden;" />
492
  </div>
493
  DEFAULT_HTML;
494
- unset($sending, $img);
495
 
496
- $new_default_html = FrmFormsHelper::get_default_html('submit');
497
  $draft_link = FrmFormsHelper::get_draft_link();
498
  foreach ( $forms as $form ) {
499
- $form->options = maybe_unserialize($form->options);
500
- if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) {
501
  continue;
502
  }
503
 
@@ -508,7 +515,7 @@ DEFAULT_HTML;
508
  $form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] );
509
  $wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
510
  }
511
- unset($form);
512
  }
513
  }
514
  }
7
  public $entry_metas;
8
 
9
  public function __construct() {
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ die( 'You are not allowed to call this page directly.' );
12
  }
13
 
14
  global $wpdb;
18
  $this->entry_metas = $wpdb->prefix . 'frm_item_metas';
19
  }
20
 
21
+ public function upgrade() {
22
  do_action( 'frm_before_install' );
23
 
24
  global $wpdb, $frm_vars;
37
 
38
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
39
 
40
+ $old_db_version = get_option( 'frm_db_version' );
41
+
42
  $this->create_tables();
43
  $this->migrate_data( $old_db_version );
44
 
53
  }
54
  }
55
 
56
+ do_action( 'frm_after_install' );
57
 
58
  $frm_vars['doing_upgrade'] = false;
59
 
167
  global $wpdb;
168
  $wpdb->query( $q . $charset_collate );
169
  }
170
+ unset( $q );
171
  }
172
  }
173
 
174
  private function maybe_create_contact_form() {
175
  $template_id = FrmForm::get_id_by_key( 'contact' );
176
  if ( $template_id ) {
177
+ $form_exists = FrmForm::get_id_by_key( 'contact-form' );
178
+ if ( $form_exists ) {
179
+ return;
180
+ }
181
+
182
  $form_id = FrmForm::duplicate( $template_id, false, true );
183
  if ( $form_id ) {
184
  $values = array(
219
  public function uninstall() {
220
  if ( ! current_user_can( 'administrator' ) ) {
221
  $frm_settings = FrmAppHelper::get_settings();
222
+ wp_die( $frm_settings->admin_permission );
223
  }
224
 
225
  global $wpdb, $wp_roles;
229
  $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entries );
230
  $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entry_metas );
231
 
232
+ delete_option( 'frm_options' );
233
+ delete_option( 'frm_db_version' );
234
 
235
  //delete roles
236
  $frm_roles = FrmAppHelper::frm_capabilities();
238
  foreach ( $frm_roles as $frm_role => $frm_role_description ) {
239
  foreach ( $roles as $role => $details ) {
240
  $wp_roles->remove_cap( $role, $frm_role );
241
+ unset( $role, $details );
242
+ }
243
+ unset( $frm_role, $frm_role_description );
244
  }
245
+ unset( $roles, $frm_roles );
246
 
247
  // delete actions, views, and styles
248
 
264
 
265
  $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_%' ) );
266
 
267
+ do_action( 'frm_after_uninstall' );
268
  return true;
269
  }
270
 
476
  continue;
477
  }
478
 
479
+ // Format form options
480
+ $form_options = maybe_unserialize( $form->options );
481
 
482
  // Migrate settings to actions
483
  FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id );
487
  private function migrate_to_11() {
488
  global $wpdb;
489
 
490
+ $forms = FrmDb::get_results( $this->forms, array(), 'id, options' );
491
 
492
  $sending = __( 'Sending', 'formidable' );
493
  $img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif';
498
  <img class="frm_ajax_loading" src="$img" alt="$sending" style="visibility:hidden;" />
499
  </div>
500
  DEFAULT_HTML;
501
+ unset( $sending, $img );
502
 
503
+ $new_default_html = FrmFormsHelper::get_default_html( 'submit' );
504
  $draft_link = FrmFormsHelper::get_draft_link();
505
  foreach ( $forms as $form ) {
506
+ $form->options = maybe_unserialize( $form->options );
507
+ if ( ! isset( $form->options['submit_html'] ) || empty( $form->options['submit_html'] ) ) {
508
  continue;
509
  }
510
 
515
  $form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] );
516
  $wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
517
  }
518
+ unset( $form );
519
  }
520
  }
521
  }
classes/models/FrmSettings.php CHANGED
@@ -33,19 +33,19 @@ class FrmSettings {
33
  public $no_ips;
34
 
35
  public function __construct() {
36
- if ( ! defined('ABSPATH') ) {
37
- die('You are not allowed to call this page directly.');
38
- }
39
 
40
- $settings = get_transient($this->option_name);
41
 
42
- if ( ! is_object($settings) ) {
43
- $settings = $this->translate_settings($settings);
44
- }
45
 
46
  foreach ( $settings as $setting_name => $setting ) {
47
  $this->{$setting_name} = $setting;
48
- unset($setting_name, $setting);
49
  }
50
 
51
  $this->set_default_options();
@@ -53,24 +53,24 @@ class FrmSettings {
53
 
54
  private function translate_settings( $settings ) {
55
  if ( $settings ) { //workaround for W3 total cache conflict
56
- return unserialize(serialize($settings));
57
  }
58
 
59
- $settings = get_option($this->option_name);
60
- if ( is_object($settings) ) {
61
- set_transient($this->option_name, $settings);
62
- return $settings;
63
- }
64
 
65
  // If unserializing didn't work
66
  if ( $settings ) { //workaround for W3 total cache conflict
67
- $settings = unserialize(serialize($settings));
68
  } else {
69
  $settings = $this;
70
  }
71
 
72
- update_option($this->option_name, $settings);
73
- set_transient($this->option_name, $settings);
74
 
75
  return $settings;
76
  }
@@ -94,7 +94,7 @@ class FrmSettings {
94
  'blank_msg' => __( 'This field cannot be blank.', 'formidable' ),
95
  'unique_msg' => __( 'This value must be unique.', 'formidable' ),
96
  'invalid_msg' => __( 'There was a problem with your submission. Errors are marked below.', 'formidable' ),
97
- 'failed_msg' => __( 'We\'re sorry. It looks like you\'ve already submitted that.', 'formidable' ),
98
  'submit_value' => __( 'Submit', 'formidable' ),
99
  'login_msg' => __( 'You do not have permission to view this form.', 'formidable' ),
100
  'admin_permission' => __( 'You do not have permission to do that', 'formidable' ),
@@ -107,8 +107,8 @@ class FrmSettings {
107
  private function set_default_options() {
108
  $this->fill_recaptcha_settings();
109
 
110
- if ( ! isset($this->load_style) ) {
111
- if ( ! isset($this->custom_style) ) {
112
  $this->custom_style = true;
113
  }
114
 
@@ -118,16 +118,16 @@ class FrmSettings {
118
  $this->fill_with_defaults();
119
 
120
  if ( is_multisite() && is_admin() ) {
121
- $mu_menu = get_site_option('frm_admin_menu_name');
122
- if ( $mu_menu && ! empty($mu_menu) ) {
123
  $this->menu = $mu_menu;
124
  $this->mu_menu = 1;
125
  }
126
  }
127
 
128
- $frm_roles = FrmAppHelper::frm_capabilities('pro');
129
- foreach ( $frm_roles as $frm_role => $frm_role_description ) {
130
- if ( ! isset($this->$frm_role) ) {
131
  $this->$frm_role = 'administrator';
132
  }
133
  }
@@ -139,7 +139,7 @@ class FrmSettings {
139
  foreach ( $settings as $setting => $default ) {
140
  if ( isset( $params[ 'frm_' . $setting ] ) ) {
141
  $this->{$setting} = $params[ 'frm_' . $setting ];
142
- } else if ( ! isset($this->{$setting}) ) {
143
  $this->{$setting} = $default;
144
  }
145
 
@@ -147,7 +147,7 @@ class FrmSettings {
147
  $this->{$setting} = $default;
148
  }
149
 
150
- unset($setting, $default);
151
  }
152
  }
153
 
@@ -155,23 +155,23 @@ class FrmSettings {
155
  $privkey = '';
156
  $re_lang = '';
157
 
158
- if ( ! isset($this->pubkey) ) {
159
- // get the options from the database
160
- $recaptcha_opt = is_multisite() ? get_site_option('recaptcha') : get_option('recaptcha');
161
- $this->pubkey = isset($recaptcha_opt['pubkey']) ? $recaptcha_opt['pubkey'] : '';
162
- $privkey = isset($recaptcha_opt['privkey']) ? $recaptcha_opt['privkey'] : $privkey;
163
- $re_lang = isset($recaptcha_opt['re_lang']) ? $recaptcha_opt['re_lang'] : $re_lang;
164
- }
165
 
166
- if ( ! isset($this->re_msg) || empty($this->re_msg) ) {
167
  $this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' );
168
  }
169
 
170
- if ( ! isset($this->privkey) ) {
171
  $this->privkey = $privkey;
172
  }
173
 
174
- if ( ! isset($this->re_lang) ) {
175
  $this->re_lang = $re_lang;
176
  }
177
 
@@ -185,16 +185,16 @@ class FrmSettings {
185
  }
186
 
187
  public function update( $params ) {
188
- $this->fill_with_defaults($params);
189
- $this->update_settings($params);
190
 
191
- if ( $this->mu_menu ) {
192
- update_site_option('frm_admin_menu_name', $this->menu);
193
- } else if ( current_user_can('administrator') ) {
194
- update_site_option('frm_admin_menu_name', false);
195
- }
196
 
197
- $this->update_roles($params);
198
 
199
  do_action( 'frm_update_settings', $params );
200
 
@@ -206,9 +206,9 @@ class FrmSettings {
206
  }
207
 
208
  private function update_settings( $params ) {
209
- $this->mu_menu = isset($params['frm_mu_menu']) ? $params['frm_mu_menu'] : 0;
210
 
211
- $this->pubkey = trim($params['frm_pubkey']);
212
  $this->privkey = $params['frm_privkey'];
213
  $this->re_type = $params['frm_re_type'];
214
  $this->re_lang = $params['frm_re_lang'];
@@ -216,7 +216,7 @@ class FrmSettings {
216
 
217
  $this->load_style = $params['frm_load_style'];
218
 
219
- $this->use_html = isset($params['frm_use_html']) ? $params['frm_use_html'] : 0;
220
  $this->jquery_css = isset( $params['frm_jquery_css'] ) ? absint( $params['frm_jquery_css'] ) : 0;
221
  $this->accordion_js = isset( $params['frm_accordion_js'] ) ? absint( $params['frm_accordion_js'] ) : 0;
222
  $this->fade_form = isset( $params['frm_fade_form'] ) ? absint( $params['frm_fade_form'] ) : 0;
@@ -238,7 +238,7 @@ class FrmSettings {
238
  }
239
 
240
  foreach ( $roles as $role => $details ) {
241
- if ( in_array($role, $this->$frm_role) ) {
242
  $wp_roles->add_cap( $role, $frm_role );
243
  } else {
244
  $wp_roles->remove_cap( $role, $frm_role );
@@ -248,13 +248,13 @@ class FrmSettings {
248
  }
249
 
250
  public function store() {
251
- // Save the posted value in the database
252
 
253
- update_option('frm_options', $this);
254
 
255
- delete_transient('frm_options');
256
- set_transient('frm_options', $this);
257
 
258
- do_action( 'frm_store_settings' );
259
- }
260
  }
33
  public $no_ips;
34
 
35
  public function __construct() {
36
+ if ( ! defined( 'ABSPATH' ) ) {
37
+ die( 'You are not allowed to call this page directly.' );
38
+ }
39
 
40
+ $settings = get_transient( $this->option_name );
41
 
42
+ if ( ! is_object( $settings ) ) {
43
+ $settings = $this->translate_settings( $settings );
44
+ }
45
 
46
  foreach ( $settings as $setting_name => $setting ) {
47
  $this->{$setting_name} = $setting;
48
+ unset( $setting_name, $setting );
49
  }
50
 
51
  $this->set_default_options();
53
 
54
  private function translate_settings( $settings ) {
55
  if ( $settings ) { //workaround for W3 total cache conflict
56
+ return unserialize( serialize( $settings ) );
57
  }
58
 
59
+ $settings = get_option( $this->option_name );
60
+ if ( is_object( $settings ) ) {
61
+ set_transient( $this->option_name, $settings );
62
+ return $settings;
63
+ }
64
 
65
  // If unserializing didn't work
66
  if ( $settings ) { //workaround for W3 total cache conflict
67
+ $settings = unserialize( serialize( $settings ) );
68
  } else {
69
  $settings = $this;
70
  }
71
 
72
+ update_option( $this->option_name, $settings );
73
+ set_transient( $this->option_name, $settings );
74
 
75
  return $settings;
76
  }
94
  'blank_msg' => __( 'This field cannot be blank.', 'formidable' ),
95
  'unique_msg' => __( 'This value must be unique.', 'formidable' ),
96
  'invalid_msg' => __( 'There was a problem with your submission. Errors are marked below.', 'formidable' ),
97
+ 'failed_msg' => __( 'We\'re sorry. It looks like you\'ve already submitted that.', 'formidable' ),
98
  'submit_value' => __( 'Submit', 'formidable' ),
99
  'login_msg' => __( 'You do not have permission to view this form.', 'formidable' ),
100
  'admin_permission' => __( 'You do not have permission to do that', 'formidable' ),
107
  private function set_default_options() {
108
  $this->fill_recaptcha_settings();
109
 
110
+ if ( ! isset( $this->load_style ) ) {
111
+ if ( ! isset( $this->custom_style ) ) {
112
  $this->custom_style = true;
113
  }
114
 
118
  $this->fill_with_defaults();
119
 
120
  if ( is_multisite() && is_admin() ) {
121
+ $mu_menu = get_site_option( 'frm_admin_menu_name' );
122
+ if ( $mu_menu && ! empty( $mu_menu ) ) {
123
  $this->menu = $mu_menu;
124
  $this->mu_menu = 1;
125
  }
126
  }
127
 
128
+ $frm_roles = FrmAppHelper::frm_capabilities( 'pro' );
129
+ foreach ( $frm_roles as $frm_role => $frm_role_description ) {
130
+ if ( ! isset( $this->$frm_role ) ) {
131
  $this->$frm_role = 'administrator';
132
  }
133
  }
139
  foreach ( $settings as $setting => $default ) {
140
  if ( isset( $params[ 'frm_' . $setting ] ) ) {
141
  $this->{$setting} = $params[ 'frm_' . $setting ];
142
+ } elseif ( ! isset( $this->{$setting} ) ) {
143
  $this->{$setting} = $default;
144
  }
145
 
147
  $this->{$setting} = $default;
148
  }
149
 
150
+ unset( $setting, $default );
151
  }
152
  }
153
 
155
  $privkey = '';
156
  $re_lang = '';
157
 
158
+ if ( ! isset( $this->pubkey ) ) {
159
+ // get the options from the database
160
+ $recaptcha_opt = is_multisite() ? get_site_option( 'recaptcha' ) : get_option( 'recaptcha' );
161
+ $this->pubkey = isset( $recaptcha_opt['pubkey'] ) ? $recaptcha_opt['pubkey'] : '';
162
+ $privkey = isset( $recaptcha_opt['privkey'] ) ? $recaptcha_opt['privkey'] : $privkey;
163
+ $re_lang = isset( $recaptcha_opt['re_lang'] ) ? $recaptcha_opt['re_lang'] : $re_lang;
164
+ }
165
 
166
+ if ( ! isset( $this->re_msg ) || empty( $this->re_msg ) ) {
167
  $this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' );
168
  }
169
 
170
+ if ( ! isset( $this->privkey ) ) {
171
  $this->privkey = $privkey;
172
  }
173
 
174
+ if ( ! isset( $this->re_lang ) ) {
175
  $this->re_lang = $re_lang;
176
  }
177
 
185
  }
186
 
187
  public function update( $params ) {
188
+ $this->fill_with_defaults( $params );
189
+ $this->update_settings( $params );
190
 
191
+ if ( $this->mu_menu ) {
192
+ update_site_option( 'frm_admin_menu_name', $this->menu );
193
+ } elseif ( current_user_can( 'administrator' ) ) {
194
+ update_site_option( 'frm_admin_menu_name', false );
195
+ }
196
 
197
+ $this->update_roles( $params );
198
 
199
  do_action( 'frm_update_settings', $params );
200
 
206
  }
207
 
208
  private function update_settings( $params ) {
209
+ $this->mu_menu = isset( $params['frm_mu_menu'] ) ? $params['frm_mu_menu'] : 0;
210
 
211
+ $this->pubkey = trim( $params['frm_pubkey'] );
212
  $this->privkey = $params['frm_privkey'];
213
  $this->re_type = $params['frm_re_type'];
214
  $this->re_lang = $params['frm_re_lang'];
216
 
217
  $this->load_style = $params['frm_load_style'];
218
 
219
+ $this->use_html = isset( $params['frm_use_html'] ) ? $params['frm_use_html'] : 0;
220
  $this->jquery_css = isset( $params['frm_jquery_css'] ) ? absint( $params['frm_jquery_css'] ) : 0;
221
  $this->accordion_js = isset( $params['frm_accordion_js'] ) ? absint( $params['frm_accordion_js'] ) : 0;
222
  $this->fade_form = isset( $params['frm_fade_form'] ) ? absint( $params['frm_fade_form'] ) : 0;
238
  }
239
 
240
  foreach ( $roles as $role => $details ) {
241
+ if ( in_array( $role, $this->$frm_role ) ) {
242
  $wp_roles->add_cap( $role, $frm_role );
243
  } else {
244
  $wp_roles->remove_cap( $role, $frm_role );
248
  }
249
 
250
  public function store() {
251
+ // Save the posted value in the database
252
 
253
+ update_option( 'frm_options', $this );
254
 
255
+ delete_transient( 'frm_options' );
256
+ set_transient( 'frm_options', $this );
257
 
258
+ do_action( 'frm_store_settings' );
259
+ }
260
  }
classes/models/FrmStyle.php CHANGED
@@ -15,7 +15,7 @@ class FrmStyle {
15
 
16
  $max_slug_value = 2147483647;
17
  $min_slug_value = 37; // we want to have at least 2 characters in the slug
18
- $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
19
 
20
  $style = array(
21
  'post_type' => FrmStylesController::$post_type,
@@ -41,7 +41,7 @@ class FrmStyle {
41
  public function update( $id = 'default' ) {
42
  $all_instances = $this->get_all();
43
 
44
- if ( empty($id) ) {
45
  $new_style = (array) $this->get_new();
46
  $all_instances[] = $new_style;
47
  }
@@ -49,15 +49,15 @@ class FrmStyle {
49
  $action_ids = array();
50
 
51
  foreach ( $all_instances as $number => $new_instance ) {
52
- $new_instance = stripslashes_deep( (array) $new_instance);
53
  $this->id = $new_instance['ID'];
54
- if ( $id != $this->id || ! $_POST || ! isset($_POST['frm_style_setting']) ) {
55
  $all_instances[ $number ] = $new_instance;
56
 
57
- if ( $new_instance['menu_order'] && $_POST && empty($_POST['prev_menu_order']) && isset($_POST['frm_style_setting']['menu_order']) ) {
58
  // this style was set to default, so remove default setting on previous default style
59
  $new_instance['menu_order'] = 0;
60
- $action_ids[] = $this->save($new_instance);
61
  }
62
 
63
  // don't continue if not saving this style
@@ -70,7 +70,7 @@ class FrmStyle {
70
  $new_instance['post_status'] = 'publish';
71
  $new_instance['menu_order'] = isset( $_POST['frm_style_setting']['menu_order'] ) ? absint( $_POST['frm_style_setting']['menu_order'] ) : 0;
72
 
73
- if ( empty($id) ) {
74
  $new_instance['post_name'] = $new_instance['post_title'];
75
  }
76
 
@@ -81,8 +81,7 @@ class FrmStyle {
81
  $new_instance['post_content'][ $setting ] = $default;
82
  }
83
 
84
- if ( strpos( $setting, 'color' ) !== false || in_array( $setting, array( 'error_bg', 'error_border', 'error_text' ) ) ) {
85
- //if is a color
86
  $new_instance['post_content'][ $setting ] = str_replace( '#', '', $new_instance['post_content'][ $setting ] );
87
  } else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][ $setting ] ) ) {
88
  $new_instance['post_content'][ $setting ] = 0;
@@ -93,7 +92,7 @@ class FrmStyle {
93
 
94
  $all_instances[ $number ] = $new_instance;
95
 
96
- $action_ids[] = $this->save($new_instance);
97
 
98
  }
99
 
@@ -102,14 +101,31 @@ class FrmStyle {
102
  return $action_ids;
103
  }
104
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  /**
106
  * Create static css file
107
  */
108
  public function save_settings() {
109
  $filename = FrmAppHelper::plugin_path() . '/css/custom_theme.css.php';
110
- update_option( 'frm_last_style_update', date('njGi') );
111
 
112
- if ( ! is_file($filename) ) {
113
  return;
114
  }
115
 
@@ -156,7 +172,7 @@ class FrmStyle {
156
  }
157
 
158
  public function destroy( $id ) {
159
- return wp_delete_post($id);
160
  }
161
 
162
  public function get_one() {
@@ -170,19 +186,19 @@ class FrmStyle {
170
  return $style;
171
  }
172
 
173
- $style = get_post($this->id);
174
 
175
  if ( ! $style ) {
176
  return $style;
177
  }
178
 
179
- $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
180
 
181
  $default_values = $this->get_defaults();
182
 
183
- // fill default values
184
- $style->post_content = $this->override_defaults($style->post_content);
185
- $style->post_content = wp_parse_args( $style->post_content, $default_values);
186
 
187
  return $style;
188
  }
@@ -198,20 +214,20 @@ class FrmStyle {
198
 
199
  $temp_styles = FrmDb::check_cache( serialize( $post_atts ), 'frm_styles', $post_atts, 'get_posts' );
200
 
201
- if ( empty($temp_styles) ) {
202
  global $wpdb;
203
  // make sure there wasn't a conflict with the query
204
  $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->posts . ' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish' );
205
- $temp_styles = FrmDb::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results');
206
 
207
- if ( empty($temp_styles) ) {
208
  // create a new style if there are none
209
  $new = $this->get_new();
210
  $new->post_title = __( 'Formidable Style', 'formidable' );
211
  $new->post_name = $new->post_title;
212
  $new->menu_order = 1;
213
- $new = $this->save( (array) $new);
214
- $this->update('default');
215
 
216
  $post_atts['include'] = $new;
217
 
@@ -235,17 +251,17 @@ class FrmStyle {
235
  }
236
  }
237
 
238
- $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
239
 
240
- // fill default values
241
- $style->post_content = $this->override_defaults($style->post_content);
242
- $style->post_content = wp_parse_args( $style->post_content, $default_values);
243
 
244
  $styles[ $style->ID ] = $style;
245
  }
246
 
247
  if ( ! $default_style ) {
248
- $default_style = reset($styles);
249
  $styles[ $default_style->ID ]->menu_order = 1;
250
  }
251
 
@@ -253,7 +269,7 @@ class FrmStyle {
253
  }
254
 
255
  public function get_default_style( $styles = null ) {
256
- if ( ! isset($styles) ) {
257
  $styles = $this->get_all( 'menu_order', 'DESC', 1 );
258
  }
259
 
@@ -265,24 +281,24 @@ class FrmStyle {
265
  }
266
 
267
  public function override_defaults( $settings ) {
268
- if ( ! is_array($settings) ) {
269
  return $settings;
270
  }
271
 
272
  $settings['line_height'] = ( ! isset( $settings['field_height'] ) || $settings['field_height'] == '' || $settings['field_height'] == 'auto' ) ? 'normal' : $settings['field_height'];
273
 
274
- if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) {
275
  $settings['form_desc_size'] = $settings['description_font_size'];
276
  $settings['form_desc_color'] = $settings['description_color'];
277
  $settings['title_color'] = $settings['label_color'];
278
  }
279
 
280
- if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) {
281
  $settings['section_color'] = $settings['label_color'];
282
  $settings['section_border_color'] = $settings['border_color'];
283
  }
284
 
285
- if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) {
286
  $settings['submit_hover_bg_color'] = $settings['submit_bg_color'];
287
  $settings['submit_hover_color'] = $settings['submit_text_color'];
288
  $settings['submit_hover_border_color'] = $settings['submit_border_color'];
@@ -292,11 +308,11 @@ class FrmStyle {
292
  $settings['submit_active_border_color'] = $settings['submit_border_color'];
293
  }
294
 
295
- return $settings;
296
  }
297
 
298
  public function get_defaults() {
299
- return array(
300
  'theme_css' => 'ui-lightness',
301
  'theme_name' => 'UI Lightness',
302
 
@@ -429,7 +445,7 @@ class FrmStyle {
429
  'progress_size' => '30px',
430
 
431
  'custom_css' => '',
432
- );
433
  }
434
 
435
  public function get_field_name( $field_name, $post_field = 'post_content' ) {
15
 
16
  $max_slug_value = 2147483647;
17
  $min_slug_value = 37; // we want to have at least 2 characters in the slug
18
+ $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
19
 
20
  $style = array(
21
  'post_type' => FrmStylesController::$post_type,
41
  public function update( $id = 'default' ) {
42
  $all_instances = $this->get_all();
43
 
44
+ if ( empty( $id ) ) {
45
  $new_style = (array) $this->get_new();
46
  $all_instances[] = $new_style;
47
  }
49
  $action_ids = array();
50
 
51
  foreach ( $all_instances as $number => $new_instance ) {
52
+ $new_instance = stripslashes_deep( (array) $new_instance );
53
  $this->id = $new_instance['ID'];
54
+ if ( $id != $this->id || ! $_POST || ! isset( $_POST['frm_style_setting'] ) ) {
55
  $all_instances[ $number ] = $new_instance;
56
 
57
+ if ( $new_instance['menu_order'] && $_POST && empty( $_POST['prev_menu_order'] ) && isset( $_POST['frm_style_setting']['menu_order'] ) ) {
58
  // this style was set to default, so remove default setting on previous default style
59
  $new_instance['menu_order'] = 0;
60
+ $action_ids[] = $this->save( $new_instance );
61
  }
62
 
63
  // don't continue if not saving this style
70
  $new_instance['post_status'] = 'publish';
71
  $new_instance['menu_order'] = isset( $_POST['frm_style_setting']['menu_order'] ) ? absint( $_POST['frm_style_setting']['menu_order'] ) : 0;
72
 
73
+ if ( empty( $id ) ) {
74
  $new_instance['post_name'] = $new_instance['post_title'];
75
  }
76
 
81
  $new_instance['post_content'][ $setting ] = $default;
82
  }
83
 
84
+ if ( $this->is_color( $setting ) ) {
 
85
  $new_instance['post_content'][ $setting ] = str_replace( '#', '', $new_instance['post_content'][ $setting ] );
86
  } else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][ $setting ] ) ) {
87
  $new_instance['post_content'][ $setting ] = 0;
92
 
93
  $all_instances[ $number ] = $new_instance;
94
 
95
+ $action_ids[] = $this->save( $new_instance );
96
 
97
  }
98
 
101
  return $action_ids;
102
  }
103
 
104
+ /**
105
+ * @since 3.01.01
106
+ */
107
+ private function is_color( $setting ) {
108
+ $extra_colors = array( 'error_bg', 'error_border', 'error_text' );
109
+ return strpos( $setting, 'color' ) !== false || in_array( $setting, $extra_colors );
110
+ }
111
+
112
+ /**
113
+ * @since 3.01.01
114
+ */
115
+ public function get_color_settings() {
116
+ $defaults = $this->get_defaults();
117
+ $settings = array_keys( $defaults );
118
+ return array_filter( $settings, array( $this, 'is_color' ) );
119
+ }
120
+
121
  /**
122
  * Create static css file
123
  */
124
  public function save_settings() {
125
  $filename = FrmAppHelper::plugin_path() . '/css/custom_theme.css.php';
126
+ update_option( 'frm_last_style_update', date( 'njGi' ) );
127
 
128
+ if ( ! is_file( $filename ) ) {
129
  return;
130
  }
131
 
172
  }
173
 
174
  public function destroy( $id ) {
175
+ return wp_delete_post( $id );
176
  }
177
 
178
  public function get_one() {
186
  return $style;
187
  }
188
 
189
+ $style = get_post( $this->id );
190
 
191
  if ( ! $style ) {
192
  return $style;
193
  }
194
 
195
+ $style->post_content = FrmAppHelper::maybe_json_decode( $style->post_content );
196
 
197
  $default_values = $this->get_defaults();
198
 
199
+ // fill default values
200
+ $style->post_content = $this->override_defaults( $style->post_content );
201
+ $style->post_content = wp_parse_args( $style->post_content, $default_values );
202
 
203
  return $style;
204
  }
214
 
215
  $temp_styles = FrmDb::check_cache( serialize( $post_atts ), 'frm_styles', $post_atts, 'get_posts' );
216
 
217
+ if ( empty( $temp_styles ) ) {
218
  global $wpdb;
219
  // make sure there wasn't a conflict with the query
220
  $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->posts . ' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish' );
221
+ $temp_styles = FrmDb::check_cache( 'frm_backup_style_check', 'frm_styles', $query, 'get_results' );
222
 
223
+ if ( empty( $temp_styles ) ) {
224
  // create a new style if there are none
225
  $new = $this->get_new();
226
  $new->post_title = __( 'Formidable Style', 'formidable' );
227
  $new->post_name = $new->post_title;
228
  $new->menu_order = 1;
229
+ $new = $this->save( (array) $new );
230
+ $this->update( 'default' );
231
 
232
  $post_atts['include'] = $new;
233
 
251
  }
252
  }
253
 
254
+ $style->post_content = FrmAppHelper::maybe_json_decode( $style->post_content );
255
 
256
+ // fill default values
257
+ $style->post_content = $this->override_defaults( $style->post_content );
258
+ $style->post_content = wp_parse_args( $style->post_content, $default_values );
259
 
260
  $styles[ $style->ID ] = $style;
261
  }
262
 
263
  if ( ! $default_style ) {
264
+ $default_style = reset( $styles );
265
  $styles[ $default_style->ID ]->menu_order = 1;
266
  }
267
 
269
  }
270
 
271
  public function get_default_style( $styles = null ) {
272
+ if ( ! isset( $styles ) ) {
273
  $styles = $this->get_all( 'menu_order', 'DESC', 1 );
274
  }
275
 
281
  }
282
 
283
  public function override_defaults( $settings ) {
284
+ if ( ! is_array( $settings ) ) {
285
  return $settings;
286
  }
287
 
288
  $settings['line_height'] = ( ! isset( $settings['field_height'] ) || $settings['field_height'] == '' || $settings['field_height'] == 'auto' ) ? 'normal' : $settings['field_height'];
289
 
290
+ if ( ! isset( $settings['form_desc_size'] ) && isset( $settings['description_font_size'] ) ) {
291
  $settings['form_desc_size'] = $settings['description_font_size'];
292
  $settings['form_desc_color'] = $settings['description_color'];
293
  $settings['title_color'] = $settings['label_color'];
294
  }
295
 
296
+ if ( ! isset( $settings['section_color'] ) && isset( $settings['label_color'] ) ) {
297
  $settings['section_color'] = $settings['label_color'];
298
  $settings['section_border_color'] = $settings['border_color'];
299
  }
300
 
301
+ if ( ! isset( $settings['submit_hover_bg_color'] ) && isset( $settings['submit_bg_color'] ) ) {
302
  $settings['submit_hover_bg_color'] = $settings['submit_bg_color'];
303
  $settings['submit_hover_color'] = $settings['submit_text_color'];
304
  $settings['submit_hover_border_color'] = $settings['submit_border_color'];
308
  $settings['submit_active_border_color'] = $settings['submit_border_color'];
309
  }
310
 
311
+ return apply_filters( 'frm_override_default_styles', $settings );
312
  }
313
 
314
  public function get_defaults() {
315
+ return apply_filters( 'frm_default_style_settings', array(
316
  'theme_css' => 'ui-lightness',
317
  'theme_name' => 'UI Lightness',
318
 
445
  'progress_size' => '30px',
446
 
447
  'custom_css' => '',
448
+ ) );
449
  }
450
 
451
  public function get_field_name( $field_name, $post_field = 'post_content' ) {
classes/models/fields/FrmFieldCheckbox.php CHANGED
@@ -41,7 +41,7 @@ class FrmFieldCheckbox extends FrmFieldType {
41
  }
42
 
43
  protected function extra_field_opts() {
44
- $form_id = $this->get_field_column('form_id');
45
  return array(
46
  'align' => FrmStylesController::get_style_val( 'check_align', ( empty( $form_id ) ? 'default' : $form_id ) ),
47
  );
41
  }
42
 
43
  protected function extra_field_opts() {
44
+ $form_id = $this->get_field_column( 'form_id' );
45
  return array(
46
  'align' => FrmStylesController::get_style_val( 'check_align', ( empty( $form_id ) ? 'default' : $form_id ) ),
47
  );
classes/models/fields/FrmFieldRadio.php CHANGED
@@ -32,7 +32,7 @@ class FrmFieldRadio extends FrmFieldType {
32
  }
33
 
34
  protected function extra_field_opts() {
35
- $form_id = $this->get_field_column('form_id');
36
  return array(
37
  'align' => FrmStylesController::get_style_val( 'radio_align', ( empty( $form_id ) ? 'default' : $form_id ) ),
38
  );
32
  }
33
 
34
  protected function extra_field_opts() {
35
+ $form_id = $this->get_field_column( 'form_id' );
36
  return array(
37
  'align' => FrmStylesController::get_style_val( 'radio_align', ( empty( $form_id ) ? 'default' : $form_id ) ),
38
  );
classes/models/fields/FrmFieldTextarea.php CHANGED
@@ -32,7 +32,7 @@ class FrmFieldTextarea extends FrmFieldType {
32
  $size_html = $size ? ' style="width:' . esc_attr( $size . ( is_numeric( $size ) ? 'px' : '' ) ) . '";' : '';
33
 
34
  $max = FrmField::get_option( $this->field, 'max' );
35
- $default_value = FrmAppHelper::esc_textarea( force_balance_tags( $this->get_field_column('default_value') ) );
36
 
37
  echo '<textarea name="' . esc_attr( $this->html_name( $name ) ) . '" ' .
38
  $size_html . ' rows="' . esc_attr( $max ) . '" ' .
32
  $size_html = $size ? ' style="width:' . esc_attr( $size . ( is_numeric( $size ) ? 'px' : '' ) ) . '";' : '';
33
 
34
  $max = FrmField::get_option( $this->field, 'max' );
35
+ $default_value = FrmAppHelper::esc_textarea( force_balance_tags( $this->get_field_column( 'default_value' ) ) );
36
 
37
  echo '<textarea name="' . esc_attr( $this->html_name( $name ) ) . '" ' .
38
  $size_html . ' rows="' . esc_attr( $max ) . '" ' .
classes/models/fields/FrmFieldType.php CHANGED
@@ -82,7 +82,7 @@ abstract class FrmFieldType {
82
  */
83
  protected function set_type( $type ) {
84
  if ( empty( $this->type ) ) {
85
- $this->type = $this->get_field_column('type');
86
  if ( empty( $this->type ) && ! empty( $type ) ) {
87
  $this->type = $type;
88
  }
@@ -207,16 +207,16 @@ DEFAULT_HTML;
207
  }
208
 
209
  protected function builder_text_field( $name = '' ) {
210
- return '<input type="text" name="' . esc_attr( $this->html_name( $name ) ) . '" id="' . esc_attr( $this->html_id() ) . '" value="' . esc_attr( $this->get_field_column('default_value') ) . '" class="dyn_default_value" />';
211
  }
212
 
213
  protected function html_name( $name = '' ) {
214
  $prefix = empty( $name ) ? 'item_meta' : $name;
215
- return $prefix . '[' . $this->get_field_column('id') . ']';
216
  }
217
 
218
  protected function html_id( $plus = '' ) {
219
- return apply_filters( 'frm_field_get_html_id', 'field_' . $this->get_field_column('field_key') . $plus, $this->field );
220
  }
221
 
222
  public function display_field_settings() {
@@ -274,6 +274,13 @@ DEFAULT_HTML;
274
  return $classes;
275
  }
276
 
 
 
 
 
 
 
 
277
  /** New field **/
278
 
279
  public function get_new_field_defaults() {
@@ -307,7 +314,7 @@ DEFAULT_HTML;
307
  }
308
 
309
  protected function default_invalid_msg() {
310
- $field_name = $this->get_field_column('name');
311
  if ( $field_name == '' ) {
312
  $invalid = __( 'This field is invalid', 'formidable' );
313
  } else {
@@ -581,7 +588,7 @@ DEFAULT_HTML;
581
  * @since 3.0
582
  */
583
  protected function get_select_box( $values ) {
584
- $options = $this->get_field_column('options');
585
  $selected = $values['field_value'];
586
 
587
  if ( isset( $values['combo_name'] ) ) {
@@ -640,8 +647,8 @@ DEFAULT_HTML;
640
 
641
  protected function fill_display_field_values( $args = array() ) {
642
  $defaults = array(
643
- 'field_name' => 'item_meta[' . $this->get_field_column('id') . ']',
644
- 'field_id' => $this->get_field_column('id'),
645
  'field_plus_id' => '',
646
  'section_id' => '',
647
  );
@@ -669,7 +676,7 @@ DEFAULT_HTML;
669
  * @since 3.0
670
  */
671
  protected function add_aria_description( $args, &$input_html ) {
672
- if ( $this->get_field_column('description') != '' ) {
673
  $desc_id = 'frm_desc_' . esc_attr( $args['html_id'] );
674
  $input_html .= ' aria-describedby="' . esc_attr( $desc_id ) . '"';
675
  }
@@ -686,7 +693,7 @@ DEFAULT_HTML;
686
  public function is_not_unique( $value, $entry_id ) {
687
  $exists = false;
688
  if ( FrmAppHelper::pro_is_installed() ) {
689
- $exists = FrmProEntryMetaHelper::value_exists( $this->get_field_column('id'), $value, $entry_id );
690
  }
691
  return $exists;
692
  }
82
  */
83
  protected function set_type( $type ) {
84
  if ( empty( $this->type ) ) {
85
+ $this->type = $this->get_field_column( 'type' );
86
  if ( empty( $this->type ) && ! empty( $type ) ) {
87
  $this->type = $type;
88
  }
207
  }
208
 
209
  protected function builder_text_field( $name = '' ) {
210
+ return '<input type="text" name="' . esc_attr( $this->html_name( $name ) ) . '" id="' . esc_attr( $this->html_id() ) . '" value="' . esc_attr( $this->get_field_column( 'default_value' ) ) . '" class="dyn_default_value" />';
211
  }
212
 
213
  protected function html_name( $name = '' ) {
214
  $prefix = empty( $name ) ? 'item_meta' : $name;
215
+ return $prefix . '[' . $this->get_field_column( 'id' ) . ']';
216
  }
217
 
218
  protected function html_id( $plus = '' ) {
219
+ return apply_filters( 'frm_field_get_html_id', 'field_' . $this->get_field_column( 'field_key' ) . $plus, $this->field );
220
  }
221
 
222
  public function display_field_settings() {
274
  return $classes;
275
  }
276
 
277
+ /**
278
+ * @since 3.01.01
279
+ */
280
+ public function show_options( $field, $display, $values ) {
281
+ do_action( 'frm_' . $field['type'] . '_field_options_form', $field, $display, $values );
282
+ }
283
+
284
  /** New field **/
285
 
286
  public function get_new_field_defaults() {
314
  }
315
 
316
  protected function default_invalid_msg() {
317
+ $field_name = $this->get_field_column( 'name' );
318
  if ( $field_name == '' ) {
319
  $invalid = __( 'This field is invalid', 'formidable' );
320
  } else {
588
  * @since 3.0
589
  */
590
  protected function get_select_box( $values ) {
591
+ $options = $this->get_field_column( 'options' );
592
  $selected = $values['field_value'];
593
 
594
  if ( isset( $values['combo_name'] ) ) {
647
 
648
  protected function fill_display_field_values( $args = array() ) {
649
  $defaults = array(
650
+ 'field_name' => 'item_meta[' . $this->get_field_column( 'id' ) . ']',
651
+ 'field_id' => $this->get_field_column( 'id' ),
652
  'field_plus_id' => '',
653
  'section_id' => '',
654
  );
676
  * @since 3.0
677
  */
678
  protected function add_aria_description( $args, &$input_html ) {
679
+ if ( $this->get_field_column( 'description' ) != '' ) {
680
  $desc_id = 'frm_desc_' . esc_attr( $args['html_id'] );
681
  $input_html .= ' aria-describedby="' . esc_attr( $desc_id ) . '"';
682
  }
693
  public function is_not_unique( $value, $entry_id ) {
694
  $exists = false;
695
  if ( FrmAppHelper::pro_is_installed() ) {
696
+ $exists = FrmProEntryMetaHelper::value_exists( $this->get_field_column( 'id' ), $value, $entry_id );
697
  }
698
  return $exists;
699
  }
classes/views/addons/upgrade_to_pro.php CHANGED
@@ -59,9 +59,9 @@
59
  <tr>
60
  <th>Included AddOns</th>
61
  <td>None</td>
62
- <td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidableforms.com/pricing/#addon-lists') ) ?>" target="_blank">Premium Addons</a></td>
63
- <td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidableforms.com/pricing/#addon-lists') ) ?>" target="_blank">Advanced Addons</a></td>
64
- <td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidableforms.com/pricing/#addon-lists') ) ?>" target="_blank">Enterprise Addons</a></td>
65
  </tr>
66
  </tbody>
67
  </table>
59
  <tr>
60
  <th>Included AddOns</th>
61
  <td>None</td>
62
+ <td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/pricing/#addon-lists' ) ); ?>" target="_blank">Premium Addons</a></td>
63
+ <td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/pricing/#addon-lists' ) ); ?>" target="_blank">Advanced Addons</a></td>
64
+ <td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/pricing/#addon-lists' ) ); ?>" target="_blank">Enterprise Addons</a></td>
65
  </tr>
66
  </tbody>
67
  </table>
classes/views/frm-entries/_sidebar-shared-pub.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- if ( ! isset( $entry) ) {
3
  $entry = $record;
4
  } ?>
5
 
@@ -25,4 +25,4 @@ if ( ! isset( $entry) ) {
25
  </div>
26
  <?php } ?>
27
 
28
- <?php do_action('frm_entry_shared_sidebar', $entry); ?>
1
  <?php
2
+ if ( ! isset( $entry ) ) {
3
  $entry = $record;
4
  } ?>
5
 
25
  </div>
26
  <?php } ?>
27
 
28
+ <?php do_action( 'frm_entry_shared_sidebar', $entry ); ?>
classes/views/frm-entries/errors.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- if ( isset($include_extra_container) ) { ?>
3
  <div class="<?php echo esc_attr( $include_extra_container ) ?>" id="frm_form_<?php echo esc_attr( $form->id ) ?>_container">
4
  <?php
5
  }
@@ -16,7 +16,7 @@ if ( isset( $message ) && $message != '' ) {
16
  }
17
  }
18
 
19
- if ( isset($errors) && is_array( $errors ) && ! empty( $errors ) ) {
20
 
21
  if ( isset( $form ) && is_object( $form ) ) {
22
  FrmFormsHelper::get_scroll_js( $form->id );
@@ -26,8 +26,8 @@ if ( isset($errors) && is_array( $errors ) && ! empty( $errors ) ) {
26
  <?php
27
  $img = '';
28
  if ( ! FrmAppHelper::is_admin() ) {
29
- $img = apply_filters('frm_error_icon', $img);
30
- if ( $img && ! empty($img) ) {
31
  echo '<img src="' . esc_url( $img ) . '" alt="" />';
32
  }
33
  }
1
  <?php
2
+ if ( isset( $include_extra_container ) ) { ?>
3
  <div class="<?php echo esc_attr( $include_extra_container ) ?>" id="frm_form_<?php echo esc_attr( $form->id ) ?>_container">
4
  <?php
5
  }
16
  }
17
  }
18
 
19
+ if ( isset( $errors ) && is_array( $errors ) && ! empty( $errors ) ) {
20
 
21
  if ( isset( $form ) && is_object( $form ) ) {
22
  FrmFormsHelper::get_scroll_js( $form->id );
26
  <?php
27
  $img = '';
28
  if ( ! FrmAppHelper::is_admin() ) {
29
+ $img = apply_filters( 'frm_error_icon', $img );
30
+ if ( $img && ! empty( $img ) ) {
31
  echo '<img src="' . esc_url( $img ) . '" alt="" />';
32
  }
33
  }
classes/views/frm-entries/form.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
- if ( empty($values) || ! isset($values['fields']) || empty($values['fields']) ) { ?>
3
- <div class="frm_forms <?php echo FrmFormsHelper::get_form_style_class($form); ?>" id="frm_form_<?php echo esc_attr( $form->id ) ?>_container">
4
  <div class="frm_error_style"><strong><?php esc_html_e( 'Oops!', 'formidable' ) ?></strong> <?php printf( esc_html__( 'You did not add any fields to your form. %1$sGo back%2$s and add some.', 'formidable' ), '<a href="' . esc_url( admin_url( '?page=formidable&frm_action=edit&id=' . $form->id ) ) . '">', '</a>' ) ?>
5
  </div>
6
  </div>
@@ -19,15 +19,15 @@ $frm_hide_fields = FrmAppHelper::get_post_param( 'frm_hide_fields_' . $form->id,
19
  <fieldset>
20
  <?php echo FrmFormsHelper::replace_shortcodes( $values['before_html'], $form, $title, $description ); ?>
21
  <div <?php echo wp_strip_all_tags( apply_filters( 'frm_fields_container_class', 'class="frm_fields_container"' ) ); ?>>
22
- <?php do_action( 'frm_after_title', compact('form') ) ?>
23
- <input type="hidden" name="frm_action" value="<?php echo esc_attr($form_action) ?>" />
24
- <input type="hidden" name="form_id" value="<?php echo esc_attr($form->id) ?>" />
25
- <input type="hidden" name="frm_hide_fields_<?php echo esc_attr( $form->id ) ?>" id="frm_hide_fields_<?php echo esc_attr( $form->id ) ?>" value="<?php echo esc_attr($frm_hide_fields) ?>" />
26
- <input type="hidden" name="form_key" value="<?php echo esc_attr($form->form_key) ?>" />
27
  <input type="hidden" name="item_meta[0]" value="" />
28
  <?php wp_nonce_field( 'frm_submit_entry_nonce', 'frm_submit_entry_' . $form->id ); ?>
29
  <label for="frm_verify_<?php echo esc_attr( $form->id ) ?>" class="frm_screen_reader frm_hidden"><?php esc_html_e( 'If you are human, leave this field blank.', 'formidable' ) ?></label>
30
- <input type="text" class="frm_hidden frm_verify" id="frm_verify_<?php echo esc_attr( $form->id ) ?>" name="frm_verify" value="<?php echo esc_attr( FrmAppHelper::get_param('frm_verify', '', 'get', 'wp_kses_post' ) ) ?>" <?php FrmFormsHelper::maybe_hide_inline() ?> />
31
  <?php if ( isset( $id ) ) { ?>
32
  <input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
33
  <?php } ?>
@@ -41,14 +41,14 @@ if ( FrmAppHelper::is_admin() ) {
41
  ?>
42
  <div class="frm_form_field form-field">
43
  <label class="frm_primary_label"><?php esc_html_e( 'Entry Key', 'formidable' ) ?></label>
44
- <input type="text" name="item_key" value="<?php echo esc_attr($values['item_key']) ?>" />
45
  </div>
46
  <?php } else { ?>
47
- <input type="hidden" name="item_key" value="<?php echo esc_attr($values['item_key']) ?>" />
48
  <?php
49
  }
50
 
51
- do_action('frm_entry_form', $form, $form_action, $errors);
52
 
53
  global $frm_vars;
54
  // close open section div
@@ -58,12 +58,12 @@ if ( isset( $frm_vars['div'] ) && $frm_vars['div'] ) {
58
  }
59
 
60
  // close open collapsible toggle div
61
- if ( isset($frm_vars['collapse_div']) && $frm_vars['collapse_div'] ) {
62
  echo "</div>\n";
63
- unset($frm_vars['collapse_div']);
64
  }
65
 
66
- echo FrmFormsHelper::replace_shortcodes($values['after_html'], $form);
67
 
68
  if ( FrmForm::show_submit( $form ) ) {
69
 
@@ -76,6 +76,6 @@ if ( FrmForm::show_submit( $form ) ) {
76
  </div>
77
  </fieldset>
78
  </div>
79
- <?php if ( has_action('frm_entries_footer_scripts') ) { ?>
80
  <script type="text/javascript"><?php do_action( 'frm_entries_footer_scripts', $values['fields'], $form ); ?></script>
81
  <?php } ?>
1
  <?php
2
+ if ( empty( $values ) || ! isset( $values['fields'] ) || empty( $values['fields'] ) ) { ?>
3
+ <div class="frm_forms <?php echo FrmFormsHelper::get_form_style_class( $form ); ?>" id="frm_form_<?php echo esc_attr( $form->id ); ?>_container">
4
  <div class="frm_error_style"><strong><?php esc_html_e( 'Oops!', 'formidable' ) ?></strong> <?php printf( esc_html__( 'You did not add any fields to your form. %1$sGo back%2$s and add some.', 'formidable' ), '<a href="' . esc_url( admin_url( '?page=formidable&frm_action=edit&id=' . $form->id ) ) . '">', '</a>' ) ?>
5
  </div>
6
  </div>
19
  <fieldset>
20
  <?php echo FrmFormsHelper::replace_shortcodes( $values['before_html'], $form, $title, $description ); ?>
21
  <div <?php echo wp_strip_all_tags( apply_filters( 'frm_fields_container_class', 'class="frm_fields_container"' ) ); ?>>
22
+ <?php do_action( 'frm_after_title', compact( 'form' ) ); ?>
23
+ <input type="hidden" name="frm_action" value="<?php echo esc_attr( $form_action ); ?>" />
24
+ <input type="hidden" name="form_id" value="<?php echo esc_attr( $form->id ); ?>" />
25
+ <input type="hidden" name="frm_hide_fields_<?php echo esc_attr( $form->id ); ?>" id="frm_hide_fields_<?php echo esc_attr( $form->id ); ?>" value="<?php echo esc_attr( $frm_hide_fields ); ?>" />
26
+ <input type="hidden" name="form_key" value="<?php echo esc_attr( $form->form_key ); ?>" />
27
  <input type="hidden" name="item_meta[0]" value="" />
28
  <?php wp_nonce_field( 'frm_submit_entry_nonce', 'frm_submit_entry_' . $form->id ); ?>
29
  <label for="frm_verify_<?php echo esc_attr( $form->id ) ?>" class="frm_screen_reader frm_hidden"><?php esc_html_e( 'If you are human, leave this field blank.', 'formidable' ) ?></label>
30
+ <input type="text" class="frm_hidden frm_verify" id="frm_verify_<?php echo esc_attr( $form->id ); ?>" name="frm_verify" value="<?php echo esc_attr( FrmAppHelper::get_param( 'frm_verify', '', 'get', 'wp_kses_post' ) ); ?>" <?php FrmFormsHelper::maybe_hide_inline(); ?> />
31
  <?php if ( isset( $id ) ) { ?>
32
  <input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
33
  <?php } ?>
41
  ?>
42
  <div class="frm_form_field form-field">
43
  <label class="frm_primary_label"><?php esc_html_e( 'Entry Key', 'formidable' ) ?></label>
44
+ <input type="text" name="item_key" value="<?php echo esc_attr( $values['item_key'] ); ?>" />
45
  </div>
46
  <?php } else { ?>
47
+ <input type="hidden" name="item_key" value="<?php echo esc_attr( $values['item_key'] ); ?>" />
48
  <?php
49
  }
50
 
51
+ do_action( 'frm_entry_form', $form, $form_action, $errors );
52
 
53
  global $frm_vars;
54
  // close open section div
58
  }
59
 
60
  // close open collapsible toggle div
61
+ if ( isset( $frm_vars['collapse_div'] ) && $frm_vars['collapse_div'] ) {
62
  echo "</div>\n";
63
+ unset( $frm_vars['collapse_div'] );
64
  }
65
 
66
+ echo FrmFormsHelper::replace_shortcodes( $values['after_html'], $form );
67
 
68
  if ( FrmForm::show_submit( $form ) ) {
69
 
76
  </div>
77
  </fieldset>
78
  </div>
79
+ <?php if ( has_action( 'frm_entries_footer_scripts' ) ) { ?>
80
  <script type="text/javascript"><?php do_action( 'frm_entries_footer_scripts', $values['fields'], $form ); ?></script>
81
  <?php } ?>
classes/views/frm-entries/sidebar-shared.php CHANGED
@@ -2,7 +2,7 @@
2
  <div class="postbox frm_with_icons" >
3
  <h3 class="hndle">
4
  <span><?php esc_html_e( 'Entry Details', 'formidable' ) ?></span>
5
- <?php if ( FrmAppHelper::get_param('frm_action') != 'show' ) { ?>
6
  <a href="?page=formidable-entries&amp;frm_action=show&amp;id=<?php echo absint( $entry->id ); ?>" class="alignright">
7
  <?php esc_html_e( 'View Entry', 'formidable' ) ?>
8
  </a>
@@ -15,7 +15,7 @@
15
  <div class="misc-pub-section frm_no_print">
16
  <span class="dashicons dashicons-admin-post wp-media-buttons-icon"></span>
17
  <?php esc_html_e( 'Post', 'formidable' ) ?>:
18
- <b><?php echo get_the_title($entry->post_id) ?></b>
19
  <span>
20
  <a href="<?php echo esc_url( admin_url( 'post.php?post=' . $entry->post_id . '&action=edit' ) ) ?>">
21
  <?php esc_html_e( 'Edit', 'formidable' ) ?>
@@ -75,7 +75,7 @@
75
  </div>
76
  <?php } ?>
77
 
78
- <?php if ( isset($data['referrer']) ) { ?>
79
  <div class="misc-pub-section frm_force_wrap">
80
  <b><?php esc_html_e( 'Referrer', 'formidable' ) ?></b>:<br/>
81
  <?php echo wp_kses_post( str_replace( "\r\n", '<br/>', $data['referrer'] ) ); ?>
@@ -93,7 +93,7 @@
93
  <?php echo wp_kses_post( implode( ', ', (array) $d ) ); ?>
94
  </div>
95
  <?php
96
- unset($k, $d);
97
  }
98
  ?>
99
  </div>
2
  <div class="postbox frm_with_icons" >
3
  <h3 class="hndle">
4
  <span><?php esc_html_e( 'Entry Details', 'formidable' ) ?></span>
5
+ <?php if ( FrmAppHelper::get_param( 'frm_action' ) != 'show' ) { ?>
6
  <a href="?page=formidable-entries&amp;frm_action=show&amp;id=<?php echo absint( $entry->id ); ?>" class="alignright">
7
  <?php esc_html_e( 'View Entry', 'formidable' ) ?>
8
  </a>
15
  <div class="misc-pub-section frm_no_print">
16
  <span class="dashicons dashicons-admin-post wp-media-buttons-icon"></span>
17
  <?php esc_html_e( 'Post', 'formidable' ) ?>:
18
+ <b><?php echo get_the_title( $entry->post_id ); ?></b>
19
  <span>
20
  <a href="<?php echo esc_url( admin_url( 'post.php?post=' . $entry->post_id . '&action=edit' ) ) ?>">
21
  <?php esc_html_e( 'Edit', 'formidable' ) ?>
75
  </div>
76
  <?php } ?>
77
 
78
+ <?php if ( isset( $data['referrer'] ) ) { ?>
79
  <div class="misc-pub-section frm_force_wrap">
80
  <b><?php esc_html_e( 'Referrer', 'formidable' ) ?></b>:<br/>
81
  <?php echo wp_kses_post( str_replace( "\r\n", '<br/>', $data['referrer'] ) ); ?>
93
  <?php echo wp_kses_post( implode( ', ', (array) $d ) ); ?>
94
  </div>
95
  <?php
96
+ unset( $k, $d );
97
  }
98
  ?>
99
  </div>
classes/views/frm-fields/back-end/field-captcha.php CHANGED
@@ -1,7 +1,8 @@
1
  <?php
2
  $frm_settings = FrmAppHelper::get_settings();
3
- if ( empty( $frm_settings->pubkey ) ) { ?>
4
- <div class="howto frm_no_captcha_text"><?php printf(__( 'Your captcha will not appear on your form until you %1$sset up%2$s the Site and Secret Keys', 'formidable' ), '<a href="?page=formidable-settings">', '</a>') ?></div>
 
5
  <?php } ?>
6
  <img src="<?php echo esc_url( FrmAppHelper::plugin_url() . '/images/recaptcha.png' ) ?>" class="recaptcha_placeholder" alt="reCaptcha"/>
7
  <input type="hidden" name="<?php echo esc_attr( $field_name ) ?>" value="1" />
1
  <?php
2
  $frm_settings = FrmAppHelper::get_settings();
3
+ if ( empty( $frm_settings->pubkey ) ) {
4
+ ?>
5
+ <div class="howto frm_no_captcha_text"><?php printf( __( 'Your captcha will not appear on your form until you %1$sset up%2$s the Site and Secret Keys', 'formidable' ), '<a href="?page=formidable-settings">', '</a>' ); ?></div>
6
  <?php } ?>
7
  <img src="<?php echo esc_url( FrmAppHelper::plugin_url() . '/images/recaptcha.png' ) ?>" class="recaptcha_placeholder" alt="reCaptcha"/>
8
  <input type="hidden" name="<?php echo esc_attr( $field_name ) ?>" value="1" />
classes/views/frm-fields/front-end/checkbox-field.php CHANGED
@@ -28,7 +28,7 @@ if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' )
28
  ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
29
  }
30
 
31
- ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>"<?php echo $checked ?> <?php do_action('frm_field_input_html', $field) ?> /><?php
32
 
33
  if ( ! isset( $shortcode_atts ) || ! isset( $shortcode_atts['label'] ) || $shortcode_atts['label'] ) {
34
  echo ' ' . $opt . '</label>';
28
  ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
29
  }
30
 
31
+ ?><input type="checkbox" name="<?php echo esc_attr( $field_name ); ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ); ?>]" id="<?php echo esc_attr( $html_id ); ?>-<?php echo esc_attr( $opt_key ); ?>" value="<?php echo esc_attr( $field_val ); ?>"<?php echo $checked; ?> <?php do_action( 'frm_field_input_html', $field ); ?> /><?php
32
 
33
  if ( ! isset( $shortcode_atts ) || ! isset( $shortcode_atts['label'] ) || $shortcode_atts['label'] ) {
34
  echo ' ' . $opt . '</label>';
classes/views/frm-fields/front-end/dropdown-field.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- if ( isset($field['post_field']) && $field['post_field'] == 'post_category' && FrmAppHelper::pro_is_installed() ) {
4
  echo FrmProPost::get_category_dropdown( $field, array(
5
  'location' => 'front',
6
  'name' => $field_name,
@@ -9,9 +9,9 @@ if ( isset($field['post_field']) && $field['post_field'] == 'post_category' && F
9
  } else {
10
  if ( $read_only ) {
11
  ?>
12
- <select <?php do_action('frm_field_input_html', $field) ?>>
13
  <?php } else { ?>
14
- <select name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" <?php do_action('frm_field_input_html', $field) ?>>
15
  <?php
16
  }
17
 
1
  <?php
2
 
3
+ if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' && FrmAppHelper::pro_is_installed() ) {
4
  echo FrmProPost::get_category_dropdown( $field, array(
5
  'location' => 'front',
6
  'name' => $field_name,
9
  } else {
10
  if ( $read_only ) {
11
  ?>
12
+ <select <?php do_action( 'frm_field_input_html', $field ); ?>>
13
  <?php } else { ?>
14
+ <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $html_id ); ?>" <?php do_action( 'frm_field_input_html', $field ); ?>>
15
  <?php
16
  }
17
 
classes/views/frm-fields/front-end/radio-field.php CHANGED
@@ -20,14 +20,14 @@ if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' )
20
  if ( ! isset( $shortcode_atts ) || ! isset( $shortcode_atts['label'] ) || $shortcode_atts['label'] ) {
21
  ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
22
  }
23
- $checked = FrmAppHelper::check_selected($field['value'], $field_val) ? 'checked="checked" ' : ' ';
24
 
25
  $other_opt = false;
26
  $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked );
27
  ?>
28
  <input type="radio" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php
29
  echo $checked;
30
- do_action('frm_field_input_html', $field);
31
  ?>/><?php
32
 
33
  if ( ! isset( $shortcode_atts ) || ! isset( $shortcode_atts['label'] ) || $shortcode_atts['label'] ) {
20
  if ( ! isset( $shortcode_atts ) || ! isset( $shortcode_atts['label'] ) || $shortcode_atts['label'] ) {
21
  ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
22
  }
23
+ $checked = FrmAppHelper::check_selected( $field['value'], $field_val ) ? 'checked="checked" ' : ' ';
24
 
25
  $other_opt = false;
26
  $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked );
27
  ?>
28
  <input type="radio" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php
29
  echo $checked;
30
+ do_action( 'frm_field_input_html', $field );
31
  ?>/><?php
32
 
33
  if ( ! isset( $shortcode_atts ) || ! isset( $shortcode_atts['label'] ) || $shortcode_atts['label'] ) {
classes/views/frm-form-actions/_action_inside.php CHANGED
@@ -1,12 +1,13 @@
1
- <input type="hidden" name="<?php echo esc_attr( $action_control->get_field_name('post_excerpt', '') ) ?>" class="frm_action_name" value="<?php echo esc_attr( $form_action->post_excerpt ); ?>" />
2
- <input type="hidden" name="<?php echo esc_attr( $action_control->get_field_name('ID', '') ) ?>" value="<?php echo esc_attr( $form_action->ID ); ?>" />
3
 
4
  <table class="form-table">
5
  <tr>
6
  <th>
7
- <label <?php FrmAppHelper::maybe_add_tooltip('action_title') ?>><?php esc_html_e( 'Label', 'formidable' ) ?></label>
8
  </th>
9
- <td><input type="text" name="<?php echo esc_attr( $action_control->get_field_name('post_title', '') ) ?>" value="<?php echo esc_attr($form_action->post_title); ?>" class="large-text <?php FrmAppHelper::maybe_add_tooltip('action_title', 'open') ?>" id="<?php echo esc_attr( $action_control->get_field_id('action_post_title') ) ?>" />
 
10
  </td>
11
  </tr>
12
  </table>
@@ -24,7 +25,7 @@ if ( ! is_array( $action_control->action_options['event'] ) ) {
24
  if ( count( $action_control->action_options['event'] ) == 1 || $action_control->action_options['force_event'] ) {
25
  foreach ( $action_control->action_options['event'] as $e ) {
26
  ?>
27
- <input type="hidden" name="<?php echo esc_attr( $action_control->get_field_name('event') ) ?>[]" value="<?php echo esc_attr( $e ) ?>" />
28
  <?php
29
  }
30
  } else {
@@ -32,7 +33,7 @@ if ( count( $action_control->action_options['event'] ) == 1 || $action_control->
32
  <h3><?php esc_html_e( 'Action Triggers', 'formidable' ); ?></h3>
33
  <p>
34
  <label class="frm_left_label"><?php esc_html_e( 'Trigger this action after', 'formidable' ) ?></label>
35
- <select name="<?php echo esc_attr( $action_control->get_field_name('event') ) ?>[]" multiple="multiple" class="frm_multiselect" id="<?php echo esc_attr( $action_control->get_field_id('event') ) ?>">
36
  <?php
37
 
38
  $event_labels = FrmFormAction::trigger_labels();
@@ -54,5 +55,5 @@ $pass_args = array(
54
  do_action( 'frm_additional_action_settings', $form_action, $pass_args );
55
 
56
  ?>
57
- <span class="alignright frm_action_id <?php echo empty( $form_action->ID ) ? 'frm_hidden' : ''; ?>"><?php printf( __( 'Action ID: %1$s', 'formidable' ), $form_action->ID); ?></span>
58
  <div style="clear:both;"></div>
1
+ <input type="hidden" name="<?php echo esc_attr( $action_control->get_field_name( 'post_excerpt', '' ) ); ?>" class="frm_action_name" value="<?php echo esc_attr( $form_action->post_excerpt ); ?>" />
2
+ <input type="hidden" name="<?php echo esc_attr( $action_control->get_field_name( 'ID', '' ) ); ?>" value="<?php echo esc_attr( $form_action->ID ); ?>" />
3
 
4
  <table class="form-table">
5
  <tr>
6
  <th>
7
+ <label <?php FrmAppHelper::maybe_add_tooltip( 'action_title' ); ?>><?php esc_html_e( 'Label', 'formidable' ); ?></label>
8
  </th>
9
+ <td>
10
+ <input type="text" name="<?php echo esc_attr( $action_control->get_field_name( 'post_title', '' ) ); ?>" value="<?php echo esc_attr( $form_action->post_title ); ?>" class="large-text <?php FrmAppHelper::maybe_add_tooltip( 'action_title', 'open' ); ?>" id="<?php echo esc_attr( $action_control->get_field_id( 'action_post_title' ) ); ?>" />
11
  </td>
12
  </tr>
13
  </table>
25
  if ( count( $action_control->action_options['event'] ) == 1 || $action_control->action_options['force_event'] ) {
26
  foreach ( $action_control->action_options['event'] as $e ) {
27
  ?>
28
+ <input type="hidden" name="<?php echo esc_attr( $action_control->get_field_name( 'event' ) ); ?>[]" value="<?php echo esc_attr( $e ); ?>" />
29
  <?php
30
  }
31
  } else {
33
  <h3><?php esc_html_e( 'Action Triggers', 'formidable' ); ?></h3>
34
  <p>
35
  <label class="frm_left_label"><?php esc_html_e( 'Trigger this action after', 'formidable' ) ?></label>
36
+ <select name="<?php echo esc_attr( $action_control->get_field_name( 'event' ) ); ?>[]" multiple="multiple" class="frm_multiselect" id="<?php echo esc_attr( $action_control->get_field_id( 'event' ) ); ?>">
37
  <?php
38
 
39
  $event_labels = FrmFormAction::trigger_labels();
55
  do_action( 'frm_additional_action_settings', $form_action, $pass_args );
56
 
57
  ?>
58
+ <span class="alignright frm_action_id <?php echo empty( $form_action->ID ) ? 'frm_hidden' : ''; ?>"><?php printf( __( 'Action ID: %1$s', 'formidable' ), $form_action->ID ); ?></span>
59
  <div style="clear:both;"></div>
classes/views/frm-form-actions/default_actions.php CHANGED
@@ -12,7 +12,7 @@ class FrmDefPostAction extends FrmFormAction {
12
  // add register action
13
  class FrmDefRegAction extends FrmFormAction {
14
  public function __construct() {
15
- $action_ops = FrmFormAction::default_action_opts('frm_register_icon');
16
  parent::__construct( 'register', __( 'Register User', 'formidable' ), $action_ops );
17
  }
18
  }
@@ -20,7 +20,7 @@ class FrmDefRegAction extends FrmFormAction {
20
  // add paypal action
21
  class FrmDefPayPalAction extends FrmFormAction {
22
  public function __construct() {
23
- $action_ops = FrmFormAction::default_action_opts('frm_paypal_icon');
24
  parent::__construct( 'paypal', __( 'Collect Payment', 'formidable' ), $action_ops );
25
  }
26
  }
@@ -28,7 +28,7 @@ class FrmDefPayPalAction extends FrmFormAction {
28
  // add aweber action
29
  class FrmDefAweberAction extends FrmFormAction {
30
  public function __construct() {
31
- $action_ops = FrmFormAction::default_action_opts('frm_aweber_icon');
32
  parent::__construct( 'aweber', __( 'Aweber', 'formidable' ), $action_ops );
33
  }
34
  }
@@ -36,7 +36,7 @@ class FrmDefAweberAction extends FrmFormAction {
36
  // add mailchimp action
37
  class FrmDefMlcmpAction extends FrmFormAction {
38
  public function __construct() {
39
- $action_ops = FrmFormAction::default_action_opts('frm_mailchimp_icon');
40
  parent::__construct( 'mailchimp', __( 'MailChimp', 'formidable' ), $action_ops );
41
  }
42
  }
@@ -44,7 +44,7 @@ class FrmDefMlcmpAction extends FrmFormAction {
44
  // add twilio action
45
  class FrmDefTwilioAction extends FrmFormAction {
46
  public function __construct() {
47
- $action_ops = FrmFormAction::default_action_opts('frm_sms_icon');
48
  parent::__construct( 'twilio', __( 'Twilio', 'formidable' ), $action_ops );
49
  }
50
  }
@@ -52,7 +52,7 @@ class FrmDefTwilioAction extends FrmFormAction {
52
  // add highrise action
53
  class FrmDefHrsAction extends FrmFormAction {
54
  public function __construct() {
55
- $action_ops = FrmFormAction::default_action_opts('frm_highrise_icon');
56
  parent::__construct( 'highrise', __( 'Highrise', 'formidable' ), $action_ops );
57
  }
58
  }
12
  // add register action
13
  class FrmDefRegAction extends FrmFormAction {
14
  public function __construct() {
15
+ $action_ops = FrmFormAction::default_action_opts( 'frm_register_icon' );
16
  parent::__construct( 'register', __( 'Register User', 'formidable' ), $action_ops );
17
  }
18
  }
20
  // add paypal action
21
  class FrmDefPayPalAction extends FrmFormAction {
22
  public function __construct() {
23
+ $action_ops = FrmFormAction::default_action_opts( 'frm_paypal_icon' );
24
  parent::__construct( 'paypal', __( 'Collect Payment', 'formidable' ), $action_ops );
25
  }
26
  }
28
  // add aweber action
29
  class FrmDefAweberAction extends FrmFormAction {
30
  public function __construct() {
31
+ $action_ops = FrmFormAction::default_action_opts( 'frm_aweber_icon' );
32
  parent::__construct( 'aweber', __( 'Aweber', 'formidable' ), $action_ops );
33
  }
34
  }
36
  // add mailchimp action
37
  class FrmDefMlcmpAction extends FrmFormAction {
38
  public function __construct() {
39
+ $action_ops = FrmFormAction::default_action_opts( 'frm_mailchimp_icon' );
40
  parent::__construct( 'mailchimp', __( 'MailChimp', 'formidable' ), $action_ops );
41
  }
42
  }
44
  // add twilio action
45
  class FrmDefTwilioAction extends FrmFormAction {
46
  public function __construct() {
47
+ $action_ops = FrmFormAction::default_action_opts( 'frm_sms_icon' );
48
  parent::__construct( 'twilio', __( 'Twilio', 'formidable' ), $action_ops );
49
  }
50
  }
52
  // add highrise action
53
  class FrmDefHrsAction extends FrmFormAction {
54
  public function __construct() {
55
+ $action_ops = FrmFormAction::default_action_opts( 'frm_highrise_icon' );
56
  parent::__construct( 'highrise', __( 'Highrise', 'formidable' ), $action_ops );
57
  }
58
  }
classes/views/frm-form-actions/email_action.php CHANGED
@@ -11,13 +11,13 @@ class FrmEmailAction extends FrmFormAction {
11
  'priority' => 10,
12
  'ajax_load' => false,
13
  );
14
- $action_ops = apply_filters('frm_email_control_settings', $action_ops);
15
 
16
- parent::__construct('email', __( 'Email Notification', 'formidable' ), $action_ops);
17
  }
18
 
19
  public function form( $form_action, $args = array() ) {
20
- extract($args);
21
 
22
  include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_email_settings.php' );
23
  }
11
  'priority' => 10,
12
  'ajax_load' => false,
13
  );
14
+ $action_ops = apply_filters( 'frm_email_control_settings', $action_ops );
15
 
16
+ parent::__construct( 'email', __( 'Email Notification', 'formidable' ), $action_ops );
17
  }
18
 
19
  public function form( $form_action, $args = array() ) {
20
+ extract( $args );
21
 
22
  include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_email_settings.php' );
23
  }
classes/views/frm-form-actions/form_action.php CHANGED
@@ -23,14 +23,14 @@ $form_action = apply_filters( 'frm_form_' . $form_action->post_excerpt . '_actio
23
  </div>
24
  <div class="widget-inside frm_hidden">
25
  <?php
26
- if ( defined('DOING_AJAX') || ! $action_control->action_options['ajax_load'] ) {
27
  // only load settings if they are just added or are open
28
  include( dirname( __FILE__ ) . '/_action_inside.php' );
29
  } else {
30
  // include hidden settings so action won't get lost on update
31
  ?>
32
- <input type="hidden" name="<?php echo esc_attr( $action_control->get_field_name('post_excerpt', '') ) ?>" class="frm_action_name" value="<?php echo esc_attr( $form_action->post_excerpt ); ?>" />
33
- <input type="hidden" name="<?php echo esc_attr( $action_control->get_field_name('ID', '') ) ?>" value="<?php echo esc_attr( $form_action->ID ); ?>" />
34
  <?php } ?>
35
  </div>
36
  </div>
23
  </div>
24
  <div class="widget-inside frm_hidden">
25
  <?php
26
+ if ( defined( 'DOING_AJAX' ) || ! $action_control->action_options['ajax_load'] ) {
27
  // only load settings if they are just added or are open
28
  include( dirname( __FILE__ ) . '/_action_inside.php' );
29
  } else {
30
  // include hidden settings so action won't get lost on update
31
  ?>
32
+ <input type="hidden" name="<?php echo esc_attr( $action_control->get_field_name( 'post_excerpt', '' ) ); ?>" class="frm_action_name" value="<?php echo esc_attr( $form_action->post_excerpt ); ?>" />
33
+ <input type="hidden" name="<?php echo esc_attr( $action_control->get_field_name( 'ID', '' ) ); ?>" value="<?php echo esc_attr( $form_action->ID ); ?>" />
34
  <?php } ?>
35
  </div>
36
  </div>
classes/views/frm-forms/add_field.php CHANGED
@@ -61,7 +61,7 @@ if ( in_array( $field['type'], array( 'select', 'radio', 'checkbox' ) ) ) {
61
  <?php
62
 
63
  if ( isset( $field['post_field'] ) && $field['post_field'] === 'post_category' ) {
64
- echo '<p class="howto">' . FrmFieldsHelper::get_term_link( $field['taxonomy'] ) . '</p>';
65
  } elseif ( ! isset( $field['post_field'] ) || ! in_array( $field['post_field'], array( 'post_category' ) ) ) {
66
  ?>
67
  <div id="frm_add_field_<?php echo esc_attr( $field['id'] ); ?>">
@@ -279,7 +279,7 @@ if ( $display['options'] ) {
279
  include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/html-content.php' );
280
  }
281
 
282
- do_action( 'frm_' . $field['type'] . '_field_options_form', $field, $display, $values );
283
  do_action( 'frm_field_options_form', $field, $display, $values );
284
 
285
  if ( $display['required'] || $display['invalid'] || $display['unique'] || $display['conf_field'] ) {
61
  <?php
62
 
63
  if ( isset( $field['post_field'] ) && $field['post_field'] === 'post_category' ) {
64
+ echo '<p class="howto" id="frm_has_hidden_options_' . esc_attr( $field['id'] ) . '">' . FrmFieldsHelper::get_term_link( $field['taxonomy'] ) . '</p>';
65
  } elseif ( ! isset( $field['post_field'] ) || ! in_array( $field['post_field'], array( 'post_category' ) ) ) {
66
  ?>
67
  <div id="frm_add_field_<?php echo esc_attr( $field['id'] ); ?>">
279
  include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/html-content.php' );
280
  }
281
 
282
+ $field_obj->show_options( $field, $display, $values );
283
  do_action( 'frm_field_options_form', $field, $display, $values );
284
 
285
  if ( $display['required'] || $display['invalid'] || $display['unique'] || $display['conf_field'] ) {
classes/views/frm-forms/form.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php wp_nonce_field('frm_save_form_nonce', 'frm_save_form'); ?>
2
  <input type="hidden" name="status" value="<?php echo esc_attr( $values['status'] ); ?>" />
3
  <input type="hidden" name="new_status" value="" />
4
 
@@ -9,7 +9,7 @@
9
  <input type="text" name="name" value="<?php echo esc_attr( $form->name ); ?>" id="title" placeholder="<?php esc_attr_e( 'Enter title here' ) ?>" />
10
  </div>
11
 
12
- <div class="frm_no_fields <?php echo ( isset($values['fields']) && ! empty($values['fields']) ) ? 'frm_hidden' : ''; ?>">
13
  <div class="alignleft sketch1">
14
  <img src="<?php echo esc_url( FrmAppHelper::plugin_url() . '/images/sketch_arrow1.png' ); ?>" alt="" />
15
  </div>
@@ -55,7 +55,7 @@ if ( isset( $values['fields'] ) && ! empty( $values['fields'] ) ) {
55
  </ul>
56
 
57
  <p>
58
- <?php $page_action = FrmAppHelper::get_param('frm_action'); ?>
59
  <button class="frm_submit_<?php echo ( isset( $values['ajax_load'] ) && $values['ajax_load'] ) ? '' : 'no_'; ?>ajax button-primary frm_button_submit" type="button"><?php echo esc_html( ( $page_action == 'edit' || $page_action == 'update' ) ? __( 'Update', 'formidable' ) : __( 'Create', 'formidable' ) ); ?></button>
60
  </p>
61
 
1
+ <?php wp_nonce_field( 'frm_save_form_nonce', 'frm_save_form' ); ?>
2
  <input type="hidden" name="status" value="<?php echo esc_attr( $values['status'] ); ?>" />
3
  <input type="hidden" name="new_status" value="" />
4
 
9
  <input type="text" name="name" value="<?php echo esc_attr( $form->name ); ?>" id="title" placeholder="<?php esc_attr_e( 'Enter title here' ) ?>" />
10
  </div>
11
 
12
+ <div class="frm_no_fields <?php echo ( isset( $values['fields'] ) && ! empty( $values['fields'] ) ) ? 'frm_hidden' : ''; ?>">
13
  <div class="alignleft sketch1">
14
  <img src="<?php echo esc_url( FrmAppHelper::plugin_url() . '/images/sketch_arrow1.png' ); ?>" alt="" />
15
  </div>
55
  </ul>
56
 
57
  <p>
58
+ <?php $page_action = FrmAppHelper::get_param( 'frm_action' ); ?>
59
  <button class="frm_submit_<?php echo ( isset( $values['ajax_load'] ) && $values['ajax_load'] ) ? '' : 'no_'; ?>ajax button-primary frm_button_submit" type="button"><?php echo esc_html( ( $page_action == 'edit' || $page_action == 'update' ) ? __( 'Update', 'formidable' ) : __( 'Create', 'formidable' ) ); ?></button>
60
  </p>
61
 
classes/views/frm-forms/mb_html_tab.php CHANGED
@@ -53,7 +53,7 @@
53
  foreach ( $form_codes as $skey => $sname ) {
54
  ?>
55
  <li class="frm_col_<?php echo esc_attr( $col ) ?>">
56
- <a href="javascript:void(0)" class="show_before_html show_after_html frmbutton button frm_insert_code" data-code="<?php echo esc_attr($skey) ?>"><?php echo esc_html( $sname ); ?></a>
57
  </li>
58
  <?php
59
  $col = ( 'one' === $col ) ? 'two' : 'one';
@@ -65,7 +65,7 @@
65
  ) as $skey => $sname ) {
66
  ?>
67
  <li class="frm_col_<?php echo esc_attr( $col ) ?>">
68
- <a href="javascript:void(0)" class="show_submit_html frmbutton button frm_insert_code" data-code="<?php echo esc_attr($skey) ?>"><?php echo esc_html( $sname ); ?></a>
69
  </li>
70
  <?php
71
  $col = ( 'one' === $col ) ? 'two' : 'one';
53
  foreach ( $form_codes as $skey => $sname ) {
54
  ?>
55
  <li class="frm_col_<?php echo esc_attr( $col ) ?>">
56
+ <a href="javascript:void(0)" class="show_before_html show_after_html frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $skey ); ?>"><?php echo esc_html( $sname ); ?></a>
57
  </li>
58
  <?php
59
  $col = ( 'one' === $col ) ? 'two' : 'one';
65
  ) as $skey => $sname ) {
66
  ?>
67
  <li class="frm_col_<?php echo esc_attr( $col ) ?>">
68
+ <a href="javascript:void(0)" class="show_submit_html frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $skey ); ?>"><?php echo esc_html( $sname ); ?></a>
69
  </li>
70
  <?php
71
  $col = ( 'one' === $col ) ? 'two' : 'one';
classes/views/frm-forms/settings.php CHANGED
@@ -94,7 +94,7 @@
94
  <tr>
95
  <td class="frm_175_width">
96
  <select name="options[success_action]" id="success_action">
97
- <option value="message" <?php selected($values['success_action'], 'message') ?>>
98
  <?php esc_html_e( 'Show Message', 'formidable' ) ?>
99
  </option>
100
  <option value="redirect" <?php selected( $values['success_action'], 'redirect' ); ?>>
@@ -133,7 +133,7 @@
133
  </label>
134
  </td>
135
  </tr>
136
- <?php if ( function_exists( 'akismet_http_post') ) { ?>
137
  <tr>
138
  <td colspan="2"><?php esc_html_e( 'Use Akismet to check entries for spam for', 'formidable' ) ?>
139
  <select name="options[akismet]">
@@ -246,7 +246,7 @@
246
  <textarea id="frm_form_description" name="description" cols="50" rows="5" class="frm_long_input"><?php echo FrmAppHelper::esc_textarea( $values['description'] ); ?></textarea>
247
  </td>
248
  </tr>
249
- <?php do_action('frm_additional_form_options', $values); ?>
250
  </table>
251
  </div>
252
 
@@ -315,10 +315,12 @@
315
  </div>
316
 
317
  <p><label><?php esc_html_e( 'After Fields', 'formidable' ) ?></label>
318
- <textarea name="options[after_html]" rows="3" id="after_html" class="frm_long_input"><?php echo FrmAppHelper::esc_textarea($values['after_html']) ?></textarea></p>
 
319
 
320
  <p><label><?php esc_html_e( 'Submit Button', 'formidable' ) ?></label>
321
- <textarea name="options[submit_html]" rows="3" id="submit_html" class="frm_long_input"><?php echo FrmAppHelper::esc_textarea($values['submit_html']) ?></textarea></p>
 
322
  </div>
323
  </div>
324
 
@@ -341,7 +343,7 @@
341
  </div>
342
  <?php } ?>
343
 
344
- <?php do_action('frm_add_form_option_section', $values); ?>
345
  <div class="clear"></div>
346
  </div>
347
  </div>
94
  <tr>
95
  <td class="frm_175_width">
96
  <select name="options[success_action]" id="success_action">
97
+ <option value="message" <?php selected( $values['success_action'], 'message' ); ?>>
98
  <?php esc_html_e( 'Show Message', 'formidable' ) ?>
99
  </option>
100
  <option value="redirect" <?php selected( $values['success_action'], 'redirect' ); ?>>
133
  </label>
134
  </td>
135
  </tr>
136
+ <?php if ( function_exists( 'akismet_http_post' ) ) { ?>
137
  <tr>
138
  <td colspan="2"><?php esc_html_e( 'Use Akismet to check entries for spam for', 'formidable' ) ?>
139
  <select name="options[akismet]">
246
  <textarea id="frm_form_description" name="description" cols="50" rows="5" class="frm_long_input"><?php echo FrmAppHelper::esc_textarea( $values['description'] ); ?></textarea>
247
  </td>
248
  </tr>
249
+ <?php do_action( 'frm_additional_form_options', $values ); ?>
250
  </table>
251
  </div>
252
 
315
  </div>
316
 
317
  <p><label><?php esc_html_e( 'After Fields', 'formidable' ) ?></label>
318
+ <textarea name="options[after_html]" rows="3" id="after_html" class="frm_long_input"><?php echo FrmAppHelper::esc_textarea( $values['after_html'] ); ?></textarea>
319
+ </p>
320
 
321
  <p><label><?php esc_html_e( 'Submit Button', 'formidable' ) ?></label>
322
+ <textarea name="options[submit_html]" rows="3" id="submit_html" class="frm_long_input"><?php echo FrmAppHelper::esc_textarea( $values['submit_html'] ); ?></textarea>
323
+ </p>
324
  </div>
325
  </div>
326
 
343
  </div>
344
  <?php } ?>
345
 
346
+ <?php do_action( 'frm_add_form_option_section', $values ); ?>
347
  <div class="clear"></div>
348
  </div>
349
  </div>
classes/views/frm-forms/shortcode_opts.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- if ( ! empty($form_id) ) {
3
  ?>
4
  <h4 class="frm_left_label"><?php esc_html_e( 'Select a form:', 'formidable' ); ?></h4>
5
  <?php FrmFormsHelper::forms_dropdown( 'frmsc_' . $shortcode . '_' . $form_id ); ?>
1
  <?php
2
+ if ( ! empty( $form_id ) ) {
3
  ?>
4
  <h4 class="frm_left_label"><?php esc_html_e( 'Select a form:', 'formidable' ); ?></h4>
5
  <?php FrmFormsHelper::forms_dropdown( 'frmsc_' . $shortcode . '_' . $form_id ); ?>
classes/views/frm-forms/sidebar-settings.php CHANGED
@@ -3,7 +3,7 @@
3
  <div id="frm-fixed">
4
  <?php
5
 
6
- if ( ! isset($hide_preview) || ! $hide_preview ) {
7
  include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/_publish_box.php' );
8
  }
9
  ?>
3
  <div id="frm-fixed">
4
  <?php
5
 
6
+ if ( ! isset( $hide_preview ) || ! $hide_preview ) {
7
  include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/_publish_box.php' );
8
  }
9
  ?>
classes/views/frm-settings/form.php CHANGED
@@ -26,12 +26,12 @@
26
  </ul>
27
  </div>
28
 
29
- <?php do_action('frm_before_settings'); ?>
30
 
31
  <form name="frm_settings_form" method="post" class="frm_settings_form" action="?page=formidable-settings<?php echo ( $a ? '&amp;t=' . $a : '' ); ?>">
32
  <input type="hidden" name="frm_action" value="process-form" />
33
  <input type="hidden" name="action" value="process-form" />
34
- <?php wp_nonce_field('process_form_nonce', 'process_form'); ?>
35
 
36
  <div class="general_settings tabs-panel <?php echo esc_attr( $a === 'general_settings' ? 'frm_block' : 'frm_hidden' ); ?>">
37
  <p class="submit">
@@ -56,7 +56,7 @@
56
 
57
  <p>
58
  <label for="frm_use_html">
59
- <input type="checkbox" id="frm_use_html" name="frm_use_html" value="1" <?php checked($frm_settings->use_html, 1) ?>> <?php esc_html_e( 'Use HTML5 in forms', 'formidable' ) ?>
60
  </label>
61
  <span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'We recommend using HTML 5 for your forms. It adds some nifty options like placeholders, patterns, and autocomplete.', 'formidable' ) ?>"></span>
62
  </p>
@@ -95,10 +95,10 @@
95
  </p>
96
 
97
  <p><label class="frm_left_label"><?php esc_html_e( 'Site Key', 'formidable' ) ?></label>
98
- <input type="text" name="frm_pubkey" id="frm_pubkey" size="42" value="<?php echo esc_attr($frm_settings->pubkey) ?>" placeholder="<?php esc_attr_e( 'Optional', 'formidable' ) ?>" /></p>
99
 
100
  <p><label class="frm_left_label"><?php esc_html_e( 'Secret Key', 'formidable' ) ?></label>
101
- <input type="text" name="frm_privkey" id="frm_privkey" size="42" value="<?php echo esc_attr($frm_settings->privkey) ?>" placeholder="<?php esc_attr_e( 'Optional', 'formidable' ) ?>" /></p>
102
 
103
  <p><label class="frm_left_label"><?php esc_html_e( 'reCAPTCHA Type', 'formidable' ) ?></label>
104
  <select name="frm_re_type" id="frm_re_type">
@@ -114,7 +114,7 @@
114
  <select name="frm_re_lang" id="frm_re_lang">
115
  <option value="" <?php selected( $frm_settings->re_lang, '' ) ?>><?php esc_html_e( 'Browser Default', 'formidable' ); ?></option>
116
  <?php foreach ( $captcha_lang as $lang => $lang_name ) { ?>
117
- <option value="<?php echo esc_attr($lang) ?>" <?php selected($frm_settings->re_lang, $lang) ?>><?php echo esc_html( $lang_name ) ?></option>
118
  <?php } ?>
119
  </select></p>
120
 
@@ -167,7 +167,7 @@
167
  <label class="frm_left_label"><?php esc_html_e( 'Success Message', 'formidable' ); ?>
168
  <span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'The default message seen after a form is submitted.', 'formidable' ) ?>" ></span>
169
  </label>
170
- <input type="text" id="frm_success_msg" name="frm_success_msg" class="frm_with_left_label" value="<?php echo esc_attr($frm_settings->success_msg) ?>" />
171
  </p>
172
 
173
  <p>
@@ -175,7 +175,7 @@
175
  <input type="text" value="<?php echo esc_attr( $frm_settings->submit_value ) ?>" id="frm_submit_value" name="frm_submit_value" class="frm_with_left_label" />
176
  </p>
177
 
178
- <?php do_action('frm_settings_form', $frm_settings); ?>
179
 
180
  <?php if ( ! FrmAppHelper::pro_is_installed() ) { ?>
181
  <div class="clear"></div>
26
  </ul>
27
  </div>
28
 
29
+ <?php do_action( 'frm_before_settings' ); ?>
30
 
31
  <form name="frm_settings_form" method="post" class="frm_settings_form" action="?page=formidable-settings<?php echo ( $a ? '&amp;t=' . $a : '' ); ?>">
32
  <input type="hidden" name="frm_action" value="process-form" />
33
  <input type="hidden" name="action" value="process-form" />
34
+ <?php wp_nonce_field( 'process_form_nonce', 'process_form' ); ?>
35
 
36
  <div class="general_settings tabs-panel <?php echo esc_attr( $a === 'general_settings' ? 'frm_block' : 'frm_hidden' ); ?>">
37
  <p class="submit">
56
 
57
  <p>
58
  <label for="frm_use_html">
59
+ <input type="checkbox" id="frm_use_html" name="frm_use_html" value="1" <?php checked( $frm_settings->use_html, 1 ); ?>> <?php esc_html_e( 'Use HTML5 in forms', 'formidable' ); ?>
60
  </label>
61
  <span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'We recommend using HTML 5 for your forms. It adds some nifty options like placeholders, patterns, and autocomplete.', 'formidable' ) ?>"></span>
62
  </p>
95
  </p>
96
 
97
  <p><label class="frm_left_label"><?php esc_html_e( 'Site Key', 'formidable' ) ?></label>
98
+ <input type="text" name="frm_pubkey" id="frm_pubkey" size="42" value="<?php echo esc_attr( $frm_settings->pubkey ); ?>" placeholder="<?php esc_attr_e( 'Optional', 'formidable' ); ?>" /></p>
99
 
100
  <p><label class="frm_left_label"><?php esc_html_e( 'Secret Key', 'formidable' ) ?></label>
101
+ <input type="text" name="frm_privkey" id="frm_privkey" size="42" value="<?php echo esc_attr( $frm_settings->privkey ); ?>" placeholder="<?php esc_attr_e( 'Optional', 'formidable' ); ?>" /></p>
102
 
103
  <p><label class="frm_left_label"><?php esc_html_e( 'reCAPTCHA Type', 'formidable' ) ?></label>
104
  <select name="frm_re_type" id="frm_re_type">
114
  <select name="frm_re_lang" id="frm_re_lang">
115
  <option value="" <?php selected( $frm_settings->re_lang, '' ) ?>><?php esc_html_e( 'Browser Default', 'formidable' ); ?></option>
116
  <?php foreach ( $captcha_lang as $lang => $lang_name ) { ?>
117
+ <option value="<?php echo esc_attr( $lang ); ?>" <?php selected( $frm_settings->re_lang, $lang ); ?>><?php echo esc_html( $lang_name ); ?></option>
118
  <?php } ?>
119
  </select></p>
120
 
167
  <label class="frm_left_label"><?php esc_html_e( 'Success Message', 'formidable' ); ?>
168
  <span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'The default message seen after a form is submitted.', 'formidable' ) ?>" ></span>
169
  </label>
170
+ <input type="text" id="frm_success_msg" name="frm_success_msg" class="frm_with_left_label" value="<?php echo esc_attr( $frm_settings->success_msg ); ?>" />
171
  </p>
172
 
173
  <p>
175
  <input type="text" value="<?php echo esc_attr( $frm_settings->submit_value ) ?>" id="frm_submit_value" name="frm_submit_value" class="frm_with_left_label" />
176
  </p>
177
 
178
+ <?php do_action( 'frm_settings_form', $frm_settings ); ?>
179
 
180
  <?php if ( ! FrmAppHelper::pro_is_installed() ) { ?>
181
  <div class="clear"></div>
classes/views/shared/mb_adv_info.php CHANGED
@@ -48,7 +48,7 @@
48
 
49
  if ( $f->type == 'data' ) {
50
  //get all fields from linked form
51
- if ( isset($f->field_options['form_select']) && is_numeric($f->field_options['form_select']) ) {
52
  $linked_form = FrmDb::get_var( $wpdb->prefix . 'frm_fields', array( 'id' => $f->field_options['form_select'] ), 'form_id' );
53
  if ( ! in_array( $linked_form, $linked_forms ) ) {
54
  $linked_forms[] = $linked_form;
@@ -67,14 +67,14 @@
67
  ) );
68
 
69
  $ldfe = $linked_field->id;
70
- unset($linked_field);
71
  }
72
  }
73
  }
74
  }
75
  $dfe = $f->id;
76
  }
77
- unset($f);
78
  }
79
  }
80
  ?>
@@ -129,8 +129,8 @@
129
  ?>
130
  <li>
131
  <a href="javascript:void(0)" class="frmids alignright frm_insert_code" data-code="if <?php echo esc_attr( $f->id ) ?>]<?php esc_attr_e( 'Conditional text here', 'formidable' ) ?>[/if <?php echo esc_attr( $f->id ) ?>">[if <?php echo (int) $f->id ?>]</a>
132
- <a href="javascript:void(0)" class="frmkeys alignright frm_insert_code" data-code="if <?php echo esc_attr( $f->field_key ) ?>]something[/if <?php echo esc_attr( $f->field_key ) ?>">[if <?php echo FrmAppHelper::truncate($f->field_key, 10) ?>]</a>
133
- <a href="javascript:void(0)" class="frm_insert_code" data-code="<?php echo esc_attr($f->id) ?>"><?php echo FrmAppHelper::truncate($f->name, 60) ?></a>
134
  </li>
135
  <?php
136
 
@@ -152,11 +152,11 @@
152
  foreach ( $cond_shortcodes as $skey => $sname ) {
153
  ?>
154
  <li class="frm_col_<?php echo esc_attr( $col ) ?>">
155
- <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="if x <?php echo esc_attr($skey) ?>][/if x"><?php echo esc_html( $sname ) ?></a>
156
  </li>
157
  <?php
158
  $col = ( $col == 'one' ) ? 'two' : 'one';
159
- unset($skey, $sname);
160
  }
161
  ?>
162
  </ul>
@@ -184,15 +184,15 @@
184
  ?>
185
  <?php if ( isset( $file ) ) { ?>
186
  <li class="frm_col_<?php echo esc_attr( $col ) ?>">
187
- <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr($file->id) ?> show_image=1"><?php esc_html_e( 'Show image', 'formidable' ) ?></a>
188
  </li>
189
  <?php $col = ( $col == 'one' ? 'two' : 'one' ); ?>
190
  <li class="frm_col_<?php echo esc_attr( $col ) ?>">
191
- <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr($file->id) ?> show=id"><?php esc_html_e( 'Image ID', 'formidable' ) ?></a>
192
  </li>
193
  <?php $col = ( $col == 'one' ? 'two' : 'one' ); ?>
194
  <li class="frm_col_<?php echo esc_attr( $col ) ?>">
195
- <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr($file->id) ?> show_filename=1"><?php esc_html_e( 'Image Name', 'formidable' ) ?></a>
196
  </li>
197
  <?php } ?>
198
  </ul>
@@ -240,7 +240,7 @@
240
  <li class="frm_col_one">
241
  <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $dfe . ' show="created-at"' ) ?>"><?php esc_html_e( 'Creation Date', 'formidable' ); ?></a>
242
  </li>
243
- <?php if ( isset($ldfe) ) { ?>
244
  <li class="frm_col_two">
245
  <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $dfe . ' show="' . $ldfe . '"' ) ?>"><?php esc_html_e( 'Field From Entry', 'formidable' ); ?></a>
246
  </li>
48
 
49
  if ( $f->type == 'data' ) {
50
  //get all fields from linked form
51
+ if ( isset( $f->field_options['form_select'] ) && is_numeric( $f->field_options['form_select'] ) ) {
52
  $linked_form = FrmDb::get_var( $wpdb->prefix . 'frm_fields', array( 'id' => $f->field_options['form_select'] ), 'form_id' );
53
  if ( ! in_array( $linked_form, $linked_forms ) ) {
54
  $linked_forms[] = $linked_form;
67
  ) );
68
 
69
  $ldfe = $linked_field->id;
70
+ unset( $linked_field );
71
  }
72
  }
73
  }
74
  }
75
  $dfe = $f->id;
76
  }
77
+ unset( $f );
78
  }
79
  }
80
  ?>
129
  ?>
130
  <li>
131
  <a href="javascript:void(0)" class="frmids alignright frm_insert_code" data-code="if <?php echo esc_attr( $f->id ) ?>]<?php esc_attr_e( 'Conditional text here', 'formidable' ) ?>[/if <?php echo esc_attr( $f->id ) ?>">[if <?php echo (int) $f->id ?>]</a>
132
+ <a href="javascript:void(0)" class="frmkeys alignright frm_insert_code" data-code="if <?php echo esc_attr( $f->field_key ); ?>]something[/if <?php echo esc_attr( $f->field_key ); ?>">[if <?php echo FrmAppHelper::truncate( $f->field_key, 10 ); ?>]</a>
133
+ <a href="javascript:void(0)" class="frm_insert_code" data-code="<?php echo esc_attr( $f->id ); ?>"><?php echo FrmAppHelper::truncate( $f->name, 60 ); ?></a>
134
  </li>
135
  <?php
136
 
152
  foreach ( $cond_shortcodes as $skey => $sname ) {
153
  ?>
154
  <li class="frm_col_<?php echo esc_attr( $col ) ?>">
155
+ <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="if x <?php echo esc_attr( $skey ); ?>][/if x"><?php echo esc_html( $sname ); ?></a>
156
  </li>
157
  <?php
158
  $col = ( $col == 'one' ) ? 'two' : 'one';
159
+ unset( $skey, $sname );
160
  }
161
  ?>
162
  </ul>
184
  ?>
185
  <?php if ( isset( $file ) ) { ?>
186
  <li class="frm_col_<?php echo esc_attr( $col ) ?>">
187
+ <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $file->id ); ?> show_image=1"><?php esc_html_e( 'Show image', 'formidable' ); ?></a>
188
  </li>
189
  <?php $col = ( $col == 'one' ? 'two' : 'one' ); ?>
190
  <li class="frm_col_<?php echo esc_attr( $col ) ?>">
191
+ <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $file->id ); ?> show=id"><?php esc_html_e( 'Image ID', 'formidable' ); ?></a>
192
  </li>
193
  <?php $col = ( $col == 'one' ? 'two' : 'one' ); ?>
194
  <li class="frm_col_<?php echo esc_attr( $col ) ?>">
195
+ <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $file->id ); ?> show_filename=1"><?php esc_html_e( 'Image Name', 'formidable' ); ?></a>
196
  </li>
197
  <?php } ?>
198
  </ul>
240
  <li class="frm_col_one">
241
  <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $dfe . ' show="created-at"' ) ?>"><?php esc_html_e( 'Creation Date', 'formidable' ); ?></a>
242
  </li>
243
+ <?php if ( isset( $ldfe ) ) { ?>
244
  <li class="frm_col_two">
245
  <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $dfe . ' show="' . $ldfe . '"' ) ?>"><?php esc_html_e( 'Field From Entry', 'formidable' ); ?></a>
246
  </li>
classes/views/styles/_field-colors.php CHANGED
@@ -60,7 +60,7 @@
60
  <div class="clear"></div>
61
  <p class="frm_no_bottom_margin">
62
  <label>
63
- <input type="checkbox" name="<?php echo esc_attr( $frm_style->get_field_name( 'remove_box_shadow' ) ) ?>" id="frm_remove_box_shadow" value="1" <?php checked($style->post_content['remove_box_shadow'], 1) ?> />
64
  <?php esc_html_e( 'Remove box shadow', 'formidable' ) ?>
65
  </label>
66
  </p>
@@ -78,7 +78,7 @@
78
  <div class="clear"></div>
79
  <p class="frm_no_bottom_margin">
80
  <label>
81
- <input type="checkbox" name="<?php echo esc_attr( $frm_style->get_field_name( 'remove_box_shadow_active' ) ); ?>" id="frm_remove_box_shadow_active" value="1" <?php checked($style->post_content['remove_box_shadow_active'], 1) ?> />
82
  <?php esc_html_e( 'Remove box shadow', 'formidable' ) ?>
83
  </label>
84
  </p>
60
  <div class="clear"></div>
61
  <p class="frm_no_bottom_margin">
62
  <label>
63
+ <input type="checkbox" name="<?php echo esc_attr( $frm_style->get_field_name( 'remove_box_shadow' ) ); ?>" id="frm_remove_box_shadow" value="1" <?php checked( $style->post_content['remove_box_shadow'], 1 ); ?> />
64
  <?php esc_html_e( 'Remove box shadow', 'formidable' ) ?>
65
  </label>
66
  </p>
78
  <div class="clear"></div>
79
  <p class="frm_no_bottom_margin">
80
  <label>
81
+ <input type="checkbox" name="<?php echo esc_attr( $frm_style->get_field_name( 'remove_box_shadow_active' ) ); ?>" id="frm_remove_box_shadow_active" value="1" <?php checked( $style->post_content['remove_box_shadow_active'], 1 ); ?> />
82
  <?php esc_html_e( 'Remove box shadow', 'formidable' ) ?>
83
  </label>
84
  </p>
classes/views/styles/_field-labels.php CHANGED
@@ -1,10 +1,10 @@
1
  <div class="field-group field-group-background clearfix frm-first-row">
2
  <label><?php esc_html_e( 'Color', 'formidable' ) ?></label>
3
- <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('label_color') ) ?>" id="frm_label_color" class="hex" value="<?php echo esc_attr( $style->post_content['label_color'] ) ?>" />
4
  </div>
5
  <div class="field-group clearfix frm-first-row">
6
  <label><?php esc_html_e( 'Weight', 'formidable' ) ?></label>
7
- <select name="<?php echo esc_attr( $frm_style->get_field_name('weight') ) ?>" id="frm_weight">
8
  <?php foreach ( FrmStyle::get_bold_options() as $value => $name ) { ?>
9
  <option value="<?php echo esc_attr( $value ) ?>" <?php selected( $style->post_content['weight'], $value ) ?>><?php echo esc_html( $name ) ?></option>
10
  <?php } ?>
@@ -12,14 +12,14 @@
12
  </div>
13
  <div class="field-group clearfix frm-first-row">
14
  <label><?php esc_html_e( 'Size', 'formidable' ) ?></label>
15
- <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('font_size') ) ?>" id="frm_font_size" value="<?php echo esc_attr($style->post_content['font_size']) ?>" size="3" />
16
  </div>
17
 
18
  <div class="field-group clearfix frm_clear">
19
  <label><?php esc_html_e( 'Position', 'formidable' ) ?></label>
20
- <select name="<?php echo esc_attr( $frm_style->get_field_name('position') ) ?>" id="frm_position">
21
  <?php foreach ( FrmStylesHelper::get_css_label_positions() as $pos => $pos_label ) { ?>
22
- <option value="<?php echo esc_attr( $pos ) ?>" <?php selected($style->post_content['position'], $pos) ?>><?php echo esc_html( $pos_label ) ?></option>
23
  <?php } ?>
24
  </select>
25
  </div>
@@ -38,23 +38,23 @@
38
 
39
  <div class="field-group clearfix">
40
  <label><?php esc_html_e( 'Width', 'formidable' ) ?></label>
41
- <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('width') ) ?>" id="frm_width" value="<?php echo esc_attr( $style->post_content['width'] ) ?>" />
42
  </div>
43
 
44
  <div class="field-group clearfix frm_clear">
45
  <label><?php esc_html_e( 'Padding', 'formidable' ) ?></label>
46
- <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('label_padding') ) ?>" id="frm_label_padding" value="<?php echo esc_attr( $style->post_content['label_padding'] ) ?>" />
47
  </div>
48
 
49
  <div class="clear"></div>
50
  <h3><?php esc_html_e( 'Required Indicator', 'formidable' ) ?></h3>
51
  <div class="field-group field-group-border clearfix after-h3">
52
  <label class="background"><?php esc_html_e( 'Color', 'formidable' ) ?></label>
53
- <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('required_color') ) ?>" id="frm_required_color" class="hex" value="<?php echo esc_attr( $style->post_content['required_color'] ) ?>" />
54
  </div>
55
  <div class="field-group clearfix after-h3">
56
  <label><?php esc_html_e( 'Weight', 'formidable' ) ?></label>
57
- <select name="<?php echo esc_attr( $frm_style->get_field_name('required_weight') ) ?>" id="frm_required_weight">
58
  <?php foreach ( FrmStyle::get_bold_options() as $value => $name ) { ?>
59
  <option value="<?php echo esc_attr( $value ) ?>" <?php selected( $style->post_content['required_weight'], $value ) ?>><?php echo esc_html( $name ) ?></option>
60
  <?php } ?>
1
  <div class="field-group field-group-background clearfix frm-first-row">
2
  <label><?php esc_html_e( 'Color', 'formidable' ) ?></label>
3
+ <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'label_color' ) ); ?>" id="frm_label_color" class="hex" value="<?php echo esc_attr( $style->post_content['label_color'] ); ?>" />
4
  </div>
5
  <div class="field-group clearfix frm-first-row">
6
  <label><?php esc_html_e( 'Weight', 'formidable' ) ?></label>
7
+ <select name="<?php echo esc_attr( $frm_style->get_field_name( 'weight' ) ); ?>" id="frm_weight">
8
  <?php foreach ( FrmStyle::get_bold_options() as $value => $name ) { ?>
9
  <option value="<?php echo esc_attr( $value ) ?>" <?php selected( $style->post_content['weight'], $value ) ?>><?php echo esc_html( $name ) ?></option>
10
  <?php } ?>
12
  </div>
13
  <div class="field-group clearfix frm-first-row">
14
  <label><?php esc_html_e( 'Size', 'formidable' ) ?></label>
15
+ <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'font_size' ) ); ?>" id="frm_font_size" value="<?php echo esc_attr( $style->post_content['font_size'] ); ?>" size="3" />
16
  </div>
17
 
18
  <div class="field-group clearfix frm_clear">
19
  <label><?php esc_html_e( 'Position', 'formidable' ) ?></label>
20
+ <select name="<?php echo esc_attr( $frm_style->get_field_name( 'position' ) ); ?>" id="frm_position">
21
  <?php foreach ( FrmStylesHelper::get_css_label_positions() as $pos => $pos_label ) { ?>
22
+ <option value="<?php echo esc_attr( $pos ); ?>" <?php selected( $style->post_content['position'], $pos ); ?>><?php echo esc_html( $pos_label ); ?></option>
23
  <?php } ?>
24
  </select>
25
  </div>
38
 
39
  <div class="field-group clearfix">
40
  <label><?php esc_html_e( 'Width', 'formidable' ) ?></label>
41
+ <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'width' ) ); ?>" id="frm_width" value="<?php echo esc_attr( $style->post_content['width'] ); ?>" />
42
  </div>
43
 
44
  <div class="field-group clearfix frm_clear">
45
  <label><?php esc_html_e( 'Padding', 'formidable' ) ?></label>
46
+ <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'label_padding' ) ); ?>" id="frm_label_padding" value="<?php echo esc_attr( $style->post_content['label_padding'] ); ?>" />
47
  </div>
48
 
49
  <div class="clear"></div>
50
  <h3><?php esc_html_e( 'Required Indicator', 'formidable' ) ?></h3>
51
  <div class="field-group field-group-border clearfix after-h3">
52
  <label class="background"><?php esc_html_e( 'Color', 'formidable' ) ?></label>
53
+ <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'required_color' ) ); ?>" id="frm_required_color" class="hex" value="<?php echo esc_attr( $style->post_content['required_color'] ); ?>" />
54
  </div>
55
  <div class="field-group clearfix after-h3">
56
  <label><?php esc_html_e( 'Weight', 'formidable' ) ?></label>
57
+ <select name="<?php echo esc_attr( $frm_style->get_field_name( 'required_weight' ) ); ?>" id="frm_required_weight">
58
  <?php foreach ( FrmStyle::get_bold_options() as $value => $name ) { ?>
59
  <option value="<?php echo esc_attr( $value ) ?>" <?php selected( $style->post_content['required_weight'], $value ) ?>><?php echo esc_html( $name ) ?></option>
60
  <?php } ?>
classes/views/styles/_field-sizes.php CHANGED
@@ -1,42 +1,42 @@
1
  <div class="field-group clearfix frm-first-row">
2
  <label><?php esc_html_e( 'Size', 'formidable' ) ?></label>
3
- <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('field_font_size') ) ?>" id="frm_field_font_size" value="<?php echo esc_attr( $style->post_content['field_font_size'] ) ?>" />
4
  </div>
5
 
6
  <div class="field-group clearfix frm-first-row">
7
  <label><?php esc_html_e( 'Height', 'formidable' ) ?></label>
8
- <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('field_height') ) ?>" id="frm_field_height" value="<?php echo esc_attr( $style->post_content['field_height'] ) ?>" />
9
  </div>
10
 
11
  <div class="field-group clearfix frm-first-row">
12
  <label><?php esc_html_e( 'Width', 'formidable' ) ?></label>
13
- <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('field_width') ) ?>" id="frm_field_width" value="<?php echo esc_attr( $style->post_content['field_width'] ) ?>" />
14
  </div>
15
 
16
  <div class="clear"></div>
17
  <p class="frm_no_bottom_margin">
18
- <label><input type="checkbox" name="<?php echo esc_attr( $frm_style->get_field_name('auto_width') ) ?>" id="frm_auto_width" value="1" <?php checked( $style->post_content['auto_width'], 1 ) ?> />
19
  <?php esc_html_e( 'Automatic Width for drop-down fields', 'formidable' ) ?></label>
20
  </p>
21
 
22
  <div class="field-group clearfix">
23
  <label><?php esc_html_e( 'Padding', 'formidable' ) ?></label>
24
- <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('field_pad') ) ?>" id="frm_field_pad" value="<?php echo esc_attr( $style->post_content['field_pad'] ) ?>" />
25
  </div>
26
 
27
  <div class="field-group clearfix">
28
  <label><?php esc_html_e( 'Margin', 'formidable' ) ?></label>
29
- <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('field_margin') ) ?>" id="frm_field_margin" value="<?php echo esc_attr( $style->post_content['field_margin'] ) ?>" />
30
  </div>
31
 
32
  <div class="field-group clearfix">
33
  <label><?php esc_html_e( 'Corners', 'formidable' ) ?> <span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'Formidable uses CSS3 border-radius for corner rounding, which is not currently supported by Internet Explorer.', 'formidable' ) ?>" ></span></label>
34
- <input type="text" value="<?php echo esc_attr( $style->post_content['border_radius'] ) ?>" name="<?php echo esc_attr( $frm_style->get_field_name('border_radius') ) ?>" id="frm_border_radius" />
35
  </div>
36
 
37
  <div class="field-group clearfix frm-first-row">
38
  <label><?php esc_html_e( 'Weight', 'formidable' ) ?></label>
39
- <select name="<?php echo esc_attr( $frm_style->get_field_name('field_weight') ) ?>" id="frm_field_weight">
40
  <?php foreach ( FrmStyle::get_bold_options() as $value => $name ) { ?>
41
  <option value="<?php echo esc_attr( $value ) ?>" <?php selected( $style->post_content['field_weight'], $value ) ?>><?php echo esc_attr( $name ) ?></option>
42
  <?php } ?>
1
  <div class="field-group clearfix frm-first-row">
2
  <label><?php esc_html_e( 'Size', 'formidable' ) ?></label>
3
+ <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'field_font_size' ) ); ?>" id="frm_field_font_size" value="<?php echo esc_attr( $style->post_content['field_font_size'] ); ?>" />
4
  </div>
5
 
6
  <div class="field-group clearfix frm-first-row">
7
  <label><?php esc_html_e( 'Height', 'formidable' ) ?></label>
8
+ <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'field_height' ) ); ?>" id="frm_field_height" value="<?php echo esc_attr( $style->post_content['field_height'] ); ?>" />
9
  </div>
10
 
11
  <div class="field-group clearfix frm-first-row">
12
  <label><?php esc_html_e( 'Width', 'formidable' ) ?></label>
13
+ <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'field_width' ) ); ?>" id="frm_field_width" value="<?php echo esc_attr( $style->post_content['field_width'] ); ?>" />
14
  </div>
15
 
16
  <div class="clear"></div>
17
  <p class="frm_no_bottom_margin">
18
+ <label><input type="checkbox" name="<?php echo esc_attr( $frm_style->get_field_name( 'auto_width' ) ); ?>" id="frm_auto_width" value="1" <?php checked( $style->post_content['auto_width'], 1 ); ?> />
19
  <?php esc_html_e( 'Automatic Width for drop-down fields', 'formidable' ) ?></label>
20
  </p>
21
 
22
  <div class="field-group clearfix">
23
  <label><?php esc_html_e( 'Padding', 'formidable' ) ?></label>
24
+ <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'field_pad' ) ); ?>" id="frm_field_pad" value="<?php echo esc_attr( $style->post_content['field_pad'] ); ?>" />
25
  </div>
26
 
27
  <div class="field-group clearfix">
28
  <label><?php esc_html_e( 'Margin', 'formidable' ) ?></label>
29
+ <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'field_margin' ) ); ?>" id="frm_field_margin" value="<?php echo esc_attr( $style->post_content['field_margin'] ); ?>" />
30
  </div>
31
 
32
  <div class="field-group clearfix">
33
  <label><?php esc_html_e( 'Corners', 'formidable' ) ?> <span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'Formidable uses CSS3 border-radius for corner rounding, which is not currently supported by Internet Explorer.', 'formidable' ) ?>" ></span></label>
34
+ <input type="text" value="<?php echo esc_attr( $style->post_content['border_radius'] ); ?>" name="<?php echo esc_attr( $frm_style->get_field_name( 'border_radius' ) ); ?>" id="frm_border_radius" />
35
  </div>
36
 
37
  <div class="field-group clearfix frm-first-row">
38
  <label><?php esc_html_e( 'Weight', 'formidable' ) ?></label>
39
+ <select name="<?php echo esc_attr( $frm_style->get_field_name( 'field_weight' ) ); ?>" id="frm_field_weight">
40
  <?php foreach ( FrmStyle::get_bold_options() as $value => $name ) { ?>
41
  <option value="<?php echo esc_attr( $value ) ?>" <?php selected( $style->post_content['field_weight'], $value ) ?>><?php echo esc_attr( $name ) ?></option>
42
  <?php } ?>
classes/views/styles/_general.php CHANGED
@@ -1,5 +1,5 @@
1
  <p>
2
- <label><input type="checkbox" name="<?php echo esc_attr( $frm_style->get_field_name('center_form') ) ?>" id="frm_center_form" value="1" <?php checked($style->post_content['center_form'], 1) ?> />
3
  <?php esc_html_e( 'Center form on page', 'formidable' ) ?> <span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'This will center your form on the page where it is published if the form width is less than the available width on the page.', 'formidable' ) ?>" ></span>
4
  </label>
5
  </p>
@@ -21,37 +21,37 @@
21
 
22
  <div class="field-group clearfix frm-first-row">
23
  <label><?php esc_html_e( 'Max Width', 'formidable' ) ?></label>
24
- <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('form_width') ) ?>" value="<?php echo esc_attr( $style->post_content['form_width'] ) ?>"/>
25
  </div>
26
 
27
  <div class="field-group clearfix frm-first-row">
28
  <label><?php esc_html_e( 'Background', 'formidable' ) ?></label>
29
- <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('fieldset_bg_color') ) ?>" id="frm_fieldset_bg_color" class="hex" value="<?php echo esc_attr( $style->post_content['fieldset_bg_color'] ) ?>" size="4" />
30
  </div>
31
 
32
  <div class="field-group field-group-border clearfix">
33
  <label><?php esc_html_e( 'Border', 'formidable' ) ?></label>
34
- <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('fieldset') ) ?>" id="frm_fieldset" value="<?php echo esc_attr( $style->post_content['fieldset'] ) ?>" size="4" />
35
  </div>
36
 
37
  <div class="field-group clearfix">
38
  <label><?php esc_html_e( 'Color', 'formidable' ) ?></label>
39
- <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('fieldset_color') ) ?>" id="frm_fieldset_color" class="hex" value="<?php echo esc_attr( $style->post_content['fieldset_color'] ) ?>" />
40
  </div>
41
 
42
  <div class="field-group clearfix">
43
  <label><?php esc_html_e( 'Padding', 'formidable' ) ?></label>
44
- <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('fieldset_padding') ) ?>" id="frm_fieldset_padding" value="<?php echo esc_attr( $style->post_content['fieldset_padding'] ) ?>" size="4" />
45
  </div>
46
 
47
  <div id="frm_gen_font_box" class="field-group clearfix">
48
  <label><?php esc_html_e( 'Font Family', 'formidable' ) ?></label>
49
- <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('font') ) ?>" id="frm_font" value="<?php echo esc_attr( $style->post_content['font'] ) ?>" class="frm_full_width" />
50
  </div>
51
 
52
  <div class="field-group clearfix frm-half">
53
  <label><?php esc_html_e( 'Direction', 'formidable' ) ?></label>
54
- <select name="<?php echo esc_attr( $frm_style->get_field_name('direction') ) ?>" id="frm_direction">
55
  <option value="ltr" <?php selected( $style->post_content['direction'], 'ltr' ); ?>>
56
  <?php esc_html_e( 'Left to Right', 'formidable' ) ?>
57
  </option>
@@ -63,7 +63,8 @@
63
 
64
  <div class="clear"></div>
65
  <p class="frm_no_bottom_margin">
66
- <label><input type="checkbox" name="<?php echo esc_attr( $frm_style->get_field_name('important_style') ) ?>" id="frm_important_style" value="1" <?php checked($style->post_content['important_style'], 1) ?> />
 
67
  <?php esc_html_e( 'Override theme styling', 'formidable' ) ?> <span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'This will add !important to many of the lines in the Formidable styling to make sure it will be used.', 'formidable' ) ?>" ></span>
68
  </label>
69
  </p>
1
  <p>
2
+ <label><input type="checkbox" name="<?php echo esc_attr( $frm_style->get_field_name( 'center_form' ) ); ?>" id="frm_center_form" value="1" <?php checked( $style->post_content['center_form'], 1 ); ?> />
3
  <?php esc_html_e( 'Center form on page', 'formidable' ) ?> <span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'This will center your form on the page where it is published if the form width is less than the available width on the page.', 'formidable' ) ?>" ></span>
4
  </label>
5
  </p>
21
 
22
  <div class="field-group clearfix frm-first-row">
23
  <label><?php esc_html_e( 'Max Width', 'formidable' ) ?></label>
24
+ <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'form_width' ) ); ?>" value="<?php echo esc_attr( $style->post_content['form_width'] ); ?>"/>
25
  </div>
26
 
27
  <div class="field-group clearfix frm-first-row">
28
  <label><?php esc_html_e( 'Background', 'formidable' ) ?></label>
29
+ <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'fieldset_bg_color' ) ); ?>" id="frm_fieldset_bg_color" class="hex" value="<?php echo esc_attr( $style->post_content['fieldset_bg_color'] ); ?>" size="4" />
30
  </div>
31
 
32
  <div class="field-group field-group-border clearfix">
33
  <label><?php esc_html_e( 'Border', 'formidable' ) ?></label>
34
+ <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'fieldset' ) ); ?>" id="frm_fieldset" value="<?php echo esc_attr( $style->post_content['fieldset'] ); ?>" size="4" />
35
  </div>
36
 
37
  <div class="field-group clearfix">
38
  <label><?php esc_html_e( 'Color', 'formidable' ) ?></label>
39
+ <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'fieldset_color' ) ); ?>" id="frm_fieldset_color" class="hex" value="<?php echo esc_attr( $style->post_content['fieldset_color'] ); ?>" />
40
  </div>
41
 
42
  <div class="field-group clearfix">
43
  <label><?php esc_html_e( 'Padding', 'formidable' ) ?></label>
44
+ <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'fieldset_padding' ) ); ?>" id="frm_fieldset_padding" value="<?php echo esc_attr( $style->post_content['fieldset_padding'] ); ?>" size="4" />
45
  </div>
46
 
47
  <div id="frm_gen_font_box" class="field-group clearfix">
48
  <label><?php esc_html_e( 'Font Family', 'formidable' ) ?></label>
49
+ <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'font' ) ); ?>" id="frm_font" value="<?php echo esc_attr( $style->post_content['font'] ); ?>" class="frm_full_width" />
50
  </div>
51
 
52
  <div class="field-group clearfix frm-half">
53
  <label><?php esc_html_e( 'Direction', 'formidable' ) ?></label>
54
+ <select name="<?php echo esc_attr( $frm_style->get_field_name( 'direction' ) ); ?>" id="frm_direction">
55
  <option value="ltr" <?php selected( $style->post_content['direction'], 'ltr' ); ?>>
56
  <?php esc_html_e( 'Left to Right', 'formidable' ) ?>
57
  </option>
63
 
64
  <div class="clear"></div>
65
  <p class="frm_no_bottom_margin">
66
+ <label>
67
+ <input type="checkbox" name="<?php echo esc_attr( $frm_style->get_field_name( 'important_style' ) ); ?>" id="frm_important_style" value="1" <?php checked( $style->post_content['important_style'], 1 ); ?> />
68
  <?php esc_html_e( 'Override theme styling', 'formidable' ) ?> <span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'This will add !important to many of the lines in the Formidable styling to make sure it will be used.', 'formidable' ) ?>" ></span>
69
  </label>
70
  </p>
classes/views/styles/custom_css.php CHANGED
@@ -1,6 +1,6 @@
1
  <div class="nav-menus-php">
2
  <div class="wrap">
3
- <?php FrmStylesHelper::style_menu('custom_css'); ?>
4
 
5
  <p><?php esc_html_e( 'You can add custom css here or in your theme style.css', 'formidable' ) ?></p>
6
 
@@ -8,13 +8,13 @@
8
 
9
  <form method="post">
10
  <input type="hidden" name="ID" value="<?php echo esc_attr( $style->ID ) ?>" />
11
- <input type="hidden" name="<?php echo esc_attr( $frm_style->get_field_name('post_title', '') ); ?>" value="<?php echo esc_attr( $style->post_title ) ?>" />
12
- <input type="hidden" name="<?php echo esc_attr( $frm_style->get_field_name('menu_order', '') ); ?>" value="<?php echo esc_attr( $style->menu_order ) ?>" />
13
  <input type="hidden" name="style_name" value="frm_style_<?php echo esc_attr( $style->post_name ) ?>" />
14
  <input type="hidden" name="frm_action" value="save_css" />
15
  <?php wp_nonce_field( 'frm_custom_css_nonce', 'frm_custom_css' ); ?>
16
 
17
- <textarea name="<?php echo esc_attr( $frm_style->get_field_name('custom_css') ) ?>" id="<?php echo esc_attr( $id ) ?>" class="hide-if-js"><?php echo FrmAppHelper::esc_textarea( $style->post_content['custom_css'] ) ?></textarea>
18
 
19
  <?php
20
  if ( ! empty( $settings ) && $id == 'frm_codemirror_box' ) {
@@ -32,7 +32,7 @@
32
  continue;
33
  }
34
  ?>
35
- <input type="hidden" value="<?php echo esc_attr($v) ?>" name="<?php echo esc_attr( $frm_style->get_field_name( $k ) ) ?>" />
36
  <?php
37
  }
38
  ?>
1
  <div class="nav-menus-php">
2
  <div class="wrap">
3
+ <?php FrmStylesHelper::style_menu( 'custom_css' ); ?>
4
 
5
  <p><?php esc_html_e( 'You can add custom css here or in your theme style.css', 'formidable' ) ?></p>
6
 
8
 
9
  <form method="post">
10
  <input type="hidden" name="ID" value="<?php echo esc_attr( $style->ID ) ?>" />
11
+ <input type="hidden" name="<?php echo esc_attr( $frm_style->get_field_name( 'post_title', '' ) ); ?>" value="<?php echo esc_attr( $style->post_title ); ?>" />
12
+ <input type="hidden" name="<?php echo esc_attr( $frm_style->get_field_name( 'menu_order', '' ) ); ?>" value="<?php echo esc_attr( $style->menu_order ); ?>" />
13
  <input type="hidden" name="style_name" value="frm_style_<?php echo esc_attr( $style->post_name ) ?>" />
14
  <input type="hidden" name="frm_action" value="save_css" />
15
  <?php wp_nonce_field( 'frm_custom_css_nonce', 'frm_custom_css' ); ?>
16
 
17
+ <textarea name="<?php echo esc_attr( $frm_style->get_field_name( 'custom_css' ) ); ?>" id="<?php echo esc_attr( $id ); ?>" class="hide-if-js"><?php echo FrmAppHelper::esc_textarea( $style->post_content['custom_css'] ); ?></textarea>
18
 
19
  <?php
20
  if ( ! empty( $settings ) && $id == 'frm_codemirror_box' ) {
32
  continue;
33
  }
34
  ?>
35
+ <input type="hidden" value="<?php echo esc_attr( $v ); ?>" name="<?php echo esc_attr( $frm_style->get_field_name( $k ) ); ?>" />
36
  <?php
37
  }
38
  ?>
classes/views/styles/manage.php CHANGED
@@ -33,7 +33,7 @@
33
  ?>
34
  <tr id="menu-locations-row">
35
  <td class="menu-location-title">
36
- <strong><?php echo esc_html( empty( $form->name ) ? __( '(no title)') : $form->name ) ?></strong>
37
  </td>
38
  <td class="menu-location-menus">
39
  <input type="hidden" name="prev_style[<?php echo esc_attr( $form->id ) ?>]" value="<?php echo esc_attr( $this_style ) ?>" />
33
  ?>
34
  <tr id="menu-locations-row">
35
  <td class="menu-location-title">
36
+ <strong><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : $form->name ); ?></strong>
37
  </td>
38
  <td class="menu-location-menus">
39
  <input type="hidden" name="prev_style[<?php echo esc_attr( $form->id ) ?>]" value="<?php echo esc_attr( $this_style ) ?>" />
classes/views/xml/forms_xml.php CHANGED
@@ -13,16 +13,16 @@ while ( $next_set = array_splice( $item_ids, 0, 20 ) ) {
13
  ?>
14
  <form>
15
  <id><?php echo absint( $form->id ) ?></id>
16
- <form_key><?php echo FrmXMLHelper::cdata($form->form_key) ?></form_key>
17
- <name><?php echo FrmXMLHelper::cdata($form->name) ?></name>
18
- <description><?php echo FrmXMLHelper::cdata($form->description) ?></description>
19
  <created_at><?php echo esc_html( $form->created_at ) ?></created_at>
20
  <logged_in><?php echo esc_html( $form->logged_in ) ?></logged_in>
21
  <is_template><?php echo esc_html( $form->is_template ) ?></is_template>
22
  <default_template><?php echo esc_html( $form->default_template ) ?></default_template>
23
  <editable><?php echo esc_html( $form->editable ) ?></editable>
24
- <options><?php echo FrmXMLHelper::prepare_form_options_for_export($form->options) ?></options>
25
- <status><?php echo FrmXMLHelper::cdata($form->status) ?></status>
26
  <parent_form_id><?php echo esc_html( $form->parent_form_id ) ?></parent_form_id>
27
  <?php
28
 
@@ -32,16 +32,16 @@ while ( $next_set = array_splice( $item_ids, 0, 20 ) ) {
32
  ?>
33
  <field>
34
  <id><?php echo absint( $field->id ) ?></id>
35
- <field_key><?php echo FrmXMLHelper::cdata($field->field_key) ?></field_key>
36
- <name><?php echo FrmXMLHelper::cdata($field->name) ?></name>
37
- <description><?php echo FrmXMLHelper::cdata($field->description) ?></description>
38
- <type><?php echo FrmXMLHelper::cdata($field->type) ?></type>
39
- <default_value><?php echo FrmXMLHelper::cdata($field->default_value) ?></default_value>
40
  <field_order><?php echo absint( $field->field_order ) ?></field_order>
41
  <form_id><?php echo absint( $field->form_id ) ?></form_id>
42
  <required><?php echo absint( $field->required ) ?></required>
43
- <options><?php echo FrmXMLHelper::cdata($field->options) ?></options>
44
- <field_options><?php echo FrmXMLHelper::cdata($field->field_options) ?></field_options>
45
  </field>
46
  <?php } ?>
47
  </form>
13
  ?>
14
  <form>
15
  <id><?php echo absint( $form->id ) ?></id>
16
+ <form_key><?php echo FrmXMLHelper::cdata( $form->form_key ); ?></form_key>
17
+ <name><?php echo FrmXMLHelper::cdata( $form->name ); ?></name>
18
+ <description><?php echo FrmXMLHelper::cdata( $form->description ); ?></description>
19
  <created_at><?php echo esc_html( $form->created_at ) ?></created_at>
20
  <logged_in><?php echo esc_html( $form->logged_in ) ?></logged_in>
21
  <is_template><?php echo esc_html( $form->is_template ) ?></is_template>
22
  <default_template><?php echo esc_html( $form->default_template ) ?></default_template>
23
  <editable><?php echo esc_html( $form->editable ) ?></editable>
24
+ <options><?php echo FrmXMLHelper::prepare_form_options_for_export( $form->options ); ?></options>
25
+ <status><?php echo FrmXMLHelper::cdata( $form->status ); ?></status>
26
  <parent_form_id><?php echo esc_html( $form->parent_form_id ) ?></parent_form_id>
27
  <?php
28
 
32
  ?>
33
  <field>
34
  <id><?php echo absint( $field->id ) ?></id>
35
+ <field_key><?php echo FrmXMLHelper::cdata( $field->field_key ); ?></field_key>
36
+ <name><?php echo FrmXMLHelper::cdata( $field->name ); ?></name>
37
+ <description><?php echo FrmXMLHelper::cdata( $field->description ); ?></description>
38
+ <type><?php echo FrmXMLHelper::cdata( $field->type ); ?></type>
39
+ <default_value><?php echo FrmXMLHelper::cdata( $field->default_value ); ?></default_value>
40
  <field_order><?php echo absint( $field->field_order ) ?></field_order>
41
  <form_id><?php echo absint( $field->form_id ) ?></form_id>
42
  <required><?php echo absint( $field->required ) ?></required>
43
+ <options><?php echo FrmXMLHelper::cdata( $field->options ); ?></options>
44
+ <field_options><?php echo FrmXMLHelper::cdata( $field->field_options ); ?></field_options>
45
  </field>
46
  <?php } ?>
47
  </form>
classes/views/xml/import_form.php CHANGED
@@ -17,7 +17,7 @@
17
  <p>
18
  <label>
19
  <?php echo esc_html( apply_filters( 'frm_upload_instructions2', __( 'Choose a Formidable XML file', 'formidable' ) ) ) ?>
20
- (<?php echo esc_html( sprintf( __( 'Maximum size: %s', 'formidable' ), ini_get( 'upload_max_filesize') ) ) ?>)
21
  </label>
22
  <input type="file" name="frm_import_file" size="25" />
23
  </p>
17
  <p>
18
  <label>
19
  <?php echo esc_html( apply_filters( 'frm_upload_instructions2', __( 'Choose a Formidable XML file', 'formidable' ) ) ) ?>
20
+ (<?php echo esc_html( sprintf( __( 'Maximum size: %s', 'formidable' ), ini_get( 'upload_max_filesize' ) ) ); ?>)
21
  </label>
22
  <input type="file" name="frm_import_file" size="25" />
23
  </p>
classes/widgets/FrmShowForm.php CHANGED
@@ -4,7 +4,7 @@ class FrmShowForm extends WP_Widget {
4
 
5
  public function __construct() {
6
  $widget_ops = array( 'description' => __( 'Display a Formidable Form', 'formidable' ) );
7
- parent::__construct('frm_show_form', __( 'Formidable Form', 'formidable' ), $widget_ops);
8
  }
9
 
10
  public function widget( $args, $instance ) {
4
 
5
  public function __construct() {
6
  $widget_ops = array( 'description' => __( 'Display a Formidable Form', 'formidable' ) );
7
+ parent::__construct( 'frm_show_form', __( 'Formidable Form', 'formidable' ), $widget_ops );
8
  }
9
 
10
  public function widget( $args, $instance ) {
css/_single_theme.css.php CHANGED
@@ -61,7 +61,7 @@ $arrow_icons = FrmStylesHelper::arrow_icons();
61
  font-weight:<?php echo esc_html( $section_weight . $important ) ?>;
62
  color:<?php echo esc_html( $section_color . $important ) ?>;
63
  border:none<?php echo esc_html( $important ) ?>;
64
- border<?php echo esc_html( $section_border_loc ) ?>:<?php echo esc_html( $section_border_width . ' ' . $section_border_style . ' #' . $section_border_color . $important ) ?>;
65
  background-color:<?php echo esc_html( $section_bg_color . $important ); ?>
66
  }
67
 
@@ -245,7 +245,7 @@ if ( '' === $field_height || 'auto' === $field_height ) {
245
  }
246
 
247
  .<?php echo esc_html( $style_class ) ?> .frm_required{
248
- color:#<?php echo esc_html( $required_color . $important ); ?>;
249
  font-weight:<?php echo esc_html( $required_weight . $important ); ?>;
250
  }
251
 
@@ -368,9 +368,9 @@ if ( ! empty( $important ) ) {
368
  .<?php echo esc_html( $style_class ) ?> input[readonly],
369
  .<?php echo esc_html( $style_class ) ?> select[readonly],
370
  .<?php echo esc_html( $style_class ) ?> textarea[readonly]{
371
- background-color:#<?php echo esc_html( $bg_color_disabled . $important ); ?>;
372
  color:<?php echo esc_html( $text_color_disabled . $important ) ?>;
373
- border-color:#<?php echo esc_html( $border_color_disabled . $important ) ?>;
374
  }
375
 
376
  /* These do not work if they are combined */
@@ -418,8 +418,8 @@ if ( ! empty( $important ) ) {
418
  .frm_form_fields_active_style,
419
  .<?php echo esc_html( $style_class ) ?> .chosen-container-single.chosen-container-active .chosen-single,
420
  .<?php echo esc_html( $style_class ) ?> .chosen-container-active .chosen-choices{
421
- background-color:#<?php echo esc_html( $bg_color_active . $important ); ?>;
422
- border-color:#<?php echo esc_html( $border_color_active . $important ) ?>;
423
  <?php if ( isset( $remove_box_shadow_active ) && $remove_box_shadow_active ) { ?>
424
  box-shadow:none;
425
  <?php } else { ?>
@@ -464,9 +464,9 @@ if ( ! empty( $important ) ) {
464
  box-sizing:border-box;
465
  -ms-box-sizing:border-box;
466
  <?php if ( ! empty( $submit_shadow_color ) ) { ?>
467
- -moz-box-shadow:0 1px 1px #<?php echo esc_html( $submit_shadow_color ); ?>;
468
- -webkit-box-shadow:0 1px 1px #<?php echo esc_html( $submit_shadow_color ); ?>;
469
- box-shadow:0 1px 1px #<?php echo esc_html( $submit_shadow_color ); ?>;
470
  <?php } ?>
471
  margin:<?php echo esc_html( $submit_margin ) ?>;
472
  margin-left:0;
@@ -563,22 +563,6 @@ if ( ! empty( $important ) ) {
563
  clear:both;
564
  }
565
 
566
- <?php if ( $check_align === 'block' ) { ?>
567
- .<?php echo esc_html( $style_class ) ?> .frm_checkbox label{
568
- display: block;
569
- padding-left: 20px;
570
- text-indent: -20px;
571
- }
572
- <?php } ?>
573
-
574
- <?php if ( $radio_align === 'block' ) { ?>
575
- .<?php echo esc_html( $style_class ) ?> .frm_radio label{
576
- display: block;
577
- padding-left: 20px;
578
- text-indent: -20px;
579
- }
580
- <?php } ?>
581
-
582
  .<?php echo esc_html( $style_class ) ?> .frm_radio{
583
  display:<?php echo esc_html( $radio_align . $important ) ?>;
584
  }
@@ -628,15 +612,15 @@ if ( ! empty( $important ) ) {
628
  .<?php echo esc_html( $style_class ) ?> .frm_blank_field .chosen-container-multi .chosen-choices,
629
  .<?php echo esc_html( $style_class ) ?> .frm_blank_field .chosen-container-single .chosen-single,
630
  .<?php echo esc_html( $style_class ) ?> .frm_form_field :invalid{
631
- color:#<?php echo esc_html( $text_color_error . $important ) ?>;
632
- background-color:#<?php echo esc_html( $bg_color_error . $important ); ?>;
633
- border-color:#<?php echo esc_html( $border_color_error . $important ) ?>;
634
  border-width:<?php echo esc_html( $border_width_error . $important ) ?>;
635
  border-style:<?php echo esc_html( $border_style_error . $important ) ?>;
636
  }
637
 
638
  .<?php echo esc_html( $style_class ) ?> .frm_blank_field .sigWrapper{
639
- border-color:#<?php echo esc_html( $border_color_error ) ?> !important;
640
  }
641
 
642
  .<?php echo esc_html( $style_class ) ?> .frm_error{
@@ -645,12 +629,12 @@ if ( ! empty( $important ) ) {
645
 
646
  .<?php echo esc_html( $style_class ) ?> .frm_blank_field label,
647
  .<?php echo esc_html( $style_class ) ?> .frm_error{
648
- color:#<?php echo esc_html( $border_color_error . $important ) ?>;
649
  }
650
 
651
  .<?php echo esc_html( $style_class ) ?> .frm_error_style{
652
  background-color:<?php echo esc_html( $error_bg . $important ); ?>;
653
- border:1px solid #<?php echo esc_html( $error_border . $important ) ?>;
654
  border-radius:<?php echo esc_html( $border_radius . $important ) ?>;
655
  color: <?php echo esc_html( $error_text . $important ) ?>;
656
  font-size:<?php echo esc_html( $error_font_size . $important ) ?>;
@@ -660,14 +644,14 @@ if ( ! empty( $important ) ) {
660
 
661
  .<?php echo esc_html( $style_class ) ?> .frm_message,
662
  .frm_success_style{
663
- border:1px solid #<?php echo esc_html( $success_border_color ) ?>;
664
  background-color:<?php echo esc_html( $success_bg_color . $important ); ?>;
665
- color:#<?php echo esc_html( $success_text_color . $important ) ?>;
666
  border-radius:<?php echo esc_html( $border_radius . $important ) ?>;
667
  }
668
 
669
  .<?php echo esc_html( $style_class ) ?> .frm_message p{
670
- color:#<?php echo esc_html( $success_text_color . $important ) ?>;
671
  }
672
 
673
  .<?php echo esc_html( $style_class ) ?> .frm_message{
@@ -712,7 +696,7 @@ if ( ! empty( $important ) ) {
712
  .<?php echo esc_html( $style_class ) ?> .frm_grid_first.frm_blank_field,
713
  .<?php echo esc_html( $style_class ) ?> .frm_grid_odd.frm_blank_field{
714
  background-color:<?php echo esc_html( $error_bg . $important ); ?>;
715
- border-color:#<?php echo esc_html( $error_border ) ?>;
716
  }
717
 
718
  .<?php echo esc_html( $style_class ) ?> .frm_grid_first,
@@ -721,7 +705,7 @@ if ( ! empty( $important ) ) {
721
  }
722
 
723
  .<?php echo esc_html( $style_class ) ?> .frm_grid{
724
- background-color:#<?php echo esc_html( $bg_color_active . $important ); ?>;
725
  }
726
 
727
  .<?php echo esc_html( $style_class ) ?> .frm_form_field.frm_html_scroll_box{
61
  font-weight:<?php echo esc_html( $section_weight . $important ) ?>;
62
  color:<?php echo esc_html( $section_color . $important ) ?>;
63
  border:none<?php echo esc_html( $important ) ?>;
64
+ border<?php echo esc_html( $section_border_loc ); ?>:<?php echo esc_html( $section_border_width . ' ' . $section_border_style . ' ' . $section_border_color . $important ); ?>;
65
  background-color:<?php echo esc_html( $section_bg_color . $important ); ?>
66
  }
67
 
245
  }
246
 
247
  .<?php echo esc_html( $style_class ) ?> .frm_required{
248
+ color:<?php echo esc_html( $required_color . $important ); ?>;
249
  font-weight:<?php echo esc_html( $required_weight . $important ); ?>;
250
  }
251
 
368
  .<?php echo esc_html( $style_class ) ?> input[readonly],
369
  .<?php echo esc_html( $style_class ) ?> select[readonly],
370
  .<?php echo esc_html( $style_class ) ?> textarea[readonly]{
371
+ background-color:<?php echo esc_html( $bg_color_disabled . $important ); ?>;
372
  color:<?php echo esc_html( $text_color_disabled . $important ) ?>;
373
+ border-color:<?php echo esc_html( $border_color_disabled . $important ) ?>;
374
  }
375
 
376
  /* These do not work if they are combined */
418
  .frm_form_fields_active_style,
419
  .<?php echo esc_html( $style_class ) ?> .chosen-container-single.chosen-container-active .chosen-single,
420
  .<?php echo esc_html( $style_class ) ?> .chosen-container-active .chosen-choices{
421
+ background-color:<?php echo esc_html( $bg_color_active . $important ); ?>;
422
+ border-color:<?php echo esc_html( $border_color_active . $important ); ?>;
423
  <?php if ( isset( $remove_box_shadow_active ) && $remove_box_shadow_active ) { ?>
424
  box-shadow:none;
425
  <?php } else { ?>
464
  box-sizing:border-box;
465
  -ms-box-sizing:border-box;
466
  <?php if ( ! empty( $submit_shadow_color ) ) { ?>
467
+ -moz-box-shadow:0 1px 1px <?php echo esc_html( $submit_shadow_color ); ?>;
468
+ -webkit-box-shadow:0 1px 1px <?php echo esc_html( $submit_shadow_color ); ?>;
469
+ box-shadow:0 1px 1px <?php echo esc_html( $submit_shadow_color ); ?>;
470
  <?php } ?>
471
  margin:<?php echo esc_html( $submit_margin ) ?>;
472
  margin-left:0;
563
  clear:both;
564
  }
565
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
566
  .<?php echo esc_html( $style_class ) ?> .frm_radio{
567
  display:<?php echo esc_html( $radio_align . $important ) ?>;
568
  }
612
  .<?php echo esc_html( $style_class ) ?> .frm_blank_field .chosen-container-multi .chosen-choices,
613
  .<?php echo esc_html( $style_class ) ?> .frm_blank_field .chosen-container-single .chosen-single,
614
  .<?php echo esc_html( $style_class ) ?> .frm_form_field :invalid{
615
+ color:<?php echo esc_html( $text_color_error . $important ); ?>;
616
+ background-color:<?php echo esc_html( $bg_color_error . $important ); ?>;
617
+ border-color:<?php echo esc_html( $border_color_error . $important ); ?>;
618
  border-width:<?php echo esc_html( $border_width_error . $important ) ?>;
619
  border-style:<?php echo esc_html( $border_style_error . $important ) ?>;
620
  }
621
 
622
  .<?php echo esc_html( $style_class ) ?> .frm_blank_field .sigWrapper{
623
+ border-color:<?php echo esc_html( $border_color_error ); ?> !important;
624
  }
625
 
626
  .<?php echo esc_html( $style_class ) ?> .frm_error{
629
 
630
  .<?php echo esc_html( $style_class ) ?> .frm_blank_field label,
631
  .<?php echo esc_html( $style_class ) ?> .frm_error{
632
+ color:<?php echo esc_html( $border_color_error . $important ); ?>;
633
  }
634
 
635
  .<?php echo esc_html( $style_class ) ?> .frm_error_style{
636
  background-color:<?php echo esc_html( $error_bg . $important ); ?>;
637
+ border:1px solid <?php echo esc_html( $error_border . $important ); ?>;
638
  border-radius:<?php echo esc_html( $border_radius . $important ) ?>;
639
  color: <?php echo esc_html( $error_text . $important ) ?>;
640
  font-size:<?php echo esc_html( $error_font_size . $important ) ?>;
644
 
645
  .<?php echo esc_html( $style_class ) ?> .frm_message,
646
  .frm_success_style{
647
+ border:1px solid <?php echo esc_html( $success_border_color ); ?>;
648
  background-color:<?php echo esc_html( $success_bg_color . $important ); ?>;
649
+ color:<?php echo esc_html( $success_text_color . $important ); ?>;
650
  border-radius:<?php echo esc_html( $border_radius . $important ) ?>;
651
  }
652
 
653
  .<?php echo esc_html( $style_class ) ?> .frm_message p{
654
+ color:<?php echo esc_html( $success_text_color . $important ); ?>;
655
  }
656
 
657
  .<?php echo esc_html( $style_class ) ?> .frm_message{
696
  .<?php echo esc_html( $style_class ) ?> .frm_grid_first.frm_blank_field,
697
  .<?php echo esc_html( $style_class ) ?> .frm_grid_odd.frm_blank_field{
698
  background-color:<?php echo esc_html( $error_bg . $important ); ?>;
699
+ border-color:<?php echo esc_html( $error_border ); ?>;
700
  }
701
 
702
  .<?php echo esc_html( $style_class ) ?> .frm_grid_first,
705
  }
706
 
707
  .<?php echo esc_html( $style_class ) ?> .frm_grid{
708
+ background-color:<?php echo esc_html( $bg_color_active . $important ); ?>;
709
  }
710
 
711
  .<?php echo esc_html( $style_class ) ?> .frm_form_field.frm_html_scroll_box{
css/custom_theme.css.php CHANGED
@@ -424,7 +424,7 @@ table.form_results.with_frm_style tr.frm_even,
424
 
425
  table.form_results.with_frm_style tr.frm_odd,
426
  .frm-grid .frm_odd{
427
- background-color:#<?php echo esc_html( $defaults['bg_color_active'] ) ?>;
428
  }
429
 
430
  .frm_collapse .ui-icon{
@@ -587,7 +587,7 @@ select.frm_loading_lookup{
587
  }
588
 
589
  .frm_grid{
590
- background-color:#<?php echo esc_html( $defaults['bg_color_active'] ) ?>;
591
  }
592
 
593
  .frm_grid .frm_primary_label,
424
 
425
  table.form_results.with_frm_style tr.frm_odd,
426
  .frm-grid .frm_odd{
427
+ background-color:<?php echo esc_html( $defaults['bg_color_active'] ); ?>;
428
  }
429
 
430
  .frm_collapse .ui-icon{
587
  }
588
 
589
  .frm_grid{
590
+ background-color:<?php echo esc_html( $defaults['bg_color_active'] ); ?>;
591
  }
592
 
593
  .frm_grid .frm_primary_label,
css/frm_admin.css CHANGED
@@ -2768,6 +2768,21 @@ iframe#dyncontent_ifr{min-height:150px;}
2768
  width:100%;
2769
  }
2770
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2771
  /*form field groups*/
2772
  .accordion-container .field-group {
2773
  float: left;
@@ -2845,53 +2860,6 @@ iframe#dyncontent_ifr{min-height:150px;}
2845
  }
2846
  .global-font .field-group input[type="text"]{width:auto;}
2847
 
2848
- /*pickers*/
2849
- #picker {
2850
- position: absolute;
2851
- left: 0;
2852
- top: auto;
2853
- width: 200px;
2854
- }
2855
-
2856
- /*Farbtastic styles*/
2857
- .farbtastic {
2858
- position: relative;
2859
- background: #555;
2860
- border: 1px solid #aaa;
2861
- top: 1px;
2862
- left: 0;
2863
- z-index: 99999999;
2864
- }
2865
- .farbtastic * {
2866
- position: absolute;
2867
- cursor: crosshair;
2868
- }
2869
- .farbtastic, .farbtastic .wheel {
2870
- width: 195px;
2871
- height: 195px;
2872
- }
2873
- .farbtastic .color, .farbtastic .overlay {
2874
- top: 47px;
2875
- left: 47px;
2876
- width: 101px;
2877
- height: 101px;
2878
- }
2879
- .farbtastic .wheel {
2880
- background: url(../images/styler/wheel.png) no-repeat;
2881
- width: 195px;
2882
- height: 195px;
2883
- }
2884
- .farbtastic .overlay {
2885
- background: url(../images/styler/mask.png) no-repeat;
2886
- }
2887
- .farbtastic .marker {
2888
- width: 17px;
2889
- height: 17px;
2890
- margin: -8px 0 0 -8px;
2891
- overflow: hidden;
2892
- background: url(../images/styler/marker.png) no-repeat;
2893
- }
2894
-
2895
  /* RTL */
2896
  .rtl .frm-ltr{
2897
  direction:rtl;
2768
  width:100%;
2769
  }
2770
 
2771
+ #frm_styling_form .wp-picker-container .wp-color-result.button{
2772
+ max-width:100%;
2773
+ overflow: hidden;
2774
+ }
2775
+
2776
+ .wp-picker-holder{
2777
+ position:absolute;
2778
+ z-index: 999;
2779
+ }
2780
+
2781
+ #frm_styling_form div.tabs-panel{
2782
+ padding-left:5px;
2783
+ padding-right:5px;
2784
+ }
2785
+
2786
  /*form field groups*/
2787
  .accordion-container .field-group {
2788
  float: left;
2860
  }
2861
  .global-font .field-group input[type="text"]{width:auto;}
2862
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2863
  /* RTL */
2864
  .rtl .frm-ltr{
2865
  direction:rtl;
formidable.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Formidable Forms
4
  Description: Quickly and easily create drag-and-drop forms
5
- Version: 3.01
6
  Plugin URI: https://formidableforms.com/
7
  Author URI: https://formidableforms.com/
8
  Author: Strategy11
@@ -31,7 +31,7 @@ function load_formidable_forms() {
31
  'pro_is_authorized' => false,
32
  );
33
 
34
- $frm_path = dirname(__FILE__);
35
  if ( file_exists( $frm_path . '/pro/formidable-pro.php' ) ) {
36
  include( $frm_path . '/pro/formidable-pro.php' );
37
  }
@@ -41,11 +41,11 @@ function load_formidable_forms() {
41
 
42
  // if __autoload is active, put it on the spl_autoload stack
43
  if ( is_array( spl_autoload_functions() ) && in_array( '__autoload', spl_autoload_functions() ) ) {
44
- spl_autoload_register('__autoload');
45
  }
46
 
47
  // Add the autoloader
48
- spl_autoload_register('frm_forms_autoloader');
49
 
50
  function frm_forms_autoloader( $class_name ) {
51
  // Only load Frm classes here
2
  /*
3
  Plugin Name: Formidable Forms
4
  Description: Quickly and easily create drag-and-drop forms
5
+ Version: 3.01.01
6
  Plugin URI: https://formidableforms.com/
7
  Author URI: https://formidableforms.com/
8
  Author: Strategy11
31
  'pro_is_authorized' => false,
32
  );
33
 
34
+ $frm_path = dirname( __FILE__ );
35
  if ( file_exists( $frm_path . '/pro/formidable-pro.php' ) ) {
36
  include( $frm_path . '/pro/formidable-pro.php' );
37
  }
41
 
42
  // if __autoload is active, put it on the spl_autoload stack
43
  if ( is_array( spl_autoload_functions() ) && in_array( '__autoload', spl_autoload_functions() ) ) {
44
+ spl_autoload_register( '__autoload' );
45
  }
46
 
47
  // Add the autoloader
48
+ spl_autoload_register( 'frm_forms_autoloader' );
49
 
50
  function frm_forms_autoloader( $class_name ) {
51
  // Only load Frm classes here
images/styler/marker.png DELETED
Binary file
images/styler/mask.png DELETED
Binary file
images/styler/wheel.png DELETED
Binary file
js/formidable.js CHANGED
@@ -408,7 +408,9 @@ function frmFrontFormJS(){
408
  }
409
  var formID = jQuery(object).find('input[name="form_id"]').val();
410
  response.content = response.content.replace(/ frm_pro_form /g, ' frm_pro_form frm_no_hide ');
411
- jQuery(object).closest( '.frm_forms' ).replaceWith( response.content );
 
 
412
 
413
  addUrlParam(response);
414
 
@@ -508,6 +510,14 @@ function frmFrontFormJS(){
508
  }
509
  }
510
 
 
 
 
 
 
 
 
 
511
  function addUrlParam(response){
512
  if ( history.pushState && typeof response.page !== 'undefined' ) {
513
  var url = addQueryVar('frm_page', response.page);
408
  }
409
  var formID = jQuery(object).find('input[name="form_id"]').val();
410
  response.content = response.content.replace(/ frm_pro_form /g, ' frm_pro_form frm_no_hide ');
411
+ var replaceContent = jQuery( object ).closest( '.frm_forms' );
412
+ removeAddedScripts( replaceContent, formID );
413
+ replaceContent.replaceWith( response.content );
414
 
415
  addUrlParam(response);
416
 
510
  }
511
  }
512
 
513
+ function removeAddedScripts( formContainer, formID ) {
514
+ var endReplace = jQuery( '.frm_end_ajax_' + formID );
515
+ if ( endReplace.length ) {
516
+ formContainer.nextUntil( '.frm_end_ajax_' + formID ).remove();
517
+ endReplace.remove();
518
+ }
519
+ }
520
+
521
  function addUrlParam(response){
522
  if ( history.pushState && typeof response.page !== 'undefined' ) {
523
  var url = addQueryVar('frm_page', response.page);
js/formidable.min.js CHANGED
@@ -1,35 +1,35 @@
1
- function frmFrontFormJS(){function f(){var a=jQuery(this),b=a.closest(".frm_inside_container").find("label.frm_primary_label");0<a.val().length?b.addClass("frm_visible"):b.removeClass("frm_visible")}function e(a,b){var c="";c=a instanceof jQuery?a.attr("name"):a.name;if(""===c)return c=a instanceof jQuery?a.data("name"):a.getAttribute("data-name"),""!==c&&c?c:0;c=c.replace("item_meta[","").replace("[]","").split("]");if(1>c.length)return 0;c=c.filter(function(a){return""!==a});var d=c[0],h=!1;if(1===
2
- c.length)return d;if("[form"===c[1]||"[row_ids"===c[1])return 0;jQuery('input[name="item_meta['+d+'][form]"]').length&&(d=c[2].replace("[",""),h=!0);"other"===d&&(d=h?c[3].replace("[",""):c[1].replace("[",""));!0===b&&(d=d===c[0]?d+"-"+c[1].replace("[",""):d+"-"+c[0]+"-"+c[1].replace("[",""));return d}function k(a,b){var c=a.getAttribute("data-frmfile");if("hidden"===a.type&&null===c)return b;var d="",h="";if("checkbox"===a.type||"radio"===a.type)c=jQuery('input[name="'+a.name+'"]').closest(".frm_required_field").find("input:checked"),
3
- jQuery(c).each(function(){d=this.value});else if("file"===a.type||c)"undefined"===typeof c&&(c=e(a,!0),c=c.replace("file","")),"undefined"===typeof b[c]&&(d=n(c)),h=c;else{c=a.className;if(-1!==c.indexOf("frm_pos_none"))return b;d=jQuery(a).val();if(null===d)d="";else if("string"!==typeof d){h=d;d="";for(var l=0;l<h.length;l++)""!==h[l]&&(d=h[l])}h=-1===c.indexOf("frm_other_input")?e(a,!0):e(a,!1);-1!==c.indexOf("frm_time_select")&&(h=h.replace("-H","").replace("-m",""))}""===d&&(""===h&&(h=e(a,!0)),
4
- h in b||(b[h]=q(a,"data-reqmsg")));return b}function n(a){var b="";jQuery('input[name="file'+a+'"], input[name="file'+a+'[]"], input[name^="item_meta['+a+']"]').each(function(){""===b&&(b=this.value)});return b}function p(a,b,c){var d=a.value,h=e(a,!0);if(h in b)return b;var l=0===h.indexOf("conf_");if(""!==d||l){var g=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/i,f=q(a,"data-invmsg");""!==
5
- d&&!1===g.test(d)?(b[h]=f,l&&(b[h.replace("conf_","")]="")):l&&(a=a.name.replace("conf_",""),c.filter('[name="'+a+'"]').val()!==d&&(b[h]="",b[h.replace("conf_","")]=""))}return b}function v(a,b){var c=a.value;""!==c&&!1!==isNaN(c/1)&&(c=e(a,!0),c in b||(b[c]=q(a,"data-invmsg")));return b}function w(a,b){var c=a.value,d=q(a,"pattern");if(""!==d&&""!==c){var h=e(a,!0);h in b||(d=new RegExp("^"+d+"$","i"),!1===d.test(c)&&(b[h]=q(a,"data-invmsg")))}return b}function q(a,b){var c=a.getAttribute(b);null===
6
- c&&(c="");return c}function C(a,b){"undefined"===typeof b&&jQuery(a).find('input[name="frm_action"]').val();var c=jQuery(a).find(".frm_form_field");c.addClass("frm_doing_ajax");jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:jQuery(a).serialize()+"&action=frm_entries_"+b+"&nonce="+frm_js.nonce,success:function(b){var d={content:"",errors:{},pass:!1};null===b&&(b=d);b=b.replace(/^\s+|\s+$/g,"");b=0===b.indexOf("{")?jQuery.parseJSON(b):d;if("undefined"!==typeof b.redirect)jQuery(document).trigger("frmBeforeFormRedirect",
7
- [a,b]),window.location=b.redirect;else if(""!==b.content){t(jQuery(a));-1!=frm_js.offset&&frmFrontForm.scrollMsg(jQuery(a),!1);var l=jQuery(a).find('input[name="form_id"]').val();b.content=b.content.replace(/ frm_pro_form /g," frm_pro_form frm_no_hide ");jQuery(a).closest(".frm_forms").replaceWith(b.content);d=b;if(history.pushState&&"undefined"!==typeof d.page){var g=d.page;var f=encodeURI("frm_page");g=encodeURI(g);for(var e=document.location.search.substr(1).split("&"),k=e.length,m;k--;)if(m=e[k].split("="),
8
- m[0]==f){m[1]=g;e[k]=m.join("=");break}0>k&&(e[e.length]=[f,g].join("="));f=e.join("&");window.history.pushState({html:d.html},"","?"+f)}"function"===typeof frmThemeOverride_frmAfterSubmit&&(l=jQuery('input[name="frm_page_order_'+l+'"]').val(),d=jQuery(b.content).find('input[name="form_id"]').val(),frmThemeOverride_frmAfterSubmit(d,l,b.content,a));jQuery(b.content).find(".frm_message").length?jQuery(document).trigger("frmFormComplete",[a,b]):jQuery(document).trigger("frmPageChanged",[a,b])}else if(Object.keys(b.errors).length){t(jQuery(a),
9
- "enable");d=!0;x();f=!1;for(l in b.errors)g=jQuery(a).find("#frm_field_"+l+"_container"),g.length&&(g.is(":visible")||(e=g.closest(".frm_toggle_container"),e.length&&(e=e.prev(),e.hasClass("frm_trigger")||(e=e.prev(".frm_trigger")),e.click())),g.is(":visible")&&(u(g,l,b.errors),d=!1,g=jQuery(a).find("#frm_field_"+l+"_container .frm-g-recaptcha, #frm_field_"+l+"_container .g-recaptcha"),g.length&&(f=!0,g=g.data("rid"),jQuery().grecaptcha&&(g?grecaptcha.reset(g):grecaptcha.reset()))));jQuery(document).trigger("frmFormErrors",
10
- [a,b]);c.removeClass("frm_doing_ajax");y(a);!0!==f&&z(a,!1);d?a.submit():jQuery(a).prepend(b.error_message)}else D(a),z(a,!0),a.submit()},error:function(){jQuery(a).find('input[type="submit"], input[type="button"]').removeAttr("disabled");a.submit()}})}function u(a,b,c){a.length&&a.is(":visible")&&(a.addClass("frm_blank_field"),"function"===typeof frmThemeOverride_frmPlaceError?frmThemeOverride_frmPlaceError(b,c):a.append('<div class="frm_error">'+c[b]+"</div>"),jQuery(document).trigger("frmAddFieldError",
11
- [a,b,c]))}function x(){jQuery(".form-field").removeClass("frm_blank_field has-error");jQuery(".form-field .frm_error").replaceWith("");jQuery(".frm_error_style").remove()}function y(a){var b=jQuery(a).find(".frm_blank_field:first");b.length&&frmFrontForm.scrollMsg(b,a,!0)}function A(a){a.hasClass("frm_loading_form")||(a.addClass("frm_loading_form"),a.trigger("frmStartFormLoading"));a.find('input[type="submit"], input[type="button"], button[type="submit"]').attr("disabled","disabled")}function t(a,
12
- b,c){0<c||(a.removeClass("frm_loading_form"),a.trigger("frmEndFormLoading"),"enable"===b&&a.find('input[type="submit"], input[type="button"], button[type="submit"]').removeAttr("disabled"))}function D(a){var b=document.getElementById("frm_loading");null!==b&&(a=jQuery(a).find("input[type=file]").val(),"undefined"!==typeof a&&""!==a&&setTimeout(function(){jQuery(b).fadeIn("slow")},2E3))}function z(a,b){var c=jQuery(a).find(".frm-g-recaptcha, .g-recaptcha");c.length&&(!b||1>jQuery(a).find(".frm_next_page").length||
13
- 1>jQuery(a).find(".frm_next_page").val())&&c.closest(".frm_form_field").replaceWith('<input type="hidden" name="recaptcha_checked" value="'+frm_js.nonce+'">')}function E(){B(jQuery(this),"clear")}function F(){B(jQuery(this),"replace")}function B(a,b){var c=a.data("frmval").replace(/(\n|\r\n)/g,"\r");if(""===c||"undefined"===typeof c)return!1;var d=a.val().replace(/(\n|\r\n)/g,"\r");"replace"==b?""===d&&a.addClass("frm_default").val(c):d==c&&a.removeClass("frm_default").val("")}function G(){var a=
14
- jQuery(this),b=a.data("eid"),c=a.data("fid");a.append('<span class="spinner" style="display:inline"></span>');jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:{action:"frm_entries_send_email",entry_id:b,form_id:c,nonce:frm_js.nonce},success:function(b){a.replaceWith(b)}});return!1}function H(){var a=jQuery(this).data("frmconfirm");return confirm(a)}function I(){var a=jQuery(this).data("frmtoggle");jQuery(a).is(":visible")?jQuery(a).slideUp("fast"):jQuery(a).slideDown("fast");return!1}function J(){Array.prototype.indexOf||
15
- (Array.prototype.indexOf=function(a,b){var c=this.length>>>0,d=Number(b)||0;d=0>d?Math.ceil(d):Math.floor(d);for(0>d&&(d+=c);d<c;d++)if(d in this&&this[d]===a)return d;return-1})}function K(){"function"!==typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")})}function L(){Array.prototype.filter||(Array.prototype.filter=function(a,b){if(void 0===this||null===this)throw new TypeError;var c=Object(this),d=c.length>>>0;if("function"!==typeof a)throw new TypeError;
16
- for(var e=[],f=0;f<d;f++)if(f in c){var g=c[f];a.call(b,g,f,c)&&e.push(g)}return e})}function M(){Object.keys||(Object.keys=function(a){var b=[],c;for(c in a)a.hasOwnProperty(c)&&b.push(c);return b})}var r="",m=[];return{init:function(){jQuery(document).off("submit.formidable",".frm-show-form");jQuery(document).on("submit.formidable",".frm-show-form",frmFrontForm.submitForm);jQuery(".frm-show-form input[onblur], .frm-show-form textarea[onblur]").each(function(){""===jQuery(this).val()&&jQuery(this).blur()});
17
- jQuery(document).on("focus",".frm_toggle_default",E);jQuery(document).on("blur",".frm_toggle_default",F);jQuery(".frm_toggle_default").blur();jQuery(document.getElementById("frm_resend_email")).click(G);jQuery(document).on("change",'.frm-show-form input[name^="item_meta"], .frm-show-form select[name^="item_meta"], .frm-show-form textarea[name^="item_meta"]',frmFrontForm.fieldValueChanged);jQuery(document).on("change keyup",".frm-show-form .frm_inside_container input, .frm-show-form .frm_inside_container select, .frm-show-form .frm_inside_container textarea",
18
- f);jQuery(document).on("click","a[data-frmconfirm]",H);jQuery("a[data-frmtoggle]").click(I);J();K();L();M()},getFieldId:function(a,b){return e(a,b)},renderRecaptcha:function(a){var b=a.getAttribute("data-size"),c={sitekey:a.getAttribute("data-sitekey"),size:b,theme:a.getAttribute("data-theme")};if("invisible"===b){var d=jQuery(a).closest("form").find('input[name="form_id"]').val();c.callback=function(a){frmFrontForm.afterRecaptcha(a,d)}}b=grecaptcha.render(a.id,c);a.setAttribute("data-rid",b)},afterSingleRecaptcha:function(a){a=
19
- jQuery(".frm-show-form .g-recaptcha").closest("form")[0];frmFrontForm.submitFormNow(a)},afterRecaptcha:function(a,b){var c=jQuery("#frm_form_"+b+"_container form")[0];frmFrontForm.submitFormNow(c)},submitForm:function(a){frmFrontForm.submitFormManual(a,this)},submitFormManual:function(a,b){if("undefined"!==typeof frmProForm&&frmProForm.goingToPreviousPage(b))var c=!1;else{var d=jQuery(b).find('.frm-g-recaptcha[data-size="invisible"], .g-recaptcha[data-size="invisible"]');d.length?(c=d.data("rid"),
20
- c=0===grecaptcha.getResponse(c).length?d:!1):c=!1}d=b.className.trim().split(/\s+/gi);d&&1>c.length&&!(-1<d.indexOf("frm_pro_form"))||jQuery("body").hasClass("wp-admin")||(a.preventDefault(),c.length?(d=c.data("rid"),grecaptcha.reset(d),grecaptcha.execute(d)):(c=frmFrontForm.validateFormSubmit(b),0===Object.keys(c).length&&(A(jQuery(b)),frmFrontForm.submitFormNow(b,d))))},submitFormNow:function(a){-1<a.className.trim().split(/\s+/gi).indexOf("frm_ajax_submit")?1>jQuery(a).find('input[type="file"]').filter(function(){return!!this.value}).length?
21
- (r=jQuery(a).find('input[name="frm_action"]').val(),frmFrontForm.checkFormErrors(a,r)):a.submit():a.submit()},validateFormSubmit:function(a){"undefined"!==typeof tinyMCE&&jQuery(a).find(".wp-editor-wrap").length&&tinyMCE.triggerSave();m=[];var b=jQuery(a).hasClass("frm_js_validate");b&&"undefined"!==typeof frmProForm&&(frmProForm.savingDraft(a)||frmProForm.goingToPreviousPage(a))&&(b=!1);b&&(frmFrontForm.getAjaxFormErrors(a),Object.keys(m).length&&frmFrontForm.addAjaxFormErrors(a));return m},getAjaxFormErrors:function(a){var b=
22
- [],c=jQuery(a).find(".frm_required_field:visible input, .frm_required_field:visible select, .frm_required_field:visible textarea").filter(":not(.frm_optional)");if(c.length)for(var d=0,e=c.length;d<e;d++)b=k(c[d],b);c=jQuery(a).find("input[type=email]").filter(":visible");d=jQuery(a).find("input,select,textarea");if(d.length){e=0;for(var f=d.length;e<f;e++){var g=d[e];""!==g.value&&"hidden"!==g.type&&("number"===g.type?b=v(g,b):"email"===g.type?b=p(g,b,c):null!==g.pattern&&(b=w(g,b)))}}c=jQuery(a).find(".frm-g-recaptcha");
23
- c.length&&(d=c.data("rid"),0===grecaptcha.getResponse(d).length&&(c=c.closest(".frm_form_field").attr("id").replace("frm_field_","").replace("_container",""),b[c]=""));m=b;if("function"===typeof frmThemeOverride_jsErrors&&(r=jQuery(a).find('input[name="frm_action"]').val(),a=frmThemeOverride_jsErrors(r,a),Object.keys(a).length))for(var n in a)m[n]=a[n];return m},addAjaxFormErrors:function(a){x();for(var b in m){var c=jQuery(a).find("#frm_field_"+b+"_container");c.length?u(c,b,m):delete m[b]}y(a)},
24
- checkFormErrors:function(a,b){C(a,b)},checkRequiredField:function(a,b){return k(a,b)},showSubmitLoading:function(a){A(a)},removeSubmitLoading:function(a,b,c){t(a,b,c)},scrollToID:function(a){a=jQuery(document.getElementById(a));frmFrontForm.scrollMsg(a,!1)},scrollMsg:function(a,b,c){if("undefined"===typeof b){if(a=jQuery(document.getElementById("frm_form_"+a+"_container")),1>a.length)return}else a="string"===typeof a?jQuery(b).find("#frm_field_"+a+"_container"):a;if(a=a.offset().top){a-=frm_js.offset;
25
- b=jQuery("html").css("margin-top");var d=jQuery("body").css("margin-top");if(b||d)a=a-parseInt(b)-parseInt(d);if(a&&window.innerHeight&&(b=document.documentElement.scrollTop||document.body.scrollTop,a>b+window.innerHeight||a<b))return"undefined"===typeof c?jQuery(window).scrollTop(a):jQuery("html,body").animate({scrollTop:a},500),!1}},fieldValueChanged:function(a){var b=frmFrontForm.getFieldId(this,!1);if(b&&"undefined"!==typeof b&&(!a.frmTriggered||a.frmTriggered!=b)&&(jQuery(document).trigger("frmFieldChanged",
26
- [this,b,a]),!0!==a.selfTriggered&&jQuery(this).closest("form").hasClass("frm_js_validate"))){a=[];b=jQuery(this).closest(".frm_form_field");b.hasClass("frm_required_field")&&!jQuery(this).hasClass("frm_optional")&&(a=k(this,a));if(1>a.length)if("email"===this.type){var c=jQuery(this).closest("form").find("input[type=email]");a=p(this,a,c)}else"number"===this.type?a=v(this,a):null!==this.pattern&&(a=w(this,a));b.removeClass("frm_blank_field has-error");b.find(".frm_error").remove();if(0<Object.keys(a).length)for(var d in a)u(b,
27
- d,a)}},savingDraft:function(a){console.warn("DEPRECATED: function frmFrontForm.savingDraft in v3.0 use frmProForm.savingDraft");if("undefined"!==typeof frmProForm)return frmProForm.savingDraft(a)},goingToPreviousPage:function(a){console.warn("DEPRECATED: function frmFrontForm.goingToPreviousPage in v3.0 use frmProForm.goingToPreviousPage");if("undefined"!==typeof frmProForm)return frmProForm.goingToPreviousPage(a)},hideOrShowFields:function(a,b){console.warn("DEPRECATED: function frmFrontForm.hideOrShowFields in v3.0 use frmProForm.hideOrShowFields");
28
- "undefined"!==typeof frmProForm&&frmProForm.hideOrShowFields()},hidePreviouslyHiddenFields:function(){console.warn("DEPRECATED: function frmFrontForm.hidePreviouslyHiddenFields in v3.0 use frmProForm.hidePreviouslyHiddenFields");"undefined"!==typeof frmProForm&&frmProForm.hidePreviouslyHiddenFields()},checkDependentDynamicFields:function(a){console.warn("DEPRECATED: function frmFrontForm.checkDependentDynamicFields in v3.0 use frmProForm.checkDependentDynamicFields");"undefined"!==typeof frmProForm&&
29
- frmProForm.checkDependentDynamicFields(a)},checkDependentLookupFields:function(a){console.warn("DEPRECATED: function frmFrontForm.checkDependentLookupFields in v3.0 use frmProForm.checkDependentLookupFields");"undefined"!==typeof frmProForm&&frmProForm.checkDependentLookupFields(a)},loadGoogle:function(){console.warn("DEPRECATED: function frmFrontForm.loadGoogle in v3.0 use frmProForm.loadGoogle");frmProForm.loadGoogle()},removeUsedTimes:function(a,b){console.warn("DEPRECATED: function frmFrontForm.removeUsedTimes in v3.0 use frmProForm.removeUsedTimes");
30
- "undefined"!==typeof frmProForm&&frmProForm.removeUsedTimes()},escapeHtml:function(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")},invisible:function(a){jQuery(a).css("visibility","hidden")},visible:function(a){jQuery(a).css("visibility","visible")}}}var frmFrontForm=frmFrontFormJS();jQuery(document).ready(function(f){frmFrontForm.init()});
31
- function frmRecaptcha(){for(var f=jQuery(".frm-g-recaptcha"),e=0,k=f.length;e<k;e++)frmFrontForm.renderRecaptcha(f[e])}function frmAfterRecaptcha(f){frmFrontForm.afterSingleRecaptcha(f)}
32
- function frmUpdateField(f,e,k,n,p){jQuery(document.getElementById("frm_update_field_"+f+"_"+e+"_"+p)).html('<span class="frm-loading-img"></span>');jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:{action:"frm_entries_update_field_ajax",entry_id:f,field_id:e,value:k,nonce:frm_js.nonce},success:function(){""===n.replace(/^\s+|\s+$/g,"")?jQuery(document.getElementById("frm_update_field_"+f+"_"+e+"_"+p)).fadeOut("slow"):jQuery(document.getElementById("frm_update_field_"+f+"_"+e+"_"+p)).replaceWith(n)}})}
33
- function frmDeleteEntry(f,e){console.warn("DEPRECATED: function frmDeleteEntry in v2.0.13 use frmFrontForm.deleteEntry");jQuery(document.getElementById("frm_delete_"+f)).replaceWith('<span class="frm-loading-img" id="frm_delete_'+f+'"></span>');jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:{action:"frm_entries_destroy",entry:f,nonce:frm_js.nonce},success:function(k){"success"===k.replace(/^\s+|\s+$/g,"")?jQuery(document.getElementById(e+f)).fadeOut("slow"):jQuery(document.getElementById("frm_delete_"+
34
- f)).replaceWith(k)}})}function frmOnSubmit(f){console.warn("DEPRECATED: function frmOnSubmit in v2.0 use frmFrontForm.submitForm");frmFrontForm.submitForm(f,this)}
35
- function frm_resend_email(f,e){console.warn("DEPRECATED: function frm_resend_email in v2.0");var k=jQuery(document.getElementById("frm_resend_email"));k.append('<span class="spinner" style="display:inline"></span>');jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:{action:"frm_entries_send_email",entry_id:f,form_id:e,nonce:frm_js.nonce},success:function(e){k.replaceWith(e)}})};
1
+ function frmFrontFormJS(){function e(){var a=jQuery(this),b=a.closest(".frm_inside_container").find("label.frm_primary_label");0<a.val().length?b.addClass("frm_visible"):b.removeClass("frm_visible")}function f(a,b){var c="";c=a instanceof jQuery?a.attr("name"):a.name;if(""===c)return c=a instanceof jQuery?a.data("name"):a.getAttribute("data-name"),""!==c&&c?c:0;c=c.replace("item_meta[","").replace("[]","").split("]");if(1>c.length)return 0;c=c.filter(function(a){return""!==a});var d=c[0],g=!1;if(1===
2
+ c.length)return d;if("[form"===c[1]||"[row_ids"===c[1])return 0;jQuery('input[name="item_meta['+d+'][form]"]').length&&(d=c[2].replace("[",""),g=!0);"other"===d&&(d=g?c[3].replace("[",""):c[1].replace("[",""));!0===b&&(d=d===c[0]?d+"-"+c[1].replace("[",""):d+"-"+c[0]+"-"+c[1].replace("[",""));return d}function h(a,b){var c=a.getAttribute("data-frmfile");if("hidden"===a.type&&null===c)return b;var d="",g="";if("checkbox"===a.type||"radio"===a.type)c=jQuery('input[name="'+a.name+'"]').closest(".frm_required_field").find("input:checked"),
3
+ jQuery(c).each(function(){d=this.value});else if("file"===a.type||c)"undefined"===typeof c&&(c=f(a,!0),c=c.replace("file","")),"undefined"===typeof b[c]&&(d=p(c)),g=c;else{c=a.className;if(-1!==c.indexOf("frm_pos_none"))return b;d=jQuery(a).val();if(null===d)d="";else if("string"!==typeof d){g=d;d="";for(var k=0;k<g.length;k++)""!==g[k]&&(d=g[k])}g=-1===c.indexOf("frm_other_input")?f(a,!0):f(a,!1);-1!==c.indexOf("frm_time_select")&&(g=g.replace("-H","").replace("-m",""))}""===d&&(""===g&&(g=f(a,!0)),
4
+ g in b||(b[g]=r(a,"data-reqmsg")));return b}function p(a){var b="";jQuery('input[name="file'+a+'"], input[name="file'+a+'[]"], input[name^="item_meta['+a+']"]').each(function(){""===b&&(b=this.value)});return b}function q(a,b,c){var d=a.value,g=f(a,!0);if(g in b)return b;var k=0===g.indexOf("conf_");if(""!==d||k){var n=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/i,e=r(a,"data-invmsg");""!==
5
+ d&&!1===n.test(d)?(b[g]=e,k&&(b[g.replace("conf_","")]="")):k&&(a=a.name.replace("conf_",""),c.filter('[name="'+a+'"]').val()!==d&&(b[g]="",b[g.replace("conf_","")]=""))}return b}function w(a,b){var c=a.value;""!==c&&!1!==isNaN(c/1)&&(c=f(a,!0),c in b||(b[c]=r(a,"data-invmsg")));return b}function x(a,b){var c=a.value,d=r(a,"pattern");if(""!==d&&""!==c){var g=f(a,!0);g in b||(d=new RegExp("^"+d+"$","i"),!1===d.test(c)&&(b[g]=r(a,"data-invmsg")))}return b}function r(a,b){var c=a.getAttribute(b);null===
6
+ c&&(c="");return c}function D(a,b){"undefined"===typeof b&&jQuery(a).find('input[name="frm_action"]').val();var c=jQuery(a).find(".frm_form_field");c.addClass("frm_doing_ajax");jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:jQuery(a).serialize()+"&action=frm_entries_"+b+"&nonce="+frm_js.nonce,success:function(b){var d={content:"",errors:{},pass:!1};null===b&&(b=d);b=b.replace(/^\s+|\s+$/g,"");b=0===b.indexOf("{")?jQuery.parseJSON(b):d;if("undefined"!==typeof b.redirect)jQuery(document).trigger("frmBeforeFormRedirect",
7
+ [a,b]),window.location=b.redirect;else if(""!==b.content){u(jQuery(a));-1!=frm_js.offset&&frmFrontForm.scrollMsg(jQuery(a),!1);var k=jQuery(a).find('input[name="form_id"]').val();b.content=b.content.replace(/ frm_pro_form /g," frm_pro_form frm_no_hide ");d=jQuery(a).closest(".frm_forms");var e=jQuery(".frm_end_ajax_"+k);e.length&&(d.nextUntil(".frm_end_ajax_"+k).remove(),e.remove());d.replaceWith(b.content);d=b;if(history.pushState&&"undefined"!==typeof d.page){var f=d.page;e=encodeURI("frm_page");
8
+ f=encodeURI(f);for(var l=document.location.search.substr(1).split("&"),h=l.length,m;h--;)if(m=l[h].split("="),m[0]==e){m[1]=f;l[h]=m.join("=");break}0>h&&(l[l.length]=[e,f].join("="));e=l.join("&");window.history.pushState({html:d.html},"","?"+e)}"function"===typeof frmThemeOverride_frmAfterSubmit&&(k=jQuery('input[name="frm_page_order_'+k+'"]').val(),d=jQuery(b.content).find('input[name="form_id"]').val(),frmThemeOverride_frmAfterSubmit(d,k,b.content,a));jQuery(b.content).find(".frm_message").length?
9
+ jQuery(document).trigger("frmFormComplete",[a,b]):jQuery(document).trigger("frmPageChanged",[a,b])}else if(Object.keys(b.errors).length){u(jQuery(a),"enable");d=!0;y();e=!1;for(k in b.errors)f=jQuery(a).find("#frm_field_"+k+"_container"),f.length&&(f.is(":visible")||(l=f.closest(".frm_toggle_container"),l.length&&(l=l.prev(),l.hasClass("frm_trigger")||(l=l.prev(".frm_trigger")),l.click())),f.is(":visible")&&(v(f,k,b.errors),d=!1,f=jQuery(a).find("#frm_field_"+k+"_container .frm-g-recaptcha, #frm_field_"+
10
+ k+"_container .g-recaptcha"),f.length&&(e=!0,f=f.data("rid"),jQuery().grecaptcha&&(f?grecaptcha.reset(f):grecaptcha.reset()))));jQuery(document).trigger("frmFormErrors",[a,b]);c.removeClass("frm_doing_ajax");z(a);!0!==e&&A(a,!1);d?a.submit():jQuery(a).prepend(b.error_message)}else E(a),A(a,!0),a.submit()},error:function(){jQuery(a).find('input[type="submit"], input[type="button"]').removeAttr("disabled");a.submit()}})}function v(a,b,c){a.length&&a.is(":visible")&&(a.addClass("frm_blank_field"),"function"===
11
+ typeof frmThemeOverride_frmPlaceError?frmThemeOverride_frmPlaceError(b,c):a.append('<div class="frm_error">'+c[b]+"</div>"),jQuery(document).trigger("frmAddFieldError",[a,b,c]))}function y(){jQuery(".form-field").removeClass("frm_blank_field has-error");jQuery(".form-field .frm_error").replaceWith("");jQuery(".frm_error_style").remove()}function z(a){var b=jQuery(a).find(".frm_blank_field:first");b.length&&frmFrontForm.scrollMsg(b,a,!0)}function B(a){a.hasClass("frm_loading_form")||(a.addClass("frm_loading_form"),
12
+ a.trigger("frmStartFormLoading"));a.find('input[type="submit"], input[type="button"], button[type="submit"]').attr("disabled","disabled")}function u(a,b,c){0<c||(a.removeClass("frm_loading_form"),a.trigger("frmEndFormLoading"),"enable"===b&&a.find('input[type="submit"], input[type="button"], button[type="submit"]').removeAttr("disabled"))}function E(a){var b=document.getElementById("frm_loading");null!==b&&(a=jQuery(a).find("input[type=file]").val(),"undefined"!==typeof a&&""!==a&&setTimeout(function(){jQuery(b).fadeIn("slow")},
13
+ 2E3))}function A(a,b){var c=jQuery(a).find(".frm-g-recaptcha, .g-recaptcha");c.length&&(!b||1>jQuery(a).find(".frm_next_page").length||1>jQuery(a).find(".frm_next_page").val())&&c.closest(".frm_form_field").replaceWith('<input type="hidden" name="recaptcha_checked" value="'+frm_js.nonce+'">')}function F(){C(jQuery(this),"clear")}function G(){C(jQuery(this),"replace")}function C(a,b){var c=a.data("frmval").replace(/(\n|\r\n)/g,"\r");if(""===c||"undefined"===typeof c)return!1;var d=a.val().replace(/(\n|\r\n)/g,
14
+ "\r");"replace"==b?""===d&&a.addClass("frm_default").val(c):d==c&&a.removeClass("frm_default").val("")}function H(){var a=jQuery(this),b=a.data("eid"),c=a.data("fid");a.append('<span class="spinner" style="display:inline"></span>');jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:{action:"frm_entries_send_email",entry_id:b,form_id:c,nonce:frm_js.nonce},success:function(b){a.replaceWith(b)}});return!1}function I(){var a=jQuery(this).data("frmconfirm");return confirm(a)}function J(){var a=jQuery(this).data("frmtoggle");
15
+ jQuery(a).is(":visible")?jQuery(a).slideUp("fast"):jQuery(a).slideDown("fast");return!1}function K(){Array.prototype.indexOf||(Array.prototype.indexOf=function(a,b){var c=this.length>>>0,d=Number(b)||0;d=0>d?Math.ceil(d):Math.floor(d);for(0>d&&(d+=c);d<c;d++)if(d in this&&this[d]===a)return d;return-1})}function L(){"function"!==typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")})}function M(){Array.prototype.filter||(Array.prototype.filter=function(a,
16
+ b){if(void 0===this||null===this)throw new TypeError;var c=Object(this),d=c.length>>>0;if("function"!==typeof a)throw new TypeError;for(var f=[],e=0;e<d;e++)if(e in c){var h=c[e];a.call(b,h,e,c)&&f.push(h)}return f})}function N(){Object.keys||(Object.keys=function(a){var b=[],c;for(c in a)a.hasOwnProperty(c)&&b.push(c);return b})}var t="",m=[];return{init:function(){jQuery(document).off("submit.formidable",".frm-show-form");jQuery(document).on("submit.formidable",".frm-show-form",frmFrontForm.submitForm);
17
+ jQuery(".frm-show-form input[onblur], .frm-show-form textarea[onblur]").each(function(){""===jQuery(this).val()&&jQuery(this).blur()});jQuery(document).on("focus",".frm_toggle_default",F);jQuery(document).on("blur",".frm_toggle_default",G);jQuery(".frm_toggle_default").blur();jQuery(document.getElementById("frm_resend_email")).click(H);jQuery(document).on("change",'.frm-show-form input[name^="item_meta"], .frm-show-form select[name^="item_meta"], .frm-show-form textarea[name^="item_meta"]',frmFrontForm.fieldValueChanged);
18
+ jQuery(document).on("change keyup",".frm-show-form .frm_inside_container input, .frm-show-form .frm_inside_container select, .frm-show-form .frm_inside_container textarea",e);jQuery(document).on("click","a[data-frmconfirm]",I);jQuery("a[data-frmtoggle]").click(J);K();L();M();N()},getFieldId:function(a,b){return f(a,b)},renderRecaptcha:function(a){var b=a.getAttribute("data-size"),c={sitekey:a.getAttribute("data-sitekey"),size:b,theme:a.getAttribute("data-theme")};if("invisible"===b){var d=jQuery(a).closest("form").find('input[name="form_id"]').val();
19
+ c.callback=function(a){frmFrontForm.afterRecaptcha(a,d)}}b=grecaptcha.render(a.id,c);a.setAttribute("data-rid",b)},afterSingleRecaptcha:function(a){a=jQuery(".frm-show-form .g-recaptcha").closest("form")[0];frmFrontForm.submitFormNow(a)},afterRecaptcha:function(a,b){var c=jQuery("#frm_form_"+b+"_container form")[0];frmFrontForm.submitFormNow(c)},submitForm:function(a){frmFrontForm.submitFormManual(a,this)},submitFormManual:function(a,b){if("undefined"!==typeof frmProForm&&frmProForm.goingToPreviousPage(b))var c=
20
+ !1;else{var d=jQuery(b).find('.frm-g-recaptcha[data-size="invisible"], .g-recaptcha[data-size="invisible"]');d.length?(c=d.data("rid"),c=0===grecaptcha.getResponse(c).length?d:!1):c=!1}d=b.className.trim().split(/\s+/gi);d&&1>c.length&&!(-1<d.indexOf("frm_pro_form"))||jQuery("body").hasClass("wp-admin")||(a.preventDefault(),c.length?(d=c.data("rid"),grecaptcha.reset(d),grecaptcha.execute(d)):(c=frmFrontForm.validateFormSubmit(b),0===Object.keys(c).length&&(B(jQuery(b)),frmFrontForm.submitFormNow(b,
21
+ d))))},submitFormNow:function(a){-1<a.className.trim().split(/\s+/gi).indexOf("frm_ajax_submit")?1>jQuery(a).find('input[type="file"]').filter(function(){return!!this.value}).length?(t=jQuery(a).find('input[name="frm_action"]').val(),frmFrontForm.checkFormErrors(a,t)):a.submit():a.submit()},validateFormSubmit:function(a){"undefined"!==typeof tinyMCE&&jQuery(a).find(".wp-editor-wrap").length&&tinyMCE.triggerSave();m=[];var b=jQuery(a).hasClass("frm_js_validate");b&&"undefined"!==typeof frmProForm&&
22
+ (frmProForm.savingDraft(a)||frmProForm.goingToPreviousPage(a))&&(b=!1);b&&(frmFrontForm.getAjaxFormErrors(a),Object.keys(m).length&&frmFrontForm.addAjaxFormErrors(a));return m},getAjaxFormErrors:function(a){var b=[],c=jQuery(a).find(".frm_required_field:visible input, .frm_required_field:visible select, .frm_required_field:visible textarea").filter(":not(.frm_optional)");if(c.length)for(var d=0,e=c.length;d<e;d++)b=h(c[d],b);c=jQuery(a).find("input[type=email]").filter(":visible");d=jQuery(a).find("input,select,textarea");
23
+ if(d.length){e=0;for(var f=d.length;e<f;e++){var n=d[e];""!==n.value&&"hidden"!==n.type&&("number"===n.type?b=w(n,b):"email"===n.type?b=q(n,b,c):null!==n.pattern&&(b=x(n,b)))}}c=jQuery(a).find(".frm-g-recaptcha");c.length&&(d=c.data("rid"),0===grecaptcha.getResponse(d).length&&(c=c.closest(".frm_form_field").attr("id").replace("frm_field_","").replace("_container",""),b[c]=""));m=b;if("function"===typeof frmThemeOverride_jsErrors&&(t=jQuery(a).find('input[name="frm_action"]').val(),a=frmThemeOverride_jsErrors(t,
24
+ a),Object.keys(a).length))for(var p in a)m[p]=a[p];return m},addAjaxFormErrors:function(a){y();for(var b in m){var c=jQuery(a).find("#frm_field_"+b+"_container");c.length?v(c,b,m):delete m[b]}z(a)},checkFormErrors:function(a,b){D(a,b)},checkRequiredField:function(a,b){return h(a,b)},showSubmitLoading:function(a){B(a)},removeSubmitLoading:function(a,b,c){u(a,b,c)},scrollToID:function(a){a=jQuery(document.getElementById(a));frmFrontForm.scrollMsg(a,!1)},scrollMsg:function(a,b,c){if("undefined"===typeof b){if(a=
25
+ jQuery(document.getElementById("frm_form_"+a+"_container")),1>a.length)return}else a="string"===typeof a?jQuery(b).find("#frm_field_"+a+"_container"):a;if(a=a.offset().top){a-=frm_js.offset;b=jQuery("html").css("margin-top");var d=jQuery("body").css("margin-top");if(b||d)a=a-parseInt(b)-parseInt(d);if(a&&window.innerHeight&&(b=document.documentElement.scrollTop||document.body.scrollTop,a>b+window.innerHeight||a<b))return"undefined"===typeof c?jQuery(window).scrollTop(a):jQuery("html,body").animate({scrollTop:a},
26
+ 500),!1}},fieldValueChanged:function(a){var b=frmFrontForm.getFieldId(this,!1);if(b&&"undefined"!==typeof b&&(!a.frmTriggered||a.frmTriggered!=b)&&(jQuery(document).trigger("frmFieldChanged",[this,b,a]),!0!==a.selfTriggered&&jQuery(this).closest("form").hasClass("frm_js_validate"))){a=[];b=jQuery(this).closest(".frm_form_field");b.hasClass("frm_required_field")&&!jQuery(this).hasClass("frm_optional")&&(a=h(this,a));if(1>a.length)if("email"===this.type){var c=jQuery(this).closest("form").find("input[type=email]");
27
+ a=q(this,a,c)}else"number"===this.type?a=w(this,a):null!==this.pattern&&(a=x(this,a));b.removeClass("frm_blank_field has-error");b.find(".frm_error").remove();if(0<Object.keys(a).length)for(var d in a)v(b,d,a)}},savingDraft:function(a){console.warn("DEPRECATED: function frmFrontForm.savingDraft in v3.0 use frmProForm.savingDraft");if("undefined"!==typeof frmProForm)return frmProForm.savingDraft(a)},goingToPreviousPage:function(a){console.warn("DEPRECATED: function frmFrontForm.goingToPreviousPage in v3.0 use frmProForm.goingToPreviousPage");
28
+ if("undefined"!==typeof frmProForm)return frmProForm.goingToPreviousPage(a)},hideOrShowFields:function(a,b){console.warn("DEPRECATED: function frmFrontForm.hideOrShowFields in v3.0 use frmProForm.hideOrShowFields");"undefined"!==typeof frmProForm&&frmProForm.hideOrShowFields()},hidePreviouslyHiddenFields:function(){console.warn("DEPRECATED: function frmFrontForm.hidePreviouslyHiddenFields in v3.0 use frmProForm.hidePreviouslyHiddenFields");"undefined"!==typeof frmProForm&&frmProForm.hidePreviouslyHiddenFields()},
29
+ checkDependentDynamicFields:function(a){console.warn("DEPRECATED: function frmFrontForm.checkDependentDynamicFields in v3.0 use frmProForm.checkDependentDynamicFields");"undefined"!==typeof frmProForm&&frmProForm.checkDependentDynamicFields(a)},checkDependentLookupFields:function(a){console.warn("DEPRECATED: function frmFrontForm.checkDependentLookupFields in v3.0 use frmProForm.checkDependentLookupFields");"undefined"!==typeof frmProForm&&frmProForm.checkDependentLookupFields(a)},loadGoogle:function(){console.warn("DEPRECATED: function frmFrontForm.loadGoogle in v3.0 use frmProForm.loadGoogle");
30
+ frmProForm.loadGoogle()},removeUsedTimes:function(a,b){console.warn("DEPRECATED: function frmFrontForm.removeUsedTimes in v3.0 use frmProForm.removeUsedTimes");"undefined"!==typeof frmProForm&&frmProForm.removeUsedTimes()},escapeHtml:function(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")},invisible:function(a){jQuery(a).css("visibility","hidden")},visible:function(a){jQuery(a).css("visibility","visible")}}}
31
+ var frmFrontForm=frmFrontFormJS();jQuery(document).ready(function(e){frmFrontForm.init()});function frmRecaptcha(){for(var e=jQuery(".frm-g-recaptcha"),f=0,h=e.length;f<h;f++)frmFrontForm.renderRecaptcha(e[f])}function frmAfterRecaptcha(e){frmFrontForm.afterSingleRecaptcha(e)}
32
+ function frmUpdateField(e,f,h,p,q){jQuery(document.getElementById("frm_update_field_"+e+"_"+f+"_"+q)).html('<span class="frm-loading-img"></span>');jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:{action:"frm_entries_update_field_ajax",entry_id:e,field_id:f,value:h,nonce:frm_js.nonce},success:function(){""===p.replace(/^\s+|\s+$/g,"")?jQuery(document.getElementById("frm_update_field_"+e+"_"+f+"_"+q)).fadeOut("slow"):jQuery(document.getElementById("frm_update_field_"+e+"_"+f+"_"+q)).replaceWith(p)}})}
33
+ function frmDeleteEntry(e,f){console.warn("DEPRECATED: function frmDeleteEntry in v2.0.13 use frmFrontForm.deleteEntry");jQuery(document.getElementById("frm_delete_"+e)).replaceWith('<span class="frm-loading-img" id="frm_delete_'+e+'"></span>');jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:{action:"frm_entries_destroy",entry:e,nonce:frm_js.nonce},success:function(h){"success"===h.replace(/^\s+|\s+$/g,"")?jQuery(document.getElementById(f+e)).fadeOut("slow"):jQuery(document.getElementById("frm_delete_"+
34
+ e)).replaceWith(h)}})}function frmOnSubmit(e){console.warn("DEPRECATED: function frmOnSubmit in v2.0 use frmFrontForm.submitForm");frmFrontForm.submitForm(e,this)}
35
+ function frm_resend_email(e,f){console.warn("DEPRECATED: function frm_resend_email in v2.0");var h=jQuery(document.getElementById("frm_resend_email"));h.append('<span class="spinner" style="display:inline"></span>');jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:{action:"frm_entries_send_email",entry_id:e,form_id:f,nonce:frm_js.nonce},success:function(e){h.replaceWith(e)}})};
js/formidable_admin.js CHANGED
@@ -607,6 +607,137 @@ function frmAdminBuildJS(){
607
  initiateMultiselect();
608
  }
609
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
610
  function popCalcFields(v){
611
  /*jshint validthis:true */
612
  var p;
@@ -977,7 +1108,7 @@ function frmAdminBuildJS(){
977
  var id=jQuery(this).closest('li.form-field').data('fid');
978
  var form_id = this_form_id;
979
  var row_key = 0;
980
- var lookupBlockRows = document.getElementById( 'frm_watch_lookup_block_'+id ).childNodes;
981
  if ( lookupBlockRows.length > 0 ) {
982
  var lastRowId = lookupBlockRows[ lookupBlockRows.length - 1 ].id;
983
  row_key = 1 + parseInt( lastRowId.replace( 'frm_watch_lookup_' + id + '_', '' ) );
@@ -1364,7 +1495,9 @@ function frmAdminBuildJS(){
1364
 
1365
  function getFieldValues(){
1366
  /*jshint validthis:true */
1367
- var val = this.value;
 
 
1368
  if ( val ) {
1369
  var parentIDs = this.parentNode.id.replace('frm_logic_', '').split('_');
1370
  var fieldID = parentIDs[0];
@@ -1378,6 +1511,14 @@ function frmAdminBuildJS(){
1378
  var showSelect = (valueFieldType == 'select' || valueFieldType == 'checkbox' || valueFieldType == 'radio' );
1379
  var showText = ( valueFieldType == 'text' || valueFieldType == 'email' || valueFieldType == 'phone' || valueFieldType == 'url' || valueFieldType == 'number' );
1380
 
 
 
 
 
 
 
 
 
1381
  if ( showSelect || showText ) {
1382
  fill.innerHTML = '';
1383
  if ( showSelect ) {
@@ -2324,7 +2465,7 @@ function frmAdminBuildJS(){
2324
  var cssLink = jQuery('<link href="'+locStr+'" type="text/css" rel="Stylesheet" class="ui-theme" />');
2325
  jQuery('head').append(cssLink);
2326
 
2327
- if( jQuery('link.ui-theme').size() > 1){
2328
  jQuery('link.ui-theme:first').remove();
2329
  }
2330
  }
@@ -2832,6 +2973,7 @@ function frmAdminBuildJS(){
2832
  jQuery(document.getElementById('frm-insert-fields')).on('click', '.frm_add_field', addFieldClick);
2833
  $newFields.on('click', '.frm_duplicate_icon', duplicateField);
2834
  $newFields.on('click', '.use_calc', popCalcFields);
 
2835
  $newFields.on('change', 'input.frm_format_opt', toggleInvalidMsg);
2836
  $newFields.on('click', 'input.frm_req_field', markRequired);
2837
  $newFields.on('click', 'a.frm_req_field', clickRequired);
@@ -3092,12 +3234,22 @@ function frmAdminBuildJS(){
3092
  document.getElementById("frm_field_height").addEventListener("blur", textSquishCheck);
3093
  document.getElementById("frm_field_font_size").addEventListener("blur", textSquishCheck);
3094
  document.getElementById("frm_field_pad").addEventListener("blur", textSquishCheck);
 
 
 
 
 
 
 
 
 
 
3095
 
3096
  // update styling on change
3097
  jQuery('#frm_styling_form .styling_settings').change(function(){
3098
  var locStr = jQuery('input[name^="frm_style_setting[post_content]"], select[name^="frm_style_setting[post_content]"], textarea[name^="frm_style_setting[post_content]"], input[name="style_name"]').serialize();
3099
  jQuery.ajax({
3100
- type:'GET',url:ajaxurl,
3101
  data:'action=frm_change_styling&nonce='+frmGlobal.nonce+'&'+locStr,
3102
  success:function(css){
3103
  document.getElementById('this_css').innerHTML = css;
@@ -3189,7 +3341,7 @@ function frmAdminBuildJS(){
3189
  });
3190
  });
3191
 
3192
- jQuery('.frm_pro_form #datepicker_sample').datepicker();
3193
 
3194
  jQuery(document.getElementById('frm_position')).change(setPosClass);
3195
 
607
  initiateMultiselect();
608
  }
609
 
610
+ function checkCalculationCreatedByUser() {
611
+ var calculation = this.value;
612
+ var warningMessage = checkMatchingParens( calculation );
613
+ warningMessage += checkShortcodes( calculation, this );
614
+
615
+ if ( warningMessage !== '' ) {
616
+ alert( calculation + "\n\n" + warningMessage );
617
+ }
618
+ }
619
+
620
+ /**
621
+ * Checks a string for parens, brackets, and curly braces and returns a message if any unmatched are found.
622
+ * @param formula
623
+ * @returns {string}
624
+ */
625
+ function checkMatchingParens( formula ) {
626
+
627
+ var stack = [],
628
+ formula_array = formula.split( '' ),
629
+ length = formula_array.length,
630
+ opening = [ "{", "[", "(" ],
631
+ closing = {
632
+ "}": "{",
633
+ ")": "(",
634
+ "]": "[",
635
+ },
636
+ unmatchedClosing = [],
637
+ msg = '',
638
+ i, next, top;
639
+
640
+ for ( i = 0; i < length; i++ ) {
641
+ if ( opening.includes( formula_array[ i ] ) ) {
642
+ stack.push( formula_array[ i ] );
643
+ continue;
644
+ }
645
+ if ( closing.hasOwnProperty( formula_array[ i ] ) ) {
646
+ top = stack.pop();
647
+ if ( top !== closing[ formula_array[ i ] ] ) {
648
+ unmatchedClosing.push( formula_array[ i ] )
649
+ }
650
+ }
651
+ }
652
+
653
+ if ( stack.length > 0 || unmatchedClosing.length > 0 ) {
654
+ msg = frm_admin_js.unmatched_parens + '\n\n';
655
+ return msg;
656
+ }
657
+
658
+ return '';
659
+ }
660
+
661
+ /**
662
+ * Checks a calculation for shortcodes that shouldn't be in it and returns a message if found.
663
+ * @param calculation
664
+ * @param inputElement
665
+ * @returns {string}
666
+ */
667
+ function checkShortcodes( calculation, inputElement ) {
668
+ var msg = checkNonNumericShortcodes( calculation, inputElement );
669
+ msg += checkNonFormShortcodes( calculation );
670
+
671
+ return msg;
672
+ }
673
+
674
+ /**
675
+ * Checks if a numeric calculation has shortcodes that output non-numeric strings and returns a message if found.
676
+ * @param calculation
677
+ *
678
+ * @param inputElement
679
+ * @returns {string}
680
+ */
681
+ function checkNonNumericShortcodes( calculation, inputElement ) {
682
+
683
+ var msg = '';
684
+
685
+ if ( isTextCalculation( inputElement ) ) {
686
+ return msg;
687
+ }
688
+
689
+ var nonNumericShortcodes = getNonNumericShortcodes();
690
+
691
+ if ( nonNumericShortcodes.test( calculation ) ) {
692
+ msg = frm_admin_js.text_shortcodes + "\n\n";
693
+ }
694
+
695
+ return msg;
696
+ }
697
+
698
+ /**
699
+ * Determines if the calculation input is from a text calculation.
700
+ *
701
+ * @param inputElement
702
+ */
703
+ function isTextCalculation( inputElement ) {
704
+ return jQuery( inputElement ).siblings( "label[for^='calc_type']" ).children( "input" ).prop( "checked" );
705
+ }
706
+
707
+ /**
708
+ * Returns a regular expression of shortcodes that can't be used in numeric calculations.
709
+ * @returns {RegExp}
710
+ */
711
+ function getNonNumericShortcodes() {
712
+ return /\[(date|time|email|ip)\]/;
713
+ }
714
+
715
+ /**
716
+ * Checks if a string has any shortcodes that do not belong in forms and returns a message if any are found.
717
+ * @param formula
718
+ * @returns {string}
719
+ */
720
+ function checkNonFormShortcodes( formula ) {
721
+ var nonFormShortcodes = getNonFormShortcodes(),
722
+ msg = '';
723
+
724
+ if ( nonFormShortcodes.test( formula ) ) {
725
+ msg += frm_admin_js.view_shortcodes + "\n\n";
726
+ }
727
+
728
+ return msg;
729
+ }
730
+
731
+ /**
732
+ * Returns a regular expression of shortcodes that can't be used in forms but can be used in Views, Email
733
+ * Notifications, and other Formidable areas.
734
+ *
735
+ * @returns {RegExp}
736
+ */
737
+ function getNonFormShortcodes() {
738
+ return /\[(if\b|foreach|created-at|created-by|updated-at|updated-by)|((key|id)\])/;
739
+ }
740
+
741
  function popCalcFields(v){
742
  /*jshint validthis:true */
743
  var p;
1108
  var id=jQuery(this).closest('li.form-field').data('fid');
1109
  var form_id = this_form_id;
1110
  var row_key = 0;
1111
+ var lookupBlockRows = document.getElementById( 'frm_watch_lookup_block_'+id ).children;
1112
  if ( lookupBlockRows.length > 0 ) {
1113
  var lastRowId = lookupBlockRows[ lookupBlockRows.length - 1 ].id;
1114
  row_key = 1 + parseInt( lastRowId.replace( 'frm_watch_lookup_' + id + '_', '' ) );
1495
 
1496
  function getFieldValues(){
1497
  /*jshint validthis:true */
1498
+ var is_taxonomy,
1499
+ val = this.value;
1500
+
1501
  if ( val ) {
1502
  var parentIDs = this.parentNode.id.replace('frm_logic_', '').split('_');
1503
  var fieldID = parentIDs[0];
1511
  var showSelect = (valueFieldType == 'select' || valueFieldType == 'checkbox' || valueFieldType == 'radio' );
1512
  var showText = ( valueFieldType == 'text' || valueFieldType == 'email' || valueFieldType == 'phone' || valueFieldType == 'url' || valueFieldType == 'number' );
1513
 
1514
+ if ( showSelect ) {
1515
+ is_taxonomy = document.getElementById( 'frm_has_hidden_options_' + val );
1516
+ if ( is_taxonomy !== null ) {
1517
+ // get the category options with ajax
1518
+ showSelect = false;
1519
+ }
1520
+ }
1521
+
1522
  if ( showSelect || showText ) {
1523
  fill.innerHTML = '';
1524
  if ( showSelect ) {
2465
  var cssLink = jQuery('<link href="'+locStr+'" type="text/css" rel="Stylesheet" class="ui-theme" />');
2466
  jQuery('head').append(cssLink);
2467
 
2468
+ if ( jQuery( 'link.ui-theme' ).length > 1 ) {
2469
  jQuery('link.ui-theme:first').remove();
2470
  }
2471
  }
2973
  jQuery(document.getElementById('frm-insert-fields')).on('click', '.frm_add_field', addFieldClick);
2974
  $newFields.on('click', '.frm_duplicate_icon', duplicateField);
2975
  $newFields.on('click', '.use_calc', popCalcFields);
2976
+ $newFields.on('change', 'input[id^="frm_calc"]', checkCalculationCreatedByUser);
2977
  $newFields.on('change', 'input.frm_format_opt', toggleInvalidMsg);
2978
  $newFields.on('click', 'input.frm_req_field', markRequired);
2979
  $newFields.on('click', 'a.frm_req_field', clickRequired);
3234
  document.getElementById("frm_field_height").addEventListener("blur", textSquishCheck);
3235
  document.getElementById("frm_field_font_size").addEventListener("blur", textSquishCheck);
3236
  document.getElementById("frm_field_pad").addEventListener("blur", textSquishCheck);
3237
+ jQuery('input.hex').wpColorPicker({
3238
+ width:200,
3239
+ change: function( event, ui ) {
3240
+ var hexcolor = jQuery( this ).wpColorPicker( 'color' );
3241
+ jQuery( event.target ).val( hexcolor ).change();
3242
+ }
3243
+ });
3244
+ jQuery('.wp-color-result-text').text( function( i, oldText ) {
3245
+ return oldText === 'Select Color' ? 'Select' : oldText;
3246
+ });
3247
 
3248
  // update styling on change
3249
  jQuery('#frm_styling_form .styling_settings').change(function(){
3250
  var locStr = jQuery('input[name^="frm_style_setting[post_content]"], select[name^="frm_style_setting[post_content]"], textarea[name^="frm_style_setting[post_content]"], input[name="style_name"]').serialize();
3251
  jQuery.ajax({
3252
+ type:'POST',url:ajaxurl,
3253
  data:'action=frm_change_styling&nonce='+frmGlobal.nonce+'&'+locStr,
3254
  success:function(css){
3255
  document.getElementById('this_css').innerHTML = css;
3341
  });
3342
  });
3343
 
3344
+ jQuery('.frm_pro_form #datepicker_sample').datepicker({changeMonth:true,changeYear:true});
3345
 
3346
  jQuery(document.getElementById('frm_position')).change(setPosClass);
3347
 
js/jquery/jquery-ui-themepicker.js DELETED
@@ -1,395 +0,0 @@
1
- //global for tracking open and focused toolbar panels on refresh
2
- var openGroups = [];
3
- var focusedEl = null;
4
-
5
- jQuery.fn.spinDown = function() {
6
- return this.click(function() {
7
- var $this = jQuery(this);
8
- $this.next().slideToggle(100);
9
- $this.parent().siblings().children('.state-active').click(); //close open tabs
10
- $this.prev().toggleClass('not-active');
11
- $this.find('.icon').toggleClass('icon-triangle-1-s').end().toggleClass('state-active');
12
- //jQuery('li.ui-state-default .ui-state-active').removeClass('ui-state-active');
13
- $this.find('.ui-icon').toggleClass('ui-icon-triangle-1-s').end().toggleClass('ui-state-active');
14
- if($this.is('.corner-all')) { $this.removeClass('corner-all').addClass('corner-top'); }
15
- else if($this.is('.corner-top')) { $this.removeClass('corner-top').addClass('corner-all'); }
16
- if($this.is('.ui-corner-all')) { $this.removeClass('ui-corner-all').addClass('ui-corner-top'); }
17
- else if($this.is('.ui-corner-top')) { $this.removeClass('ui-corner-top').addClass('ui-corner-all'); }
18
- return false;
19
- });
20
- };
21
-
22
- // validation for hex inputs
23
- jQuery.fn.validHex = function() {
24
- return this.each(function() {
25
- var value = jQuery(this).val();
26
- value = value.replace(/[^#a-fA-F0-9]/g, ''); // non [#a-f0-9]
27
- if(value.match(/#/g) && value.match(/#/g).length > 1) value = value.replace(/#/g, ''); // ##
28
- if(value.indexOf('#') == -1) value = '#'+value; // no #
29
- if(value.length > 7) value = value.substr(0,7); // too many chars
30
- jQuery(this).val(value);
31
- });
32
- };
33
-
34
- //color pickers setup (sets bg color of inputs)
35
- jQuery.fn.applyFarbtastic = function() {
36
- return this.each(function() {
37
- jQuery('<div/>').farbtastic(this).remove();
38
- });
39
- };
40
-
41
- jQuery(document).ready(function($){
42
- // hover class toggles in app panel
43
- jQuery('.state-default').hover(
44
- function(){ jQuery(this).addClass('state-hover'); },
45
- function(){ jQuery(this).removeClass('state-hover'); }
46
- );
47
-
48
- $('div.theme-group .theme-group-header').addClass('corner-all').spinDown();
49
-
50
- // focus and blur classes in form
51
- $('input, select').focus(function(){
52
- $('input.focus, select.focus').removeClass('focus');
53
- $(this).addClass('focus');
54
- }).blur(function(){ $(this).removeClass('focus');});
55
-
56
- // hex inputs
57
- $('input.hex').validHex().keyup(function() {$(this).validHex();})
58
- .click(function(){
59
- $(this).addClass('focus');
60
- $('#picker').remove();
61
- $('div.picker-on').removeClass('picker-on');
62
- $('div.texturePicker ul:visible').hide(0).parent().css('position', 'static');
63
- $(this).after('<div id="picker"></div>').parent().addClass('picker-on');
64
- $('#picker').farbtastic(this);
65
- return false;
66
- })
67
- .wrap('<div class="hasPicker"></div>')
68
- .applyFarbtastic();
69
-
70
- $('body').click(function() {
71
- $('div.picker-on').removeClass('picker-on');
72
- $('#picker').remove();
73
- $('input.focus, select.focus').removeClass('focus');
74
- $('div.texturePicker ul:visible').hide().parent().css('position', 'static');
75
- });
76
- });
77
-
78
-
79
-
80
- // $Id: farbtastic.js,v 1.2 2007/01/08 22:53:01 unconed Exp $
81
- // Farbtastic 1.2
82
-
83
- jQuery.fn.farbtastic = function (callback) {
84
- jQuery.farbtastic(this, callback);
85
- return this;
86
- };
87
-
88
- jQuery.farbtastic = function (container, callback) {
89
- var container = jQuery(container).get(0);
90
- return container.farbtastic || (container.farbtastic = new jQuery._farbtastic(container, callback));
91
- };
92
-
93
- jQuery._farbtastic = function (container, callback) {
94
- // Store farbtastic object
95
- var fb = this;
96
-
97
- // Insert markup
98
- jQuery(container).html('<div class="farbtastic"><div class="color"></div><div class="wheel"></div><div class="overlay"></div><div class="h-marker marker"></div><div class="sl-marker marker"></div></div>');
99
- var e = jQuery('.farbtastic', container);
100
- fb.wheel = jQuery('.wheel', container).get(0);
101
- // Dimensions
102
- fb.radius = 84;
103
- fb.square = 100;
104
- fb.width = 194;
105
-
106
- // Fix background PNGs in IE6
107
- if (navigator.appVersion.match(/MSIE [0-6]\./)) {
108
- jQuery('*', e).each(function () {
109
- if (this.currentStyle.backgroundImage != 'none') {
110
- var image = this.currentStyle.backgroundImage;
111
- image = this.currentStyle.backgroundImage.substring(5, image.length - 2);
112
- jQuery(this).css({
113
- 'backgroundImage': 'none',
114
- 'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='" + image + "')"
115
- });
116
- }
117
- });
118
- }
119
-
120
- /**
121
- * Link to the given element(s) or callback.
122
- */
123
- fb.linkTo = function (callback) {
124
- // Unbind previous nodes
125
- if (typeof fb.callback == 'object'){jQuery(fb.callback).unbind('keyup', fb.updateValue);}
126
-
127
- // Reset color
128
- fb.color = null;
129
-
130
- // Bind callback or elements
131
- if (typeof callback == 'function'){fb.callback = callback;}
132
- else if (typeof callback == 'object' || typeof callback == 'string') {
133
- fb.callback = jQuery(callback);
134
- fb.callback.bind('keyup', fb.updateValue);
135
- if (fb.callback.get(0).value){fb.setColor(fb.callback.get(0).value);}
136
- }
137
- return this;
138
- };
139
- fb.updateValue = function (event) {
140
- if (this.value && this.value != fb.color){fb.setColor(this.value);}
141
- };
142
-
143
- /**
144
- * Change color with HTML syntax #123456
145
- */
146
- fb.setColor = function (color) {
147
- var unpack = fb.unpack(color);
148
- if (fb.color != color && unpack) {
149
- fb.color = color;
150
- fb.rgb = unpack;
151
- fb.hsl = fb.RGBToHSL(fb.rgb);
152
- fb.updateDisplay();
153
- }
154
- return this;
155
- };
156
-
157
- /**
158
- * Change color with HSL triplet [0..1, 0..1, 0..1]
159
- */
160
- fb.setHSL = function (hsl) {
161
- fb.hsl = hsl;
162
- fb.rgb = fb.HSLToRGB(hsl);
163
- fb.color = fb.pack(fb.rgb);
164
- fb.updateDisplay();
165
- return this;
166
- };
167
-
168
- /////////////////////////////////////////////////////
169
-
170
- /**
171
- * Retrieve the coordinates of the given event relative to the center
172
- * of the widget.
173
- */
174
- fb.widgetCoords = function (event) {
175
- var x, y;
176
- var el = event.target || event.srcElement;
177
- var reference = fb.wheel;
178
-
179
- if (typeof event.offsetX != 'undefined') {
180
- // Use offset coordinates and find common offsetParent
181
- var pos = { x: event.offsetX, y: event.offsetY };
182
-
183
- // Send the coordinates upwards through the offsetParent chain.
184
- var e = el;
185
- while (e) {
186
- e.mouseX = pos.x;
187
- e.mouseY = pos.y;
188
- pos.x += e.offsetLeft;
189
- pos.y += e.offsetTop;
190
- e = e.offsetParent;
191
- };
192
-
193
- // Look for the coordinates starting from the wheel widget.
194
- var e = reference;
195
- var offset = { x: 0, y: 0 };
196
- while (e) {
197
- if (typeof e.mouseX != 'undefined') {
198
- x = e.mouseX - offset.x;
199
- y = e.mouseY - offset.y;
200
- break;
201
- }
202
- offset.x += e.offsetLeft;
203
- offset.y += e.offsetTop;
204
- e = e.offsetParent;
205
- }
206
-
207
- // Reset stored coordinates
208
- e = el;
209
- while (e) {
210
- e.mouseX = undefined;
211
- e.mouseY = undefined;
212
- e = e.offsetParent;
213
- }
214
- }
215
- else {
216
- // Use absolute coordinates
217
- var pos = fb.absolutePosition(reference);
218
- x = (event.pageX || 0*(event.clientX + jQuery('html').get(0).scrollLeft)) - pos.x;
219
- y = (event.pageY || 0*(event.clientY + jQuery('html').get(0).scrollTop)) - pos.y;
220
- }
221
- // Subtract distance to middle
222
- return { x: x - fb.width / 2, y: y - fb.width / 2 };
223
- };
224
-
225
- /**
226
- * Mousedown handler
227
- */
228
- fb.mousedown = function (event) {
229
- // Capture mouse
230
- if (!document.dragging) {
231
- jQuery(document).bind('mousemove', fb.mousemove).bind('mouseup', fb.mouseup);
232
- document.dragging = true;
233
- };
234
-
235
- // Check which area is being dragged
236
- var pos = fb.widgetCoords(event);
237
- fb.circleDrag = Math.max(Math.abs(pos.x), Math.abs(pos.y)) * 2 > fb.square;
238
-
239
- // Process
240
- fb.mousemove(event);
241
- return false;
242
- };
243
-
244
- /**
245
- * Mousemove handler
246
- */
247
- fb.mousemove = function (event) {
248
- // Get coordinates relative to color picker center
249
- var pos = fb.widgetCoords(event);
250
-
251
- // Set new HSL parameters
252
- if (fb.circleDrag) {
253
- var hue = Math.atan2(pos.x, -pos.y) / 6.28;
254
- if (hue < 0) hue += 1;
255
- fb.setHSL([hue, fb.hsl[1], fb.hsl[2]]);
256
- }else{
257
- var sat = Math.max(0, Math.min(1, -(pos.x / fb.square) + .5));
258
- var lum = Math.max(0, Math.min(1, -(pos.y / fb.square) + .5));
259
- fb.setHSL([fb.hsl[0], sat, lum]);
260
- }
261
- return false;
262
- };
263
-
264
- /**
265
- * Mouseup handler
266
- */
267
- fb.mouseup = function () {
268
- // Uncapture mouse
269
- jQuery(document).unbind('mousemove', fb.mousemove);
270
- jQuery(document).unbind('mouseup', fb.mouseup);
271
- document.dragging = false;
272
- //formChange();
273
- };
274
-
275
- /**
276
- * Update the markers and styles
277
- */
278
- fb.updateDisplay = function () {
279
- // Markers
280
- var angle = fb.hsl[0] * 6.28;
281
- jQuery('.h-marker', e).css({
282
- left: Math.round(Math.sin(angle) * fb.radius + fb.width / 2) + 'px',
283
- top: Math.round(-Math.cos(angle) * fb.radius + fb.width / 2) + 'px'
284
- });
285
-
286
- jQuery('.sl-marker', e).css({
287
- left: Math.round(fb.square * (.5 - fb.hsl[1]) + fb.width / 2) + 'px',
288
- top: Math.round(fb.square * (.5 - fb.hsl[2]) + fb.width / 2) + 'px'
289
- });
290
-
291
- // Saturation/Luminance gradient
292
- jQuery('.color', e).css('backgroundColor', fb.pack(fb.HSLToRGB([fb.hsl[0], 1, 0.5])));
293
-
294
- // Linked elements or callback
295
- if (typeof fb.callback == 'object') {
296
- // Set background/foreground color
297
- jQuery(fb.callback).css({
298
- backgroundColor: fb.color,
299
- color: fb.hsl[2] > 0.5 ? '#000' : '#fff'
300
- });
301
-
302
- // Change linked value
303
- jQuery(fb.callback).each(function() {
304
- if (this.value && this.value != fb.color){this.value = fb.color; jQuery(this).change();}
305
- });
306
- }else if (typeof fb.callback == 'function'){fb.callback.call(fb, fb.color);}
307
- };
308
-
309
- /**
310
- * Get absolute position of element
311
- */
312
- fb.absolutePosition = function (el) {
313
- var r = { x: el.offsetLeft, y: el.offsetTop };
314
- // Resolve relative to offsetParent
315
- if (el.offsetParent) {
316
- var tmp = fb.absolutePosition(el.offsetParent);
317
- r.x += tmp.x;
318
- r.y += tmp.y;
319
- }
320
- return r;
321
- };
322
-
323
- /* Various color utility functions */
324
- fb.pack = function (rgb) {
325
- var r = Math.round(rgb[0] * 255);
326
- var g = Math.round(rgb[1] * 255);
327
- var b = Math.round(rgb[2] * 255);
328
- return '#' + (r < 16 ? '0' : '') + r.toString(16) +
329
- (g < 16 ? '0' : '') + g.toString(16) +
330
- (b < 16 ? '0' : '') + b.toString(16);
331
- };
332
-
333
- fb.unpack = function (color) {
334
- if (color.length == 7) {
335
- return [parseInt('0x' + color.substring(1, 3)) / 255,
336
- parseInt('0x' + color.substring(3, 5)) / 255,
337
- parseInt('0x' + color.substring(5, 7)) / 255];
338
- }
339
- else if (color.length == 4) {
340
- return [parseInt('0x' + color.substring(1, 2)) / 15,
341
- parseInt('0x' + color.substring(2, 3)) / 15,
342
- parseInt('0x' + color.substring(3, 4)) / 15];
343
- }
344
- };
345
-
346
- fb.HSLToRGB = function (hsl) {
347
- var m1, m2, r, g, b;
348
- var h = hsl[0], s = hsl[1], l = hsl[2];
349
- m2 = (l <= 0.5) ? l * (s + 1) : l + s - l*s;
350
- m1 = l * 2 - m2;
351
- return [this.hueToRGB(m1, m2, h+0.33333),
352
- this.hueToRGB(m1, m2, h),
353
- this.hueToRGB(m1, m2, h-0.33333)];
354
- };
355
-
356
- fb.hueToRGB = function (m1, m2, h) {
357
- h = (h < 0) ? h + 1 : ((h > 1) ? h - 1 : h);
358
- if (h * 6 < 1) return m1 + (m2 - m1) * h * 6;
359
- if (h * 2 < 1) return m2;
360
- if (h * 3 < 2) return m1 + (m2 - m1) * (0.66666 - h) * 6;
361
- return m1;
362
- };
363
-
364
- fb.RGBToHSL = function (rgb) {
365
- var min, max, delta, h, s, l;
366
- var r = rgb[0], g = rgb[1], b = rgb[2];
367
- min = Math.min(r, Math.min(g, b));
368
- max = Math.max(r, Math.max(g, b));
369
- delta = max - min;
370
- l = (min + max) / 2;
371
- s = 0;
372
- if (l > 0 && l < 1) {
373
- s = delta / (l < 0.5 ? (2 * l) : (2 - 2 * l));
374
- }
375
- h = 0;
376
- if (delta > 0) {
377
- if (max == r && max != g) h += (g - b) / delta;
378
- if (max == g && max != b) h += (2 + (b - r) / delta);
379
- if (max == b && max != r) h += (4 + (r - g) / delta);
380
- h /= 6;
381
- }
382
- return [h, s, l];
383
- };
384
-
385
- // Install mousedown handler (the others are set on the document on-demand)
386
- jQuery('*', e).mousedown(fb.mousedown);
387
-
388
- // Init color
389
- fb.setColor('#000000');
390
-
391
- // Set linked elements/callback
392
- if (callback) {
393
- fb.linkTo(callback);
394
- }
395
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/jquery/jquery-ui-themepicker.min.js DELETED
@@ -1 +0,0 @@
1
- var openGroups=[],focusedEl=null;jQuery.fn.spinDown=function(){return this.click(function(){var e=jQuery(this);return e.next().slideToggle(100),e.parent().siblings().children(".state-active").click(),e.prev().toggleClass("not-active"),e.find(".icon").toggleClass("icon-triangle-1-s").end().toggleClass("state-active"),e.find(".ui-icon").toggleClass("ui-icon-triangle-1-s").end().toggleClass("ui-state-active"),e.is(".corner-all")?e.removeClass("corner-all").addClass("corner-top"):e.is(".corner-top")&&e.removeClass("corner-top").addClass("corner-all"),e.is(".ui-corner-all")?e.removeClass("ui-corner-all").addClass("ui-corner-top"):e.is(".ui-corner-top")&&e.removeClass("ui-corner-top").addClass("ui-corner-all"),!1})},jQuery.fn.validHex=function(){return this.each(function(){var e=jQuery(this).val();e=e.replace(/[^#a-fA-F0-9]/g,""),e.match(/#/g)&&e.match(/#/g).length>1&&(e=e.replace(/#/g,"")),e.indexOf("#")==-1&&(e="#"+e),e.length>7&&(e=e.substr(0,7)),jQuery(this).val(e)})},jQuery.fn.applyFarbtastic=function(){return this.each(function(){jQuery("<div/>").farbtastic(this).remove()})},jQuery(document).ready(function(e){jQuery(".state-default").hover(function(){jQuery(this).addClass("state-hover")},function(){jQuery(this).removeClass("state-hover")}),e("div.theme-group .theme-group-header").addClass("corner-all").spinDown(),e("input, select").focus(function(){e("input.focus, select.focus").removeClass("focus"),e(this).addClass("focus")}).blur(function(){e(this).removeClass("focus")}),e("input.hex").validHex().keyup(function(){e(this).validHex()}).click(function(){return e(this).addClass("focus"),e("#picker").remove(),e("div.picker-on").removeClass("picker-on"),e("div.texturePicker ul:visible").hide(0).parent().css("position","static"),e(this).after('<div id="picker"></div>').parent().addClass("picker-on"),e("#picker").farbtastic(this),!1}).wrap('<div class="hasPicker"></div>').applyFarbtastic(),e("body").click(function(){e("div.picker-on").removeClass("picker-on"),e("#picker").remove(),e("input.focus, select.focus").removeClass("focus"),e("div.texturePicker ul:visible").hide().parent().css("position","static")})}),jQuery.fn.farbtastic=function(e){return jQuery.farbtastic(this,e),this},jQuery.farbtastic=function(e,t){var e=jQuery(e).get(0);return e.farbtastic||(e.farbtastic=new jQuery._farbtastic(e,t))},jQuery._farbtastic=function(e,t){var r=this;jQuery(e).html('<div class="farbtastic"><div class="color"></div><div class="wheel"></div><div class="overlay"></div><div class="h-marker marker"></div><div class="sl-marker marker"></div></div>');var o=jQuery(".farbtastic",e);r.wheel=jQuery(".wheel",e).get(0),r.radius=84,r.square=100,r.width=194,navigator.appVersion.match(/MSIE [0-6]\./)&&jQuery("*",o).each(function(){if("none"!=this.currentStyle.backgroundImage){var e=this.currentStyle.backgroundImage;e=this.currentStyle.backgroundImage.substring(5,e.length-2),jQuery(this).css({backgroundImage:"none",filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='"+e+"')"})}}),r.linkTo=function(e){return"object"==typeof r.callback&&jQuery(r.callback).unbind("keyup",r.updateValue),r.color=null,"function"==typeof e?r.callback=e:"object"!=typeof e&&"string"!=typeof e||(r.callback=jQuery(e),r.callback.bind("keyup",r.updateValue),r.callback.get(0).value&&r.setColor(r.callback.get(0).value)),this},r.updateValue=function(e){this.value&&this.value!=r.color&&r.setColor(this.value)},r.setColor=function(e){var t=r.unpack(e);return r.color!=e&&t&&(r.color=e,r.rgb=t,r.hsl=r.RGBToHSL(r.rgb),r.updateDisplay()),this},r.setHSL=function(e){return r.hsl=e,r.rgb=r.HSLToRGB(e),r.color=r.pack(r.rgb),r.updateDisplay(),this},r.widgetCoords=function(e){var t,o,a=e.target||e.srcElement,s=r.wheel;if("undefined"!=typeof e.offsetX){for(var i={x:e.offsetX,y:e.offsetY},n=a;n;)n.mouseX=i.x,n.mouseY=i.y,i.x+=n.offsetLeft,i.y+=n.offsetTop,n=n.offsetParent;for(var n=s,u={x:0,y:0};n;){if("undefined"!=typeof n.mouseX){t=n.mouseX-u.x,o=n.mouseY-u.y;break}u.x+=n.offsetLeft,u.y+=n.offsetTop,n=n.offsetParent}for(n=a;n;)n.mouseX=void 0,n.mouseY=void 0,n=n.offsetParent}else{var i=r.absolutePosition(s);t=(e.pageX||0*(e.clientX+jQuery("html").get(0).scrollLeft))-i.x,o=(e.pageY||0*(e.clientY+jQuery("html").get(0).scrollTop))-i.y}return{x:t-r.width/2,y:o-r.width/2}},r.mousedown=function(e){document.dragging||(jQuery(document).bind("mousemove",r.mousemove).bind("mouseup",r.mouseup),document.dragging=!0);var t=r.widgetCoords(e);return r.circleDrag=2*Math.max(Math.abs(t.x),Math.abs(t.y))>r.square,r.mousemove(e),!1},r.mousemove=function(e){var t=r.widgetCoords(e);if(r.circleDrag){var o=Math.atan2(t.x,-t.y)/6.28;o<0&&(o+=1),r.setHSL([o,r.hsl[1],r.hsl[2]])}else{var a=Math.max(0,Math.min(1,-(t.x/r.square)+.5)),s=Math.max(0,Math.min(1,-(t.y/r.square)+.5));r.setHSL([r.hsl[0],a,s])}return!1},r.mouseup=function(){jQuery(document).unbind("mousemove",r.mousemove),jQuery(document).unbind("mouseup",r.mouseup),document.dragging=!1},r.updateDisplay=function(){var e=6.28*r.hsl[0];jQuery(".h-marker",o).css({left:Math.round(Math.sin(e)*r.radius+r.width/2)+"px",top:Math.round(-Math.cos(e)*r.radius+r.width/2)+"px"}),jQuery(".sl-marker",o).css({left:Math.round(r.square*(.5-r.hsl[1])+r.width/2)+"px",top:Math.round(r.square*(.5-r.hsl[2])+r.width/2)+"px"}),jQuery(".color",o).css("backgroundColor",r.pack(r.HSLToRGB([r.hsl[0],1,.5]))),"object"==typeof r.callback?(jQuery(r.callback).css({backgroundColor:r.color,color:r.hsl[2]>.5?"#000":"#fff"}),jQuery(r.callback).each(function(){this.value&&this.value!=r.color&&(this.value=r.color,jQuery(this).change())})):"function"==typeof r.callback&&r.callback.call(r,r.color)},r.absolutePosition=function(e){var t={x:e.offsetLeft,y:e.offsetTop};if(e.offsetParent){var o=r.absolutePosition(e.offsetParent);t.x+=o.x,t.y+=o.y}return t},r.pack=function(e){var t=Math.round(255*e[0]),r=Math.round(255*e[1]),o=Math.round(255*e[2]);return"#"+(t<16?"0":"")+t.toString(16)+(r<16?"0":"")+r.toString(16)+(o<16?"0":"")+o.toString(16)},r.unpack=function(e){return 7==e.length?[parseInt("0x"+e.substring(1,3))/255,parseInt("0x"+e.substring(3,5))/255,parseInt("0x"+e.substring(5,7))/255]:4==e.length?[parseInt("0x"+e.substring(1,2))/15,parseInt("0x"+e.substring(2,3))/15,parseInt("0x"+e.substring(3,4))/15]:void 0},r.HSLToRGB=function(e){var t,r,o=e[0],a=e[1],s=e[2];return r=s<=.5?s*(a+1):s+a-s*a,t=2*s-r,[this.hueToRGB(t,r,o+.33333),this.hueToRGB(t,r,o),this.hueToRGB(t,r,o-.33333)]},r.hueToRGB=function(e,t,r){return r=r<0?r+1:r>1?r-1:r,6*r<1?e+(t-e)*r*6:2*r<1?t:3*r<2?e+(t-e)*(.66666-r)*6:e},r.RGBToHSL=function(e){var t,r,o,a,s,i,n=e[0],u=e[1],c=e[2];return t=Math.min(n,Math.min(u,c)),r=Math.max(n,Math.max(u,c)),o=r-t,i=(t+r)/2,s=0,i>0&&i<1&&(s=o/(i<.5?2*i:2-2*i)),a=0,o>0&&(r==n&&r!=u&&(a+=(u-c)/o),r==u&&r!=c&&(a+=2+(c-n)/o),r==c&&r!=n&&(a+=4+(n-u)/o),a/=6),[a,s,i]},jQuery("*",o).mousedown(r.mousedown),r.setColor("#000000"),t&&r.linkTo(t)};
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: contact form, form builder, custom form, forms, form, form maker, form cre
4
  Requires at least: 4.4
5
  Tested up to: 4.9
6
  Requires PHP: 5.3
7
- Stable tag: 3.01
8
 
9
  The best WordPress form plugin for contact forms, surveys and more. Make forms a breeze with a drag and drop form builder and form style generator.
10
 
@@ -159,6 +159,15 @@ The field and form names and descriptions are all changed with in-place edit. Ju
159
  [See more FAQs](https://formidableforms.com/formidable-faqs/ "Formidable Form FAQs")
160
 
161
  == Changelog ==
 
 
 
 
 
 
 
 
 
162
  = 3.01 =
163
  * New: Added frm_js_location hook for saving the combined javascript file in a different location
164
  * New: Added frm_include_field_in_content hook for excluding fields in the default email message
4
  Requires at least: 4.4
5
  Tested up to: 4.9
6
  Requires PHP: 5.3
7
+ Stable tag: 3.01.01
8
 
9
  The best WordPress form plugin for contact forms, surveys and more. Make forms a breeze with a drag and drop form builder and form style generator.
10
 
159
  [See more FAQs](https://formidableforms.com/formidable-faqs/ "Formidable Form FAQs")
160
 
161
  == Changelog ==
162
+ = 3.01.01 =
163
+ * New: Replace the jQuery colorpicker with the WordPress colorpicker in the visual form styler
164
+ * New: Process shortcodes in the redirect url after form submission
165
+ * New: frm_override_default_styles and frm_default_style_settings hooks
166
+ * Fix: Prevent shortcodes inside field values from being processed in more places including the redirect url. This is a security precaution.
167
+ * Fix: A default contact form was being added with each update. This update ensures the contact form is only generated once.
168
+ * Fix: Allow the visual form styler to show instant changes to the sample contact form since server limits of url size were being hit in some cases.
169
+ * Fix: HTML was being stripped from some field settings on the form creator page like validation messages
170
+
171
  = 3.01 =
172
  * New: Added frm_js_location hook for saving the combined javascript file in a different location
173
  * New: Added frm_include_field_in_content hook for excluding fields in the default email message