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 +49 -181 6.266.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';
@@ -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,37 @@
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();
@@ -187,15 +99,14 @@
187 99 private function plugins() {
188 100 $plugin_list = FrmAppHelper::get_plugins();
189 101
190 102 $plugins = array();
191 -
192 103 foreach ( $plugin_list as $slug => $info ) {
193 104 $plugins[] = array(
194 - 'name' => $info['Name'],
195 - 'slug' => $slug,
196 - 'version' => $info['Version'],
197 - 'active' => is_plugin_active( $slug ),
105 + 'name' => $info['Name'],
106 + 'slug' => $slug,
107 + 'version' => $info['Version'],
108 + 'active' => is_plugin_active( $slug ),
198 109 );
199 110 }
200 111
201 112 return $plugins;
@@ -204,20 +115,21 @@
204 115 /**
205 116 * Add global settings to tracking data.
206 117 *
207 118 * @since 3.06.04
208 - *
209 119 * @return array
210 120 */
211 121 private function settings() {
212 - $settings_list = FrmAppHelper::get_settings();
213 - $settings = array(
122 + $settings_list = FrmAppHelper::get_settings();
123 + $settings = array(
214 124 'messages' => $this->messages( $settings_list ),
215 125 'permissions' => $this->permissions( $settings_list ),
216 126 );
217 127 $pass_settings = array(
218 128 'load_style',
129 + 'use_html',
219 130 'fade_form',
131 + 'jquery_css',
220 132 're_type',
221 133 're_lang',
222 134 're_multi',
223 135 'menu',
@@ -222,20 +134,11 @@
222 134 're_multi',
223 135 'menu',
224 136 'mu_menu',
225 137 'no_ips',
226 - 'custom_header_ip',
227 - 'enable_gdpr',
228 - 'no_gdpr_cookies',
229 138 'btsp_css',
230 - 'btsp_version',
139 + 'btsp_errors',
231 140 'admin_bar',
232 - 'summary_emails',
233 - 'active_captcha',
234 - 'honeypot',
235 - 'wp_spam_check',
236 - 'denylist_check',
237 - 'email_style',
238 141 );
239 142
240 143 foreach ( $pass_settings as $setting ) {
241 144 if ( isset( $settings_list->$setting ) ) {
@@ -256,9 +159,8 @@
256 159 *
257 160 * @since 3.06.04
258 161 *
259 162 * @param FrmSettings $settings_list
260 - *
261 163 * @return array
262 164 */
263 165 private function messages( $settings_list ) {
264 166 $messages = array(
@@ -271,14 +173,11 @@
271 173 'login_msg',
272 174 'admin_permission',
273 175 );
274 176
275 - $default = $settings_list->default_options();
276 -
277 177 $message_settings = array();
278 -
279 178 foreach ( $messages as $message ) {
280 - $message_settings[ 'changed-' . $message ] = $settings_list->$message === $default[ $message ] ? 0 : 1;
179 + $message_settings[ $message ] = $settings_list->$message;
281 180 }
282 181
283 182 return $message_settings;
284 183 }
@@ -288,9 +187,8 @@
288 187 *
289 188 * @since 3.06.04
290 189 *
291 190 * @param FrmSettings $settings_list
292 - *
293 191 * @return array
294 192 */
295 193 private function permissions( $settings_list ) {
296 194 $permissions = array();
@@ -306,16 +204,15 @@
306 204 }
307 205
308 206 /**
309 207 * @since 3.06.04
310 - *
311 208 * @return array
312 209 */
313 210 private function forms() {
314 211 $s_query = array(
315 212 array(
316 - 'or' => 1,
317 - 'parent_form_id' => null,
213 + 'or' => 1,
214 + 'parent_form_id' => null,
318 215 'parent_form_id <' => 1,
319 216 ),
320 217 );
321 218
@@ -323,10 +220,10 @@
323 220 $forms = array();
324 221 $settings = array(
325 222 'form_class',
326 223 'akismet',
224 + 'honeypot',
327 225 'antispam',
328 - 'stopforumspam',
329 226 'custom_style',
330 227 'success_action',
331 228 'show_form',
332 229 'no_save',
@@ -355,45 +252,28 @@
355 252 'prev_value',
356 253 'submit_conditions',
357 254 );
358 255
359 - $style = new FrmStyle();
360 -
361 256 foreach ( $saved_forms as $form ) {
362 257 $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 ),
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 ),
370 265 'form_action_count' => $this->form_action_count( $form->id ),
371 266 );
372 267
373 268 foreach ( $settings as $setting ) {
374 269 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 - }
270 + $new_form[ $setting ] = $this->maybe_json( $form->options[ $setting ] );
391 271 }
392 272 }
393 273
394 274 $forms[] = apply_filters( 'frm_usage_form', $new_form, compact( 'form' ) );
395 - }//end foreach
275 + }
396 276
397 277 // If the array uses numeric keys, reset them.
398 278 return $forms;
399 279 }
@@ -399,17 +279,14 @@
399 279 }
400 280
401 281 /**
402 282 * @since 3.06.04
403 - *
404 - * @param int|string $form_id Form ID.
405 - *
406 283 * @return int
407 284 */
408 285 private function form_field_count( $form_id ) {
409 286 global $wpdb;
410 287
411 - $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)';
412 289
413 290 $field_query = array(
414 291 'or' => 1,
415 292 'fi.form_id' => $form_id,
@@ -420,11 +297,8 @@
420 297 }
421 298
422 299 /**
423 300 * @since 3.06.04
424 - *
425 - * @param int|string $form_id Form ID.
426 - *
427 301 * @return int
428 302 */
429 303 private function form_action_count( $form_id ) {
430 304 $args = array(
@@ -440,19 +314,17 @@
440 314 /**
441 315 * Get the last 100 fields created.
442 316 *
443 317 * @since 3.06.04
444 - *
445 318 * @return array
446 319 */
447 320 private function fields() {
448 - $args = array(
321 + $args = array(
449 322 'limit' => 50,
450 323 'order_by' => 'id DESC',
451 324 );
452 325
453 - $fields = FrmDb::get_results( 'frm_fields', array(), 'id, form_id, name, type, field_options', $args );
454 -
326 + $fields = FrmDb::get_results( 'frm_fields', array(), 'form_id, name, type, field_options', $args );
455 327 foreach ( $fields as $k => $field ) {
456 328 FrmAppHelper::unserialize_or_decode( $field->field_options );
457 329 $fields[ $k ]->field_options = json_encode( $field->field_options );
458 330 }
@@ -460,9 +332,8 @@
460 332 }
461 333
462 334 /**
463 335 * @since 3.06.04
464 - *
465 336 * @return array
466 337 */
467 338 private function actions() {
468 339 $args = array(
@@ -472,9 +343,8 @@
472 343
473 344 $actions = array();
474 345
475 346 $saved_actions = FrmDb::check_cache( json_encode( $args ), 'frm_actions', $args, 'get_posts' );
476 -
477 347 foreach ( $saved_actions as $action ) {
478 348 $actions[] = array(
479 349 'form_id' => $action->menu_order,
480 350 'type' => $action->post_excerpt,
@@ -487,20 +357,17 @@
487 357 }
488 358
489 359 /**
490 360 * @since 3.06.04
491 - *
492 361 * @return bool
493 362 */
494 363 private function tracking_allowed() {
495 - return FrmUsageController::tracking_allowed();
364 + $settings = FrmAppHelper::get_settings();
365 + return $settings->tracking;
496 366 }
497 367
498 368 /**
499 369 * @since 3.06.04
500 - *
501 - * @param mixed $value Value.
502 - *
503 370 * @return string
504 371 */
505 372 private function maybe_json( $value ) {
506 373 return is_array( $value ) ? json_encode( $value ) : $value;
@@ -505,4 +372,5 @@
505 372 private function maybe_json( $value ) {
506 373 return is_array( $value ) ? json_encode( $value ) : $value;
507 374 }
508 375 }
376 +