Formidable Forms – Form Builder for WordPress - Version 2.04

Version Description

  • New: Add FrmEntryValues and FrmFieldValue classes, which should be widely reusable.
  • New: Add ready-to-use contact form. Use it anywhere with [formidable id=contact-form]. It will only be created on new installs.
  • Enhancement: Load global settings tabs with AJAX to improve the load speed.
  • Enhancement: Add form and entry to frm_email_message filter.
  • Fix: Changed blank title processing in the form widget to match WordPress core widgets.
  • Pro Version Forms
  • New: Add FrmProEntryValues and FrmProFieldValue classes, which should be widely reusable.
  • New: Add frm_validate_file and frm_response_after_upload hooks.
  • Enhancement: Set license keys in wp-config.php. Use define('FRM_PRO_LICENSE', 'license-key-here');
  • Enhancement: Prevent the submit button from being clicked while Lookup fields are processing.
  • Fix: If a field is in a section in an embedded form, it will now be included in the default email message.
  • Fix: Entry array passed to API and Zapier includes repeating fields with their own value arrays.
  • Fix: Include_fields parameter applies in show entry shortcode.
  • Fix: Some repeating or embedded fields were duplicated in the default emails and the show entry shortcode.
  • Fix: Only show section headings in email if there are values submitted inside the section.
  • Fix: Calculation error occurred when calculation contained fields inside and outside repeating section.
  • Fix: Make sure [input opt=1] works when "other" options are present in radio fields.
  • Fix: Prevent JS error for calc with no trigger field.
  • Fix: Show loading icon when updating a field with update link.
  • Fix: Allow "3" in the title of a collapsible section
  • Fix: Only check get_user_locale in admin area to stay in step with WordPress.
  • Fix: Keep Lookup option with special characters selected when editing entry.
  • Fix: Prevent fields from returning validation errors when they're in a hidden section.
  • Fix: Fix "Array" showing for the options in post status View filter.
  • Fix: Filter fields autopopulated by lookup based on parent settings.
  • Fix: Don't set cookie during API request.
  • Fix: Fix entry ID greater than and less than filters.
  • Fix: Close the file type limit selection box when clicking away.
  • Fix: Remove autoclear from masks.
Download this release

Release Info

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

Code changes from version 2.03.10 to 2.04

Files changed (44) hide show
  1. classes/controllers/FrmEntriesController.php +45 -2
  2. classes/controllers/FrmFormsController.php +1 -1
  3. classes/controllers/FrmHooksController.php +1 -0
  4. classes/controllers/FrmSettingsController.php +31 -4
  5. classes/factories/FrmEntryFactory.php +46 -0
  6. classes/{models → factories}/FrmFieldFactory.php +0 -0
  7. classes/helpers/FrmAppHelper.php +1 -1
  8. classes/helpers/FrmEntriesHelper.php +71 -27
  9. classes/helpers/FrmFieldsHelper.php +1 -1
  10. classes/models/FrmAddon.php +65 -9
  11. classes/models/FrmDb.php +18 -0
  12. classes/models/FrmEmail.php +3 -1
  13. classes/models/FrmEntryFormat.php +104 -369
  14. classes/models/FrmEntryFormatter.php +625 -0
  15. classes/models/FrmEntryMeta.php +1 -0
  16. classes/models/FrmEntryShortcodeFormatter.php +227 -0
  17. classes/models/FrmEntryValues.php +297 -0
  18. classes/models/FrmFieldValue.php +192 -0
  19. classes/models/FrmTableHTMLGenerator.php +307 -0
  20. classes/views/frm-fields/input.php +1 -1
  21. classes/views/frm-settings/form.php +14 -5
  22. classes/views/frm-settings/license_box.php +4 -3
  23. classes/widgets/FrmShowForm.php +1 -6
  24. css/frm_admin.css +6 -0
  25. formidable.php +3 -1
  26. js/formidable.js +17 -12
  27. js/formidable.min.js +92 -92
  28. js/formidable_admin.js +30 -5
  29. languages/formidable-az_AZ.mo +0 -0
  30. languages/formidable-az_AZ.po +7801 -0
  31. languages/formidable-da_DK.mo +0 -0
  32. languages/formidable-da_DK.po +169 -169
  33. languages/formidable-de_DE.mo +0 -0
  34. languages/formidable-de_DE.po +166 -164
  35. languages/formidable-es_ES.mo +0 -0
  36. languages/formidable-es_ES.po +166 -164
  37. languages/formidable-fr_FR.mo +0 -0
  38. languages/formidable-fr_FR.po +8128 -0
  39. languages/formidable-hu_HU.mo +0 -0
  40. languages/formidable-hu_HU.po +7801 -0
  41. languages/formidable-it_IT.mo +0 -0
  42. languages/formidable-it_IT.po +166 -164
  43. languages/formidable-ja_JP.mo +0 -0
  44. languages/formidable-ja_JP.po +467 -0
classes/controllers/FrmEntriesController.php CHANGED
@@ -507,8 +507,51 @@ class FrmEntriesController {
507
  }
508
  }
509
 
 
 
 
 
 
510
  public static function show_entry_shortcode( $atts ) {
511
- return FrmEntryFormat::show_entry( $atts );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
512
  }
513
 
514
  public static function get_params( $form = null ) {
@@ -521,7 +564,7 @@ class FrmEntriesController {
521
  $date_format = get_option('date_format');
522
  $time_format = get_option('time_format');
523
  if ( isset( $data['browser'] ) ) {
524
- $browser = FrmEntryFormat::get_browser( $data['browser'] );
525
  }
526
 
527
  include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' );
507
  }
508
  }
509
 
510
+ /**
511
+ * @param $atts
512
+ *
513
+ * @return array|string
514
+ */
515
  public static function show_entry_shortcode( $atts ) {
516
+ $defaults = array(
517
+ 'id' => false,
518
+ 'entry' => false,
519
+ 'fields' => false,
520
+ 'plain_text' => false,
521
+ 'user_info' => false,
522
+ 'include_blank' => false,
523
+ 'default_email' => false,
524
+ 'form_id' => false,
525
+ 'format' => 'text',
526
+ 'direction' => 'ltr',
527
+ 'font_size' => '',
528
+ 'text_color' => '',
529
+ 'border_width' => '',
530
+ 'border_color' => '',
531
+ 'bg_color' => '',
532
+ 'alt_bg_color' => '',
533
+ 'clickable' => false,
534
+ 'exclude_fields' => '',
535
+ 'include_fields' => '',
536
+ 'include_extras' => '',
537
+ 'inline_style' => 1,
538
+ );
539
+
540
+ $atts = shortcode_atts( $defaults, $atts );
541
+
542
+ if ( $atts['default_email'] ) {
543
+
544
+ $entry_shortcode_formatter = FrmEntryFactory::entry_shortcode_formatter_instance( $atts['form_id'], $atts['format'] );
545
+ $formatted_entry = $entry_shortcode_formatter->content();
546
+
547
+ } else {
548
+
549
+ $entry_formatter = FrmEntryFactory::entry_formatter_instance( $atts );
550
+ $formatted_entry = $entry_formatter->get_formatted_entry_values();
551
+
552
+ }
553
+
554
+ return $formatted_entry;
555
  }
556
 
