Formidable Forms – Form Builder for WordPress - Version 4.0b1

Version Description

Download this release

Release Info

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

Code changes from version 3.06.05 to 4.0b1

Files changed (118) hide show
  1. classes/controllers/FrmAddonsController.php +48 -34
  2. classes/controllers/FrmAppController.php +161 -146
  3. classes/controllers/FrmEntriesController.php +212 -219
  4. classes/controllers/FrmFieldsController.php +373 -296
  5. classes/controllers/FrmFormActionsController.php +336 -187
  6. classes/controllers/FrmFormsController.php +664 -491
  7. classes/controllers/FrmHooksController.php +133 -137
  8. classes/controllers/FrmSettingsController.php +137 -44
  9. classes/controllers/FrmSimpleBlocksController.php +5 -4
  10. classes/controllers/FrmStylesController.php +199 -244
  11. classes/controllers/FrmXMLController.php +50 -43
  12. classes/factories/FrmFieldFactory.php +5 -0
  13. classes/helpers/FrmAppHelper.php +869 -742
  14. classes/helpers/FrmCSVExportHelper.php +49 -43
  15. classes/helpers/FrmEmailHelper.php +3 -1
  16. classes/helpers/FrmEntriesHelper.php +308 -230
  17. classes/helpers/FrmEntriesListHelper.php +58 -55
  18. classes/helpers/FrmFieldsHelper.php +643 -276
  19. classes/helpers/FrmFormsHelper.php +506 -280
  20. classes/helpers/FrmFormsListHelper.php +131 -117
  21. classes/helpers/FrmListHelper.php +116 -81
  22. classes/helpers/FrmShortcodeHelper.php +6 -4
  23. classes/helpers/FrmStylesHelper.php +170 -77
  24. classes/helpers/FrmTipsHelper.php +13 -7
  25. classes/helpers/FrmXMLHelper.php +553 -463
  26. classes/models/FrmAddon.php +45 -34
  27. classes/models/FrmCreateFile.php +13 -11
  28. classes/models/FrmDb.php +196 -172
  29. classes/models/FrmEmail.php +6 -3
  30. classes/models/FrmEntry.php +372 -322
  31. classes/models/FrmEntryFormatter.php +21 -21
  32. classes/models/FrmEntryMeta.php +132 -127
  33. classes/models/FrmEntryShortcodeFormatter.php +2 -1
  34. classes/models/FrmEntryValidate.php +77 -67
  35. classes/models/FrmEntryValues.php +5 -5
  36. classes/models/FrmField.php +291 -266
  37. classes/models/FrmFieldFormHtml.php +9 -9
  38. classes/models/FrmFieldOption.php +1 -1
  39. classes/models/FrmFieldValue.php +4 -3
  40. classes/models/FrmFieldValueSelector.php +1 -2
  41. classes/models/FrmForm.php +311 -277
  42. classes/models/FrmFormAction.php +283 -221
  43. classes/models/FrmFormApi.php +8 -3
  44. classes/models/FrmFormMigrator.php +30 -20
  45. classes/models/FrmMigrate.php +165 -87
  46. classes/models/FrmNotification.php +1 -0
  47. classes/models/FrmPersonalData.php +13 -2
  48. classes/models/FrmReviews.php +6 -4
  49. classes/models/FrmSettings.php +123 -122
  50. classes/models/FrmStyle.php +287 -278
  51. classes/models/FrmTableHTMLGenerator.php +15 -7
  52. classes/models/fields/FrmFieldCaptcha.php +18 -12
  53. classes/models/fields/FrmFieldCheckbox.php +2 -7
  54. classes/models/fields/FrmFieldEmail.php +1 -0
  55. classes/models/fields/FrmFieldHTML.php +13 -1
  56. classes/models/fields/FrmFieldHidden.php +3 -1
  57. classes/models/fields/FrmFieldNumber.php +1 -1
  58. classes/models/fields/FrmFieldPhone.php +1 -0
  59. classes/models/fields/FrmFieldRadio.php +2 -7
  60. classes/models/fields/FrmFieldSelect.php +11 -1
  61. classes/models/fields/FrmFieldTextarea.php +2 -2
  62. classes/models/fields/FrmFieldType.php +158 -71
  63. classes/models/fields/FrmFieldUrl.php +3 -3
  64. classes/models/fields/FrmFieldUserID.php +6 -4
  65. classes/views/addons/list.php +28 -11
  66. classes/views/addons/settings.php +8 -8
  67. classes/views/addons/upgrade_to_pro.php +7 -7
  68. classes/views/frm-entries/_sidebar-shared-pub.php +24 -17
  69. classes/views/frm-entries/direct.php +1 -1
  70. classes/views/frm-entries/errors.php +22 -22
  71. classes/views/frm-entries/form.php +19 -10
  72. classes/views/frm-entries/list.php +41 -22
  73. classes/views/frm-entries/new.php +5 -5
  74. classes/views/frm-entries/no_entries.php +38 -5
  75. classes/views/frm-entries/show.php +54 -73
  76. classes/views/frm-entries/sidebar-shared.php +115 -90
  77. classes/views/frm-entries/sidebar-show.php +2 -24
  78. classes/views/frm-fields/back-end/ajax-field-placeholder.php +2 -2
  79. classes/views/frm-fields/back-end/automatic-width.php +6 -9
  80. classes/views/frm-fields/back-end/bulk-options-overlay.php +35 -0
  81. classes/views/frm-fields/back-end/dropdown-field.php +4 -10
  82. classes/views/frm-fields/back-end/field-captcha.php +7 -4
  83. classes/views/frm-fields/back-end/field-description.php +8 -0
  84. classes/views/frm-fields/back-end/field-hidden.php +2 -2
  85. classes/views/frm-fields/back-end/field-html.php +5 -5
  86. classes/views/frm-fields/back-end/field-multiple.php +5 -7
  87. classes/views/frm-fields/back-end/field-user-id.php +4 -3
  88. classes/views/frm-fields/back-end/html-content.php +6 -5
  89. classes/views/frm-fields/back-end/inline-modal.php +15 -0
  90. classes/views/frm-fields/back-end/input-mask-info.php +28 -0
  91. classes/views/frm-fields/back-end/layout-classes.php +44 -0
  92. classes/views/frm-fields/back-end/max.php +12 -1
  93. classes/views/frm-fields/back-end/number-range.php +19 -15
  94. classes/views/frm-fields/back-end/pixels-wide.php +15 -17
  95. classes/views/frm-fields/back-end/radio-field.php +48 -0
  96. classes/views/frm-fields/back-end/settings.php +382 -0
  97. classes/views/frm-fields/back-end/smart-values.php +18 -0
  98. classes/views/frm-fields/back-end/value-format.php +9 -7
  99. classes/views/frm-fields/front-end/checkbox-field.php +36 -27
  100. classes/views/frm-fields/front-end/dropdown-field.php +16 -1
  101. classes/views/frm-fields/front-end/radio-field.php +36 -29
  102. classes/views/frm-fields/import_choices.php +0 -61
  103. classes/views/frm-fields/single-option.php +11 -16
  104. classes/views/frm-form-actions/_action_icon.php +23 -0
  105. classes/views/frm-form-actions/_action_inside.php +30 -24
  106. classes/views/frm-form-actions/_email_settings.php +80 -84
  107. classes/views/frm-form-actions/default_actions.php +74 -10
  108. classes/views/frm-form-actions/email_action.php +17 -17
  109. classes/views/frm-form-actions/form_action.php +24 -23
  110. classes/views/frm-form-actions/settings.php +80 -0
  111. classes/views/frm-forms/_publish_box.php +17 -31
  112. classes/views/frm-forms/actions-dropdown.php +9 -9
  113. classes/views/frm-forms/add-new.php +6 -1
  114. classes/views/frm-forms/add_field.php +54 -335
  115. classes/views/frm-forms/add_field_links.php +114 -126
  116. classes/views/frm-forms/edit.php +19 -27
  117. classes/views/frm-forms/form.php +37 -43
  118. classes/views/frm-forms/insert_form_popup.php +18 -48
