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