PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.0.01
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.0.01
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/models/FrmUsage.php +51 -159 6.255.0.01 View file →
@@ -9,10 +9,8 @@
9 9 class FrmUsage {
10 10
11 11 /**
12 12 * @since 3.06.04
13 - *
14 - * @return void
15 13 */
16 14 public function send_snapshot() {
17 15 if ( ! $this->tracking_allowed() ) {
18 16 return;
@@ -17,30 +15,23 @@
17 15 if ( ! $this->tracking_allowed() ) {
18 16 return;
19 17 }
20 18
21 - $ep = 'aHR0cHM6Ly91c2FnZTIuZm9ybWlkYWJsZWZvcm1zLmNvbS9zbmFwc2hvdA==';
19 + $ep = 'aHR0cHM6Ly9mcm0tdXNlci10cmFja2luZy5oZXJva3VhcHAuY29tL3NuYXBzaG90';
22 20 // $ep = base64_encode( 'http://localhost:4567/snapshot' ); // Uncomment for testing
23 21 $body = json_encode( $this->snapshot() );
24 22
25 23 // Setup variable for wp_remote_request.
26 24 $post = array(
27 - 'method' => 'POST',
28 - 'headers' => array(
25 + 'method' => 'POST',
26 + 'headers' => array(
29 27 'Accept' => 'application/json',
30 28 'Content-Type' => 'application/json',
31 29 'Content-Length' => strlen( $body ),
32 30 ),
33 - 'body' => $body,
34 - // Without this, Debug Log catches the `http_request_failed` error.
35 - 'timeout' => 45,
31 + 'body' => $body,
36 32 );
37 33
38 - // Remove time limit to execute this function.
39 - if ( function_exists( 'set_time_limit' ) ) {
40 - set_time_limit( 0 );
41 - }
42 -
43 34 wp_remote_request( base64_decode( $ep ), $post );
44 35 }
45 36
46 37 /**
@@ -71,121 +62,48 @@
71 62 $theme_data = wp_get_theme();
72 63 $form_counts = FrmForm::get_count();
73 64
74 65 $snap = array(
75 - 'uuid' => $this->uuid(),
76 - // Let's keep it anonymous.
77 - 'admin_email' => '',
78 - 'wp_version' => $wp_version,
79 - 'php_version' => phpversion(),
80 - 'mysql_version' => $wpdb->db_version(),
81 - 'os' => FrmAppHelper::get_server_os(),
82 - 'locale' => get_locale(),
66 + 'uuid' => $this->uuid(),
67 + 'admin_email' => '', // Let's keep it anonymous.
68 + 'wp_version' => $wp_version,
69 + 'php_version' => phpversion(),
70 + 'mysql_version' => $wpdb->db_version(),
71 + 'os' => php_uname( 's' ),
72 + 'locale' => get_locale(),
83 73
84 - 'active_license' => FrmAppHelper::pro_is_installed(),
85 - 'form_count' => $form_counts->published,
86 - 'entry_count' => FrmEntry::getRecordCount(),
87 - 'timestamp' => gmdate( 'c' ),
74 + 'active_license' => FrmAppHelper::pro_is_installed(),
75 + 'form_count' => $form_counts->published,
76 + 'entry_count' => FrmEntry::getRecordCount(),
77 + 'timestamp' => gmdate( 'c' ),
88 78
89 - 'theme_name' => is_object( $theme_data ) ? $theme_data->Name : '', // phpcs:ignore WordPress.NamingConventions
90 - 'plugins' => $this->plugins(),
91 - 'settings' => array(
79 + 'theme_name' => is_object( $theme_data ) ? $theme_data->Name : '', // phpcs:ignore WordPress.NamingConventions
80 + 'plugins' => $this->plugins(),
81 + 'settings' => array(
92 82 $this->settings(),
93 83 ),
94 - 'forms' => $this->forms(),
95 - 'fields' => $this->fields(),
96 - 'actions' => $this->actions(),
97 -
98 - 'onboarding-wizard' => $this->onboarding_wizard(),
99 - 'flows' => FrmUsageController::get_flows_data(),
100 - 'payments' => $this->payments(),
101 - 'subscriptions' => $this->payments( 'frm_subscriptions' ),
84 + 'forms' => $this->forms(),
85 + 'fields' => $this->fields(),
86 + 'actions' => $this->actions(),
102 87 );
103 88
104 - if ( method_exists( 'FrmProAddonsController', 'get_readable_license_type' ) ) {
105 - $snap['active_license'] = FrmProAddonsController::get_readable_license_type();
106 - }
107 -
108 89 return apply_filters( 'frm_usage_snapshot', $snap );
109 90 }
110 91
111 92 /**
112 - * Gets onboarding wizard data.
113 - *
114 - * @since 6.16.1
115 - *
116 - * @return array
117 - */
118 - private function onboarding_wizard() {
119 - $data = FrmOnboardingWizardController::get_usage_data();
120 - $skipped_keys = array(
121 - 'default_email',
122 - 'is_subscribed',
123 - 'allows_tracking',
124 - 'summary_emails',
125 - 'installed_addons',
126 - );
127 -
128 - foreach ( $skipped_keys as $skipped_key ) {
129 - unset( $data[ $skipped_key ] );
130 - }
131 -
132 - return $data;
133 - }
134 -
135 - /**
136 - * Gets payments data.
137 - *
138 - * @since 6.16.1
139 - *
140 - * @param string $table Database table name.
141 - * @return array
142 - */
143 - private function payments( $table = 'frm_payments' ) {
144 - $allowed_tables = array( 'frm_payments', 'frm_subscriptions' );
145 - if ( ! in_array( $table, $allowed_tables, true ) ) {
146 - return array();
147 - }
148 -
149 - if ( ! FrmTransLiteAppHelper::payments_table_exists() ) {
150 - return array();
151 - }
152 -
153 - global $wpdb;
154 - $rows = $wpdb->get_results(
155 - $wpdb->prepare(
156 - 'SELECT amount, status, paysys, created_at FROM %1$s',
157 - $wpdb->prefix . $table
158 - )
159 - );
160 -
161 - $payments = array();
162 - foreach ( $rows as $row ) {
163 - $payments[] = array(
164 - 'amount' => (float) $row->amount,
165 - 'status' => $row->status,
166 - 'gateway' => $row->paysys,
167 - 'created_at' => $row->created_at,
168 - );
169 - }
170 -
171 - return $payments;
172 - }
173 -
174 - /**
175 93 * @since 3.06.04
176 94 * @return array
177 95 */
178 96 private function plugins() {
179 - $plugin_list = FrmAppHelper::get_plugins();
97 + $plugin_list = get_plugins();
180 98
181 99 $plugins = array();
182 100 foreach ( $plugin_list as $slug => $info ) {
183 101 $plugins[] = array(
184 - 'name' => $info['Name'],
185 - 'slug' => $slug,
186 - 'version' => $info['Version'],
187 - 'active' => is_plugin_active( $slug ),
102 + 'name' => $info['Name'],
103 + 'slug' => $slug,
104 + 'version' => $info['Version'],
105 + 'active' => is_plugin_active( $slug ),
188 106 );
189 107 }
190 108
191 109 return $plugins;
@@ -197,16 +115,19 @@
197 115 * @since 3.06.04
198 116 * @return array
199 117 */
200 118 private function settings() {
201 - $settings_list = FrmAppHelper::get_settings();
202 - $settings = array(
119 + $settings_list = FrmAppHelper::get_settings();
120 + $settings = array(
203 121 'messages' => $this->messages( $settings_list ),
204 122 'permissions' => $this->permissions( $settings_list ),
205 123 );
206 124 $pass_settings = array(
207 125 'load_style',
126 + 'use_html',
127 + 'old_css',
208 128 'fade_form',
129 + 'jquery_css',
209 130 're_type',
210 131 're_lang',
211 132 're_multi',
212 133 'menu',
@@ -211,20 +132,11 @@
211 132 're_multi',
212 133 'menu',
213 134 'mu_menu',
214 135 'no_ips',
215 - 'custom_header_ip',
216 - 'enable_gdpr',
217 - 'no_gdpr_cookies',
218 136 'btsp_css',
219 - 'btsp_version',
137 + 'btsp_errors',
220 138 'admin_bar',
221 - 'summary_emails',
222 - 'active_captcha',
223 - 'honeypot',
224 - 'wp_spam_check',
225 - 'denylist_check',
226 - 'email_style',
227 139 );
228 140
229 141 foreach ( $pass_settings as $setting ) {
230 142 if ( isset( $settings_list->$setting ) ) {
@@ -243,10 +155,8 @@
243 155 /**
244 156 * Include the permissions settings for each capability.
245 157 *
246 158 * @since 3.06.04
247 - *
248 - * @param FrmSettings $settings_list
249 159 * @return array
250 160 */
251 161 private function messages( $settings_list ) {
252 162 $messages = array(
@@ -259,13 +169,11 @@
259 169 'login_msg',
260 170 'admin_permission',
261 171 );
262 172
263 - $default = $settings_list->default_options();
264 -
265 173 $message_settings = array();
266 174 foreach ( $messages as $message ) {
267 - $message_settings[ 'changed-' . $message ] = $settings_list->$message === $default[ $message ] ? 0 : 1;
175 + $message_settings[ $message ] = $settings_list->$message;
268 176 }
269 177
270 178 return $message_settings;
271 179 }
@@ -273,10 +181,8 @@
273 181 /**
274 182 * Include the permissions settings for each capability.
275 183 *
276 184 * @since 3.06.04
277 - *
278 - * @param FrmSettings $settings_list
279 185 * @return array
280 186 */
281 187 private function permissions( $settings_list ) {
282 188 $permissions = array();
@@ -297,10 +203,10 @@
297 203 */
298 204 private function forms() {
299 205 $s_query = array(
300 206 array(
301 - 'or' => 1,
302 - 'parent_form_id' => null,
207 + 'or' => 1,
208 + 'parent_form_id' => null,
303 209 'parent_form_id <' => 1,
304 210 ),
305 211 );
306 212
@@ -308,10 +214,10 @@
308 214 $forms = array();
309 215 $settings = array(
310 216 'form_class',
311 217 'akismet',
218 + 'honeypot',
312 219 'antispam',
313 - 'stopforumspam',
314 220 'custom_style',
315 221 'success_action',
316 222 'show_form',
317 223 'no_save',
@@ -340,44 +246,28 @@
340 246 'prev_value',
341 247 'submit_conditions',
342 248 );
343 249
344 - $style = new FrmStyle();
345 250 foreach ( $saved_forms as $form ) {
346 251 $new_form = array(
347 - 'form_id' => $form->id,
348 - 'description' => $form->description,
349 - 'logged_in' => $form->logged_in,
350 - 'editable' => $form->editable,
351 - 'is_template' => $form->is_template,
352 - 'entry_count' => FrmEntry::getRecordCount( $form->id ),
353 - 'field_count' => $this->form_field_count( $form->id ),
252 + 'form_id' => $form->id,
253 + 'description' => $form->description,
254 + 'logged_in' => $form->logged_in,
255 + 'editable' => $form->editable,
256 + 'is_template' => $form->is_template,
257 + 'entry_count' => FrmEntry::getRecordCount( $form->id ),
258 + 'field_count' => $this->form_field_count( $form->id ),
354 259 'form_action_count' => $this->form_action_count( $form->id ),
355 260 );
356 261
357 262 foreach ( $settings as $setting ) {
358 263 if ( isset( $form->options[ $setting ] ) ) {
359 - if ( 'custom_style' === $setting ) {
360 - $style->id = $form->options[ $setting ];
361 -
362 - if ( ! $style->id ) {
363 - $style_name = 0;
364 - } elseif ( 1 === intval( $style->id ) ) {
365 - $style_name = 'formidable-style';
366 - } else {
367 - $style_post = $style->get_one();
368 - $style_name = $style_post ? $style_post->post_name : 'formidable-style';
369 - }
370 -
371 - $new_form[ $setting ] = $style_name;
372 - } else {
373 - $new_form[ $setting ] = $this->maybe_json( $form->options[ $setting ] );
374 - }
264 + $new_form[ $setting ] = $this->maybe_json( $form->options[ $setting ] );
375 265 }
376 266 }
377 267
378 268 $forms[] = apply_filters( 'frm_usage_form', $new_form, compact( 'form' ) );
379 - }//end foreach
269 + }
380 270
381 271 // If the array uses numeric keys, reset them.
382 272 return $forms;
383 273 }
@@ -388,9 +278,9 @@
388 278 */
389 279 private function form_field_count( $form_id ) {
390 280 global $wpdb;
391 281
392 - $join = $wpdb->prefix . 'frm_fields fi JOIN ' . $wpdb->prefix . 'frm_forms fo ON (fi.form_id=fo.id)';
282 + $join = $wpdb->prefix . 'frm_fields fi LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fo ON (fi.form_id=fo.id)';
393 283
394 284 $field_query = array(
395 285 'or' => 1,
396 286 'fi.form_id' => $form_id,
@@ -421,14 +311,14 @@
421 311 * @since 3.06.04
422 312 * @return array
423 313 */
424 314 private function fields() {
425 - $args = array(
315 + $args = array(
426 316 'limit' => 50,
427 317 'order_by' => 'id DESC',
428 318 );
429 319
430 - $fields = FrmDb::get_results( 'frm_fields', array(), 'id, form_id, name, type, field_options', $args );
320 + $fields = FrmDb::get_results( 'frm_fields', array(), 'form_id, name, type, field_options', $args );
431 321 foreach ( $fields as $k => $field ) {
432 322 FrmAppHelper::unserialize_or_decode( $field->field_options );
433 323 $fields[ $k ]->field_options = json_encode( $field->field_options );
434 324 }
@@ -464,9 +354,10 @@
464 354 * @since 3.06.04
465 355 * @return bool
466 356 */
467 357 private function tracking_allowed() {
468 - return FrmUsageController::tracking_allowed();
358 + $settings = FrmAppHelper::get_settings();
359 + return $settings->tracking;
469 360 }
470 361
471 362 /**
472 363 * @since 3.06.04
@@ -475,4 +366,5 @@
475 366 private function maybe_json( $value ) {
476 367 return is_array( $value ) ? json_encode( $value ) : $value;
477 368 }
478 369 }
370 +