classes/controllers/FrmAddonsController.php CHANGED
@@ -16,12 +16,15 @@ class FrmAddonsController {
16
 
17
  public static function list_addons() {
18
  $installed_addons = apply_filters( 'frm_installed_addons', array() );
 
19
 
20
  $addons = self::get_api_addons();
21
  $errors = array();
 
22
  if ( isset( $addons['error'] ) ) {
23
  $api = new FrmFormApi();
24
  $errors = $api->get_error_from_response( $addons );
 
25
  unset( $addons['error'] );
26
  }
27
  self::prepare_addons( $addons );
@@ -35,6 +38,7 @@ class FrmAddonsController {
35
  $plugins = apply_filters( 'frm_installed_addons', array() );
36
  if ( empty( $plugins ) ) {
37
  esc_html_e( 'There are no plugins on your site that require a license', 'formidable' );
 
38
  return;
39
  }
40
 
@@ -44,7 +48,7 @@ class FrmAddonsController {
44
  }
45
 
46
  private static function get_api_addons() {
47
- $api = new FrmFormApi();
48
  $addons = $api->get_api_info();
49
 
50
  if ( empty( $addons ) ) {
@@ -74,64 +78,64 @@ class FrmAddonsController {
74
  'docs' => '',
75
  'excerpt' => 'Enhance your basic Formidable forms with a plethora of Pro field types and features. Create advanced forms and data-driven applications in minutes.',
76
  ),
77
- 'mailchimp' => array(
78
  'title' => 'MailChimp Forms',
79
  'excerpt' => 'Get on the path to more sales and leads in a matter of minutes. Add leads to a MailChimp mailing list when they submit forms and update their information along with the entry.',
80
  ),
81
- 'registration' => array(
82
  'title' => 'User Registration Forms',
83
  'link' => 'downloads/user-registration/',
84
  'excerpt' => 'Give new users access to your site as quickly and painlessly as possible. Allow users to register, edit and be able to login to their profiles on your site from the front end in a clean, customized registration form.',
85
  ),
86
- 'paypal' => array(
87
  'title' => 'PayPal Standard Forms',
88
  'link' => 'downloads/paypal-standard/',
89
  'excerpt' => 'Automate your business by collecting instant payments from your clients. Collect information, calculate a total, and send them on to PayPal. Require a payment before publishing content on your site.',
90
  ),
91
- 'stripe' => array(
92
  'title' => 'Stripe Forms',
93
  'docs' => 'knowledgebase/stripe/',
94
  'excerpt' => 'Any Formidable forms on your site can accept credit card payments without users ever leaving your site.',
95
  ),
96
- 'authorize-net' => array(
97
  'title' => 'Authorize.net AIM Forms',
98
  'link' => 'downloads/authorize-net-aim/',
99
  'docs' => 'knowledgebase/authorize-net-aim/',
100
  'excerpt' => 'Accept one-time payments directly on your site, using Authorize.net AIM.',
101
  ),
102
- 'woocommerce' => array(
103
  'title' => 'WooCommerce Forms',
104
  'excerpt' => 'Use a Formidable form on your WooCommerce product pages.',
105
  ),
106
- 'autoresponder' => array(
107
  'title' => 'Form Action Automation',
108
  'docs' => 'knowledgebase/schedule-autoresponder/',
109
  'excerpt' => 'Schedule email notifications, SMS messages, and API actions.',
110
  ),
111
- 'modal' => array(
112
  'title' => 'Bootstrap Modal Forms',
113
  'link' => 'downloads/bootstrap-modal/',
114
  'docs' => 'knowledgebase/bootstrap-modal/',
115
  'excerpt' => 'Open a view or form in a Bootstrap popup.',
116
  ),
117
- 'bootstrap' => array(
118
  'title' => 'Bootstrap Style Forms',
119
  'excerpt' => 'Instantly add Bootstrap styling to all your Formidable forms.',
120
  ),
121
- 'zapier' => array(
122
  'title' => 'Zapier Forms',
123
  'excerpt' => 'Connect with hundreds of different applications through Zapier. Insert a new row in a Google docs spreadsheet, post on Twitter, or add a new Dropbox file with your form.',
124
  ),
125
- 'signature' => array(
126
  'title' => 'Digital Signature Forms',
127
  'excerpt' => 'Add a signature field to your form. The user may write their signature with a trackpad/mouse or just type it.',
128
  ),
129
- 'api' => array(
130
  'title' => 'Formidable Forms API',
131
  'link' => 'downloads/formidable-api/',
132
  'excerpt' => 'Send entry results to any other site that has a Rest API. This includes the option of sending entries from one Formidable site to another.',
133
  ),
134
- 'twilio' => array(
135
  'title' => 'Twilio SMS Forms',
136
  'docs' => 'knowledgebase/twilio-add-on/',
137
  'excerpt' => 'Allow users to text their votes for polls created by Formidable Forms, or send SMS notifications when entries are submitted or updated.',
@@ -146,8 +150,8 @@ class FrmAddonsController {
146
  * @return string
147
  */
148
  public static function get_pro_download_url() {
149
- $pro_cred_store = 'frmpro-credentials';
150
- $pro_wpmu_store = 'frmpro-wpmu-sitewide';
151
  if ( is_multisite() && get_site_option( $pro_wpmu_store ) ) {
152
  $creds = get_site_option( $pro_cred_store );
153
  } else {
@@ -168,9 +172,9 @@ class FrmAddonsController {
168
  $license = strtoupper( $license );
169
  }
170
 
171
- $api = new FrmFormApi( $license );
172
  $downloads = $api->get_api_info();
173
- $pro = isset( $downloads['93790'] ) ? $downloads['93790'] : array();
174
 
175
  return isset( $pro['url'] ) ? $pro['url'] : '';
176
  }
@@ -215,8 +219,8 @@ class FrmAddonsController {
215
  $wp_version = isset( $wp_plugin['Version'] ) ? $wp_plugin['Version'] : '1.0';
216
 
217
  if ( version_compare( $wp_version, $plugin->new_version, '<' ) ) {
218
- $slug = explode( '/', $folder );
219
- $plugin->slug = $slug[0];
220
  $transient->response[ $folder ] = $plugin;
221
  }
222
 
@@ -231,7 +235,9 @@ class FrmAddonsController {
231
  * Check if a plugin is installed before showing an update for it
232
  *
233
  * @since 3.05
 
234
  * @param string $plugin - the folder/filename.php for a plugin
 
235
  * @return bool - True if installed
236
  */
237
  private static function is_installed( $plugin ) {
@@ -240,6 +246,7 @@ class FrmAddonsController {
240
  }
241
 
242
  $all_plugins = get_plugins();
 
243
  return isset( $all_plugins[ $plugin ] );
244
  }
245
 
@@ -324,6 +331,10 @@ class FrmAddonsController {
324
  'url' => $addon['url'],
325
  'class' => 'frm-install-addon',
326
  );
 
 
 
 
327
  }
328
 
329
  return $link;
@@ -332,13 +343,15 @@ class FrmAddonsController {
332
 
333
  /**
334
  * @since 3.04.03
 
335
  * @param array $addons
336
  * @param object $license The FrmAddon object
 
337
  * @return array
338
  */
339
  public static function get_addon_for_license( $addons, $license ) {
340
  $download_id = $license->download_id;
341
- $plugin = array();
342
  if ( empty( $download_id ) && ! empty( $addons ) ) {
343
  foreach ( $addons as $addon ) {
344
  if ( strtolower( $license->plugin_name ) == strtolower( $addon['title'] ) ) {
@@ -361,7 +374,7 @@ class FrmAddonsController {
361
  $loop_addons = $addons;
362
  foreach ( $loop_addons as $id => $addon ) {
363
  if ( is_numeric( $id ) ) {
364
- $slug = str_replace( array( '-wordpress-plugin', '-wordpress' ), '', $addon['slug'] );
365
  $file_name = $addon['plugin'];
366
  } else {
367
  $slug = $id;
@@ -379,8 +392,8 @@ class FrmAddonsController {
379
  if ( $addon['installed'] && ! empty( $activate_url ) && ! is_plugin_active( $file_name ) ) {
380
  $addon['activate_url'] = add_query_arg(
381
  array(
382
- '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $file_name ),
383
- 'plugin' => $file_name,
384
  ),
385
  $activate_url
386
  );
@@ -409,13 +422,13 @@ class FrmAddonsController {
409
  if ( strpos( $link, 'http' ) !== 0 ) {
410
  $link = $site_url . $link;
411
  }
412
- $link = FrmAppHelper::make_affiliate_url( $link );
413
  $query_args = array(
414
  'utm_source' => 'WordPress',
415
  'utm_medium' => 'addons',
416
  'utm_campaign' => 'liteplugin',
417
  );
418
- $link = add_query_arg( $query_args, $link );
419
  }
420
 
421
  /**
@@ -653,13 +666,13 @@ class FrmAddonsController {
653
 
654
  private static function prepare_pro_info() {
655
  return array(
656
- 'personal' => array(
657
  'id' => 2,
658
  'download' => 19367654,
659
  'price' => '49.00',
660
  'name' => 'Personal',
661
  ),
662
- 'professional' => array(
663
  'id' => 0,
664
  'download' => 19367001,
665
  'price' => '99.00',
@@ -671,7 +684,7 @@ class FrmAddonsController {
671
  'price' => '199.00',
672
  'name' => 'Business',
673
  ),
674
- 'enterprise' => array(
675
  'id' => 0,
676
  'download' => 19366992,
677
  'price' => '399.00',
@@ -709,10 +722,10 @@ class FrmAddonsController {
709
  ob_start();
710
 
711
  $show_form = false;
712
- $method = '';
713
- $url = add_query_arg( array( 'page' => 'formidable-settings' ), admin_url( 'admin.php' ) );
714
- $url = esc_url_raw( $url );
715
- $creds = request_filesystem_credentials( $url, $method, false, false, null );
716
 
717
  if ( false === $creds ) {
718
  $show_form = true;
@@ -740,7 +753,7 @@ class FrmAddonsController {
740
  private static function install_addon() {
741
  require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
742
 
743
- $download_url = esc_url_raw( $_POST['plugin'] );
744
 
745
  // Create the plugin upgrader with our custom skin.
746
  $installer = new Plugin_Upgrader( new FrmInstallerSkin() );
@@ -748,6 +761,7 @@ class FrmAddonsController {
748
 
749
  // Flush the cache and return the newly installed plugin basename.
750
  wp_cache_flush();
 
751
  return $installer->plugin_info();
752
  }
753
 
16
 
17
  public static function list_addons() {
18
  $installed_addons = apply_filters( 'frm_installed_addons', array() );
19
+ $license_type = '';
20
 
21
  $addons = self::get_api_addons();
22
  $errors = array();
23
+
24
  if ( isset( $addons['error'] ) ) {
25
  $api = new FrmFormApi();
26
  $errors = $api->get_error_from_response( $addons );
27
+ $license_type = isset( $addons['error']['type'] ) ? $addons['error']['type'] : '';
28
  unset( $addons['error'] );
29
  }
30
  self::prepare_addons( $addons );
38
  $plugins = apply_filters( 'frm_installed_addons', array() );
39
  if ( empty( $plugins ) ) {
40
  esc_html_e( 'There are no plugins on your site that require a license', 'formidable' );
41
+
42
  return;
43
  }
44
 
48
  }
49
 
50
  private static function get_api_addons() {
51
+ $api = new FrmFormApi();
52
  $addons = $api->get_api_info();
53
 
54
  if ( empty( $addons ) ) {
78
  'docs' => '',
79
  'excerpt' => 'Enhance your basic Formidable forms with a plethora of Pro field types and features. Create advanced forms and data-driven applications in minutes.',
80
  ),
81
+ 'mailchimp' => array(
82
  'title' => 'MailChimp Forms',
83
  'excerpt' => 'Get on the path to more sales and leads in a matter of minutes. Add leads to a MailChimp mailing list when they submit forms and update their information along with the entry.',
84
  ),
85
+ 'registration' => array(
86
  'title' => 'User Registration Forms',
87
  'link' => 'downloads/user-registration/',
88
  'excerpt' => 'Give new users access to your site as quickly and painlessly as possible. Allow users to register, edit and be able to login to their profiles on your site from the front end in a clean, customized registration form.',
89
  ),
90
+ 'paypal' => array(
91
  'title' => 'PayPal Standard Forms',
92
  'link' => 'downloads/paypal-standard/',
93
  'excerpt' => 'Automate your business by collecting instant payments from your clients. Collect information, calculate a total, and send them on to PayPal. Require a payment before publishing content on your site.',
94
  ),
95
+ 'stripe' => array(
96
  'title' => 'Stripe Forms',
97
  'docs' => 'knowledgebase/stripe/',
98
  'excerpt' => 'Any Formidable forms on your site can accept credit card payments without users ever leaving your site.',
99
  ),
100
+ 'authorize-net' => array(
101
  'title' => 'Authorize.net AIM Forms',
102
  'link' => 'downloads/authorize-net-aim/',
103
  'docs' => 'knowledgebase/authorize-net-aim/',
104
  'excerpt' => 'Accept one-time payments directly on your site, using Authorize.net AIM.',
105
  ),
106
+ 'woocommerce' => array(
107
  'title' => 'WooCommerce Forms',
108
  'excerpt' => 'Use a Formidable form on your WooCommerce product pages.',
109
  ),
110
+ 'autoresponder' => array(
111
  'title' => 'Form Action Automation',
112
  'docs' => 'knowledgebase/schedule-autoresponder/',
113
  'excerpt' => 'Schedule email notifications, SMS messages, and API actions.',
114
  ),
115
+ 'modal' => array(
116
  'title' => 'Bootstrap Modal Forms',
117
  'link' => 'downloads/bootstrap-modal/',
118
  'docs' => 'knowledgebase/bootstrap-modal/',
119
  'excerpt' => 'Open a view or form in a Bootstrap popup.',
120
  ),
121
+ 'bootstrap' => array(
122
  'title' => 'Bootstrap Style Forms',
123
  'excerpt' => 'Instantly add Bootstrap styling to all your Formidable forms.',
124
  ),
125
+ 'zapier' => array(
126
  'title' => 'Zapier Forms',
127
  'excerpt' => 'Connect with hundreds of different applications through Zapier. Insert a new row in a Google docs spreadsheet, post on Twitter, or add a new Dropbox file with your form.',
128
  ),
129
+ 'signature' => array(
130
  'title' => 'Digital Signature Forms',
131
  'excerpt' => 'Add a signature field to your form. The user may write their signature with a trackpad/mouse or just type it.',
132
  ),
133
+ 'api' => array(
134
  'title' => 'Formidable Forms API',
135
  'link' => 'downloads/formidable-api/',
136
  'excerpt' => 'Send entry results to any other site that has a Rest API. This includes the option of sending entries from one Formidable site to another.',
137
  ),
138
+ 'twilio' => array(
139
  'title' => 'Twilio SMS Forms',
140
  'docs' => 'knowledgebase/twilio-add-on/',
141
  'excerpt' => 'Allow users to text their votes for polls created by Formidable Forms, or send SMS notifications when entries are submitted or updated.',
150
  * @return string
151
  */
152
  public static function get_pro_download_url() {
153
+ $pro_cred_store = 'frmpro-credentials';
154
+ $pro_wpmu_store = 'frmpro-wpmu-sitewide';
155
  if ( is_multisite() && get_site_option( $pro_wpmu_store ) ) {
156
  $creds = get_site_option( $pro_cred_store );
157
  } else {
172
  $license = strtoupper( $license );
173
  }
174
 
175
+ $api = new FrmFormApi( $license );
176
  $downloads = $api->get_api_info();
177
+ $pro = isset( $downloads['93790'] ) ? $downloads['93790'] : array();
178
 
179
  return isset( $pro['url'] ) ? $pro['url'] : '';
180
  }
219
  $wp_version = isset( $wp_plugin['Version'] ) ? $wp_plugin['Version'] : '1.0';
220
 
221
  if ( version_compare( $wp_version, $plugin->new_version, '<' ) ) {
222
+ $slug = explode( '/', $folder );
223
+ $plugin->slug = $slug[0];
224
  $transient->response[ $folder ] = $plugin;
225
  }
226
 
235
  * Check if a plugin is installed before showing an update for it
236
  *
237
  * @since 3.05
238
+ *
239
  * @param string $plugin - the folder/filename.php for a plugin
240
+ *
241
  * @return bool - True if installed
242
  */
243
  private static function is_installed( $plugin ) {
246
  }
247
 
248
  $all_plugins = get_plugins();
249
+
250
  return isset( $all_plugins[ $plugin ] );
251
  }
252
 
331
  'url' => $addon['url'],
332
  'class' => 'frm-install-addon',
333
  );
334
+ } elseif ( isset( $addon['categories'] ) && ! empty( $addon['categories'] ) ) {
335
+ $link = array(
336
+ 'categories' => $addon['categories'],
337
+ );
338
  }
339
 
340
  return $link;
343
 
344
  /**
345
  * @since 3.04.03
346
+ *
347
  * @param array $addons
348
  * @param object $license The FrmAddon object
349
+ *
350
  * @return array
351
  */
352
  public static function get_addon_for_license( $addons, $license ) {
353
  $download_id = $license->download_id;
354
+ $plugin = array();
355
  if ( empty( $download_id ) && ! empty( $addons ) ) {
356
  foreach ( $addons as $addon ) {
357
  if ( strtolower( $license->plugin_name ) == strtolower( $addon['title'] ) ) {
374
  $loop_addons = $addons;
375
  foreach ( $loop_addons as $id => $addon ) {
376
  if ( is_numeric( $id ) ) {
377
+ $slug = str_replace( array( '-wordpress-plugin', '-wordpress' ), '', $addon['slug'] );
378
  $file_name = $addon['plugin'];
379
  } else {
380
  $slug = $id;
392
  if ( $addon['installed'] && ! empty( $activate_url ) && ! is_plugin_active( $file_name ) ) {
393
  $addon['activate_url'] = add_query_arg(
394
  array(
395
+ '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $file_name ),
396
+ 'plugin' => $file_name,
397
  ),
398
  $activate_url
399
  );
422
  if ( strpos( $link, 'http' ) !== 0 ) {
423
  $link = $site_url . $link;
424
  }
425
+ $link = FrmAppHelper::make_affiliate_url( $link );
426
  $query_args = array(
427
  'utm_source' => 'WordPress',
428
  'utm_medium' => 'addons',
429
  'utm_campaign' => 'liteplugin',
430
  );
431
+ $link = add_query_arg( $query_args, $link );
432
  }
433
 
434
  /**
666
 
667
  private static function prepare_pro_info() {
668
  return array(
669
+ 'personal' => array(
670
  'id' => 2,
671
  'download' => 19367654,
672
  'price' => '49.00',
673
  'name' => 'Personal',
674
  ),
675
+ 'professional' => array(
676
  'id' => 0,
677
  'download' => 19367001,
678
  'price' => '99.00',
684
  'price' => '199.00',
685
  'name' => 'Business',
686
  ),
687
+ 'enterprise' => array(
688
  'id' => 0,
689
  'download' => 19366992,
690
  'price' => '399.00',
722
  ob_start();
723
 
724
  $show_form = false;
725
+ $method = '';
726
+ $url = add_query_arg( array( 'page' => 'formidable-settings' ), admin_url( 'admin.php' ) );
727
+ $url = esc_url_raw( $url );
728
+ $creds = request_filesystem_credentials( $url, $method, false, false, null );
729
 
730
  if ( false === $creds ) {
731
  $show_form = true;
753
  private static function install_addon() {
754
  require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
755
 
756
+ $download_url = FrmAppHelper::get_param( 'plugin', '', 'post', 'esc_url_raw' );
757
 
758
  // Create the plugin upgrader with our custom skin.
759
  $installer = new Plugin_Upgrader( new FrmInstallerSkin() );
761
 
762
  // Flush the cache and return the newly installed plugin basename.
763
  wp_cache_flush();
764
+
765
  return $installer->plugin_info();
766
  }
767
 
classes/controllers/FrmAppController.php CHANGED
@@ -3,14 +3,14 @@
3
  class FrmAppController {
4
 
5
  public static function menu() {
6
- FrmAppHelper::maybe_add_permissions();
7
- if ( ! current_user_can( 'frm_view_forms' ) ) {
8
- return;
9
- }
10
 
11
  $menu_name = FrmAppHelper::get_menu_name();
12
  add_menu_page( 'Formidable', $menu_name, 'frm_view_forms', 'formidable', 'FrmFormsController::route', self::menu_icon(), self::get_menu_position() );
13
- }
14
 
15
  private static function get_menu_position() {
16
  return apply_filters( 'frm_menu_position', '29.3' );
@@ -27,6 +27,7 @@ class FrmAppController {
27
  )
28
  );
29
  $icon = 'data:image/svg+xml;base64,' . base64_encode( $icon );
 
30
  return apply_filters( 'frm_icon', $icon );
31
  }
32
 
@@ -37,6 +38,10 @@ class FrmAppController {
37
  if ( self::is_white_page() ) {
38
  $classes .= ' frm-white-body ';
39
  }
 
 
 
 
40
  return $classes;
41
  }
42
 
@@ -44,33 +49,45 @@ class FrmAppController {
44
  * @since 3.0
45
  */
46
  private static function is_white_page() {
47
- $is_white_page = ( FrmAppHelper::is_admin_page( 'formidable' ) || FrmAppHelper::is_admin_page( 'formidable-entries' ) || FrmAppHelper::is_admin_page( 'formidable-pro-upgrade' ) || FrmAppHelper::is_admin_page( 'formidable-addons' ) || FrmAppHelper::is_admin_page( 'formidable-import' ) );
 
 
 
 
 
 
 
 
 
 
 
 
48
  if ( ! $is_white_page ) {
49
- $screen = get_current_screen();
50
- $is_white_page = ( $screen && $screen->id === 'edit-frm_display' );
51
  }
52
 
53
  return $is_white_page;
54
  }
55
 
56
- public static function load_wp_admin_style() {
57
- FrmAppHelper::load_font_style();
58
- }
59
 
60
  public static function get_form_nav( $form, $show_nav = false, $title = 'show' ) {
61
  $show_nav = FrmAppHelper::get_param( 'show_nav', $show_nav, 'get', 'absint' );
62
- if ( empty( $show_nav ) || ! $form ) {
63
- return;
64
- }
65
 
66
  FrmForm::maybe_get_form( $form );
67
  if ( ! is_object( $form ) ) {
68
  return;
69
  }
70
 
71
- $id = $form->id;
72
  $current_page = self::get_current_page();
73
- $nav_items = self::get_form_nav_items( $form );
74
 
75
  include( FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php' );
76
  }
@@ -78,8 +95,8 @@ class FrmAppController {
78
  private static function get_current_page() {
79
  global $pagenow;
80
 
81
- $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
82
- $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title', 'None' );
83
  $current_page = isset( $_GET['page'] ) ? $page : $post_type;
84
  if ( $pagenow == 'post.php' || $pagenow == 'post-new.php' ) {
85
  $current_page = 'frm_display';
@@ -93,24 +110,24 @@ class FrmAppController {
93
 
94
  $nav_items = array(
95
  array(
96
- 'link' => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . absint( $id ) ),
97
- 'label' => __( 'Build', 'formidable' ),
98
- 'current' => array( 'edit', 'new', 'duplicate' ),
99
- 'page' => 'formidable',
100
  'permission' => 'frm_edit_forms',
101
  ),
102
  array(
103
- 'link' => admin_url( 'admin.php?page=formidable&frm_action=settings&id=' . absint( $id ) ),
104
- 'label' => __( 'Settings', 'formidable' ),
105
- 'current' => array( 'settings' ),
106
- 'page' => 'formidable',
107
  'permission' => 'frm_edit_forms',
108
  ),
109
  array(
110
- 'link' => admin_url( 'admin.php?page=formidable-entries&frm_action=list&form=' . absint( $id ) ),
111
- 'label' => __( 'Entries', 'formidable' ),
112
- 'current' => array(),
113
- 'page' => 'formidable-entries',
114
  'permission' => 'frm_view_entries',
115
  ),
116
  );
@@ -141,32 +158,32 @@ class FrmAppController {
141
  'data-medium' => 'reports-nav',
142
  ),
143
  );
144
- self::include_upgrade_overlay();
145
  }
146
 
147
  $nav_args = array(
148
  'form_id' => $id,
149
  'form' => $form,
150
  );
 
151
  return apply_filters( 'frm_form_nav_list', $nav_items, $nav_args );
152
  }
153
 
154
- // Adds a settings link to the plugins page
155
- public static function settings_link( $links ) {
156
  $settings = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable' ) ) . '">' . __( 'Build a Form', 'formidable' ) . '</a>';
157
- array_unshift( $links, $settings );
158
 
159
- return $links;
160
- }
161
 
162
- public static function pro_get_started_headline() {
163
  self::maybe_show_upgrade_bar();
164
  self::review_request();
165
 
166
- // Don't display this error as we're upgrading the thing, or if the user shouldn't see the message
167
- if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) {
168
- return;
169
- }
170
 
171
  $pro_installed = is_dir( WP_PLUGIN_DIR . '/formidable-pro' );
172
  $authorized = get_site_option( 'frmpro-authorized' ) && ! is_callable( 'load_formidable_pro' );
@@ -183,31 +200,32 @@ class FrmAppController {
183
  $inst_install_url = wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin=formidable-pro/formidable-pro.php' ), 'activate-plugin_formidable-pro/formidable-pro.php' );
184
  } else {
185
  $inst_install_url = '#';
186
- $download_url = FrmAddonsController::get_pro_download_url();
187
 
188
  if ( empty( $download_url ) ) {
189
  $inst_install_url = 'https://formidableforms.com/knowledgebase/install-formidable-forms/?utm_source=WordPress&utm_medium=get-started&utm_campaign=liteplugin';
190
  }
191
  }
192
- ?>
193
- <div class="error frm_previous_install">
194
- <?php
195
- echo apply_filters( // WPCS: XSS ok.
196
- 'frm_pro_update_msg',
197
- sprintf(
198
- esc_html__( 'This site has been previously authorized to run Formidable Forms. %1$sInstall Formidable Pro%2$s or %3$sdeauthorize%4$s this site to continue running the free version and remove this message.', 'formidable' ),
199
- '<br/><a href="' . esc_url( $inst_install_url ) . '" id="frm_install_link" target="_blank" data-prourl="' . esc_url( $download_url ) . '">',
200
- '</a>',
201
- '<a href="#" class="frm_deauthorize_link">',
202
- '</a>'
203
- ),
204
- esc_url( $inst_install_url )
205
- );
206
  ?>
207
- <div id="frm_install_message" class="hidden frm_hidden"></div>
208
- </div>
209
- <?php
210
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
211
 
212
  private static function maybe_show_upgrade_bar() {
213
  if ( ! FrmAppHelper::is_formidable_admin() || FrmAppHelper::pro_is_installed() ) {
@@ -216,15 +234,17 @@ class FrmAppController {
216
 
217
  $affiliate = FrmAppHelper::get_affiliate();
218
  if ( ! empty( $affiliate ) ) {
219
- $tip = FrmTipsHelper::get_banner_tip();
220
  $link = FrmAppHelper::admin_upgrade_link( 'banner' );
221
- ?>
222
- <div class="update-nag frm-update-to-pro">
223
- <?php echo FrmAppHelper::kses( $tip['tip'] ); // WPCS: XSS ok. ?>
224
- <span><?php echo FrmAppHelper::kses( $tip['call'] ); // WPCS: XSS ok. ?></span>
225
- <a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( $link ) ); ?>" class="button">Upgrade to Pro</a>
226
- </div>
227
- <?php
 
 
228
  }
229
  }
230
 
@@ -294,6 +314,7 @@ class FrmAppController {
294
  }
295
  }
296
  }
 
297
  return $upsell;
298
  }
299
 
@@ -326,6 +347,7 @@ class FrmAppController {
326
  if ( ! $needs_upgrade ) {
327
  $needs_upgrade = apply_filters( 'frm_db_needs_upgrade', $needs_upgrade );
328
  }
 
329
  return $needs_upgrade;
330
  }
331
 
@@ -340,10 +362,10 @@ class FrmAppController {
340
  if ( strpos( $db_version, '-' ) === false ) {
341
  $needs_upgrade = true;
342
  } else {
343
- $last_upgrade = explode( '-', $db_version );
344
  $needs_db_upgrade = (int) $last_upgrade[1] < (int) $atts['new_db_version'];
345
- $new_version = version_compare( $last_upgrade[0], $atts['new_plugin_version'], '<' );
346
- $needs_upgrade = $needs_db_upgrade || $new_version;
347
  }
348
 
349
  return $needs_upgrade;
@@ -362,13 +384,13 @@ class FrmAppController {
362
  }
363
 
364
  $action = FrmAppHelper::simple_get( 'action', 'sanitize_title' );
365
- if ( ! FrmAppHelper::doing_ajax() || $action == 'frm_import_choices' ) {
366
  // don't continue during ajax calls
367
  self::admin_js();
368
  }
369
  }
370
 
371
- public static function admin_js() {
372
  $version = FrmAppHelper::plugin_version();
373
  FrmAppHelper::load_admin_wide_js( false );
374
 
@@ -389,29 +411,29 @@ class FrmAppController {
389
 
390
  wp_register_script( 'formidable_admin', FrmAppHelper::plugin_url() . '/js/formidable_admin.js', $dependecies, $version, true );
391
  wp_register_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css', array(), $version );
392
- wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' );
393
  wp_register_style( 'formidable-grids', FrmAppHelper::plugin_url() . '/css/frm_grids.css', array(), $version );
394
 
395
  // load multselect js
396
- wp_register_script( 'bootstrap-multiselect', FrmAppHelper::plugin_url() . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip' ), '0.9.8', true );
 
397
 
398
- $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
399
  $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
400
 
401
  global $pagenow;
402
  if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow == 'edit.php' && $post_type == 'frm_display' ) ) {
403
 
404
- wp_enqueue_script( 'admin-widgets' );
405
- wp_enqueue_style( 'widgets' );
406
- wp_enqueue_script( 'formidable' );
407
- wp_enqueue_script( 'formidable_admin' );
408
  FrmAppHelper::localize_script( 'admin' );
409
 
410
  wp_enqueue_style( 'formidable-admin' );
411
  if ( 'formidable-styles' !== $page ) {
412
  wp_enqueue_style( 'formidable-grids' );
413
  wp_enqueue_style( 'formidable-dropzone' );
414
- add_thickbox();
415
  } else {
416
  $settings = FrmAppHelper::get_settings();
417
  if ( empty( $settings->old_css ) ) {
@@ -419,36 +441,36 @@ class FrmAppController {
419
  }
420
  }
421
 
422
- wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' );
423
-
424
  do_action( 'frm_enqueue_builder_scripts' );
425
- } else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) {
426
- if ( isset( $_REQUEST['post_type'] ) ) {
427
- $post_type = sanitize_title( $_REQUEST['post_type'] );
428
- } else if ( isset( $_REQUEST['post'] ) && absint( $_REQUEST['post'] ) ) {
429
- $post = get_post( absint( $_REQUEST['post'] ) );
430
- if ( ! $post ) {
431
- return;
432
- }
433
- $post_type = $post->post_type;
434
- } else {
435
- return;
436
- }
437
-
438
- if ( $post_type == 'frm_display' ) {
439
- wp_enqueue_script( 'jquery-ui-draggable' );
440
- wp_enqueue_script( 'formidable_admin' );
441
- wp_enqueue_style( 'formidable-admin' );
 
 
442
  FrmAppHelper::localize_script( 'admin' );
443
- }
444
- } else if ( $pagenow == 'widgets.php' ) {
445
- FrmAppHelper::load_admin_wide_js();
446
- }
447
- }
448
 
449
- public static function load_lang() {
450
- load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' );
451
- }
452
 
453
  /**
454
  * Check if the styles are updated when a form is loaded on the front-end
@@ -510,6 +532,7 @@ class FrmAppController {
510
  delete_option( 'frm_install_running' );
511
  }
512
  }
 
513
  return true;
514
  }
515
 
@@ -524,14 +547,14 @@ class FrmAppController {
524
  wp_die();
525
  }
526
 
527
- public static function install() {
528
- $frmdb = new FrmMigrate();
529
- $frmdb->upgrade();
530
- }
531
 
532
- public static function uninstall() {
533
  FrmAppHelper::permission_check( 'administrator' );
534
- check_ajax_referer( 'frm_ajax', 'nonce' );
535
 
536
  $frmdb = new FrmMigrate();
537
  $frmdb->uninstall();
@@ -540,42 +563,35 @@ class FrmAppController {
540
  deactivate_plugins( FrmAppHelper::plugin_folder() . '/formidable.php', false, false );
541
  echo esc_url_raw( admin_url( 'plugins.php?deactivate=true' ) );
542
 
543
- wp_die();
544
- }
 
 
 
 
 
 
 
545
 
546
- public static function drop_tables( $tables ) {
547
- global $wpdb;
548
- $tables[] = $wpdb->prefix . 'frm_fields';
549
- $tables[] = $wpdb->prefix . 'frm_forms';
550
- $tables[] = $wpdb->prefix . 'frm_items';
551
- $tables[] = $wpdb->prefix . 'frm_item_metas';
552
- return $tables;
553
- }
554
 
555
- public static function deauthorize() {
556
  FrmAppHelper::permission_check( 'frm_change_settings' );
557
- check_ajax_referer( 'frm_ajax', 'nonce' );
558
 
559
- delete_option( 'frmpro-credentials' );
560
- delete_option( 'frmpro-authorized' );
561
- delete_site_option( 'frmpro-credentials' );
562
- delete_site_option( 'frmpro-authorized' );
563
- wp_die();
564
- }
565
 
566
  public static function set_footer_text( $text ) {
567
  if ( FrmAppHelper::is_formidable_admin() ) {
568
- $link = FrmAppHelper::admin_upgrade_link( 'footer' );
569
- $text = sprintf(
570
- __( 'Help us spread the %1$sFormidable Forms%2$s love with %3$s %5$s on WordPress.org%4$s. Thank you heaps!', 'formidable' ),
571
- '<a href="' . esc_url( FrmAppHelper::make_affiliate_url( $link ) ) . '" target="_blank">',
572
- '</a>',
573
- '<a href="https://wordpress.org/support/plugin/formidable/reviews/?filter=5#new-post" target="_blank">',
574
- '</a>',
575
- '&#9733;&#9733;&#9733;&#9733;&#9733;'
576
- );
577
- $text = '<span id="footer-thankyou">' . $text . '</span>';
578
  }
 
579
  return $text;
580
  }
581
 
@@ -583,9 +599,9 @@ class FrmAppController {
583
  * @deprecated 1.07.05
584
  * @codeCoverageIgnore
585
  */
586
- public static function get_form_shortcode( $atts ) {
587
- return FrmDeprecated::get_form_shortcode( $atts );
588
- }
589
 
590
  /**
591
  * @deprecated 2.5.4
@@ -605,7 +621,6 @@ class FrmAppController {
605
  FrmDeprecated::front_head();
606
  }
607
 
608
-
609
  /**
610
  * @deprecated 3.0.04
611
  * @codeCoverageIgnore
3
  class FrmAppController {
4
 
5
  public static function menu() {
6
+ FrmAppHelper::maybe_add_permissions();
7
+ if ( ! current_user_can( 'frm_view_forms' ) ) {
8
+ return;
9
+ }
10
 
11
  $menu_name = FrmAppHelper::get_menu_name();
12
  add_menu_page( 'Formidable', $menu_name, 'frm_view_forms', 'formidable', 'FrmFormsController::route', self::menu_icon(), self::get_menu_position() );
13
+ }
14
 
15
  private static function get_menu_position() {
16
  return apply_filters( 'frm_menu_position', '29.3' );
27
  )
28
  );
29
  $icon = 'data:image/svg+xml;base64,' . base64_encode( $icon );
30
+
31
  return apply_filters( 'frm_icon', $icon );
32
  }
33
 
38
  if ( self::is_white_page() ) {
39
  $classes .= ' frm-white-body ';
40
  }
41
+ if ( FrmAppHelper::is_full_screen() ) {
42
+ $classes .= ' frm-full-screen';
43
+ }
44
+
45
  return $classes;
46
  }
47
 
49
  * @since 3.0
50
  */
51
  private static function is_white_page() {
52
+ $white_pages = array(
53
+ 'formidable',
54
+ 'formidable-entries',
55
+ 'formidable-pro-upgrade',
56
+ 'formidable-addons',
57
+ 'formidable-import',
58
+ 'formidable-settings',
59
+ 'formidable-styles',
60
+ );
61
+
62
+ $get_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
63
+ $is_white_page = in_array( $get_page, $white_pages );
64
+
65
  if ( ! $is_white_page ) {
66
+ $screen = get_current_screen();
67
+ $is_white_page = ( $screen && strpos( $screen->id, 'frm_display' ) !== false );
68
  }
69
 
70
  return $is_white_page;
71
  }
72
 
73
+ public static function load_wp_admin_style() {
74
+ FrmAppHelper::load_font_style();
75
+ }
76
 
77
  public static function get_form_nav( $form, $show_nav = false, $title = 'show' ) {
78
  $show_nav = FrmAppHelper::get_param( 'show_nav', $show_nav, 'get', 'absint' );
79
+ if ( empty( $show_nav ) || ! $form ) {
80
+ return;
81
+ }
82
 
83
  FrmForm::maybe_get_form( $form );
84
  if ( ! is_object( $form ) ) {
85
  return;
86
  }
87
 
88
+ $id = $form->id;
89
  $current_page = self::get_current_page();
90
+ $nav_items = self::get_form_nav_items( $form );
91
 
92
  include( FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php' );
93
  }
95
  private static function get_current_page() {
96
  global $pagenow;
97
 
98
+ $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
99
+ $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title', 'None' );
100
  $current_page = isset( $_GET['page'] ) ? $page : $post_type;
101
  if ( $pagenow == 'post.php' || $pagenow == 'post-new.php' ) {
102
  $current_page = 'frm_display';
110
 
111
  $nav_items = array(
112
  array(
113
+ 'link' => FrmForm::get_edit_link( $id ),
114
+ 'label' => __( 'Build', 'formidable' ),
115
+ 'current' => array( 'edit', 'new', 'duplicate' ),
116
+ 'page' => 'formidable',
117
  'permission' => 'frm_edit_forms',
118
  ),
119
  array(
120
+ 'link' => admin_url( 'admin.php?page=formidable&frm_action=settings&id=' . absint( $id ) ),
121
+ 'label' => __( 'Settings', 'formidable' ),
122
+ 'current' => array( 'settings' ),
123
+ 'page' => 'formidable',
124
  'permission' => 'frm_edit_forms',
125
  ),
126
  array(
127
+ 'link' => admin_url( 'admin.php?page=formidable-entries&frm-full=1&frm_action=list&form=' . absint( $id ) ),
128
+ 'label' => __( 'Entries', 'formidable' ),
129
+ 'current' => array(),
130
+ 'page' => 'formidable-entries',
131
  'permission' => 'frm_view_entries',
132
  ),
133
  );
158
  'data-medium' => 'reports-nav',
159
  ),
160
  );
 
161
  }
162
 
163
  $nav_args = array(
164
  'form_id' => $id,
165
  'form' => $form,
166
  );
167
+
168
  return apply_filters( 'frm_form_nav_list', $nav_items, $nav_args );
169
  }
170
 
171
+ // Adds a settings link to the plugins page
172
+ public static function settings_link( $links ) {
173
  $settings = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable' ) ) . '">' . __( 'Build a Form', 'formidable' ) . '</a>';
174
+ array_unshift( $links, $settings );
175
 
176
+ return $links;
177
+ }
178
 
179
+ public static function pro_get_started_headline() {
180
  self::maybe_show_upgrade_bar();
181
  self::review_request();
182
 
183
+ // Don't display this error as we're upgrading the thing, or if the user shouldn't see the message
184
+ if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) {
185
+ return;
186
+ }
187
 
188
  $pro_installed = is_dir( WP_PLUGIN_DIR . '/formidable-pro' );
189
  $authorized = get_site_option( 'frmpro-authorized' ) && ! is_callable( 'load_formidable_pro' );
200
  $inst_install_url = wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin=formidable-pro/formidable-pro.php' ), 'activate-plugin_formidable-pro/formidable-pro.php' );
201
  } else {
202
  $inst_install_url = '#';
203
+ $download_url = FrmAddonsController::get_pro_download_url();
204
 
205
  if ( empty( $download_url ) ) {
206
  $inst_install_url = 'https://formidableforms.com/knowledgebase/install-formidable-forms/?utm_source=WordPress&utm_medium=get-started&utm_campaign=liteplugin';
207
  }
208
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209
  ?>
210
+ <div class="error frm_previous_install">
211
+ <?php
212
+ echo apply_filters( // WPCS: XSS ok.
213
+ 'frm_pro_update_msg',
214
+ sprintf(
215
+ /* translators: %1$s: Start link HTML, %2$s: End link HTML, %3$s: Start link HTML, %4$s: End link HTML */
216
+ esc_html__( 'This site has been previously authorized to run Formidable Forms. %1$sInstall Formidable Pro%2$s or %3$sdeauthorize%4$s this site to continue running the free version and remove this message.', 'formidable' ),
217
+ '<br/><a href="' . esc_url( $inst_install_url ) . '" id="frm_install_link" target="_blank" data-prourl="' . esc_url( $download_url ) . '">',
218
+ '</a>',
219
+ '<a href="#" class="frm_deauthorize_link">',
220
+ '</a>'
221
+ ),
222
+ esc_url( $inst_install_url )
223
+ );
224
+ ?>
225
+ <div id="frm_install_message" class="hidden frm_hidden"></div>
226
+ </div>
227
+ <?php
228
+ }
229
 
230
  private static function maybe_show_upgrade_bar() {
231
  if ( ! FrmAppHelper::is_formidable_admin() || FrmAppHelper::pro_is_installed() ) {
234
 
235
  $affiliate = FrmAppHelper::get_affiliate();
236
  if ( ! empty( $affiliate ) ) {
237
+ $tip = FrmTipsHelper::get_banner_tip();
238
  $link = FrmAppHelper::admin_upgrade_link( 'banner' );
239
+ ?>
240
+ <div class="update-nag frm-update-to-pro">
241
+ <?php echo FrmAppHelper::kses( $tip['tip'] ); // WPCS: XSS ok. ?>
242
+ <span><?php echo FrmAppHelper::kses( $tip['call'] ); // WPCS: XSS ok. ?></span>
243
+ <a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( $link ) ); ?>" class="button">
244
+ Upgrade to Pro
245
+ </a>
246
+ </div>
247
+ <?php
248
  }
249
  }
250
 
314
  }
315
  }
316
  }
317
+
318
  return $upsell;
319
  }
320
 
347
  if ( ! $needs_upgrade ) {
348
  $needs_upgrade = apply_filters( 'frm_db_needs_upgrade', $needs_upgrade );
349
  }
350
+
351
  return $needs_upgrade;
352
  }
353
 
362
  if ( strpos( $db_version, '-' ) === false ) {
363
  $needs_upgrade = true;
364
  } else {
365
+ $last_upgrade = explode( '-', $db_version );
366
  $needs_db_upgrade = (int) $last_upgrade[1] < (int) $atts['new_db_version'];
367
+ $new_version = version_compare( $last_upgrade[0], $atts['new_plugin_version'], '<' );
368
+ $needs_upgrade = $needs_db_upgrade || $new_version;
369
  }
370
 
371
  return $needs_upgrade;
384
  }
385
 
386
  $action = FrmAppHelper::simple_get( 'action', 'sanitize_title' );
387
+ if ( ! FrmAppHelper::doing_ajax() ) {
388
  // don't continue during ajax calls
389
  self::admin_js();
390
  }
391
  }
392
 
393
+ public static function admin_js() {
394
  $version = FrmAppHelper::plugin_version();
395
  FrmAppHelper::load_admin_wide_js( false );
396
 
411
 
412
  wp_register_script( 'formidable_admin', FrmAppHelper::plugin_url() . '/js/formidable_admin.js', $dependecies, $version, true );
413
  wp_register_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css', array(), $version );
414
+ wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' );
415
  wp_register_style( 'formidable-grids', FrmAppHelper::plugin_url() . '/css/frm_grids.css', array(), $version );
416
 
417
  // load multselect js
418
+ $depends_on = array( 'jquery', 'bootstrap_tooltip' );
419
+ wp_register_script( 'bootstrap-multiselect', FrmAppHelper::plugin_url() . '/js/bootstrap-multiselect.js', $depends_on, '0.9.8', true );
420
 
421
+ $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
422
  $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
423
 
424
  global $pagenow;
425
  if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow == 'edit.php' && $post_type == 'frm_display' ) ) {
426
 
427
+ wp_enqueue_script( 'admin-widgets' );
428
+ wp_enqueue_style( 'widgets' );
429
+ wp_enqueue_script( 'formidable' );
430
+ wp_enqueue_script( 'formidable_admin' );
431
  FrmAppHelper::localize_script( 'admin' );
432
 
433
  wp_enqueue_style( 'formidable-admin' );
434
  if ( 'formidable-styles' !== $page ) {
435
  wp_enqueue_style( 'formidable-grids' );
436
  wp_enqueue_style( 'formidable-dropzone' );
 
437
  } else {
438
  $settings = FrmAppHelper::get_settings();
439
  if ( empty( $settings->old_css ) ) {
441
  }
442
  }
443
 
 
 
444
  do_action( 'frm_enqueue_builder_scripts' );
445
+ self::include_upgrade_overlay();
446
+ } elseif ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) {
447
+ if ( isset( $_REQUEST['post_type'] ) ) {
448
+ $post_type = sanitize_title( wp_unslash( $_REQUEST['post_type'] ) );
449
+ } elseif ( isset( $_REQUEST['post'] ) && absint( $_REQUEST['post'] ) ) {
450
+ $post = get_post( absint( wp_unslash( $_REQUEST['post'] ) ) );
451
+ if ( ! $post ) {
452
+ return;
453
+ }
454
+ $post_type = $post->post_type;
455
+ } else {
456
+ return;
457
+ }
458
+
459
+ if ( $post_type == 'frm_display' ) {
460
+ wp_enqueue_style( 'formidable-grids' );
461
+ wp_enqueue_script( 'jquery-ui-draggable' );
462
+ wp_enqueue_script( 'formidable_admin' );
463
+ wp_enqueue_style( 'formidable-admin' );
464
  FrmAppHelper::localize_script( 'admin' );
465
+ }
466
+ } elseif ( $pagenow == 'widgets.php' ) {
467
+ FrmAppHelper::load_admin_wide_js();
468
+ }
469
+ }
470
 
471
+ public static function load_lang() {
472
+ load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' );
473
+ }
474
 
475
  /**
476
  * Check if the styles are updated when a form is loaded on the front-end
532
  delete_option( 'frm_install_running' );
533
  }
534
  }
535
+
536
  return true;
537
  }
538
 
547
  wp_die();
548
  }
549
 
550
+ public static function install() {
551
+ $frmdb = new FrmMigrate();
552
+ $frmdb->upgrade();
553
+ }
554
 
555
+ public static function uninstall() {
556
  FrmAppHelper::permission_check( 'administrator' );
557
+ check_ajax_referer( 'frm_ajax', 'nonce' );
558
 
559
  $frmdb = new FrmMigrate();
560
  $frmdb->uninstall();
563
  deactivate_plugins( FrmAppHelper::plugin_folder() . '/formidable.php', false, false );
564
  echo esc_url_raw( admin_url( 'plugins.php?deactivate=true' ) );
565
 
566
+ wp_die();
567
+ }
568
+
569
+ public static function drop_tables( $tables ) {
570
+ global $wpdb;
571
+ $tables[] = $wpdb->prefix . 'frm_fields';
572
+ $tables[] = $wpdb->prefix . 'frm_forms';
573
+ $tables[] = $wpdb->prefix . 'frm_items';
574
+ $tables[] = $wpdb->prefix . 'frm_item_metas';
575
 
576
+ return $tables;
577
+ }
 
 
 
 
 
 
578
 
579
+ public static function deauthorize() {
580
  FrmAppHelper::permission_check( 'frm_change_settings' );
581
+ check_ajax_referer( 'frm_ajax', 'nonce' );
582
 
583
+ delete_option( 'frmpro-credentials' );
584
+ delete_option( 'frmpro-authorized' );
585
+ delete_site_option( 'frmpro-credentials' );
586
+ delete_site_option( 'frmpro-authorized' );
587
+ wp_die();
588
+ }
589
 
590
  public static function set_footer_text( $text ) {
591
  if ( FrmAppHelper::is_formidable_admin() ) {
592
+ $text = '';
 
 
 
 
 
 
 
 
 
593
  }
594
+
595
  return $text;
596
  }
597
 
599
  * @deprecated 1.07.05
600
  * @codeCoverageIgnore
601
  */
602
+ public static function get_form_shortcode( $atts ) {
603
+ return FrmDeprecated::get_form_shortcode( $atts );
604
+ }
605
 
606
  /**
607
  * @deprecated 2.5.4
621
  FrmDeprecated::front_head();
622
  }
623
 
 
624
  /**
625
  * @deprecated 3.0.04
626
  * @codeCoverageIgnore
classes/controllers/FrmEntriesController.php CHANGED
@@ -16,7 +16,7 @@ class FrmEntriesController {
16
  private static function load_manage_entries_hooks() {
17
  if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show', 'new' ) ) ) {
18
  $menu_name = FrmAppHelper::get_menu_name();
19
- $base = self::base_column_key( $menu_name );
20
 
21
  add_filter( 'manage_' . $base . '_columns', 'FrmEntriesController::manage_columns' );
22
  add_filter( 'get_user_option_' . self::hidden_column_key( $menu_name ), 'FrmEntriesController::hidden_columns' );
@@ -26,61 +26,25 @@ class FrmEntriesController {
26
  }
27
  }
28
 
29
- /* Display in Back End */
30
- public static function route() {
31
  $action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' );
32
 
33
- switch ( $action ) {
34
- case 'show':
35
- case 'destroy':
36
- case 'destroy_all':
37
- return self::$action();
38
 
39
- default:
40
- do_action( 'frm_entry_action_route', $action );
41
- if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) {
42
- return;
43
- }
44
-
45
- return self::display_list();
46
- }
47
- }
48
-
49
- public static function contextual_help( $help, $screen_id, $screen ) {
50
- // Only add to certain screens. add_help_tab was introduced in WordPress 3.3
51
- if ( ! method_exists( $screen, 'add_help_tab' ) ) {
52
- return $help;
53
- }
54
-
55
- $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
56
- $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
57
- $show_help = ( $page == 'formidable-entries' && ( empty( $action ) || $action == 'list' ) );
58
- if ( ! $show_help ) {
59
- return $help;
60
- }
61
-
62
- unset( $action, $page );
63
-
64
- $screen->add_help_tab(
65
- array(
66
- 'id' => 'formidable-entries-tab',
67
- 'title' => __( 'Overview', 'formidable' ),
68
- 'content' => '<p>' .
69
- esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) .
70
- '</p> <p>' .
71
- esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) .
72
- '</p>',
73
- )
74
- );
75
-
76
- $screen->set_help_sidebar(
77
- '<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' .
78
- '<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/knowledgebase/manage-entries-from-the-back-end/?utm_source=WordPress&utm_medium=entries&utm_campaign=liteplugin' ) ) . '" target="_blank">' . esc_html__( 'Documentation on Entries', 'formidable' ) . '</a></p>' .
79
- '<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/support/?utm_source=WordPress&utm_medium=entries&utm_campaign=liteplugin' ) ) . '" target="_blank">' . esc_html__( 'Support', 'formidable' ) . '</a></p>'
80
- );
81
 
82
- return $help;
83
- }
 
84
 
85
  /**
86
  * Prevent the "screen options" tab from showing when
@@ -98,17 +62,17 @@ class FrmEntriesController {
98
  }
99
 
100
  public static function manage_columns( $columns ) {
101
- global $frm_vars;
102
  $form_id = FrmForm::get_current_form_id();
103
 
104
- $columns[ $form_id . '_id' ] = 'ID';
105
  $columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' );
106
 
107
  if ( $form_id ) {
108
  self::get_columns_for_form( $form_id, $columns );
109
  } else {
110
  $columns[ $form_id . '_form_id' ] = __( 'Form', 'formidable' );
111
- $columns[ $form_id . '_name' ] = __( 'Entry Name', 'formidable' );
112
  $columns[ $form_id . '_user_id' ] = __( 'Created By', 'formidable' );
113
  }
114
 
@@ -116,7 +80,7 @@ class FrmEntriesController {
116
  $columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' );
117
  self::maybe_add_ip_col( $form_id, $columns );
118
 
119
- $frm_vars['cols'] = $columns;
120
 
121
  $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
122
  if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $action, array( '', 'list', 'destroy' ) ) ) {
@@ -128,10 +92,10 @@ class FrmEntriesController {
128
  'option' => 'formidable_page_formidable_entries_per_page',
129
  )
130
  );
131
- }
132
 
133
- return $columns;
134
- }
135
 
136
  private static function get_columns_for_form( $form_id, &$columns ) {
137
  $form_cols = FrmField::get_all_for_form( $form_id, '', 'include' );
@@ -196,73 +160,76 @@ class FrmEntriesController {
196
  public static function check_hidden_cols( $check, $object_id, $meta_key, $meta_value, $prev_value ) {
197
  $this_page_name = self::hidden_column_key();
198
  if ( $meta_key != $this_page_name || $meta_value == $prev_value ) {
199
- return $check;
200
- }
201
 
202
  if ( empty( $prev_value ) ) {
203
  $prev_value = get_metadata( 'user', $object_id, $meta_key, true );
204
  }
205
 
206
- global $frm_vars;
207
  //add a check so we don't create a loop
208
  $frm_vars['prev_hidden_cols'] = ( isset( $frm_vars['prev_hidden_cols'] ) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
209
 
210
- return $check;
211
- }
212
 
213
- //add hidden columns back from other forms
 
 
214
  public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) {
215
  $this_page_name = self::hidden_column_key();
216
  if ( $meta_key != $this_page_name ) {
217
- return;
218
- }
219
 
220
  global $frm_vars;
221
  if ( ! isset( $frm_vars['prev_hidden_cols'] ) || ! $frm_vars['prev_hidden_cols'] ) {
222
- return; //don't continue if there's no previous value
223
  }
224
 
225
- foreach ( $meta_value as $mk => $mv ) {
226
- //remove blank values
227
- if ( empty( $mv ) ) {
228
- unset( $meta_value[ $mk ] );
229
- }
230
- }
231
 
232
  $cur_form_prefix = reset( $meta_value );
233
  $cur_form_prefix = explode( '_', $cur_form_prefix );
234
- $cur_form_prefix = $cur_form_prefix[0];
235
- $save = false;
236
 
237
- foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) {
238
  if ( empty( $prev_hidden ) || in_array( $prev_hidden, $meta_value ) ) {
239
- //don't add blank cols or process included cols
240
- continue;
241
- }
242
 
243
  $form_prefix = explode( '_', $prev_hidden );
244
- $form_prefix = $form_prefix[0];
245
- if ( $form_prefix == $cur_form_prefix ) {
246
- //don't add back columns that are meant to be hidden
247
- continue;
248
- }
249
-
250
- $meta_value[] = $prev_hidden;
251
- $save = true;
252
  unset( $form_prefix );
253
- }
254
 
255
  if ( $save ) {
256
  $user_id = get_current_user_id();
257
  update_user_option( $user_id, $this_page_name, $meta_value, true );
258
- }
259
- }
260
 
261
  /**
262
  * @since 2.05.07
263
  */
264
  private static function hidden_column_key( $menu_name = '' ) {
265
  $base = self::base_column_key( $menu_name );
 
266
  return 'manage' . $base . 'columnshidden';
267
  }
268
 
@@ -273,19 +240,21 @@ class FrmEntriesController {
273
  if ( empty( $menu_name ) ) {
274
  $menu_name = FrmAppHelper::get_menu_name();
275
  }
 
276
  return sanitize_title( $menu_name ) . '_page_formidable-entries';
277
  }
278
 
279
  public static function save_per_page( $save, $option, $value ) {
280
- if ( $option == 'formidable_page_formidable_entries_per_page' ) {
281
- $save = (int) $value;
282
- }
283
- return $save;
284
- }
 
285
 
286
  public static function sortable_columns() {
287
  $form_id = FrmForm::get_current_form_id();
288
- $fields = FrmField::get_all_for_form( $form_id );
289
 
290
  $columns = array(
291
  $form_id . '_id' => 'id',
@@ -315,8 +284,8 @@ class FrmEntriesController {
315
  $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0;
316
 
317
  if ( ! empty( $hidden ) ) {
318
- $result = $hidden;
319
- $i = $i - count( $result );
320
  $max_columns = 11;
321
  } else {
322
  $max_columns = 8;
@@ -347,6 +316,7 @@ class FrmEntriesController {
347
  unset( $form_prefix );
348
  }
349
  }
 
350
  return $hidden;
351
  }
352
 
@@ -362,7 +332,7 @@ class FrmEntriesController {
362
  $atts['form_id'] . '_item_key' => '',
363
  $atts['form_id'] . '_id' => '',
364
  );
365
- $cols = $remove_first + array_reverse( $frm_vars['cols'], true );
366
 
367
  $i = $atts['i'];
368
 
@@ -381,69 +351,72 @@ class FrmEntriesController {
381
  }
382
 
383
  public static function display_list( $message = '', $errors = array() ) {
384
- global $wpdb, $frm_vars;
385
 
386
- $form = FrmForm::maybe_get_current_form();
387
  $params = FrmForm::get_admin_params( $form );
388
 
389
- if ( $form ) {
390
- $params['form'] = $form->id;
391
- $frm_vars['current_form'] = $form;
392
 
393
  self::get_delete_form_time( $form, $errors );
394
  }
395
 
396
- $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' );
397
 
398
- $wp_list_table = new $table_class( array( 'params' => $params ) );
399
 
400
- $pagenum = $wp_list_table->get_pagenum();
401
 
402
- $wp_list_table->prepare_items();
403
 
404
- $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
405
- if ( $pagenum > $total_pages && $total_pages > 0 ) {
406
  $url = add_query_arg( 'paged', $total_pages );
407
- if ( headers_sent() ) {
408
  echo FrmAppHelper::js_redirect( $url ); // WPCS: XSS ok.
409
- } else {
410
- wp_redirect( esc_url_raw( $url ) );
411
- }
412
- die();
413
- }
414
 
415
  if ( empty( $message ) && isset( $_GET['import-message'] ) ) {
416
- $message = __( 'Your import is complete', 'formidable' );
417
- }
418
 
419
  require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php' );
420
- }
421
 
422
  private static function get_delete_form_time( $form, &$errors ) {
423
  if ( 'trash' == $form->status ) {
424
  $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
425
- $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? ( $form->options['trash_time'] ) : time() ) );
426
- $errors['trash'] = sprintf( __( 'This form is in the trash and is scheduled to be deleted permanently in %s along with any entries.', 'formidable' ), $time_to_delete );
 
 
427
  }
428
  }
429
 
430
- /* Back End CRUD */
431
  public static function show( $id = 0 ) {
432
  FrmAppHelper::permission_check( 'frm_view_entries' );
433
 
434
- if ( ! $id ) {
435
  $id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
436
 
437
- if ( ! $id ) {
438
  $id = FrmAppHelper::get_param( 'item_id', 0, 'get', 'absint' );
439
- }
440
- }
441
 
442
  $entry = FrmEntry::getOne( $id, true );
443
  if ( ! $entry ) {
444
  echo '<div id="form_show_entry_page" class="wrap">' .
445
  esc_html__( 'You are trying to view an entry that does not exist.', 'formidable' ) .
446
  '</div>';
 
447
  return;
448
  }
449
 
@@ -452,67 +425,67 @@ class FrmEntriesController {
452
  $data = array( 'referrer' => $data );
453
  }
454
 
455
- $fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' );
456
- $to_emails = array();
457
- $form = FrmForm::getOne( $entry->form_id );
458
 
459
  include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' );
460
- }
461
 
462
- public static function destroy() {
463
  FrmAppHelper::permission_check( 'frm_delete_entries' );
464
 
465
  $params = FrmForm::get_admin_params();
466
 
467
  if ( isset( $params['keep_post'] ) && $params['keep_post'] ) {
468
  self::unlink_post( $params['id'] );
469
- }
 
 
 
 
 
470
 
471
- $message = '';
472
- if ( FrmEntry::destroy( $params['id'] ) ) {
473
- $message = __( 'Entry was Successfully Destroyed', 'formidable' );
474
- }
475
 
476
- self::display_list( $message );
477
- }
 
 
 
478
 
479
- public static function destroy_all() {
480
- if ( ! current_user_can( 'frm_delete_entries' ) ) {
481
- $frm_settings = FrmAppHelper::get_settings();
482
- wp_die( esc_html( $frm_settings->admin_permission ) );
483
- }
484
 
485
- $params = FrmForm::get_admin_params();
486
- $message = '';
487
- $errors = array();
488
- $form_id = (int) $params['form'];
489
-
490
- if ( $form_id ) {
491
- $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) );
492
- $action = FrmFormAction::get_action_for_form( $form_id, 'wppost', 1 );
493
-
494
- if ( $action ) {
495
- // this action takes a while, so only trigger it if there are posts to delete
496
- foreach ( $entry_ids as $entry_id ) {
497
- do_action( 'frm_before_destroy_entry', $entry_id );
498
- unset( $entry_id );
499
- }
500
- }
501
-
502
- $results = self::delete_form_entries( $form_id );
503
- if ( $results ) {
504
  FrmEntry::clear_cache();
505
- $message = __( 'Entries were Successfully Destroyed', 'formidable' );
506
- }
507
- } else {
508
- $errors = __( 'No entries were specified', 'formidable' );
509
- }
510
 
511
- self::display_list( $message, $errors );
512
- }
513
 