557
  public static function get_params( $form = null ) {
564
  $date_format = get_option('date_format');
565
  $time_format = get_option('time_format');
566
  if ( isset( $data['browser'] ) ) {
567
+ $browser = FrmEntriesHelper::get_browser( $data['browser'] );
568
  }
569
 
570
  include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' );
classes/controllers/FrmFormsController.php CHANGED
@@ -761,7 +761,7 @@ class FrmFormsController {
761
  public static function get_email_html() {
762
  FrmAppHelper::permission_check('frm_view_forms');
763
  check_ajax_referer( 'frm_ajax', 'nonce' );
764
- echo FrmEntryFormat::show_entry( array(
765
  'form_id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ),
766
  'default_email' => true,
767
  'plain_text' => FrmAppHelper::get_post_param( 'plain_text', '', 'absint' ),
761
  public static function get_email_html() {
762
  FrmAppHelper::permission_check('frm_view_forms');
763
  check_ajax_referer( 'frm_ajax', 'nonce' );
764
+ echo FrmEntriesController::show_entry_shortcode( array(
765
  'form_id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ),
766
  'default_email' => true,
767
  'plain_text' => FrmAppHelper::get_post_param( 'plain_text', '', 'absint' ),
classes/controllers/FrmHooksController.php CHANGED
@@ -122,6 +122,7 @@ class FrmHooksController {
122
  // Settings Controller
123
  add_action( 'admin_menu', 'FrmSettingsController::menu', 45 );
124
  add_action( 'frm_before_settings', 'FrmSettingsController::license_box' );
 
125
 
126
  // Styles Controller
127
  add_action( 'admin_menu', 'FrmStylesController::menu', 14 );
122
  // Settings Controller
123
  add_action( 'admin_menu', 'FrmSettingsController::menu', 45 );
124
  add_action( 'frm_before_settings', 'FrmSettingsController::license_box' );
125
+ add_action( 'wp_ajax_frm_settings_tab', 'FrmSettingsController::load_settings_tab' );
126
 
127
  // Styles Controller
128
  add_action( 'admin_menu', 'FrmStylesController::menu', 14 );
classes/controllers/FrmSettingsController.php CHANGED
@@ -23,19 +23,46 @@ class FrmSettingsController {
23
  $uploads = wp_upload_dir();
24
  $target_path = $uploads['basedir'] . '/formidable/css';
25
 
 
 
 
 
 
 
 
 
26
  $sections = array();
27
  if ( apply_filters( 'frm_include_addon_page', false ) ) {
28
  $sections['licenses'] = array(
29
  'class' => 'FrmAddonsController', 'function' => 'license_settings',
30
  'name' => __( 'Plugin Licenses', 'formidable' ),
 
31
  );
32
  }
33
- $sections = apply_filters( 'frm_add_settings_section', $sections );
34
 
35
- $captcha_lang = FrmAppHelper::locales( 'captcha' );
 
36
 
37
- require( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php' );
38
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
  public static function process_form( $stop_load = false ) {
41
  global $frm_vars;
23
  $uploads = wp_upload_dir();
24
  $target_path = $uploads['basedir'] . '/formidable/css';
25
 
26
+ $sections = self::get_settings_tabs();
27
+
28
+ $captcha_lang = FrmAppHelper::locales( 'captcha' );
29
+
30
+ require( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php' );
31
+ }
32
+
33
+ private static function get_settings_tabs() {
34
  $sections = array();
35
  if ( apply_filters( 'frm_include_addon_page', false ) ) {
36
  $sections['licenses'] = array(
37
  'class' => 'FrmAddonsController', 'function' => 'license_settings',
38
  'name' => __( 'Plugin Licenses', 'formidable' ),
39
+ 'ajax' => true,
40
  );
41
  }
42
+ $sections = apply_filters( 'frm_add_settings_section', $sections );
43
 
44
+ return $sections;
45
+ }
46
 
47
+ public static function load_settings_tab() {
48
+ FrmAppHelper::permission_check('frm_change_settings');
49
+ check_ajax_referer( 'frm_ajax', 'nonce' );
50
+
51
+ $section = FrmAppHelper::get_post_param( 'tab', '', 'sanitize_text_field' );
52
+ $sections = self::get_settings_tabs();
53
+ if ( ! isset( $sections[ $section ] ) ) {
54
+ wp_die();
55
+ }
56
+
57
+ $section = $sections[ $section ];
58
+
59
+ if ( isset( $section['class'] ) ) {
60
+ call_user_func( array( $section['class'], $section['function'] ) );
61
+ } else {
62
+ call_user_func( ( isset( $section['function'] ) ? $section['function'] : $section ) );
63
+ }
64
+ wp_die();
65
+ }
66
 
67
  public static function process_form( $stop_load = false ) {
68
  global $frm_vars;
classes/factories/FrmEntryFactory.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @since 2.04
5
+ */
6
+ class FrmEntryFactory {
7
+
8
+ /**
9
+ * Create an instance of the FrmEntryFormatter class
10
+ *
11
+ * @since 2.04
12
+ *
13
+ * @param array $atts
14
+ *
15
+ * @return FrmEntryFormatter|FrmProEntryFormatter
16
+ */
17
+ public static function entry_formatter_instance( $atts ) {
18
+ if ( FrmAppHelper::pro_is_installed() ) {
19
+ $entry_formatter = new FrmProEntryFormatter( $atts );
20
+ } else {
21
+ $entry_formatter = new FrmEntryFormatter( $atts );
22
+ }
23
+
24
+ return $entry_formatter;
25
+ }
26
+
27
+ /**
28
+ * Create an intsance of the FrmEntryShortcodeFormatter class
29
+ *
30
+ * @since 2.04
31
+ *
32
+ * @param int|string $form_id
33
+ * @param string $format
34
+ *
35
+ * @return FrmEntryShortcodeFormatter|FrmProEntryShortcodeFormatter
36
+ */
37
+ public static function entry_shortcode_formatter_instance( $form_id, $format ) {
38
+ if ( FrmAppHelper::pro_is_installed() ) {
39
+ $shortcode_formatter = new FrmProEntryShortcodeFormatter( $form_id, $format );
40
+ } else {
41
+ $shortcode_formatter = new FrmEntryShortcodeFormatter( $form_id, $format );
42
+ }
43
+
44
+ return $shortcode_formatter;
45
+ }
46
+ }
classes/{models → factories}/FrmFieldFactory.php RENAMED
File without changes
classes/helpers/FrmAppHelper.php CHANGED
@@ -10,7 +10,7 @@ class FrmAppHelper {
10
  /**
11
  * @since 2.0
12
  */
13
- public static $plug_version = '2.03.10';
14
 
15
  /**
16
  * @since 1.07.02
10
  /**
11
  * @since 2.0
12
  */
13
+ public static $plug_version = '2.04';
14
 
15
  /**
16
  * @since 1.07.02
classes/helpers/FrmEntriesHelper.php CHANGED
@@ -196,7 +196,7 @@ class FrmEntriesHelper {
196
  $this_atts = $atts;
197
  }
198
 
199
- $default = FrmEntryFormat::show_entry( $this_atts );
200
 
201
  // Add the default message
202
  $message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
@@ -487,37 +487,81 @@ class FrmEntriesHelper {
487
  return $content;
488
  }
489
 
490
- public static function fill_entry_values( $atts, $f, array &$values ) {
491
- _deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryFormat::fill_entry_values' );
492
- FrmEntryFormat::fill_entry_values( $atts, $f, $values );
493
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
494
 
495
- public static function flatten_multi_file_upload( &$val, $field ) {
496
- _deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryFormat::flatten_multi_file_upload' );
497
- FrmEntryFormat::flatten_multi_file_upload( $field, $val );
498
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
499
 
500
- public static function textarea_display_value() {
501
- _deprecated_function( __FUNCTION__, '2.0.9', 'custom code' );
502
- }
 
503
 
504
- public static function fill_entry_user_info( $atts, array &$values ) {
505
- _deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryFormat::fill_entry_user_info' );
506
- FrmEntryFormat::fill_entry_user_info( $atts, $values );
507
- }
508
 
509
- public static function get_entry_description_data( $atts ) {
510
- _deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryFormat::get_entry_description_data' );
511
- return FrmEntryFormat::get_entry_description_data( $atts );
512
- }
 
 
 
 
 
 
 
 
 
513
 
514
- public static function convert_entry_to_content( $values, $atts, array &$content ) {
515
- _deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryFormat::convert_entry_to_content' );
516
- FrmEntryFormat::convert_entry_to_content( $values, $atts, $content );
517
- }
518
 
519
- public static function get_browser( $u_agent ) {
520
- _deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryFormat::get_browser' );
521
- return FrmEntryFormat::get_browser( $u_agent );
522
  }
 
523
  }
196
  $this_atts = $atts;
197
  }
198
 
199
+ $default = FrmEntriesController::show_entry_shortcode( $this_atts );
200
 
201
  // Add the default message
202
  $message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
487
  return $content;
488
  }
489
 
490
+ /**
491
+ * Get the browser from the user agent
492
+ *
493
+ * @since 2.04
494
+ *
495
+ * @param string $u_agent
496
+ *
497
+ * @return string
498
+ */
499
+ public static function get_browser( $u_agent ) {
500
+ $bname = __( 'Unknown', 'formidable' );
501
+ $platform = __( 'Unknown', 'formidable' );
502
+ $ub = '';
503
+
504
+ // Get the operating system
505
+ if ( preg_match( '/windows|win32/i', $u_agent ) ) {
506
+ $platform = 'Windows';
507
+ } else if ( preg_match( '/android/i', $u_agent ) ) {
508
+ $platform = 'Android';
509
+ } else if ( preg_match( '/linux/i', $u_agent ) ) {
510
+ $platform = 'Linux';
511
+ } else if ( preg_match( '/macintosh|mac os x/i', $u_agent ) ) {
512
+ $platform = 'OS X';
513
+ }
514
 
515
+ $agent_options = array(
516
+ 'Chrome' => 'Google Chrome',
517
+ 'Safari' => 'Apple Safari',
518
+ 'Opera' => 'Opera',
519
+ 'Netscape' => 'Netscape',
520
+ 'Firefox' => 'Mozilla Firefox',
521
+ );
522
+
523
+ // Next get the name of the useragent yes seperately and for good reason
524
+ if ( strpos( $u_agent, 'MSIE' ) !== false && strpos( $u_agent, 'Opera' ) === false ) {
525
+ $bname = 'Internet Explorer';
526
+ $ub = 'MSIE';
527
+ } else {
528
+ foreach ( $agent_options as $agent_key => $agent_name ) {
529
+ if ( strpos( $u_agent, $agent_key ) !== false ) {
530
+ $bname = $agent_name;
531
+ $ub = $agent_key;
532
+ break;
533
+ }
534
+ }
535
+ }
536
 
537
+ // finally get the correct version number
538
+ $known = array( 'Version', $ub, 'other' );
539
+ $pattern = '#(?<browser>' . join( '|', $known ) . ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
540
+ preg_match_all( $pattern, $u_agent, $matches ); // get the matching numbers
541
 
542
+ // see how many we have
543
+ $i = count($matches['browser']);
 
 
544
 
545
+ if ( $i > 1 ) {
546
+ //we will have two since we are not using 'other' argument yet
547
+ //see if version is before or after the name
548
+ if ( strripos( $u_agent, 'Version' ) < strripos( $u_agent, $ub ) ) {
549
+ $version = $matches['version'][0];
550
+ } else {
551
+ $version = $matches['version'][1];
552
+ }
553
+ } else if ( $i === 1 ) {
554
+ $version = $matches['version'][0];
555
+ } else {
556
+ $version = '';
557
+ }
558
 
559
+ // check if we have a number
560
+ if ( $version == '' ) {
561
+ $version = '?';
562
+ }
563
 
564
+ return $bname . ' ' . $version . ' / ' . $platform;
 
 
565
  }
566
+
567
  }
classes/helpers/FrmFieldsHelper.php CHANGED
@@ -687,7 +687,7 @@ DEFAULT_HTML;
687
  case 'user_agent':
688
  case 'user-agent':
689
  $entry->description = maybe_unserialize($entry->description);
690
- $replace_with = FrmEntryFormat::get_browser( $entry->description['browser'] );
691
  break;
692
 
693
  case 'created_at':
687
  case 'user_agent':
688
  case 'user-agent':
689
  $entry->description = maybe_unserialize($entry->description);
690
+ $replace_with = FrmEntriesHelper::get_browser( $entry->description['browser'] );
691
  break;
692
 
693
  case 'created_at':
classes/models/FrmAddon.php CHANGED
@@ -80,13 +80,60 @@ class FrmAddon {
80
  }
81
 
82
  public function get_license() {
83
- return trim( get_option( $this->option_name . 'key' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  }
85
 
86
  public function set_license( $license ) {
87
  update_option( $this->option_name . 'key', $license );
88
  }
89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  public function clear_license() {
91
  delete_option( $this->option_name . 'active' );
92
  delete_option( $this->option_name . 'key' );
@@ -193,23 +240,33 @@ class FrmAddon {
193
  check_ajax_referer( 'frm_ajax', 'nonce' );
194
 
195
  if ( ! isset( $_POST['license'] ) || empty( $_POST['license'] ) ) {
196
- wp_die( __( 'Oops! You forgot to enter your license number.', 'formidable' ) );
 
 
 
197
  }
198
 
199
  $license = stripslashes( sanitize_text_field( $_POST['license'] ) );
200
  $plugin_slug = sanitize_text_field( $_POST['plugin'] );
201
  $this_plugin = self::get_addon( $plugin_slug );
202
- $this_plugin->set_license( $license );
203
- $this_plugin->license = $license;
204
 
205
- $response = $this_plugin->get_license_status();
 
 
 
 
 
 
 
 
206
  $response['message'] = '';
207
  $response['success'] = false;
208
 
209
  if ( $response['error'] ) {
210
  $response['message'] = $response['status'];
211
  } else {
212
- $messages = $this_plugin->get_messages();
213
  if ( is_string( $response['status'] ) && isset( $messages[ $response['status'] ] ) ) {
214
  $response['message'] = $messages[ $response['status'] ];
215
  } else {
@@ -221,11 +278,10 @@ class FrmAddon {
221
  $is_valid = 'valid';
222
  $response['success'] = true;
223
  }
224
- $this_plugin->set_active( $is_valid );
225
  }
226
 
227
- echo json_encode( $response );
228
- wp_die();
229
  }
230
 
231
  private function get_license_status() {
80
  }
81
 
82
  public function get_license() {
83
+ $license = trim( get_option( $this->option_name . 'key' ) );
84
+ if ( empty( $license ) ) {
85
+ $license = $this->activate_defined_license();
86
+ }
87
+ return $license;
88
+ }
89
+
90
+ /**
91
+ * Activate the license in wp-config.php
92
+ * @since 2.04
93
+ */
94
+ public function activate_defined_license() {
95
+ $license = $this->get_defined_license();
96
+ if ( ! empty( $license ) && ! $this->is_active() && $this->is_time_to_auto_activate() ) {
97
+ $response = $this->activate_license( $license );
98
+ $this->set_auto_activate_time();
99
+ if ( ! $response['success'] ) {
100
+ $license = '';
101
+ }
102
+ }
103
+ return $license;
104
+ }
105
+
106
+ /**
107
+ * Check the wp-config.php for the license key
108
+ * @since 2.04
109
+ */
110
+ public function get_defined_license() {
111
+ $consant_name = 'FRM_' . strtoupper( $this->plugin_slug ) . '_LICENSE';
112
+ return defined( $consant_name ) ? constant( $consant_name ) : false;
113
  }
114
 
115
  public function set_license( $license ) {
116
  update_option( $this->option_name . 'key', $license );
117
  }
118
 
119
+ /**
120
+ * If the license is in the config, limit the frequency of checks.
121
+ * The license may be entered incorrectly, so we don't want to check on every page load.
122
+ * @since 2.04
123
+ */
124
+ private function is_time_to_auto_activate() {
125
+ $last_try = get_option( $this->option_name .'last_activate' );
126
+ return ( ! $last_try || $last_try < strtotime('-1 day') );
127
+ }
128
+
129
+ private function set_auto_activate_time() {
130
+ update_option( $this->option_name . 'last_activate', time() );
131
+ }
132
+
133
+ public function is_active() {
134
+ return get_option( $this->option_name . 'active' );
135
+ }
136
+
137
  public function clear_license() {
138
  delete_option( $this->option_name . 'active' );
139
  delete_option( $this->option_name . 'key' );
240
  check_ajax_referer( 'frm_ajax', 'nonce' );
241
 
242
  if ( ! isset( $_POST['license'] ) || empty( $_POST['license'] ) ) {
243
+ wp_die( json_encode( array(
244
+ 'message' => __( 'Oops! You forgot to enter your license number.', 'formidable' ),
245
+ 'success' => false,
246
+ ) ) );
247
  }
248
 
249
  $license = stripslashes( sanitize_text_field( $_POST['license'] ) );
250
  $plugin_slug = sanitize_text_field( $_POST['plugin'] );
251
  $this_plugin = self::get_addon( $plugin_slug );
252
+ $response = $this_plugin->activate_license( $license );
 
253
 
254
+ echo json_encode( $response );
255
+ wp_die();
256
+ }
257
+
258
+ private function activate_license( $license ) {
259
+ $this->set_license( $license );
260
+ $this->license = $license;
261
+
262
+ $response = $this->get_license_status();
263
  $response['message'] = '';
264
  $response['success'] = false;
265
 
266
  if ( $response['error'] ) {
267
  $response['message'] = $response['status'];
268
  } else {
269
+ $messages = $this->get_messages();
270
  if ( is_string( $response['status'] ) && isset( $messages[ $response['status'] ] ) ) {
271
  $response['message'] = $messages[ $response['status'] ];
272
  } else {
278
  $is_valid = 'valid';
279
  $response['success'] = true;
280
  }
281
+ $this->set_active( $is_valid );
282
  }
283
 
284
+ return $response;
 
285
  }
286
 
287
  private function get_license_status() {
classes/models/FrmDb.php CHANGED
@@ -43,6 +43,10 @@ class FrmDb {
43
 
44
  /**** ADD/UPDATE DEFAULT TEMPLATES ****/
45
  FrmXMLController::add_default_templates();
 
 
 
 
46
  }
47
 
48
  do_action('frm_after_install');
@@ -159,6 +163,20 @@ class FrmDb {
159
  }
160
  }
161
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
162
  /**
163
  * @param integer $frm_db_version
164
  * @param int $old_db_version
43
 
44
  /**** ADD/UPDATE DEFAULT TEMPLATES ****/
45
  FrmXMLController::add_default_templates();
46
+
47
+ if ( ! $old_db_version ) {
48
+ $this->maybe_create_contact_form();
49
+ }
50
  }
51
 
52
  do_action('frm_after_install');
163
  }
164
  }
165
 
166
+ private function maybe_create_contact_form() {
167
+ $template_id = FrmForm::getIdByKey( 'contact' );
168
+ if ( $template_id ) {
169
+ $form_id = FrmForm::duplicate( $template_id, false, true );
170
+ if ( $form_id ) {
171
+ $values = array(
172
+ 'status' => 'published',
173
+ 'form_key' => 'contact-form',
174
+ );
175
+ FrmForm::update( $form_id, $values );
176
+ }
177
+ }
178
+ }
179
+
180
  /**
181
  * @param integer $frm_db_version
182
  * @param int $old_db_version
classes/models/FrmEmail.php CHANGED
@@ -297,7 +297,7 @@ class FrmEmail {
297
  $data = maybe_unserialize( $this->entry->description );
298
  $mail_body .= "\r\n\r\n" . __( 'User Information', 'formidable' ) . "\r\n";
299
  $mail_body .= __( 'IP Address', 'formidable' ) . ': ' . $this->entry->ip . "\r\n";
300
- $mail_body .= __( 'User-Agent (Browser/OS)', 'formidable' ) . ': ' . FrmEntryFormat::get_browser( $data['browser'] ) . "\r\n";
301
  $mail_body .= __( 'Referrer', 'formidable' ) . ': ' . $data['referrer'] . "\r\n";
302
  }
303
 
@@ -691,6 +691,8 @@ class FrmEmail {
691
  'message' => $this->message,
692
  'attachments' => $this->attachments,
693
  'plain_text' => $this->is_plain_text,
 
 
694
  );
695
  }
696
 
297
  $data = maybe_unserialize( $this->entry->description );
298
  $mail_body .= "\r\n\r\n" . __( 'User Information', 'formidable' ) . "\r\n";
299
  $mail_body .= __( 'IP Address', 'formidable' ) . ': ' . $this->entry->ip . "\r\n";
300
+ $mail_body .= __( 'User-Agent (Browser/OS)', 'formidable' ) . ': ' . FrmEntriesHelper::get_browser( $data['browser'] ) . "\r\n";
301
  $mail_body .= __( 'Referrer', 'formidable' ) . ': ' . $data['referrer'] . "\r\n";
302
  }
303
 
691
  'message' => $this->message,
692
  'attachments' => $this->attachments,
693
  'plain_text' => $this->is_plain_text,
694
+ 'form' => $this->form,
695
+ 'entry' => $this->entry,
696
  );
697
  }
698
 
classes/models/FrmEntryFormat.php CHANGED
@@ -1,130 +1,75 @@
1
  <?php
2
 
3
  class FrmEntryFormat {
4
- public static function show_entry( $atts ) {
5
- $atts = shortcode_atts( array(
6
- 'id' => false, 'entry' => false, 'fields' => false, 'plain_text' => false,
7
- 'user_info' => false, 'include_blank' => false, 'default_email' => false,
8
- 'form_id' => false, 'format' => 'text', 'direction' => 'ltr',
9
- 'font_size' => '', 'text_color' => '',
10
- 'border_width' => '', 'border_color' => '',
11
- 'bg_color' => '', 'alt_bg_color' => '',
12
- 'clickable' => false,
13
- 'exclude_fields' => '', 'include_fields' => '',
14
- 'include_extras' => '', 'inline_style' => 1,
15
- ), $atts );
16
-
17
- $atts['exclude_fields'] = self::comma_list_to_array( $atts['exclude_fields'] );
18
- $atts['include_fields'] = self::comma_list_to_array( $atts['include_fields'] );
19
- $atts['include_extras'] = self::comma_list_to_array( $atts['include_extras'] );
20
-
21
- if ( $atts['format'] != 'text' ) {
22
- //format options are text, array, or json
23
- $atts['plain_text'] = true;
24
- }
25
-
26
- if ( is_object( $atts['entry'] ) && ! isset( $atts['entry']->metas ) ) {
27
- // if the entry does not include metas, force it again
28
- $atts['entry'] = false;
29
- }
30
-
31
- if ( ! $atts['entry'] || ! is_object( $atts['entry'] ) ) {
32
- if ( ! $atts['id'] && ! $atts['default_email'] ) {
33
- return '';
34
- }
35
-
36
- if ( $atts['id'] ) {
37
- $atts['entry'] = FrmEntry::getOne( $atts['id'], true );
38
- }
39
- }
40
-
41
- if ( $atts['entry'] ) {
42
- $atts['form_id'] = $atts['entry']->form_id;
43
- $atts['id'] = $atts['entry']->id;
44
- }
45
 
46
- if ( ! $atts['fields'] || ! is_array( $atts['fields'] ) ) {
47
- $atts['fields'] = FrmField::get_all_for_form( $atts['form_id'], '', 'include' );
48
- }
49
 
50
- $values = array();
51
- foreach ( $atts['fields'] as $f ) {
52
- if ( ! self::skip_field( $atts, $f ) ) {
53
- self::fill_entry_values( $atts, $f, $values );
54
- }
55
- unset($f);
56
- }
57
 
58
- self::fill_entry_user_info( $atts, $values );
59
- $values = apply_filters( 'frm_show_entry_array', $values, $atts );
 
 
 
 
60
 
61
- if ( $atts['format'] == 'json' ) {
62
- $content = json_encode( $values );
63
- } else if ( $atts['format'] == 'array' ) {
64
- $content = $values;
65
- } else {
66
- $content = array();
67
- self::prepare_text_output( $values, $atts, $content );
 
 
68
  }
69
 
70
- return $content;
71
  }
72
 
73
- private static function comma_list_to_array( $list ) {
74
- $array = array_map( 'strtolower', array_map( 'trim', explode( ',', $list ) ) );
75
- $field_types = array(
76
- 'section' => 'divider',
77
- 'heading' => 'divider',
78
- 'page' => 'break',
79
- );
80
- foreach ( $field_types as $label => $field_type ) {
81
- if ( in_array( $label, $array ) ) {
82
- $array[] = $field_type;
83
- }
84
- }
85
- return $array;
86
  }
87
 
88
- private static function skip_field( $atts, $field ) {
89
- $skip = ( $field->type == 'password' || $field->type == 'credit_card' );
90
-
91
- if ( $skip && ! empty( $atts['include_extras'] ) ) {
92
- $skip = ! in_array( $field->type, $atts['include_extras'] );
93
- }
94
-
95
- if ( ! $skip && ! empty( $atts['exclude_fields'] ) ) {
96
- $skip = self::field_in_list( $field, $atts['exclude_fields'] );
97
- }
98
-
99
- if ( $skip && ! empty( $atts['include_fields'] ) ) {
100
- $skip = ! self::field_in_list( $field, $atts['include_fields'] );
101
- }
102
 
103
- return $skip;
104
  }
105
 
106
- private static function field_in_list( $field, $list ) {
107
- return ( in_array( $field->id, $list ) || in_array( $field->field_key, $list ) );
 
 
 
108
  }
109
 
110
  /**
111
- * Get the labels and value shortcodes for fields in the Default HTML email message
112
- *
113
- * @since 2.0.23
114
- * @param object $f
115
- * @param array $values
116
  */
117
- public static function get_field_shortcodes_for_default_email( $f, &$values ) {
118
- $field_shortcodes = array(
119
- 'label' => '[' . $f->id . ' show=field_label]',
120
- 'val' => '[' . $f->id . ']',
121
- 'type' => $f->type,
122
- );
123
-
124
- $values[ $f->id ] = apply_filters( 'frm_field_shortcodes_for_default_html_email', $field_shortcodes, $f );
125
  }
126
 
 
 
 
127
  public static function fill_entry_values( $atts, $f, array &$values ) {
 
 
128
  $no_save_field = FrmField::is_no_save_field( $f->type );
129
  if ( $no_save_field ) {
130
  if ( ! in_array( $f->type, $atts['include_extras'] ) ) {
@@ -165,7 +110,12 @@ class FrmEntryFormat {
165
  }
166
  }
167
 
 
 
 
168
  private static function fill_missing_fields( $atts, &$values ) {
 
 
169
  if ( $atts['entry'] && ! isset( $atts['entry']->metas[ $atts['field']->id ] ) ) {
170
  // In case include_blank is set
171
  $atts['entry']->metas[ $atts['field']->id ] = '';
@@ -174,11 +124,37 @@ class FrmEntryFormat {
174
  }
175
  }
176
 
 
 
 
177
  public static function fill_values_from_entry( $atts, &$values ) {
 
 
178
  $values = apply_filters( 'frm_prepare_entry_array', $values, $atts );
179
  }
180
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  private static function get_field_value( $atts, &$val ) {
 
 
182
  $f = $atts['field'];
183
  if ( $atts['entry'] ) {
184
  $prev_val = maybe_unserialize( $atts['entry']->metas[ $f->id ] );
@@ -196,20 +172,14 @@ class FrmEntryFormat {
196
  }
197
  }
198
 
199
- /**
200
- * Flatten multi-dimensional array for multi-file upload fields
201
- * @since 2.0.9
202
- */
203
- public static function flatten_multi_file_upload( $field, &$val ) {
204
- if ( $field->type == 'file' && FrmField::is_option_true( $field, 'multiple' ) ) {
205
- $val = FrmAppHelper::array_flatten( $val );
206
- }
207
- }
208
-
209
  /**
210
  * @since 2.03.02
 
 
211
  */
212
  public static function prepare_field_output( $atts, &$val ) {
 
 
213
  $val = apply_filters( 'frm_display_' . $atts['field']->type . '_value_custom', $val, array(
214
  'field' => $atts['field'], 'atts' => $atts,
215
  ) );
@@ -220,8 +190,12 @@ class FrmEntryFormat {
220
 
221
  /**
222
  * @since 2.03.02
 
 
223
  */
224
  private static function flatten_array_value( $atts, &$val ) {
 
 
225
  if ( is_array( $val ) ) {
226
  if ( $atts['format'] == 'text' ) {
227
  $val = implode( ', ', $val );
@@ -237,8 +211,12 @@ class FrmEntryFormat {
237
  * @since 2.0.21
238
  * @param boolean $plain_text
239
  * @param mixed $val
 
 
240
  */
241
  private static function maybe_strip_html( $plain_text, &$val ) {
 
 
242
  if ( $plain_text && ! is_array( $val ) ) {
243
  if ( strpos( $val, '<img' ) !== false ) {
244
  $val = str_replace( array( '<img', 'src=', '/>', '"' ), '', $val );
@@ -248,269 +226,26 @@ class FrmEntryFormat {
248
  }
249
  }
250
 
251
- public static function fill_entry_user_info( $atts, array &$values ) {
252
- if ( ! $atts['user_info'] || empty( $atts['entry'] ) ) {
253
- return;
254
- }
255
-
256
- $data = self::get_entry_description_data( $atts );
257
-
258
- if ( $atts['default_email'] ) {
259
- $atts['entry']->ip = '[ip]';
260
- }
261
-
262
- if ( $atts['format'] != 'text' ) {
263
- $values['ip'] = $atts['entry']->ip;
264
- $values['browser'] = self::get_browser( $data['browser'] );
265
- $values['referrer'] = $data['referrer'];
266
- } else {
267
- $values['ip'] = array( 'label' => __( 'IP Address', 'formidable' ), 'val' => $atts['entry']->ip );
268
- $values['browser'] = array(
269
- 'label' => __( 'User-Agent (Browser/OS)', 'formidable' ),
270
- 'val' => self::get_browser( $data['browser'] ),
271
- );
272
- $values['referrer'] = array( 'label' => __( 'Referrer', 'formidable' ), 'val' => $data['referrer'] );
273
- }
274
- }
275
-
276
  /**
277
- * @param array $atts - include (object) entry, (boolean) default_email
278
- * @since 2.0.9
279
  */
280
- public static function get_entry_description_data( $atts ) {
281
- $default_data = array(
282
- 'browser' => '',
283
- 'referrer' => '',
284
- );
285
- $data = $default_data;
286
-
287
- if ( isset( $atts['entry']->description ) ) {
288
- $data = (array) maybe_unserialize( $atts['entry']->description );
289
- } else if ( $atts['default_email'] ) {
290
- $data = array(
291
- 'browser' => '[browser]',
292
- 'referrer' => '[referrer]',
293
- );
294
- }
295
-
296
- return array_merge( $default_data, $data );
297
- }
298
-
299
  public static function get_browser( $u_agent ) {
300
- $bname = __( 'Unknown', 'formidable' );
301
- $platform = __( 'Unknown', 'formidable' );
302
- $ub = '';
303
-
304
- // Get the operating system
305
- if ( preg_match( '/windows|win32/i', $u_agent ) ) {
306
- $platform = 'Windows';
307
- } else if ( preg_match( '/android/i', $u_agent ) ) {
308
- $platform = 'Android';
309
- } else if ( preg_match( '/linux/i', $u_agent ) ) {
310
- $platform = 'Linux';
311
- } else if ( preg_match( '/macintosh|mac os x/i', $u_agent ) ) {
312
- $platform = 'OS X';
313
- }
314
-
315
- $agent_options = array(
316
- 'Chrome' => 'Google Chrome',
317
- 'Safari' => 'Apple Safari',
318
- 'Opera' => 'Opera',
319
- 'Netscape' => 'Netscape',
320
- 'Firefox' => 'Mozilla Firefox',
321
- );
322
-
323
- // Next get the name of the useragent yes seperately and for good reason
324
- if ( strpos( $u_agent, 'MSIE' ) !== false && strpos( $u_agent, 'Opera' ) === false ) {
325
- $bname = 'Internet Explorer';
326
- $ub = 'MSIE';
327
- } else {
328
- foreach ( $agent_options as $agent_key => $agent_name ) {
329
- if ( strpos( $u_agent, $agent_key ) !== false ) {
330
- $bname = $agent_name;
331
- $ub = $agent_key;
332
- break;
333
- }
334
- }
335
- }
336
-
337
- // finally get the correct version number
338
- $known = array( 'Version', $ub, 'other' );
339
- $pattern = '#(?<browser>' . join( '|', $known ) . ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
340
- preg_match_all( $pattern, $u_agent, $matches ); // get the matching numbers
341
-
342
- // see how many we have
343
- $i = count($matches['browser']);
344
-
345
- if ( $i > 1 ) {
346
- //we will have two since we are not using 'other' argument yet
347
- //see if version is before or after the name
348
- if ( strripos( $u_agent, 'Version' ) < strripos( $u_agent, $ub ) ) {
349
- $version = $matches['version'][0];
350
- } else {
351
- $version = $matches['version'][1];
352
- }
353
- } else if ( $i === 1 ) {
354
- $version = $matches['version'][0];
355
- } else {
356
- $version = '';
357
- }
358
-
359
- // check if we have a number
360
- if ( $version == '' ) {
361
- $version = '?';
362
- }
363
-
364
- return $bname . ' ' . $version . ' / ' . $platform;
365
- }
366
-
367
- private static function prepare_text_output( $values, $atts, &$content ) {
368
- self::convert_entry_to_content( $values, $atts, $content );
369
-
370
- if ( 'text' == $atts['format'] ) {
371
- $content = implode('', $content);
372
- }
373
-
374
- if ( $atts['clickable'] ) {
375
- $content = make_clickable( $content );
376
- }
377
- }
378
-
379
- public static function convert_entry_to_content( $values, $atts, array &$content ) {
380
- if ( $atts['plain_text'] ) {
381
- self::plain_text_content( $values, $atts, $content );
382
- } else {
383
- self::html_content( $values, $atts, $content );
384
- }
385
- }
386
-
387
- private static function plain_text_content( $values, $atts, &$content ) {
388
- foreach ( $values as $id => $value ) {
389
- $atts['id'] = $id;
390
- $atts['value'] = $value;
391
- self::single_plain_text_row( $atts, $content );
392
- }
393
  }
394
 
395
- private static function html_content( $values, $atts, &$content ) {
396
- self::setup_defaults( $atts );
397
- self::prepare_inline_styles( $atts );
398
-
399
- $content[] = '<table cellspacing="0" ' . $atts['table_style'] . '><tbody>' . "\r\n";
400
-
401
- $atts['odd'] = true;
402
- foreach ( $values as $id => $value ) {
403
- $atts['id'] = $id;
404
- $atts['value'] = $value;
405
- self::single_html_row( $atts, $content );
406
- $atts['odd'] = ! $atts['odd'];
407
- }
408
-
409
- $content[] = '</tbody></table>';
410
- }
411
-
412
- private static function setup_defaults( &$atts ) {
413
- $default_settings = apply_filters( 'frm_show_entry_styles', array(
414
- 'border_color' => 'dddddd',
415
- 'bg_color' => 'f7f7f7',
416
- 'text_color' => '444444',
417
- 'font_size' => '12px',
418
- 'border_width' => '1px',
419
- 'alt_bg_color' => 'ffffff',
420
- ) );
421
-
422
- // merge defaults, global settings, and shortcode options
423
- foreach ( $default_settings as $key => $setting ) {
424
- if ( $atts[ $key ] != '' ) {
425
- continue;
426
- }
427
-
428
- $atts[ $key ] = $setting;
429
- unset( $key, $setting );
430
- }
431
- }
432
-
433
- private static function prepare_inline_styles( &$atts ) {
434
- if ( empty( $atts['inline_style'] ) ) {
435
- $atts['table_style'] = $atts['bg_color'] = $atts['bg_color_alt'] = $atts['row_style'] = '';
436
- } else {
437
- $atts['table_style'] = ' style="' . esc_attr( 'font-size:' . $atts['font_size'] . ';line-height:135%; border-bottom:' . $atts['border_width'] . ' solid #' . $atts['border_color'] . ';' ) . '"';
438
-
439
- $row_style_attributes = 'text-align:' . ( $atts['direction'] == 'rtl' ? 'right' : 'left' ) . ';';
440
- $row_style_attributes .= 'color:#' . $atts['text_color'] . ';padding:7px 9px;vertical-align:top;';
441
- $row_style_attributes .= 'border-top:' . $atts['border_width'] . ' solid #' . $atts['border_color'] . ';';
442
- $atts['row_style'] = ' style="' . $row_style_attributes . '"';
443
-
444
- if ( $atts['default_email'] ) {
445
- $atts['bg_color'] = $atts['bg_color_alt'] = ' style="[frm-alt-color]"';
446
- } else {
447
- $atts['bg_color'] = ' style="background-color:#' . $atts['bg_color'] . ';"';
448
- $atts['bg_color_alt'] = ' style="background-color:#' . $atts['alt_bg_color'] . ';"';
449
- }
450
- }
451
- }
452
-
453
- public static function single_plain_text_row( $atts, &$content ) {
454
- $row = array();
455
- if ( 'rtl' == $atts['direction'] ) {
456
- $row[] = $atts['value']['val'] . ' :' . $atts['value']['label'] . "\r\n";
457
- } else {
458
- $row[] = $atts['value']['label'] . ': ' . $atts['value']['val'] . "\r\n";
459
- }
460
- $row = apply_filters( 'frm_entry_plain_text_row', $row, $atts );
461
- $content = array_merge( $content, $row );
462
- }
463
-
464
- public static function single_html_row( $atts, &$content ) {
465
- $row = array();
466
- if ( $atts['default_email'] && is_numeric( $atts['id'] ) ) {
467
- self::default_email_row( $atts, $row );
468
- } else {
469
- self::row_content( $atts, $row );
470
- }
471
- $row = apply_filters( 'frm_entry_html_row', $row, $atts );
472
- $content = array_merge( $content, $row );
473
- }
474
-
475
- public static function html_field_row( $atts, &$content ) {
476
- $content[] = '<tr ' . self::table_row_style( $atts ) . '>';
477
- $content[] = '<td colspan="2" ' . $atts['row_style'] . '>' . $atts['value']['val'] . '</td>';
478
- $content[] = '</tr>' . "\r\n";
479
- }
480
-
481
- private static function default_email_row( $atts, &$content ) {
482
- $content[] = '[if ' . $atts['id'] . ']';
483
- self::row_content( $atts, $content );
484
- $content[] = '[/if ' . $atts['id'] . ']' . "\r\n";
485
- }
486
-
487
- private static function row_content( $atts, &$content ) {
488
- $content[] = '<tr' . self::table_row_style( $atts ) . '>';
489
-
490
- $atts['value']['val'] = str_replace( "\r\n", '<br/>', $atts['value']['val'] );
491
-
492
- if ( 'rtl' == $atts['direction'] ) {
493
- $first = $atts['value']['val'];
494
- $second = $atts['value']['label'];
495
- } else {
496
- $first = $atts['value']['label'];
497
- $second = $atts['value']['val'];
498
- }
499
-
500
- $content[] = '<td ' . $atts['row_style'] . '>' . $first . '</td>';
501
- $content[] = '<td ' . $atts['row_style'] . '>' . $second . '</td>';
502
-
503
- $content[] = '</tr>' . "\r\n";
504
- }
505
-
506
- private static function table_row_style( $atts ) {
507
- return ( $atts['odd'] ? $atts['bg_color'] : $atts['bg_color_alt'] );
508
  }
509
 
510
  /**
511
- * @deprecated 2.03.04
512
  */
513
- public static function textarea_display_value() {
514
- _deprecated_function( __FUNCTION__, '2.03.04', 'custom code' );
515
  }
516
  }
1
  <?php
2
 
3
  class FrmEntryFormat {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
+ /***********************************************************************
6
+ * Deprecated Functions
7
+ ************************************************************************/
8
 
9
+ /**
10
+ * @deprecated 2.03.04
11
+ */
12
+ public static function textarea_display_value() {
13
+ _deprecated_function( __FUNCTION__, '2.03.04', 'custom code' );
14
+ }
 
15
 
16
+ /**
17
+ * @deprecated 2.04
18
+ */
19
+ public static function single_html_row( $atts, &$content ) {
20
+ _deprecated_function( __FUNCTION__, '2.04', 'custom code' );
21
+ }
22
 
23
+ /**
24
+ * @deprecated 2.04
25
+ *
26
+ * @param stdClass $field
27
+ * @param array|string $val
28
+ */
29
+ public static function flatten_multi_file_upload( $field, &$val ) {
30
+ if ( $field->type == 'file' && FrmField::is_option_true( $field, 'multiple' ) ) {
31
+ $val = FrmAppHelper::array_flatten( $val );
32
  }
33
 
34
+ _deprecated_function( __FUNCTION__, '2.04', 'custom code' );
35
  }
36
 
37
+ /**
38
+ * @deprecated 2.04
39
+ */
40
+ public static function fill_entry_user_info() {
41
+ _deprecated_function( __FUNCTION__, '2.04', 'custom code' );
 
 
 
 
 
 
 
 
42
  }
43
 
44
+ /**
45
+ * @deprecated 2.04
46
+ */
47
+ public static function get_entry_description_data() {
48
+ _deprecated_function( __FUNCTION__, '2.04', 'custom code' );
 
 
 
 
 
 
 
 
 
49
 
50
+ return array();
51
  }
52
 
53
+ /**
54
+ * @deprecated 2.04
55
+ */
56
+ public static function single_plain_text_row() {
57
+ _deprecated_function( __FUNCTION__, '2.04', 'custom code' );
58
  }
59
 
60
  /**
61
+ * @deprecated 2.04
 
 
 
 
62
  */
63
+ public static function html_field_row() {
64
+ _deprecated_function( __FUNCTION__, '2.04', 'custom code' );
 
 
 
 
 
 
65
  }
66
 
67
+ /**
68
+ * @deprecated 2.04
69
+ */
70
  public static function fill_entry_values( $atts, $f, array &$values ) {
71
+ _deprecated_function( __FUNCTION__, '2.04', 'instance of FrmEntryValues or FrmProEntryValues' );
72
+
73
  $no_save_field = FrmField::is_no_save_field( $f->type );
74
  if ( $no_save_field ) {
75
  if ( ! in_array( $f->type, $atts['include_extras'] ) ) {
110
  }
111
  }
112
 
113
+ /**
114
+ * @deprecated 2.04
115
+ */
116
  private static function fill_missing_fields( $atts, &$values ) {
117
+ _deprecated_function( __FUNCTION__, '2.04', 'instance of FrmEntryValues or FrmProEntryValues' );
118
+
119
  if ( $atts['entry'] && ! isset( $atts['entry']->metas[ $atts['field']->id ] ) ) {
120
  // In case include_blank is set
121
  $atts['entry']->metas[ $atts['field']->id ] = '';
124
  }
125
  }
126
 
127
+ /**
128
+ * @deprecated 2.04
129
+ */
130
  public static function fill_values_from_entry( $atts, &$values ) {
131
+ _deprecated_function( __FUNCTION__, '2.04', 'instance of FrmEntryValues or FrmProEntryValues' );
132
+
133
  $values = apply_filters( 'frm_prepare_entry_array', $values, $atts );
134
  }
135
 
136
+ /**
137
+ * @deprecated 2.04
138
+ */
139
+ public static function get_field_shortcodes_for_default_email( $f, &$values ) {
140
+ // TODO: adjust this message
141
+ _deprecated_function( __FUNCTION__, '2.04', 'instance of FrmEntryValues or FrmProEntryValues' );
142
+
143
+ $field_shortcodes = array(
144
+ 'label' => '[' . $f->id . ' show=field_label]',
145
+ 'val' => '[' . $f->id . ']',
146
+ 'type' => $f->type,
147
+ );
148
+
149
+ $values[ $f->id ] = apply_filters( 'frm_field_shortcodes_for_default_html_email', $field_shortcodes, $f );
150
+ }
151
+
152
+ /**
153
+ * @deprecated 2.04
154
+ */
155
  private static function get_field_value( $atts, &$val ) {
156
+ _deprecated_function( __FUNCTION__, '2.04', 'instance of FrmEntryValues or FrmProEntryValues' );
157
+
158
  $f = $atts['field'];
159
  if ( $atts['entry'] ) {
160
  $prev_val = maybe_unserialize( $atts['entry']->metas[ $f->id ] );
172
  }
173
  }
174
 
 
 
 
 
 
 
 
 
 
 
175
  /**
176
  * @since 2.03.02
177
+ *
178
+ * @deprecated 2.04
179
  */
180
  public static function prepare_field_output( $atts, &$val ) {
181
+ _deprecated_function( __FUNCTION__, '2.04', 'instance of FrmEntryValues or FrmProEntryValues' );
182
+
183
  $val = apply_filters( 'frm_display_' . $atts['field']->type . '_value_custom', $val, array(
184
  'field' => $atts['field'], 'atts' => $atts,
185
  ) );
190
 
191
  /**
192
  * @since 2.03.02
193
+ *
194
+ * @deprecated 2.04
195
  */
196
  private static function flatten_array_value( $atts, &$val ) {
197
+ _deprecated_function( __FUNCTION__, '2.04', 'instance of FrmEntryValues or FrmProEntryValues' );
198
+
199
  if ( is_array( $val ) ) {
200
  if ( $atts['format'] == 'text' ) {
201
  $val = implode( ', ', $val );
211
  * @since 2.0.21
212
  * @param boolean $plain_text
213
  * @param mixed $val
214
+ *
215
+ * @deprecated 2.04
216
  */
217
  private static function maybe_strip_html( $plain_text, &$val ) {
218
+ _deprecated_function( __FUNCTION__, '2.04', 'instance of FrmEntryValues or FrmProEntryValues' );
219
+
220
  if ( $plain_text && ! is_array( $val ) ) {
221
  if ( strpos( $val, '<img' ) !== false ) {
222
  $val = str_replace( array( '<img', 'src=', '/>', '"' ), '', $val );
226
  }
227
  }
228
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
229
  /**
230
+ * @deprecated 2.04
 
231
  */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
232
  public static function get_browser( $u_agent ) {
233
+ _deprecated_function( __FUNCTION__, '2.04', 'FrmEntriesHelper::get_browser' );
234
+ return FrmEntriesHelper::get_browser( $u_agent );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
235
  }
236
 
237
+ /**
238
+ * @deprecated 2.04
239
+ */
240
+ public static function show_entry( $atts ) {
241
+ _deprecated_function( __FUNCTION__, '2.04', 'FrmEntriesController::show_entry_shortcode' );
242
+ return FrmEntriesController::show_entry_shortcode( $atts );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
243
  }
244
 
245
  /**
246
+ * @deprecated 2.04
247
  */
248
+ public static function convert_entry_to_content() {
249
+ _deprecated_function( __FUNCTION__, '2.04', 'FrmEntriesController::show_entry_shortcode' );
250
  }
251
  }
classes/models/FrmEntryFormatter.php ADDED
@@ -0,0 +1,625 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @since 2.04
5
+ */
6
+ class FrmEntryFormatter {
7
+
8
+ /**
9
+ * @var stdClass
10
+ * @since 2.04
11
+ */
12
+ protected $entry = null;
13
+
14
+ /**
15
+ * @var FrmEntryValues
16
+ * @since 2.04
17
+ */
18
+ protected $entry_values = null;
19
+
20
+ /**
21
+ * @var bool
22
+ * @since 2.04
23
+ */
24
+ protected $is_plain_text = false;
25
+
26
+ /**
27
+ * @var bool
28
+ * @since 2.04
29
+ */
30
+ protected $include_user_info = false;
31
+
32
+ /**
33
+ * @var bool
34
+ * @since 2.04
35
+ */
36
+ protected $include_blank = false;
37
+
38
+ /**
39
+ * @var string
40
+ * @since 2.04
41
+ */
42
+ protected $format = 'text';
43
+
44
+ /**
45
+ * @var string
46
+ * @since 2.04
47
+ */
48
+ protected $direction = 'ltr';
49
+
50
+ /**
51
+ * @var FrmTableHTMLGenerator
52
+ * @since 2.04
53
+ */
54
+ protected $table_generator = null;
55
+
56
+ /**
57
+ * @var bool
58
+ * @since 2.04
59
+ */
60
+ protected $is_clickable = false;
61
+
62
+ /**
63
+ * @var array
64
+ * @since 2.04
65
+ */
66
+ protected $include_extras = array();
67
+
68
+ /**
69
+ * @var array
70
+ * @since 2.04
71
+ */
72
+ protected $skip_fields = array( 'captcha' );
73
+
74
+ /**
75
+ * FrmEntryFormat constructor
76
+ *
77
+ * @since 2.04
78
+ *
79
+ * @param $atts
80
+ */
81
+ public function __construct( $atts ) {
82
+ $this->init_entry( $atts );
83
+
84
+ if ( $this->entry === null || $this->entry === false ) {
85
+ return;
86
+ }
87
+
88
+ $this->init_is_plain_text( $atts );
89
+ $this->init_format( $atts );
90
+ $this->init_include_blank( $atts );
91
+ $this->init_direction( $atts );
92
+ $this->init_include_user_info( $atts );
93
+ $this->init_entry_values( $atts );
94
+
95
+ if ( $this->format === 'table' ) {
96
+ $this->init_table_generator( $atts );
97
+ $this->init_is_clickable( $atts );
98
+ }
99
+ }
100
+
101
+ /**
102
+ * Set the entry property
103
+ *
104
+ * @since 2.04
105
+ *
106
+ * @param array $atts
107
+ */
108