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
-