514
  /**
515
  * @since 3.01
 
516
  * @param int $form_id
517
  */
518
  private static function delete_form_entries( $form_id ) {
@@ -520,26 +493,28 @@ class FrmEntriesController {
520
 
521
  $form_ids = self::get_child_form_ids( $form_id );
522
 
523
- $meta_query = $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) WHERE form_id=%d", $form_id );
524
  $entry_query = $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id );
525
 
526
  if ( ! empty( $form_ids ) ) {
527
- $form_query = ' OR form_id in (' . $form_ids . ')';
528
- $meta_query .= $form_query;
529
  $entry_query .= $form_query;
530
  }
531
 
532
  $wpdb->query( $meta_query ); // WPCS: unprepared SQL ok.
 
533
  return $wpdb->query( $entry_query ); // WPCS: unprepared SQL ok.
534
  }
535
 
536
  /**
537
  * @since 3.01
 
538
  * @param int $form_id
539
  * @param bool|string $implode
540
  */
541
  private static function get_child_form_ids( $form_id, $implode = ',' ) {
542
- $form_ids = array();
543
  $child_form_ids = FrmDb::get_col( 'frm_forms', array( 'parent_form_id' => $form_id ) );
544
  if ( $child_form_ids ) {
545
  $form_ids = $child_form_ids;
@@ -548,36 +523,37 @@ class FrmEntriesController {
548
  if ( $implode ) {
549
  $form_ids = implode( $implode, $form_ids );
550
  }
 
551
  return $form_ids;
552
  }
553
 
554
- public static function process_entry( $errors = '', $ajax = false ) {
555
  $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
556
  if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) {
557
- return;
558
- }
559
 
560
- global $frm_vars;
561
 
562
  $form = FrmForm::getOne( $form_id );
563
- if ( ! $form ) {
564
- return;
565
- }
566
 
567
  $params = FrmForm::get_params( $form );
568
 
569
- if ( ! isset( $frm_vars['form_params'] ) ) {
570
- $frm_vars['form_params'] = array();
571
- }
572
  $frm_vars['form_params'][ $form->id ] = $params;
573
 
574
  if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) {
575
- return;
576
- }
577
 
578
- if ( $errors == '' && ! $ajax ) {
579
  $errors = FrmEntryValidate::validate( $_POST );
580
- }
581
 
582
  /**
583
  * Use this filter to add trigger actions and add errors after
@@ -589,24 +565,25 @@ class FrmEntriesController {
589
 
590
  $frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors );
591
 
592
- if ( empty( $errors ) ) {
593
  $_POST['frm_skip_cookie'] = 1;
594
- $do_success = false;
595
- if ( $params['action'] == 'create' ) {
596
  if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
597
  $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST );
 
598
  $params['id'] = $frm_vars['created_entries'][ $form_id ]['entry_id'];
599
- $do_success = true;
600
- }
601
- }
602
 
603
- do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
604
  if ( $do_success ) {
605
  FrmFormsController::maybe_trigger_redirect( $form, $params, array( 'ajax' => $ajax ) );
606
  }
607
  unset( $_POST['frm_skip_cookie'] );
608
- }
609
- }
610
 
611
  /**
612
  * Escape url entities before redirect
@@ -614,33 +591,39 @@ class FrmEntriesController {
614
  * @since 3.0
615
  *
616
  * @param string $url
 
617
  * @return string
618
  */
619
  public static function prepare_redirect_url( $url ) {
620
  return str_replace( array( ' ', '[', ']', '|', '@' ), array( '%20', '%5B', '%5D', '%7C', '%40' ), $url );
621
  }
622
 
623
- public static function delete_entry_before_redirect( $url, $form, $atts ) {
624
- self::_delete_entry( $atts['id'], $form );
625
- return $url;
626
- }
627
 
628
- //Delete entry if not redirected
629
- public static function delete_entry_after_save( $atts ) {
630
- self::_delete_entry( $atts['entry_id'], $atts['form'] );
631
- }
 
 
 
 
 
 
 
632
 
633
- private static function _delete_entry( $entry_id, $form ) {
634
- if ( ! $form ) {
635
- return;
636
- }
637
 
638
- $form->options = maybe_unserialize( $form->options );
639
- if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
640
  self::unlink_post( $entry_id );
641
- FrmEntry::destroy( $entry_id );
642
- }
643
- }
644
 
