PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.0
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.0
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 -189 6.265.0 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,38 +15,28 @@
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 /**
47 38 * @since 3.06.04
48 - *
49 - * @param bool $regenerate
50 - *
51 39 * @return string
52 40 */
53 41 public function uuid( $regenerate = false ) {
54 42 $uuid_key = 'frm-usage-uuid';
@@ -65,9 +53,8 @@
65 53 }
66 54
67 55 /**
68 56 * @since 3.06.04
69 - *
70 57 * @return array
71 58 */
72 59 public function snapshot() {
73 60 global $wpdb, $wp_version;
@@ -75,127 +62,48 @@
75 62 $theme_data = wp_get_theme();
76 63 $form_counts = FrmForm::get_count();
77 64
78 65 $snap = array(
79 - 'uuid' => $this->uuid(),
80 - // 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(),
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(),
87 73
88 - 'active_license' => FrmAppHelper::pro_is_installed(),
89 - 'form_count' => $form_counts->published,
90 - 'entry_count' => FrmEntry::getRecordCount(),
91 - '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' ),
92 78
93 - 'theme_name' => is_object( $theme_data ) ? $theme_data->Name : '', // phpcs:ignore WordPress.NamingConventions
94 - 'plugins' => $this->plugins(),
95 - 'settings' => array(
79 + 'theme_name' => is_object( $theme_data ) ? $theme_data->Name : '', // phpcs:ignore WordPress.NamingConventions
80 + 'plugins' => $this->plugins(),
81 + 'settings' => array(
96 82 $this->settings(),
97 83 ),
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' ),
84 + 'forms' => $this->forms(),
85 + 'fields' => $this->fields(),
86 + 'actions' => $this->actions(),
107 87 );
108 88
109 - if ( method_exists( 'FrmProAddonsController', 'get_readable_license_type' ) ) {
110 - $snap['active_license'] = FrmProAddonsController::get_readable_license_type();
111 - }
112 -
113 89 return apply_filters( 'frm_usage_snapshot', $snap );
114 90 }
115 91
116 92 /**
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 93 * @since 3.06.04
184 - *
185 94 * @return array
186 95 */
187 96 private function plugins() {
188 - $plugin_list = FrmAppHelper::get_plugins();
97 + $plugin_list = get_plugins();
189 98
190 99 $plugins = array();
191 -
192 100 foreach ( $plugin_list as $slug => $info ) {
193 101 $plugins[] = array(
194 - 'name' => $info['Name'],
195 - 'slug' => $slug,
196 - 'version' => $info['Version'],
197 - 'active' => is_plugin_active( $slug ),
102 + 'name' => $info['Name'],
103 + 'slug' => $slug,
104 + 'version' => $info['Version'],
105 + 'active' => is_plugin_active( $slug ),
198 106 );
199 107 }
200 108
201 109 return $plugins;
@@ -204,20 +112,22 @@
204 112 /**
205 113 * Add global settings to tracking data.
206 114 *
207 115 * @since 3.06.04
208 - *
209 116 * @return array
210 117 */
211 118 private function settings() {
212 - $settings_list = FrmAppHelper::get_settings();
213 - $settings = array(
119 + $settings_list = FrmAppHelper::get_settings();
120 + $settings = array(
214 121 'messages' => $this->messages( $settings_list ),
215 122 'permissions' => $this->permissions( $settings_list ),
216 123 );
217 124 $pass_settings = array(
218 125 'load_style',
126 + 'use_html',
127 + 'old_css',
219 128 'fade_form',
129 + 'jquery_css',
220 130 're_type',
221 131 're_lang',
222 132 're_multi',
223 133 'menu',
@@ -222,20 +132,11 @@
222 132 're_multi',
223 133 'menu',
224 134 'mu_menu',
225 135 'no_ips',
226 - 'custom_header_ip',
227 - 'enable_gdpr',
228 - 'no_gdpr_cookies',
229 136 'btsp_css',
230 - 'btsp_version',
137 + 'btsp_errors',
231 138 'admin_bar',
232 - 'summary_emails',
233 - 'active_captcha',
234 - 'honeypot',
235 - 'wp_spam_check',
236 - 'denylist_check',
237 - 'email_style',
238 139 );
239 140
240 141 foreach ( $pass_settings as $setting ) {
241 142 if ( isset( $settings_list->$setting ) ) {
@@ -254,11 +155,8 @@
254 155 /**
255 156 * Include the permissions settings for each capability.
256 157 *
257 158 * @since 3.06.04
258 - *
259 - * @param FrmSettings $settings_list
260 - *
261 159 * @return array
262 160 */
263 161 private function messages( $settings_list ) {
264 162 $messages = array(
@@ -271,14 +169,11 @@
271 169 'login_msg',
272 170 'admin_permission',
273 171 );
274 172
275 - $default = $settings_list->default_options();
276 -
277 173 $message_settings = array();
278 -
279 174 foreach ( $messages as $message ) {
280 - $message_settings[ 'changed-' . $message ] = $settings_list->$message === $default[ $message ] ? 0 : 1;
175 + $message_settings[ $message ] = $settings_list->$message;
281 176 }
282 177
283 178 return $message_settings;
284 179 }
@@ -286,11 +181,8 @@
286 181 /**
287 182 * Include the permissions settings for each capability.
288 183 *
289 184 * @since 3.06.04
290 - *
291 - * @param FrmSettings $settings_list
292 - *
293 185 * @return array
294 186 */
295 187 private function permissions( $settings_list ) {
296 188 $permissions = array();
@@ -306,16 +198,15 @@
306 198 }
307 199
308 200 /**
309 201 * @since 3.06.04
310 - *
311 202 * @return array
312 203 */
313 204 private function forms() {
314 205 $s_query = array(
315 206 array(
316 - 'or' => 1,
317 - 'parent_form_id' => null,
207 + 'or' => 1,
208 + 'parent_form_id' => null,
318 209 'parent_form_id <' => 1,
319 210 ),
320 211 );
321 212
@@ -323,10 +214,10 @@
323 214 $forms = array();
324 215 $settings = array(
325 216 'form_class',
326 217 'akismet',
218 + 'honeypot',
327 219 'antispam',
328 - 'stopforumspam',
329 220 'custom_style',
330 221 'success_action',
331 222 'show_form',
332 223 'no_save',
@@ -355,45 +246,28 @@
355 246 'prev_value',
356 247 'submit_conditions',
357 248 );
358 249
359 - $style = new FrmStyle();
360 -
361 250 foreach ( $saved_forms as $form ) {
362 251 $new_form = array(
363 - 'form_id' => $form->id,
364 - 'description' => $form->description,
365 - 'logged_in' => $form->logged_in,
366 - 'editable' => $form->editable,
367 - 'is_template' => $form->is_template,
368 - 'entry_count' => FrmEntry::getRecordCount( $form->id ),
369 - '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 ),
370 259 'form_action_count' => $this->form_action_count( $form->id ),
371 260 );
372 261
373 262 foreach ( $settings as $setting ) {
374 263 if ( isset( $form->options[ $setting ] ) ) {
375 - if ( 'custom_style' === $setting ) {
376 - $style->id = $form->options[ $setting ];
377 -
378 - if ( ! $style->id ) {
379 - $style_name = 0;
380 - } elseif ( 1 === intval( $style->id ) ) {
381 - $style_name = 'formidable-style';
382 - } else {
383 - $style_post = $style->get_one();
384 - $style_name = $style_post ? $style_post->post_name : 'formidable-style';
385 - }
386 -
387 - $new_form[ $setting ] = $style_name;
388 - } else {
389 - $new_form[ $setting ] = $this->maybe_json( $form->options[ $setting ] );
390 - }
264 + $new_form[ $setting ] = $this->maybe_json( $form->options[ $setting ] );
391 265 }
392 266 }
393 267
394 268 $forms[] = apply_filters( 'frm_usage_form', $new_form, compact( 'form' ) );
395 - }//end foreach
269 + }
396 270
397 271 // If the array uses numeric keys, reset them.
398 272 return $forms;
399 273 }
@@ -399,17 +273,14 @@
399 273 }
400 274
401 275 /**
402 276 * @since 3.06.04
403 - *
404 - * @param int|string $form_id Form ID.
405 - *
406 277 * @return int
407 278 */
408 279 private function form_field_count( $form_id ) {
409 280 global $wpdb;
410 281
411 - $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)';
412 283
413 284 $field_query = array(
414 285 'or' => 1,
415 286 'fi.form_id' => $form_id,
@@ -420,11 +291,8 @@
420 291 }
421 292
422 293 /**
423 294 * @since 3.06.04
424 - *
425 - * @param int|string $form_id Form ID.
426 - *
427 295 * @return int
428 296 */
429 297 private function form_action_count( $form_id ) {
430 298 $args = array(
@@ -440,19 +308,17 @@
440 308 /**
441 309 * Get the last 100 fields created.
442 310 *
443 311 * @since 3.06.04
444 - *
445 312 * @return array
446 313 */
447 314 private function fields() {
448 - $args = array(
315 + $args = array(
449 316 'limit' => 50,
450 317 'order_by' => 'id DESC',
451 318 );
452 319
453 - $fields = FrmDb::get_results( 'frm_fields', array(), 'id, form_id, name, type, field_options', $args );
454 -
320 + $fields = FrmDb::get_results( 'frm_fields', array(), 'form_id, name, type, field_options', $args );
455 321 foreach ( $fields as $k => $field ) {
456 322 FrmAppHelper::unserialize_or_decode( $field->field_options );
457 323 $fields[ $k ]->field_options = json_encode( $field->field_options );
458 324 }
@@ -460,9 +326,8 @@
460 326 }
461 327
462 328 /**
463 329 * @since 3.06.04
464 - *
465 330 * @return array
466 331 */
467 332 private function actions() {
468 333 $args = array(
@@ -472,9 +337,8 @@
472 337
473 338 $actions = array();
474 339
475 340 $saved_actions = FrmDb::check_cache( json_encode( $args ), 'frm_actions', $args, 'get_posts' );
476 -
477 341 foreach ( $saved_actions as $action ) {
478 342 $actions[] = array(
479 343 'form_id' => $action->menu_order,
480 344 'type' => $action->post_excerpt,
@@ -487,20 +351,17 @@
487 351 }
488 352
489 353 /**
490 354 * @since 3.06.04
491 - *
492 355 * @return bool
493 356 */
494 357 private function tracking_allowed() {
495 - return FrmUsageController::tracking_allowed();
358 + $settings = FrmAppHelper::get_settings();
359 + return $settings->tracking;
496 360 }
497 361
498 362 /**
499 363 * @since 3.06.04
500 - *
501 - * @param mixed $value Value.
502 - *
503 364 * @return string
504 365 */
505 366 private function maybe_json( $value ) {
506 367 return is_array( $value ) ? json_encode( $value ) : $value;
@@ -505,4 +366,5 @@
505 366 private function maybe_json( $value ) {
506 367 return is_array( $value ) ? json_encode( $value ) : $value;
507 368 }
508 369 }
370 +