PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.8
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.8
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 +53 -183 6.276.8 View file →
@@ -17,38 +17,28 @@
17 17 if ( ! $this->tracking_allowed() ) {
18 18 return;
19 19 }
20 20
21 - $ep = 'aHR0cHM6Ly91c2FnZTIuZm9ybWlkYWJsZWZvcm1zLmNvbS9zbmFwc2hvdA==';
21 + $ep = 'aHR0cHM6Ly9mcm0tdXNlci10cmFja2luZy5oZXJva3VhcHAuY29tL3NuYXBzaG90';
22 22 // $ep = base64_encode( 'http://localhost:4567/snapshot' ); // Uncomment for testing
23 23 $body = json_encode( $this->snapshot() );
24 24
25 25 // Setup variable for wp_remote_request.
26 26 $post = array(
27 - 'method' => 'POST',
28 - 'headers' => array(
27 + 'method' => 'POST',
28 + 'headers' => array(
29 29 'Accept' => 'application/json',
30 30 'Content-Type' => 'application/json',
31 31 'Content-Length' => strlen( $body ),
32 32 ),
33 - 'body' => $body,
34 - // Without this, Debug Log catches the `http_request_failed` error.
35 - 'timeout' => 45,
33 + 'body' => $body,
36 34 );
37 35
38 - // Remove time limit to execute this function.
39 - if ( function_exists( 'set_time_limit' ) ) {
40 - set_time_limit( 0 );
41 - }
42 -
43 36 wp_remote_request( base64_decode( $ep ), $post );
44 37 }
45 38
46 39 /**
47 40 * @since 3.06.04
48 - *
49 - * @param bool $regenerate
50 - *
51 41 * @return string
52 42 */
53 43 public function uuid( $regenerate = false ) {
54 44 $uuid_key = 'frm-usage-uuid';
@@ -53,9 +43,9 @@
53 43 public function uuid( $regenerate = false ) {
54 44 $uuid_key = 'frm-usage-uuid';
55 45 $uuid = get_option( $uuid_key );
56 46
57 - if ( $regenerate || ! $uuid ) {
47 + if ( $regenerate || empty( $uuid ) ) {
58 48 // Definitely not cryptographically secure but
59 49 // close enough to provide an unique id
60 50 $uuid = md5( uniqid() . site_url() );
61 51 update_option( $uuid_key, $uuid, 'no' );
@@ -65,9 +55,8 @@
65 55 }
66 56
67 57 /**
68 58 * @since 3.06.04
69 - *
70 59 * @return array
71 60 */
72 61 public function snapshot() {
73 62 global $wpdb, $wp_version;
@@ -75,126 +64,49 @@
75 64 $theme_data = wp_get_theme();
76 65 $form_counts = FrmForm::get_count();
77 66
78 67 $snap = array(
79 - 'uuid' => $this->uuid(),
68 + 'uuid' => $this->uuid(),
80 69 // Let's keep it anonymous.
81 - 'admin_email' => '',
82 - 'wp_version' => $wp_version,
83 - 'php_version' => phpversion(),
84 - 'mysql_version' => $wpdb->db_version(),
85 - 'os' => FrmAppHelper::get_server_os(),
86 - 'locale' => get_locale(),
70 + 'admin_email' => '',
71 + 'wp_version' => $wp_version,
72 + 'php_version' => phpversion(),
73 + 'mysql_version' => $wpdb->db_version(),
74 + 'os' => FrmAppHelper::get_server_os(),
75 + 'locale' => get_locale(),
87 76
88 - 'active_license' => FrmAppHelper::pro_is_installed(),
89 - 'form_count' => $form_counts->published,
90 - 'entry_count' => FrmEntry::getRecordCount(),
91 - 'timestamp' => gmdate( 'c' ),
77 + 'active_license' => FrmAppHelper::pro_is_installed(),
78 + 'form_count' => $form_counts->published,
79 + 'entry_count' => FrmEntry::getRecordCount(),
80 + 'timestamp' => gmdate( 'c' ),
92 81
93 - 'theme_name' => is_object( $theme_data ) ? $theme_data->Name : '', // phpcs:ignore WordPress.NamingConventions
94 - 'plugins' => $this->plugins(),
95 - 'settings' => array(
82 + 'theme_name' => is_object( $theme_data ) ? $theme_data->Name : '', // phpcs:ignore WordPress.NamingConventions
83 + 'plugins' => $this->plugins(),
84 + 'settings' => array(
96 85 $this->settings(),
97 86 ),
98 - 'forms' => $this->forms(),
99 - 'fields' => $this->fields(),
100 - 'actions' => $this->actions(),
101 -
102 - 'onboarding-wizard' => $this->onboarding_wizard(),
103 - 'welcome-tour' => FrmWelcomeTourController::get_usage_data(),
104 - 'flows' => FrmUsageController::get_flows_data(),
105 - 'payments' => $this->payments(),
106 - 'subscriptions' => $this->payments( 'frm_subscriptions' ),
87 + 'forms' => $this->forms(),
88 + 'fields' => $this->fields(),
89 + 'actions' => $this->actions(),
107 90 );
108 91
109 - if ( method_exists( 'FrmProAddonsController', 'get_readable_license_type' ) ) {
110 - $snap['active_license'] = FrmProAddonsController::get_readable_license_type();
111 - }
112 -
113 92 return apply_filters( 'frm_usage_snapshot', $snap );
114 93 }
115 94
116 95 /**
117 - * Gets onboarding wizard data.
118 - *
119 - * @since 6.16.1
120 - *
121 - * @return array
122 - */
123 - private function onboarding_wizard() {
124 - $data = FrmOnboardingWizardController::get_usage_data();
125 - $skipped_keys = array(
126 - 'default_email',
127 - 'is_subscribed',
128 - 'allows_tracking',
129 - 'summary_emails',
130 - 'installed_addons',
131 - );
132 -
133 - foreach ( $skipped_keys as $skipped_key ) {
134 - unset( $data[ $skipped_key ] );
135 - }
136 -
137 - return $data;
138 - }
139 -
140 - /**
141 - * Gets payments data.
142 - *
143 - * @since 6.16.1
144 - *
145 - * @param string $table Database table name.
146 - *
147 - * @return array
148 - */
149 - private function payments( $table = 'frm_payments' ) {
150 - $allowed_tables = array( 'frm_payments', 'frm_subscriptions' );
151 -
152 - if ( ! in_array( $table, $allowed_tables, true ) ) {
153 - return array();
154 - }
155 -
156 - if ( ! FrmTransLiteAppHelper::payments_table_exists() ) {
157 - return array();
158 - }
159 -
160 - global $wpdb;
161 - $rows = $wpdb->get_results(
162 - $wpdb->prepare(
163 - 'SELECT amount, status, paysys, created_at FROM %1$s',
164 - $wpdb->prefix . $table
165 - )
166 - );
167 -
168 - $payments = array();
169 -
170 - foreach ( $rows as $row ) {
171 - $payments[] = array(
172 - 'amount' => (float) $row->amount,
173 - 'status' => $row->status,
174 - 'gateway' => $row->paysys,
175 - 'created_at' => $row->created_at,
176 - );
177 - }
178 -
179 - return $payments;
180 - }
181 -
182 - /**
183 96 * @since 3.06.04
184 - *
185 97 * @return array
186 98 */
187 99 private function plugins() {
188 100 $plugin_list = FrmAppHelper::get_plugins();
189 - $plugins = array();
190 101
102 + $plugins = array();
191 103 foreach ( $plugin_list as $slug => $info ) {
192 104 $plugins[] = array(
193 - 'name' => $info['Name'],
194 - 'slug' => $slug,
195 - 'version' => $info['Version'],
196 - 'active' => is_plugin_active( $slug ),
105 + 'name' => $info['Name'],
106 + 'slug' => $slug,
107 + 'version' => $info['Version'],
108 + 'active' => is_plugin_active( $slug ),
197 109 );
198 110 }
199 111
200 112 return $plugins;
@@ -203,20 +115,21 @@
203 115 /**
204 116 * Add global settings to tracking data.
205 117 *
206 118 * @since 3.06.04
207 - *
208 119 * @return array
209 120 */
210 121 private function settings() {
211 - $settings_list = FrmAppHelper::get_settings();
212 - $settings = array(
122 + $settings_list = FrmAppHelper::get_settings();
123 + $settings = array(
213 124 'messages' => $this->messages( $settings_list ),
214 125 'permissions' => $this->permissions( $settings_list ),
215 126 );
216 127 $pass_settings = array(
217 128 'load_style',
129 + 'use_html',
218 130 'fade_form',
131 + 'jquery_css',
219 132 're_type',
220 133 're_lang',
221 134 're_multi',
222 135 'menu',
@@ -221,20 +134,11 @@
221 134 're_multi',
222 135 'menu',
223 136 'mu_menu',
224 137 'no_ips',
225 - 'custom_header_ip',
226 - 'enable_gdpr',
227 - 'no_gdpr_cookies',
228 138 'btsp_css',
229 - 'btsp_version',
139 + 'btsp_errors',
230 140 'admin_bar',
231 - 'summary_emails',
232 - 'active_captcha',
233 - 'honeypot',
234 - 'wp_spam_check',
235 - 'denylist_check',
236 - 'email_style',
237 141 );
238 142
239 143 foreach ( $pass_settings as $setting ) {
240 144 if ( isset( $settings_list->$setting ) ) {
@@ -255,9 +159,8 @@
255 159 *
256 160 * @since 3.06.04
257 161 *
258 162 * @param FrmSettings $settings_list
259 - *
260 163 * @return array
261 164 */
262 165 private function messages( $settings_list ) {
263 166 $messages = array(
@@ -270,13 +173,11 @@
270 173 'login_msg',
271 174 'admin_permission',
272 175 );
273 176
274 - $default = $settings_list->default_options();
275 177 $message_settings = array();
276 -
277 178 foreach ( $messages as $message ) {
278 - $message_settings[ 'changed-' . $message ] = $settings_list->$message === $default[ $message ] ? 0 : 1;
179 + $message_settings[ $message ] = $settings_list->$message;
279 180 }
280 181
281 182 return $message_settings;
282 183 }
@@ -286,9 +187,8 @@
286 187 *
287 188 * @since 3.06.04
288 189 *
289 190 * @param FrmSettings $settings_list
290 - *
291 191 * @return array
292 192 */
293 193 private function permissions( $settings_list ) {
294 194 $permissions = array();
@@ -304,16 +204,15 @@
304 204 }
305 205
306 206 /**
307 207 * @since 3.06.04
308 - *
309 208 * @return array
310 209 */
311 210 private function forms() {
312 211 $s_query = array(
313 212 array(
314 - 'or' => 1,
315 - 'parent_form_id' => null,
213 + 'or' => 1,
214 + 'parent_form_id' => null,
316 215 'parent_form_id <' => 1,
317 216 ),
318 217 );
319 218
@@ -321,10 +220,10 @@
321 220 $forms = array();
322 221 $settings = array(
323 222 'form_class',
324 223 'akismet',
224 + 'honeypot',
325 225 'antispam',
326 - 'stopforumspam',
327 226 'custom_style',
328 227 'success_action',
329 228 'show_form',
330 229 'no_save',
@@ -353,45 +252,28 @@
353 252 'prev_value',
354 253 'submit_conditions',
355 254 );
356 255
357 - $style = new FrmStyle();
358 -
359 256 foreach ( $saved_forms as $form ) {
360 257 $new_form = array(
361 - 'form_id' => $form->id,
362 - 'description' => $form->description,
363 - 'logged_in' => $form->logged_in,
364 - 'editable' => $form->editable,
365 - 'is_template' => $form->is_template,
366 - 'entry_count' => FrmEntry::getRecordCount( $form->id ),
367 - 'field_count' => $this->form_field_count( $form->id ),
258 + 'form_id' => $form->id,
259 + 'description' => $form->description,
260 + 'logged_in' => $form->logged_in,
261 + 'editable' => $form->editable,
262 + 'is_template' => $form->is_template,
263 + 'entry_count' => FrmEntry::getRecordCount( $form->id ),
264 + 'field_count' => $this->form_field_count( $form->id ),
368 265 'form_action_count' => $this->form_action_count( $form->id ),
369 266 );
370 267
371 268 foreach ( $settings as $setting ) {
372 269 if ( isset( $form->options[ $setting ] ) ) {
373 - if ( 'custom_style' === $setting ) {
374 - $style->id = $form->options[ $setting ];
375 -
376 - if ( ! $style->id ) {
377 - $style_name = 0;
378 - } elseif ( 1 === intval( $style->id ) ) {
379 - $style_name = 'formidable-style';
380 - } else {
381 - $style_post = $style->get_one();
382 - $style_name = $style_post ? $style_post->post_name : 'formidable-style';
383 - }
384 -
385 - $new_form[ $setting ] = $style_name;
386 - } else {
387 - $new_form[ $setting ] = $this->maybe_json( $form->options[ $setting ] );
388 - }
270 + $new_form[ $setting ] = $this->maybe_json( $form->options[ $setting ] );
389 271 }
390 272 }
391 273
392 274 $forms[] = apply_filters( 'frm_usage_form', $new_form, compact( 'form' ) );
393 - }//end foreach
275 + }
394 276
395 277 // If the array uses numeric keys, reset them.
396 278 return $forms;
397 279 }
@@ -397,17 +279,14 @@
397 279 }
398 280
399 281 /**
400 282 * @since 3.06.04
401 - *
402 - * @param int|string $form_id Form ID.
403 - *
404 283 * @return int
405 284 */
406 285 private function form_field_count( $form_id ) {
407 286 global $wpdb;
408 287
409 - $join = $wpdb->prefix . 'frm_fields fi JOIN ' . $wpdb->prefix . 'frm_forms fo ON (fi.form_id=fo.id)';
288 + $join = $wpdb->prefix . 'frm_fields fi LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fo ON (fi.form_id=fo.id)';
410 289
411 290 $field_query = array(
412 291 'or' => 1,
413 292 'fi.form_id' => $form_id,
@@ -418,11 +297,8 @@
418 297 }
419 298
420 299 /**
421 300 * @since 3.06.04
422 - *
423 - * @param int|string $form_id Form ID.
424 - *
425 301 * @return int
426 302 */
427 303 private function form_action_count( $form_id ) {
428 304 $args = array(
@@ -438,30 +314,26 @@
438 314 /**
439 315 * Get the last 100 fields created.
440 316 *
441 317 * @since 3.06.04
442 - *
443 318 * @return array
444 319 */
445 320 private function fields() {
446 - $args = array(
321 + $args = array(
447 322 'limit' => 50,
448 323 'order_by' => 'id DESC',
449 324 );
450 325
451 - $fields = FrmDb::get_results( 'frm_fields', array(), 'id, form_id, name, type, field_options', $args );
452 -
326 + $fields = FrmDb::get_results( 'frm_fields', array(), 'form_id, name, type, field_options', $args );
453 327 foreach ( $fields as $k => $field ) {
454 328 FrmAppHelper::unserialize_or_decode( $field->field_options );
455 329 $fields[ $k ]->field_options = json_encode( $field->field_options );
456 330 }
457 -
458 331 return $fields;
459 332 }
460 333
461 334 /**
462 335 * @since 3.06.04
463 - *
464 336 * @return array
465 337 */
466 338 private function actions() {
467 339 $args = array(
@@ -468,11 +340,11 @@
468 340 'post_type' => FrmFormActionsController::$action_post_type,
469 341 'numberposts' => 100,
470 342 );
471 343
472 - $actions = array();
344 + $actions = array();
345 +
473 346 $saved_actions = FrmDb::check_cache( json_encode( $args ), 'frm_actions', $args, 'get_posts' );
474 -
475 347 foreach ( $saved_actions as $action ) {
476 348 $actions[] = array(
477 349 'form_id' => $action->menu_order,
478 350 'type' => $action->post_excerpt,
@@ -485,20 +357,17 @@
485 357 }
486 358
487 359 /**
488 360 * @since 3.06.04
489 - *
490 361 * @return bool
491 362 */
492 363 private function tracking_allowed() {
493 - return FrmUsageController::tracking_allowed();
364 + $settings = FrmAppHelper::get_settings();
365 + return $settings->tracking;
494 366 }
495 367
496 368 /**
497 369 * @since 3.06.04
498 - *
499 - * @param mixed $value Value.
500 - *
501 370 * @return string
502 371 */
503 372 private function maybe_json( $value ) {
504 373 return is_array( $value ) ? json_encode( $value ) : $value;
@@ -503,4 +372,5 @@
503 372 private function maybe_json( $value ) {
504 373 return is_array( $value ) ? json_encode( $value ) : $value;
505 374 }
506 375 }
376 +