645
  /**
646
  * Unlink entry from post
@@ -675,6 +658,7 @@ class FrmEntriesController {
675
  'border_color' => '',
676
  'bg_color' => '',
677
  'alt_bg_color' => '',
 
678
  'clickable' => false,
679
  'exclude_fields' => '',
680
  'include_fields' => '',
@@ -691,8 +675,9 @@ class FrmEntriesController {
691
  'format' => $atts['format'],
692
  'plain_text' => $atts['plain_text'],
693
  );
694
- $entry_shortcode_formatter = FrmEntryFactory::entry_shortcode_formatter_instance( $atts['form_id'], $shortcode_atts );
695
- $formatted_entry = $entry_shortcode_formatter->content();
 
696
 
697
  } else {
698
 
@@ -704,8 +689,8 @@ class FrmEntriesController {
704
  return $formatted_entry;
705
  }
706
 
707
- public static function entry_sidebar( $entry ) {
708
- $data = maybe_unserialize( $entry->description );
709
  $date_format = get_option( 'date_format' );
710
  $time_format = get_option( 'time_format' );
711
  if ( isset( $data['browser'] ) ) {
@@ -713,7 +698,15 @@ class FrmEntriesController {
713
  }
714
 
715
  include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' );
716
- }
 
 
 
 
 
 
 
 
717
 
718
  /**
719
  * @deprecated 1.07.05
16
  private static function load_manage_entries_hooks() {
17
  if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show', 'new' ) ) ) {
18
  $menu_name = FrmAppHelper::get_menu_name();
19
+ $base = self::base_column_key( $menu_name );
20
 
21
  add_filter( 'manage_' . $base . '_columns', 'FrmEntriesController::manage_columns' );
22
  add_filter( 'get_user_option_' . self::hidden_column_key( $menu_name ), 'FrmEntriesController::hidden_columns' );
26
  }
27
  }
28
 
29
+ /* Display in Back End */
30
+ public static function route() {
31
  $action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' );
32
 
33
+ switch ( $action ) {
34
+ case 'show':
35
+ case 'destroy':
36
+ case 'destroy_all':
37
+ return self::$action();
38
 
39
+ default:
40
+ do_action( 'frm_entry_action_route', $action );
41
+ if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) {
42
+ return;
43
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
+ return self::display_list();
46
+ }
47
+ }
48
 
