Formidable Forms – Form Builder for WordPress - Version 2.0.13

Version Description

  • Allow css file updating if FTP creds are present
  • Add 'frm_ajax_url' hook
  • Allow layout classes to be used with submit button
  • Remove frm_last class
  • Prevent get_filesystem_method error in multisite after update
  • Conditionally use ssl for the ajax url for form submission
  • Pro Features:
  • Allow recaptcha to be conditionally hidden on previous pages of form
  • Fix error with embedded form on a conditionally hidden page
  • Show the editlink after an entry is edited in place
  • Make sure collapsible section icons show regardless of characters in the section title
  • Don't require conditionally hidden dynamic category fields
  • Add fields attribute to [editlink] shortcode
  • Fix calculations using repeating checkboxes
  • Prevent double click on Add button in repeating section
  • Clear conditionally hidden fields even if they aren't visible
  • Make sure pro templates get imported in multisite
  • Use separate values by default for post status fields
  • Make sure the separate values option is allows for post status fields
  • Show the frmcal-week-end class consistently
  • Fix default values in repeating Dynamic fields
  • Make Private Views show up in shortcode builder
  • Don't do calculations in conditionally hidden repeating fields
  • Do calcs in repeating fields when adding a row
  • Improve JS for IE8
  • Fix unique time error
  • Fix default date in jQuery calendar
  • Allow entry key with frm-field-value shortcode
  • Fix unique time error
  • Improve calculations across page breaks
  • Prevent clearing default values when hiding/showing sections
  • Run calculations in collapsible sections
  • Fix duplicating regular sections
  • Add post ID View filter
  • Fix empty graphs
  • Allow frm-entry-update-field, editlink, and deletelink inside foreach loop
  • Fix importing parent_form_id on child forms
Download this release

Release Info

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

Code changes from version 2.0.12 to 2.0.13

Files changed (41) hide show
  1. classes/controllers/FrmAddonsController.php +1 -1
  2. classes/controllers/FrmAppController.php +1 -1
  3. classes/controllers/FrmEntriesController.php +6 -7
  4. classes/controllers/FrmFieldsController.php +10 -10
  5. classes/controllers/FrmFormActionsController.php +7 -8
  6. classes/controllers/FrmFormsController.php +8 -8
  7. classes/controllers/FrmStatisticsController.php +0 -1
  8. classes/controllers/FrmStylesController.php +9 -9
  9. classes/controllers/FrmXMLController.php +2 -2
  10. classes/helpers/FrmAppHelper.php +43 -40
  11. classes/helpers/FrmEntriesHelper.php +47 -37
  12. classes/helpers/FrmFieldsHelper.php +19 -19
  13. classes/helpers/FrmFormsHelper.php +12 -11
  14. classes/helpers/FrmListHelper.php +0 -1
  15. classes/helpers/FrmStylesHelper.php +5 -5
  16. classes/helpers/FrmXMLHelper.php +161 -84
  17. classes/models/EDD_SL_Plugin_Updater.php +4 -5
  18. classes/models/FrmAddon.php +5 -8
  19. classes/models/FrmDb.php +5 -5
  20. classes/models/FrmEntry.php +3 -4
  21. classes/models/FrmEntryFormat.php +1 -2
  22. classes/models/FrmEntryMeta.php +10 -11
  23. classes/models/FrmEntryValidate.php +4 -4
  24. classes/models/FrmField.php +5 -5
  25. classes/models/FrmForm.php +7 -7
  26. classes/models/FrmFormAction.php +16 -16
  27. classes/models/FrmNotification.php +4 -4
  28. classes/models/FrmSettings.php +4 -5
  29. classes/models/FrmStyle.php +64 -10
  30. classes/views/addons/settings.php +2 -2
  31. classes/views/frm-entries/form.php +9 -0
  32. classes/views/frm-fields/show-build.php +1 -1
  33. classes/views/frm-form-actions/email_action.php +0 -1
  34. classes/views/frm-forms/add_field.php +1 -1
  35. classes/views/frm-forms/add_field_links.php +3 -4
  36. css/custom_theme.css.php +28 -4
  37. css/frm_admin.css +5 -4
  38. formidable.php +1 -1
  39. js/formidable.js +823 -428
  40. js/formidable.min.js +2 -65
  41. readme.txt +41 -2
classes/controllers/FrmAddonsController.php CHANGED
@@ -11,4 +11,4 @@ class FrmAddonsController {
11
 
12
  include( FrmAppHelper::plugin_path() . '/classes/views/addons/settings.php' );
13
  }
14
- }
11
 
12
  include( FrmAppHelper::plugin_path() . '/classes/views/addons/settings.php' );
13
  }
14
+ }
classes/controllers/FrmAppController.php CHANGED
@@ -256,7 +256,7 @@ class FrmAppController {
256
 
257
  $upgrade_url = add_query_arg( array( 'action' => 'frm_silent_upgrade' ), $upgrade_url );
258
  $r = wp_remote_get( esc_url_raw( $upgrade_url ) );
259
- if ( is_wp_error( $r ) ) {
260
  // if the remove post fails, use javascript instead
261
  add_action( 'admin_notices', 'FrmAppController::install_js_fallback' );
262
  }
256
 
257
  $upgrade_url = add_query_arg( array( 'action' => 'frm_silent_upgrade' ), $upgrade_url );
258
  $r = wp_remote_get( esc_url_raw( $upgrade_url ) );
259
+ if ( is_wp_error( $r ) || ! is_array( $r ) || ! empty( $r['body'] ) ) {
260
  // if the remove post fails, use javascript instead
261
  add_action( 'admin_notices', 'FrmAppController::install_js_fallback' );
262
  }
classes/controllers/FrmEntriesController.php CHANGED
@@ -35,7 +35,7 @@ class FrmEntriesController {
35
  }
36
  }
37
 
38
- public static function contextual_help($help, $screen_id, $screen) {
39
  // Only add to certain screens. add_help_tab was introduced in WordPress 3.3
40
  if ( $screen_id != 'formidable_page_formidable-entries' || ! method_exists( $screen, 'add_help_tab' ) ) {
41
  return $help;
@@ -140,7 +140,7 @@ class FrmEntriesController {
140
  }
141
 
142
  //add hidden columns back from other forms
143
- public static function update_hidden_cols($meta_id, $object_id, $meta_key, $meta_value ) {
144
  $frm_settings = FrmAppHelper::get_settings();
145
 
146
  $sanitized = sanitize_title($frm_settings->menu);
@@ -189,7 +189,7 @@ class FrmEntriesController {
189
  }
190
  }
191
 
192
- public static function save_per_page($save, $option, $value) {
193
  if ( $option == 'formidable_page_formidable_entries_per_page' ) {
194
  $save = (int) $value;
195
  }
@@ -219,7 +219,7 @@ class FrmEntriesController {
219
  return $columns;
220
  }
221
 
222
- public static function hidden_columns($result) {
223
  global $frm_vars;
224
 
225
  $form_id = FrmForm::get_current_form_id();
@@ -498,7 +498,7 @@ class FrmEntriesController {
498
  return $value;
499
  }
500
 
501
- public static function &filter_shortcode_value($value, $tag, $atts, $field) {
502
  $plain_text = add_filter('frm_plain_text_email', true);
503
  FrmEntryFormat::textarea_display_value( $field->type, $plain_text, $value );
504
 
@@ -552,7 +552,7 @@ class FrmEntriesController {
552
  return FrmForm::get_params( $form );
553
  }
554
 
555
- public static function entry_sidebar($entry) {
556
  $data = maybe_unserialize($entry->description);
557
  $date_format = get_option('date_format');
558
  $time_format = get_option('time_format');
@@ -562,5 +562,4 @@ class FrmEntriesController {
562
 
563
  include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/sidebar-shared.php');
564
  }
565
-
566
  }
35
  }
36
  }
37
 
38
+ public static function contextual_help( $help, $screen_id, $screen ) {
39
  // Only add to certain screens. add_help_tab was introduced in WordPress 3.3
40
  if ( $screen_id != 'formidable_page_formidable-entries' || ! method_exists( $screen, 'add_help_tab' ) ) {
41
  return $help;
140
  }
141
 
142
  //add hidden columns back from other forms
143
+ public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) {
144
  $frm_settings = FrmAppHelper::get_settings();
145
 
146
  $sanitized = sanitize_title($frm_settings->menu);
189
  }
190
  }
191
 
192
+ public static function save_per_page( $save, $option, $value ) {
193
  if ( $option == 'formidable_page_formidable_entries_per_page' ) {
194
  $save = (int) $value;
195
  }
219
  return $columns;
220
  }
221
 
222
+ public static function hidden_columns( $result ) {
223
  global $frm_vars;
224
 
225
  $form_id = FrmForm::get_current_form_id();
498
  return $value;
499
  }
500
 
501
+ public static function &filter_shortcode_value( $value, $tag, $atts, $field ) {
502
  $plain_text = add_filter('frm_plain_text_email', true);
503
  FrmEntryFormat::textarea_display_value( $field->type, $plain_text, $value );
504
 
552
  return FrmForm::get_params( $form );
553
  }
554
 
555
+ public static function entry_sidebar( $entry ) {
556
  $data = maybe_unserialize($entry->description);
557
  $date_format = get_option('date_format');
558
  $time_format = get_option('time_format');
562
 
563
  include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/sidebar-shared.php');
564
  }
 
565
  }
classes/controllers/FrmFieldsController.php CHANGED
@@ -65,7 +65,7 @@ class FrmFieldsController {
65
  /**
66
  * @param integer $form_id
67
  */
68
- public static function include_new_field($field_type, $form_id) {
69
  $values = array();
70
  if ( FrmAppHelper::pro_is_installed() ) {
71
  $values['post_type'] = FrmProFormsHelper::post_type($form_id);
@@ -99,7 +99,7 @@ class FrmFieldsController {
99
  wp_die();
100
  }
101
 
102
- public static function edit_name($field = 'name', $id = '') {
103
  check_ajax_referer( 'frm_ajax', 'nonce' );
104
 
105
  if ( empty($field) ) {
@@ -482,7 +482,7 @@ class FrmFieldsController {
482
  wp_die();
483
  }
484
 
485
- public static function change_type($type) {
486
  $type_switch = array(
487
  'scale' => 'radio',
488
  '10radio' => 'radio',
@@ -502,7 +502,7 @@ class FrmFieldsController {
502
  return $type;
503
  }
504
 
505
- public static function display_field_options($display) {
506
  switch ( $display['type'] ) {
507
  case 'captcha':
508
  $display['required'] = false;
@@ -555,7 +555,7 @@ class FrmFieldsController {
555
  return $add_html;
556
  }
557
 
558
- private static function add_input_classes($field, array &$class) {
559
  if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
560
  $class[] = $field['input_class'];
561
  }
@@ -574,7 +574,7 @@ class FrmFieldsController {
574
  }
575
  }
576
 
577
- private static function add_html_size($field, array &$add_html) {
578
  if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], array( 'select', 'data', 'time', 'hidden' ) ) ) {
579
  return;
580
  }
@@ -594,7 +594,7 @@ class FrmFieldsController {
594
  self::add_html_cols($field, $add_html);
595
  }
596
 
597
- private static function add_html_cols($field, array &$add_html) {
598
  if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) {
599
  return;
600
  }
@@ -619,7 +619,7 @@ class FrmFieldsController {
619
  $add_html['cols'] = 'cols="' . absint( $size ) . '"';
620
  }
621
 
622
- private static function add_html_length($field, array &$add_html) {
623
  // check for max setting and if this field accepts maxlength
624
  if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden' ) ) ) {
625
  return;
@@ -633,7 +633,7 @@ class FrmFieldsController {
633
  $add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"';
634
  }
635
 
636
- private static function add_html_placeholder($field, array &$add_html, array &$class) {
637
  if ( empty( $field['default_value'] ) || FrmAppHelper::is_admin_page( 'formidable' ) ) {
638
  return;
639
  }
@@ -696,7 +696,7 @@ class FrmFieldsController {
696
  return $opt;
697
  }
698
 
699
- public static function check_label($opt) {
700
  if ( is_array($opt) ) {
701
  $opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
702
  }
65
  /**
66
  * @param integer $form_id
67
  */
68
+ public static function include_new_field( $field_type, $form_id ) {
69
  $values = array();
70
  if ( FrmAppHelper::pro_is_installed() ) {
71
  $values['post_type'] = FrmProFormsHelper::post_type($form_id);
99
  wp_die();
100
  }
101
 
102
+ public static function edit_name( $field = 'name', $id = '' ) {
103
  check_ajax_referer( 'frm_ajax', 'nonce' );
104
 
105
  if ( empty($field) ) {
482
  wp_die();
483
  }
484
 
485
+ public static function change_type( $type ) {
486
  $type_switch = array(
487
  'scale' => 'radio',
488
  '10radio' => 'radio',
502
  return $type;
503
  }
504
 
505
+ public static function display_field_options( $display ) {
506
  switch ( $display['type'] ) {
507
  case 'captcha':
508
  $display['required'] = false;
555
  return $add_html;
556
  }
557
 
558
+ private static function add_input_classes( $field, array &$class ) {
559
  if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
560
  $class[] = $field['input_class'];
561
  }
574
  }
575
  }
576
 
577
+ private static function add_html_size( $field, array &$add_html ) {
578
  if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], array( 'select', 'data', 'time', 'hidden' ) ) ) {
579
  return;
580
  }
594
  self::add_html_cols($field, $add_html);
595
  }
596
 
597
+ private static function add_html_cols( $field, array &$add_html ) {
598
  if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) {
599
  return;
600
  }
619
  $add_html['cols'] = 'cols="' . absint( $size ) . '"';
620
  }
621
 
622
+ private static function add_html_length( $field, array &$add_html ) {
623
  // check for max setting and if this field accepts maxlength
624
  if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden' ) ) ) {
625
  return;
633
  $add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"';
634
  }
635
 
636
+ private static function add_html_placeholder( $field, array &$add_html, array &$class ) {
637
  if ( empty( $field['default_value'] ) || FrmAppHelper::is_admin_page( 'formidable' ) ) {
638
  return;
639
  }
696
  return $opt;
697
  }
698
 
699
+ public static function check_label( $opt ) {
700
  if ( is_array($opt) ) {
701
  $opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
702
  }
classes/controllers/FrmFormActionsController.php CHANGED
@@ -56,7 +56,7 @@ class FrmFormActionsController {
56
  }
57
  }
58
 
59
- public static function get_form_actions($action = 'all' ) {
60
  $temp_actions = self::$registered_actions;
61
  if ( empty($temp_actions) ) {
62
  self::actions_init();
@@ -131,7 +131,7 @@ class FrmFormActionsController {
131
  }
132
  }
133
 
134
- public static function action_control($form_action, $form, $action_key, $action_control, $values) {
135
  $action_control->_set($action_key);
136
  include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php');
137
  }
@@ -178,7 +178,7 @@ class FrmFormActionsController {
178
  wp_die();
179
  }
180
 
181
- private static function fields_to_values($form_id, array &$values) {
182
  $form = FrmForm::getOne($form_id);
183
 
184
  $values = array( 'fields' => array(), 'id' => $form->id );
@@ -198,7 +198,7 @@ class FrmFormActionsController {
198
  return $form;
199
  }
200
 
201
- public static function update_settings($form_id) {
202
  global $wpdb;
203
 
204
  $registered_actions = self::$registered_actions->actions;
@@ -309,7 +309,7 @@ class FrmFormActionsController {
309
  }
310
  }
311
 
312
- public static function duplicate_form_actions($form_id, $values, $args = array() ) {
313
  if ( ! isset($args['old_id']) || empty($args['old_id']) ) {
314
  // continue if we know which actions to copy
315
  return;
@@ -333,7 +333,6 @@ class FrmFormActionsController {
333
  $where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] );
334
  return $where;
335
  }
336
-
337
  }
338
 
339
 
@@ -344,11 +343,11 @@ class Frm_Form_Action_Factory {
344
  add_action( 'frm_form_actions_init', array( $this, '_register_actions' ), 100 );
345
  }
346
 
347
- public function register($action_class) {
348
  $this->actions[ $action_class ] = new $action_class();
349
  }
350
 
351
- public function unregister($action_class) {
352
  if ( isset( $this->actions[ $action_class ] ) ) {
353
  unset($this->actions[ $action_class ]);
354
  }
56
  }
57
  }
58
 
59
+ public static function get_form_actions( $action = 'all' ) {
60
  $temp_actions = self::$registered_actions;
61
  if ( empty($temp_actions) ) {
62
  self::actions_init();
131
  }
132
  }
133
 
134
+ public static function action_control( $form_action, $form, $action_key, $action_control, $values ) {
135
  $action_control->_set($action_key);
136
  include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php');
137
  }
178
  wp_die();
179
  }
180
 
181
+ private static function fields_to_values( $form_id, array &$values ) {
182
  $form = FrmForm::getOne($form_id);
183
 
184
  $values = array( 'fields' => array(), 'id' => $form->id );
198
  return $form;
199
  }
200
 
201
+ public static function update_settings( $form_id ) {
202
  global $wpdb;
203
 
204
  $registered_actions = self::$registered_actions->actions;
309
  }
310
  }
311
 
312
+ public static function duplicate_form_actions( $form_id, $values, $args = array() ) {
313
  if ( ! isset($args['old_id']) || empty($args['old_id']) ) {
314
  // continue if we know which actions to copy
315
  return;
333
  $where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] );
334
  return $where;
335
  }
 
336
  }
337
 
338
 
343
  add_action( 'frm_form_actions_init', array( $this, '_register_actions' ), 100 );
344
  }
345
 
346
+ public function register( $action_class ) {
347
  $this->actions[ $action_class ] = new $action_class();
348
  }
349
 
350
+ public function unregister( $action_class ) {
351
  if ( isset( $this->actions[ $action_class ] ) ) {
352
  unset($this->actions[ $action_class ]);
353
  }
classes/controllers/FrmFormsController.php CHANGED
@@ -290,7 +290,7 @@ class FrmFormsController {
290
  self::change_form_status( 'untrash' );
291
  }
292
 
293
- public static function bulk_untrash($ids) {
294
  FrmAppHelper::permission_check('frm_edit_forms');
295
 
296
  $count = FrmForm::set_status( $ids, 'published' );
@@ -338,7 +338,7 @@ class FrmFormsController {
338
  self::display_forms_list( $params, $message );
339
  }
340
 
341
- public static function bulk_trash($ids) {
342
  FrmAppHelper::permission_check('frm_delete_forms');
343
 
344
  $count = 0;
@@ -372,7 +372,7 @@ class FrmFormsController {
372
  self::display_forms_list( $params, $message );
373
  }
374
 
375
- public static function bulk_destroy($ids) {
376
  FrmAppHelper::permission_check('frm_delete_forms');
377
 
378
  $count = 0;
@@ -407,7 +407,7 @@ class FrmFormsController {
407
  return FrmForm::scheduled_delete( $delete_timestamp );
408
  }
409
 
410
- public static function insert_form_button($content) {
411
  if ( current_user_can('frm_view_forms') ) {
412
  $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' ) ) . '"><span class="frm-buttons-icon wp-media-buttons-icon"></span> Formidable</a>';
413
 
@@ -499,7 +499,7 @@ class FrmFormsController {
499
  require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/list.php');
500
  }
501
 
502
- public static function get_columns($columns) {
503
  $columns['cb'] = '<input type="checkbox" />';
504
  $columns['id'] = 'ID';
505
 
@@ -714,7 +714,7 @@ class FrmFormsController {
714
  }
715
 
716
  // Insert the form class setting into the form
717
- public static function form_classes($form) {
718
  if ( isset($form->options['form_class']) ) {
719
  echo esc_attr( sanitize_text_field( $form->options['form_class'] ) );
720
  }
@@ -990,7 +990,7 @@ class FrmFormsController {
990
  }
991
 
992
  //formidable shortcode
993
- public static function get_form_shortcode($atts) {
994
  global $frm_vars;
995
  if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) {
996
  $sc = '[formidable';
@@ -1090,7 +1090,7 @@ class FrmFormsController {
1090
  do_action( 'frm_enqueue_form_scripts', $params );
1091
  }
1092
 
1093
- public static function get_form_contents($form, $title, $description, $atts) {
1094
  global $frm_vars;
1095
 
1096
  $frm_settings = FrmAppHelper::get_settings();
290
  self::change_form_status( 'untrash' );
291
  }
292
 
293
+ public static function bulk_untrash( $ids ) {
294
  FrmAppHelper::permission_check('frm_edit_forms');
295
 
296
  $count = FrmForm::set_status( $ids, 'published' );
338
  self::display_forms_list( $params, $message );
339
  }
340
 
341
+ public static function bulk_trash( $ids ) {
342
  FrmAppHelper::permission_check('frm_delete_forms');
343
 
344
  $count = 0;
372
  self::display_forms_list( $params, $message );
373
  }
374
 
375
+ public static function bulk_destroy( $ids ) {
376
  FrmAppHelper::permission_check('frm_delete_forms');
377
 
378
  $count = 0;
407
  return FrmForm::scheduled_delete( $delete_timestamp );
408
  }
409
 
410
+ public static function insert_form_button( $content ) {
411
  if ( current_user_can('frm_view_forms') ) {
412
  $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' ) ) . '"><span class="frm-buttons-icon wp-media-buttons-icon"></span> Formidable</a>';
413
 
499
  require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/list.php');
500
  }
501
 
502
+ public static function get_columns( $columns ) {
503
  $columns['cb'] = '<input type="checkbox" />';
504
  $columns['id'] = 'ID';
505
 
714
  }
715
 
716
  // Insert the form class setting into the form
717
+ public static function form_classes( $form ) {
718
  if ( isset($form->options['form_class']) ) {
719
  echo esc_attr( sanitize_text_field( $form->options['form_class'] ) );
720
  }
990
  }
991
 
992
  //formidable shortcode
993
+ public static function get_form_shortcode( $atts ) {
994
  global $frm_vars;
995
  if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) {
996
  $sc = '[formidable';
1090
  do_action( 'frm_enqueue_form_scripts', $params );
1091
  }
1092
 
1093
+ public static function get_form_contents( $form, $title, $description, $atts ) {
1094
  global $frm_vars;
1095
 
1096
  $frm_settings = FrmAppHelper::get_settings();
classes/controllers/FrmStatisticsController.php CHANGED
@@ -16,5 +16,4 @@ class FrmStatisticsController {
16
  $form = FrmAppHelper::get_param( 'form', false, 'get', 'sanitize_title' );
17
  require( FrmAppHelper::plugin_path() . '/classes/views/frm-statistics/list_displays.php' );
18
  }
19
-
20
  }
16
  $form = FrmAppHelper::get_param( 'form', false, 'get', 'sanitize_title' );
17
  require( FrmAppHelper::plugin_path() . '/classes/views/frm-statistics/list_displays.php' );
18
  }
 
19
  }
classes/controllers/FrmStylesController.php CHANGED
@@ -127,12 +127,12 @@ class FrmStylesController {
127
  }
128
  }
129
 
130
- public static function new_style($return = '') {
131
  FrmAppHelper::update_message( __( 'create multiple styling templates', 'formidable' ), 'wrap' );
132
  self::load_styler('default');
133
  }
134
 
135
- public static function edit($style_id = false, $message = '') {
136
  if ( ! $style_id ) {
137
  $style_id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
138
  if ( empty($style_id) ) {
@@ -171,7 +171,7 @@ class FrmStylesController {
171
  return self::edit($post_id, $message);
172
  }
173
 
174
- public static function load_styler($style, $message = '') {
175
  global $frm_settings;
176
 
177
  $frm_style = new FrmStyle();
@@ -192,7 +192,7 @@ class FrmStylesController {
192
  * @param string $message
193
  * @param array $forms
194
  */
195
- private static function manage($message = '', $forms = array()) {
196
  $frm_style = new FrmStyle();
197
  $styles = $frm_style->get_all();
198
  $default_style = $frm_style->get_default_style($styles);
@@ -331,7 +331,7 @@ class FrmStylesController {
331
  }
332
  }
333
 
334
- public static function include_style_section($atts, $sec) {
335
  extract($atts);
336
  $current_tab = FrmAppHelper::simple_get( 'page-tab', 'sanitize_title', 'default' );
337
  include(FrmAppHelper::plugin_path() .'/classes/views/styles/_'. $sec['args'] .'.php');
@@ -397,7 +397,7 @@ class FrmStylesController {
397
  * @param string $class
398
  * @param string $style
399
  */
400
- public static function get_form_style_class($class, $style) {
401
  if ( 1 == $style ) {
402
  $style = 'default';
403
  }
@@ -415,14 +415,14 @@ class FrmStylesController {
415
  /**
416
  * @param string $val
417
  */
418
- public static function get_style_val($val, $form = 'default') {
419
  $style = self::get_form_style($form);
420
  if ( $style && isset( $style->post_content[ $val ] ) ) {
421
  return $style->post_content[ $val ];
422
  }
423
  }
424
 
425
- public static function show_entry_styles($default_styles) {
426
  $frm_style = new FrmStyle('default');
427
  $style = $frm_style->get_one();
428
 
@@ -444,7 +444,7 @@ class FrmStylesController {
444
  return $default_styles;
445
  }
446
 
447
- public static function &important_style($important, $field) {
448
  $important = self::get_style_val('important_style', $field['form_id']);
449
  return $important;
450
  }
127
  }
128
  }
129
 
130
+ public static function new_style( $return = '' ) {
131
  FrmAppHelper::update_message( __( 'create multiple styling templates', 'formidable' ), 'wrap' );
132
  self::load_styler('default');
133
  }
134
 
135
+ public static function edit( $style_id = false, $message = '' ) {
136
  if ( ! $style_id ) {
137
  $style_id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
138
  if ( empty($style_id) ) {
171
  return self::edit($post_id, $message);
172
  }
173
 
174
+ public static function load_styler( $style, $message = '' ) {
175
  global $frm_settings;
176
 
177
  $frm_style = new FrmStyle();
192
  * @param string $message
193
  * @param array $forms
194
  */
195
+ private static function manage( $message = '', $forms = array() ) {
196
  $frm_style = new FrmStyle();
197
  $styles = $frm_style->get_all();
198
  $default_style = $frm_style->get_default_style($styles);
331
  }
332
  }
333
 
334
+ public static function include_style_section( $atts, $sec ) {
335
  extract($atts);
336
  $current_tab = FrmAppHelper::simple_get( 'page-tab', 'sanitize_title', 'default' );
337
  include(FrmAppHelper::plugin_path() .'/classes/views/styles/_'. $sec['args'] .'.php');
397
  * @param string $class
398
  * @param string $style
399
  */
400
+ public static function get_form_style_class( $class, $style ) {
401
  if ( 1 == $style ) {
402
  $style = 'default';
403
  }
415
  /**
416
  * @param string $val
417
  */
418
+ public static function get_style_val( $val, $form = 'default' ) {
419
  $style = self::get_form_style($form);
420
  if ( $style && isset( $style->post_content[ $val ] ) ) {
421
  return $style->post_content[ $val ];
422
  }
423
  }
424
 
425
+ public static function show_entry_styles( $default_styles ) {
426
  $frm_style = new FrmStyle('default');
427
  $style = $frm_style->get_one();
428
 
444
  return $default_styles;
445
  }
446
 
447
+ public static function &important_style( $important, $field ) {
448
  $important = self::get_style_val('important_style', $field['form_id']);
449
  return $important;
450
  }
classes/controllers/FrmXMLController.php CHANGED
@@ -155,7 +155,7 @@ class FrmXMLController {
155
  wp_die();
156
  }
157
 
158
- public static function generate_xml($type, $args = array() ) {
159
  global $wpdb;
160
 
161
  $type = (array) $type;
@@ -269,7 +269,7 @@ class FrmXMLController {
269
  include(FrmAppHelper::plugin_path() .'/classes/views/xml/xml.php');
270
  }
271
 
272
- public static function allow_mime($mimes) {
273
  if ( ! isset( $mimes['csv'] ) ) {
274
  // allow csv files
275
  $mimes['csv'] = 'text/csv';
155
  wp_die();
156
  }
157
 
158
+ public static function generate_xml( $type, $args = array() ) {
159
  global $wpdb;
160
 
161
  $type = (array) $type;
269
  include(FrmAppHelper::plugin_path() .'/classes/views/xml/xml.php');
270
  }
271
 
272
+ public static function allow_mime( $mimes ) {
273
  if ( ! isset( $mimes['csv'] ) ) {
274
  // allow csv files
275
  $mimes['csv'] = 'text/csv';
classes/helpers/FrmAppHelper.php CHANGED
@@ -5,12 +5,12 @@ if ( ! defined('ABSPATH') ) {
5
 
6
  class FrmAppHelper {
7
  public static $db_version = 26; //version of the database we are moving to
8
- public static $pro_db_version = 29;
9
 
10
  /**
11
  * @since 2.0
12
  */
13
- public static $plug_version = '2.0.12';
14
 
15
  /**
16
  * @since 1.07.02
@@ -78,7 +78,7 @@ class FrmAppHelper {
78
  *
79
  * @since 2.0
80
  */
81
- public static function update_message($features, $class = '') {
82
  return; // hide the upgrade messages for now
83
  if ( ! self::pro_is_installed() ) {
84
  include(self::plugin_path() .'/classes/views/shared/update_message.php');
@@ -97,7 +97,7 @@ class FrmAppHelper {
97
  * @param string $page The name of the page to check
98
  * @return boolean
99
  */
100
- public static function is_admin_page($page = 'formidable' ) {
101
  global $pagenow;
102
  $get_page = self::simple_get( 'page', 'sanitize_title' );
103
  if ( $pagenow ) {
@@ -175,7 +175,7 @@ class FrmAppHelper {
175
  * @param string $value
176
  * @return string
177
  */
178
- public static function get_server_value($value) {
179
  return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
180
  }
181
 
@@ -434,7 +434,7 @@ class FrmAppHelper {
434
  * @since 2.0
435
  * @return mixed The cached value or false
436
  */
437
- public static function check_cache_and_transient($cache_key) {
438
  // check caching layer first
439
  $results = self::check_cache( $cache_key );
440
  if ( $results ) {
@@ -454,7 +454,7 @@ class FrmAppHelper {
454
  * @since 2.0
455
  * @param string $cache_key
456
  */
457
- public static function delete_cache_and_transient($cache_key) {
458
  delete_transient($cache_key);
459
  wp_cache_delete($cache_key);
460
  }
@@ -467,7 +467,7 @@ class FrmAppHelper {
467
  * @param string $group The name of the cache group
468
  * @return boolean True or False
469
  */
470
- public static function cache_delete_group($group) {
471
  global $wp_object_cache;
472
 
473
  if ( isset( $wp_object_cache->cache[ $group ] ) ) {
@@ -489,7 +489,7 @@ class FrmAppHelper {
489
  * @param string $value The value to compare
490
  * @return boolean True or False
491
  */
492
- public static function is_true($value) {
493
  return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
494
  }
495
 
@@ -500,14 +500,14 @@ class FrmAppHelper {
500
  return do_shortcode( $matches[0] );
501
  }
502
 
503
- public static function load_scripts($scripts) {
504
  _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_script' );
505
  foreach ( (array) $scripts as $s ) {
506
  wp_enqueue_script($s);
507
  }
508
  }
509
 
510
- public static function load_styles($styles) {
511
  _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_style' );
512
  foreach ( (array) $styles as $s ) {
513
  wp_enqueue_style($s);
@@ -533,7 +533,7 @@ class FrmAppHelper {
533
  <?php
534
  }
535
 
536
- public static function post_edit_link($post_id) {
537
  $post = get_post($post_id);
538
  if ( $post ) {
539
  return '<a href="'. esc_url(admin_url('post.php') .'?post='. $post_id .'&action=edit') .'">'. self::truncate($post->post_title, 50) .'</a>';
@@ -541,7 +541,7 @@ class FrmAppHelper {
541
  return '';
542
  }
543
 
544
- public static function wp_roles_dropdown($field_name, $capability, $multiple = 'single') {
545
  $capability = (array) self::get_param($field_name, $capability, 'post');
546
 
547
  ?>
@@ -553,7 +553,7 @@ class FrmAppHelper {
553
  <?php
554
  }
555
 
556
- public static function roles_options($capability) {
557
  global $frm_vars;
558
  if ( isset($frm_vars['editable_roles']) ) {
559
  $editable_roles = $frm_vars['editable_roles'];
@@ -570,7 +570,7 @@ class FrmAppHelper {
570
  }
571
  }
572
 
573
- public static function frm_capabilities($type = 'auto') {
574
  $cap = array(
575
  'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ),
576
  'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ),
@@ -592,7 +592,7 @@ class FrmAppHelper {
592
  return $cap;
593
  }
594
 
595
- public static function user_has_permission($needed_role) {
596
  if ( $needed_role == '-1' ) {
597
  return false;
598
  }
@@ -655,7 +655,7 @@ class FrmAppHelper {
655
  * @since 2.0
656
  * @param string $permission
657
  */
658
- public static function permission_check($permission, $show_message = 'show') {
659
  $permission_error = self::permission_nonce_error($permission);
660
  if ( $permission_error !== false ) {
661
  if ( 'hide' == $show_message ) {
@@ -671,7 +671,7 @@ class FrmAppHelper {
671
  * @param string $permission
672
  * @return false|string The permission message or false if allowed
673
  */
674
- public static function permission_nonce_error($permission, $nonce_name = '', $nonce = '') {
675
  if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) {
676
  $frm_settings = self::get_settings();
677
  return $frm_settings->admin_permission;
@@ -696,7 +696,7 @@ class FrmAppHelper {
696
  }
697
  }
698
 
699
- public static function check_selected($values, $current) {
700
  $values = self::recursive_function_map( $values, 'trim' );
701
  $current = trim($current);
702
 
@@ -805,14 +805,14 @@ class FrmAppHelper {
805
  * Add auto paragraphs to text areas
806
  * @since 2.0
807
  */
808
- public static function use_wpautop($content) {
809
  if ( apply_filters('frm_use_wpautop', true) ) {
810
  $content = wpautop(str_replace( '<br>', '<br />', $content));
811
  }
812
  return $content;
813
  }
814
 
815
- public static function replace_quotes($val) {
816
  //Replace double quotes
817
  $val = str_replace( array( '&#8220;', '&#8221;', '&#8243;' ), '"', $val );
818
  //Replace single quotes
@@ -833,7 +833,7 @@ class FrmAppHelper {
833
  /**
834
  * @param string $handle
835
  */
836
- public static function script_version($handle) {
837
  global $wp_scripts;
838
  if ( ! $wp_scripts ) {
839
  return false;
@@ -853,11 +853,11 @@ class FrmAppHelper {
853
  return $ver;
854
  }
855
 
856
- public static function js_redirect($url) {
857
  return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>';
858
  }
859
 
860
- public static function get_user_id_param($user_id) {
861
  if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
862
  return $user_id;
863
  }
@@ -881,7 +881,7 @@ class FrmAppHelper {
881
  return $user_id;
882
  }
883
 
884
- public static function get_file_contents($filename, $atts = array()) {
885
  if ( ! is_file($filename) ) {
886
  return false;
887
  }
@@ -978,7 +978,7 @@ class FrmAppHelper {
978
  return $values;
979
  }
980
 
981
- private static function fill_field_defaults($field, $record, array &$values, $args) {
982
  $post_values = $args['post_values'];
983
 
984
  if ( $args['default'] ) {
@@ -1025,7 +1025,7 @@ class FrmAppHelper {
1025
  $values['fields'][ $field->id ] = $field_array;
1026
  }
1027
 
1028
- private static function fill_field_opts($field, array &$field_array, $args) {
1029
  $post_values = $args['post_values'];
1030
  $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1031
 
@@ -1050,7 +1050,7 @@ class FrmAppHelper {
1050
  /**
1051
  * @param string $table
1052
  */
1053
- private static function fill_form_opts($record, $table, $post_values, array &$values) {
1054
  if ( $table == 'entries' ) {
1055
  $form = $record->form_id;
1056
  FrmForm::maybe_get_form( $form );
@@ -1079,7 +1079,7 @@ class FrmAppHelper {
1079
  /**
1080
  * Set to POST value or default
1081
  */
1082
- private static function fill_form_defaults($post_values, array &$values) {
1083
  $form_defaults = FrmFormsHelper::get_default_opts();
1084
 
1085
  foreach ( $form_defaults as $opt => $default ) {
@@ -1108,7 +1108,7 @@ class FrmAppHelper {
1108
  return FrmEntryMeta::get_meta_value( $entry, $field_id );
1109
  }
1110
 
1111
- public static function insert_opt_html($args) {
1112
  $class = '';
1113
  if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) {
1114
  $class .= 'show_frm_not_email_to';
@@ -1132,7 +1132,7 @@ class FrmAppHelper {
1132
  return FrmFieldsHelper::get_countries();
1133
  }
1134
 
1135
- public static function truncate($str, $length, $minword = 3, $continue = '...') {
1136
  if ( is_array( $str ) ) {
1137
  return;
1138
  }
@@ -1182,7 +1182,7 @@ class FrmAppHelper {
1182
  return call_user_func_array( $function_name, $args );
1183
  }
1184
 
1185
- public static function get_formatted_time($date, $date_format = '', $time_format = '' ) {
1186
  if ( empty($date) ) {
1187
  return $date;
1188
  }
@@ -1292,7 +1292,7 @@ class FrmAppHelper {
1292
  * @param string $term The value to escape
1293
  * @return string The escaped value
1294
  */
1295
- public static function esc_like($term) {
1296
  global $wpdb;
1297
  if ( method_exists($wpdb, 'esc_like') ) {
1298
  // WP 4.0
@@ -1307,7 +1307,7 @@ class FrmAppHelper {
1307
  /**
1308
  * @param string $order_query
1309
  */
1310
- public static function esc_order($order_query) {
1311
  if ( empty($order_query) ) {
1312
  return '';
1313
  }
@@ -1353,7 +1353,7 @@ class FrmAppHelper {
1353
  /**
1354
  * @param string $limit
1355
  */
1356
- public static function esc_limit($limit) {
1357
  if ( empty($limit) ) {
1358
  return '';
1359
  }
@@ -1500,7 +1500,7 @@ class FrmAppHelper {
1500
  }
1501
  }
1502
 
1503
- public static function maybe_add_tooltip($name, $class = 'closed', $form_name = '') {
1504
  $tooltips = array(
1505
  'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ),
1506
  'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <name@email.com> or name@email.com. [admin_email] is the address set in WP General Settings.', 'formidable' ),
@@ -1634,7 +1634,7 @@ class FrmAppHelper {
1634
  return $post;
1635
  }
1636
 
1637
- public static function maybe_json_decode($string) {
1638
  if ( is_array($string) ) {
1639
  return $string;
1640
  }
@@ -1658,7 +1658,7 @@ class FrmAppHelper {
1658
  * @param string $post_type The name of the post type that may need to be highlighted
1659
  * @return echo The javascript to open and highlight the Formidable menu
1660
  */
1661
- public static function maybe_highlight_menu($post_type) {
1662
  global $post, $pagenow;
1663
 
1664
  if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
@@ -1705,8 +1705,11 @@ class FrmAppHelper {
1705
  * @param string $location
1706
  */
1707
  public static function localize_script( $location ) {
 
 
 
1708
  wp_localize_script( 'formidable', 'frm_js', array(
1709
- 'ajax_url' => admin_url( 'admin-ajax.php' ),
1710
  'images_url' => self::plugin_url() . '/images',
1711
  'loading' => __( 'Loading&hellip;' ),
1712
  'remove' => __( 'Remove', 'formidable' ),
@@ -1756,7 +1759,7 @@ class FrmAppHelper {
1756
  * @param float $min_version The version the add-on requires
1757
  * @return echo The message on the plugins listing page
1758
  */
1759
- public static function min_version_notice($min_version) {
1760
  $frm_version = self::plugin_version();
1761
 
1762
  // check if Formidable meets minimum requirements
5
 
6
  class FrmAppHelper {
7
  public static $db_version = 26; //version of the database we are moving to
8
+ public static $pro_db_version = 30;
9
 
10
  /**
11
  * @since 2.0
12
  */
13
+ public static $plug_version = '2.0.13';
14
 
15
  /**
16
  * @since 1.07.02
78
  *
79
  * @since 2.0
80
  */
81
+ public static function update_message( $features, $class = '' ) {
82
  return; // hide the upgrade messages for now
83
  if ( ! self::pro_is_installed() ) {
84
  include(self::plugin_path() .'/classes/views/shared/update_message.php');
97
  * @param string $page The name of the page to check
98
  * @return boolean
99
  */
100
+ public static function is_admin_page( $page = 'formidable' ) {
101
  global $pagenow;
102
  $get_page = self::simple_get( 'page', 'sanitize_title' );
103
  if ( $pagenow ) {
175
  * @param string $value
176
  * @return string
177
  */
178
+ public static function get_server_value( $value ) {
179
  return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
180
  }
181
 
434
  * @since 2.0
435
  * @return mixed The cached value or false
436
  */
437
+ public static function check_cache_and_transient( $cache_key ) {
438
  // check caching layer first
439
  $results = self::check_cache( $cache_key );
440
  if ( $results ) {
454
  * @since 2.0
455
  * @param string $cache_key
456
  */
457
+ public static function delete_cache_and_transient( $cache_key ) {
458
  delete_transient($cache_key);
459
  wp_cache_delete($cache_key);
460
  }
467
  * @param string $group The name of the cache group
468
  * @return boolean True or False
469
  */
470
+ public static function cache_delete_group( $group ) {
471
  global $wp_object_cache;
472
 
473
  if ( isset( $wp_object_cache->cache[ $group ] ) ) {
489
  * @param string $value The value to compare
490
  * @return boolean True or False
491
  */
492
+ public static function is_true( $value ) {
493
  return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
494
  }
495
 
500
  return do_shortcode( $matches[0] );
501
  }
502
 
503
+ public static function load_scripts( $scripts ) {
504
  _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_script' );
505
  foreach ( (array) $scripts as $s ) {
506
  wp_enqueue_script($s);
507
  }
508
  }
509
 
510
+ public static function load_styles( $styles ) {
511
  _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_style' );
512
  foreach ( (array) $styles as $s ) {
513
  wp_enqueue_style($s);
533
  <?php
534
  }
535
 
536
+ public static function post_edit_link( $post_id ) {
537
  $post = get_post($post_id);
538
  if ( $post ) {
539
  return '<a href="'. esc_url(admin_url('post.php') .'?post='. $post_id .'&action=edit') .'">'. self::truncate($post->post_title, 50) .'</a>';
541
  return '';
542
  }
543
 
544
+ public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
545
  $capability = (array) self::get_param($field_name, $capability, 'post');
546
 
547
  ?>
553
  <?php
554
  }
555
 
556
+ public static function roles_options( $capability ) {
557
  global $frm_vars;
558
  if ( isset($frm_vars['editable_roles']) ) {
559
  $editable_roles = $frm_vars['editable_roles'];
570
  }
571
  }
572
 
573
+ public static function frm_capabilities( $type = 'auto' ) {
574
  $cap = array(
575
  'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ),
576
  'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ),
592
  return $cap;
593
  }
594
 
595
+ public static function user_has_permission( $needed_role ) {
596
  if ( $needed_role == '-1' ) {
597
  return false;
598
  }
655
  * @since 2.0
656
  * @param string $permission
657
  */
658
+ public static function permission_check( $permission, $show_message = 'show' ) {
659
  $permission_error = self::permission_nonce_error($permission);
660
  if ( $permission_error !== false ) {
661
  if ( 'hide' == $show_message ) {
671
  * @param string $permission
672
  * @return false|string The permission message or false if allowed
673
  */
674
+ public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) {
675
  if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) {
676
  $frm_settings = self::get_settings();
677
  return $frm_settings->admin_permission;
696
  }
697
  }
698
 
699
+ public static function check_selected( $values, $current ) {
700
  $values = self::recursive_function_map( $values, 'trim' );
701
  $current = trim($current);
702
 
805
  * Add auto paragraphs to text areas
806
  * @since 2.0
807
  */
808
+ public static function use_wpautop( $content ) {
809
  if ( apply_filters('frm_use_wpautop', true) ) {
810
  $content = wpautop(str_replace( '<br>', '<br />', $content));
811
  }
812
  return $content;
813
  }
814
 
815
+ public static function replace_quotes( $val ) {
816
  //Replace double quotes
817
  $val = str_replace( array( '&#8220;', '&#8221;', '&#8243;' ), '"', $val );
818
  //Replace single quotes
833
  /**
834
  * @param string $handle
835
  */
836
+ public static function script_version( $handle ) {
837
  global $wp_scripts;
838
  if ( ! $wp_scripts ) {
839
  return false;
853
  return $ver;
854
  }
855
 
856
+ public static function js_redirect( $url ) {
857
  return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>';
858
  }
859
 
860
+ public static function get_user_id_param( $user_id ) {
861
  if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
862
  return $user_id;
863
  }
881
  return $user_id;
882
  }
883
 
884
+ public static function get_file_contents( $filename, $atts = array() ) {
885
  if ( ! is_file($filename) ) {
886
  return false;
887
  }
978
  return $values;
979
  }
980
 
981
+ private static function fill_field_defaults( $field, $record, array &$values, $args ) {
982
  $post_values = $args['post_values'];
983
 
984
  if ( $args['default'] ) {
1025
  $values['fields'][ $field->id ] = $field_array;
1026
  }
1027
 
1028
+ private static function fill_field_opts( $field, array &$field_array, $args ) {
1029
  $post_values = $args['post_values'];
1030
  $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1031
 
1050
  /**
1051
  * @param string $table
1052
  */
1053
+ private static function fill_form_opts( $record, $table, $post_values, array &$values ) {
1054
  if ( $table == 'entries' ) {
1055
  $form = $record->form_id;
1056
  FrmForm::maybe_get_form( $form );
1079
  /**
1080
  * Set to POST value or default
1081
  */
1082
+ private static function fill_form_defaults( $post_values, array &$values ) {
1083
  $form_defaults = FrmFormsHelper::get_default_opts();
1084
 
1085
  foreach ( $form_defaults as $opt => $default ) {
1108
  return FrmEntryMeta::get_meta_value( $entry, $field_id );
1109
  }
1110
 
1111
+ public static function insert_opt_html( $args ) {
1112
  $class = '';
1113
  if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) {
1114
  $class .= 'show_frm_not_email_to';
1132
  return FrmFieldsHelper::get_countries();
1133
  }
1134
 
1135
+ public static function truncate( $str, $length, $minword = 3, $continue = '...' ) {
1136
  if ( is_array( $str ) ) {
1137
  return;
1138
  }
1182
  return call_user_func_array( $function_name, $args );
1183
  }
1184
 
1185
+ public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1186
  if ( empty($date) ) {
1187
  return $date;
1188
  }
1292
  * @param string $term The value to escape
1293
  * @return string The escaped value
1294
  */
1295
+ public static function esc_like( $term ) {
1296
  global $wpdb;
1297
  if ( method_exists($wpdb, 'esc_like') ) {
1298
  // WP 4.0
1307
  /**
1308
  * @param string $order_query
1309
  */
1310
+ public static function esc_order( $order_query ) {
1311
  if ( empty($order_query) ) {
1312
  return '';
1313
  }
1353
  /**
1354
  * @param string $limit
1355
  */
1356
+ public static function esc_limit( $limit ) {
1357
  if ( empty($limit) ) {
1358
  return '';
1359
  }
1500
  }
1501
  }
1502
 
1503
+ public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) {
1504
  $tooltips = array(
1505
  'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ),
1506
  'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <name@email.com> or name@email.com. [admin_email] is the address set in WP General Settings.', 'formidable' ),
1634
  return $post;
1635
  }
1636
 
1637
+ public static function maybe_json_decode( $string ) {
1638
  if ( is_array($string) ) {
1639
  return $string;
1640
  }
1658
  * @param string $post_type The name of the post type that may need to be highlighted
1659
  * @return echo The javascript to open and highlight the Formidable menu
1660
  */
1661
+ public static function maybe_highlight_menu( $post_type ) {
1662
  global $post, $pagenow;
1663
 
1664
  if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1705
  * @param string $location
1706
  */
1707
  public static function localize_script( $location ) {
1708
+ $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' );
1709
+ $ajax_url = apply_filters( 'frm_ajax_url', $ajax_url );
1710
+
1711
  wp_localize_script( 'formidable', 'frm_js', array(
1712
+ 'ajax_url' => $ajax_url,
1713
  'images_url' => self::plugin_url() . '/images',
1714
  'loading' => __( 'Loading&hellip;' ),
1715
  'remove' => __( 'Remove', 'formidable' ),
1759
  * @param float $min_version The version the add-on requires
1760
  * @return echo The message on the plugins listing page
1761
  */
1762
+ public static function min_version_notice( $min_version ) {
1763
  $frm_version = self::plugin_version();
1764
 
1765
  // check if Formidable meets minimum requirements
classes/helpers/FrmEntriesHelper.php CHANGED
@@ -18,35 +18,7 @@ class FrmEntriesHelper {
18
  }
19
 
20
  foreach ( (array) $fields as $field ) {
21
- $default = $field->default_value;
22
- $posted_val = false;
23
- $new_value = $default;
24
-
25
- if ( ! $reset && $_POST && isset( $_POST['item_meta'][ $field->id ] ) && $_POST['item_meta'][ $field->id ] != '' ) {
26
- $new_value = stripslashes_deep( $_POST['item_meta'][ $field->id ] );
27
- $posted_val = true;
28
- } else if ( FrmField::is_option_true( $field, 'clear_on_focus' ) ) {
29
- $new_value = '';
30
- }
31
-
32
- $is_default = ($new_value == $default) ? true : false;
33
-
34
- //If checkbox, multi-select dropdown, or checkbox data from entries field, set return array to true
35
- $return_array = FrmField::is_field_with_multiple_values( $field );
36
-
37
- $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true, $return_array);
38
-
39
- if ( ! is_array( $new_value ) ) {
40
- if ( $is_default ) {
41
- $new_value = $field->default_value;
42
- } else if ( ! $posted_val ) {
43
- $new_value = apply_filters('frm_filter_default_value', $new_value, $field);
44
- }
45
-
46
- $new_value = str_replace('"', '&quot;', $new_value);
47
- }
48
-
49
- unset($is_default, $posted_val);
50
 
51
  $field_array = array(
52
  'id' => $field->id,
@@ -105,7 +77,45 @@ class FrmEntriesHelper {
105
  return apply_filters( 'frm_setup_new_entry', $values );
106
  }
107
 
108
- public static function setup_edit_vars($values, $record) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  $values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' );
110
  $values['form_id'] = $record->form_id;
111
  $values['is_draft'] = $record->is_draft;
@@ -137,7 +147,7 @@ class FrmEntriesHelper {
137
  FrmEntry::maybe_get_entry( $entry );
138
  }
139
 
140
- public static function replace_default_message($message, $atts) {
141
  if ( strpos($message, '[default-message') === false &&
142
  strpos($message, '[default_message') === false &&
143
  ! empty( $message ) ) {
@@ -167,7 +177,7 @@ class FrmEntriesHelper {
167
  return $message;
168
  }
169
 
170
- public static function prepare_display_value($entry, $field, $atts) {
171
  $field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
172
  if ( FrmAppHelper::pro_is_installed() ) {
173
  FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
@@ -223,7 +233,7 @@ class FrmEntriesHelper {
223
  * Prepare the saved value for display
224
  * @return string
225
  */
226
- public static function display_value($value, $field, $atts = array()) {
227
 
228
  $defaults = array(
229
  'type' => '', 'html' => false, 'show_filename' => true,
@@ -290,7 +300,7 @@ class FrmEntriesHelper {
290
  return apply_filters('frm_display_value', $value, $field, $atts);
291
  }
292
 
293
- public static function set_posted_value($field, $value, $args) {
294
  // If validating a field with "other" opt, set back to prev value now
295
  if ( isset( $args['other'] ) && $args['other'] ) {
296
  $value = $args['temp_value'];
@@ -302,7 +312,7 @@ class FrmEntriesHelper {
302
  }
303
  }
304
 
305
- public static function get_posted_value($field, &$value, $args) {
306
  $field_id = is_object( $field ) ? $field->id : $field;
307
 
308
  if ( empty($args['parent_field_id']) ) {
@@ -427,7 +437,7 @@ class FrmEntriesHelper {
427
  }
428
 
429
  // Add submitted values to a string for spam checking
430
- public static function entry_array_to_string($values) {
431
  $content = '';
432
  foreach ( $values['item_meta'] as $val ) {
433
  if ( $content != '' ) {
@@ -460,7 +470,7 @@ class FrmEntriesHelper {
460
  FrmEntryFormat::textarea_display_value( $type, $plain_text, $value );
461
  }
462
 
463
- public static function fill_entry_user_info($atts, array &$values) {
464
  _deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryFormat::fill_entry_user_info' );
465
  FrmEntryFormat::fill_entry_user_info( $atts, $values );
466
  }
18
  }
19
 
20
  foreach ( (array) $fields as $field ) {
21
+ $new_value = self::get_field_value_for_new_entry( $field, $reset );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
  $field_array = array(
24
  'id' => $field->id,
77
  return apply_filters( 'frm_setup_new_entry', $values );
78
  }
79
 
80
+ /**
81
+ * Set the value for each field
82
+ * This function is used when the form is first loaded and on all page turns *for a new entry*
83
+ *
84
+ * @since 2.0.13
85
+ *
86
+ * @param object $field - this is passed by reference since it is an object
87
+ * @param boolean $reset
88
+ * @return string|array $new_value
89
+ */
90
+ private static function get_field_value_for_new_entry( $field, $reset ) {
91
+ //If checkbox, multi-select dropdown, or checkbox data from entries field, the value should be an array
92
+ $return_array = FrmField::is_field_with_multiple_values( $field );
93
+
94
+ // Do any shortcodes in default value and allow customization of default value
95
+ $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true, $return_array);
96
+ // Calls FrmProFieldsHelper::get_default_value
97
+
98
+ $new_value = $field->default_value;
99
+
100
+ if ( ! $reset && $_POST && isset( $_POST['item_meta'][ $field->id ] ) ) {
101
+ // If value was posted, get it
102
+
103
+ $new_value = stripslashes_deep( $_POST['item_meta'][ $field->id ] );
104
+
105
+ } else if ( FrmField::is_option_true( $field, 'clear_on_focus' ) ) {
106
+ // If clear on focus is selected, the value should be blank (unless it was posted, of course)
107
+
108
+ $new_value = '';
109
+ }
110
+
111
+ if ( ! is_array( $new_value ) ) {
112
+ $new_value = str_replace('"', '&quot;', $new_value);
113
+ }
114
+
115
+ return $new_value;
116
+ }
117
+
118
+ public static function setup_edit_vars( $values, $record ) {
119
  $values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' );
120
  $values['form_id'] = $record->form_id;
121
  $values['is_draft'] = $record->is_draft;
147
  FrmEntry::maybe_get_entry( $entry );
148
  }
149
 
150
+ public static function replace_default_message( $message, $atts ) {
151
  if ( strpos($message, '[default-message') === false &&
152
  strpos($message, '[default_message') === false &&
153
  ! empty( $message ) ) {
177
  return $message;
178
  }
179
 
180
+ public static function prepare_display_value( $entry, $field, $atts ) {
181
  $field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
182
  if ( FrmAppHelper::pro_is_installed() ) {
183
  FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
233
  * Prepare the saved value for display
234
  * @return string
235
  */
236
+ public static function display_value( $value, $field, $atts = array() ) {
237
 
238
  $defaults = array(
239
  'type' => '', 'html' => false, 'show_filename' => true,
300
  return apply_filters('frm_display_value', $value, $field, $atts);
301
  }
302
 
303
+ public static function set_posted_value( $field, $value, $args ) {
304
  // If validating a field with "other" opt, set back to prev value now
305
  if ( isset( $args['other'] ) && $args['other'] ) {
306
  $value = $args['temp_value'];
312
  }
313
  }
314
 
315
+ public static function get_posted_value( $field, &$value, $args ) {
316
  $field_id = is_object( $field ) ? $field->id : $field;
317
 
318
  if ( empty($args['parent_field_id']) ) {
437
  }
438
 
439
  // Add submitted values to a string for spam checking
440
+ public static function entry_array_to_string( $values ) {
441
  $content = '';
442
  foreach ( $values['item_meta'] as $val ) {
443
  if ( $content != '' ) {
470
  FrmEntryFormat::textarea_display_value( $type, $plain_text, $value );
471
  }
472
 
473
+ public static function fill_entry_user_info( $atts, array &$values ) {
474
  _deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryFormat::fill_entry_user_info' );
475
  FrmEntryFormat::fill_entry_user_info( $atts, $values );
476
  }
classes/helpers/FrmFieldsHelper.php CHANGED
@@ -5,7 +5,7 @@ if ( ! defined('ABSPATH') ) {
5
 
6
  class FrmFieldsHelper {
7
 
8
- public static function setup_new_vars($type = '', $form_id = '') {
9
 
10
  if ( strpos($type, '|') ) {
11
  list($type, $setting) = explode('|', $type);
@@ -67,7 +67,7 @@ class FrmFieldsHelper {
67
  return $values;
68
  }
69
 
70
- public static function get_html_id($field, $plus = '') {
71
  return apply_filters('frm_field_html_id', 'field_'. $field['field_key'] . $plus, $field);
72
  }
73
 
@@ -164,7 +164,7 @@ class FrmFieldsHelper {
164
  /**
165
  * @since 2.0
166
  */
167
- public static function get_error_msg($field, $error) {
168
  $frm_settings = FrmAppHelper::get_settings();
169
  $default_settings = $frm_settings->default_options();
170
 
@@ -208,7 +208,7 @@ DEFAULT_HTML;
208
  return apply_filters('frm_custom_html', $default_html, $type);
209
  }
210
 
211
- public static function replace_shortcodes($html, $field, $errors = array(), $form = false, $args = array()) {
212
  $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form);
213
 
214
  $defaults = array(
@@ -423,7 +423,7 @@ DEFAULT_HTML;
423
  $html = str_replace( '['. $code .']', $replace_with, $html );
424
  }
425
 
426
- public static function get_shortcode_tag($shortcodes, $short_key, $args) {
427
  $args = wp_parse_args( $args, array( 'conditional' => false, 'conditional_check' => false, 'foreach' => false ) );
428
  if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) {
429
  $args['conditional_check'] = true;
@@ -463,7 +463,7 @@ DEFAULT_HTML;
463
  }
464
  }
465
 
466
- public static function display_recaptcha($field) {
467
  $frm_settings = FrmAppHelper::get_settings();
468
  $lang = apply_filters('frm_recaptcha_lang', $frm_settings->re_lang, $field);
469
 
@@ -481,7 +481,7 @@ DEFAULT_HTML;
481
  <?php
482
  }
483
 
484
- public static function show_single_option($field) {
485
  $field_name = $field['name'];
486
  $html_id = self::get_html_id($field);
487
  foreach ( $field['options'] as $opt_key => $opt ) {
@@ -499,7 +499,7 @@ DEFAULT_HTML;
499
  }
500
  }
501
 
502
- public static function dropdown_categories($args) {
503
  $defaults = array( 'field' => false, 'name' => false, 'show_option_all' => ' ' );
504
  $args = wp_parse_args($args, $defaults);
505
 
@@ -572,7 +572,7 @@ DEFAULT_HTML;
572
  return $dropdown;
573
  }
574
 
575
- public static function get_term_link($tax_id) {
576
  $tax = get_taxonomy($tax_id);
577
  if ( ! $tax ) {
578
  return;
@@ -587,7 +587,7 @@ DEFAULT_HTML;
587
  return $link;
588
  }
589
 
590
- public static function value_meets_condition($observed_value, $cond, $hide_opt) {
591
  // Remove white space from hide_opt
592
  if ( ! is_array( $hide_opt ) ) {
593
  $hide_opt = rtrim( $hide_opt );
@@ -617,7 +617,7 @@ DEFAULT_HTML;
617
  return $m;
618
  }
619
 
620
- public static function array_value_condition($observed_value, $cond, $hide_opt) {
621
  $m = false;
622
  if ( $cond == '==' ) {
623
  if ( is_array($hide_opt) ) {
@@ -656,7 +656,7 @@ DEFAULT_HTML;
656
  * @since 2.0
657
  * @return string
658
  */
659
- public static function basic_replace_shortcodes($value, $form, $entry) {
660
  if ( strpos($value, '[sitename]') !== false ) {
661
  $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
662
  $value = str_replace('[sitename]', $new_value, $value);
@@ -668,7 +668,7 @@ DEFAULT_HTML;
668
  return $value;
669
  }
670
 
671
- public static function get_shortcodes($content, $form_id) {
672
  if ( FrmAppHelper::pro_is_installed() ) {
673
  return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
674
  }
@@ -682,7 +682,7 @@ DEFAULT_HTML;
682
  return $matches;
683
  }
684
 
685
- public static function allowed_shortcodes($fields = array()) {
686
  $tagregexp = array(
687
  'editlink', 'id', 'key', 'ip',
688
  'siteurl', 'sitename', 'admin_email',
@@ -699,7 +699,7 @@ DEFAULT_HTML;
699
  return $tagregexp;
700
  }
701
 
702
- public static function replace_content_shortcodes($content, $entry, $shortcodes) {
703
  $shortcode_values = array(
704
  'id' => $entry->id,
705
  'key' => $entry->item_key,
@@ -870,7 +870,7 @@ DEFAULT_HTML;
870
  return $new_value;
871
  }
872
 
873
- public static function get_display_value($replace_with, $field, $atts = array()) {
874
  $sep = isset( $atts['sep'] ) ? $atts['sep'] : ', ';
875
 
876
  $replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts );
@@ -891,7 +891,7 @@ DEFAULT_HTML;
891
  return $replace_with;
892
  }
893
 
894
- public static function get_field_types($type) {
895
  $single_input = array(
896
  'text', 'textarea', 'rte', 'number', 'email', 'url',
897
  'image', 'file', 'date', 'phone', 'hidden', 'time',
@@ -1168,7 +1168,7 @@ DEFAULT_HTML;
1168
  ?><a href="javascript:void(0)" class="frm_bstooltip <?php echo esc_attr( $atts['icon'] ); ?>frm_default_val_icons frm_action_icon frm_icon_font" title="<?php echo esc_attr( $atts['message'] ); ?>"></a><?php
1169
  }
1170
 
1171
- public static function switch_field_ids($val) {
1172
  global $frm_duplicate_ids;
1173
  $replace = array();
1174
  $replace_with = array();
@@ -1294,7 +1294,7 @@ DEFAULT_HTML;
1294
  ) );
1295
  }
1296
 
1297
- public static function get_bulk_prefilled_opts(array &$prepop) {
1298
  $prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1299
 
1300
  $states = FrmFieldsHelper::get_us_states();
5
 
6
  class FrmFieldsHelper {
7
 
8
+ public static function setup_new_vars( $type = '', $form_id = '' ) {
9
 
10
  if ( strpos($type, '|') ) {
11
  list($type, $setting) = explode('|', $type);
67
  return $values;
68
  }
69
 
70
+ public static function get_html_id( $field, $plus = '' ) {
71
  return apply_filters('frm_field_html_id', 'field_'. $field['field_key'] . $plus, $field);
72
  }
73
 
164
  /**
165
  * @since 2.0
166
  */
167
+ public static function get_error_msg( $field, $error ) {
168
  $frm_settings = FrmAppHelper::get_settings();
169
  $default_settings = $frm_settings->default_options();
170
 
208
  return apply_filters('frm_custom_html', $default_html, $type);
209
  }
210
 
211
+ public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) {
212
  $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form);
213
 
214
  $defaults = array(
423
  $html = str_replace( '['. $code .']', $replace_with, $html );
424
  }
425
 
426
+ public static function get_shortcode_tag( $shortcodes, $short_key, $args ) {
427
  $args = wp_parse_args( $args, array( 'conditional' => false, 'conditional_check' => false, 'foreach' => false ) );
428
  if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) {
429
  $args['conditional_check'] = true;
463
  }
464
  }
465
 
466
+ public static function display_recaptcha( $field ) {
467
  $frm_settings = FrmAppHelper::get_settings();
468
  $lang = apply_filters('frm_recaptcha_lang', $frm_settings->re_lang, $field);
469
 
481
  <?php
482
  }
483
 
484
+ public static function show_single_option( $field ) {
485
  $field_name = $field['name'];
486
  $html_id = self::get_html_id($field);
487
  foreach ( $field['options'] as $opt_key => $opt ) {
499
  }
500
  }
501
 
502
+ public static function dropdown_categories( $args ) {
503
  $defaults = array( 'field' => false, 'name' => false, 'show_option_all' => ' ' );
504
  $args = wp_parse_args($args, $defaults);
505
 
572
  return $dropdown;
573
  }
574
 
575
+ public static function get_term_link( $tax_id ) {
576
  $tax = get_taxonomy($tax_id);
577
  if ( ! $tax ) {
578
  return;
587
  return $link;
588
  }
589
 
590
+ public static function value_meets_condition( $observed_value, $cond, $hide_opt ) {
591
  // Remove white space from hide_opt
592
  if ( ! is_array( $hide_opt ) ) {
593
  $hide_opt = rtrim( $hide_opt );
617
  return $m;
618
  }
619
 
620
+ public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
621
  $m = false;
622
  if ( $cond == '==' ) {
623
  if ( is_array($hide_opt) ) {
656
  * @since 2.0
657
  * @return string
658
  */
659
+ public static function basic_replace_shortcodes( $value, $form, $entry ) {
660
  if ( strpos($value, '[sitename]') !== false ) {
661
  $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
662
  $value = str_replace('[sitename]', $new_value, $value);
668
  return $value;
669
  }
670
 
671
+ public static function get_shortcodes( $content, $form_id ) {
672
  if ( FrmAppHelper::pro_is_installed() ) {
673
  return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
674
  }
682
  return $matches;
683
  }
684
 
685
+ public static function allowed_shortcodes( $fields = array() ) {
686
  $tagregexp = array(
687
  'editlink', 'id', 'key', 'ip',
688
  'siteurl', 'sitename', 'admin_email',
699
  return $tagregexp;
700
  }
701
 
702
+ public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
703
  $shortcode_values = array(
704
  'id' => $entry->id,
705
  'key' => $entry->item_key,
870
  return $new_value;
871
  }
872
 
873
+ public static function get_display_value( $replace_with, $field, $atts = array() ) {
874
  $sep = isset( $atts['sep'] ) ? $atts['sep'] : ', ';
875
 
876
  $replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts );
891
  return $replace_with;
892
  }
893
 
894
+ public static function get_field_types( $type ) {
895
  $single_input = array(
896
  'text', 'textarea', 'rte', 'number', 'email', 'url',
897
  'image', 'file', 'date', 'phone', 'hidden', 'time',
1168
  ?><a href="javascript:void(0)" class="frm_bstooltip <?php echo esc_attr( $atts['icon'] ); ?>frm_default_val_icons frm_action_icon frm_icon_font" title="<?php echo esc_attr( $atts['message'] ); ?>"></a><?php
1169
  }
1170
 
1171
+ public static function switch_field_ids( $val ) {
1172
  global $frm_duplicate_ids;
1173
  $replace = array();
1174
  $replace_with = array();
1294
  ) );
1295
  }
1296
 
1297
+ public static function get_bulk_prefilled_opts( array &$prepop ) {
1298
  $prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1299
 
1300
  $states = FrmFieldsHelper::get_us_states();
classes/helpers/FrmFormsHelper.php CHANGED
@@ -10,7 +10,7 @@ class FrmFormsHelper {
10
  FrmForm::maybe_get_form( $form );
11
  }
12
 
13
- public static function get_direct_link($key, $form = false ) {
14
  $target_url = esc_url(admin_url('admin-ajax.php') . '?action=frm_forms_preview&form='. $key);
15
  $target_url = apply_filters('frm_direct_link', $target_url, $key, $form);
16
 
@@ -114,7 +114,7 @@ class FrmFormsHelper {
114
  <?php
115
  }
116
 
117
- public static function get_sortable_classes($col, $sort_col, $sort_dir) {
118
  echo ($sort_col == $col) ? 'sorted' : 'sortable';
119
  echo ($sort_col == $col && $sort_dir == 'desc') ? ' asc' : ' desc';
120
  }
@@ -186,7 +186,7 @@ class FrmFormsHelper {
186
  return apply_filters('frm_setup_edit_form_vars', $values);
187
  }
188
 
189
- public static function fill_default_opts($values, $record, $post_values) {
190
 
191
  $defaults = self::get_default_opts();
192
  foreach ( $defaults as $var => $default ) {
@@ -246,7 +246,7 @@ class FrmFormsHelper {
246
  /**
247
  * @param string $loc
248
  */
249
- public static function get_default_html($loc) {
250
  if ( $loc == 'submit' ) {
251
  $sending = __( 'Sending', 'formidable' );
252
  $draft_link = self::get_draft_link();
@@ -277,7 +277,7 @@ BEFORE_HTML;
277
  return $link;
278
  }
279
 
280
- public static function get_custom_submit($html, $form, $submit, $form_action, $values) {
281
  $button = self::replace_shortcodes($html, $form, $submit, $form_action, $values);
282
  if ( ! strpos($button, '[button_action]') ) {
283
  return;
@@ -419,7 +419,7 @@ BEFORE_HTML;
419
  return $html;
420
  }
421
 
422
- public static function submit_button_label($submit) {
423
  if ( ! $submit || empty($submit) ) {
424
  $frm_settings = FrmAppHelper::get_settings();
425
  $submit = $frm_settings->submit_value;
@@ -428,7 +428,7 @@ BEFORE_HTML;
428
  return $submit;
429
  }
430
 
431
- public static function get_form_style_class($form = false) {
432
  $style = self::get_form_style($form);
433
  $class = ' with_frm_style';
434
 
@@ -535,11 +535,12 @@ BEFORE_HTML;
535
  }
536
  }
537
  }
538
- public static function get_scroll_js($form_id) {
 
539
  ?><script type="text/javascript">jQuery(document).ready(function(){frmFrontForm.scrollMsg(<?php echo (int) $form_id ?>);})</script><?php
540
  }
541
 
542
- public static function edit_form_link($form_id) {
543
  if ( is_object($form_id) ) {
544
  $form = $form_id;
545
  $name = $form->name;
@@ -557,7 +558,7 @@ BEFORE_HTML;
557
  return $val;
558
  }
559
 
560
- public static function delete_trash_link($id, $status, $length = 'long') {
561
  $link = '';
562
  $labels = array(
563
  'restore' => array(
@@ -589,7 +590,7 @@ BEFORE_HTML;
589
  return $link;
590
  }
591
 
592
- public static function status_nice_name($status) {
593
  $nice_names = array(
594
  'draft' => __( 'Draft', 'formidable' ),
595
  'trash' => __( 'Trash', 'formidable' ),
10
  FrmForm::maybe_get_form( $form );
11
  }
12
 
13
+ public static function get_direct_link( $key, $form = false ) {
14
  $target_url = esc_url(admin_url('admin-ajax.php') . '?action=frm_forms_preview&form='. $key);
15
  $target_url = apply_filters('frm_direct_link', $target_url, $key, $form);
16
 
114
  <?php
115
  }
116
 
117
+ public static function get_sortable_classes( $col, $sort_col, $sort_dir ) {
118
  echo ($sort_col == $col) ? 'sorted' : 'sortable';
119
  echo ($sort_col == $col && $sort_dir == 'desc') ? ' asc' : ' desc';
120
  }
186
  return apply_filters('frm_setup_edit_form_vars', $values);
187
  }
188
 
189
+ public static function fill_default_opts( $values, $record, $post_values ) {
190
 
191
  $defaults = self::get_default_opts();
192
  foreach ( $defaults as $var => $default ) {
246
  /**
247
  * @param string $loc
248
  */
249
+ public static function get_default_html( $loc ) {
250
  if ( $loc == 'submit' ) {
251
  $sending = __( 'Sending', 'formidable' );
252
  $draft_link = self::get_draft_link();
277
  return $link;
278
  }
279
 
280
+ public static function get_custom_submit( $html, $form, $submit, $form_action, $values ) {
281
  $button = self::replace_shortcodes($html, $form, $submit, $form_action, $values);
282
  if ( ! strpos($button, '[button_action]') ) {
283
  return;
419
  return $html;
420
  }
421
 
422
+ public static function submit_button_label( $submit ) {
423
  if ( ! $submit || empty($submit) ) {
424
  $frm_settings = FrmAppHelper::get_settings();
425
  $submit = $frm_settings->submit_value;
428
  return $submit;
429
  }
430
 
431
+ public static function get_form_style_class( $form = false ) {
432
  $style = self::get_form_style($form);
433
  $class = ' with_frm_style';
434
 
535
  }
536
  }
537
  }
538
+
539
+ public static function get_scroll_js( $form_id ) {
540
  ?><script type="text/javascript">jQuery(document).ready(function(){frmFrontForm.scrollMsg(<?php echo (int) $form_id ?>);})</script><?php
541
  }
542
 
543
+ public static function edit_form_link( $form_id ) {
544
  if ( is_object($form_id) ) {
545
  $form = $form_id;
546
  $name = $form->name;
558
  return $val;
559
  }
560
 
561
+ public static function delete_trash_link( $id, $status, $length = 'long' ) {
562
  $link = '';
563
  $labels = array(
564
  'restore' => array(
590
  return $link;
591
  }
592
 
593
+ public static function status_nice_name( $status ) {
594
  $nice_names = array(
595
  'draft' => __( 'Draft', 'formidable' ),
596
  'trash' => __( 'Trash', 'formidable' ),
classes/helpers/FrmListHelper.php CHANGED
@@ -31,5 +31,4 @@ class FrmListHelper extends WP_List_Table {
31
  echo "\n\t", $this->single_row( $item, $style );
32
  }
33
  }
34
-
35
  }
31
  echo "\n\t", $this->single_row( $item, $style );
32
  }
33
  }
 
34
  }
classes/helpers/FrmStylesHelper.php CHANGED
@@ -33,7 +33,7 @@ class FrmStylesHelper {
33
  return $themes;
34
  }
35
 
36
- public static function jquery_css_url($theme_css) {
37
  if ( $theme_css == -1 ) {
38
  return;
39
  }
@@ -71,7 +71,7 @@ class FrmStylesHelper {
71
  return $uploads;
72
  }
73
 
74
- public static function style_menu($active = '') {
75
  ?>
76
  <h2 class="nav-tab-wrapper">
77
  <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles' ) ) ?>" class="nav-tab <?php echo ( '' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Edit Styles', 'formidable' ) ?></a>
@@ -114,7 +114,7 @@ class FrmStylesHelper {
114
  * @since 2.0
115
  * @return The class for this icon
116
  */
117
- public static function icon_key_to_class($key, $icon = '+', $type = 'arrow') {
118
  if ( 'arrow' == $type && is_numeric($key) ) {
119
  //frm_arrowup6_icon
120
  $arrow = array( '-' => 'down', '+' => 'up' );
@@ -134,7 +134,7 @@ class FrmStylesHelper {
134
  return $class;
135
  }
136
 
137
- public static function bs_icon_select($style, $frm_style, $type = 'arrow') {
138
  $function_name = $type . '_icons';
139
  $icons = self::$function_name();
140
  unset( $function_name );
@@ -174,7 +174,7 @@ class FrmStylesHelper {
174
  <?php
175
  }
176
 
177
- public static function hex2rgb($hex) {
178
  $hex = str_replace('#', '', $hex);
179
 
180
  if ( strlen($hex) == 3 ) {
33
  return $themes;
34
  }
35
 
36
+ public static function jquery_css_url( $theme_css ) {
37
  if ( $theme_css == -1 ) {
38
  return;
39
  }
71
  return $uploads;
72
  }
73
 
74
+ public static function style_menu( $active = '' ) {
75
  ?>
76
  <h2 class="nav-tab-wrapper">
77
  <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles' ) ) ?>" class="nav-tab <?php echo ( '' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Edit Styles', 'formidable' ) ?></a>
114
  * @since 2.0
115
  * @return The class for this icon
116
  */
117
+ public static function icon_key_to_class( $key, $icon = '+', $type = 'arrow' ) {
118
  if ( 'arrow' == $type && is_numeric($key) ) {
119
  //frm_arrowup6_icon
120
  $arrow = array( '-' => 'down', '+' => 'up' );
134
  return $class;
135
  }
136
 
137
+ public static function bs_icon_select( $style, $frm_style, $type = 'arrow' ) {
138
  $function_name = $type . '_icons';
139
  $icons = self::$function_name();
140
  unset( $function_name );
174
  <?php
175
  }
176
 
177
+ public static function hex2rgb( $hex ) {
178
  $hex = str_replace('#', '', $hex);
179
 
180
  if ( strlen($hex) == 3 ) {
classes/helpers/FrmXMLHelper.php CHANGED
@@ -22,7 +22,7 @@ class FrmXMLHelper {
22
  }
23
  }
24
 
25
- public static function import_xml($file) {
26
  $defaults = array(
27
  'forms' => 0, 'fields' => 0, 'terms' => 0,
28
  'posts' => 0, 'views' => 0, 'actions' => 0,
@@ -79,7 +79,7 @@ class FrmXMLHelper {
79
  return $return;
80
  }
81
 
82
- public static function import_xml_terms($terms, $imported) {
83
  foreach ( $terms as $t ) {
84
  if ( term_exists((string) $t->term_slug, (string) $t->term_taxonomy) ) {
85
  continue;
@@ -121,9 +121,9 @@ class FrmXMLHelper {
121
  return $parent;
122
  }
123
 
124
- public static function import_xml_forms($forms, $imported) {
125
- // Keep track of repeating sections that are created
126
- $repeat_fields = array();
127
 
128
  foreach ( $forms as $item ) {
129
  $form = array(
@@ -149,10 +149,7 @@ class FrmXMLHelper {
149
  $edit_query['created_at'] = $form['created_at'];
150
  }
151
 
152
- if ( ! empty( $form['parent_form_id'] ) && isset( $imported['forms'][ $form['parent_form_id'] ] ) ) {
153
- // replace the old parent id with the new one
154
- $form['parent_form_id'] = $imported['forms'][ $form['parent_form_id'] ];
155
- }
156
 
157
  $edit_query = apply_filters('frm_match_xml_form', $edit_query, $form);
158
 
@@ -183,81 +180,12 @@ class FrmXMLHelper {
183
  $imported['imported']['forms']++;
184
  // Keep track of whether this specific form was updated or not
185
  $imported['form_status'][ $form_id ] = 'imported';
 
 
186
  }
187
  }
188
 
189
- foreach ( $item->field as $field ) {
190
- $f = array(
191
- 'id' => (int) $field->id,
192
- 'field_key' => (string) $field->field_key,
193
- 'name' => (string) $field->name,
194
- 'description' => (string) $field->description,
195
- 'type' => (string) $field->type,
196
- 'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value),
197
- 'field_order' => (int) $field->field_order,
198
- 'form_id' => (int) $form_id,
199
- 'required' => (int) $field->required,
200
- 'options' => FrmAppHelper::maybe_json_decode( (string) $field->options),
201
- 'field_options' => FrmAppHelper::maybe_json_decode( (string) $field->field_options ),
202
- );
203
-
204
- if ( is_array($f['default_value']) && in_array($f['type'], array(
205
- 'text', 'email', 'url', 'textarea',
206
- 'number','phone', 'date', 'time',
207
- 'hidden', 'password', 'tag', 'image',
208
- )) ) {
209
- if ( count($f['default_value']) === 1 ) {
210
- $f['default_value'] = '['. reset($f['default_value']) .']';
211
- } else {
212
- $f['default_value'] = reset($f['default_value']);
213
- }
214
- }
215
-
216
- $f = apply_filters('frm_duplicated_field', $f);
217
-
218
- if ( ! empty($this_form) ) {
219
- // check for field to edit by field id
220
- if ( isset( $form_fields[ $f['id'] ] ) ) {
221
- FrmField::update( $f['id'], $f );
222
- $imported['updated']['fields']++;
223
-
224
- unset( $form_fields[ $f['id'] ] );
225
-
226
- //unset old field key
227
- if ( isset( $form_fields[ $f['field_key'] ] ) ) {
228
- unset( $form_fields[ $f['field_key'] ] );
229
- }
230
- } else if ( isset( $form_fields[ $f['field_key'] ] ) ) {
231
- // check for field to edit by field key
232
- unset($f['id']);
233
-
234
- FrmField::update( $form_fields[ $f['field_key'] ], $f );
235
- $imported['updated']['fields']++;
236
-
237
- unset( $form_fields[ $form_fields[ $f['field_key'] ] ] ); //unset old field id
238
- unset( $form_fields[ $f['field_key'] ] ); //unset old field key
239
- } else {
240
- $new_id = FrmField::create( $f );
241
- if ( $new_id == false ) {
242
- continue;
243
- }
244
- self::track_repeating_fields( $f, $new_id, $repeat_fields );
245
-
246
- // if no matching field id or key in this form, create the field
247
- $imported['imported']['fields']++;
248
- }
249
- } else {
250
- $new_id = FrmField::create( $f );
251
- if ( $new_id == false ) {
252
- continue;
253
- }
254
-
255
- self::track_repeating_fields( $f, $new_id, $repeat_fields );
256
- $imported['imported']['fields']++;
257
- }
258
-
259
- unset($field, $new_id);
260
- }
261
 
262
  // Delete any fields attached to this form that were not included in the template
263
  if ( isset( $form_fields ) && ! empty( $form_fields ) ) {
@@ -281,10 +209,159 @@ class FrmXMLHelper {
281
  unset($form, $item);
282
  }
283
  self::update_repeat_field_options( $repeat_fields, $imported['forms'] );
 
284
 
285
  return $imported;
286
  }
287
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
288
  /**
289
  * Update form_select for all imported repeating sections and embedded forms
290
  *
@@ -329,7 +406,7 @@ class FrmXMLHelper {
329
  }
330
  }
331
 
332
- public static function import_xml_views($views, $imported) {
333
  $imported['posts'] = array();
334
  $form_action_type = FrmFormActionsController::$action_post_type;
335
 
@@ -564,7 +641,7 @@ class FrmXMLHelper {
564
  /**
565
  * @param string $message
566
  */
567
- public static function parse_message($result, &$message, &$errors) {
568
  if ( is_wp_error($result) ) {
569
  $errors[] = $result->get_error_message();
570
  } else if ( ! $result ) {
@@ -609,7 +686,7 @@ class FrmXMLHelper {
609
  }
610
  }
611
 
612
- public static function item_count_message($m, $type, &$s_message) {
613
  if ( ! $m ) {
614
  return;
615
  }
22
  }
23
  }
24
 
25
+ public static function import_xml( $file ) {
26
  $defaults = array(
27
  'forms' => 0, 'fields' => 0, 'terms' => 0,
28
  'posts' => 0, 'views' => 0, 'actions' => 0,
79
  return $return;
80
  }
81
 
82
+ public static function import_xml_terms( $terms, $imported ) {
83
  foreach ( $terms as $t ) {
84
  if ( term_exists((string) $t->term_slug, (string) $t->term_taxonomy) ) {
85
  continue;
121
  return $parent;
122
  }
123
 
124
+ public static function import_xml_forms( $forms, $imported ) {
125
+ // Keep track of repeating sections and child forms that are imported
126
+ $repeat_fields = $child_forms_missing_parent = array();
127
 
128
  foreach ( $forms as $item ) {
129
  $form = array(
149
  $edit_query['created_at'] = $form['created_at'];
150
  }
151
 
152
+ $old_parent_form_id = self::maybe_replace_parent_form_id( $imported['forms'], $form['parent_form_id'] );
 
 
 
153
 
154
  $edit_query = apply_filters('frm_match_xml_form', $edit_query, $form);
155
 
180
  $imported['imported']['forms']++;
181
  // Keep track of whether this specific form was updated or not
182
  $imported['form_status'][ $form_id ] = 'imported';
183
+
184
+ self::track_child_forms_missing_parent( (int) $form_id, $old_parent_form_id, $child_forms_missing_parent );
185
  }
186
  }
187
 
188
+ self::import_xml_fields( $item->field, $form_id, $this_form, $form_fields, $imported, $repeat_fields );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
 
190
  // Delete any fields attached to this form that were not included in the template
191
  if ( isset( $form_fields ) && ! empty( $form_fields ) ) {
209
  unset($form, $item);
210
  }
211
  self::update_repeat_field_options( $repeat_fields, $imported['forms'] );
212
+ self::update_child_form_parents( $child_forms_missing_parent, $imported['forms'] );
213
 
214
  return $imported;
215
  }
216
 
217
+ /**
218
+ * Replace the parent_form_id on child forms if their parent was already imported
219
+ * @since 2.0.13
220
+ *
221
+ * @param array $imported_forms
222
+ * @param int $parent_form_id
223
+ * @return int $old_parent_form_id
224
+ */
225
+ private static function maybe_replace_parent_form_id( $imported_forms, &$parent_form_id ) {
226
+ $old_parent_form_id = 0;
227
+
228
+ if ( ! empty( $parent_form_id ) ) {
229
+ if ( isset( $imported_forms[ $parent_form_id ] ) ) {
230
+ // The parent has already been imported
231
+
232
+ // replace the old parent id with the new one
233
+ $parent_form_id = $imported_forms[ $parent_form_id ];
234
+ } else {
235
+ // The parent will be imported after
236
+
237
+ $old_parent_form_id = $parent_form_id;
238
+ }
239
+ }
240
+
241
+ return $old_parent_form_id;
242
+ }
243
+
244
+ /**
245
+ * Track child forms that were imported before their parents
246
+ * @since 2.0.13
247
+ *
248
+ * @param int $new_form_id
249
+ * @param int $old_parent_form_id
250
+ * @param array $child_forms_missing_parent
251
+ */
252
+ private static function track_child_forms_missing_parent( $new_form_id, $old_parent_form_id, &$child_forms_missing_parent ) {
253
+ if ( $old_parent_form_id ) {
254
+ if ( ! isset( $child_forms_missing_parent[ $old_parent_form_id ] ) ) {
255
+ $child_forms_missing_parent[ $old_parent_form_id ] = array();
256
+ }
257
+
258
+ // Multiple child forms may have the same parent
259
+ $child_forms_missing_parent[ $old_parent_form_id ][] = $new_form_id;
260
+ }
261
+ }
262
+
263
+ /**
264
+ * Import all fields for a form
265
+ * @since 2.0.13
266
+ *
267
+ * TODO: Cut down on params
268
+ */
269
+ private static function import_xml_fields( $xml_fields, $form_id, $this_form, &$form_fields, &$imported, &$repeat_fields ) {
270
+ foreach ( $xml_fields as $field ) {
271
+ $f = array(
272
+ 'id' => (int) $field->id,
273
+ 'field_key' => (string) $field->field_key,
274
+ 'name' => (string) $field->name,
275
+ 'description' => (string) $field->description,
276
+ 'type' => (string) $field->type,
277
+ 'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value),
278
+ 'field_order' => (int) $field->field_order,
279
+ 'form_id' => (int) $form_id,
280
+ 'required' => (int) $field->required,
281
+ 'options' => FrmAppHelper::maybe_json_decode( (string) $field->options),
282
+ 'field_options' => FrmAppHelper::maybe_json_decode( (string) $field->field_options ),
283
+ );
284
+
285
+ if ( is_array($f['default_value']) && in_array($f['type'], array(
286
+ 'text', 'email', 'url', 'textarea',
287
+ 'number','phone', 'date', 'time',
288
+ 'hidden', 'password', 'tag', 'image',
289
+ )) ) {
290
+ if ( count($f['default_value']) === 1 ) {
291
+ $f['default_value'] = '['. reset($f['default_value']) .']';
292
+ } else {
293
+ $f['default_value'] = reset($f['default_value']);
294
+ }
295
+ }
296
+
297
+ $f = apply_filters('frm_duplicated_field', $f);
298
+
299
+ if ( ! empty($this_form) ) {
300
+ // check for field to edit by field id
301
+ if ( isset( $form_fields[ $f['id'] ] ) ) {
302
+ FrmField::update( $f['id'], $f );
303
+ $imported['updated']['fields']++;
304
+
305
+ unset( $form_fields[ $f['id'] ] );
306
+
307
+ //unset old field key
308
+ if ( isset( $form_fields[ $f['field_key'] ] ) ) {
309
+ unset( $form_fields[ $f['field_key'] ] );
310
+ }
311
+ } else if ( isset( $form_fields[ $f['field_key'] ] ) ) {
312
+ // check for field to edit by field key
313
+ unset($f['id']);
314
+
315
+ FrmField::update( $form_fields[ $f['field_key'] ], $f );
316
+ $imported['updated']['fields']++;
317
+
318
+ unset( $form_fields[ $form_fields[ $f['field_key'] ] ] ); //unset old field id
319
+ unset( $form_fields[ $f['field_key'] ] ); //unset old field key
320
+ } else {
321
+ $new_id = FrmField::create( $f );
322
+ if ( $new_id == false ) {
323
+ continue;
324
+ }
325
+ self::track_repeating_fields( $f, $new_id, $repeat_fields );
326
+
327
+ // if no matching field id or key in this form, create the field
328
+ $imported['imported']['fields']++;
329
+ }
330
+ } else {
331
+ $new_id = FrmField::create( $f );
332
+ if ( $new_id == false ) {
333
+ continue;
334
+ }
335
+
336
+ self::track_repeating_fields( $f, $new_id, $repeat_fields );
337
+ $imported['imported']['fields']++;
338
+ }
339
+
340
+ unset($field, $new_id);
341
+ }
342
+ }
343
+
344
+ /**
345
+ * Update parent_form_id for child forms that were imported before parents
346
+ *
347
+ * @since 2.0.13
348
+ *
349
+ * @param array $child_forms_missing_parent
350
+ * @param array $imported_forms
351
+ */
352
+ private static function update_child_form_parents( $child_forms_missing_parent, $imported_forms ) {
353
+ foreach ( $child_forms_missing_parent as $old_parent_form_id => $child_form_ids ) {
354
+ if ( isset( $imported_forms[ $old_parent_form_id ] ) ) {
355
+
356
+ // Update all children with this old parent_form_id
357
+ $new_parent_form_id = (int) $imported_forms[ $old_parent_form_id ];
358
+ foreach ( $child_form_ids as $child_form_id ) {
359
+ FrmForm::update( $child_form_id, array( 'parent_form_id' => $new_parent_form_id ) );
360
+ }
361
+ }
362
+ }
363
+ }
364
+
365
  /**
366
  * Update form_select for all imported repeating sections and embedded forms
367
  *
406
  }
407
  }
408
 
409
+ public static function import_xml_views( $views, $imported ) {
410
  $imported['posts'] = array();
411
  $form_action_type = FrmFormActionsController::$action_post_type;
412
 
641
  /**
642
  * @param string $message
643
  */
644
+ public static function parse_message( $result, &$message, &$errors ) {
645
  if ( is_wp_error($result) ) {
646
  $errors[] = $result->get_error_message();
647
  } else if ( ! $result ) {
686
  }
687
  }
688
 
689
+ public static function item_count_message( $m, $type, &$s_message ) {
690
  if ( ! $m ) {
691
  return;
692
  }
classes/models/EDD_SL_Plugin_Updater.php CHANGED
@@ -75,7 +75,7 @@ class EDD_SL_Plugin_Updater {
75
 
76
  global $pagenow;
77
 
78
- if( ! is_object( $_transient_data ) ) {
79
  $_transient_data = new stdClass;
80
  }
81
 
@@ -138,7 +138,7 @@ class EDD_SL_Plugin_Updater {
138
  $cache_key = md5( 'edd_plugin_' .sanitize_key( $this->name ) . '_version_info' );
139
  $version_info = get_transient( $cache_key );
140
 
141
- if( false === $version_info ) {
142
 
143
  $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
144
 
@@ -229,7 +229,7 @@ class EDD_SL_Plugin_Updater {
229
  'fields' => array(
230
  'banners' => false, // These will be supported soon hopefully
231
  'reviews' => false,
232
- )
233
  );
234
 
235
  $api_response = $this->api_request( 'plugin_information', $to_send );
@@ -293,7 +293,7 @@ class EDD_SL_Plugin_Updater {
293
  'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
294
  'slug' => $data['slug'],
295
  'author' => $data['author'],
296
- 'url' => home_url()
297
  );
298
 
299
  $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
@@ -337,5 +337,4 @@ class EDD_SL_Plugin_Updater {
337
 
338
  exit;
339
  }
340
-
341
  }
75
 
76
  global $pagenow;
77
 
78
+ if ( ! is_object( $_transient_data ) ) {
79
  $_transient_data = new stdClass;
80
  }
81
 
138
  $cache_key = md5( 'edd_plugin_' .sanitize_key( $this->name ) . '_version_info' );
139
  $version_info = get_transient( $cache_key );
140
 
141
+ if ( false === $version_info ) {
142
 
143
  $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
144
 
229
  'fields' => array(
230
  'banners' => false, // These will be supported soon hopefully
231
  'reviews' => false,
232
+ ),
233
  );
234
 
235
  $api_response = $this->api_request( 'plugin_information', $to_send );
293
  'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
294
  'slug' => $data['slug'],
295
  'author' => $data['author'],
296
+ 'url' => home_url(),
297
  );
298
 
299
  $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
337
 
338
  exit;
339
  }
 
340
  }
classes/models/FrmAddon.php CHANGED
@@ -46,7 +46,7 @@ class FrmAddon {
46
 
47
  if ( ! empty( $license ) ) {
48
  if ( ! class_exists('EDD_SL_Plugin_Updater') ) {
49
- include( dirname( __FILE__ ) . '/EDD_SL_EDD_SL_Plugin_Updater.php' );
50
  }
51
 
52
  // setup the updater
@@ -72,7 +72,7 @@ class FrmAddon {
72
  update_option( $this_plugin->option_name . 'key', $license );
73
 
74
  $response = array( 'success' => false, 'message' => '' );
75
- try{
76
  $license_data = $this_plugin->send_mothership_request( 'activate_license', $license );
77
 
78
  // $license_data->license will be either "valid" or "invalid"
@@ -85,8 +85,7 @@ class FrmAddon {
85
  }
86
 
87
  update_option( $this_plugin->option_name . 'active', $is_valid );
88
- }
89
- catch(Exception $e) {
90
  $response['message'] = $e->getMessage();
91
  }
92
 
@@ -102,7 +101,7 @@ class FrmAddon {
102
  $this_plugin = self::get_addon( $plugin_slug );
103
 
104
  $response = array( 'success' => false, 'message' => '' );
105
- try{
106
  // $license_data->license will be either "deactivated" or "failed"
107
  $license_data = $this_plugin->send_mothership_request( 'deactivate_license', $license );
108
  if ( is_array( $license_data ) && $license_data['license'] == 'deactivated' ) {
@@ -111,8 +110,7 @@ class FrmAddon {
111
  } else {
112
  $response['message'] = __( 'There was an error deactivating your license.', 'formidable' );
113
  }
114
- }
115
- catch ( Exception $e ) {
116
  $response['message'] = $e->getMessage();
117
  }
118
 
@@ -164,5 +162,4 @@ class FrmAddon {
164
 
165
  return __( 'Your License Key was invalid', 'formidable' );
166
  }
167
-
168
  }
46
 
47
  if ( ! empty( $license ) ) {
48
  if ( ! class_exists('EDD_SL_Plugin_Updater') ) {
49
+ include( dirname( __FILE__ ) . '/EDD_SL_Plugin_Updater.php' );
50
  }
51
 
52
  // setup the updater
72
  update_option( $this_plugin->option_name . 'key', $license );
73
 
74
  $response = array( 'success' => false, 'message' => '' );
75
+ try {
76
  $license_data = $this_plugin->send_mothership_request( 'activate_license', $license );
77
 
78
  // $license_data->license will be either "valid" or "invalid"
85
  }
86
 
87
  update_option( $this_plugin->option_name . 'active', $is_valid );
88
+ } catch ( Exception $e ) {
 
89
  $response['message'] = $e->getMessage();
90
  }
91
 
101
  $this_plugin = self::get_addon( $plugin_slug );
102
 
103
  $response = array( 'success' => false, 'message' => '' );
104
+ try {
105
  // $license_data->license will be either "deactivated" or "failed"
106
  $license_data = $this_plugin->send_mothership_request( 'deactivate_license', $license );
107
  if ( is_array( $license_data ) && $license_data['license'] == 'deactivated' ) {
110
  } else {
111
  $response['message'] = __( 'There was an error deactivating your license.', 'formidable' );
112
  }
113
+ } catch ( Exception $e ) {
 
114
  $response['message'] = $e->getMessage();
115
  }
116
 
162
 
163
  return __( 'Your License Key was invalid', 'formidable' );
164
  }
 
165
  }
classes/models/FrmDb.php CHANGED
@@ -46,7 +46,7 @@ class FrmDb {
46
  do_action('frm_after_install');
47
 
48
  /**** update the styling settings ****/
49
- if ( is_admin() ) {
50
  $frm_style = new FrmStyle();
51
  $frm_style->update( 'default' );
52
  }
@@ -59,9 +59,9 @@ class FrmDb {
59
  }
60
 
61
  $charset_collate = '';
62
- if ( ! empty($wpdb->charset) ) {
63
- $charset_collate = ' DEFAULT CHARACTER SET '. $wpdb->charset;
64
- }
65
 
66
  if ( ! empty($wpdb->collate) ) {
67
  $charset_collate .= ' COLLATE '. $wpdb->collate;
@@ -160,7 +160,7 @@ class FrmDb {
160
  /**
161
  * @param integer $frm_db_version
162
  */
163
- private function migrate_data($frm_db_version, $old_db_version) {
164
  $migrations = array( 4, 6, 11, 16, 17, 23, 25 );
165
  foreach ( $migrations as $migration ) {
166
  if ( $frm_db_version >= $migration && $old_db_version < $migration ) {
46
  do_action('frm_after_install');
47
 
48
  /**** update the styling settings ****/
49
+ if ( is_admin() && function_exists( 'get_filesystem_method' ) ) {
50
  $frm_style = new FrmStyle();
51
  $frm_style->update( 'default' );
52
  }
59
  }
60
 
61
  $charset_collate = '';
62
+ if ( ! empty( $wpdb->charset ) ) {
63
+ $charset_collate .= ' DEFAULT CHARACTER SET '. $wpdb->charset;
64
+ }
65
 
66
  if ( ! empty($wpdb->collate) ) {
67
  $charset_collate .= ' COLLATE '. $wpdb->collate;
160
  /**
161
  * @param integer $frm_db_version
162
  */
163
+ private function migrate_data( $frm_db_version, $old_db_version ) {
164
  $migrations = array( 4, 6, 11, 16, 17, 23, 25 );
165
  foreach ( $migrations as $migration ) {
166
  if ( $frm_db_version >= $migration && $old_db_version < $migration ) {
classes/models/FrmEntry.php CHANGED
@@ -92,7 +92,7 @@ class FrmEntry {
92
  * check for duplicate entries created in the last minute
93
  * @return boolean
94
  */
95
- public static function is_duplicate($new_values, $values) {
96
  if ( defined('WP_IMPORTING') && WP_IMPORTING ) {
97
  return false;
98
  }
@@ -304,7 +304,7 @@ class FrmEntry {
304
  }
305
  }
306
 
307
- public static function getOne( $id, $meta = false) {
308
  global $wpdb;
309
 
310
  $query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it
@@ -330,7 +330,7 @@ class FrmEntry {
330
  return stripslashes_deep($entry);
331
  }
332
 
333
- public static function get_meta($entry) {
334
  if ( ! $entry ) {
335
  return $entry;
336
  }
@@ -573,5 +573,4 @@ class FrmEntry {
573
  _deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryValidate::akismet' );
574
  return FrmEntryValidate::akismet( $values );
575
  }
576
-
577
  }
92
  * check for duplicate entries created in the last minute
93
  * @return boolean
94
  */
95
+ public static function is_duplicate( $new_values, $values ) {
96
  if ( defined('WP_IMPORTING') && WP_IMPORTING ) {
97
  return false;
98
  }
304
  }
305
  }
306
 
307
+ public static function getOne( $id, $meta = false ) {
308
  global $wpdb;
309
 
310
  $query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it
330
  return stripslashes_deep($entry);
331
  }
332
 
333
+ public static function get_meta( $entry ) {
334
  if ( ! $entry ) {
335
  return $entry;
336
  }
573
  _deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryValidate::akismet' );
574
  return FrmEntryValidate::akismet( $values );
575
  }
 
576
  }
classes/models/FrmEntryFormat.php CHANGED
@@ -146,7 +146,7 @@ class FrmEntryFormat {
146
  }
147
 
148
  public static function fill_entry_user_info( $atts, array &$values ) {
149
- if ( ! $atts['user_info'] ) {
150
  return;
151
  }
152
 
@@ -325,5 +325,4 @@ class FrmEntryFormat {
325
  $content[] = '</tbody></table>';
326
  }
327
  }
328
-
329
  }
146
  }
147
 
148
  public static function fill_entry_user_info( $atts, array &$values ) {
149
+ if ( ! $atts['user_info'] || empty( $atts['entry'] ) ) {
150
  return;
151
  }
152
 
325
  $content[] = '</tbody></table>';
326
  }
327
  }
 
328
  }
classes/models/FrmEntryMeta.php CHANGED
@@ -8,7 +8,7 @@ class FrmEntryMeta {
8
  /**
9
  * @param string $meta_key
10
  */
11
- public static function add_entry_meta($entry_id, $field_id, $meta_key = null, $meta_value) {
12
  global $wpdb;
13
 
14
  if ( FrmAppHelper::is_empty_value( $meta_value ) ) {
@@ -40,7 +40,7 @@ class FrmEntryMeta {
40
  /**
41
  * @param string $meta_key
42
  */
43
- public static function update_entry_meta($entry_id, $field_id, $meta_key = null, $meta_value) {
44
  if ( ! $field_id ) {
45
  return false;
46
  }
@@ -61,7 +61,7 @@ class FrmEntryMeta {
61
  return $wpdb->update( $wpdb->prefix .'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values );
62
  }
63
 
64
- public static function update_entry_metas($entry_id, $values) {
65
  global $wpdb;
66
 
67
  $prev_values = FrmDb::get_col( $wpdb->prefix .'frm_item_metas', array( 'item_id' => $entry_id, 'field_id !' => 0 ), 'field_id' );
@@ -103,7 +103,7 @@ class FrmEntryMeta {
103
  self::clear_cache();
104
  }
105
 
106
- public static function duplicate_entry_metas($old_id, $new_id) {
107
  $metas = self::get_entry_meta_info($old_id);
108
  foreach ( $metas as $meta ) {
109
  self::add_entry_meta($new_id, $meta->field_id, null, $meta->meta_value);
@@ -112,7 +112,7 @@ class FrmEntryMeta {
112
  self::clear_cache();
113
  }
114
 
115
- public static function delete_entry_meta($entry_id, $field_id) {
116
  global $wpdb;
117
  self::clear_cache();
118
  return $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id));
@@ -140,7 +140,7 @@ class FrmEntryMeta {
140
  }
141
  }
142
 
143
- public static function get_entry_meta_by_field($entry_id, $field_id) {
144
  global $wpdb;
145
 
146
  if ( is_object( $entry_id ) ) {
@@ -178,7 +178,7 @@ class FrmEntryMeta {
178
  return self::get_entry_meta_by_field( $entry_id, $field_id );
179
  }
180
 
181
- public static function get_entry_metas($entry_id) {
182
  _deprecated_function( __FUNCTION__, '1.07.10');
183
 
184
  global $wpdb;
@@ -212,7 +212,7 @@ class FrmEntryMeta {
212
  * @param string $order
213
  * @param string $limit
214
  */
215
- private static function meta_field_query($field_id, $order, $limit, $args, array &$query) {
216
  global $wpdb;
217
  $query[] = 'SELECT';
218
  $query[] = $args['unique'] ? 'DISTINCT(em.meta_value)' : 'em.meta_value';
@@ -238,7 +238,7 @@ class FrmEntryMeta {
238
  $query[] = $order . $limit;
239
  }
240
 
241
- public static function get_entry_meta_info($entry_id) {
242
  return FrmDb::get_results( 'frm_item_metas', array( 'item_id' => $entry_id ) );
243
  }
244
 
@@ -287,7 +287,7 @@ class FrmEntryMeta {
287
  * @param string $order_by
288
  * @param string $limit
289
  */
290
- private static function get_ids_query($where, $order_by, $limit, $unique, $args, array &$query ) {
291
  global $wpdb;
292
  $query[] = 'SELECT';
293
 
@@ -387,5 +387,4 @@ class FrmEntryMeta {
387
 
388
  return $results;
389
  }
390
-
391
  }
8
  /**
9
  * @param string $meta_key
10
  */
11
+ public static function add_entry_meta( $entry_id, $field_id, $meta_key = null, $meta_value ) {
12
  global $wpdb;
13
 
14
  if ( FrmAppHelper::is_empty_value( $meta_value ) ) {
40
  /**
41
  * @param string $meta_key
42
  */
43
+ public static function update_entry_meta( $entry_id, $field_id, $meta_key = null, $meta_value ) {
44
  if ( ! $field_id ) {
45
  return false;
46
  }
61
  return $wpdb->update( $wpdb->prefix .'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values );
62
  }
63
 
64
+ public static function update_entry_metas( $entry_id, $values ) {
65
  global $wpdb;
66
 
67
  $prev_values = FrmDb::get_col( $wpdb->prefix .'frm_item_metas', array( 'item_id' => $entry_id, 'field_id !' => 0 ), 'field_id' );
103
  self::clear_cache();
104
  }
105
 
106
+ public static function duplicate_entry_metas( $old_id, $new_id ) {
107
  $metas = self::get_entry_meta_info($old_id);
108
  foreach ( $metas as $meta ) {
109
  self::add_entry_meta($new_id, $meta->field_id, null, $meta->meta_value);
112
  self::clear_cache();
113
  }
114
 
115
+ public static function delete_entry_meta( $entry_id, $field_id ) {
116
  global $wpdb;
117
  self::clear_cache();
118
  return $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id));
140
  }
141
  }
142
 
143
+ public static function get_entry_meta_by_field( $entry_id, $field_id ) {
144
  global $wpdb;
145
 
146
  if ( is_object( $entry_id ) ) {
178
  return self::get_entry_meta_by_field( $entry_id, $field_id );
179
  }
180
 
181
+ public static function get_entry_metas( $entry_id ) {
182
  _deprecated_function( __FUNCTION__, '1.07.10');
183
 
184
  global $wpdb;
212
  * @param string $order
213
  * @param string $limit
214
  */
215
+ private static function meta_field_query( $field_id, $order, $limit, $args, array &$query ) {
216
  global $wpdb;
217
  $query[] = 'SELECT';
218
  $query[] = $args['unique'] ? 'DISTINCT(em.meta_value)' : 'em.meta_value';
238
  $query[] = $order . $limit;
239
  }
240
 
241
+ public static function get_entry_meta_info( $entry_id ) {
242
  return FrmDb::get_results( 'frm_item_metas', array( 'item_id' => $entry_id ) );
243
  }
244
 
287
  * @param string $order_by
288
  * @param string $limit
289
  */
290
+ private static function get_ids_query( $where, $order_by, $limit, $unique, $args, array &$query ) {
291
  global $wpdb;
292
  $query[] = 'SELECT';
293
 
387
 
388
  return $results;
389
  }
 
390
  }
classes/models/FrmEntryValidate.php CHANGED
@@ -92,7 +92,7 @@ class FrmEntryValidate {
92
  $errors = apply_filters('frm_validate_field_entry', $errors, $posted_field, $value, $args);
93
  }
94
 
95
- public static function validate_url_field(&$errors, $field, &$value, $args) {
96
  if ( $value == '' || ! in_array( $field->type, array( 'website', 'url', 'image' ) ) ) {
97
  return;
98
  }
@@ -110,7 +110,7 @@ class FrmEntryValidate {
110
  }
111
  }
112
 
113
- public static function validate_email_field(&$errors, $field, $value, $args) {
114
  if ( $value == '' || $field->type != 'email' ) {
115
  return;
116
  }
@@ -121,8 +121,8 @@ class FrmEntryValidate {
121
  }
122
  }
123
 
124
- public static function validate_recaptcha(&$errors, $field, $args) {
125
- if ( $field->type != 'captcha' || FrmAppHelper::is_admin() ) {
126
  return;
127
  }
128
 
92
  $errors = apply_filters('frm_validate_field_entry', $errors, $posted_field, $value, $args);
93
  }
94
 
95
+ public static function validate_url_field( &$errors, $field, &$value, $args ) {
96
  if ( $value == '' || ! in_array( $field->type, array( 'website', 'url', 'image' ) ) ) {
97
  return;
98
  }
110
  }
111
  }
112
 
113
+ public static function validate_email_field( &$errors, $field, $value, $args ) {
114
  if ( $value == '' || $field->type != 'email' ) {
115
  return;
116
  }
121
  }
122
  }
123
 
124
+ public static function validate_recaptcha( &$errors, $field, $args ) {
125
+ if ( $field->type != 'captcha' || FrmAppHelper::is_admin() || apply_filters( 'frm_is_field_hidden', false, $field, stripslashes_deep( $_POST ) ) ) {
126
  return;
127
  }
128
 
classes/models/FrmField.php CHANGED
@@ -120,7 +120,7 @@ class FrmField {
120
  FrmFieldsHelper::fill_field( $values, $field, $form_id, $new_key );
121
 
122
  // If this is a repeating section, create new form
123
- if ( $field->type == 'divider' && self::is_option_true( $field, 'repeat' ) ) {
124
  // create the repeatable form
125
  $new_repeat_form_id = apply_filters( 'frm_create_repeat_form', 0, array( 'parent_form_id' => $form_id, 'field_name' => $field->name ) );
126
 
@@ -219,7 +219,7 @@ class FrmField {
219
  return $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_fields WHERE id=%d', $id ) );
220
  }
221
 
222
- public static function delete_form_transient($form_id) {
223
  $form_id = absint( $form_id );
224
  delete_transient( 'frm_form_fields_'. $form_id .'exclude' );
225
  delete_transient( 'frm_form_fields_'. $form_id .'include' );
@@ -291,7 +291,7 @@ class FrmField {
291
  return $type;
292
  }
293
 
294
- public static function get_all_types_in_form($form_id, $type, $limit = '', $inc_sub = 'exclude') {
295
  if ( ! $form_id ) {
296
  return array();
297
  }
@@ -367,7 +367,7 @@ class FrmField {
367
  return $results;
368
  }
369
 
370
- public static function include_sub_fields(&$results, $inc_sub, $type = 'all') {
371
  if ( 'include' != $inc_sub ) {
372
  return;
373
  }
@@ -394,7 +394,7 @@ class FrmField {
394
  }
395
  }
396
 
397
- public static function getAll($where = array(), $order_by = '', $limit = '', $blog_id = false) {
398
  $cache_key = maybe_serialize($where) . $order_by .'l'. $limit .'b'. $blog_id;
399
  if ( self::$use_cache ) {
400
  // make sure old cache doesn't get saved as a transient
120
  FrmFieldsHelper::fill_field( $values, $field, $form_id, $new_key );
121
 
122
  // If this is a repeating section, create new form
123
+ if ( self::is_repeating_field( $field ) ) {
124
  // create the repeatable form
125
  $new_repeat_form_id = apply_filters( 'frm_create_repeat_form', 0, array( 'parent_form_id' => $form_id, 'field_name' => $field->name ) );
126
 
219
  return $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_fields WHERE id=%d', $id ) );
220
  }
221
 
222
+ public static function delete_form_transient( $form_id ) {
223
  $form_id = absint( $form_id );
224
  delete_transient( 'frm_form_fields_'. $form_id .'exclude' );
225
  delete_transient( 'frm_form_fields_'. $form_id .'include' );
291
  return $type;
292
  }
293
 
294
+ public static function get_all_types_in_form( $form_id, $type, $limit = '', $inc_sub = 'exclude' ) {
295
  if ( ! $form_id ) {
296
  return array();
297
  }
367
  return $results;
368
  }
369
 
370
+ public static function include_sub_fields( &$results, $inc_sub, $type = 'all' ) {
371
  if ( 'include' != $inc_sub ) {
372
  return;
373
  }
394
  }
395
  }
396
 
397
+ public static function getAll( $where = array(), $order_by = '', $limit = '', $blog_id = false ) {
398
  $cache_key = maybe_serialize($where) . $order_by .'l'. $limit .'b'. $blog_id;
399
  if ( self::$use_cache ) {
400
  // make sure old cache doesn't get saved as a transient
classes/models/FrmForm.php CHANGED
@@ -102,7 +102,7 @@ class FrmForm {
102
  return false;
103
  }
104
 
105
- public static function after_duplicate($form_id, $values) {
106
  $new_opts = $values['options'] = maybe_unserialize($values['options']);
107
 
108
  if ( isset($new_opts['success_msg']) ) {
@@ -131,7 +131,7 @@ class FrmForm {
131
  $values['form_key'] = FrmAppHelper::get_unique_key($values['form_key'], $wpdb->prefix .'frm_forms', 'form_key', $id);
132
  }
133
 
134
- $form_fields = array( 'form_key', 'name', 'description', 'status' );
135
 
136
  $new_values = self::set_update_options( array(), $values);
137
 
@@ -166,7 +166,7 @@ class FrmForm {
166
  /**
167
  * @return array
168
  */
169
- public static function set_update_options($new_values, $values) {
170
  if ( ! isset($values['options']) ) {
171
  return $new_values;
172
  }
@@ -189,7 +189,7 @@ class FrmForm {
189
  /**
190
  * @return array
191
  */
192
- public static function update_fields($id, $values) {
193
 
194
  if ( ! isset($values['options']) && ! isset($values['item_meta']) && ! isset($values['field_options']) ) {
195
  return $values;
@@ -276,7 +276,7 @@ class FrmForm {
276
  * @param string $status
277
  * @return int|boolean
278
  */
279
- public static function set_status($id, $status) {
280
  if ( 'trash' == $status ) {
281
  return self::trash($id);
282
  }
@@ -308,7 +308,7 @@ class FrmForm {
308
  /**
309
  * @return int|boolean
310
  */
311
- public static function trash($id) {
312
  if ( ! EMPTY_TRASH_DAYS ) {
313
  return self::destroy( $id );
314
  }
@@ -543,7 +543,7 @@ class FrmForm {
543
  /**
544
  * @return int count of forms
545
  */
546
- public static function &get_count( ) {
547
  global $wpdb;
548
 
549
  $cache_key = 'frm_form_counts';
102
  return false;
103
  }
104
 
105
+ public static function after_duplicate( $form_id, $values ) {
106
  $new_opts = $values['options'] = maybe_unserialize($values['options']);
107
 
108
  if ( isset($new_opts['success_msg']) ) {
131
  $values['form_key'] = FrmAppHelper::get_unique_key($values['form_key'], $wpdb->prefix .'frm_forms', 'form_key', $id);
132
  }
133
 
134
+ $form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' );
135
 
136
  $new_values = self::set_update_options( array(), $values);
137
 
166
  /**
167
  * @return array
168
  */
169
+ public static function set_update_options( $new_values, $values ) {
170
  if ( ! isset($values['options']) ) {
171
  return $new_values;
172
  }
189
  /**
190
  * @return array
191
  */
192
+ public static function update_fields( $id, $values ) {
193
 
194
  if ( ! isset($values['options']) && ! isset($values['item_meta']) && ! isset($values['field_options']) ) {
195
  return $values;
276
  * @param string $status
277
  * @return int|boolean
278
  */
279
+ public static function set_status( $id, $status ) {
280
  if ( 'trash' == $status ) {
281
  return self::trash($id);
282
  }
308
  /**
309
  * @return int|boolean
310
  */
311
+ public static function trash( $id ) {
312
  if ( ! EMPTY_TRASH_DAYS ) {
313
  return self::destroy( $id );
314
  }
543
  /**
544
  * @return int count of forms
545
  */
546
+ public static function &get_count() {
547
  global $wpdb;
548
 
549
  $cache_key = 'frm_form_counts';
classes/models/FrmFormAction.php CHANGED
@@ -24,7 +24,7 @@ class FrmFormAction {
24
  * @param array $old_instance Old settings for this instance
25
  * @return array Settings to save or bool false to cancel saving
26
  */
27
- public function update($new_instance, $old_instance) {
28
  return $new_instance;
29
  }
30
 
@@ -33,7 +33,7 @@ class FrmFormAction {
33
  *
34
  * @param array $instance Current settings
35
  */
36
- public function form($instance, $args = array()) {
37
  echo '<p class="no-options-widget">' . esc_html__( 'There are no options for this action.', 'formidable' ) . '</p>';
38
  return 'noform';
39
  }
@@ -49,7 +49,7 @@ class FrmFormAction {
49
  return array();
50
  }
51
 
52
- public function migrate_values($action, $form) {
53
  return $action;
54
  }
55
 
@@ -108,7 +108,7 @@ class FrmFormAction {
108
  * @param string $field_name Field name
109
  * @return string Name attribute for $field_name
110
  */
111
- public function get_field_name($field_name, $post_field = 'post_content') {
112
  return $this->option_name . '[' . $this->number . ']'. ( empty($post_field) ? '' : '['. $post_field .']' ) .'[' . $field_name . ']';
113
  }
114
 
@@ -120,18 +120,18 @@ class FrmFormAction {
120
  * @param string $field_name Field name
121
  * @return string ID attribute for $field_name
122
  */
123
- public function get_field_id($field_name) {
124
  return $field_name .'_'. $this->number;
125
  }
126
 
127
  // Private Function. Don't worry about this.
128
 
129
- public function _set($number) {
130
  $this->number = $number;
131
  $this->id = $this->id_base . '-' . $number;
132
  }
133
 
134
- public function prepare_new($form_id = false) {
135
  if ( $form_id ) {
136
  $this->form_id = $form_id;
137
  }
@@ -161,7 +161,7 @@ class FrmFormAction {
161
  return (object) $form_action;
162
  }
163
 
164
- public function create($form_id) {
165
  $this->form_id = $form_id;
166
 
167
  $action = $this->prepare_new();
@@ -169,7 +169,7 @@ class FrmFormAction {
169
  return $this->save_settings($action);
170
  }
171
 
172
- public function duplicate_form_actions($form_id, $old_id) {
173
  if ( $form_id == $old_id ) {
174
  // don't duplicate the actions if this is a template getting updated
175
  return;
@@ -205,7 +205,7 @@ class FrmFormAction {
205
  return $post_id;
206
  }
207
 
208
- public function duplicate_one($action, $form_id) {
209
  global $frm_duplicate_ids;
210
 
211
  $action->menu_order = $form_id;
@@ -233,7 +233,7 @@ class FrmFormAction {
233
  return $this->save_settings($action);
234
  }
235
 
236
- private function duplicate_array_walk($action, $subkey, $val) {
237
  global $frm_duplicate_ids;
238
 
239
  if ( is_array($subkey) ) {
@@ -333,7 +333,7 @@ class FrmFormAction {
333
  return $action_ids;
334
  }
335
 
336
- public function save_settings($settings) {
337
  return FrmAppHelper::save_settings( $settings, 'frm_actions' );
338
  }
339
 
@@ -450,7 +450,7 @@ class FrmFormAction {
450
  return $args;
451
  }
452
 
453
- public function prepare_action($action) {
454
  $action->post_content = FrmAppHelper::maybe_json_decode($action->post_content);
455
  $action->post_excerpt = sanitize_title( $action->post_excerpt );
456
 
@@ -475,7 +475,7 @@ class FrmFormAction {
475
  return $action;
476
  }
477
 
478
- public function destroy($form_id = false, $type = 'default') {
479
  global $wpdb;
480
 
481
  $this->form_id = $form_id;
@@ -501,7 +501,7 @@ class FrmFormAction {
501
  *
502
  * @since 2.0.5
503
  */
504
- public static function clear_cache( ) {
505
  FrmAppHelper::cache_delete_group( 'frm_actions' );
506
  }
507
 
@@ -535,7 +535,7 @@ class FrmFormAction {
535
  /**
536
  * Migrate settings from form->options into new action.
537
  */
538
- public function migrate_to_2($form, $update = 'update') {
539
  $action = $this->prepare_new($form->id);
540
  $form->options = maybe_unserialize($form->options);
541
 
24
  * @param array $old_instance Old settings for this instance
25
  * @return array Settings to save or bool false to cancel saving
26
  */
27
+ public function update( $new_instance, $old_instance ) {
28
  return $new_instance;
29
  }
30
 
33
  *
34
  * @param array $instance Current settings
35
  */
36
+ public function form( $instance, $args = array() ) {
37
  echo '<p class="no-options-widget">' . esc_html__( 'There are no options for this action.', 'formidable' ) . '</p>';
38
  return 'noform';
39
  }
49
  return array();
50
  }
51
 
52
+ public function migrate_values( $action, $form ) {
53
  return $action;
54
  }
55
 
108
  * @param string $field_name Field name
109
  * @return string Name attribute for $field_name
110
  */
111
+ public function get_field_name( $field_name, $post_field = 'post_content' ) {
112
  return $this->option_name . '[' . $this->number . ']'. ( empty($post_field) ? '' : '['. $post_field .']' ) .'[' . $field_name . ']';
113
  }
114
 
120
  * @param string $field_name Field name
121
  * @return string ID attribute for $field_name
122
  */
123
+ public function get_field_id( $field_name ) {
124
  return $field_name .'_'. $this->number;
125
  }
126
 
127
  // Private Function. Don't worry about this.
128
 
129
+ public function _set( $number ) {
130
  $this->number = $number;
131
  $this->id = $this->id_base . '-' . $number;
132
  }
133
 
134
+ public function prepare_new( $form_id = false ) {
135
  if ( $form_id ) {
136
  $this->form_id = $form_id;
137
  }
161
  return (object) $form_action;
162
  }
163
 
164
+ public function create( $form_id ) {
165
  $this->form_id = $form_id;
166
 
167
  $action = $this->prepare_new();
169
  return $this->save_settings($action);
170
  }
171
 
172
+ public function duplicate_form_actions( $form_id, $old_id ) {
173
  if ( $form_id == $old_id ) {
174
  // don't duplicate the actions if this is a template getting updated
175
  return;
205
  return $post_id;
206
  }
207
 
208
+ public function duplicate_one( $action, $form_id ) {
209
  global $frm_duplicate_ids;
210
 
211
  $action->menu_order = $form_id;
233
  return $this->save_settings($action);
234
  }
235
 
236
+ private function duplicate_array_walk( $action, $subkey, $val ) {
237
  global $frm_duplicate_ids;
238
 
239
  if ( is_array($subkey) ) {
333
  return $action_ids;
334
  }
335
 
336
+ public function save_settings( $settings ) {
337
  return FrmAppHelper::save_settings( $settings, 'frm_actions' );
338
  }
339
 
450
  return $args;
451
  }
452
 
453
+ public function prepare_action( $action ) {
454
  $action->post_content = FrmAppHelper::maybe_json_decode($action->post_content);
455
  $action->post_excerpt = sanitize_title( $action->post_excerpt );
456
 
475
  return $action;
476
  }
477
 
478
+ public function destroy( $form_id = false, $type = 'default' ) {
479
  global $wpdb;
480
 
481
  $this->form_id = $form_id;
501
  *
502
  * @since 2.0.5
503
  */
504
+ public static function clear_cache() {
505
  FrmAppHelper::cache_delete_group( 'frm_actions' );
506
  }
507
 
535
  /**
536
  * Migrate settings from form->options into new action.
537
  */
538
+ public function migrate_to_2( $form, $update = 'update' ) {
539
  $action = $this->prepare_new($form->id);
540
  $form->options = maybe_unserialize($form->options);
541
 
classes/models/FrmNotification.php CHANGED
@@ -8,7 +8,7 @@ class FrmNotification {
8
  add_action('frm_trigger_email_action', 'FrmNotification::trigger_email', 10, 3);
9
  }
10
 
11
- public static function trigger_email($action, $entry, $form) {
12
  if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
13
  return;
14
  }
@@ -147,12 +147,12 @@ class FrmNotification {
147
  return $sent_to;
148
  }
149
 
150
- public function entry_created($entry_id, $form_id) {
151
  _deprecated_function( __FUNCTION__, '2.0', 'FrmFormActionsController::trigger_actions("create", '. $form_id .', '. $entry_id .', "email")');
152
  FrmFormActionsController::trigger_actions('create', $form_id, $entry_id, 'email');
153
  }
154
 
155
- public function send_notification_email($to_email, $subject, $message, $from = '', $from_name = '', $plain_text = true, $attachments = array(), $reply_to = '') {
156
  _deprecated_function( __FUNCTION__, '2.0', 'FrmNotification::send_email' );
157
 
158
  return self::send_email(compact(
@@ -299,7 +299,7 @@ class FrmNotification {
299
  $atts[ $f ] = $final_val;
300
  }
301
 
302
- public static function send_email($atts) {
303
  $admin_email = get_option('admin_email');
304
  $defaults = array(
305
  'to_email' => $admin_email,
8
  add_action('frm_trigger_email_action', 'FrmNotification::trigger_email', 10, 3);
9
  }
10
 
11
+ public static function trigger_email( $action, $entry, $form ) {
12
  if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
13
  return;
14
  }
147
  return $sent_to;
148
  }
149
 
150
+ public function entry_created( $entry_id, $form_id ) {
151
  _deprecated_function( __FUNCTION__, '2.0', 'FrmFormActionsController::trigger_actions("create", '. $form_id .', '. $entry_id .', "email")');
152
  FrmFormActionsController::trigger_actions('create', $form_id, $entry_id, 'email');
153
  }
154
 
155
+ public function send_notification_email( $to_email, $subject, $message, $from = '', $from_name = '', $plain_text = true, $attachments = array(), $reply_to = '' ) {
156
  _deprecated_function( __FUNCTION__, '2.0', 'FrmNotification::send_email' );
157
 
158
  return self::send_email(compact(
299
  $atts[ $f ] = $final_val;
300
  }
301
 
302
+ public static function send_email( $atts ) {
303
  $admin_email = get_option('admin_email');
304
  $defaults = array(
305
  'to_email' => $admin_email,
classes/models/FrmSettings.php CHANGED
@@ -46,7 +46,7 @@ class FrmSettings{
46
  $this->set_default_options();
47
  }
48
 
49
- private function translate_settings($settings) {
50
  if ( $settings ) { //workaround for W3 total cache conflict
51
  return unserialize(serialize($settings));
52
  }
@@ -124,7 +124,7 @@ class FrmSettings{
124
  }
125
  }
126
 
127
- public function fill_with_defaults($params = array()) {
128
  $settings = $this->default_options();
129
 
130
  foreach ( $settings as $setting => $default ) {
@@ -182,7 +182,7 @@ class FrmSettings{
182
  do_action( 'frm_update_settings', $params );
183
  }
184
 
185
- private function update_settings($params) {
186
  $this->mu_menu = isset($params['frm_mu_menu']) ? $params['frm_mu_menu'] : 0;
187
 
188
  $this->pubkey = trim($params['frm_pubkey']);
@@ -198,7 +198,7 @@ class FrmSettings{
198
  $this->accordion_js = isset( $params['frm_accordion_js'] ) ? absint( $params['frm_accordion_js'] ) : 0;
199
  }
200
 
201
- private function update_roles($params) {
202
  //update roles
203
  global $wp_roles;
204
 
@@ -243,5 +243,4 @@ class FrmSettings{
243
 
244
  do_action( 'frm_store_settings' );
245
  }
246
-
247
  }
46
  $this->set_default_options();
47
  }
48
 
49
+ private function translate_settings( $settings ) {
50
  if ( $settings ) { //workaround for W3 total cache conflict
51
  return unserialize(serialize($settings));
52
  }
124
  }
125
  }
126
 
127
+ public function fill_with_defaults( $params = array() ) {
128
  $settings = $this->default_options();
129
 
130
  foreach ( $settings as $setting => $default ) {
182
  do_action( 'frm_update_settings', $params );
183
  }
184
 
185
+ private function update_settings( $params ) {
186
  $this->mu_menu = isset($params['frm_mu_menu']) ? $params['frm_mu_menu'] : 0;
187
 
188
  $this->pubkey = trim($params['frm_pubkey']);
198
  $this->accordion_js = isset( $params['frm_accordion_js'] ) ? absint( $params['frm_accordion_js'] ) : 0;
199
  }
200
 
201
+ private function update_roles( $params ) {
202
  //update roles
203
  global $wp_roles;
204
 
243
 
244
  do_action( 'frm_store_settings' );
245
  }
 
246
  }
classes/models/FrmStyle.php CHANGED
@@ -30,11 +30,11 @@ class FrmStyle {
30
  return (object) $style;
31
  }
32
 
33
- public function save($settings) {
34
  return FrmAppHelper::save_settings( $settings, 'frm_styles' );
35
  }
36
 
37
- public function duplicate($id) {
38
  // duplicating is a pro feature
39
  }
40
 
@@ -99,7 +99,7 @@ class FrmStyle {
99
  /**
100
  * Create static css file
101
  */
102
- public function save_settings($styles) {
103
  $filename = FrmAppHelper::plugin_path() .'/css/custom_theme.css.php';
104
 
105
  if ( ! is_file($filename) ) {
@@ -124,16 +124,20 @@ class FrmStyle {
124
  $access_type = get_filesystem_method();
125
  if ( $access_type === 'direct' ) {
126
  $creds = request_filesystem_credentials( site_url() .'/wp-admin/', '', false, false, array() );
 
 
 
127
 
 
128
  // initialize the API
129
- if ( ! WP_Filesystem($creds) ) {
130
  // any problems and we exit
131
  $dirs_exist = false;
132
  }
133
 
134
- global $wp_filesystem;
135
-
136
  if ( $dirs_exist ) {
 
 
137
  $chmod_dir = defined('FS_CHMOD_DIR') ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 );
138
  $chmod_file = defined('FS_CHMOD_FILE') ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 );
139
 
@@ -162,7 +166,57 @@ class FrmStyle {
162
  set_transient('frmpro_css', $css);
163
  }
164
 
165
- public function destroy($id) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
  return wp_delete_post($id);
167
  }
168
 
@@ -258,7 +312,7 @@ class FrmStyle {
258
  return $styles;
259
  }
260
 
261
- public function get_default_style($styles = null) {
262
  if ( ! isset($styles) ) {
263
  $styles = $this->get_all( 'menu_order', 'DESC', 1 );
264
  }
@@ -270,7 +324,7 @@ class FrmStyle {
270
  }
271
  }
272
 
273
- public function override_defaults($settings) {
274
  if ( ! is_array($settings) ) {
275
  return $settings;
276
  }
@@ -422,7 +476,7 @@ class FrmStyle {
422
  );
423
  }
424
 
425
- public function get_field_name($field_name, $post_field = 'post_content') {
426
  return 'frm_style_setting'. ( empty($post_field) ? '' : '['. $post_field .']' ) .'[' . $field_name . ']';
427
  }
428
 
30
  return (object) $style;
31
  }
32
 
33
+ public function save( $settings ) {
34
  return FrmAppHelper::save_settings( $settings, 'frm_styles' );
35
  }
36
 
37
+ public function duplicate( $id ) {
38
  // duplicating is a pro feature
39
  }
40
 
99
  /**
100
  * Create static css file
101
  */
102
+ public function save_settings( $styles ) {
103
  $filename = FrmAppHelper::plugin_path() .'/css/custom_theme.css.php';
104
 
105
  if ( ! is_file($filename) ) {
124
  $access_type = get_filesystem_method();
125
  if ( $access_type === 'direct' ) {
126
  $creds = request_filesystem_credentials( site_url() .'/wp-admin/', '', false, false, array() );
127
+ } else {
128
+ $creds = $this->get_ftp_creds( $access_type );
129
+ }
130
 
131
+ if ( ! empty( $creds ) ) {
132
  // initialize the API
133
+ if ( ! WP_Filesystem( $creds ) ) {
134
  // any problems and we exit
135
  $dirs_exist = false;
136
  }
137
 
 
 
138
  if ( $dirs_exist ) {
139
+ global $wp_filesystem;
140
+
141
  $chmod_dir = defined('FS_CHMOD_DIR') ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 );
142
  $chmod_file = defined('FS_CHMOD_FILE') ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 );
143
 
166
  set_transient('frmpro_css', $css);
167
  }
168
 
169
+ private function get_ftp_creds( $type ) {
170
+ $credentials = get_option( 'ftp_credentials', array( 'hostname' => '', 'username' => '' ) );
171
+
172
+ $credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : $credentials['hostname'];
173
+ $credentials['username'] = defined('FTP_USER') ? FTP_USER : $credentials['username'];
174
+ $credentials['password'] = defined('FTP_PASS') ? FTP_PASS : '';
175
+
176
+ // Check to see if we are setting the public/private keys for ssh
177
+ $credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : '';
178
+ $credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : '';
179
+
180
+ // Sanitize the hostname, Some people might pass in odd-data:
181
+ $credentials['hostname'] = preg_replace( '|\w+://|', '', $credentials['hostname'] ); //Strip any schemes off
182
+
183
+ if ( strpos( $credentials['hostname'], ':' ) ) {
184
+ list( $credentials['hostname'], $credentials['port'] ) = explode( ':', $credentials['hostname'], 2 );
185
+ if ( ! is_numeric( $credentials['port'] ) ) {
186
+ unset( $credentials['port'] );
187
+ }
188
+ } else {
189
+ unset( $credentials['port'] );
190
+ }
191
+
192
+ if ( ( defined( 'FTP_SSH' ) && FTP_SSH ) || ( defined( 'FS_METHOD' ) && 'ssh2' == FS_METHOD ) ) {
193
+ $credentials['connection_type'] = 'ssh';
194
+ } else if ( ( defined( 'FTP_SSL' ) && FTP_SSL ) && 'ftpext' == $type ) {
195
+ //Only the FTP Extension understands SSL
196
+ $credentials['connection_type'] = 'ftps';
197
+ } else if ( ! isset( $credentials['connection_type'] ) ) {
198
+ //All else fails (And it's not defaulted to something else saved), Default to FTP
199
+ $credentials['connection_type'] = 'ftp';
200
+ }
201
+
202
+ $has_creds = ( ! empty( $credentials['password'] ) && ! empty( $credentials['username'] ) && ! empty( $credentials['hostname'] ) );
203
+ $can_ssh = ( 'ssh' == $credentials['connection_type'] && ! empty( $credentials['public_key'] ) && ! empty( $credentials['private_key'] ) );
204
+ if ( $has_creds || $can_ssh ) {
205
+ $stored_credentials = $credentials;
206
+ if ( ! empty( $stored_credentials['port'] ) ) {
207
+ //save port as part of hostname to simplify above code.
208
+ $stored_credentials['hostname'] .= ':' . $stored_credentials['port'];
209
+ }
210
+
211
+ unset( $stored_credentials['password'], $stored_credentials['port'], $stored_credentials['private_key'], $stored_credentials['public_key'] );
212
+
213
+ return $credentials;
214
+ }
215
+
216
+ return false;
217
+ }
218
+
219
+ public function destroy( $id ) {
220
  return wp_delete_post($id);
221
  }
222
 
312
  return $styles;
313
  }
314
 
315
+ public function get_default_style( $styles = null ) {
316
  if ( ! isset($styles) ) {
317
  $styles = $this->get_all( 'menu_order', 'DESC', 1 );
318
  }
324
  }
325
  }
326
 
327
+ public function override_defaults( $settings ) {
328
  if ( ! is_array($settings) ) {
329
  return $settings;
330
  }
476
  );
477
  }
478
 
479
+ public function get_field_name( $field_name, $post_field = 'post_content' ) {
480
  return 'frm_style_setting'. ( empty($post_field) ? '' : '['. $post_field .']' ) .'[' . $field_name . ']';
481
  }
482
 
classes/views/addons/settings.php CHANGED
@@ -2,7 +2,7 @@
2
  <h2><?php _e( 'Plugin Licenses', 'formidable' ); ?></h2>
3
 
4
  <?php
5
-
6
  foreach ( $plugins as $slug => $plugin ) {
7
  $license = get_option( 'edd_'. $slug .'_license_key' );
8
  $status = get_option( 'edd_'. $slug .'_license_active' );
@@ -28,4 +28,4 @@
28
  </div>
29
  <?php } ?>
30
 
31
- </div>
2
  <h2><?php _e( 'Plugin Licenses', 'formidable' ); ?></h2>
3
 
4
  <?php
5
+
6
  foreach ( $plugins as $slug => $plugin ) {
7
  $license = get_option( 'edd_'. $slug .'_license_key' );
8
  $status = get_option( 'edd_'. $slug .'_license_active' );
28
  </div>
29
  <?php } ?>
30
 
31
+ </div>
classes/views/frm-entries/form.php CHANGED
@@ -10,12 +10,21 @@ if ( empty($values) || ! isset($values['fields']) || empty($values['fields']) )
10
 
11
  global $frm_vars;
12
  FrmFormsController::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] );
 
 
 
 
 
 
 
13
  ?>
14
  <div class="frm_form_fields <?php echo esc_attr( apply_filters( 'frm_form_fields_class', '', $values ) ); ?>">
15
  <fieldset>
16
  <?php echo FrmFormsHelper::replace_shortcodes( $values['before_html'], $form, $title, $description ); ?>
17
  <input type="hidden" name="frm_action" value="<?php echo esc_attr($form_action) ?>" />
18
  <input type="hidden" name="form_id" value="<?php echo esc_attr($form->id) ?>" />
 
 
19
  <input type="hidden" name="form_key" value="<?php echo esc_attr($form->form_key) ?>" />
20
  <input type="hidden" name="item_meta[0]" value="" />
21
  <?php wp_nonce_field( 'frm_submit_entry_nonce', 'frm_submit_entry_' . $form->id ); ?>
10
 
11
  global $frm_vars;
12
  FrmFormsController::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] );
13
+
14
+ // Get conditionally hidden fields
15
+ $frm_hide_fields = FrmAppHelper::get_post_param( 'frm_hide_fields', '', 'sanitize_text_field' );
16
+
17
+ // Get helpers
18
+ $frm_helpers = apply_filters( 'frm_get_parent_child_field_helpers', '', $values['fields'] );
19
+
20
  ?>
21
  <div class="frm_form_fields <?php echo esc_attr( apply_filters( 'frm_form_fields_class', '', $values ) ); ?>">
22
  <fieldset>
23
  <?php echo FrmFormsHelper::replace_shortcodes( $values['before_html'], $form, $title, $description ); ?>
24
  <input type="hidden" name="frm_action" value="<?php echo esc_attr($form_action) ?>" />
25
  <input type="hidden" name="form_id" value="<?php echo esc_attr($form->id) ?>" />
26
+ <input type="hidden" name="frm_hide_fields" id="frm_hide_fields" value="<?php echo esc_attr($frm_hide_fields) ?>" />
27
+ <input type="hidden" name="frm_helpers" id="frm_helpers" value="<?php echo esc_attr( $frm_helpers ) ?>" />
28
  <input type="hidden" name="form_key" value="<?php echo esc_attr($form->form_key) ?>" />
29
  <input type="hidden" name="item_meta[0]" value="" />
30
  <?php wp_nonce_field( 'frm_submit_entry_nonce', 'frm_submit_entry_' . $form->id ); ?>
classes/views/frm-fields/show-build.php CHANGED
@@ -43,7 +43,7 @@
43
  <div class="frm-show-click frm_small_top_margin">
44
  <?php
45
 
46
- if ( ! isset( $field['post_field'] ) || ! in_array( $field['post_field'], array( 'post_status', 'post_category' ) ) ) { ?>
47
  <?php do_action('frm_add_multiple_opts_labels', $field); ?>
48
  <ul id="frm_field_<?php echo esc_attr( $field['id'] ) ?>_opts" class="frm_sortable_field_opts<?php echo ( count($field['options']) > 10 ) ? ' frm_field_opts_list' : ''; ?>">
49
  <?php FrmFieldsHelper::show_single_option($field); ?>
43
  <div class="frm-show-click frm_small_top_margin">
44
  <?php
45
 
46
+ if ( ! isset( $field['post_field'] ) || ! in_array( $field['post_field'], array( 'post_category' ) ) ) { ?>
47
  <?php do_action('frm_add_multiple_opts_labels', $field); ?>
48
  <ul id="frm_field_<?php echo esc_attr( $field['id'] ) ?>_opts" class="frm_sortable_field_opts<?php echo ( count($field['options']) > 10 ) ? ' frm_field_opts_list' : ''; ?>">
49
  <?php FrmFieldsHelper::show_single_option($field); ?>
classes/views/frm-form-actions/email_action.php CHANGED
@@ -36,5 +36,4 @@ class FrmEmailAction extends FrmFormAction {
36
  'event' => array( 'create' ),
37
  );
38
  }
39
-
40
  }
36
  'event' => array( 'create' ),
37
  );
38
  }
 
39
  }
classes/views/frm-forms/add_field.php CHANGED
@@ -124,7 +124,7 @@ if ( in_array( $field['type'], array( 'select', 'radio', 'checkbox' ) ) ) { ?>
124
 
125
  if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
126
  echo '<p class="howto">'. FrmFieldsHelper::get_term_link($field['taxonomy']) .'</p>';
127
- } else if ( ! isset( $field['post_field'] ) || ! in_array( $field['post_field'], array( 'post_category', 'post_status' ) ) ) {
128
  ?>
129
  <div id="frm_add_field_<?php echo esc_attr( $field['id'] ); ?>">
130
  <a href="javascript:void(0);" data-opttype="single" class="button frm_cb_button frm_add_opt"><?php _e( 'Add Option', 'formidable' ) ?></a>
124
 
125
  if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
126
  echo '<p class="howto">'. FrmFieldsHelper::get_term_link($field['taxonomy']) .'</p>';
127
+ } else if ( ! isset( $field['post_field'] ) || ! in_array( $field['post_field'], array( 'post_category' ) ) ) {
128
  ?>
129
  <div id="frm_add_field_<?php echo esc_attr( $field['id'] ); ?>">
130
  <a href="javascript:void(0);" data-opttype="single" class="button frm_cb_button frm_add_opt"><?php _e( 'Add Option', 'formidable' ) ?></a>
classes/views/frm-forms/add_field_links.php CHANGED
@@ -85,18 +85,17 @@ foreach ( FrmField::pro_field_selection() as $field_key => $field_type ) {
85
  'label' => __( 'First', 'formidable' ),
86
  'title' => __( 'Add this to the first field in each row along with a width. ie frm_first frm_third', 'formidable' ),
87
  ),
88
- 'frm_last' => array(
89
- 'label' => __( 'Last', 'formidable' ),
90
- 'title' => __( 'Add this to the last field in each row along with a width. ie frm_last frm_third', 'formidable' ),
91
- ),
92
  'frm_half' => __( '1/2', 'formidable' ),
93
  'frm_third' => __( '1/3', 'formidable' ),
94
  'frm_two_thirds' => __( '2/3', 'formidable' ),
95
  'frm_fourth' => __( '1/4', 'formidable' ),
 
96
  'frm_fifth' => __( '1/5', 'formidable' ),
 
97
  'frm_sixth' => __( '1/6', 'formidable' ),
98
  'frm_seventh' => __( '1/7', 'formidable' ),
99
  'frm_eighth' => __( '1/8', 'formidable' ),
 
100
  'frm_inline' => array(
101
  'label' => __( 'Inline', 'formidable' ),
102
  'title' => __( 'Align fields in a row without a specific width.', 'formidable' ),
85
  'label' => __( 'First', 'formidable' ),
86
  'title' => __( 'Add this to the first field in each row along with a width. ie frm_first frm_third', 'formidable' ),
87
  ),
 
 
 
 
88
  'frm_half' => __( '1/2', 'formidable' ),
89
  'frm_third' => __( '1/3', 'formidable' ),
90
  'frm_two_thirds' => __( '2/3', 'formidable' ),
91
  'frm_fourth' => __( '1/4', 'formidable' ),
92
+ 'frm_three_fourths' => __( '3/4', 'formidable' ),
93
  'frm_fifth' => __( '1/5', 'formidable' ),
94
+ 'frm_two_fifths' => __( '2/5', 'formidable' ),
95
  'frm_sixth' => __( '1/6', 'formidable' ),
96
  'frm_seventh' => __( '1/7', 'formidable' ),
97
  'frm_eighth' => __( '1/8', 'formidable' ),
98
+ 'frm_alignright' => __( 'Right', 'formidable' ),
99
  'frm_inline' => array(
100
  'label' => __( 'Inline', 'formidable' ),
101
  'title' => __( 'Align fields in a row without a specific width.', 'formidable' ),
css/custom_theme.css.php CHANGED
@@ -632,18 +632,26 @@ table.frmcal-calendar .frmcal-today .frmcal_date{
632
  .frm_form_field.frm_last_inline,
633
  .frm_form_field.frm_last,
634
  .frm_form_field.frm_half,
 
635
  .frm_form_field.frm_third,
 
636
  .frm_form_field.frm_two_thirds,
637
  .frm_form_field.frm_fourth,
 
638
  .frm_form_field.frm_three_fourths,
639
  .frm_form_field.frm_fifth,
 
640
  .frm_form_field.frm_two_fifths,
641
  .frm_form_field.frm_three_fifths,
642
  .frm_form_field.frm_four_fifths,
643
  .frm_form_field.frm_sixth,
 
644
  .frm_form_field.frm_seventh,
 
645
  .frm_form_field.frm_eighth,
646
- .frm_form_field.frm_inline{
 
 
647
  clear:none;
648
  float:left;
649
  margin-left:2.5%;
@@ -678,12 +686,14 @@ table.frmcal-calendar .frmcal-today .frmcal_date{
678
  .frm_form_field.frm_right_half,
679
  .frm_form_field.frm_first_half,
680
  .frm_form_field.frm_last_half,
681
- .frm_form_field.frm_half{
 
682
  width:48.75%;
683
  }
684
 
685
  .frm_form_field.frm_left_third,
686
  .frm_form_field.frm_third,
 
687
  .frm_form_field.frm_right_third,
688
  .frm_form_field.frm_first_third,
689
  .frm_form_field.frm_last_third{
@@ -700,6 +710,7 @@ table.frmcal-calendar .frmcal-today .frmcal_date{
700
 
701
  .frm_form_field.frm_left_fourth,
702
  .frm_form_field.frm_fourth,
 
703
  .frm_form_field.frm_right_fourth,
704
  .frm_form_field.frm_first_fourth,
705
  .frm_form_field.frm_last_fourth{
@@ -712,6 +723,7 @@ table.frmcal-calendar .frmcal-today .frmcal_date{
712
 
713
  .frm_form_field.frm_left_fifth,
714
  .frm_form_field.frm_fifth,
 
715
  .frm_form_field.frm_right_fifth,
716
  .frm_form_field.frm_first_fifth,
717
  .frm_form_field.frm_last_fifth{
@@ -731,18 +743,21 @@ table.frmcal-calendar .frmcal-today .frmcal_date{
731
  }
732
 
733
  .frm_form_field.frm_sixth,
 
734
  .frm_form_field.frm_first_sixth,
735
  .frm_form_field.frm_last_sixth{
736
  width:14.58%;
737
  }
738
 
739
  .frm_form_field.frm_seventh,
 
740
  .frm_form_field.frm_first_seventh,
741
  .frm_form_field.frm_last_seventh{
742
  width:12.14%;
743
  }
744
 
745
  .frm_form_field.frm_eighth,
 
746
  .frm_form_field.frm_first_eighth,
747
  .frm_form_field.frm_last_eighth{
748
  width:10.31%;
@@ -751,6 +766,7 @@ table.frmcal-calendar .frmcal-today .frmcal_date{
751
  .frm_form_field.frm_left_inline,
752
  .frm_form_field.frm_first_inline,
753
  .frm_form_field.frm_inline,
 
754
  .frm_form_field.frm_right_inline,
755
  .frm_form_field.frm_last_inline{
756
  width:auto;
@@ -1277,8 +1293,8 @@ html[xmlns] .frm_clearfix{
1277
  margin:0 !important;
1278
  }
1279
 
1280
- .with_frm_style.frm_login_form.frm_inline_login.frm_no_labels .login-username label,
1281
- .with_frm_style.frm_login_form.frm_inline_login.frm_no_labels .login-password label{
1282
  display:none;
1283
  }
1284
 
@@ -1751,31 +1767,39 @@ html[xmlns] .frm_clearfix{
1751
 
1752
  @media only screen and (max-width: 600px) {
1753
  .frm_form_field.frm_half,
 
1754
  .frm_form_field.frm_left_half,
1755
  .frm_form_field.frm_right_half,
1756
  .frm_form_field.frm_first_half,
1757
  .frm_form_field.frm_last_half,
1758
  .frm_form_field.frm_first_third,
1759
  .frm_form_field.frm_third,
 
1760
  .frm_form_field.frm_last_third,
1761
  .frm_form_field.frm_first_two_thirds,
1762
  .frm_form_field.frm_last_two_thirds,
1763
  .frm_form_field.frm_two_thirds,
1764
  .frm_form_field.frm_left_fourth,
1765
  .frm_form_field.frm_fourth,
 
1766
  .frm_form_field.frm_right_fourth,
1767
  .frm_form_field.frm_first_fourth,
1768
  .frm_form_field.frm_last_fourth,
1769
  .frm_form_field.frm_three_fourths,
1770
  .frm_form_field.frm_fifth,
 
1771
  .frm_form_field.frm_two_fifths,
1772
  .frm_form_field.frm_three_fifths,
1773
  .frm_form_field.frm_four_fifths,
1774
  .frm_form_field.frm_sixth,
 
1775
  .frm_form_field.frm_seventh,
 
1776
  .frm_form_field.frm_eighth,
 
1777
  .frm_form_field.frm_first_inline,
1778
  .frm_form_field.frm_inline,
 
1779
  .frm_form_field.frm_last_inline{
1780
  width:100%;
1781
  margin-left:0;
632
  .frm_form_field.frm_last_inline,
633
  .frm_form_field.frm_last,
634
  .frm_form_field.frm_half,
635
+ .frm_submit.frm_half,
636
  .frm_form_field.frm_third,
637
+ .frm_submit.frm_third,
638
  .frm_form_field.frm_two_thirds,
639
  .frm_form_field.frm_fourth,
640
+ .frm_submit.frm_fourth,
641
  .frm_form_field.frm_three_fourths,
642
  .frm_form_field.frm_fifth,
643
+ .frm_submit.frm_fifth,
644
  .frm_form_field.frm_two_fifths,
645
  .frm_form_field.frm_three_fifths,
646
  .frm_form_field.frm_four_fifths,
647
  .frm_form_field.frm_sixth,
648
+ .frm_submit.frm_sixth,
649
  .frm_form_field.frm_seventh,
650
+ .frm_submit.frm_seventh,
651
  .frm_form_field.frm_eighth,
652
+ .frm_submit.frm_eighth,
653
+ .frm_form_field.frm_inline,
654
+ .frm_submit.frm_inline{
655
  clear:none;
656
  float:left;
657
  margin-left:2.5%;
686
  .frm_form_field.frm_right_half,
687
  .frm_form_field.frm_first_half,
688
  .frm_form_field.frm_last_half,
689
+ .frm_form_field.frm_half,
690
+ .frm_submit.frm_half{
691
  width:48.75%;
692
  }
693
 
694
  .frm_form_field.frm_left_third,
695
  .frm_form_field.frm_third,
696
+ .frm_submit.frm_third,
697
  .frm_form_field.frm_right_third,
698
  .frm_form_field.frm_first_third,
699
  .frm_form_field.frm_last_third{
710
 
711
  .frm_form_field.frm_left_fourth,
712
  .frm_form_field.frm_fourth,
713
+ .frm_submit.frm_fourth,
714
  .frm_form_field.frm_right_fourth,
715
  .frm_form_field.frm_first_fourth,
716
  .frm_form_field.frm_last_fourth{
723
 
724
  .frm_form_field.frm_left_fifth,
725
  .frm_form_field.frm_fifth,
726
+ .frm_submit.frm_fifth,
727
  .frm_form_field.frm_right_fifth,
728
  .frm_form_field.frm_first_fifth,
729
  .frm_form_field.frm_last_fifth{
743
  }
744
 
745
  .frm_form_field.frm_sixth,
746
+ .frm_submit.frm_sixth,
747
  .frm_form_field.frm_first_sixth,
748
  .frm_form_field.frm_last_sixth{
749
  width:14.58%;
750
  }
751
 
752
  .frm_form_field.frm_seventh,
753
+ .frm_submit.frm_seventh,
754
  .frm_form_field.frm_first_seventh,
755
  .frm_form_field.frm_last_seventh{
756
  width:12.14%;
757
  }
758
 
759
  .frm_form_field.frm_eighth,
760
+ .frm_submit.frm_eighth,
761
  .frm_form_field.frm_first_eighth,
762
  .frm_form_field.frm_last_eighth{
763
  width:10.31%;
766
  .frm_form_field.frm_left_inline,
767
  .frm_form_field.frm_first_inline,
768
  .frm_form_field.frm_inline,
769
+ .frm_submit.frm_inline,
770
  .frm_form_field.frm_right_inline,
771
  .frm_form_field.frm_last_inline{
772
  width:auto;
1293
  margin:0 !important;
1294
  }
1295
 
1296
+ .with_frm_style.frm_login_form.frm_no_labels .login-username label,
1297
+ .with_frm_style.frm_login_form.frm_no_labels .login-password label{
1298
  display:none;
1299
  }
1300
 
1767
 
1768
  @media only screen and (max-width: 600px) {
1769
  .frm_form_field.frm_half,
1770
+ .frm_submit.frm_half,
1771
  .frm_form_field.frm_left_half,
1772
  .frm_form_field.frm_right_half,
1773
  .frm_form_field.frm_first_half,
1774
  .frm_form_field.frm_last_half,
1775
  .frm_form_field.frm_first_third,
1776
  .frm_form_field.frm_third,
1777
+ .frm_submit.frm_third,
1778
  .frm_form_field.frm_last_third,
1779
  .frm_form_field.frm_first_two_thirds,
1780
  .frm_form_field.frm_last_two_thirds,
1781
  .frm_form_field.frm_two_thirds,
1782
  .frm_form_field.frm_left_fourth,
1783
  .frm_form_field.frm_fourth,
1784
+ .frm_submit.frm_fourth,
1785
  .frm_form_field.frm_right_fourth,
1786
  .frm_form_field.frm_first_fourth,
1787
  .frm_form_field.frm_last_fourth,
1788
  .frm_form_field.frm_three_fourths,
1789
  .frm_form_field.frm_fifth,
1790
+ .frm_submit.frm_fifth,
1791
  .frm_form_field.frm_two_fifths,
1792
  .frm_form_field.frm_three_fifths,
1793
  .frm_form_field.frm_four_fifths,
1794
  .frm_form_field.frm_sixth,
1795
+ .frm_submit.frm_sixth,
1796
  .frm_form_field.frm_seventh,
1797
+ .frm_submit.frm_seventh,
1798
  .frm_form_field.frm_eighth,
1799
+ .frm_submit.frm_eighth,
1800
  .frm_form_field.frm_first_inline,
1801
  .frm_form_field.frm_inline,
1802
+ .frm_submit.frm_inline,
1803
  .frm_form_field.frm_last_inline{
1804
  width:100%;
1805
  margin-left:0;
css/frm_admin.css CHANGED
@@ -1383,7 +1383,7 @@ span.howto{display:inline;}
1383
  #frm_form_editor_container .ui-widget-content{display:none; padding:15px;}
1384
  #frm_form_editor_container .ui-widget-content label{float:left; width:170px; text-align:right; padding-right:5px; clear:both;}
1385
  #frm_form_editor_container .ui-widget-content label.nofloat{clear:none; float:none; margin-left:10px;}
1386
- #frm_form_editor_container .ui-state-default{color:#333;}
1387
  #frm_form_editor_container .ui-state-default a.frm_orange, #postbox-container-1 a.frm_orange{color:#D54E21;}
1388
 
1389
  #styling_settings input[type=checkbox], #styling_settings input[type=radio] {border:solid 1px #bbb;}
@@ -1415,12 +1415,14 @@ span.howto{display:inline;}
1415
  .frm_sorting > li.ui-state-default,
1416
  .frm_sorting .no_repeat_section li.ui-state-default.edit_field_type_end_divider:hover{
1417
  border:1px solid transparent;
1418
- font-weight:normal;
1419
  background-color:transparent;
1420
  background-image:none;
1421
  padding:5px;
1422
  margin:20px 0;
1423
  box-shadow:none;
 
 
1424
  }
1425
  .frm_sorting > li.ui-state-default.edit_field_type_form{
1426
  border:1px solid #d1e5ee;
@@ -1703,14 +1705,13 @@ table td.frm_left_label{
1703
  .frm_38_trigger .frm_sorting li.ui-state-default.frm_not_divider.selected,
1704
  .frm_sorting li.ui-state-default.selected.edit_field_type_divider .divider_section_only{
1705
  border:1px solid #e4f3ff;
1706
- background-color: #fbfdff;
1707
  }
1708
  .start_divider.frm_sorting li.ui-state-default.frm_not_divider.selected {
1709
  border:1px solid #E7E7E7;
1710
  background:#FDFDFD;
1711
  }
1712
 
1713
-
1714
  .frm_sorting li.ui-state-default.selected.edit_field_type_divider .divider_section_only .frm-show-hover{
1715
  visibility:visible !important;
1716
  display:inline !important;
1383
  #frm_form_editor_container .ui-widget-content{display:none; padding:15px;}
1384
  #frm_form_editor_container .ui-widget-content label{float:left; width:170px; text-align:right; padding-right:5px; clear:both;}
1385
  #frm_form_editor_container .ui-widget-content label.nofloat{clear:none; float:none; margin-left:10px;}
1386
+ #frm_form_editor_container .ui-state-default{color:#333 !important;}
1387
  #frm_form_editor_container .ui-state-default a.frm_orange, #postbox-container-1 a.frm_orange{color:#D54E21;}
1388
 
1389
  #styling_settings input[type=checkbox], #styling_settings input[type=radio] {border:solid 1px #bbb;}
1415
  .frm_sorting > li.ui-state-default,
1416
  .frm_sorting .no_repeat_section li.ui-state-default.edit_field_type_end_divider:hover{
1417
  border:1px solid transparent;
1418
+ font-weight:lighter !important;
1419
  background-color:transparent;
1420
  background-image:none;
1421
  padding:5px;
1422
  margin:20px 0;
1423
  box-shadow:none;
1424
+ display:block !important;
1425
+ text-align:inherit !important;
1426
  }
1427
  .frm_sorting > li.ui-state-default.edit_field_type_form{
1428
  border:1px solid #d1e5ee;
1705
  .frm_38_trigger .frm_sorting li.ui-state-default.frm_not_divider.selected,
1706
  .frm_sorting li.ui-state-default.selected.edit_field_type_divider .divider_section_only{
1707
  border:1px solid #e4f3ff;
1708
+ background-color: #fbfdff;
1709
  }
1710
  .start_divider.frm_sorting li.ui-state-default.frm_not_divider.selected {
1711
  border:1px solid #E7E7E7;
1712
  background:#FDFDFD;
1713
  }
1714
 
 
1715
  .frm_sorting li.ui-state-default.selected.edit_field_type_divider .divider_section_only .frm-show-hover{
1716
  visibility:visible !important;
1717
  display:inline !important;
formidable.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Formidable
4
  Description: Quickly and easily create drag-and-drop forms
5
- Version: 2.0.12
6
  Plugin URI: http://formidablepro.com/
7
  Author URI: http://strategy11.com
8
  Author: Strategy11
2
  /*
3
  Plugin Name: Formidable
4
  Description: Quickly and easily create drag-and-drop forms
5
+ Version: 2.0.13
6
  Plugin URI: http://formidablepro.com/
7
  Author URI: http://strategy11.com
8
  Author: Strategy11
js/formidable.js CHANGED
@@ -5,6 +5,7 @@ function frmFrontFormJS(){
5
  var hidden_fields = [];
6
  var frm_checked_dep = [];
7
  var addingRow = '';
 
8
  var action = '';
9
  var jsErrors = [];
10
 
@@ -130,7 +131,7 @@ function frmFrontFormJS(){
130
  reset = 'persist';
131
  }
132
 
133
- checkDependentField('und', field_id, null, jQuery(this), reset);
134
  doCalculation(field_id, jQuery(this));
135
  //validateField( field_id, this );
136
  }
@@ -144,11 +145,15 @@ function frmFrontFormJS(){
144
  fieldName = field.name;
145
  }
146
  var nameParts = fieldName.replace('item_meta[', '').replace('[]', '').split(']');
 
 
 
147
  nameParts = nameParts.filter(function(n){ return n !== ''; });
 
148
  var field_id = nameParts[0];
149
  var isRepeating = false;
150
 
151
- if ( nameParts.length === 1 ) {
152
  return field_id;
153
  }
154
 
@@ -178,7 +183,19 @@ function frmFrontFormJS(){
178
  return field_id;
179
  }
180
 
181
- function checkDependentField(selected, field_id, rec, parentField, reset){
 
 
 
 
 
 
 
 
 
 
 
 
182
  var rules = getRulesForField( field_id );
183
  if ( typeof rules === 'undefined' ) {
184
  return;
@@ -194,14 +211,16 @@ function frmFrontFormJS(){
194
  hidden_fields = [];
195
  }
196
 
197
- var isRepeat = maybeSetRowId( parentField );
198
 
199
  var len = rules.length;
200
  for ( var i = 0, l = len; i < l; i++ ) {
201
  if ( rules[i].FieldName === field_id ) {
202
- hideOrShowField(i, rules[i], field_id, selected, rec, parentField);
 
203
  } else {
204
- hideOrShowField(i, rules[i], field_id, selected, rec);
 
205
  }
206
 
207
  if ( i === ( len - 1 ) ) {
@@ -213,18 +232,17 @@ function frmFrontFormJS(){
213
  }
214
  }
215
 
216
- function maybeSetRowId( parentField ) {
 
 
 
217
  var isRepeat = false;
218
- if ( addingRow === '' && typeof parentField !== 'undefined' && parentField !== null ) {
219
- if ( parentField.length > 1 ) {
220
- parentField = parentField.eq(0);
221
- }
222
- isRepeat = parentField.closest('.frm_repeat_sec, .frm_repeat_inline, .frm_repeat_grid');
223
- if ( typeof isRepeat !== 'undefined' ) {
224
- addingRow = isRepeat.attr('id');
225
  isRepeat = true;
226
- } else {
227
- isRepeat = false;
228
  }
229
  }
230
  return isRepeat;
@@ -256,285 +274,290 @@ function frmFrontFormJS(){
256
  return this_opts;
257
  }
258
 
259
- /**
260
- * Track whether fields should hide or show in show_fields variable
261
- */
262
- function hideOrShowField(i, f, triggerFieldId, selected, rec, parentField){
263
  // Instantiate variables
264
- f.inputName = 'item_meta['+ f.FieldName +']';
265
- f.hiddenName = 'item_meta['+ f.HideField +']';
266
- f.containerID = 'frm_field_'+ f.FieldName +'_container';
267
- f.hideContainerID = 'frm_field_'+ f.HideField +'_container';
268
- f.hideBy = '#';
269
- var getRepeat = false;
270
-
271
- if ( typeof parentField !== 'undefined' && parentField !== null ) {
272
- parentField = maybeGetFirstElement( parentField );
273
-
274
- if ( typeof parentField.attr('name') === 'undefined' ) {
275
- return;
276
- }
277
 
278
- updateObjectForRepeatingSection( parentField, f );
279
- } else {
280
- getRepeat = true;
281
- parentField = jQuery('input[name^="'+ f.inputName +'"], textarea[name^="'+ f.inputName +'"], select[name^="'+ f.inputName +'"]');
282
 
283
- // If in repeating section
284
- if ( parentField.length < 1 ) {
285
- checkRepeatingFields( i, f, triggerFieldId, selected, rec );
286
  return;
287
  }
288
-
289
- parentField = maybeGetFirstElement( parentField );
290
  }
291
 
292
- setEmptyKeyInArray(f);
293
-
294
- maybeUpdateHideBy( f );
295
 
296
- selected = getEnteredValue( i, f, triggerFieldId, selected, rec, parentField, getRepeat );
297
- if ( selected === false ) {
 
298
  return;
299
  }
300
 
301
- updateShowFields( i, f, selected );
 
 
 
 
302
 
303
- adjustShowFieldsForRepeat(f, i);
 
 
 
 
 
 
 
 
 
304
 
305
- hideFieldNow(i, f, rec);
306
- }
307
 
308
- function maybeGetFirstElement( parentField ) {
309
- if ( parentField.length > 1 ) {
310
- parentField = parentField.eq(0);
311
- }
312
- return parentField;
313
  }
314
 
315
- function updateObjectForRepeatingSection( parentField, f ) {
316
- var container = parentField.closest('.frm_repeat_sec, .frm_repeat_inline, .frm_repeat_grid');
317
- if ( container.length ) {
318
- var repeatInput = container.find('.frm_field_'+ f.FieldName +'_container');
319
- f.containerID = repeatInput.attr('id');
320
- f.hideContainerID = f.containerID.replace(f.FieldName, f.HideField);
321
- f.hiddenName = f.inputName.replace('['+ f.FieldName +']', '['+ f.HideField +']');
322
- }
323
- }
324
 
325
- /**
326
- * If field in logic is repeating, loop through each repeating field
327
- */
328
- function checkRepeatingFields( i, f, triggerFieldId, selected, rec ) {
329
- // Get class for repeating field
330
- var repeatingFieldClass = '.'+ f.containerID;
331
- if ( addingRow !== '' && addingRow != undefined ) {
332
- repeatingFieldClass = '#' + addingRow +' '+ repeatingFieldClass;
333
- }
334
-
335
- // Get all repeating field divs
336
- var repeatingFieldDivs = jQuery(repeatingFieldClass);
337
- if ( repeatingFieldDivs.length ) {
338
- var repeatingFields = repeatingFieldDivs.find('input, textarea, select');
339
-
340
- // If non-hidden fields exist in the repeating field divs
341
- if ( repeatingFields.length ) {
342
- if ( addingRow === '' || addingRow === undefined ) {
343
- var lastId = '';
344
-
345
- // Loop through each input/select/textarea in repeating fields
346
- repeatingFields.each(function(){
347
- var thisId = jQuery(this).closest('.frm_form_field').attr('id');
348
- if ( thisId != lastId ) { // don't trigger radio/checkbox multiple times
349
- hideOrShowField(i, f, f.FieldName, selected, rec, jQuery(this));
350
- }
351
- lastId = thisId;
352
- });
353
- } else {
354
- hideOrShowField(i, f, triggerFieldId, selected, rec, repeatingFields);
355
- }
356
- } else {
357
- setEmptyKeyInArray(f);
358
- show_fields[f.hideContainerID][i] = false;
359
- hideFieldNow(i, f, rec);
360
- }
361
- }
362
- }
363
 
364
- /**
365
- * Check if only the dependent field is in a repeating section
366
- */
367
- function maybeUpdateHideBy( f ) {
368
- var hideContainer = document.getElementById(f.hideContainerID);
369
- if ( hideContainer === null ) {
370
- // it is a repeating section, use the class
371
- f.hideBy = '.';
372
  }
373
- }
374
 
375
- /**
376
- * Get the entered/selected value in the current field
377
- */
378
- function getEnteredValue( i, f, triggerFieldId, selected, rec, parentField, getRepeat ) {
379
- if ( f.FieldName !== triggerFieldId || typeof selected === 'undefined' || selected === 'und' ) {
380
- if ( ( f.Type === 'radio' || f.Type === 'data-radio' ) && parentField.attr('type') === 'radio' ) {
381
- selected = jQuery('input[name="'+ f.inputName +'"]:checked').val();
382
- if ( typeof selected === 'undefined' ) {
383
- selected = '';
384
- }
385
- } else if ( f.Type === 'select' || f.Type === 'time' || f.Type === 'data-select' || ( f.Type !== 'checkbox' && f.Type !== 'data-checkbox' ) ) {
386
- selected = parentField.val();
387
- }
388
- }
389
 
390
- if ( typeof selected === 'undefined' ) {
391
- if ( parentField.length === 0 ) {
392
- return false; // the parent field is currently getting processed
393
- }
394
- selected = parentField.val();
395
  }
 
396
 
397
- if ( typeof selected === 'undefined' ) {
398
- // check for repeating/embedded field
399
- if ( getRepeat === true ) {
400
- var repeat = jQuery('.'+ f.containerID +' input, .'+ f.containerID +' select, .'+ f.containerID +' textarea');
401
- if ( repeat.length ) {
402
- repeat.each(function(){
403
- hideOrShowField(i, f, f.FieldName, selected, rec, jQuery(this));
404
- });
405
- return false;
406
- }
407
- }
408
- selected = '';
409
- }
410
 
411
- // get selected checkbox values
412
- var checkVals = [];
413
  if ( f.Type === 'checkbox' || f.Type === 'data-checkbox' ) {
414
- checkVals = getCheckedVal(f.containerID, f.inputName);
415
 
416
  if ( checkVals.length ) {
417
- selected = checkVals;
418
  }else{
419
- selected = '';
420
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
421
  }
422
 
423
- return selected;
424
  }
425
 
426
- /**
427
- * Add values to the show_fields array
428
- */
429
- function updateShowFields( i, f, selected ) {
430
- if ( selected === null || selected === '' || selected.length < 1 ) {
431
- show_fields[f.hideContainerID][i] = false;
 
 
 
 
432
  } else {
433
- show_fields[f.hideContainerID][i] = {'funcName':'getDataOpts', 'f':f, 'sel':selected};
434
  }
435
 
436
- if ( f.Type === 'checkbox' || (f.Type === 'data-checkbox' && typeof f.LinkedField === 'undefined') ) {
437
- show_fields[f.hideContainerID][i] = false;
438
 
439
- var match = false;
440
- if ( selected !== '') {
441
- if ( f.Condition === '!=' ) {
442
- show_fields[f.hideContainerID][i] = true;
443
- }
444
- for ( var b = 0; b<selected.length; b++ ) {
445
- match = operators(f.Condition, f.Value, selected[b]);
446
- if ( f.Condition === '!=' ) {
447
- if ( show_fields[f.hideContainerID][i] === true && match === false ) {
448
- show_fields[f.hideContainerID][i] = false;
449
- }
450
- } else if(show_fields[f.hideContainerID][i] === false && match){
451
- show_fields[f.hideContainerID][i] = true;
452
- }
453
- }
454
  } else {
455
- match = operators(f.Condition, f.Value, '');
456
- if(show_fields[f.hideContainerID][i] === false && match){
457
- show_fields[f.hideContainerID][i] = true;
458
- }
459
  }
460
- } else if ( typeof f.LinkedField !== 'undefined' && f.Type.indexOf('data-') === 0 ) {
461
- if ( typeof f.DataType === 'undefined' || f.DataType === 'data' ) {
462
- if ( selected === '' ) {
463
- hideAndClearDynamicField( f.hideContainerID, f.hideBy, f.HideField, 'hide' );
464
- } else if ( f.Type === 'data-radio' ) {
465
- if ( typeof f.DataType === 'undefined' ) {
466
- show_fields[f.hideContainerID][i] = operators(f.Condition, f.Value, selected);
467
- } else {
468
- show_fields[f.hideContainerID][i] = {'funcName':'getData','f':f,'sel':selected};
 
 
 
 
 
 
 
 
 
 
 
469
  }
470
- } else if ( f.Type === 'data-checkbox' || ( f.Type === 'data-select' && isNotEmptyArray( selected ) ) ) {
471
- hideAndClearDynamicField( f.hideContainerID, f.hideBy, f.HideField, 'show' );
472
- show_fields[f.hideContainerID][i] = true;
473
- getData(f, selected, 1);
474
- } else if ( f.Type === 'data-select' ) {
475
- show_fields[f.hideContainerID][i] = {'funcName':'getData','f':f,'sel':selected};
476
  }
477
  }
478
- }else if ( typeof f.Value === 'undefined' && f.Type.indexOf('data') === 0 ) {
479
- if ( selected === '' ) {
480
- f.Value = '1';
481
- } else {
482
- f.Value = selected;
483
  }
484
- show_fields[f.hideContainerID][i] = operators(f.Condition, f.Value, selected);
485
- f.Value = undefined;
486
- }else{
487
- show_fields[f.hideContainerID][i] = operators(f.Condition, f.Value, selected);
488
  }
489
  }
490
 
491
- function setEmptyKeyInArray(f) {
492
- if ( typeof show_fields[f.hideContainerID] === 'undefined' ) {
493
- show_fields[f.hideContainerID] = [];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
494
  }
495
  }
496
 
497
- /**
498
- * If a dependent field is in a repeating section, adjust the show_fields array so it includes every repeating field individually
499
- */
500
- function adjustShowFieldsForRepeat(f, i){
501
- var hideFieldRepeatContainer = jQuery( '.' + f.hideContainerID ).closest('.frm_repeat_sec, .frm_repeat_inline, .frm_repeat_grid');
502
-
503
- if ( hideFieldRepeatContainer.length ) {
504
- //f.hideContainerID is in repeating section
505
- var result = show_fields[f.hideContainerID][i];
506
- delete show_fields[f.hideContainerID];
507
-
508
- var fCopy = f;
509
- var originalId = f.hideContainerID;
510
- var repeatId;
511
- jQuery.each(hideFieldRepeatContainer, function(key,val){
512
- repeatId = '-' + val.id.replace( 'frm_section_', '' ) + '_container';
513
- repeatId = originalId.replace( '_container', repeatId );
514
- fCopy.hideContainerID = repeatId;
515
-
516
- setEmptyKeyInArray(fCopy);
517
- show_fields[repeatId][i] = result;
518
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
519
  }
520
  }
521
 
522
- function hideAndClearDynamicField(hideContainer, hideBy, field_id, hide){
523
- if ( jQuery.inArray(hideContainer, hidden_fields) === -1 ) {
524
- hidden_fields[ field_id ] = hideContainer;
525
- if(hideBy === '.'){
526
- hideContainer = jQuery('.'+hideContainer);
527
- }else{
528
- hideContainer = jQuery(document.getElementById(hideContainer));
 
 
 
 
 
 
 
 
 
529
  }
530
- if ( hide === 'hide' ) {
531
- hideContainer.hide();
 
 
 
 
 
 
 
532
  }
533
- hideContainer.find('.frm_data_field_container').empty();
 
 
 
 
 
 
 
 
 
 
 
 
534
  }
535
- }
 
536
 
537
- function hideAndClearField( container, f ) {
538
  container.hide();
539
  if ( jQuery.inArray(container.attr('id'), hidden_fields) === -1 ) {
540
  var field_id = f.HideField;
@@ -542,43 +565,91 @@ function frmFrontFormJS(){
542
 
543
  var inputs = getInputsInContainer( container );
544
  if ( inputs.length ){
545
- inputs.prop('checked', false).prop('selectedIndex', 0);
546
- inputs.not(':checkbox, :radio, select').val('');
547
- var i = false;
548
- inputs.each(function(){
549
- if ( this.tagName == 'SELECT' ) {
550
- var autocomplete = document.getElementById( this.id + '_chosen' );
551
- if ( autocomplete !== null ) {
552
- jQuery(this).trigger('chosen:updated');
553
- }
554
- }
555
 
556
- if ( i === false || ["checkbox","radio"].indexOf( this.type ) < 0 ) {
557
- triggerChange( jQuery(this) );
558
- }
559
- i = true;
560
- });
 
 
 
 
 
 
 
 
 
561
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
562
  }
563
  }
564
 
565
- function getInputsInContainer( container ) {
566
- return container.find('select[name^="item_meta"], textarea[name^="item_meta"], input[name^="item_meta"]:not([type=hidden])');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
567
  }
568
 
569
  function showFieldAndSetValue( container, f ) {
570
  var inputs = getInputsInContainer( container );
571
- setDefaultValue( inputs );
572
 
573
- if ( inputs.length > 1 ) {
 
 
 
 
 
 
574
  for ( var i = 0; i < inputs.length; i++ ) {
575
- doCalcForSingleField( f.HideField, jQuery( inputs[i] ) );
 
576
  }
577
- } else {
578
- doCalcForSingleField( f.HideField, inputs );
579
  }
580
-
581
- container.show();
582
  }
583
 
584
  function setDefaultValue( input ) {
@@ -610,6 +681,25 @@ function frmFrontFormJS(){
610
  }
611
  }
612
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
613
  function triggerChange( input, fieldKey ) {
614
  if ( typeof fieldKey === 'undefined' ) {
615
  fieldKey = 'dependent';
@@ -622,72 +712,6 @@ function frmFrontFormJS(){
622
  input.trigger({ type:'change', selfTriggered:true, frmTriggered:fieldKey });
623
  }
624
 
625
- function hideFieldNow(i, f, rec){
626
- if ( f.MatchType === 'all' || show_fields[f.hideContainerID][i] === false ) {
627
- hide_later.push({
628
- 'result':show_fields[f.hideContainerID][i], 'show':f.Show,
629
- 'match':f.MatchType, 'FieldName':f.FieldName, 'HideField':f.HideField,
630
- 'hideContainerID':f.hideContainerID, 'hideBy':f.hideBy
631
- });
632
- return;
633
- }
634
-
635
- var display = 'none';
636
- if ( f.Show === 'show' ) {
637
- if ( show_fields[f.hideContainerID][i] !== true ) {
638
- showField(show_fields[f.hideContainerID][i], f.FieldName, rec);
639
- return;
640
- }
641
- display = '';
642
- }
643
-
644
- var hideClass;
645
- if(f.hideBy === '.'){
646
- hideClass = jQuery('.'+f.hideContainerID);
647
- }else{
648
- hideClass = jQuery( document.getElementById(f.hideContainerID) );
649
- }
650
-
651
- if(hideClass.length){
652
- if ( display === 'none' ) {
653
- hideAndClearField( hideClass, f );
654
- } else {
655
- showFieldAndSetValue( hideClass, f );
656
- }
657
- }
658
- }
659
-
660
- function hideFieldLater(rec){
661
- jQuery.each(hide_later, function(hkey,hvalue){
662
- delete hide_later[hkey];
663
- if ( typeof hvalue === 'undefined' || typeof hvalue.result === 'undefined' ) {
664
- return;
665
- }
666
-
667
- var container = jQuery(hvalue.hideBy + hvalue.hideContainerID);
668
- var hideField = hvalue.show;
669
- if ( container.length ) {
670
- if ( ( hvalue.match === 'any' && (jQuery.inArray(true, show_fields[hvalue.hideContainerID]) === -1) ) ||
671
- ( hvalue.match === 'all' && (jQuery.inArray(false, show_fields[hvalue.hideContainerID]) > -1) ) ) {
672
- if ( hvalue.show === 'show' ) {
673
- hideField = 'hide';
674
- } else {
675
- hideField = 'show';
676
- }
677
- }
678
-
679
- if ( hideField === 'show' ) {
680
- showFieldAndSetValue( container, hvalue );
681
- if ( typeof hvalue.result !== false && typeof hvalue.result !== true ) {
682
- showField( hvalue.result, hvalue.FieldName, rec );
683
- }
684
- } else {
685
- hideAndClearField(container, hvalue);
686
- }
687
- }
688
- });
689
- }
690
-
691
  function operators(op, a, b){
692
  if ( typeof b === 'undefined' ) {
693
  b = '';
@@ -780,28 +804,19 @@ function frmFrontFormJS(){
780
  return;
781
  }
782
 
783
- var hiddenInput = jQuery('input[name^="'+ f.hiddenName +'"], select[name^="'+ f.hiddenName +'"]:not(":disabled"), textarea[name^="'+ f.hiddenName +'"]');
784
 
785
- var prev = [];
786
- hiddenInput.each(function(){
787
- if ( this.type === 'radio' || this.type === 'checkbox' ) {
788
- if ( this.checked === true ) {
789
- prev.push(jQuery(this).val());
790
- }
791
- } else {
792
- prev.push(jQuery(this).val());
793
- }
794
- });
795
 
796
  if(f.DataType == 'select'){
797
  if((rec == 'stop' || jQuery('#'+ f.hideContainerID +' .frm-loading-img').length) && (jQuery.inArray(f.HideField, frm_checked_dep) > -1)){
798
  return;
799
  }
800
  }
801
-
802
- if(prev.length === 0){
803
- prev = '';
804
- }
805
 
806
  frm_checked_dep.push(f.HideField);
807
 
@@ -809,7 +824,7 @@ function frmFrontFormJS(){
809
  //don't get values for fields that are to remain hidden on the page
810
  var $dataField = jQuery(fcont).find('.frm_data_field_container');
811
  if($dataField.length === 0 && hiddenInput.length ){
812
- checkDependentField(prev, f.HideField, 'stop', hiddenInput);
813
  return false;
814
  }
815
 
@@ -818,7 +833,7 @@ function frmFrontFormJS(){
818
  if ( !match ) {
819
  fcont.style.display = 'none';
820
  $dataField.html('');
821
- checkDependentField('', f.HideField, 'stop', hiddenInput);
822
  return false;
823
  }
824
  }
@@ -835,7 +850,7 @@ function frmFrontFormJS(){
835
  data:{
836
  action:'frm_fields_ajax_data_options', hide_field:field_id,
837
  entry_id:selected, selected_field_id:f.LinkedField, field_id:f.HideField,
838
- hide_id:f.hideContainerID, nonce:frm_js.nonce
839
  },
840
  success:function(html){
841
  $dataField.html(html);
@@ -852,36 +867,41 @@ function frmFrontFormJS(){
852
  fcont.style.display = '';
853
  }
854
 
855
- if(html !== '' && prev !== ''){
856
- if(!jQuery.isArray(prev)){
857
- var new_prev = [];
858
- new_prev.push(prev);
859
- prev = new_prev;
860
- }
 
861
 
862
- //select options that were selected previously
863
- jQuery.each(prev, function(ckey,cval){
864
- if ( typeof(cval) === 'undefined' || cval === '' ) {
865
- return;
866
- }
867
- if ( dataType == 'checkbox' || dataType == 'radio' ) {
868
- if ( parentField.length > 1 ) {
869
- parentField.filter('[value="' + cval+ '"]').attr('checked','checked');
870
- } else if ( parentField.val() == cval ){
871
- parentField.attr('checked','checked');
872
- }
873
- } else if ( dataType == 'select' ) {
874
- var selOpt = parentField.children('option[value="'+ cval +'"]');
875
- if(selOpt.length){
876
- selOpt.prop('selected', true);
 
 
 
 
877
  }else{
878
- //remove options that no longer exist
879
- prev.splice(ckey, 1);
880
  }
881
- }else{
882
- parentField.val(cval);
883
- }
884
- });
 
885
  }
886
 
887
  if(parentField.hasClass('frm_chzn') && jQuery().chosen){
@@ -893,6 +913,29 @@ function frmFrontFormJS(){
893
  });
894
  }
895
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
896
  function doCalculation(field_id, triggerField){
897
  if ( typeof __FRMCALC === 'undefined' ) {
898
  // there are no calculations on this page
@@ -914,7 +957,7 @@ function frmFrontFormJS(){
914
  for ( var i = 0, l = len; i < l; i++ ) {
915
 
916
  // Stop calculation if total field is conditionally hidden
917
- if ( fieldIsConditionallyHidden( all_calcs, triggerField, keys[i] ) ) {
918
  continue;
919
  }
920
 
@@ -923,37 +966,46 @@ function frmFrontFormJS(){
923
  }
924
 
925
  /**
926
- * If field is hidden with conditional logic, don't do the calc
927
  */
928
- function fieldIsConditionallyHidden( all_calcs, triggerField, field_key ) {
929
- var totalFieldId = all_calcs.calc[ field_key ].field_id;
930
- var t = document.getElementById( 'frm_field_' + totalFieldId + '_container' );
931
- if ( t !== null ) {
932
- if ( t.offsetHeight === 0 ) {
933
- // Conditionally hidden field
934
- return true;
935
- } else {
936
- // Regular, visible field
937
- return false;
938
- }
939
- }
940
-
941
- // Check if we're dealing with a conditionally hidden repeating field
942
- var container = triggerField.closest('.frm_repeat_sec, .frm_repeat_inline, .frm_repeat_grid');
943
- if ( container.length ) {
944
- var idPart = container[0].id.replace( 'frm_section_', '' );
945
- var totalField = document.getElementById( 'frm_field_' + totalFieldId + '-' + idPart + '_container' );
946
- if ( totalField !== null && totalField.offsetHeight === 0 ) {
947
- // Conditionally hidden field (repeating)
948
- return true;
949
- } else {
950
- // Regular, visible field or hidden field (repeating)
951
- return false;
952
- }
953
  } else {
954
- // Hidden field
955
  return false;
956
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
957
  }
958
 
959
  function doSingleCalculation( all_calcs, field_key, vals, triggerField ) {
@@ -1037,15 +1089,18 @@ function frmFrontFormJS(){
1037
  return field;
1038
  }
1039
 
1040
- function doCalcForSingleField( field_id, triggerField ) {
1041
  if ( typeof __FRMCALC === 'undefined' ) {
1042
  // there are no calculations on this page
1043
  return;
1044
  }
 
1045
  var all_calcs = __FRMCALC;
1046
- var field_key = all_calcs.fieldsWithCalc[ field_id ];
1047
- if ( typeof field_key === 'undefined' ) {
1048
- // this field has no calculation
 
 
1049
  return;
1050
  }
1051
 
@@ -1053,6 +1108,30 @@ function frmFrontFormJS(){
1053
  doSingleCalculation( all_calcs, field_key, vals, triggerField );
1054
  }
1055
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1056
  function getCalcFieldId( field, all_calcs, vals ) {
1057
  if ( typeof vals[field.valKey] !== 'undefined' && vals[field.valKey] !== 0 ) {
1058
  return vals;
@@ -1078,7 +1157,7 @@ function frmFrontFormJS(){
1078
  var thisVal = getOptionValue( field.thisField, this );
1079
 
1080
  if ( field.thisField.type == 'date' ) {
1081
- var d = jQuery.datepicker.parseDate(all_calcs.date, thisVal);
1082
  if ( d !== null ) {
1083
  vals[field.valKey] = Math.ceil(d/(1000*60*60*24));
1084
  }
@@ -1101,6 +1180,62 @@ function frmFrontFormJS(){
1101
  return vals;
1102
  }
1103
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1104
  function getSiblingField( field ) {
1105
  if ( typeof field.triggerField === 'undefined' ) {
1106
  return null;
@@ -1560,7 +1695,7 @@ function frmFrontFormJS(){
1560
 
1561
  if ( showDelete ) {
1562
  if ( typeof entry.deleteLink !== 'undefined' ) {
1563
- data.setCell(row, col,'<a href="'+ entry.deleteLink +'" class="frm_delete_link" onclick="return confirm('+ opts.options.confirm +')">'+ opts.options.delete_link +'</a>');
1564
  } else {
1565
  data.setCell(row, col, '');
1566
  }
@@ -1739,6 +1874,15 @@ function frmFrontFormJS(){
1739
 
1740
  function addRow(){
1741
  /*jshint validthis:true */
 
 
 
 
 
 
 
 
 
1742
  var id = jQuery(this).data('parent');
1743
  var i = 0;
1744
  if ( jQuery('.frm_repeat_'+id).length > 0 ) {
@@ -1758,7 +1902,7 @@ function frmFrontFormJS(){
1758
  jQuery('.frm_repeat_'+ id +':last').after(item);
1759
 
1760
  var checked = ['other'];
1761
- var fieldID;
1762
  var reset = 'reset';
1763
  addingRow = item.attr('id');
1764
 
@@ -1767,9 +1911,10 @@ function frmFrontFormJS(){
1767
  if ( this.type != 'file' ) {
1768
  fieldID = this.name.replace('item_meta[', '').split(']')[2].replace('[', '');
1769
  if ( jQuery.inArray(fieldID, checked ) == -1 ) {
 
1770
  checked.push(fieldID);
1771
- checkDependentField('und', fieldID, null, jQuery(this), reset);
1772
- doCalculation(fieldID, jQuery(this));
1773
  reset = 'persist';
1774
  }
1775
  }
@@ -1781,7 +1926,7 @@ function frmFrontFormJS(){
1781
  for ( var f = 0, l = checkLen; f < l; f++ ) {
1782
  if ( jQuery.inArray(r.logic.check[f], checked ) == -1 ) {
1783
  if(jQuery(html).find('.frm_field_'+r.logic.check[f]+'_container').length < 1){
1784
- checkDependentField('und', r.logic.check[f], null, null, reset);
1785
  reset = 'persist';
1786
  }
1787
  }
@@ -1802,10 +1947,87 @@ function frmFrontFormJS(){
1802
  if(typeof(frmThemeOverride_frmAddRow) == 'function'){
1803
  frmThemeOverride_frmAddRow(id, r);
1804
  }
 
 
 
 
 
1805
  }
1806
  });
1807
 
 
 
1808
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1809
  return false;
1810
  }
1811
 
@@ -1816,6 +2038,12 @@ function frmFrontFormJS(){
1816
  });
1817
  }
1818
 
 
 
 
 
 
 
1819
  function toggleDiv(){
1820
  /*jshint validthis:true */
1821
  var div=jQuery(this).data('frmtoggle');
@@ -1854,6 +2082,158 @@ function frmFrontFormJS(){
1854
  return !jQuery.isArray( obj ) && (obj - parseFloat( obj ) + 1) >= 0;
1855
  }
1856
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1857
  /* Get checked values with IE8 fallback */
1858
  function getCheckedVal(containerID, inputName) {
1859
  var checkVals = [];
@@ -1917,8 +2297,14 @@ function frmFrontFormJS(){
1917
  jQuery(document).on('click', '.frm_remove_form_row', removeRow);
1918
  jQuery(document).on('click', '.frm_add_form_row', addRow);
1919
 
 
1920
  jQuery('a[data-frmtoggle]').click(toggleDiv);
1921
 
 
 
 
 
 
1922
  // toggle collapsible entries shortcode
1923
  jQuery('.frm_month_heading, .frm_year_heading').click( function(){
1924
  var content = jQuery(this).children('.ui-icon-triangle-1-e, .ui-icon-triangle-1-s');
@@ -1930,6 +2316,12 @@ function frmFrontFormJS(){
1930
  jQuery(this).next('.frm_toggle_container').hide();
1931
  }
1932
  });
 
 
 
 
 
 
1933
  },
1934
 
1935
  submitForm: function(e){
@@ -2028,7 +2420,7 @@ function frmFrontFormJS(){
2028
  var len = ids.length;
2029
  var reset = 'reset';
2030
  for ( var i = 0, l = len; i < l; i++ ) {
2031
- checkDependentField('und', ids[i], null, null, reset);
2032
  reset = 'persist';
2033
  }
2034
  },
@@ -2095,7 +2487,23 @@ jQuery(document).ready(function($){
2095
  frmFrontForm.init();
2096
  });
2097
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2098
  function frmEditEntry(entry_id,prefix,post_id,form_id,cancel,hclass){
 
2099
  var $edit = jQuery(document.getElementById('frm_edit_'+entry_id));
2100
  var label = $edit.html();
2101
  var $cont = jQuery(document.getElementById(prefix+entry_id));
@@ -2112,6 +2520,7 @@ function frmEditEntry(entry_id,prefix,post_id,form_id,cancel,hclass){
2112
  }
2113
 
2114
  function frmCancelEdit(entry_id,prefix,label,post_id,form_id,hclass){
 
2115
  var $edit = jQuery(document.getElementById('frm_edit_'+entry_id));
2116
  var $link = $edit.find('a');
2117
  var cancel = $link.html();
@@ -2124,22 +2533,8 @@ function frmCancelEdit(entry_id,prefix,label,post_id,form_id,hclass){
2124
  $edit.replaceWith('<a id="frm_edit_'+entry_id+'" class="frm_edit_link '+hclass+'" href="javascript:frmEditEntry('+entry_id+',\''+prefix+'\','+post_id+','+form_id+',\''+ frmFrontForm.escapeHtml(cancel) +'\',\''+hclass+'\')">'+label+'</a>');
2125
  }
2126
 
2127
- function frmUpdateField(entry_id,field_id,value,message,num){
2128
- jQuery(document.getElementById('frm_update_field_'+entry_id+'_'+field_id)).html('<span class="frm-loading-img"></span>');
2129
- jQuery.ajax({
2130
- type:'POST',url:frm_js.ajax_url,
2131
- data:{action:'frm_entries_update_field_ajax', entry_id:entry_id, field_id:field_id, value:value, nonce:frm_js.nonce},
2132
- success:function(){
2133
- if(message.replace(/^\s+|\s+$/g,'') === ''){
2134
- jQuery(document.getElementById('frm_update_field_'+entry_id+'_'+field_id+'_'+num)).fadeOut('slow');
2135
- }else{
2136
- jQuery(document.getElementById('frm_update_field_'+entry_id+'_'+field_id+'_'+num)).replaceWith(message);
2137
- }
2138
- }
2139
- });
2140
- }
2141
-
2142
- function frmDeleteEntry(entry_id,prefix){
2143
  jQuery(document.getElementById('frm_delete_'+entry_id)).replaceWith('<span class="frm-loading-img" id="frm_delete_'+entry_id+'"></span>');
2144
  jQuery.ajax({
2145
  type:'POST',url:frm_js.ajax_url,
5
  var hidden_fields = [];
6
  var frm_checked_dep = [];
7
  var addingRow = '';
8
+ var currentlyAddingRow = false;
9
  var action = '';
10
  var jsErrors = [];
11
 
131
  reset = 'persist';
132
  }
133
 
134
+ checkDependentField(field_id, null, jQuery(this), reset);
135
  doCalculation(field_id, jQuery(this));
136
  //validateField( field_id, this );
137
  }
145
  fieldName = field.name;
146
  }
147
  var nameParts = fieldName.replace('item_meta[', '').replace('[]', '').split(']');
148
+ if ( nameParts.length < 1 ) {
149
+ return 0;
150
+ }
151
  nameParts = nameParts.filter(function(n){ return n !== ''; });
152
+
153
  var field_id = nameParts[0];
154
  var isRepeating = false;
155
 
156
+ if ( nameParts.length === 1 || nameParts[1] == '[form' ) {
157
  return field_id;
158
  }
159
 
183
  return field_id;
184
  }
185
 
186
+
187
+ /* Conditional Logic Functions */
188
+
189
+ /**
190
+ *
191
+ * Check all the logic on each field that has conditional logic dependent on a given field ID
192
+ *
193
+ * field_id = the field ID that is triggering the changes
194
+ * rec = null or go (maybe remove this variable)
195
+ * changedInput = the input that changed or null on initial page load
196
+ * reset = reset or persist
197
+ */
198
+ function checkDependentField(field_id, rec, changedInput, reset){
199
  var rules = getRulesForField( field_id );
200
  if ( typeof rules === 'undefined' ) {
201
  return;
211
  hidden_fields = [];
212
  }
213
 
214
+ var isRepeat = maybeSetRowId( changedInput );
215
 
216
  var len = rules.length;
217
  for ( var i = 0, l = len; i < l; i++ ) {
218
  if ( rules[i].FieldName === field_id ) {
219
+ // Field in logic is the same field that triggered the change
220
+ hideOrShowField(i, rules[i], rec, changedInput);
221
  } else {
222
+ // Field in logic is different from the field that triggered the change
223
+ hideOrShowField(i, rules[i], rec);
224
  }
225
 
226
  if ( i === ( len - 1 ) ) {
232
  }
233
  }
234
 
235
+ /*
236
+ * Check if changed field is a repeating field. If so, set addingRow to the HTML id of the repeating section div
237
+ */
238
+ function maybeSetRowId( changedInput ) {
239
  var isRepeat = false;
240
+ if ( addingRow === '' && typeof changedInput !== 'undefined' && changedInput !== null ) {
241
+ changedInput = maybeGetFirstElement( changedInput );
242
+ var repeatSecObj = changedInput.closest('.frm_repeat_sec, .frm_repeat_inline, .frm_repeat_grid');
243
+ if ( typeof repeatSecObj !== 'undefined' && typeof repeatSecObj.attr('id') !== 'undefined' ) {
244
+ addingRow = repeatSecObj.attr('id');
 
 
245
  isRepeat = true;
 
 
246
  }
247
  }
248
  return isRepeat;
274
  return this_opts;
275
  }
276
 
277
+ // Hide or show a field with conditional logic
278
+ // Track whether fields should hide or show in show_fields variable
279
+ function hideOrShowField(i, logicRules, rec, changedInput){
 
280
  // Instantiate variables
281
+ logicRules.inputName = 'item_meta['+ logicRules.FieldName +']';
282
+ logicRules.hiddenName = 'item_meta['+ logicRules.HideField +']';
283
+ logicRules.containerID = 'frm_field_'+ logicRules.FieldName +'_container';
284
+ logicRules.hideContainerID = 'frm_field_'+ logicRules.HideField +'_container';
285
+
286
+ // If the trigger field is a repeating field, only check single row of repeating section
287
+ if ( addingRow !== '' ) {
288
+ checkRepeatingFieldInSingleRow( i, logicRules, rec, addingRow );
289
+ return;
290
+ }
 
 
 
291
 
292
+ // Conditional logic is being checked on initial page load or the logic field being checked isn't the field that changed
293
+ if ( typeof changedInput === 'undefined' || changedInput === null ) {
294
+ changedInput = jQuery('input[name^="'+ logicRules.inputName +'"], textarea[name^="'+ logicRules.inputName +'"], select[name^="'+ logicRules.inputName +'"]');
 
295
 
296
+ // Current logic field is repeating (which means hide/show field is repeating as well)
297
+ if ( changedInput.length < 1 ) {
298
+ checkLogicForTwoRepeatingFields( i, logicRules, rec );
299
  return;
300
  }
 
 
301
  }
302
 
303
+ // Get the value from the logic field (not repeating)
304
+ var fieldValue = getBasicEnteredValue( logicRules );
 
305
 
306
+ // If field to hide/show is a repeating field and the logic field is not repeating, loop through each one of the repeating fields with that field ID
307
+ if ( isRepeatingFieldById( logicRules.HideField ) ) {
308
+ checkLogicForRepeatingHideField( i, logicRules, fieldValue, rec );
309
  return;
310
  }
311
 
312
+ // By this point, only non-repeating fields should be getting checked so proceed normally
313
+ setEmptyKeyInShowFieldsArray( logicRules );
314
+ updateShowFields( i, logicRules, fieldValue );
315
+ hideFieldNow( i, logicRules, rec );
316
+ }
317
 
318
+ // Check conditional logic when the trigger field is repeating and the current logic field may or may not be repeating
319
+ // Hide/show field is repeating
320
+ function checkRepeatingFieldInSingleRow( i, logicRules, rec, repeatSecHtmlId ) {
321
+ // If logic field is a repeating field, update inputName accordingly
322
+ if ( isRepeatingFieldById( logicRules.FieldName ) ) {
323
+ logicRules.inputName = getRepeatingFieldName( logicRules.FieldName, repeatSecHtmlId );
324
+ logicRules.containerID = getRepeatingFieldHtmlId( logicRules.FieldName, repeatSecHtmlId );
325
+ }
326
+ // Updat hideContainerID for repeating fields
327
+ logicRules.hideContainerID = getRepeatingFieldHtmlId( logicRules.HideField, repeatSecHtmlId );
328
 
329
+ // Get the value in the logic field
330
+ var fieldValue = getBasicEnteredValue( logicRules );
331
 
332
+ setEmptyKeyInShowFieldsArray(logicRules);
333
+ updateShowFields( i, logicRules, fieldValue );
334
+ hideFieldNow(i, logicRules, rec);
 
 
335
  }
336
 
337
+ // If the trigger field is NOT repeating, but the current logic field and the show/hide field are repeating
338
+ function checkLogicForTwoRepeatingFields( i, logicRules, rec ) {
339
+ var allRepeatFields = document.getElementsByClassName('frm_field_' + logicRules.FieldName + '_container');
340
+ for ( var r = 0; r < allRepeatFields.length; r++ ) {
341
+ logicRules.inputName = getRepeatingFieldName( logicRules.FieldName, allRepeatFields[r].id );
342
+ logicRules.containerID = allRepeatFields[r].id;
343
+ logicRules.hideContainerID = allRepeatFields[r].id.replace( logicRules.FieldName, logicRules.HideField );
 
 
344
 
345
+ // Get the value in the logic field
346
+ var fieldValue = getBasicEnteredValue( logicRules );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
347
 
348
+ setEmptyKeyInShowFieldsArray(logicRules);
349
+ updateShowFields( i, logicRules, fieldValue );
350
+ hideFieldNow(i, logicRules, rec);
 
 
 
 
 
351
  }
352
+ }
353
 
354
+ // If the hide/show field is repeating, loop through each field in column to check it
355
+ function checkLogicForRepeatingHideField( i, logicRules, fieldValue, rec ){
356
+ var allRepeatFields = document.getElementsByClassName('frm_field_' + logicRules.HideField + '_container');
357
+ for ( var r = 0; r < allRepeatFields.length; r++ ) {
358
+ logicRules.hideContainerID = allRepeatFields[r].id;
 
 
 
 
 
 
 
 
 
359
 
360
+ setEmptyKeyInShowFieldsArray(logicRules);
361
+ updateShowFields( i, logicRules, fieldValue );
362
+ hideFieldNow(i, logicRules, rec);
 
 
363
  }
364
+ }
365
 
366
+ function getBasicEnteredValue( f ){
367
+ var fieldValue = '';
 
 
 
 
 
 
 
 
 
 
 
368
 
369
+ // If field is a checkbox field
 
370
  if ( f.Type === 'checkbox' || f.Type === 'data-checkbox' ) {
371
+ var checkVals = getCheckedVal(f.containerID, f.inputName);
372
 
373
  if ( checkVals.length ) {
374
+ fieldValue = checkVals;
375
  }else{
376
+ fieldValue = '';
377
  }
378
+ return fieldValue;
379
+ }
380
+
381
+ // If field is on another page
382
+ fieldValue = jQuery('input[name="'+ f.inputName +'"][type="hidden"]').val();
383
+ if ( typeof fieldValue !== 'undefined' ) {
384
+ return fieldValue;
385
+ }
386
+
387
+ if ( f.Type == 'radio' || f.Type === 'data-radio' ) {
388
+ // If radio field on the current page
389
+ fieldValue = jQuery('input[name="'+ f.inputName +'"]:checked').val();
390
+ } else if ( f.Type === 'select' || f.Type === 'data-select' ) {
391
+ // If dropdown field on the current page
392
+ fieldValue = jQuery('select[name^="'+ f.inputName +'"]').val();
393
+ } else {
394
+ // If text field on the current page
395
+ fieldValue = jQuery('input[name="'+ f.inputName +'"]').val();
396
+ }
397
+
398
+ if ( typeof fieldValue === 'undefined' ) {
399
+ fieldValue = '';
400
  }
401
 
402
+ return fieldValue;
403
  }
404
 
405
+ function setEmptyKeyInShowFieldsArray(f) {
406
+ if ( typeof show_fields[f.hideContainerID] === 'undefined' ) {
407
+ show_fields[f.hideContainerID] = [];
408
+ }
409
+ }
410
+
411
+ // Add values to the show_fields array
412
+ function updateShowFields( i, logicRules, fieldValue ) {
413
+ if ( fieldValue === null || fieldValue === '' || fieldValue.length < 1 ) {
414
+ show_fields[logicRules.hideContainerID][i] = false;
415
  } else {
416
+ show_fields[logicRules.hideContainerID][i] = {'funcName':'getDataOpts', 'f':logicRules, 'sel':fieldValue};
417
  }
418
 
419
+ if ( logicRules.Type === 'checkbox' || (logicRules.Type === 'data-checkbox' && typeof logicRules.LinkedField === 'undefined') ) {
 
420
 
421
+ updateShowFieldsForCheckbox( i, logicRules, fieldValue );
422
+
423
+ } else if ( typeof logicRules.LinkedField !== 'undefined' && logicRules.Type.indexOf('data-') === 0 ) {
424
+
425
+ updateShowFieldsForDynamicField( i, logicRules, fieldValue );
426
+
427
+ }else if ( typeof logicRules.Value === 'undefined' && logicRules.Type.indexOf('data') === 0 ) {
428
+ if ( fieldValue === '' ) {
429
+ logicRules.Value = '1';
 
 
 
 
 
 
430
  } else {
431
+ logicRules.Value = fieldValue;
 
 
 
432
  }
433
+ show_fields[logicRules.hideContainerID][i] = operators(logicRules.Condition, logicRules.Value, fieldValue);
434
+ logicRules.Value = undefined;
435
+ } else {
436
+ show_fields[logicRules.hideContainerID][i] = operators(logicRules.Condition, logicRules.Value, fieldValue);
437
+ }
438
+ }
439
+
440
+ function updateShowFieldsForCheckbox( i, logicRules, fieldValue ) {
441
+ show_fields[logicRules.hideContainerID][i] = false;
442
+
443
+ var match = false;
444
+ if ( fieldValue !== '') {
445
+ if ( logicRules.Condition === '!=' ) {
446
+ show_fields[logicRules.hideContainerID][i] = true;
447
+ }
448
+ for ( var b = 0; b<fieldValue.length; b++ ) {
449
+ match = operators(logicRules.Condition, logicRules.Value, fieldValue[b]);
450
+ if ( logicRules.Condition === '!=' ) {
451
+ if ( show_fields[logicRules.hideContainerID][i] === true && match === false ) {
452
+ show_fields[logicRules.hideContainerID][i] = false;
453
  }
454
+ } else if(show_fields[logicRules.hideContainerID][i] === false && match){
455
+ show_fields[logicRules.hideContainerID][i] = true;
 
 
 
 
456
  }
457
  }
458
+ } else {
459
+ match = operators(logicRules.Condition, logicRules.Value, '');
460
+ if(show_fields[logicRules.hideContainerID][i] === false && match){
461
+ show_fields[logicRules.hideContainerID][i] = true;
 
462
  }
 
 
 
 
463
  }
464
  }
465
 
466
+ function updateShowFieldsForDynamicField( i, logicRules, fieldValue ) {
467
+ if ( typeof logicRules.DataType === 'undefined' || logicRules.DataType === 'data' ) {
468
+ if ( fieldValue === '' ) {
469
+ hideAndClearDynamicField( logicRules.hideContainerID, logicRules.HideField, 'hide' );
470
+ } else if ( logicRules.Type === 'data-radio' ) {
471
+ if ( typeof logicRules.DataType === 'undefined' ) {
472
+ show_fields[logicRules.hideContainerID][i] = operators(logicRules.Condition, logicRules.Value, fieldValue);
473
+ } else {
474
+ show_fields[logicRules.hideContainerID][i] = {'funcName':'getData','f':logicRules,'sel':fieldValue};
475
+ }
476
+ } else if ( logicRules.Type === 'data-checkbox' || ( logicRules.Type === 'data-select' && isNotEmptyArray( fieldValue ) ) ) {
477
+ hideAndClearDynamicField( logicRules.hideContainerID, logicRules.HideField, 'show' );
478
+ show_fields[logicRules.hideContainerID][i] = true;
479
+ getData(logicRules, fieldValue, 0);
480
+ } else if ( logicRules.Type === 'data-select' ) {
481
+ show_fields[logicRules.hideContainerID][i] = {'funcName':'getData','f':logicRules,'sel':fieldValue};
482
+ }
483
  }
484
  }
485
 
486
+ function hideFieldNow(i, f, rec){
487
+ if ( f.MatchType === 'all' || show_fields[f.hideContainerID][i] === false ) {
488
+ hide_later.push({
489
+ 'result':show_fields[f.hideContainerID][i], 'show':f.Show,
490
+ 'match':f.MatchType, 'FieldName':f.FieldName, 'HideField':f.HideField,
491
+ 'hideContainerID':f.hideContainerID
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
492
  });
493
+ return;
494
+ }
495
+
496
+ var display = 'none';
497
+ if ( f.Show === 'show' ) {
498
+ if ( show_fields[f.hideContainerID][i] !== true ) {
499
+ showField(show_fields[f.hideContainerID][i], f.FieldName, rec);
500
+ return;
501
+ }
502
+ display = '';
503
+ }
504
+
505
+ var hideFieldContainer = jQuery( document.getElementById(f.hideContainerID) );
506
+
507
+ if ( display == 'none' ) {
508
+ // Hide the field
509
+ routeToHideFieldAndClearVal( hideFieldContainer, f);
510
+ } else {
511
+ // Show the field
512
+ routeToShowFieldAndSetVal( hideFieldContainer, f);
513
  }
514
  }
515
 
516
+ function hideFieldLater(rec){
517
+ jQuery.each(hide_later, function(hkey,hvalue){
518
+ delete hide_later[hkey];
519
+ if ( typeof hvalue === 'undefined' || typeof hvalue.result === 'undefined' ) {
520
+ return;
521
+ }
522
+
523
+ var container = jQuery('#' + hvalue.hideContainerID);
524
+ var hideField = hvalue.show;
525
+ if ( ( hvalue.match === 'any' && (jQuery.inArray(true, show_fields[hvalue.hideContainerID]) === -1) ) ||
526
+ ( hvalue.match === 'all' && (jQuery.inArray(false, show_fields[hvalue.hideContainerID]) > -1) ) ) {
527
+ if ( hvalue.show === 'show' ) {
528
+ hideField = 'hide';
529
+ } else {
530
+ hideField = 'show';
531
+ }
532
  }
533
+
534
+ if ( hideField === 'show' ) {
535
+ routeToShowFieldAndSetVal( container, hvalue );
536
+
537
+ if ( typeof hvalue.result !== false && typeof hvalue.result !== true ) {
538
+ showField( hvalue.result, hvalue.FieldName, rec );
539
+ }
540
+ } else {
541
+ routeToHideFieldAndClearVal( container, hvalue );
542
  }
543
+ });
544
+ }
545
+
546
+ /* Hide Field Functions */
547
+ function routeToHideFieldAndClearVal( hideFieldContainer, f ) {
548
+ if ( hideFieldContainer.length ) {
549
+ // Field is not type=hidden
550
+ hideFieldAndClearValue( hideFieldContainer, f );
551
+ } else {
552
+ // Field is type=hidden
553
+ var fieldName = getFieldName( f.HideField, f.hideContainerID );
554
+ var inputs = jQuery( 'input[name^="' + fieldName + '"]' );
555
+ clearValueForInputs( inputs );
556
  }
557
+ addToHideFields( f.hideContainerID );
558
+ }
559
 
560
+ function hideFieldAndClearValue( container, f ) {
561
  container.hide();
562
  if ( jQuery.inArray(container.attr('id'), hidden_fields) === -1 ) {
563
  var field_id = f.HideField;
565
 
566
  var inputs = getInputsInContainer( container );
567
  if ( inputs.length ){
568
+ clearValueForInputs( inputs )
569
+ }
570
+ }
571
+ }
 
 
 
 
 
 
572
 
573
+ function clearValueForInputs( inputs ) {
574
+ inputs.prop('checked', false).prop('selectedIndex', 0);
575
+ inputs.not(':checkbox, :radio, select').val('');
576
+ var i = false;
577
+ inputs.each(function(){
578
+ if ( this.tagName == 'SELECT' ) {
579
+ var autocomplete = document.getElementById( this.id + '_chosen' );
580
+ if ( autocomplete !== null ) {
581
+ jQuery(this).trigger('chosen:updated');
582
+ }
583
+ }
584
+
585
+ if ( i === false || ["checkbox","radio"].indexOf( this.type ) < 0 ) {
586
+ triggerChange( jQuery(this) );
587
  }
588
+ i = true;
589
+ });
590
+ }
591
+
592
+ function addToHideFields( htmlFieldId ) {
593
+ // Get all currently hidden fields
594
+ var frmHideFieldsInput = document.getElementById('frm_hide_fields');
595
+ var hiddenFields = frmHideFieldsInput.value;
596
+ if ( hiddenFields ) {
597
+ hiddenFields = JSON.parse( hiddenFields );
598
+ } else {
599
+ hiddenFields = [];
600
+ }
601
+
602
+ // If field id is already in the array, move on
603
+ if ( hiddenFields.indexOf( htmlFieldId ) > -1 ) {
604
+ return;
605
+ } else {
606
+ // Add new conditionally hidden field to array
607
+ hiddenFields.push( htmlFieldId );
608
+ hiddenFields = JSON.stringify( hiddenFields );
609
+ frmHideFieldsInput.value = hiddenFields;
610
  }
611
  }
612
 
613
+ function hideAndClearDynamicField(hideContainer,field_id, hide){
614
+ if ( jQuery.inArray(hideContainer, hidden_fields) === -1 ) {
615
+ hidden_fields[ field_id ] = hideContainer;
616
+ hideContainer = jQuery(document.getElementById(hideContainer));
617
+ if ( hide === 'hide' ) {
618
+ hideContainer.hide();
619
+ }
620
+ hideContainer.find('.frm_data_field_container').empty();
621
+ }
622
+ }
623
+
624
+ /* Show Field Functions */
625
+ function routeToShowFieldAndSetVal( hideFieldContainer, f ) {
626
+ if ( hideFieldContainer.length ) {
627
+ // Field is not type=hidden
628
+ showFieldAndSetValue( hideFieldContainer, f );
629
+ } else {
630
+ // Set field value (don't show it)
631
+ var fieldName = getFieldName( f.HideField, f.hideContainerID );
632
+ var inputs = jQuery( 'input[name^="' + fieldName + '"]' );
633
+ setValForInputs( inputs )
634
+ }
635
+ removeFromHideFields( f.hideContainerID );
636
  }
637
 
638
  function showFieldAndSetValue( container, f ) {
639
  var inputs = getInputsInContainer( container );
 
640
 
641
+ setValForInputs( inputs )
642
+
643
+ container.show();
644
+ }
645
+
646
+ function setValForInputs( inputs ){
647
+ if ( inputs.length ) {
648
  for ( var i = 0; i < inputs.length; i++ ) {
649
+ setDefaultValue( jQuery( inputs[i] ) );
650
+ maybeDoCalcForSingleField( inputs[i] );
651
  }
 
 
652
  }
 
 
653
  }
654
 
655
  function setDefaultValue( input ) {
681
  }
682
  }
683
 
684
+ function removeFromHideFields( htmlFieldId ) {
685
+ // Get all currently hidden fields
686
+ var frmHideFieldsInput = document.getElementById('frm_hide_fields');
687
+ var hiddenFields = frmHideFieldsInput.value;
688
+ if ( hiddenFields ) {
689
+ hiddenFields = JSON.parse( hiddenFields );
690
+ } else {
691
+ return;
692
+ }
693
+
694
+ // If field id is in the array, delete it
695
+ var item_index = hiddenFields.indexOf( htmlFieldId );
696
+ if ( item_index > -1 ) {
697
+ hiddenFields.splice(item_index, 1);
698
+ hiddenFields = JSON.stringify( hiddenFields );
699
+ frmHideFieldsInput.value = hiddenFields;
700
+ }
701
+ }
702
+
703
  function triggerChange( input, fieldKey ) {
704
  if ( typeof fieldKey === 'undefined' ) {
705
  fieldKey = 'dependent';
712
  input.trigger({ type:'change', selfTriggered:true, frmTriggered:fieldKey });
713
  }
714
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
715
  function operators(op, a, b){
716
  if ( typeof b === 'undefined' ) {
717
  b = '';
804
  return;
805
  }
806
 
807
+ var hiddenInput = jQuery( '#' + f.hideContainerID ).find('select[name^="item_meta"], textarea[name^="item_meta"], input[name^="item_meta"]');
808
 
809
+ // Get the previously selected field value
810
+ var prev = getPrevFieldValue( hiddenInput );
811
+
812
+ // Get default value
813
+ var defaultValue = hiddenInput.data('frmval');
 
 
 
 
 
814
 
815
  if(f.DataType == 'select'){
816
  if((rec == 'stop' || jQuery('#'+ f.hideContainerID +' .frm-loading-img').length) && (jQuery.inArray(f.HideField, frm_checked_dep) > -1)){
817
  return;
818
  }
819
  }
 
 
 
 
820
 
821
  frm_checked_dep.push(f.HideField);
822
 
824
  //don't get values for fields that are to remain hidden on the page
825
  var $dataField = jQuery(fcont).find('.frm_data_field_container');
826
  if($dataField.length === 0 && hiddenInput.length ){
827
+ checkDependentField(f.HideField, 'stop', hiddenInput);
828
  return false;
829
  }
830
 
833
  if ( !match ) {
834
  fcont.style.display = 'none';
835
  $dataField.html('');
836
+ checkDependentField(f.HideField, 'stop', hiddenInput);
837
  return false;
838
  }
839
  }
850
  data:{
851
  action:'frm_fields_ajax_data_options', hide_field:field_id,
852
  entry_id:selected, selected_field_id:f.LinkedField, field_id:f.HideField,
853
+ default_value:defaultValue, hide_id:f.hideContainerID, nonce:frm_js.nonce
854
  },
855
  success:function(html){
856
  $dataField.html(html);
867
  fcont.style.display = '';
868
  }
869
 
870
+ if(html !== ''){
871
+ if ( prev !== '' ) {
872
+ if(!jQuery.isArray(prev)){
873
+ var new_prev = [];
874
+ new_prev.push(prev);
875
+ prev = new_prev;
876
+ }
877
 
878
+ //select options that were selected previously
879
+ jQuery.each(prev, function(ckey,cval){
880
+ if ( typeof(cval) === 'undefined' || cval === '' ) {
881
+ return;
882
+ }
883
+ if ( dataType == 'checkbox' || dataType == 'radio' ) {
884
+ if ( parentField.length > 1 ) {
885
+ parentField.filter('[value="' + cval+ '"]').attr('checked','checked');
886
+ } else if ( parentField.val() == cval ){
887
+ parentField.attr('checked','checked');
888
+ }
889
+ } else if ( dataType == 'select' ) {
890
+ var selOpt = parentField.children('option[value="'+ cval +'"]');
891
+ if(selOpt.length){
892
+ selOpt.prop('selected', true);
893
+ }else{
894
+ //remove options that no longer exist
895
+ prev.splice(ckey, 1);
896
+ }
897
  }else{
898
+ parentField.val(cval);
 
899
  }
900
+ });
901
+ } else {
902
+ // If no options were selected previously, set to default value
903
+ setDefaultValue( getInputsInContainer( $dataField ) );
904
+ }
905
  }
906
 
907
  if(parentField.hasClass('frm_chzn') && jQuery().chosen){
913
  });
914
  }
915
 
916
+ function getPrevFieldValue( inputs ) {
917
+ var prev = [];
918
+ var thisVal = '';
919
+ inputs.each(function(){
920
+ thisVal = this.value;
921
+ if ( this.type === 'radio' || this.type === 'checkbox' ) {
922
+ if ( this.checked === true ) {
923
+ prev.push( thisVal );
924
+ }
925
+ } else {
926
+ if ( thisVal !== '' ) {
927
+ prev.push( thisVal );
928
+ }
929
+ }
930
+ });
931
+
932
+ if ( prev.length === 0 ) {
933
+ prev = '';
934
+ }
935
+
936
+ return prev;
937
+ }
938
+
939
  function doCalculation(field_id, triggerField){
940
  if ( typeof __FRMCALC === 'undefined' ) {
941
  // there are no calculations on this page
957
  for ( var i = 0, l = len; i < l; i++ ) {
958
 
959
  // Stop calculation if total field is conditionally hidden
960
+ if ( fieldIsConditionallyHidden( all_calcs.calc[ keys[i] ].field_id, triggerField.attr('name') ) ) {
961
  continue;
962
  }
963
 
966
  }
967
 
968
  /**
969
+ * Check if field (or its HTML parent) is hidden with conditional logic
970
  */
971
+ function fieldIsConditionallyHidden( field_id, triggerFieldName ) {
972
+ var hiddenFields = document.getElementById( 'frm_hide_fields').value;
973
+ if ( hiddenFields ) {
974
+ hiddenFields = JSON.parse( hiddenFields );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
975
  } else {
 
976
  return false;
977
  }
978
+
979
+ var checkFieldId = field_id;
980
+
981
+ // If triggerField is repeating, assume total field is also repeating
982
+ if ( isRepeatingFieldByName( triggerFieldName ) ) {
983
+ var triggerFieldParts = triggerFieldName.replace('item_meta', '').replace( /\[/g, '').split( ']' );
984
+ checkFieldId = field_id + '-' + triggerFieldParts[0] + '-' + triggerFieldParts[1];
985
+ }
986
+
987
+ // If total field is a conditionally hidden (could be repeating or non-repeating)
988
+ if ( hiddenFields.indexOf( 'frm_field_' + checkFieldId + '_container' ) > -1 ) {
989
+ return true;
990
+ }
991
+
992
+ // If field is inside of section/embedded form which is hidden with conditional logic
993
+ var helpers = getHelpers();
994
+ if ( helpers && helpers[ field_id ] !== null && hiddenFields.indexOf( 'frm_field_' + helpers[ field_id ] + '_container' ) > -1 ) {
995
+ return true;
996
+ }
997
+
998
+ return false;
999
+ }
1000
+
1001
+ function isRepeatingFieldByName( fieldName ) {
1002
+ var isRepeating = false;
1003
+ var fieldNameParts = fieldName.split( '[' );
1004
+ if ( fieldNameParts.length >= 4 ) {
1005
+ isRepeating = true;
1006
+ }
1007
+
1008
+ return isRepeating;
1009
  }
1010
 
1011
  function doSingleCalculation( all_calcs, field_key, vals, triggerField ) {
1089
  return field;
1090
  }
1091
 
1092
+ function maybeDoCalcForSingleField( field_input ) {
1093
  if ( typeof __FRMCALC === 'undefined' ) {
1094
  // there are no calculations on this page
1095
  return;
1096
  }
1097
+
1098
  var all_calcs = __FRMCALC;
1099
+ var field_key = getFieldKey( field_input.id, field_input.name );
1100
+ var triggerField = maybeGetTriggerField( field_input );
1101
+
1102
+ if ( all_calcs.calc[ field_key ] === undefined ) {
1103
+ // This field doesn't have any calculations
1104
  return;
1105
  }
1106
 
1108
  doSingleCalculation( all_calcs, field_key, vals, triggerField );
1109
  }
1110
 
1111
+ function getFieldKey( fieldHtmlId, fieldName ) {
1112
+ var field_key = fieldHtmlId.replace( 'field_', '' );
1113
+
1114
+ if ( isRepeatingFieldByName( fieldName ) ) {
1115
+ var fieldKeyParts = field_key.split('-');
1116
+ var newFieldKey = '';
1117
+ for ( var i=0; i<fieldKeyParts.length-1; i++ ){
1118
+ newFieldKey = newFieldKey + fieldKeyParts[i];
1119
+ }
1120
+ field_key = newFieldKey;
1121
+ }
1122
+
1123
+ return field_key;
1124
+ }
1125
+
1126
+ function maybeGetTriggerField( fieldInput ) {
1127
+ var triggerField = null;
1128
+ if ( isRepeatingFieldByName( fieldInput.name ) ) {
1129
+ triggerField = jQuery( fieldInput ).closest('.frm_form_field');
1130
+ }
1131
+
1132
+ return triggerField;
1133
+ }
1134
+
1135
  function getCalcFieldId( field, all_calcs, vals ) {
1136
  if ( typeof vals[field.valKey] !== 'undefined' && vals[field.valKey] !== 0 ) {
1137
  return vals;
1157
  var thisVal = getOptionValue( field.thisField, this );
1158
 
1159
  if ( field.thisField.type == 'date' ) {
1160
+ var d = getDateFieldValue( all_calcs.date, thisVal );
1161
  if ( d !== null ) {
1162
  vals[field.valKey] = Math.ceil(d/(1000*60*60*24));
1163
  }
1180
  return vals;
1181
  }
1182
 
1183
+ /**
1184
+ * Get the value from a date field regardless of whether datepicker is defined for it
1185
+ * Limitations: If using a format with a 2-digit date, '20' will be added to the front if the year is prior to 70
1186
+ */
1187
+ function getDateFieldValue( dateFormat, thisVal ) {
1188
+ var d = 0;
1189
+
1190
+ if ( ! thisVal ) {
1191
+ // If no value was selected in date field, use 0
1192
+ } else if ( typeof jQuery.datepicker === 'undefined' ) {
1193
+ // If date field is not on the current page
1194
+
1195
+ var splitAt = '-';
1196
+ if ( dateFormat.indexOf( '/' ) > -1 ) {
1197
+ splitAt = '/';
1198
+ }
1199
+
1200
+ var formatPieces = dateFormat.split( splitAt );
1201
+ var datePieces = thisVal.split( splitAt );
1202
+
1203
+ var year, month, day;
1204
+ year = month = day = '';
1205
+
1206
+ for ( var i = 0; i < formatPieces.length; i++ ) {
1207
+ if ( formatPieces[ i ] == 'y' ) {
1208
+ var currentYear = new Date().getFullYear() + 15;
1209
+ var currentYearPlusFifteen = currentYear.toString().substr(2,2);
1210
+
1211
+ if ( datePieces[ i ] > currentYearPlusFifteen ) {
1212
+ year = '19' + datePieces[ i ];
1213
+ } else {
1214
+ year = '20' + datePieces[ i ];
1215
+ }
1216
+ } else if ( formatPieces[ i ] == 'yy' ) {
1217
+ year = datePieces[ i ];
1218
+ } else if ( formatPieces[ i ] == 'm' || formatPieces[ i ] == 'mm' ) {
1219
+ month = datePieces[ i ];
1220
+ if ( month.length < 2 ) {
1221
+ month = '0' + month;
1222
+ }
1223
+ } else if ( formatPieces[ i ] == 'd' || formatPieces[ i ] == 'dd' ) {
1224
+ day = datePieces[ i ];
1225
+ if ( day.length < 2 ) {
1226
+ day = '0' + day;
1227
+ }
1228
+ }
1229
+ }
1230
+
1231
+ d = Date.parse( year + '-' + month + '-' + day );
1232
+
1233
+ } else {
1234
+ d = jQuery.datepicker.parseDate(dateFormat, thisVal);
1235
+ }
1236
+ return d;
1237
+ }
1238
+
1239
  function getSiblingField( field ) {
1240
  if ( typeof field.triggerField === 'undefined' ) {
1241
  return null;
1695
 
1696
  if ( showDelete ) {
1697
  if ( typeof entry.deleteLink !== 'undefined' ) {
1698
+ data.setCell(row, col,'<a href="'+ entry.deleteLink +'" class="frm_delete_link" data-frmconfirm="'+ opts.options.confirm +'">'+ opts.options.delete_link +'</a>');
1699
  } else {
1700
  data.setCell(row, col, '');
1701
  }
1874
 
1875
  function addRow(){
1876
  /*jshint validthis:true */
1877
+
1878
+ // If row is currently being added, leave now
1879
+ if ( currentlyAddingRow === true ) {
1880
+ return false;
1881
+ }
1882
+
1883
+ // Indicate that a row is being added (so double clicking Add button doesn't cause problems)
1884
+ currentlyAddingRow = true;
1885
+
1886
  var id = jQuery(this).data('parent');
1887
  var i = 0;
1888
  if ( jQuery('.frm_repeat_'+id).length > 0 ) {
1902
  jQuery('.frm_repeat_'+ id +':last').after(item);
1903
 
1904
  var checked = ['other'];
1905
+ var fieldID, fieldObject;
1906
  var reset = 'reset';
1907
  addingRow = item.attr('id');
1908
 
1911
  if ( this.type != 'file' ) {
1912
  fieldID = this.name.replace('item_meta[', '').split(']')[2].replace('[', '');
1913
  if ( jQuery.inArray(fieldID, checked ) == -1 ) {
1914
+ fieldObject = jQuery( '#' + this.id );
1915
  checked.push(fieldID);
1916
+ checkDependentField(fieldID, null, fieldObject, reset);
1917
+ doCalculation(fieldID, fieldObject);
1918
  reset = 'persist';
1919
  }
1920
  }
1926
  for ( var f = 0, l = checkLen; f < l; f++ ) {
1927
  if ( jQuery.inArray(r.logic.check[f], checked ) == -1 ) {
1928
  if(jQuery(html).find('.frm_field_'+r.logic.check[f]+'_container').length < 1){
1929
+ checkDependentField(r.logic.check[f], null, null, reset);
1930
  reset = 'persist';
1931
  }
1932
  }
1947
  if(typeof(frmThemeOverride_frmAddRow) == 'function'){
1948
  frmThemeOverride_frmAddRow(id, r);
1949
  }
1950
+
1951
+ currentlyAddingRow = false;
1952
+ },
1953
+ error: function() {
1954
+ currentlyAddingRow = false;
1955
  }
1956
  });
1957
 
1958
+ return false;
1959
+ }
1960
 
1961
+ /* In-place edit */
1962
+ function editEntry(){
1963
+ /*jshint validthis:true */
1964
+ var $edit = jQuery(this);
1965
+ var entry_id = $edit.data('entryid');
1966
+ var prefix = $edit.data('prefix');
1967
+ var post_id = $edit.data('pageid');
1968
+ var form_id = $edit.data('formid');
1969
+ var label = $edit.data('edit');
1970
+ var fields = $edit.data('fields');
1971
+ var exclude_fields = $edit.data('excludefields');
1972
+
1973
+ var $cont = jQuery(document.getElementById(prefix+entry_id));
1974
+ var orig = $cont.html();
1975
+ $cont.html('<span class="frm-loading-img" id="'+prefix+entry_id+'"></span><div class="frm_orig_content" style="display:none">'+orig+'</div>');
1976
+ jQuery.ajax({
1977
+ type:'POST',url:frm_js.ajax_url,dataType:'html',
1978
+ data:{
1979
+ action:'frm_entries_edit_entry_ajax', post_id:post_id,
1980
+ entry_id:entry_id, id:form_id, nonce:frm_js.nonce,
1981
+ fields:fields, exclude_fields:exclude_fields,
1982
+ },
1983
+ success:function(html){
1984
+ $cont.children('.frm-loading-img').replaceWith(html);
1985
+ $edit.removeClass('frm_inplace_edit').addClass('frm_cancel_edit');
1986
+ $edit.html(label);
1987
+ }
1988
+ });
1989
+ return false;
1990
+ }
1991
+
1992
+ function cancelEdit(){
1993
+ /*jshint validthis:true */
1994
+ var $edit = jQuery(this);
1995
+ var entry_id = $edit.data('entryid');
1996
+ var prefix = $edit.data('prefix');
1997
+ var label = $edit.data('edit');
1998
+
1999
+ if(!$edit.hasClass('frm_ajax_edited')){
2000
+ var $cont = jQuery(document.getElementById(prefix+entry_id));
2001
+ $cont.children('.frm_forms').replaceWith('');
2002
+ $cont.children('.frm_orig_content').fadeIn('slow').removeClass('frm_orig_content');
2003
+ }
2004
+ $edit.removeClass('frm_cancel_edit').addClass('frm_inplace_edit');
2005
+ $edit.html(label);
2006
+ return false;
2007
+ }
2008
+
2009
+ function deleteEntry(){
2010
+ /*jshint validthis:true */
2011
+ var $link = jQuery(this);
2012
+ var confirmText = $link.data('deleteconfirm');
2013
+ if ( confirm( confirmText ) ) {
2014
+ var entry_id = $link.data('entryid');
2015
+ var prefix = $link.data('prefix');
2016
+
2017
+ $link.replaceWith('<span class="frm-loading-img" id="frm_delete_'+entry_id+'"></span>');
2018
+ jQuery.ajax({
2019
+ type:'POST',url:frm_js.ajax_url,
2020
+ data:{action:'frm_entries_destroy', entry:entry_id, nonce:frm_js.nonce},
2021
+ success:function(html){
2022
+ if(html.replace(/^\s+|\s+$/g,'') == 'success'){
2023
+ jQuery(document.getElementById(prefix+entry_id)).fadeOut('slow');
2024
+ jQuery(document.getElementById('frm_delete_'+entry_id)).fadeOut('slow');
2025
+ }else{
2026
+ jQuery(document.getElementById('frm_delete_'+entry_id)).replaceWith(html);
2027
+ }
2028
+ }
2029
+ });
2030
+ }
2031
  return false;
2032
  }
2033
 
2038
  });
2039
  }
2040
 
2041
+ function confirmClick() {
2042
+ /*jshint validthis:true */
2043
+ var message = jQuery(this).data('frmconfirm');
2044
+ return confirm(message);
2045
+ }
2046
+
2047
  function toggleDiv(){
2048
  /*jshint validthis:true */
2049
  var div=jQuery(this).data('frmtoggle');
2082
  return !jQuery.isArray( obj ) && (obj - parseFloat( obj ) + 1) >= 0;
2083
  }
2084
 
2085
+ function getInputsInContainer( container ) {
2086
+ return container.find('select[name^="item_meta"], textarea[name^="item_meta"], input[name^="item_meta"]');
2087
+ }
2088
+
2089
+ // Get the beginning part of the name for a given field
2090
+ function getFieldName( fieldId, fieldDivId ){
2091
+ var fieldName = 'item_meta[' + fieldId + ']';
2092
+
2093
+ // If field is repeating
2094
+ if ( isRepeatingFieldById( fieldId ) ) {
2095
+ fieldName = getRepeatingFieldName( fieldId, fieldDivId );
2096
+ }
2097
+
2098
+ return fieldName;
2099
+ }
2100
+
2101
+ function getHelpers() {
2102
+ var helpers = document.getElementById( 'frm_helpers' ).value;
2103
+ if ( helpers ) {
2104
+ helpers = JSON.parse( helpers );
2105
+ } else {
2106
+ helpers = [];
2107
+ }
2108
+
2109
+ return helpers;
2110
+ }
2111
+
2112
+ // Get the input name of a specific field in a given row of a repeating section
2113
+ function getRepeatingFieldName( fieldId, parentHtmlId ) {
2114
+ var repeatFieldName = '';
2115
+ if ( parentHtmlId.indexOf( 'frm_section' ) > -1 ) {
2116
+ // The HTML id provided is the frm_section HTML id
2117
+ var repeatSecParts = parentHtmlId.replace( 'frm_section_', '' ).split( '-' );
2118
+ repeatFieldName = 'item_meta[' + repeatSecParts[0] + '][' + repeatSecParts[1] + '][' + fieldId +']';
2119
+ } else {
2120
+ // The HTML id provided is the field div HTML id
2121
+ var fieldDivParts = parentHtmlId.replace( 'frm_field_', '').replace( '_container', '').split('-');
2122
+ repeatFieldName = 'item_meta[' + fieldDivParts[1] + '][' + fieldDivParts[2] + '][' + fieldId +']';
2123
+ }
2124
+
2125
+ return repeatFieldName;
2126
+ }
2127
+
2128
+ // Get the HTML id for a given repeating field
2129
+ function getRepeatingFieldHtmlId( fieldId, repeatSecHtmlId ){
2130
+ var repeatSecParts = repeatSecHtmlId.replace( 'frm_section_', '' ).split( '-' );
2131
+ var repeatFieldHtmlId = 'frm_field_' + fieldId + '-' + repeatSecParts[0] + '-' + repeatSecParts[1] + '_container';
2132
+ return repeatFieldHtmlId;
2133
+ }
2134
+
2135
+ function maybeGetFirstElement( jQueryObj ) {
2136
+ if ( jQueryObj.length > 1 ) {
2137
+ jQueryObj = jQueryObj.eq(0);
2138
+ }
2139
+ return jQueryObj;
2140
+ }
2141
+
2142
+ // Check if a given field is repeating
2143
+ function isRepeatingFieldById( fieldId ){
2144
+ // Check field div first
2145
+ var fieldDiv = document.getElementById( 'frm_field_' + fieldId + '_container' );
2146
+ if ( typeof fieldDiv != 'undefined' && fieldDiv != null ) {
2147
+ return false;
2148
+ }
2149
+
2150
+ // Check input next so type=hidden fields don't get marked as repeating
2151
+ var fieldInput = jQuery( 'input[name^="item_meta[' + fieldId + ']"],select[name^="item_meta[' + fieldId + ']"], textarea[name^="item_meta[' + fieldId + ']"]' );
2152
+ if ( fieldInput.length < 1 ) {
2153
+ // TODO: Change this so Section (on diff page), HTML (on diff page), reCaptcha (on diff page), and page break fields don't return true
2154
+ return true;
2155
+ } else {
2156
+ return false;
2157
+ }
2158
+ }
2159
+
2160
+ /* Fallback functions */
2161
+ function addIndexOfFallbackForIE8() {
2162
+ if ( !Array.prototype.indexOf ) {
2163
+ Array.prototype.indexOf = function(elt /*, from*/) {
2164
+ var len = this.length >>> 0;
2165
+
2166
+ var from = Number(arguments[1]) || 0;
2167
+ from = (from < 0) ? Math.ceil(from) : Math.floor(from);
2168
+ if (from < 0) {
2169
+ from += len;
2170
+ }
2171
+
2172
+ for (; from < len; from++) {
2173
+ if ( from in this && this[from] === elt ) {
2174
+ return from;
2175
+ }
2176
+ }
2177
+ return -1;
2178
+ };
2179
+ }
2180
+ }
2181
+
2182
+ function addTrimFallbackForIE8(){
2183
+ if ( typeof String.prototype.trim !== 'function' ) {
2184
+ String.prototype.trim = function() {
2185
+ return this.replace(/^\s+|\s+$/g, '');
2186
+ };
2187
+ }
2188
+ }
2189
+
2190
+ function addFilterFallbackForIE8(){
2191
+ if ( !Array.prototype.filter ) {
2192
+
2193
+ Array.prototype.filter = function(fun /*, thisp */) {
2194
+ "use strict";
2195
+
2196
+ if ( this === void 0 || this === null ) {
2197
+ throw new TypeError();
2198
+ }
2199
+
2200
+ var t = Object( this );
2201
+ var len = t.length >>> 0;
2202
+ if ( typeof fun !== "function" ) {
2203
+ throw new TypeError();
2204
+ }
2205
+
2206
+ var res = [];
2207
+ var thisp = arguments[1];
2208
+ for (var i = 0; i < len; i++) {
2209
+ if ( i in t ) {
2210
+ var val = t[i]; // in case fun mutates this
2211
+ if (fun.call(thisp, val, i, t))
2212
+ res.push(val);
2213
+ }
2214
+ }
2215
+
2216
+ return res;
2217
+ };
2218
+ }
2219
+ }
2220
+
2221
+ function addKeysFallbackForIE8(){
2222
+ if ( !Object.keys ) {
2223
+ Object.keys = function(obj) {
2224
+ var keys = [];
2225
+
2226
+ for (var i in obj) {
2227
+ if (obj.hasOwnProperty(i)) {
2228
+ keys.push(i);
2229
+ }
2230
+ }
2231
+
2232
+ return keys;
2233
+ };
2234
+ }
2235
+ }
2236
+
2237
  /* Get checked values with IE8 fallback */
2238
  function getCheckedVal(containerID, inputName) {
2239
  var checkVals = [];
2297
  jQuery(document).on('click', '.frm_remove_form_row', removeRow);
2298
  jQuery(document).on('click', '.frm_add_form_row', addRow);
2299
 
2300
+ jQuery(document).on('click', 'a[data-frmconfirm]', confirmClick);
2301
  jQuery('a[data-frmtoggle]').click(toggleDiv);
2302
 
2303
+ // In place edit
2304
+ jQuery('.frm_edit_link_container').on('click', 'a.frm_inplace_edit', editEntry);
2305
+ jQuery('.frm_edit_link_container').on('click', 'a.frm_cancel_edit', cancelEdit);
2306
+ jQuery('.frm_ajax_delete').click(deleteEntry);
2307
+
2308
  // toggle collapsible entries shortcode
2309
  jQuery('.frm_month_heading, .frm_year_heading').click( function(){
2310
  var content = jQuery(this).children('.ui-icon-triangle-1-e, .ui-icon-triangle-1-s');
2316
  jQuery(this).next('.frm_toggle_container').hide();
2317
  }
2318
  });
2319
+
2320
+ // Add fallbacks for the beloved IE8
2321
+ addIndexOfFallbackForIE8();
2322
+ addTrimFallbackForIE8();
2323
+ addFilterFallbackForIE8();
2324
+ addKeysFallbackForIE8();
2325
  },
2326
 
2327
  submitForm: function(e){
2420
  var len = ids.length;
2421
  var reset = 'reset';
2422
  for ( var i = 0, l = len; i < l; i++ ) {
2423
+ checkDependentField(ids[i], null, null, reset);
2424
  reset = 'persist';
2425
  }
2426
  },
2487
  frmFrontForm.init();
2488
  });
2489
 
2490
+ function frmUpdateField(entry_id,field_id,value,message,num){
2491
+ jQuery(document.getElementById('frm_update_field_'+entry_id+'_'+field_id)).html('<span class="frm-loading-img"></span>');
2492
+ jQuery.ajax({
2493
+ type:'POST',url:frm_js.ajax_url,
2494
+ data:{action:'frm_entries_update_field_ajax', entry_id:entry_id, field_id:field_id, value:value, nonce:frm_js.nonce},
2495
+ success:function(){
2496
+ if(message.replace(/^\s+|\s+$/g,'') === ''){
2497
+ jQuery(document.getElementById('frm_update_field_'+entry_id+'_'+field_id+'_'+num)).fadeOut('slow');
2498
+ }else{
2499
+ jQuery(document.getElementById('frm_update_field_'+entry_id+'_'+field_id+'_'+num)).replaceWith(message);
2500
+ }
2501
+ }
2502
+ });
2503
+ }
2504
+
2505
  function frmEditEntry(entry_id,prefix,post_id,form_id,cancel,hclass){
2506
+ console.warn('DEPRECATED: function frmEditEntry in v2.0.13 use frmFrontForm.editEntry');
2507
  var $edit = jQuery(document.getElementById('frm_edit_'+entry_id));
2508
  var label = $edit.html();
2509
  var $cont = jQuery(document.getElementById(prefix+entry_id));
2520
  }
2521
 
2522
  function frmCancelEdit(entry_id,prefix,label,post_id,form_id,hclass){
2523
+ console.warn('DEPRECATED: function frmCancelEdit in v2.0.13 use frmFrontForm.cancelEdit');
2524
  var $edit = jQuery(document.getElementById('frm_edit_'+entry_id));
2525
  var $link = $edit.find('a');
2526
  var cancel = $link.html();
2533
  $edit.replaceWith('<a id="frm_edit_'+entry_id+'" class="frm_edit_link '+hclass+'" href="javascript:frmEditEntry('+entry_id+',\''+prefix+'\','+post_id+','+form_id+',\''+ frmFrontForm.escapeHtml(cancel) +'\',\''+hclass+'\')">'+label+'</a>');
2534
  }
2535
 
2536
+ function frmDeleteEntry(entry_id,prefix){
2537
+ console.warn('DEPRECATED: function frmDeleteEntry in v2.0.13 use frmFrontForm.deleteEntry');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2538
  jQuery(document.getElementById('frm_delete_'+entry_id)).replaceWith('<span class="frm-loading-img" id="frm_delete_'+entry_id+'"></span>');
2539
  jQuery.ajax({
2540
  type:'POST',url:frm_js.ajax_url,
js/formidable.min.js CHANGED
@@ -1,65 +1,2 @@
1
- function frmFrontFormJS(){function l(a){var b=jQuery(this),c=b.attr("type");"submit"!==c&&a.preventDefault();a=b.parents("form:first");var d=b="",f=this.name;if("frm_prev_page"===f||-1!==this.className.indexOf("frm_prev_page"))b=jQuery(a).find(".frm_next_page").attr("id").replace("frm_next_p_","");else if("frm_save_draft"===f||-1!==this.className.indexOf("frm_save_draft"))d=1;jQuery(".frm_next_page").val(b);jQuery(".frm_saving_draft").val(d);"submit"!==c&&a.trigger("submit")}function n(){jQuery(this).parent().children(".frm_toggle_container").slideToggle("fast");
2
- jQuery(this).toggleClass("active").children(".ui-icon-triangle-1-e, .ui-icon-triangle-1-s").toggleClass("ui-icon-triangle-1-s ui-icon-triangle-1-e")}function p(){this.className=this.className.replace("frm_transparent","");this.parentNode.getElementsByTagName("a")[0].className.indexOf("frm_clear_file_link")}function v(){var a=this.type,b=!1,c=!1;if("select-one"===a)c=!0,"frm_other_trigger"===this.options[this.selectedIndex].className&&(b=!0);else if("select-multiple"===a)for(var c=!0,d=this.options,
3
- b=!1,f=0;f<d.length;f++)if("frm_other_trigger"===d[f].className&&d[f].selected){b=!0;break}c?(a=jQuery(this).parent().children(".frm_other_input"),a.length&&(b?a[0].className=a[0].className.replace("frm_pos_none",""):(1>a[0].className.indexOf("frm_pos_none")&&(a[0].className+=" frm_pos_none"),a[0].value=""))):"radio"===a?jQuery(this).is(":checked")&&(jQuery(this).closest(".frm_radio").children(".frm_other_input").removeClass("frm_pos_none"),jQuery(this).closest(".frm_radio").siblings().children(".frm_other_input").addClass("frm_pos_none").val("")):
4
- "checkbox"===a&&(this.checked?jQuery(this).closest(".frm_checkbox").children(".frm_other_input").removeClass("frm_pos_none"):jQuery(this).closest(".frm_checkbox").children(".frm_other_input").addClass("frm_pos_none").val(""))}function w(a){var b=y(this);if(b&&"undefined"!==typeof b){var c="reset";if(a.frmTriggered){if(a.frmTriggered==b)return;c="persist"}r("und",b,null,jQuery(this),c);E(b,jQuery(this))}}function y(a,b){var c="",c=a instanceof jQuery?a.attr("name"):a.name,c=c.replace("item_meta[",
5
- "").replace("[]","").split("]"),c=c.filter(function(a){return""!==a}),d=c[0],f=!1;if(1===c.length)return d;jQuery('input[name="item_meta['+d+'][form]"]').length&&(d=c[2].replace("[",""),f=!0);"other"===d&&(d=f?c[3].replace("[",""):c[1].replace("[",""));!0===b&&(d=d+"-"+c[0]+"-"+c[1].replace("[",""));return d}function r(a,b,c,d,f){var e;if("undefined"===typeof __FRMRULES||"undefined"===typeof __FRMRULES[b])e=void 0;else{e=__FRMRULES[b];for(var h=[],g=0,k=e.length;g<k;g++){var l=e[g];if("undefined"!==
6
- typeof l)for(var F=0,n=l.Conditions.length;F<n;F++){var p=l.Conditions[F];p.HideField=l.Setting.FieldName;p.MatchType=l.MatchType;p.Show=l.Show;h.push(p)}}e=h}if("undefined"!==typeof e){if("undefined"===typeof c||null===c)c="go";"persist"!==f&&(m=[],B=[]);f=d;h=!1;""===u&&"undefined"!==typeof f&&null!==f&&(1<f.length&&(f=f.eq(0)),h=f.closest(".frm_repeat_sec, .frm_repeat_inline, .frm_repeat_grid"),"undefined"!==typeof h?(u=h.attr("id"),h=!0):h=!1);f=h;h=e.length;for(g=0;g<h;g++)e[g].FieldName===b?
7
- q(g,e[g],b,a,c,d):q(g,e[g],b,a,c),g===h-1&&(aa(c),f&&(u=""))}}function q(a,b,c,d,f,e){b.inputName="item_meta["+b.FieldName+"]";b.hiddenName="item_meta["+b.HideField+"]";b.containerID="frm_field_"+b.FieldName+"_container";b.hideContainerID="frm_field_"+b.HideField+"_container";b.hideBy="#";var h=!1;if("undefined"!==typeof e&&null!==e){e=x(e);if("undefined"===typeof e.attr("name"))return;var g=e.closest(".frm_repeat_sec, .frm_repeat_inline, .frm_repeat_grid");g.length&&(g=g.find(".frm_field_"+b.FieldName+
8
- "_container"),b.containerID=g.attr("id"),b.hideContainerID=b.containerID.replace(b.FieldName,b.HideField),b.hiddenName=b.inputName.replace("["+b.FieldName+"]","["+b.HideField+"]"))}else{h=!0;e=jQuery('input[name^="'+b.inputName+'"], textarea[name^="'+b.inputName+'"], select[name^="'+b.inputName+'"]');if(1>e.length){C(a,b,c,d,f);return}e=x(e)}G(b);null===document.getElementById(b.hideContainerID)&&(b.hideBy=".");d=ba(a,b,c,d,f,e,h);if(!1!==d){c=d;m[b.hideContainerID][a]=null===c||""===c||1>c.length?
9
- !1:{funcName:"getDataOpts",f:b,sel:c};if("checkbox"===b.Type||"data-checkbox"===b.Type&&"undefined"===typeof b.LinkedField)if(d=m[b.hideContainerID][a]=!1,""!==c)for("!="===b.Condition&&(m[b.hideContainerID][a]=!0),e=0;e<c.length;e++)d=z(b.Condition,b.Value,c[e]),"!="===b.Condition?!0===m[b.hideContainerID][a]&&!1===d&&(m[b.hideContainerID][a]=!1):!1===m[b.hideContainerID][a]&&d&&(m[b.hideContainerID][a]=!0);else d=z(b.Condition,b.Value,""),!1===m[b.hideContainerID][a]&&d&&(m[b.hideContainerID][a]=
10
- !0);else if("undefined"!==typeof b.LinkedField&&0===b.Type.indexOf("data-")){if("undefined"===typeof b.DataType||"data"===b.DataType)""===c?L(b.hideContainerID,b.hideBy,b.HideField,"hide"):"data-radio"===b.Type?m[b.hideContainerID][a]="undefined"===typeof b.DataType?z(b.Condition,b.Value,c):{funcName:"getData",f:b,sel:c}:(!(d="data-checkbox"===b.Type)&&(d="data-select"===b.Type)&&(d=jQuery.isArray(c)&&(1<c.length||""!==c[0])),d?(L(b.hideContainerID,b.hideBy,b.HideField,"show"),m[b.hideContainerID][a]=
11
- !0,M(b,c,1)):"data-select"===b.Type&&(m[b.hideContainerID][a]={funcName:"getData",f:b,sel:c}))}else"undefined"===typeof b.Value&&0===b.Type.indexOf("data")?(b.Value=""===c?"1":c,m[b.hideContainerID][a]=z(b.Condition,b.Value,c),b.Value=void 0):m[b.hideContainerID][a]=z(b.Condition,b.Value,c);ca(b,a);N(a,b,f)}}function x(a){1<a.length&&(a=a.eq(0));return a}function C(a,b,c,d,f){var e="."+b.containerID;""!==u&&void 0!=u&&(e="#"+u+" "+e);e=jQuery(e);if(e.length)if(e=e.find("input, textarea, select"),
12
- e.length)if(""===u||void 0===u){var h="";e.each(function(){var c=jQuery(this).closest(".frm_form_field").attr("id");c!=h&&q(a,b,b.FieldName,d,f,jQuery(this));h=c})}else q(a,b,c,d,f,e);else G(b),m[b.hideContainerID][a]=!1,N(a,b,f)}function ba(a,b,c,d,f,e,h){if(b.FieldName!==c||"undefined"===typeof d||"und"===d)if(("radio"===b.Type||"data-radio"===b.Type)&&"radio"===e.attr("type"))d=jQuery('input[name="'+b.inputName+'"]:checked').val(),"undefined"===typeof d&&(d="");else if("select"===b.Type||"time"===
13
- b.Type||"data-select"===b.Type||"checkbox"!==b.Type&&"data-checkbox"!==b.Type)d=e.val();if("undefined"===typeof d){if(0===e.length)return!1;d=e.val()}if("undefined"===typeof d){if(!0===h&&(c=jQuery("."+b.containerID+" input, ."+b.containerID+" select, ."+b.containerID+" textarea"),c.length))return c.each(function(){q(a,b,b.FieldName,d,f,jQuery(this))}),!1;d=""}c=[];if("checkbox"===b.Type||"data-checkbox"===b.Type)c=da(b.containerID,b.inputName),d=c.length?c:"";return d}function G(a){"undefined"===
14
- typeof m[a.hideContainerID]&&(m[a.hideContainerID]=[])}function ca(a,b){var c=jQuery("."+a.hideContainerID).closest(".frm_repeat_sec, .frm_repeat_inline, .frm_repeat_grid");if(c.length){var d=m[a.hideContainerID][b];delete m[a.hideContainerID];var f=a.hideContainerID,e;jQuery.each(c,function(c,g){e="-"+g.id.replace("frm_section_","")+"_container";e=f.replace("_container",e);a.hideContainerID=e;G(a);m[e][b]=d})}}function L(a,b,c,d){-1===jQuery.inArray(a,B)&&(B[c]=a,a="."===b?jQuery("."+a):jQuery(document.getElementById(a)),
15
- "hide"===d&&a.hide(),a.find(".frm_data_field_container").empty())}function O(a,b){a.hide();if(-1===jQuery.inArray(a.attr("id"),B)){B[b.HideField]=a.attr("id");var c=P(a);if(c.length){c.prop("checked",!1).prop("selectedIndex",0);c.not(":checkbox, :radio, select").val("");var d=!1;c.each(function(){"SELECT"==this.tagName&&null!==document.getElementById(this.id+"_chosen")&&jQuery(this).trigger("chosen:updated");(!1===d||0>["checkbox","radio"].indexOf(this.type))&&A(jQuery(this));d=!0})}}}function P(a){return a.find('select[name^="item_meta"], textarea[name^="item_meta"], input[name^="item_meta"]:not([type=hidden])')}
16
- function Q(a,b){var c=P(a);a:{var d=c.length;if(c.is(":checkbox, :radio")){if(c.is(":checked"))break a}else if(c.val())break a;if(d)for(var f=0;f<d;f++){var e=jQuery(c[f]),h=e.data("frmval");if("undefined"!==typeof h)if(!e.is(":checkbox, :radio"))e.val(h),A(e);else if(e.val()==h||jQuery.isArray(h)&&-1!==jQuery.inArray(e.val(),h))e.prop("checked",!0),A(e)}}if(1<c.length)for(d=0;d<c.length;d++)R(b.HideField,jQuery(c[d]));else R(b.HideField,c);a.show()}function A(a,b){"undefined"===typeof b&&(b="dependent");
17
- 1<a.length&&(a=a.eq(0));a.trigger({type:"change",selfTriggered:!0,frmTriggered:b})}function N(a,b,c){if("all"===b.MatchType||!1===m[b.hideContainerID][a])H.push({result:m[b.hideContainerID][a],show:b.Show,match:b.MatchType,FieldName:b.FieldName,HideField:b.HideField,hideContainerID:b.hideContainerID,hideBy:b.hideBy});else{var d="none";if("show"===b.Show){if(!0!==m[b.hideContainerID][a]){S(m[b.hideContainerID][a],b.FieldName,c);return}d=""}a="."===b.hideBy?jQuery("."+b.hideContainerID):jQuery(document.getElementById(b.hideContainerID));
18
- a.length&&("none"===d?O(a,b):Q(a,b))}}function aa(a){jQuery.each(H,function(b,c){delete H[b];if("undefined"!==typeof c&&"undefined"!==typeof c.result){var d=jQuery(c.hideBy+c.hideContainerID),f=c.show;if(d.length){if("any"===c.match&&-1===jQuery.inArray(!0,m[c.hideContainerID])||"all"===c.match&&-1<jQuery.inArray(!1,m[c.hideContainerID]))f="show"===c.show?"hide":"show";"show"===f?(Q(d,c),!1!==typeof c.result&&!0!==typeof c.result&&S(c.result,c.FieldName,a)):O(d,c)}}})}function z(a,b,c){"undefined"===
19
- typeof c&&(c="");jQuery.isArray(c)&&-1<jQuery.inArray(b,c)&&(c=b);-1!==String(b).search(/^\s*(\+|-)?((\d+(\.\d+)?)|(\.\d+))\s*$/)&&(b=parseFloat(b),c=parseFloat(c));return"-1"!=String(b).indexOf("&quot;")&&z(a,b.replace("&quot;",'"'),c)?!0:{"==":function(a,b){return a==b},"!=":function(a,b){return a!=b},"<":function(a,b){return a>b},">":function(a,b){return a<b},LIKE:function(a,b){return b?-1!=b.indexOf(a):0},"not LIKE":function(a,b){return b?-1==b.indexOf(a):1}}[a](b,c)}function S(a,b,c){"getDataOpts"==
20
- a.funcName?ea(a.f,a.sel,b,c):"getData"==a.funcName&&M(a.f,a.sel,0)}function M(a,b,c){var d=document.getElementById(a.hideContainerID),f=jQuery(d).find(".frm_data_field_container");if(0===f.length)return!0;c||f.html('<span class="frm-loading-img"></span>');jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:{action:"frm_fields_ajax_get_data",entry_id:b,field_id:a.LinkedField,current_field:a.HideField,hide_id:a.hideContainerID,nonce:frm_js.nonce},success:function(a){c?f.append(a):f.html(a);var b=f.children("input"),
21
- g=b.val();d.style.display=""===a&&!c||""===g?"none":"";A(b);return!0}})}function ea(a,b,c,d){if(!("stop"==d&&-1<jQuery.inArray(a.HideField,I)&&a.parentField&&"hidden"==a.parentField.attr("type"))){var f=jQuery('input[name^="'+a.hiddenName+'"], select[name^="'+a.hiddenName+'"]:not(":disabled"), textarea[name^="'+a.hiddenName+'"]'),e=[];f.each(function(){"radio"===this.type||"checkbox"===this.type?!0===this.checked&&e.push(jQuery(this).val()):e.push(jQuery(this).val())});if("select"!=a.DataType||"stop"!=
22
- d&&!jQuery("#"+a.hideContainerID+" .frm-loading-img").length||!(-1<jQuery.inArray(a.HideField,I))){0===e.length&&(e="");I.push(a.HideField);var h=document.getElementById(a.hideContainerID),g=jQuery(h).find(".frm_data_field_container");if(0===g.length&&f.length)return r(e,a.HideField,"stop",f),!1;if(""!==a.Value&&!z(a.Condition,a.Value,b))return h.style.display="none",g.html(""),r("",a.HideField,"stop",f),!1;g.html('<span class="frm-loading-img" style="visibility:visible;display:inline;"></span>');
23
- var k=a.DataType;jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:{action:"frm_fields_ajax_data_options",hide_field:c,entry_id:b,selected_field_id:a.LinkedField,field_id:a.HideField,hide_id:a.hideContainerID,nonce:frm_js.nonce},success:function(b){g.html(b);var c=g.find("select, input, textarea"),d=1;"hidden"==c.attr("type")&&(d=c.val());""===b||""===d?(h.style.display="none",e=""):"all"!=a.MatchType&&(h.style.display="");""!==b&&""!==e&&(jQuery.isArray(e)||(b=[],b.push(e),e=b),jQuery.each(e,function(a,
24
- b){if("undefined"!==typeof b&&""!==b)if("checkbox"==k||"radio"==k)1<c.length?c.filter('[value="'+b+'"]').attr("checked","checked"):c.val()==b&&c.attr("checked","checked");else if("select"==k){var d=c.children('option[value="'+b+'"]');d.length?d.prop("selected",!0):e.splice(a,1)}else c.val(b)}));c.hasClass("frm_chzn")&&jQuery().chosen&&jQuery(".frm_chzn").chosen({allow_single_deselect:!0});A(c)}})}}}function E(a,b){if("undefined"!==typeof __FRMCALC){var c=__FRMCALC,d=c.fields[a];if("undefined"!==typeof d)for(var d=
25
- d.total,f=[],e=0,h=d.length;e<h;e++){var g;var k=b;g=c.calc[d[e]].field_id;var l=document.getElementById("frm_field_"+g+"_container");null!==l?g=0===l.offsetHeight?!0:!1:(k=k.closest(".frm_repeat_sec, .frm_repeat_inline, .frm_repeat_grid"),k.length?(k=k[0].id.replace("frm_section_",""),g=document.getElementById("frm_field_"+g+"-"+k+"_container"),g=null!==g&&0===g.offsetHeight?!0:!1):g=!1);g||T(c,d[e],f,b)}}}function T(a,b,c,d){var f=a.calc[b],e=f.calc,h=jQuery(document.getElementById("field_"+b)),
26
- g={triggerField:d,inSection:!1,thisFieldCall:'input[id^="field_'+b+'-"]'};1>h.length&&"undefined"!==typeof d&&(g.inSection=!0,g.thisFieldId=fa(a.fieldsWithCalc,b),h=U(g));e=ga(f,e,a,c,g);a=f.calc_dec;e.indexOf(").toFixed(")&&(c=e.split(").toFixed("),V(c[1])&&(a=c[1],e=e.replace(").toFixed("+a,"")));e=parseFloat(eval(e));"undefined"===typeof e&&(e=0);V(a)&&(e=e.toFixed(a));h.val()!=e&&(h.val(e),A(h,b))}function ga(a,b,c,d,f){for(var e=0,h=a.fields.length;e<h;e++){var g={triggerField:f.triggerField,
27
- thisFieldId:a.fields[e],inSection:f.inSection,valKey:f.inSection+""+a.fields[e],thisField:c.fields[a.fields[e]],thisFieldCall:"input"+c.fieldKeys[a.fields[e]]},k=c;"checkbox"==g.thisField.type||"select"==g.thisField.type?g.thisFieldCall=g.thisFieldCall+":checked,select"+k.fieldKeys[g.thisFieldId]+" option:selected,"+g.thisFieldCall+"[type=hidden]":"radio"==g.thisField.type||"scale"==g.thisField.type?g.thisFieldCall=g.thisFieldCall+":checked,"+g.thisFieldCall+"[type=hidden]":"textarea"==g.thisField.type&&
28
- (g.thisFieldCall=g.thisFieldCall+",textarea"+k.fieldKeys[g.thisFieldId]);d=ha(g,c,d);if("undefined"===typeof d[g.valKey]||isNaN(d[g.valKey]))d[g.valKey]=0;k="["+g.thisFieldId+"]";k=k.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1");b=b.replace(new RegExp(k,"g"),d[g.valKey])}return b}function R(a,b){if("undefined"!==typeof __FRMCALC){var c=__FRMCALC,d=c.fieldsWithCalc[a];"undefined"!==typeof d&&T(c,d,[],b)}}function ha(a,b,c){if("undefined"!==typeof c[a.valKey]&&0!==c[a.valKey])return c;c[a.valKey]=0;
29
- var d;if(!1===a.inSection)d=jQuery(a.thisFieldCall);else if(d=U(a),null===d||"undefined"===typeof d)d=jQuery(a.thisFieldCall);if(null===d||"undefined"===typeof d||1>d.length)return c;d.each(function(){var d;d=a.thisField;var e=!1;if("hidden"==this.type)""!==J(this)&&(e=!0);else if("select"==d.type){var h=this.className;h&&-1<h.indexOf("frm_other_trigger")&&(e=!0)}else("checkbox"==d.type||"radio"==d.type)&&-1<this.id.indexOf("-other_")&&0>this.id.indexOf("-otext")&&(e=!0);e?(e=0,"select"==d.type?"hidden"==
30
- this.type?(d=!1,2<this.name.split("[").length&&(d=!0),d||(e=J(this))):e=jQuery(this).closest(".frm_other_container").find(".frm_other_input").val():"checkbox"!=d.type&&"radio"!=d.type||"hidden"==this.type||(e=J(this)),d=e):d="checkbox"!==this.type&&"radio"!==this.type||!this.checked?jQuery(this).val():this.value;"undefined"===typeof d&&(d="");if("date"==a.thisField.type)d=jQuery.datepicker.parseDate(b.date,d),null!==d&&(c[a.valKey]=Math.ceil(d/864E5));else{""!==d&&0!==d&&(d=d.trim(),d=parseFloat(d.replace(/,/g,
31
- "").match(/-?[\d\.]+$/)));if("undefined"===typeof d||isNaN(d)||""===d)d=0;c[a.valKey]+=d}});return c}function U(a){if("undefined"===typeof a.triggerField)return null;var b=a.triggerField.closest(".frm_repeat_sec, .frm_repeat_inline, .frm_repeat_grid");return b.length?(a=a.thisFieldCall.replace("[id=","[id^="),b.find(a)):null}function J(a){var b="";a=document.getElementById(a.id+"-otext");null!==a&&""!==a.value&&(b=a.value);return b}function W(a,b){jQuery(a).find('input[type="submit"], input[type="button"]').attr("disabled",
32
- "disabled");jQuery(a).find(".frm_ajax_loading").addClass("frm_loading_now");"undefined"==typeof b&&jQuery(a).find('input[name="frm_action"]').val();jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:jQuery(a).serialize()+"&action=frm_entries_"+b+"&nonce="+frm_js.nonce,success:function(b){b=b.replace(/^\s+|\s+$/g,"");0===b.indexOf("{")&&(b=jQuery.parseJSON(b));if(""===b||!b||"0"===b||"object"!=typeof b&&0===b.indexOf("<!DOCTYPE")){var d=document.getElementById("frm_loading");null!==d&&(b=jQuery(a).find("input[type=file]").val(),
33
- "undefined"!=typeof b&&""!==b&&setTimeout(function(){jQuery(d).fadeIn("slow")},2E3));b=jQuery(a).find(".g-recaptcha");b.length&&(1>jQuery(a).find(".frm_next_page").length||1>jQuery(a).find(".frm_next_page").val())&&b.closest(".frm_form_field").replaceWith('<input type="hidden" name="recaptcha_checked" value="'+frm_js.nonce+'">');a.submit()}else if("object"!=typeof b){jQuery(a).find(".frm_ajax_loading").removeClass("frm_loading_now");var f=jQuery(a).find('input[name="form_id"]').val();jQuery(a).closest("#frm_form_"+
34
- f+"_container").replaceWith(b);frmFrontForm.scrollMsg(f);if("function"==typeof frmThemeOverride_frmAfterSubmit){var f=jQuery('input[name="frm_page_order_'+f+'"]').val(),e=jQuery(b).find('input[name="form_id"]').val();frmThemeOverride_frmAfterSubmit(e,f,b,a)}b=jQuery(a).find('input[name="id"]');b.length&&jQuery(document.getElementById("frm_edit_"+b.val())).find("a").addClass("frm_ajax_edited").click()}else{jQuery(a).find('input[type="submit"], input[type="button"]').removeAttr("disabled");jQuery(a).find(".frm_ajax_loading").removeClass("frm_loading_now");
35
- f=!0;jQuery(".form-field").removeClass("frm_blank_field");jQuery(".form-field .frm_error").replaceWith("");var e="",h=!1,g=null,k;for(k in b)if(g=jQuery(a).find(jQuery(document.getElementById("frm_field_"+k+"_container"))),g.length){if(!g.is(":visible")){var l=g.closest(".frm_toggle_container");l.length&&l.prev(".frm_trigger").click()}g.is(":visible")&&(f=!1,""===e&&(frmFrontForm.scrollMsg(k,a,!0),e="#frm_field_"+k+"_container"),jQuery(a).find("#frm_field_"+k+"_container .g-recaptcha").length&&(h=
36
- !0,grecaptcha.reset()),X(g,k,b))}else if("redirect"==k){window.location=b[k];return}!0!==h&&jQuery(a).find(".g-recaptcha").closest(".frm_form_field").replaceWith('<input type="hidden" name="recaptcha_checked" value="'+frm_js.nonce+'">');f&&a.submit()}},error:function(){jQuery(a).find('input[type="submit"], input[type="button"]').removeAttr("disabled");a.submit()}})}function X(a,b,c){a.length&&a.is(":visible")&&(a.addClass("frm_blank_field"),"function"==typeof frmThemeOverride_frmPlaceError?frmThemeOverride_frmPlaceError(b,
37
- c):a.append('<div class="frm_error">'+c[b]+"</div>"))}function ia(){Y(jQuery(this),"clear")}function ja(){Y(jQuery(this),"replace")}function Y(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 ka(){var a=jQuery(this),b=a.data("eid"),c=a.data("fid");a.append('<span class="spinner" style="display:inline"></span>');
38
- 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 la(a,b){google.load("visualization","1.0",{packages:[b],callback:function(){if("table"==b){var c=new google.visualization.DataTable,d=!1;-1!==jQuery.inArray("id",a.options.fields)&&(d=!0,c.addColumn("number",frm_js.id));for(var f=a.fields.length,e="string",h=0,g=f;h<g;h++){var k=a.fields[h],e=Z(k);c.addColumn(e,k.name)}h=
39
- !1;a.options.edit_link&&(h=!0,c.addColumn("string",a.options.edit_link));g=!1;a.options.delete_link&&(g=!0,c.addColumn("string",a.options.delete_link));k=0;if(null!==a.entries){var l=a.entries.length;c.addRows(l);for(var m=0,n=0;n<l;n++){var k=0,p=a.entries[n];d&&(c.setCell(m,k,p.id),k++);for(var q=0,r=f;q<r;q++){var t=a.fields[q],e=Z(t),t=p.metas[t.id];"number"!=e||null!==t&&""!==t?"boolean"==e&&(t=null===t||"false"==t||!1===t?!1:!0):t=0;c.setCell(m,k,t);k++}h&&("undefined"!==typeof p.editLink?c.setCell(m,
40
- k,'<a href="'+p.editLink+'">'+a.options.edit_link+"</a>"):c.setCell(m,k,""),k++);g&&("undefined"!==typeof p.deleteLink?c.setCell(m,k,'<a href="'+p.deleteLink+'" class="frm_delete_link" onclick="return confirm('+a.options.confirm+')">'+a.options.delete_link+"</a>"):c.setCell(m,k,""));m++}}else for(c.addRows(1),h=k=0,g=f;h<g;h++)0<k?c.setCell(0,k,""):c.setCell(0,k,a.options.no_entries),k++;(new google.visualization.Table(document.getElementById("frm_google_table_"+a.options.form_id))).draw(c,a.graphOpts)}else ma(a)}})}
41
- function Z(a){var b="string";if("number"==a.type)b="number";else if("checkbox"==a.type||"select"==a.type){var c=a.options.length;"select"==a.type&&""===a.options[0]&&(c="post_status"==a.field_options.post_field?3:c-1);1==c&&(b="boolean")}return b}function ma(a){var b=new google.visualization.DataTable,c=!1,d=!1,f=a.rows.length;if(0<f)if("table"==a.type){c=!0;b.addRows(a.rows[f-1][0]+1);for(var e=0;e<f;e++)b.setCell(a.rows[e])}else if("undefined"!=typeof a.rows[0].tooltip)for(var d=c=!0,h=0;h<f;h++){e=
42
- a.rows[h].tooltip;delete a.rows[h].tooltip;var g=Object.keys(a.rows[h]).map(function(b){return a.rows[h][b]});a.rows[h]=g;a.rows[h].push(e)}f=a.cols.length;if(c){if(0<f)for(c=0;c<f;c++)e=a.cols[c],b.addColumn(e.type,e.name);d&&(b.addColumn({type:"string",role:"tooltip"}),b.addRows(a.rows))}else{b=[[]];for(d=0;d<f;d++)b[0].push(a.cols[d].name);b=b.concat(a.rows);b=google.visualization.arrayToDataTable(b)}d=a.type.charAt(0).toUpperCase()+a.type.slice(1)+"Chart";(new google.visualization[d](document.getElementById("chart_"+
43
- a.graph_id))).draw(b,a.options)}function na(){var a=jQuery(this),b=a.data("fid");a.wrap('<div class="frm_file_names frm_uploaded_files">');for(var c=a.get(0).files,d=0;d<c.length;d++)0===d?a.after(c[d].name+' <a href="#" class="frm_clear_file_link">'+frm_js.remove+"</a>"):a.after(c[d].name+"<br/>");a.hide();c=a.attr("name");c!="item_meta["+b+"][]"&&c.replace("item_meta[","").replace("[]","").split("][");a.closest(".frm_form_field").find(".frm_uploaded_files:last").after('<input name="'+c+'" data-fid="'+
44
- b+'"class="frm_transparent frm_multiple_file" multiple="multiple" type="file" />')}function oa(){pa(jQuery(this).parent(".frm_uploaded_files"))}function qa(){jQuery(this).parent(".frm_file_names").replaceWith("");return!1}function ra(){var a="frm_section_"+jQuery(this).data("parent")+"-"+jQuery(this).data("key"),b=jQuery(document.getElementById(a)),c=b.find("input, select, textarea");b.fadeOut("slow",function(){b.remove();c.each(function(){if("file"!=this.type){var a=this.name.replace("item_meta[",
45
- "").split("]")[2].replace("[","");E(a,jQuery(this))}})});return!1}function sa(){var a=jQuery(this).data("parent"),b=0;0<jQuery(".frm_repeat_"+a).length&&(b=1+parseInt(jQuery(".frm_repeat_"+a+":last").attr("id").replace("frm_section_"+a+"-","")),"undefined"==typeof b&&(b=1));jQuery.ajax({type:"POST",url:frm_js.ajax_url,dataType:"json",data:{action:"frm_add_form_row",field_id:a,i:b,nonce:frm_js.nonce},success:function(b){var d=b.html,f=jQuery(d).hide().fadeIn("slow");jQuery(".frm_repeat_"+a+":last").after(f);
46
- var e=["other"],h,g="reset";u=f.attr("id");jQuery(d).find("input, select, textarea").each(function(){"file"!=this.type&&(h=this.name.replace("item_meta[","").split("]")[2].replace("[",""),-1==jQuery.inArray(h,e)&&(e.push(h),r("und",h,null,jQuery(this),g),E(h,jQuery(this)),g="persist"))});u="";for(var f=0,k=b.logic.check.length;f<k;f++)-1==jQuery.inArray(b.logic.check[f],e)&&1>jQuery(d).find(".frm_field_"+b.logic.check[f]+"_container").length&&(r("und",b.logic.check[f],null,null,g),g="persist");0<
47
- jQuery(d).find(".star").length&&jQuery(".star").rating();0<jQuery(d).find(".frm_chzn").length&&jQuery().chosen&&jQuery(".frm_chzn").chosen({allow_single_deselect:!0});"function"==typeof frmThemeOverride_frmAddRow&&frmThemeOverride_frmAddRow(a,b)}});return!1}function pa(a){a.fadeOut("slow",function(){a.remove()})}function ta(){var a=jQuery(this).data("frmtoggle");jQuery(a).is(":visible")?jQuery(a).slideUp("fast"):jQuery(a).slideDown("fast");return!1}function fa(a,b){for(var c in a)if(a.hasOwnProperty(c)&&
48
- a[c]===b)return c;return null}function V(a){return!jQuery.isArray(a)&&0<=a-parseFloat(a)+1}function da(a,b){var c=[];if("undefined"==typeof document.querySelector)jQuery("#"+a+' input[type=checkbox]:checked, input[type=hidden][name^="'+b+'"]').each(function(){c.push(this.value)});else for(var d=document.querySelectorAll("#"+a+' input[type=checkbox], input[type=hidden][name^="'+b+'"]'),f=0;f<d.length;f++)("checkbox"==d[f].type&&d[f].checked||"hidden"==d[f].type)&&c.push(d[f].value);return c}var m=
49
- [],H=[],B=[],I=[],u="",K="",D=[];return{init:function(){jQuery(document).on("click",".frm_trigger",n);var a=jQuery(".frm_blank_field");a.length&&a.closest(".frm_toggle_container").prev(".frm_trigger").click();jQuery.isFunction(jQuery.fn.placeholder)?jQuery(".frm-show-form input, .frm-show-form textarea").placeholder():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",
50
- ia);jQuery(document).on("blur",".frm_toggle_default",ja);jQuery(".frm_toggle_default").blur();jQuery(document.getElementById("frm_resend_email")).click(ka);jQuery(document).on("change",".frm_multiple_file",na);jQuery(document).on("click",".frm_clear_file_link",qa);jQuery(document).on("click",".frm_remove_link",oa);jQuery(document).on("focusin","input[data-frmmask]",function(){jQuery(this).mask(jQuery(this).data("frmmask").toString())});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"]',
51
- w);jQuery(document).on("click",'.frm-show-form input[type="submit"], .frm-show-form input[name="frm_prev_page"], .frm-show-form .frm_save_draft',l);jQuery(document).on("change",'.frm_other_container input[type="checkbox"], .frm_other_container input[type="radio"], .frm_other_container select',v);jQuery(document).on("change","input[type=file].frm_transparent",p);jQuery(document).on("click",".frm_remove_form_row",ra);jQuery(document).on("click",".frm_add_form_row",sa);jQuery("a[data-frmtoggle]").click(ta);
52
- jQuery(".frm_month_heading, .frm_year_heading").click(function(){var a=jQuery(this).children(".ui-icon-triangle-1-e, .ui-icon-triangle-1-s");a.hasClass("ui-icon-triangle-1-e")?(a.addClass("ui-icon-triangle-1-s").removeClass("ui-icon-triangle-1-e"),jQuery(this).next(".frm_toggle_container").fadeIn("slow")):(a.addClass("ui-icon-triangle-1-e").removeClass("ui-icon-triangle-1-s"),jQuery(this).next(".frm_toggle_container").hide())})},submitForm:function(a){a.preventDefault();jQuery(this).find(".wp-editor-wrap").length&&
53
- "undefined"!=typeof tinyMCE&&tinyMCE.triggerSave();K=jQuery(this).find('input[name="frm_action"]').val();D=[];frmFrontForm.getAjaxFormErrors(this);if(0===Object.keys(D).length)W(this,K);else{jQuery(".form-field").removeClass("frm_blank_field");jQuery(".form-field .frm_error").replaceWith("");for(var b in D)a=jQuery(this).find(jQuery("#frm_field_"+b+"_container")),X(a,b,D)}},getAjaxFormErrors:function(a){"function"==typeof frmThemeOverride_jsErrors&&(D=frmThemeOverride_jsErrors(K,a))},checkFormErrors:function(a,
54
- b){W(a,b)},scrollToID:function(a){a=jQuery(document.getElementById(a).offset());window.scrollTo(a.left,a.top)},scrollMsg:function(a,b,c){var d="";if(d="undefined"==typeof b?jQuery(document.getElementById("frm_form_"+a+"_container")).offset().top:jQuery(b).find(document.getElementById("frm_field_"+a+"_container")).offset().top){d-=frm_js.offset;a=jQuery("html").css("margin-top");b=jQuery("body").css("margin-top");if(a||b)d=d-parseInt(a)-parseInt(b);if(d&&window.innerHeight&&(a=document.documentElement.scrollTop||
55
- document.body.scrollTop,d>a+window.innerHeight||d<a))return"undefined"===typeof c?jQuery(window).scrollTop(d):jQuery("html,body").animate({scrollTop:d},500),!1}},hideCondFields:function(a){a=JSON.parse(a);for(var b=0,c=a.length;b<c;b++){var d=document.getElementById("frm_field_"+a[b]+"_container");null!==d?d.style.display="none":jQuery(".frm_field_"+a[b]+"_container").hide()}},checkDependent:function(a){a=JSON.parse(a);for(var b="reset",c=0,d=a.length;c<d;c++)r("und",a[c],null,null,b),b="persist"},
56
- loadGoogle:function(){if("undefined"!==typeof google&&google&&google.load)for(var a=__FRMTABLES,b=Object.keys(a),c=0;c<b.length;c++)for(var d=a[b[c]],f=b[c],e=0;e<d.length;e++)la(d[e],f);else setTimeout(frmFrontForm.loadGoogle,30)},removeUsedTimes:function(a,b){var c=jQuery(a).parents("form:first").find('input[name="id"]');jQuery.ajax({type:"POST",url:frm_js.ajax_url,dataType:"json",data:{action:"frm_fields_ajax_time_options",time_field:b,date_field:a.id,entry_id:c?c.val():"",date:jQuery(a).val(),
57
- nonce:frm_js.nonce},success:function(a){var c=jQuery(document.getElementById(b));c.find("option").removeAttr("disabled");if(a&&""!==a)for(var e in a)c.find('option[value="'+e+'"]').attr("disabled","disabled")}})},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();
58
- jQuery(document).ready(function(l){frmFrontForm.init()});
59
- function frmEditEntry(l,n,p,v,w,y){var r=jQuery(document.getElementById("frm_edit_"+l)),q=r.html(),x=jQuery(document.getElementById(n+l)),C=x.html();x.html('<span class="frm-loading-img" id="'+n+l+'"></span><div class="frm_orig_content" style="display:none">'+C+"</div>");jQuery.ajax({type:"POST",url:frm_js.ajax_url,dataType:"html",data:{action:"frm_entries_edit_entry_ajax",post_id:p,entry_id:l,id:v,nonce:frm_js.nonce},success:function(C){x.children(".frm-loading-img").replaceWith(C);r.replaceWith('<span id="frm_edit_'+
60
- l+'"><a onclick="frmCancelEdit('+l+",'"+n+"','"+frmFrontForm.escapeHtml(q)+"',"+p+","+v+",'"+y+'\')" class="'+y+'">'+w+"</a></span>")}})}
61
- function frmCancelEdit(l,n,p,v,w,y){var r=jQuery(document.getElementById("frm_edit_"+l)),q=r.find("a"),x=q.html();q.hasClass("frm_ajax_edited")||(q=jQuery(document.getElementById(n+l)),q.children(".frm_forms").replaceWith(""),q.children(".frm_orig_content").fadeIn("slow").removeClass("frm_orig_content"));r.replaceWith('<a id="frm_edit_'+l+'" class="frm_edit_link '+y+'" href="javascript:frmEditEntry('+l+",'"+n+"',"+v+","+w+",'"+frmFrontForm.escapeHtml(x)+"','"+y+"')\">"+p+"</a>")}
62
- function frmUpdateField(l,n,p,v,w){jQuery(document.getElementById("frm_update_field_"+l+"_"+n)).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:l,field_id:n,value:p,nonce:frm_js.nonce},success:function(){""===v.replace(/^\s+|\s+$/g,"")?jQuery(document.getElementById("frm_update_field_"+l+"_"+n+"_"+w)).fadeOut("slow"):jQuery(document.getElementById("frm_update_field_"+l+"_"+n+"_"+w)).replaceWith(v)}})}
63
- function frmDeleteEntry(l,n){jQuery(document.getElementById("frm_delete_"+l)).replaceWith('<span class="frm-loading-img" id="frm_delete_'+l+'"></span>');jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:{action:"frm_entries_destroy",entry:l,nonce:frm_js.nonce},success:function(p){"success"==p.replace(/^\s+|\s+$/g,"")?jQuery(document.getElementById(n+l)).fadeOut("slow"):jQuery(document.getElementById("frm_delete_"+l)).replaceWith(p)}})}
64
- function frmOnSubmit(l){console.warn("DEPRECATED: function frmOnSubmit in v2.0 use frmFrontForm.submitForm");frmFrontForm.submitForm(l,this)}
65
- function frm_resend_email(l,n){console.warn("DEPRECATED: function frm_resend_email in v2.0");$link=jQuery(document.getElementById("frm_resend_email"));$link.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:l,form_id:n,nonce:frm_js.nonce},success:function(l){$link.replaceWith(l)}})};
1
+ function frmFrontFormJS(){"use strict";function setNextPage(e){var t=jQuery(this),i=t.attr("type");"submit"!==i&&e.preventDefault();var r=t.parents("form:first"),n="",a="",l=this.name;"frm_prev_page"===l||-1!==this.className.indexOf("frm_prev_page")?n=jQuery(r).find(".frm_next_page").attr("id").replace("frm_next_p_",""):("frm_save_draft"===l||-1!==this.className.indexOf("frm_save_draft"))&&(a=1),jQuery(".frm_next_page").val(n),jQuery(".frm_saving_draft").val(a),"submit"!==i&&r.trigger("submit")}function toggleSection(){jQuery(this).parent().children(".frm_toggle_container").slideToggle("fast"),jQuery(this).toggleClass("active").children(".ui-icon-triangle-1-e, .ui-icon-triangle-1-s").toggleClass("ui-icon-triangle-1-s ui-icon-triangle-1-e")}function showFileUploadText(){this.className=this.className.replace("frm_transparent","");var e=this.parentNode.getElementsByTagName("a")[0].className;-1==e.indexOf("frm_clear_file_link")&&(e+=" frm_hidden")}function showOtherText(){var e=this.type,t=!1,i=!1;if("select-one"===e){i=!0;var r=this.options[this.selectedIndex];"frm_other_trigger"===r.className&&(t=!0)}else if("select-multiple"===e){i=!0;var n=this.options;t=!1;for(var a=0;a<n.length;a++)if("frm_other_trigger"===n[a].className&&n[a].selected){t=!0;break}}if(i){var l=jQuery(this).parent().children(".frm_other_input");l.length&&(t?l[0].className=l[0].className.replace("frm_pos_none",""):(l[0].className.indexOf("frm_pos_none")<1&&(l[0].className=l[0].className+" frm_pos_none"),l[0].value=""))}else"radio"===e?jQuery(this).is(":checked")&&(jQuery(this).closest(".frm_radio").children(".frm_other_input").removeClass("frm_pos_none"),jQuery(this).closest(".frm_radio").siblings().children(".frm_other_input").addClass("frm_pos_none").val("")):"checkbox"===e&&(this.checked?jQuery(this).closest(".frm_checkbox").children(".frm_other_input").removeClass("frm_pos_none"):jQuery(this).closest(".frm_checkbox").children(".frm_other_input").addClass("frm_pos_none").val(""))}function maybeCheckDependent(e){var t=getFieldId(this);if(t&&"undefined"!=typeof t){var i="reset";if(e.frmTriggered){if(e.frmTriggered==t)return;i="persist"}checkDependentField(t,null,jQuery(this),i),doCalculation(t,jQuery(this))}}function getFieldId(e,t){var i="";i=e instanceof jQuery?e.attr("name"):e.name;var r=i.replace("item_meta[","").replace("[]","").split("]");if(r.length<1)return 0;r=r.filter(function(e){return""!==e});var n=r[0],a=!1;return 1===r.length||"[form"==r[1]?n:(jQuery('input[name="item_meta['+n+'][form]"]').length&&(n=r[2].replace("[",""),a=!0),"other"===n&&(n=a?r[3].replace("[",""):r[1].replace("[","")),t===!0&&(n=n+"-"+r[0]+"-"+r[1].replace("[","")),n)}function checkDependentField(e,t,i,r){var n=getRulesForField(e);if("undefined"!=typeof n){("undefined"==typeof t||null===t)&&(t="go"),"persist"!==r&&(show_fields=[],hidden_fields=[]);for(var a=maybeSetRowId(i),l=n.length,d=0,o=l;o>d;d++)n[d].FieldName===e?hideOrShowField(d,n[d],t,i):hideOrShowField(d,n[d],t),d===l-1&&(hideFieldLater(t),a&&(addingRow=""))}}function maybeSetRowId(e){var t=!1;if(""===addingRow&&"undefined"!=typeof e&&null!==e){e=maybeGetFirstElement(e);var i=e.closest(".frm_repeat_sec, .frm_repeat_inline, .frm_repeat_grid");"undefined"!=typeof i&&"undefined"!=typeof i.attr("id")&&(addingRow=i.attr("id"),t=!0)}return t}function getRulesForField(e){if("undefined"!=typeof __FRMRULES&&"undefined"!=typeof __FRMRULES[e]){var t=compileRules(__FRMRULES[e]);return t}}function compileRules(e){for(var t=[],i=0,r=e.length;r>i;i++){var n=e[i];if("undefined"!=typeof n)for(var a=0,l=n.Conditions.length;l>a;a++){var d=n.Conditions[a];d.HideField=n.Setting.FieldName,d.MatchType=n.MatchType,d.Show=n.Show,t.push(d)}}return t}function hideOrShowField(e,t,i,r){if(t.inputName="item_meta["+t.FieldName+"]",t.hiddenName="item_meta["+t.HideField+"]",t.containerID="frm_field_"+t.FieldName+"_container",t.hideContainerID="frm_field_"+t.HideField+"_container",""!==addingRow)return void checkRepeatingFieldInSingleRow(e,t,i,addingRow);if(("undefined"==typeof r||null===r)&&(r=jQuery('input[name^="'+t.inputName+'"], textarea[name^="'+t.inputName+'"], select[name^="'+t.inputName+'"]'),r.length<1))return void checkLogicForTwoRepeatingFields(e,t,i);var n=getBasicEnteredValue(t);return isRepeatingFieldById(t.HideField)?void checkLogicForRepeatingHideField(e,t,n,i):(setEmptyKeyInShowFieldsArray(t),updateShowFields(e,t,n),void hideFieldNow(e,t,i))}function checkRepeatingFieldInSingleRow(e,t,i,r){isRepeatingFieldById(t.FieldName)&&(t.inputName=getRepeatingFieldName(t.FieldName,r),t.containerID=getRepeatingFieldHtmlId(t.FieldName,r)),t.hideContainerID=getRepeatingFieldHtmlId(t.HideField,r);var n=getBasicEnteredValue(t);setEmptyKeyInShowFieldsArray(t),updateShowFields(e,t,n),hideFieldNow(e,t,i)}function checkLogicForTwoRepeatingFields(e,t,i){for(var r=document.getElementsByClassName("frm_field_"+t.FieldName+"_container"),n=0;n<r.length;n++){t.inputName=getRepeatingFieldName(t.FieldName,r[n].id),t.containerID=r[n].id,t.hideContainerID=r[n].id.replace(t.FieldName,t.HideField);var a=getBasicEnteredValue(t);setEmptyKeyInShowFieldsArray(t),updateShowFields(e,t,a),hideFieldNow(e,t,i)}}function checkLogicForRepeatingHideField(e,t,i,r){for(var n=document.getElementsByClassName("frm_field_"+t.HideField+"_container"),a=0;a<n.length;a++)t.hideContainerID=n[a].id,setEmptyKeyInShowFieldsArray(t),updateShowFields(e,t,i),hideFieldNow(e,t,r)}function getBasicEnteredValue(e){var t="";if("checkbox"===e.Type||"data-checkbox"===e.Type){var i=getCheckedVal(e.containerID,e.inputName);return t=i.length?i:""}return t=jQuery('input[name="'+e.inputName+'"][type="hidden"]').val(),"undefined"!=typeof t?t:(t="radio"==e.Type||"data-radio"===e.Type?jQuery('input[name="'+e.inputName+'"]:checked').val():"select"===e.Type||"data-select"===e.Type?jQuery('select[name^="'+e.inputName+'"]').val():jQuery('input[name="'+e.inputName+'"]').val(),"undefined"==typeof t&&(t=""),t)}function setEmptyKeyInShowFieldsArray(e){"undefined"==typeof show_fields[e.hideContainerID]&&(show_fields[e.hideContainerID]=[])}function updateShowFields(e,t,i){show_fields[t.hideContainerID][e]=null===i||""===i||i.length<1?!1:{funcName:"getDataOpts",f:t,sel:i},"checkbox"===t.Type||"data-checkbox"===t.Type&&"undefined"==typeof t.LinkedField?updateShowFieldsForCheckbox(e,t,i):"undefined"!=typeof t.LinkedField&&0===t.Type.indexOf("data-")?updateShowFieldsForDynamicField(e,t,i):"undefined"==typeof t.Value&&0===t.Type.indexOf("data")?(t.Value=""===i?"1":i,show_fields[t.hideContainerID][e]=operators(t.Condition,t.Value,i),t.Value=void 0):show_fields[t.hideContainerID][e]=operators(t.Condition,t.Value,i)}function updateShowFieldsForCheckbox(e,t,i){show_fields[t.hideContainerID][e]=!1;var r=!1;if(""!==i){"!="===t.Condition&&(show_fields[t.hideContainerID][e]=!0);for(var n=0;n<i.length;n++)r=operators(t.Condition,t.Value,i[n]),"!="===t.Condition?show_fields[t.hideContainerID][e]===!0&&r===!1&&(show_fields[t.hideContainerID][e]=!1):show_fields[t.hideContainerID][e]===!1&&r&&(show_fields[t.hideContainerID][e]=!0)}else r=operators(t.Condition,t.Value,""),show_fields[t.hideContainerID][e]===!1&&r&&(show_fields[t.hideContainerID][e]=!0)}function updateShowFieldsForDynamicField(e,t,i){("undefined"==typeof t.DataType||"data"===t.DataType)&&(""===i?hideAndClearDynamicField(t.hideContainerID,t.HideField,"hide"):"data-radio"===t.Type?show_fields[t.hideContainerID][e]="undefined"==typeof t.DataType?operators(t.Condition,t.Value,i):{funcName:"getData",f:t,sel:i}:"data-checkbox"===t.Type||"data-select"===t.Type&&isNotEmptyArray(i)?(hideAndClearDynamicField(t.hideContainerID,t.HideField,"show"),show_fields[t.hideContainerID][e]=!0,getData(t,i,0)):"data-select"===t.Type&&(show_fields[t.hideContainerID][e]={funcName:"getData",f:t,sel:i}))}function hideFieldNow(e,t,i){if("all"===t.MatchType||show_fields[t.hideContainerID][e]===!1)return void hide_later.push({result:show_fields[t.hideContainerID][e],show:t.Show,match:t.MatchType,FieldName:t.FieldName,HideField:t.HideField,hideContainerID:t.hideContainerID});var r="none";if("show"===t.Show){if(show_fields[t.hideContainerID][e]!==!0)return void showField(show_fields[t.hideContainerID][e],t.FieldName,i);r=""}var n=jQuery(document.getElementById(t.hideContainerID));"none"==r?routeToHideFieldAndClearVal(n,t):routeToShowFieldAndSetVal(n,t)}function hideFieldLater(e){jQuery.each(hide_later,function(t,i){if(delete hide_later[t],"undefined"!=typeof i&&"undefined"!=typeof i.result){var r=jQuery("#"+i.hideContainerID),n=i.show;("any"===i.match&&-1===jQuery.inArray(!0,show_fields[i.hideContainerID])||"all"===i.match&&jQuery.inArray(!1,show_fields[i.hideContainerID])>-1)&&(n="show"===i.show?"hide":"show"),"show"===n?(routeToShowFieldAndSetVal(r,i),typeof i.result!==!1&&typeof i.result!==!0&&showField(i.result,i.FieldName,e)):routeToHideFieldAndClearVal(r,i)}})}function routeToHideFieldAndClearVal(e,t){if(e.length)hideFieldAndClearValue(e,t);else{var i=getFieldName(t.HideField,t.hideContainerID),r=jQuery('input[name^="'+i+'"]');clearValueForInputs(r)}addToHideFields(t.hideContainerID)}function hideFieldAndClearValue(e,t){if(e.hide(),-1===jQuery.inArray(e.attr("id"),hidden_fields)){var i=t.HideField;hidden_fields[i]=e.attr("id");var r=getInputsInContainer(e);r.length&&clearValueForInputs(r)}}function clearValueForInputs(e){e.prop("checked",!1).prop("selectedIndex",0),e.not(":checkbox, :radio, select").val("");var t=!1;e.each(function(){if("SELECT"==this.tagName){var e=document.getElementById(this.id+"_chosen");null!==e&&jQuery(this).trigger("chosen:updated")}(t===!1||["checkbox","radio"].indexOf(this.type)<0)&&triggerChange(jQuery(this)),t=!0})}function addToHideFields(e){var t=document.getElementById("frm_hide_fields"),i=t.value;i=i?JSON.parse(i):[],i.indexOf(e)>-1||(i.push(e),i=JSON.stringify(i),t.value=i)}function hideAndClearDynamicField(e,t,i){-1===jQuery.inArray(e,hidden_fields)&&(hidden_fields[t]=e,e=jQuery(document.getElementById(e)),"hide"===i&&e.hide(),e.find(".frm_data_field_container").empty())}function routeToShowFieldAndSetVal(e,t){if(e.length)showFieldAndSetValue(e,t);else{var i=getFieldName(t.HideField,t.hideContainerID),r=jQuery('input[name^="'+i+'"]');setValForInputs(r)}removeFromHideFields(t.hideContainerID)}function showFieldAndSetValue(e){var t=getInputsInContainer(e);setValForInputs(t),e.show()}function setValForInputs(e){if(e.length)for(var t=0;t<e.length;t++)setDefaultValue(jQuery(e[t])),maybeDoCalcForSingleField(e[t])}function setDefaultValue(e){var t=e.length;if(e.is(":checkbox, :radio")){if(e.is(":checked"))return}else if(e.val())return;if(t)for(var i=0,r=t;r>i;i++){var n=jQuery(e[i]),a=n.data("frmval");"undefined"!=typeof a&&(n.is(":checkbox, :radio")?(n.val()==a||jQuery.isArray(a)&&-1!==jQuery.inArray(n.val(),a))&&(n.prop("checked",!0),triggerChange(n)):(n.val(a),triggerChange(n)))}}function removeFromHideFields(e){var t=document.getElementById("frm_hide_fields"),i=t.value;if(i){i=JSON.parse(i);var r=i.indexOf(e);r>-1&&(i.splice(r,1),i=JSON.stringify(i),t.value=i)}}function triggerChange(e,t){"undefined"==typeof t&&(t="dependent"),e.length>1&&(e=e.eq(0)),e.trigger({type:"change",selfTriggered:!0,frmTriggered:t})}function operators(e,t,i){if("undefined"==typeof i&&(i=""),jQuery.isArray(i)&&jQuery.inArray(t,i)>-1&&(i=t),-1!==String(t).search(/^\s*(\+|-)?((\d+(\.\d+)?)|(\.\d+))\s*$/)&&(t=parseFloat(t),i=parseFloat(i)),"-1"!=String(t).indexOf("&quot;")&&operators(e,t.replace("&quot;",'"'),i))return!0;var r={"==":function(e,t){return e==t},"!=":function(e,t){return e!=t},"<":function(e,t){return e>t},">":function(e,t){return t>e},LIKE:function(e,t){return t?-1!=t.indexOf(e):0},"not LIKE":function(e,t){return t?-1==t.indexOf(e):1}};return r[e](t,i)}function showField(e,t,i){"getDataOpts"==e.funcName?getDataOpts(e.f,e.sel,t,i):"getData"==e.funcName&&getData(e.f,e.sel,0)}function getData(e,t,i){var r=document.getElementById(e.hideContainerID),n=jQuery(r).find(".frm_data_field_container");return 0===n.length?!0:(i||n.html('<span class="frm-loading-img"></span>'),void jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:{action:"frm_fields_ajax_get_data",entry_id:t,field_id:e.LinkedField,current_field:e.HideField,hide_id:e.hideContainerID,nonce:frm_js.nonce},success:function(e){i?n.append(e):n.html(e);var t=n.children("input"),a=t.val();return r.style.display=""===e&&!i||""===a?"none":"",triggerChange(t),!0}}))}function getDataOpts(e,t,i,r){if(!("stop"==r&&jQuery.inArray(e.HideField,frm_checked_dep)>-1&&e.parentField&&"hidden"==e.parentField.attr("type"))){var n=jQuery("#"+e.hideContainerID).find('select[name^="item_meta"], textarea[name^="item_meta"], input[name^="item_meta"]'),a=getPrevFieldValue(n),l=n.data("frmval");if("select"!=e.DataType||"stop"!=r&&!jQuery("#"+e.hideContainerID+" .frm-loading-img").length||!(jQuery.inArray(e.HideField,frm_checked_dep)>-1)){frm_checked_dep.push(e.HideField);var d=document.getElementById(e.hideContainerID),o=jQuery(d).find(".frm_data_field_container");if(0===o.length&&n.length)return checkDependentField(e.HideField,"stop",n),!1;if(""!==e.Value){var f=operators(e.Condition,e.Value,t);if(!f)return d.style.display="none",o.html(""),checkDependentField(e.HideField,"stop",n),!1}o.html('<span class="frm-loading-img" style="visibility:visible;display:inline;"></span>');var s=(e.hiddenName,e.DataType);jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:{action:"frm_fields_ajax_data_options",hide_field:i,entry_id:t,selected_field_id:e.LinkedField,field_id:e.HideField,default_value:l,hide_id:e.hideContainerID,nonce:frm_js.nonce},success:function(t){o.html(t);var i=o.find("select, input, textarea"),r=1;if("hidden"==i.attr("type")&&(r=i.val()),""===t||""===r?(d.style.display="none",a=""):"all"!=e.MatchType&&(d.style.display=""),""!==t)if(""!==a){if(!jQuery.isArray(a)){var n=[];n.push(a),a=n}jQuery.each(a,function(e,t){if("undefined"!=typeof t&&""!==t)if("checkbox"==s||"radio"==s)i.length>1?i.filter('[value="'+t+'"]').attr("checked","checked"):i.val()==t&&i.attr("checked","checked");else if("select"==s){var r=i.children('option[value="'+t+'"]');r.length?r.prop("selected",!0):a.splice(e,1)}else i.val(t)})}else setDefaultValue(getInputsInContainer(o));i.hasClass("frm_chzn")&&jQuery().chosen&&jQuery(".frm_chzn").chosen({allow_single_deselect:!0}),triggerChange(i)}})}}}function getPrevFieldValue(e){var t=[],i="";return e.each(function(){i=this.value,"radio"===this.type||"checkbox"===this.type?this.checked===!0&&t.push(i):""!==i&&t.push(i)}),0===t.length&&(t=""),t}function doCalculation(e,t){if("undefined"!=typeof __FRMCALC){var i=__FRMCALC,r=i.fields[e];if("undefined"!=typeof r)for(var n=r.total,a=n.length,l=[],d=0,o=a;o>d;d++)fieldIsConditionallyHidden(i.calc[n[d]].field_id,t.attr("name"))||doSingleCalculation(i,n[d],l,t)}}function fieldIsConditionallyHidden(e,t){var i=document.getElementById("frm_hide_fields").value;if(!i)return!1;i=JSON.parse(i);var r=e;if(isRepeatingFieldByName(t)){var n=t.replace("item_meta","").replace(/\[/g,"").split("]");r=e+"-"+n[0]+"-"+n[1]}if(i.indexOf("frm_field_"+r+"_container")>-1)return!0;var a=getHelpers();return a&&null!==a[e]&&i.indexOf("frm_field_"+a[e]+"_container")>-1?!0:!1}function isRepeatingFieldByName(e){var t=!1,i=e.split("[");return i.length>=4&&(t=!0),t}function doSingleCalculation(all_calcs,field_key,vals,triggerField){var thisCalc=all_calcs.calc[field_key],thisFullCalc=thisCalc.calc,totalField=jQuery(document.getElementById("field_"+field_key)),fieldInfo={triggerField:triggerField,inSection:!1,thisFieldCall:'input[id^="field_'+field_key+'-"]'};totalField.length<1&&"undefined"!=typeof triggerField&&(fieldInfo.inSection=!0,fieldInfo.thisFieldId=objectSearch(all_calcs.fieldsWithCalc,field_key),totalField=getSiblingField(fieldInfo)),thisFullCalc=getValsForSingleCalc(thisCalc,thisFullCalc,all_calcs,vals,fieldInfo);var dec=thisCalc.calc_dec;if(thisFullCalc.indexOf(").toFixed(")){var calcParts=thisFullCalc.split(").toFixed(");isNumeric(calcParts[1])&&(dec=calcParts[1],thisFullCalc=thisFullCalc.replace(").toFixed("+dec,""))}var total=parseFloat(eval(thisFullCalc));"undefined"==typeof total&&(total=0),isNumeric(dec)&&(total=total.toFixed(dec)),totalField.val()!=total&&(totalField.val(total),triggerChange(totalField,field_key))}function getValsForSingleCalc(e,t,i,r,n){for(var a=e.fields.length,l=0,d=a;d>l;l++){var o={triggerField:n.triggerField,thisFieldId:e.fields[l],inSection:n.inSection,valKey:n.inSection+""+e.fields[l],thisField:i.fields[e.fields[l]],thisFieldCall:"input"+i.fieldKeys[e.fields[l]]};o=getCallForField(o,i),r=getCalcFieldId(o,i,r),("undefined"==typeof r[o.valKey]||isNaN(r[o.valKey]))&&(r[o.valKey]=0);var f="["+o.thisFieldId+"]";f=f.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1"),t=t.replace(new RegExp(f,"g"),r[o.valKey])}return t}function getCallForField(e,t){return"checkbox"==e.thisField.type||"select"==e.thisField.type?e.thisFieldCall=e.thisFieldCall+":checked,select"+t.fieldKeys[e.thisFieldId]+" option:selected,"+e.thisFieldCall+"[type=hidden]":"radio"==e.thisField.type||"scale"==e.thisField.type?e.thisFieldCall=e.thisFieldCall+":checked,"+e.thisFieldCall+"[type=hidden]":"textarea"==e.thisField.type&&(e.thisFieldCall=e.thisFieldCall+",textarea"+t.fieldKeys[e.thisFieldId]),e}function maybeDoCalcForSingleField(e){if("undefined"!=typeof __FRMCALC){var t=__FRMCALC,i=getFieldKey(e.id,e.name),r=maybeGetTriggerField(e);if(void 0!==t.calc[i]){var n=[];doSingleCalculation(t,i,n,r)}}}function getFieldKey(e,t){var i=e.replace("field_","");if(isRepeatingFieldByName(t)){for(var r=i.split("-"),n="",a=0;a<r.length-1;a++)n+=r[a];i=n}return i}function maybeGetTriggerField(e){var t=null;return isRepeatingFieldByName(e.name)&&(t=jQuery(e).closest(".frm_form_field")),t}function getCalcFieldId(e,t,i){if("undefined"!=typeof i[e.valKey]&&0!==i[e.valKey])return i;i[e.valKey]=0;var r;return e.inSection===!1?r=jQuery(e.thisFieldCall):(r=getSiblingField(e),(null===r||"undefined"==typeof r)&&(r=jQuery(e.thisFieldCall))),null===r||"undefined"==typeof r||r.length<1?i:(r.each(function(){var r=getOptionValue(e.thisField,this);if("date"==e.thisField.type){var n=getDateFieldValue(t.date,r);null!==n&&(i[e.valKey]=Math.ceil(n/864e5))}else{var a=r;""!==a&&0!==a&&(a=a.trim(),a=parseFloat(a.replace(/,/g,"").match(/-?[\d\.]+$/))),("undefined"==typeof a||isNaN(a)||""===a)&&(a=0),i[e.valKey]+=a}}),i)}function getDateFieldValue(e,t){var i=0;if(t)if("undefined"==typeof jQuery.datepicker){var r="-";e.indexOf("/")>-1&&(r="/");var n,a,l,d=e.split(r),o=t.split(r);n=a=l="";for(var f=0;f<d.length;f++)if("y"==d[f]){var s=(new Date).getFullYear()+15,c=s.toString().substr(2,2);n=o[f]>c?"19"+o[f]:"20"+o[f]}else"yy"==d[f]?n=o[f]:"m"==d[f]||"mm"==d[f]?(a=o[f],a.length<2&&(a="0"+a)):("d"==d[f]||"dd"==d[f])&&(l=o[f],l.length<2&&(l="0"+l));i=Date.parse(n+"-"+a+"-"+l)}else i=jQuery.datepicker.parseDate(e,t);else;return i}function getSiblingField(e){if("undefined"==typeof e.triggerField)return null;var t=e.triggerField.closest(".frm_repeat_sec, .frm_repeat_inline, .frm_repeat_grid");if(t.length){var i=e.thisFieldCall.replace("[id=","[id^=");return t.find(i)}return null}function getOptionValue(e,t){var i;return i=isOtherOption(e,t)?getOtherValueAnyField(e,t):"checkbox"!==t.type&&"radio"!==t.type||!t.checked?jQuery(t).val():t.value,"undefined"==typeof i&&(i=""),i}function isOtherOption(e,t){var i=!1;if("hidden"==t.type)""!==getOtherValueLimited(t)&&(i=!0);else if("select"==e.type){var r=t.className;r&&r.indexOf("frm_other_trigger")>-1&&(i=!0)}else("checkbox"==e.type||"radio"==e.type)&&t.id.indexOf("-other_")>-1&&t.id.indexOf("-otext")<0&&(i=!0);return i}function getOtherValueLimited(e){var t="",i=document.getElementById(e.id+"-otext");return null!==i&&""!==i.value&&(t=i.value),t}function getOtherValueAnyField(e,t){var i=0;return"select"==e.type?"hidden"==t.type?isCurrentOptRepeating(t)||(i=getOtherValueLimited(t)):i=getOtherSelectValue(t):("checkbox"==e.type||"radio"==e.type)&&("hidden"==t.type||(i=getOtherValueLimited(t))),i}function isCurrentOptRepeating(e){var t=!1,i=e.name.split("[");return i.length>2&&(t=!0),t}function getOtherSelectValue(e){return jQuery(e).closest(".frm_other_container").find(".frm_other_input").val()}function validateForm(e,t){var i=[],r=jQuery(t).find(".frm_required_field input, .frm_required_field select, .frm_required_field textarea");if(r.length)for(var n=0,a=r.length;a>n;n++)i=checkRequiredField(r[n],i);var l=jQuery(t).find("input[type=email]");if(l.length)for(var d=0,o=l.length;o>d;d++)i=checkEmailField(l[d],i,l);var f=jQuery(t).find("input[type=number]");if(f.length)for(var s=0,c=f.length;c>s;s++)i=checkNumberField(f[s],i);return i}function validateField(e,t){var i=[],r=jQuery(t).closest(".frm_form_field");if(r.hasClass(".frm_required_field")&&(i=checkRequiredField(t,i)),i.length<1&&"email"==t.type){var n=jQuery(t).closest("form").find("input[type=email]");i=checkEmailField(t,i,n)}if(Object.keys(i).length>0)for(var a in i)addFieldError(r,a,i);else removeFieldError(r)}function checkRequiredField(e,t,i){return""===jQuery(e).val()&&(i=getFieldId(e,!0),t[i]=""),t}function checkEmailField(e,t,i){var r=e.value,n=getFieldId(e,!0),a=0===n.indexOf("conf_");if(""!==r||a){var l=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;if(l.test(r)===!1)t[n]="",a&&(t[n.replace("conf_","")]="");else if(a){var d=e.name.replace("conf_",""),o=i.filter('[name="'+d+'"]').val();o!==r&&(t[n]="",t[n.replace("conf_","")]="")}}return t}function checkNumberField(e,t){var i=e.value;if(isNaN(i/1)!==!1){var r=getFieldId(e,!0);t[r]=""}return t}function checkDateField(e,t){return t}function getFormErrors(e,t){jQuery(e).find('input[type="submit"], input[type="button"]').attr("disabled","disabled"),jQuery(e).find(".frm_ajax_loading").addClass("frm_loading_now"),"undefined"==typeof t&&jQuery(e).find('input[name="frm_action"]').val(),jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:jQuery(e).serialize()+"&action=frm_entries_"+t+"&nonce="+frm_js.nonce,success:function(t){if(t=t.replace(/^\s+|\s+$/g,""),0===t.indexOf("{")&&(t=jQuery.parseJSON(t)),""===t||!t||"0"===t||"object"!=typeof t&&0===t.indexOf("<!DOCTYPE")){var i=document.getElementById("frm_loading");if(null!==i){var r=jQuery(e).find("input[type=file]").val();"undefined"!=typeof r&&""!==r&&setTimeout(function(){jQuery(i).fadeIn("slow")},2e3)}var n=jQuery(e).find(".g-recaptcha");n.length&&(jQuery(e).find(".frm_next_page").length<1||jQuery(e).find(".frm_next_page").val()<1)&&n.closest(".frm_form_field").replaceWith('<input type="hidden" name="recaptcha_checked" value="'+frm_js.nonce+'">'),e.submit()}else if("object"!=typeof t){jQuery(e).find(".frm_ajax_loading").removeClass("frm_loading_now");var a=jQuery(e).find('input[name="form_id"]').val();if(jQuery(e).closest("#frm_form_"+a+"_container").replaceWith(t),frmFrontForm.scrollMsg(a),"function"==typeof frmThemeOverride_frmAfterSubmit){var l=jQuery('input[name="frm_page_order_'+a+'"]').val(),d=jQuery(t).find('input[name="form_id"]').val();frmThemeOverride_frmAfterSubmit(d,l,t,e)}var o=jQuery(e).find('input[name="id"]');o.length&&jQuery(document.getElementById("frm_edit_"+o.val())).find("a").addClass("frm_ajax_edited").click()}else{jQuery(e).find('input[type="submit"], input[type="button"]').removeAttr("disabled"),jQuery(e).find(".frm_ajax_loading").removeClass("frm_loading_now");var f=!0;jQuery(".form-field").removeClass("frm_blank_field"),jQuery(".form-field .frm_error").replaceWith("");var s="",c=!1,u=null;for(var m in t)if(u=jQuery(e).find(jQuery(document.getElementById("frm_field_"+m+"_container"))),u.length){if(!u.is(":visible")){var p=u.closest(".frm_toggle_container");p.length&&p.prev(".frm_trigger").click()}if(u.is(":visible")){f=!1,""===s&&(frmFrontForm.scrollMsg(m,e,!0),s="#frm_field_"+m+"_container");var h=jQuery(e).find("#frm_field_"+m+"_container .g-recaptcha");h.length&&(c=!0,grecaptcha.reset()),addFieldError(u,m,t)}}else if("redirect"==m)return void(window.location=t[m]);c!==!0&&jQuery(e).find(".g-recaptcha").closest(".frm_form_field").replaceWith('<input type="hidden" name="recaptcha_checked" value="'+frm_js.nonce+'">'),f&&e.submit()}},error:function(){jQuery(e).find('input[type="submit"], input[type="button"]').removeAttr("disabled"),e.submit()}})}function addFieldError(e,t,i){e.length&&e.is(":visible")&&(e.addClass("frm_blank_field"),"function"==typeof frmThemeOverride_frmPlaceError?frmThemeOverride_frmPlaceError(t,i):e.append('<div class="frm_error">'+i[t]+"</div>"))}function removeFieldError(e){e.removeClass("frm_blank_field"),e.find(".frm_error").remove()}function clearDefault(){toggleDefault(jQuery(this),"clear")}function replaceDefault(){toggleDefault(jQuery(this),"replace")}function toggleDefault(e,t){var i=e.data("frmval").replace(/(\n|\r\n)/g,"\r");if(""===i||"undefined"==typeof i)return!1;var r=e.val().replace(/(\n|\r\n)/g,"\r");"replace"==t?""===r&&e.addClass("frm_default").val(i):r==i&&e.removeClass("frm_default").val("")}function resendEmail(){var e=jQuery(this),t=e.data("eid"),i=e.data("fid");return e.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:t,form_id:i,nonce:frm_js.nonce},success:function(t){e.replaceWith(t)}}),!1}function prepareGraphTypes(e,t){for(var i=0;i<e.length;i++)prepareGraphs(e[i],t)}function prepareGraphs(e,t){google.load("visualization","1.0",{packages:[t],callback:function(){"table"==t?compileGoogleTable(e):compileGraph(e)}})}function compileGoogleTable(e){var t=new google.visualization.DataTable,i=!1;-1!==jQuery.inArray("id",e.options.fields)&&(i=!0,t.addColumn("number",frm_js.id));for(var r=e.fields.length,n="string",a=0,l=r;l>a;a++){var d=e.fields[a];n=getGraphType(d),t.addColumn(n,d.name)}var o=!1;e.options.edit_link&&(o=!0,t.addColumn("string",e.options.edit_link));var f=!1;e.options.delete_link&&(f=!0,t.addColumn("string",e.options.delete_link));var s=0;if(null!==e.entries){var c=e.entries.length;t.addRows(c);for(var u=0,m=0,p=c;p>m;m++){s=0;var h=e.entries[m];i&&(t.setCell(u,s,h.id),s++);for(var _=0,y=r;y>_;_++){var g=e.fields[_];n=getGraphType(g);var v=h.metas[g.id];"number"!=n||null!==v&&""!==v?"boolean"==n&&(v=null===v||"false"==v||v===!1?!1:!0):v=0,t.setCell(u,s,v),s++}o&&("undefined"!=typeof h.editLink?t.setCell(u,s,'<a href="'+h.editLink+'">'+e.options.edit_link+"</a>"):t.setCell(u,s,""),s++),f&&("undefined"!=typeof h.deleteLink?t.setCell(u,s,'<a href="'+h.deleteLink+'" class="frm_delete_link" data-frmconfirm="'+e.options.confirm+'">'+e.options.delete_link+"</a>"):t.setCell(u,s,"")),u++}}else for(t.addRows(1),s=0,a=0,l=r;l>a;a++)s>0?t.setCell(0,s,""):t.setCell(0,s,e.options.no_entries),s++;var F=new google.visualization.Table(document.getElementById("frm_google_table_"+e.options.form_id));F.draw(t,e.graphOpts)}function getGraphType(e){var t="string";if("number"==e.type)t="number";else if("checkbox"==e.type||"select"==e.type){var i=e.options.length;"select"==e.type&&""===e.options[0]&&("post_status"==e.field_options.post_field?i=3:i-=1),1==i&&(t="boolean")}return t}function compileGraph(e){var t=new google.visualization.DataTable,i=!1,r=!1,n=e.rows.length;if(n>0)if("table"==e.type){i=!0;var a=e.rows[n-1],l=a[0]+1;t.addRows(l);for(var d=0,o=n;o>d;d++)t.setCell(e.rows[d])}else{var f=e.rows[0];if("undefined"!=typeof f.tooltip){i=!0,r=!0;for(var s=0,c=n;c>s;s++){var u=e.rows[s].tooltip;delete e.rows[s].tooltip;var m=Object.keys(e.rows[s]).map(function(t){return e.rows[s][t]});e.rows[s]=m,e.rows[s].push(u)}}}var p=e.cols.length;if(i){if(p>0)for(var h=0,_=p;_>h;h++){var y=e.cols[h];t.addColumn(y.type,y.name)}r&&(t.addColumn({type:"string",role:"tooltip"}),t.addRows(e.rows))}else{var g=[];g[0]=[];for(var v=0,F=p;F>v;v++)g[0].push(e.cols[v].name);g=g.concat(e.rows),t=google.visualization.arrayToDataTable(g)}var j=e.type.charAt(0).toUpperCase()+e.type.slice(1)+"Chart",Q=new google.visualization[j](document.getElementById("chart_"+e.graph_id));Q.draw(t,e.options)}function nextUpload(){var e=jQuery(this),t=e.data("fid");e.wrap('<div class="frm_file_names frm_uploaded_files">');for(var i=e.get(0).files,r=0;r<i.length;r++)e.after(0===r?i[r].name+' <a href="#" class="frm_clear_file_link">'+frm_js.remove+"</a>":i[r].name+"<br/>");e.hide();var n="file"+t,a=e.attr("name");if(a!="item_meta["+t+"][]"){var l=a.replace("item_meta[","").replace("[]","").split("][");3==l.length&&(n=n+"-"+l[1])}e.closest(".frm_form_field").find(".frm_uploaded_files:last").after('<input name="'+a+'" data-fid="'+t+'"class="frm_transparent frm_multiple_file" multiple="multiple" type="file" />')}function removeDiv(){fadeOut(jQuery(this).parent(".frm_uploaded_files"))}function clearFile(){return jQuery(this).parent(".frm_file_names").replaceWith(""),!1}function removeRow(){var e="frm_section_"+jQuery(this).data("parent")+"-"+jQuery(this).data("key"),t=jQuery(document.getElementById(e)),i=t.find("input, select, textarea");return t.fadeOut("slow",function(){t.remove(),i.each(function(){if("file"!=this.type){var e=this.name.replace("item_meta[","").split("]")[2].replace("[","");doCalculation(e,jQuery(this))}})}),!1}function addRow(){if(currentlyAddingRow===!0)return!1;currentlyAddingRow=!0;var e=jQuery(this).data("parent"),t=0;return jQuery(".frm_repeat_"+e).length>0&&(t=1+parseInt(jQuery(".frm_repeat_"+e+":last").attr("id").replace("frm_section_"+e+"-","")),"undefined"==typeof t&&(t=1)),jQuery.ajax({type:"POST",url:frm_js.ajax_url,dataType:"json",data:{action:"frm_add_form_row",field_id:e,i:t,nonce:frm_js.nonce},success:function(t){var i=t.html,r=jQuery(i).hide().fadeIn("slow");jQuery(".frm_repeat_"+e+":last").after(r);var n,a,l=["other"],d="reset";addingRow=r.attr("id"),jQuery(i).find("input, select, textarea").each(function(){"file"!=this.type&&(n=this.name.replace("item_meta[","").split("]")[2].replace("[",""),-1==jQuery.inArray(n,l)&&(a=jQuery("#"+this.id),l.push(n),checkDependentField(n,null,a,d),doCalculation(n,a),d="persist"))}),addingRow="";for(var o=t.logic.check.length,f=0,s=o;s>f;f++)-1==jQuery.inArray(t.logic.check[f],l)&&jQuery(i).find(".frm_field_"+t.logic.check[f]+"_container").length<1&&(checkDependentField(t.logic.check[f],null,null,d),d="persist");var c=jQuery(i).find(".star");c.length>0&&jQuery(".star").rating();var u=jQuery(i).find(".frm_chzn");u.length>0&&jQuery().chosen&&jQuery(".frm_chzn").chosen({allow_single_deselect:!0}),"function"==typeof frmThemeOverride_frmAddRow&&frmThemeOverride_frmAddRow(e,t),currentlyAddingRow=!1},error:function(){currentlyAddingRow=!1}}),!1}function editEntry(){var e=jQuery(this),t=e.data("entryid"),i=e.data("prefix"),r=e.data("pageid"),n=e.data("formid"),a=e.data("edit"),l=e.data("fields"),d=e.data("excludefields"),o=jQuery(document.getElementById(i+t)),f=o.html();return o.html('<span class="frm-loading-img" id="'+i+t+'"></span><div class="frm_orig_content" style="display:none">'+f+"</div>"),jQuery.ajax({type:"POST",url:frm_js.ajax_url,dataType:"html",data:{action:"frm_entries_edit_entry_ajax",post_id:r,entry_id:t,id:n,nonce:frm_js.nonce,fields:l,exclude_fields:d},success:function(t){o.children(".frm-loading-img").replaceWith(t),e.removeClass("frm_inplace_edit").addClass("frm_cancel_edit"),e.html(a)}}),!1}function cancelEdit(){var e=jQuery(this),t=e.data("entryid"),i=e.data("prefix"),r=e.data("edit");if(!e.hasClass("frm_ajax_edited")){var n=jQuery(document.getElementById(i+t));n.children(".frm_forms").replaceWith(""),n.children(".frm_orig_content").fadeIn("slow").removeClass("frm_orig_content")}return e.removeClass("frm_cancel_edit").addClass("frm_inplace_edit"),e.html(r),!1}function deleteEntry(){var e=jQuery(this),t=e.data("deleteconfirm");if(confirm(t)){var i=e.data("entryid"),r=e.data("prefix");e.replaceWith('<span class="frm-loading-img" id="frm_delete_'+i+'"></span>'),jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:{action:"frm_entries_destroy",entry:i,nonce:frm_js.nonce},success:function(e){"success"==e.replace(/^\s+|\s+$/g,"")?(jQuery(document.getElementById(r+i)).fadeOut("slow"),jQuery(document.getElementById("frm_delete_"+i)).fadeOut("slow")):jQuery(document.getElementById("frm_delete_"+i)).replaceWith(e)
2
+ }})}return!1}function fadeOut(e){e.fadeOut("slow",function(){e.remove()})}function confirmClick(){var e=jQuery(this).data("frmconfirm");return confirm(e)}function toggleDiv(){var e=jQuery(this).data("frmtoggle");return jQuery(e).is(":visible")?jQuery(e).slideUp("fast"):jQuery(e).slideDown("fast"),!1}function empty(e){if(null!==e)for(;e.firstChild;)e.removeChild(e.firstChild)}function objectSearch(e,t){for(var i in e)if(e.hasOwnProperty(i)&&e[i]===t)return i;return null}function isNotEmptyArray(e){return jQuery.isArray(e)&&(e.length>1||""!==e[0])}function isNumeric(e){return!jQuery.isArray(e)&&e-parseFloat(e)+1>=0}function getInputsInContainer(e){return e.find('select[name^="item_meta"], textarea[name^="item_meta"], input[name^="item_meta"]')}function getFieldName(e,t){var i="item_meta["+e+"]";return isRepeatingFieldById(e)&&(i=getRepeatingFieldName(e,t)),i}function getHelpers(){var e=document.getElementById("frm_helpers").value;return e=e?JSON.parse(e):[]}function getRepeatingFieldName(e,t){var i="";if(t.indexOf("frm_section")>-1){var r=t.replace("frm_section_","").split("-");i="item_meta["+r[0]+"]["+r[1]+"]["+e+"]"}else{var n=t.replace("frm_field_","").replace("_container","").split("-");i="item_meta["+n[1]+"]["+n[2]+"]["+e+"]"}return i}function getRepeatingFieldHtmlId(e,t){var i=t.replace("frm_section_","").split("-"),r="frm_field_"+e+"-"+i[0]+"-"+i[1]+"_container";return r}function maybeGetFirstElement(e){return e.length>1&&(e=e.eq(0)),e}function isRepeatingFieldById(e){var t=document.getElementById("frm_field_"+e+"_container");if("undefined"!=typeof t&&null!=t)return!1;var i=jQuery('input[name^="item_meta['+e+']"],select[name^="item_meta['+e+']"], textarea[name^="item_meta['+e+']"]');return i.length<1?!0:!1}function addIndexOfFallbackForIE8(){Array.prototype.indexOf||(Array.prototype.indexOf=function(e){var t=this.length>>>0,i=Number(arguments[1])||0;for(i=0>i?Math.ceil(i):Math.floor(i),0>i&&(i+=t);t>i;i++)if(i in this&&this[i]===e)return i;return-1})}function addTrimFallbackForIE8(){"function"!=typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")})}function addFilterFallbackForIE8(){Array.prototype.filter||(Array.prototype.filter=function(e){if(void 0===this||null===this)throw new TypeError;var t=Object(this),i=t.length>>>0;if("function"!=typeof e)throw new TypeError;for(var r=[],n=arguments[1],a=0;i>a;a++)if(a in t){var l=t[a];e.call(n,l,a,t)&&r.push(l)}return r})}function addKeysFallbackForIE8(){Object.keys||(Object.keys=function(e){var t=[];for(var i in e)e.hasOwnProperty(i)&&t.push(i);return t})}function getCheckedVal(e,t){var i=[];if("undefined"==typeof document.querySelector){var r=jQuery("#"+e+' input[type=checkbox]:checked, input[type=hidden][name^="'+t+'"]');r.each(function(){i.push(this.value)})}else for(var n=document.querySelectorAll("#"+e+' input[type=checkbox], input[type=hidden][name^="'+t+'"]'),a=0;a<n.length;a++)("checkbox"==n[a].type&&n[a].checked||"hidden"==n[a].type)&&i.push(n[a].value);return i}var show_fields=[],hide_later=[],hidden_fields=[],frm_checked_dep=[],addingRow="",currentlyAddingRow=!1,action="",jsErrors=[];return{init:function(){jQuery(document).on("click",".frm_trigger",toggleSection);var e=jQuery(".frm_blank_field");e.length&&e.closest(".frm_toggle_container").prev(".frm_trigger").click(),jQuery.isFunction(jQuery.fn.placeholder)?jQuery(".frm-show-form input, .frm-show-form textarea").placeholder():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",clearDefault),jQuery(document).on("blur",".frm_toggle_default",replaceDefault),jQuery(".frm_toggle_default").blur(),jQuery(document.getElementById("frm_resend_email")).click(resendEmail),jQuery(document).on("change",".frm_multiple_file",nextUpload),jQuery(document).on("click",".frm_clear_file_link",clearFile),jQuery(document).on("click",".frm_remove_link",removeDiv),jQuery(document).on("focusin","input[data-frmmask]",function(){jQuery(this).mask(jQuery(this).data("frmmask").toString())}),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"]',maybeCheckDependent),jQuery(document).on("click",'.frm-show-form input[type="submit"], .frm-show-form input[name="frm_prev_page"], .frm-show-form .frm_save_draft',setNextPage),jQuery(document).on("change",'.frm_other_container input[type="checkbox"], .frm_other_container input[type="radio"], .frm_other_container select',showOtherText),jQuery(document).on("change","input[type=file].frm_transparent",showFileUploadText),jQuery(document).on("click",".frm_remove_form_row",removeRow),jQuery(document).on("click",".frm_add_form_row",addRow),jQuery(document).on("click","a[data-frmconfirm]",confirmClick),jQuery("a[data-frmtoggle]").click(toggleDiv),jQuery(".frm_edit_link_container").on("click","a.frm_inplace_edit",editEntry),jQuery(".frm_edit_link_container").on("click","a.frm_cancel_edit",cancelEdit),jQuery(".frm_ajax_delete").click(deleteEntry),jQuery(".frm_month_heading, .frm_year_heading").click(function(){var e=jQuery(this).children(".ui-icon-triangle-1-e, .ui-icon-triangle-1-s");e.hasClass("ui-icon-triangle-1-e")?(e.addClass("ui-icon-triangle-1-s").removeClass("ui-icon-triangle-1-e"),jQuery(this).next(".frm_toggle_container").fadeIn("slow")):(e.addClass("ui-icon-triangle-1-e").removeClass("ui-icon-triangle-1-s"),jQuery(this).next(".frm_toggle_container").hide())}),addIndexOfFallbackForIE8(),addTrimFallbackForIE8(),addFilterFallbackForIE8(),addKeysFallbackForIE8()},submitForm:function(e){e.preventDefault(),jQuery(this).find(".wp-editor-wrap").length&&"undefined"!=typeof tinyMCE&&tinyMCE.triggerSave();var t=this;if(action=jQuery(t).find('input[name="frm_action"]').val(),jsErrors=[],frmFrontForm.getAjaxFormErrors(t),0===Object.keys(jsErrors).length)getFormErrors(t,action);else{jQuery(".form-field").removeClass("frm_blank_field"),jQuery(".form-field .frm_error").replaceWith("");for(var i in jsErrors){var r=jQuery(t).find(jQuery("#frm_field_"+i+"_container"));addFieldError(r,i,jsErrors)}}},getAjaxFormErrors:function(e){"function"==typeof frmThemeOverride_jsErrors&&(jsErrors=frmThemeOverride_jsErrors(action,e))},checkFormErrors:function(e,t){getFormErrors(e,t)},scrollToID:function(e){var t=jQuery(document.getElementById(e).offset());window.scrollTo(t.left,t.top)},scrollMsg:function(e,t,i){var r="";if(r="undefined"==typeof t?jQuery(document.getElementById("frm_form_"+e+"_container")).offset().top:jQuery(t).find(document.getElementById("frm_field_"+e+"_container")).offset().top){r-=frm_js.offset;var n=jQuery("html").css("margin-top"),a=jQuery("body").css("margin-top");if((n||a)&&(r=r-parseInt(n)-parseInt(a)),r&&window.innerHeight){var l=document.documentElement.scrollTop||document.body.scrollTop,d=l+window.innerHeight;if(r>d||l>r)return"undefined"==typeof i?jQuery(window).scrollTop(r):jQuery("html,body").animate({scrollTop:r},500),!1}}},hideCondFields:function(e){e=JSON.parse(e);for(var t=e.length,i=0,r=t;r>i;i++){var n=document.getElementById("frm_field_"+e[i]+"_container");null!==n?n.style.display="none":jQuery(".frm_field_"+e[i]+"_container").hide()}},checkDependent:function(e){e=JSON.parse(e);for(var t=e.length,i="reset",r=0,n=t;n>r;r++)checkDependentField(e[r],null,null,i),i="persist"},loadGoogle:function(){if("undefined"!=typeof google&&google&&google.load)for(var e=__FRMTABLES,t=Object.keys(e),i=0;i<t.length;i++)prepareGraphTypes(e[t[i]],t[i]);else setTimeout(frmFrontForm.loadGoogle,30)},removeUsedTimes:function(e,t){var i=jQuery(e).parents("form:first").find('input[name="id"]');jQuery.ajax({type:"POST",url:frm_js.ajax_url,dataType:"json",data:{action:"frm_fields_ajax_time_options",time_field:t,date_field:e.id,entry_id:i?i.val():"",date:jQuery(e).val(),nonce:frm_js.nonce},success:function(e){var i=jQuery(document.getElementById(t));if(i.find("option").removeAttr("disabled"),e&&""!==e)for(var r in e)i.find('option[value="'+r+'"]').attr("disabled","disabled")}})},escapeHtml:function(e){return e.replace(/&/g,"&").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")},invisible:function(e){jQuery(e).css("visibility","hidden")},visible:function(e){jQuery(e).css("visibility","visible")}}}function frmUpdateField(e,t,i,r,n){jQuery(document.getElementById("frm_update_field_"+e+"_"+t)).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:t,value:i,nonce:frm_js.nonce},success:function(){""===r.replace(/^\s+|\s+$/g,"")?jQuery(document.getElementById("frm_update_field_"+e+"_"+t+"_"+n)).fadeOut("slow"):jQuery(document.getElementById("frm_update_field_"+e+"_"+t+"_"+n)).replaceWith(r)}})}function frmEditEntry(e,t,i,r,n,a){console.warn("DEPRECATED: function frmEditEntry in v2.0.13 use frmFrontForm.editEntry");var l=jQuery(document.getElementById("frm_edit_"+e)),d=l.html(),o=jQuery(document.getElementById(t+e)),f=o.html();o.html('<span class="frm-loading-img" id="'+t+e+'"></span><div class="frm_orig_content" style="display:none">'+f+"</div>"),jQuery.ajax({type:"POST",url:frm_js.ajax_url,dataType:"html",data:{action:"frm_entries_edit_entry_ajax",post_id:i,entry_id:e,id:r,nonce:frm_js.nonce},success:function(f){o.children(".frm-loading-img").replaceWith(f),l.replaceWith('<span id="frm_edit_'+e+'"><a onclick="frmCancelEdit('+e+",'"+t+"','"+frmFrontForm.escapeHtml(d)+"',"+i+","+r+",'"+a+'\')" class="'+a+'">'+n+"</a></span>")}})}function frmCancelEdit(e,t,i,r,n,a){console.warn("DEPRECATED: function frmCancelEdit in v2.0.13 use frmFrontForm.cancelEdit");var l=jQuery(document.getElementById("frm_edit_"+e)),d=l.find("a"),o=d.html();if(!d.hasClass("frm_ajax_edited")){var f=jQuery(document.getElementById(t+e));f.children(".frm_forms").replaceWith(""),f.children(".frm_orig_content").fadeIn("slow").removeClass("frm_orig_content")}l.replaceWith('<a id="frm_edit_'+e+'" class="frm_edit_link '+a+'" href="javascript:frmEditEntry('+e+",'"+t+"',"+r+","+n+",'"+frmFrontForm.escapeHtml(o)+"','"+a+"')\">"+i+"</a>")}function frmDeleteEntry(e,t){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(i){"success"==i.replace(/^\s+|\s+$/g,"")?jQuery(document.getElementById(t+e)).fadeOut("slow"):jQuery(document.getElementById("frm_delete_"+e)).replaceWith(i)}})}function frmOnSubmit(e){console.warn("DEPRECATED: function frmOnSubmit in v2.0 use frmFrontForm.submitForm"),frmFrontForm.submitForm(e,this)}function frm_resend_email(e,t){console.warn("DEPRECATED: function frm_resend_email in v2.0"),$link=jQuery(document.getElementById("frm_resend_email")),$link.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:t,nonce:frm_js.nonce},success:function(e){$link.replaceWith(e)}})}var frmFrontForm=frmFrontFormJS();jQuery(document).ready(function(){frmFrontForm.init()});
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Formidable Forms ===
2
  Contributors: sswells, srwells, jamie.wahlin
3
  Donate link: http://formidablepro.com/donate
4
- Tags: admin, AJAX, captcha, contact, contact form, database, email, feedback, form, forms, javascript, jquery, page, plugin, poll, Post, spam, survey, template, widget, wpmu, form builder
5
  Requires at least: 3.6
6
  Tested up to: 4.3
7
- Stable tag: 2.0.12
8
 
9
  Beautiful forms in 60 seconds. The WordPress form builder that enables you to create forms with a simple drag-and-drop interface and in-place editing.
10
 
@@ -89,6 +89,45 @@ A. Try clearing your browser cache. As plugin modifications are made, frequent j
89
  [See more FAQs](http://formidablepro.com/formidable-faqs/ "Formidable Form FAQs")
90
 
91
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  = 2.0.12 =
93
  * Add option to center form on page
94
  * Improve styling classes for more consistency across different field classes, and make all classes responsive
1
  === Formidable Forms ===
2
  Contributors: sswells, srwells, jamie.wahlin
3
  Donate link: http://formidablepro.com/donate
4
+ Tags: admin, AJAX, captcha, contact, contact form, database, email, feedback, form, forms, javascript, jquery, page, plugin, poll, Post, spam, survey, template, widget, form builder
5
  Requires at least: 3.6
6
  Tested up to: 4.3
7
+ Stable tag: 2.0.13
8
 
9
  Beautiful forms in 60 seconds. The WordPress form builder that enables you to create forms with a simple drag-and-drop interface and in-place editing.
10
 
89
  [See more FAQs](http://formidablepro.com/formidable-faqs/ "Formidable Form FAQs")
90
 
91
  == Changelog ==
92
+ = 2.0.13 =
93
+ * Allow css file updating if FTP creds are present
94
+ * Add 'frm_ajax_url' hook
95
+ * Allow layout classes to be used with submit button
96
+ * Remove frm_last class
97
+ * Prevent get_filesystem_method error in multisite after update
98
+ * Conditionally use ssl for the ajax url for form submission
99
+ * **Pro Features:**
100
+ * Allow recaptcha to be conditionally hidden on previous pages of form
101
+ * Fix error with embedded form on a conditionally hidden page
102
+ * Show the editlink after an entry is edited in place
103
+ * Make sure collapsible section icons show regardless of characters in the section title
104
+ * Don't require conditionally hidden dynamic category fields
105
+ * Add fields attribute to [editlink] shortcode
106
+ * Fix calculations using repeating checkboxes
107
+ * Prevent double click on Add button in repeating section
108
+ * Clear conditionally hidden fields even if they aren't visible
109
+ * Make sure pro templates get imported in multisite
110
+ * Use separate values by default for post status fields
111
+ * Make sure the separate values option is allows for post status fields
112
+ * Show the frmcal-week-end class consistently
113
+ * Fix default values in repeating Dynamic fields
114
+ * Make Private Views show up in shortcode builder
115
+ * Don't do calculations in conditionally hidden repeating fields
116
+ * Do calcs in repeating fields when adding a row
117
+ * Improve JS for IE8
118
+ * Fix unique time error
119
+ * Fix default date in jQuery calendar
120
+ * Allow entry key with frm-field-value shortcode
121
+ * Fix unique time error
122
+ * Improve calculations across page breaks
123
+ * Prevent clearing default values when hiding/showing sections
124
+ * Run calculations in collapsible sections
125
+ * Fix duplicating regular sections
126
+ * Add post ID View filter
127
+ * Fix empty graphs
128
+ * Allow frm-entry-update-field, editlink, and deletelink inside foreach loop
129
+ * Fix importing parent_form_id on child forms
130
+
131
  = 2.0.12 =
132
  * Add option to center form on page
133
  * Improve styling classes for more consistency across different field classes, and make all classes responsive