49
  /**
50
  * Prevent the "screen options" tab from showing when
62
  }
63
 
64
  public static function manage_columns( $columns ) {
65
+ global $frm_vars;
66
  $form_id = FrmForm::get_current_form_id();
67
 
68
+ $columns[ $form_id . '_id' ] = 'ID';
69
  $columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' );
70
 
71
  if ( $form_id ) {
72
  self::get_columns_for_form( $form_id, $columns );
73
  } else {
74
  $columns[ $form_id . '_form_id' ] = __( 'Form', 'formidable' );
75
+ $columns[ $form_id . '_name' ] = __( 'Entry Name', 'formidable' );
76
  $columns[ $form_id . '_user_id' ] = __( 'Created By', 'formidable' );
77
  }
78
 
80
  $columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' );
81
  self::maybe_add_ip_col( $form_id, $columns );
82
 
83
+ $frm_vars['cols'] = $columns;
84
 
85
  $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
86
  if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $action, array( '', 'list', 'destroy' ) ) ) {
92
  'option' => 'formidable_page_formidable_entries_per_page',
93
  )
94
  );
95
+ }
96
 
97
+ return $columns;
98
+ }
99
 
100
  private static function get_columns_for_form( $form_id, &$columns ) {
101
  $form_cols = FrmField::get_all_for_form( $form_id, '', 'include' );
160
  public static function check_hidden_cols( $check, $object_id, $meta_key, $meta_value, $prev_value ) {
161
  $this_page_name = self::hidden_column_key();
162
  if ( $meta_key != $this_page_name || $meta_value == $prev_value ) {
163
+ return $check;
164
+ }
165
 
166
  if ( empty( $prev_value ) ) {
167
  $prev_value = get_metadata( 'user', $object_id, $meta_key, true );
168
  }
169
 
170
+ global $frm_vars;
171
  //add a check so we don't create a loop
172
  $frm_vars['prev_hidden_cols'] = ( isset( $frm_vars['prev_hidden_cols'] ) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
173
 
174
+ return $check;
175
+ }
176
 
177
+ /**
178
+ * Add hidden columns back from other forms
179
+ */
180
  public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) {
181
  $this_page_name = self::hidden_column_key();
182
  if ( $meta_key != $this_page_name ) {
183
+ return;
184
+ }
185
 
186
  global $frm_vars;
187
  if ( ! isset( $frm_vars['prev_hidden_cols'] ) || ! $frm_vars['prev_hidden_cols'] ) {
188
+ return; // Don't continue if there's no previous value.
189
  }
190
 
191
+ foreach ( $meta_value as $mk => $mv ) {
192
+ // Remove blank values.
193
+ if ( empty( $mv ) ) {
194
+ unset( $meta_value[ $mk ] );
195
+ }
196
+ }
197
 
198
  $cur_form_prefix = reset( $meta_value );
199
  $cur_form_prefix = explode( '_', $cur_form_prefix );
200
+ $cur_form_prefix = $cur_form_prefix[0];
201
+ $save = false;
202
 
203
+ foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) {
204
  if ( empty( $prev_hidden ) || in_array( $prev_hidden, $meta_value ) ) {
205
+ // Don't add blank cols or process included cols.
206
+ continue;
207
+ }
208
 
209
  $form_prefix = explode( '_', $prev_hidden );
210
+ $form_prefix = $form_prefix[0];
211
+ if ( $form_prefix == $cur_form_prefix ) {
212
+ // Don't add back columns that are meant to be hidden.
213
+ continue;
214
+ }
215
+
216
+ $meta_value[] = $prev_hidden;
217
+ $save = true;
218
  unset( $form_prefix );
219
+ }
220
 
221
  if ( $save ) {
222
  $user_id = get_current_user_id();
223
  update_user_option( $user_id, $this_page_name, $meta_value, true );
224
+ }
225
+ }
226
 
227
  /**
228
  * @since 2.05.07
229
  */
230
  private static function hidden_column_key( $menu_name = '' ) {
231
  $base = self::base_column_key( $menu_name );
232
+
233
  return 'manage' . $base . 'columnshidden';
234
  }
235
 
240
  if ( empty( $menu_name ) ) {
241
  $menu_name = FrmAppHelper::get_menu_name();
242
  }
243
+
244
  return sanitize_title( $menu_name ) . '_page_formidable-entries';
245
  }
246
 
247
  public static function save_per_page( $save, $option, $value ) {
248
+ if ( $option == 'formidable_page_formidable_entries_per_page' ) {
249
+ $save = (int) $value;
250
+ }
251
+
252
+ return $save;
253
+ }
254
 
255
  public static function sortable_columns() {
256
  $form_id = FrmForm::get_current_form_id();
257
+ $fields = FrmField::get_all_for_form( $form_id );
258
 
259
  $columns = array(
260
  $form_id . '_id' => 'id',
284
  $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0;
285
 
286
  if ( ! empty( $hidden ) ) {
287
+ $result = $hidden;
288
+ $i = $i - count( $result );
289
  $max_columns = 11;
290
  } else {
291
  $max_columns = 8;
316
  unset( $form_prefix );
317
  }
318
  }
319
+
320
  return $hidden;
321
  }
322
 
332
  $atts['form_id'] . '_item_key' => '',
333
  $atts['form_id'] . '_id' => '',
334
  );
335
+ $cols = $remove_first + array_reverse( $frm_vars['cols'], true );
336
 
337
  $i = $atts['i'];
338
 
351
  }
352
 
353
  public static function display_list( $message = '', $errors = array() ) {
354
+ global $wpdb, $frm_vars;
355
 
356
+ $form = FrmForm::maybe_get_current_form();
357
  $params = FrmForm::get_admin_params( $form );
358
 
359
+ if ( $form ) {
360
+ $params['form'] = $form->id;
361
+ $frm_vars['current_form'] = $form;
362
 
363
  self::get_delete_form_time( $form, $errors );
364
  }
365
 
366
+ $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' );
367
 
368
+ $wp_list_table = new $table_class( array( 'params' => $params ) );
369
 
370
+ $pagenum = $wp_list_table->get_pagenum();
371
 
372
+ $wp_list_table->prepare_items();
373
 
374
+ $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
375
+ if ( $pagenum > $total_pages && $total_pages > 0 ) {
376
  $url = add_query_arg( 'paged', $total_pages );
377
+ if ( headers_sent() ) {
378
  echo FrmAppHelper::js_redirect( $url ); // WPCS: XSS ok.
379
+ } else {
380
+ wp_redirect( esc_url_raw( $url ) );
381
+ }
382
+ die();
383
+ }
384
 
385
  if ( empty( $message ) && isset( $_GET['import-message'] ) ) {
386
+ $message = __( 'Your import is complete', 'formidable' );
387
+ }
388
 
389
  require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php' );
390
+ }
391
 
392
  private static function get_delete_form_time( $form, &$errors ) {
393
  if ( 'trash' == $form->status ) {
394
  $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
395
+ $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? ( $form->options['trash_time'] ) : time() ) );
396
+
397
+ /* translators: %1$s: Time string */
398
+ $errors['trash'] = sprintf( __( 'This form is in the trash and is scheduled to be deleted permanently in %s along with any entries.', 'formidable' ), $time_to_delete );
399
  }
400
  }
401
 
402
+ /* Back End CRUD */
403
  public static function show( $id = 0 ) {
404
  FrmAppHelper::permission_check( 'frm_view_entries' );
405
 
406
+ if ( ! $id ) {
407
  $id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
408
 
409
+ if ( ! $id ) {
410
  $id = FrmAppHelper::get_param( 'item_id', 0, 'get', 'absint' );
411
+ }
412
+ }
413
 
414
  $entry = FrmEntry::getOne( $id, true );
415
  if ( ! $entry ) {
416
  echo '<div id="form_show_entry_page" class="wrap">' .
417
  esc_html__( 'You are trying to view an entry that does not exist.', 'formidable' ) .
418
  '</div>';
419
+
420
  return;
421
  }
422
 
425
  $data = array( 'referrer' => $data );
426
  }
427
 
428
+ $fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' );
429
+ $form = FrmForm::getOne( $entry->form_id );
 
430
 
431
  include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' );
432
+ }
433
 
434
+ public static function destroy() {
435
  FrmAppHelper::permission_check( 'frm_delete_entries' );
436
 
437
  $params = FrmForm::get_admin_params();
438
 
439
  if ( isset( $params['keep_post'] ) && $params['keep_post'] ) {
440
  self::unlink_post( $params['id'] );
441
+ }
442
+
443
+ $message = '';
444
+ if ( FrmEntry::destroy( $params['id'] ) ) {
445
+ $message = __( 'Entry was Successfully Deleted', 'formidable' );
446
+ }
447
 
448
+ self::display_list( $message );
449
+ }
 
 
450
 
451
+ public static function destroy_all() {
452
+ if ( ! current_user_can( 'frm_delete_entries' ) ) {
453
+ $frm_settings = FrmAppHelper::get_settings();
454
+ wp_die( esc_html( $frm_settings->admin_permission ) );
455
+ }
456
 
457
+ $params = FrmForm::get_admin_params();
458
+ $message = '';
459
+ $errors = array();
460
+ $form_id = (int) $params['form'];
 
461
 
462
+ if ( $form_id ) {
463
+ $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) );
464
+ $action = FrmFormAction::get_action_for_form( $form_id, 'wppost', 1 );
465
+
466
+ if ( $action ) {
467
+ // This action takes a while, so only trigger it if there are posts to delete.
468
+ foreach ( $entry_ids as $entry_id ) {
469
+ do_action( 'frm_before_destroy_entry', $entry_id );
470
+ unset( $entry_id );
471
+ }
472
+ }
473
+
474
+ $results = self::delete_form_entries( $form_id );
475
+ if ( $results ) {
 
 
 
 
 
476
  FrmEntry::clear_cache();
477
+ $message = __( 'Entries Successfully Deleted', 'formidable' );
478
+ }
479
+ } else {
480
+ $errors = __( 'No Entries Selected', 'formidable' );
481
+ }
482
 
483
+ self::display_list( $message, $errors );
484
+ }
485
 
486
  /**
487
  * @since 3.01
488
+ *
489
  * @param int $form_id
490
  */
491
  private static function delete_form_entries( $form_id ) {
493
 
494
  $form_ids = self::get_child_form_ids( $form_id );
495
 
496
+ $meta_query = $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) WHERE form_id=%d", $form_id );
497
  $entry_query = $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id );
498
 
499
  if ( ! empty( $form_ids ) ) {
500
+ $form_query = ' OR form_id in (' . $form_ids . ')';
501
+ $meta_query .= $form_query;
502
  $entry_query .= $form_query;
503
  }
504
 
505
  $wpdb->query( $meta_query ); // WPCS: unprepared SQL ok.
506
+
507
  return $wpdb->query( $entry_query ); // WPCS: unprepared SQL ok.
508
  }
509
 
510
  /**
511
  * @since 3.01
512
+ *
513
  * @param int $form_id
514
  * @param bool|string $implode
515
  */
516
  private static function get_child_form_ids( $form_id, $implode = ',' ) {
517
+ $form_ids = array();
518
  $child_form_ids = FrmDb::get_col( 'frm_forms', array( 'parent_form_id' => $form_id ) );
519
  if ( $child_form_ids ) {
520
  $form_ids = $child_form_ids;
523
  if ( $implode ) {
524
  $form_ids = implode( $implode, $form_ids );
525
  }
526
+
527
  return $form_ids;
528
  }
529
 
530
+ public static function process_entry( $errors = '', $ajax = false ) {
531
  $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
532
  if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) {
533
+ return;
534
+ }
535
 
536
+ global $frm_vars;
537
 
538
  $form = FrmForm::getOne( $form_id );
539
+ if ( ! $form ) {
540
+ return;
541
+ }
542
 
543
  $params = FrmForm::get_params( $form );
544
 
545
+ if ( ! isset( $frm_vars['form_params'] ) ) {
546
+ $frm_vars['form_params'] = array();
547
+ }
548
  $frm_vars['form_params'][ $form->id ] = $params;
549
 
550
  if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) {
551
+ return;
552
+ }
553
 
554
+ if ( $errors == '' && ! $ajax ) {
555
  $errors = FrmEntryValidate::validate( $_POST );
556
+ }
557
 
558
  /**
559
  * Use this filter to add trigger actions and add errors after
565
 
566
  $frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors );
567
 
568
+ if ( empty( $errors ) ) {
569
  $_POST['frm_skip_cookie'] = 1;
570
+ $do_success = false;
571
+ if ( $params['action'] == 'create' ) {
572
  if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
573
  $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST );
574
+
575
  $params['id'] = $frm_vars['created_entries'][ $form_id ]['entry_id'];
576
+ $do_success = true;
577
+ }
578
+ }
579
 
580
+ do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
581
  if ( $do_success ) {
582
  FrmFormsController::maybe_trigger_redirect( $form, $params, array( 'ajax' => $ajax ) );
583
  }
584
  unset( $_POST['frm_skip_cookie'] );
585
+ }
586
+ }
587
 
588
  /**
589
  * Escape url entities before redirect
591
  * @since 3.0
592
  *
593
  * @param string $url
594
+ *
595
  * @return string
596
  */
597
  public static function prepare_redirect_url( $url ) {
598
  return str_replace( array( ' ', '[', ']', '|', '@' ), array( '%20', '%5B', '%5D', '%7C', '%40' ), $url );
599
  }
600
 
601
+ public static function delete_entry_before_redirect( $url, $form, $atts ) {
602
+ self::_delete_entry( $atts['id'], $form );
 
 
603
 
604
+ return $url;
605
+ }
606
+
607
+ /**
608
+ * Delete entry if not redirected.
609
+ *
610
+ * @param array $atts
611
+ */
612
+ public static function delete_entry_after_save( $atts ) {
613
+ self::_delete_entry( $atts['entry_id'], $atts['form'] );
614
+ }
615
 
616
+ private static function _delete_entry( $entry_id, $form ) {
617
+ if ( ! $form ) {
618
+ return;
619
+ }
620
 
621
+ $form->options = maybe_unserialize( $form->options );
622
+ if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
623
  self::unlink_post( $entry_id );
624
+ FrmEntry::destroy( $entry_id );
625
+ }
626
+ }
627
 
628
  /**
629
  * Unlink entry from post
658
  'border_color' => '',
659
  'bg_color' => '',
660
  'alt_bg_color' => '',
661
+ 'class' => '',
662
  'clickable' => false,
663
  'exclude_fields' => '',
664
  'include_fields' => '',
675
  'format' => $atts['format'],
676
  'plain_text' => $atts['plain_text'],
677
  );
678
+
679
+ $entry_formatter = FrmEntryFactory::entry_shortcode_formatter_instance( $atts['form_id'], $shortcode_atts );
680
+ $formatted_entry = $entry_formatter->content();
681
 
682
  } else {
683
 
689
  return $formatted_entry;
690
  }
691
 
692
+ public static function entry_sidebar( $entry = false ) {
693
+ $data = maybe_unserialize( $entry->description );
694
  $date_format = get_option( 'date_format' );
695
  $time_format = get_option( 'time_format' );
696
  if ( isset( $data['browser'] ) ) {
698
  }
699
 
700
  include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' );
701
+ }
702
+
703
+ /**
704
+ * @deprecated 4.0
705
+ */
706
+ public static function contextual_help( $help, $screen_id, $screen ) {
707
+ _deprecated_function( __METHOD__, '4.0' );
708
+ return $help;
709
+ }
710
 
711
  /**
712
  * @deprecated 1.07.05
classes/controllers/FrmFieldsController.php CHANGED
@@ -2,25 +2,24 @@
2
 
3
  class FrmFieldsController {
4
 
5
- public static function load_field() {
6
  FrmAppHelper::permission_check( 'frm_edit_forms' );
7
- check_ajax_referer( 'frm_ajax', 'nonce' );
8
 
9
- $fields = $_POST['field'];
10
- if ( empty( $fields ) ) {
11
- wp_die();
12
- }
13
 
14
- $_GET['page'] = 'formidable';
15
- $fields = stripslashes_deep( $fields );
16
 
17
- $values = array(
18
- 'id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ),
19
  'doing_ajax' => true,
20
  );
21
- $field_html = array();
22
 
23
- foreach ( $fields as $field ) {
24
  $field = htmlspecialchars_decode( nl2br( $field ) );
25
  $field = json_decode( $field );
26
  if ( ! isset( $field->id ) || ! is_numeric( $field->id ) ) {
@@ -32,54 +31,55 @@ class FrmFieldsController {
32
  $field->value = '';
33
  }
34
  $field->field_options = json_decode( json_encode( $field->field_options ), true );
35
- $field->options = json_decode( json_encode( $field->options ), true );
36
  $field->default_value = json_decode( json_encode( $field->default_value ), true );
37
 
38
  ob_start();
39
  self::load_single_field( $field, $values );
40
  $field_html[ absint( $field->id ) ] = ob_get_contents();
41
  ob_end_clean();
42
- }
43
 
44
  echo json_encode( $field_html );
45
 
46
- wp_die();
47
- }
48
 
49
  /**
50
  * Create a new field with ajax
51
  */
52
- public static function create() {
53
  FrmAppHelper::permission_check( 'frm_edit_forms' );
54
- check_ajax_referer( 'frm_ajax', 'nonce' );
55
 
56
  $field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' );
57
- $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
58
 
59
  $field = self::include_new_field( $field_type, $form_id );
60
 
61
  // this hook will allow for multiple fields to be added at once
62
  do_action( 'frm_after_field_created', $field, $form_id );
63
 
64
- wp_die();
65
- }
66
 
67
- /**
68
- * Set up and create a new field
69
- *
70
- * @param string $field_type
71
- * @param integer $form_id
72
- * @return array|bool
73
- */
 
74
  public static function include_new_field( $field_type, $form_id ) {
75
  $field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id );
76
- $field_values = apply_filters( 'frm_before_field_created', $field_values );
77
 
78
- $field_id = FrmField::create( $field_values );
79
 
80
- if ( ! $field_id ) {
81
- return false;
82
- }
83
 
84
  $field = self::get_field_array_from_id( $field_id );
85
 
@@ -95,47 +95,20 @@ class FrmFieldsController {
95
 
96
  self::load_single_field( $field, $values, $form_id );
97
 
98
- return $field;
99
- }
100
-
101
- public static function update_ajax_option() {
102
- FrmAppHelper::permission_check( 'frm_edit_forms' );
103
- check_ajax_referer( 'frm_ajax', 'nonce' );
104
-
105
- $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
106
- if ( ! $field_id ) {
107
- wp_die();
108
- }
109
-
110
- $field = FrmField::getOne( $field_id );
111
-
112
- if ( isset( $_POST['separate_value'] ) ) {
113
- $new_val = FrmField::is_option_true( $field, 'separate_value' ) ? 0 : 1;
114
- $field->field_options['separate_value'] = $new_val;
115
- unset( $new_val );
116
- }
117
-
118
- FrmField::update(
119
- $field_id,
120
- array(
121
- 'field_options' => $field->field_options,
122
- 'form_id' => $field->form_id,
123
- )
124
- );
125
- wp_die();
126
- }
127
 
128
- public static function duplicate() {
129
  FrmAppHelper::permission_check( 'frm_edit_forms' );
130
- check_ajax_referer( 'frm_ajax', 'nonce' );
131
 
132
  $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
133
- $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
134
 
135
  $copy_field = FrmField::getOne( $field_id );
136
- if ( ! $copy_field ) {
137
  wp_die();
138
- }
139
 
140
  do_action( 'frm_duplicate_field', $copy_field, $form_id );
141
  do_action( 'frm_duplicate_field_' . $copy_field->type, $copy_field, $form_id );
@@ -151,8 +124,8 @@ class FrmFieldsController {
151
  self::load_single_field( $field_id, $values );
152
  }
153
 
154
- wp_die();
155
- }
156
 
157
  /**
158
  * @since 3.0
@@ -163,6 +136,7 @@ class FrmFieldsController {
163
  */
164
  public static function get_field_array_from_id( $field_id ) {
165
  $field = FrmField::getOne( $field_id );
 
166
  return FrmFieldsHelper::setup_edit_vars( $field );
167
  }
168
 
@@ -180,28 +154,23 @@ class FrmFieldsController {
180
  if ( is_numeric( $field_object ) ) {
181
  $field_object = FrmField::getOne( $field_object );
182
  } elseif ( is_array( $field_object ) ) {
183
- $field = $field_object;
184
  $field_object = FrmField::getOne( $field['id'] );
185
  }
186
 
187
  $field_obj = FrmFieldFactory::get_field_factory( $field_object );
188
- $display = self::display_field_options( array(), $field_obj );
189
 
190
- $ajax_loading = isset( $values['ajax_load'] ) && $values['ajax_load'];
191
  $ajax_this_field = isset( $values['count'] ) && $values['count'] > 10 && ! in_array( $field_object->type, array( 'divider', 'end_divider' ) );
192
 
193
  if ( $ajax_loading && $ajax_this_field ) {
194
  $li_classes = self::get_classes_for_builder_field( array(), $display, $field_obj );
195
  include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/ajax-field-placeholder.php' );
196
  } else {
197
- $frm_settings = FrmAppHelper::get_settings();
198
-
199
- $pro_field_selection = FrmField::pro_field_selection();
200
- $frm_all_field_selection = array_merge( FrmField::field_selection(), $pro_field_selection );
201
- $disabled_fields = FrmAppHelper::pro_is_installed() ? array() : $pro_field_selection;
202
-
203
  if ( ! isset( $field ) && is_object( $field_object ) ) {
204
  $field_object->parent_form_id = isset( $values['id'] ) ? $values['id'] : $field_object->form_id;
 
205
  $field = FrmFieldsHelper::setup_edit_vars( $field_object );
206
  }
207
 
@@ -217,98 +186,24 @@ class FrmFieldsController {
217
  */
218
  private static function get_classes_for_builder_field( $field, $display, $field_info ) {
219
  $li_classes = $field_info->form_builder_classes( $display['type'] );
 
220
  if ( ! empty( $field ) ) {
221
  $li_classes = apply_filters( 'frm_build_field_class', $li_classes, $field );
222
  }
 
223
  return $li_classes;
224
  }
225
 
226
- public static function destroy() {
227
  FrmAppHelper::permission_check( 'frm_edit_forms' );
228
- check_ajax_referer( 'frm_ajax', 'nonce' );
229
 
230
  $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
231
  FrmField::destroy( $field_id );
232
- wp_die();
233
- }
234
-
235
- /* Field Options */
236
-
237
- //Add Single Option or Other Option
238
- public static function add_option() {
239
- FrmAppHelper::permission_check( 'frm_edit_forms' );
240
- check_ajax_referer( 'frm_ajax', 'nonce' );
241
-
242
- $id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
243
- $opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' );
244
- $opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'absint' );
245
-
246
- $field = FrmField::getOne( $id );
247
-
248
- if ( 'other' == $opt_type ) {
249
- $opt = __( 'Other', 'formidable' );
250
- $opt_key = 'other_' . $opt_key;
251
- } else {
252
- $opt = __( 'New Option', 'formidable' );
253
- }
254
-
255
- $field_data = $field;
256
- $field = (array) $field;
257
- $field['separate_value'] = isset( $field_data->field_options['separate_value'] ) ? $field_data->field_options['separate_value'] : 0;
258
- unset( $field_data );
259
- $field['html_name'] = 'item_meta[' . $field['id'] . ']';
260
-
261
- $field['options'] = array( $opt_key => $opt );
262
- FrmFieldsHelper::show_single_option( $field );
263
-
264
  wp_die();
265
- }
266
-
267
- public static function import_choices() {
268
- FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
269
-
270
- $field_id = absint( $_REQUEST['field_id'] );
271
-
272
- global $current_screen, $hook_suffix;
273
-
274
- // Catch plugins that include admin-header.php before admin.php completes.
275
- if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) {
276
- $hook_suffix = '';
277
- set_current_screen();
278
- }
279
-
280
- if ( function_exists( 'register_admin_color_schemes' ) ) {
281
- register_admin_color_schemes();
282
- }
283
-
284
- $hook_suffix = '';
285
- $admin_body_class = '';
286
-
287
- if ( get_user_setting( 'mfold' ) == 'f' ) {
288
- $admin_body_class .= ' folded';
289
- }
290
-
291
- if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) {
292
- $admin_body_class .= ' admin-bar';
293
- }
294
-
295
- if ( is_rtl() ) {
296
- $admin_body_class .= ' rtl';
297
- }
298
-
299
- $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
300
- $prepop = array();
301
- FrmFieldsHelper::get_bulk_prefilled_opts( $prepop );
302
-
303
- $field = FrmField::getOne( $field_id );
304
-
305
- wp_enqueue_script( 'utils' );
306
- wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css', array(), FrmAppHelper::plugin_version() );
307
- FrmAppHelper::load_admin_wide_js();
308
 
309
- include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/import_choices.php' );
310
- wp_die();
311
- }
312
 
313
  public static function import_options() {
314
  FrmAppHelper::permission_check( 'frm_edit_forms' );
@@ -318,38 +213,39 @@ class FrmFieldsController {
318
  return;
319
  }
320
 
321
- $field_id = absint( $_POST['field_id'] );
322
- $field = FrmField::getOne( $field_id );
323
 
324
  if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) {
325
- return;
326
- }
327
 
328
  $field = FrmFieldsHelper::setup_edit_vars( $field );
329
- $opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' );
330
- $opts = explode( "\n", rtrim( $opts, "\n" ) );
331
- $opts = array_map( 'trim', $opts );
 
 
 
332
 
333