PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.7.2
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.7.2
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 -152 6.25.1 → 6.7.2 View file →
@@ -17,30 +17,23 @@
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 /**
@@ -71,109 +64,36 @@
71 64 $theme_data = wp_get_theme();
72 65 $form_counts = FrmForm::get_count();
73 66
74 67 $snap = array(
75 - 'uuid' => $this->uuid(),
68 + 'uuid' => $this->uuid(),
76 69 // 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(),
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(),
83 76
84 - 'active_license' => FrmAppHelper::pro_is_installed(),
85 - 'form_count' => $form_counts->published,
86 - 'entry_count' => FrmEntry::getRecordCount(),
87 - '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' ),
88 81
89 - 'theme_name' => is_object( $theme_data ) ? $theme_data->Name : '', // phpcs:ignore WordPress.NamingConventions
90 - 'plugins' => $this->plugins(),
91 - 'settings' => array(
82 + 'theme_name' => is_object( $theme_data ) ? $theme_data->Name : '', // phpcs:ignore WordPress.NamingConventions
83 + 'plugins' => $this->plugins(),
84 + 'settings' => array(
92 85 $this->settings(),
93 86 ),
94 - 'forms' => $this->forms(),
95 - 'fields' => $this->fields(),
96 - 'actions' => $this->actions(),
97 -
98 - 'onboarding-wizard' => $this->onboarding_wizard(),
99 - 'welcome-tour' => FrmWelcomeTourController::get_usage_data(),
100 - 'flows' => FrmUsageController::get_flows_data(),
101 - 'payments' => $this->payments(),
102 - 'subscriptions' => $this->payments( 'frm_subscriptions' ),
87 + 'forms' => $this->forms(),
88 + 'fields' => $this->fields(),
89 + 'actions' => $this->actions(),
103 90 );
104 91
105 - if ( method_exists( 'FrmProAddonsController', 'get_readable_license_type' ) ) {
106 - $snap['active_license'] = FrmProAddonsController::get_readable_license_type();
107 - }
108 -
109 92 return apply_filters( 'frm_usage_snapshot', $snap );
110 93 }
111 94
112 95 /**
113 - * Gets onboarding wizard data.
114 - *
115 - * @since 6.16.1
116 - *
117 - * @return array
118 - */
119 - private function onboarding_wizard() {
120 - $data = FrmOnboardingWizardController::get_usage_data();
121 - $skipped_keys = array(
122 - 'default_email',
123 - 'is_subscribed',
124 - 'allows_tracking',
125 - 'summary_emails',
126 - 'installed_addons',
127 - );
128 -
129 - foreach ( $skipped_keys as $skipped_key ) {
130 - unset( $data[ $skipped_key ] );
131 - }
132 -
133 - return $data;
134 - }
135 -
136 - /**
137 - * Gets payments data.
138 - *
139 - * @since 6.16.1
140 - *
141 - * @param string $table Database table name.
142 - * @return array
143 - */
144 - private function payments( $table = 'frm_payments' ) {
145 - $allowed_tables = array( 'frm_payments', 'frm_subscriptions' );
146 - if ( ! in_array( $table, $allowed_tables, true ) ) {
147 - return array();
148 - }
149 -
150 - if ( ! FrmTransLiteAppHelper::payments_table_exists() ) {
151 - return array();
152 - }
153 -
154 - global $wpdb;
155 - $rows = $wpdb->get_results(
156 - $wpdb->prepare(
157 - 'SELECT amount, status, paysys, created_at FROM %1$s',
158 - $wpdb->prefix . $table
159 - )
160 - );
161 -
162 - $payments = array();
163 - foreach ( $rows as $row ) {
164 - $payments[] = array(
165 - 'amount' => (float) $row->amount,
166 - 'status' => $row->status,
167 - 'gateway' => $row->paysys,
168 - 'created_at' => $row->created_at,
169 - );
170 - }
171 -
172 - return $payments;
173 - }
174 -
175 - /**
176 96 * @since 3.06.04
177 97 * @return array
178 98 */
179 99 private function plugins() {
@@ -181,12 +101,12 @@
181 101
182 102 $plugins = array();
183 103 foreach ( $plugin_list as $slug => $info ) {
184 104 $plugins[] = array(
185 - 'name' => $info['Name'],
186 - 'slug' => $slug,
187 - 'version' => $info['Version'],
188 - 'active' => is_plugin_active( $slug ),
105 + 'name' => $info['Name'],
106 + 'slug' => $slug,
107 + 'version' => $info['Version'],
108 + 'active' => is_plugin_active( $slug ),
189 109 );
190 110 }
191 111
192 112 return $plugins;
@@ -198,16 +118,18 @@
198 118 * @since 3.06.04
199 119 * @return array
200 120 */
201 121 private function settings() {
202 - $settings_list = FrmAppHelper::get_settings();
203 - $settings = array(
122 + $settings_list = FrmAppHelper::get_settings();
123 + $settings = array(
204 124 'messages' => $this->messages( $settings_list ),
205 125 'permissions' => $this->permissions( $settings_list ),
206 126 );
207 127 $pass_settings = array(
208 128 'load_style',
129 + 'use_html',
209 130 'fade_form',
131 + 'jquery_css',
210 132 're_type',
211 133 're_lang',
212 134 're_multi',
213 135 'menu',
@@ -212,20 +134,11 @@
212 134 're_multi',
213 135 'menu',
214 136 'mu_menu',
215 137 'no_ips',
216 - 'custom_header_ip',
217 - 'enable_gdpr',
218 - 'no_gdpr_cookies',
219 138 'btsp_css',
220 - 'btsp_version',
139 + 'btsp_errors',
221 140 'admin_bar',
222 - 'summary_emails',
223 - 'active_captcha',
224 - 'honeypot',
225 - 'wp_spam_check',
226 - 'denylist_check',
227 - 'email_style',
228 141 );
229 142
230 143 foreach ( $pass_settings as $setting ) {
231 144 if ( isset( $settings_list->$setting ) ) {
@@ -260,13 +173,11 @@
260 173 'login_msg',
261 174 'admin_permission',
262 175 );
263 176
264 - $default = $settings_list->default_options();
265 -
266 177 $message_settings = array();
267 178 foreach ( $messages as $message ) {
268 - $message_settings[ 'changed-' . $message ] = $settings_list->$message === $default[ $message ] ? 0 : 1;
179 + $message_settings[ $message ] = $settings_list->$message;
269 180 }
270 181
271 182 return $message_settings;
272 183 }
@@ -298,10 +209,10 @@
298 209 */
299 210 private function forms() {
300 211 $s_query = array(
301 212 array(
302 - 'or' => 1,
303 - 'parent_form_id' => null,
213 + 'or' => 1,
214 + 'parent_form_id' => null,
304 215 'parent_form_id <' => 1,
305 216 ),
306 217 );
307 218
@@ -309,10 +220,10 @@
309 220 $forms = array();
310 221 $settings = array(
311 222 'form_class',
312 223 'akismet',
224 + 'honeypot',
313 225 'antispam',
314 - 'stopforumspam',
315 226 'custom_style',
316 227 'success_action',
317 228 'show_form',
318 229 'no_save',
@@ -341,44 +252,28 @@
341 252 'prev_value',
342 253 'submit_conditions',
343 254 );
344 255
345 - $style = new FrmStyle();
346 256 foreach ( $saved_forms as $form ) {
347 257 $new_form = array(
348 - 'form_id' => $form->id,
349 - 'description' => $form->description,
350 - 'logged_in' => $form->logged_in,
351 - 'editable' => $form->editable,
352 - 'is_template' => $form->is_template,
353 - 'entry_count' => FrmEntry::getRecordCount( $form->id ),
354 - '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 ),
355 265 'form_action_count' => $this->form_action_count( $form->id ),
356 266 );
357 267
358 268 foreach ( $settings as $setting ) {
359 269 if ( isset( $form->options[ $setting ] ) ) {
360 - if ( 'custom_style' === $setting ) {
361 - $style->id = $form->options[ $setting ];
362 -
363 - if ( ! $style->id ) {
364 - $style_name = 0;
365 - } elseif ( 1 === intval( $style->id ) ) {
366 - $style_name = 'formidable-style';
367 - } else {
368 - $style_post = $style->get_one();
369 - $style_name = $style_post ? $style_post->post_name : 'formidable-style';
370 - }
371 -
372 - $new_form[ $setting ] = $style_name;
373 - } else {
374 - $new_form[ $setting ] = $this->maybe_json( $form->options[ $setting ] );
375 - }
270 + $new_form[ $setting ] = $this->maybe_json( $form->options[ $setting ] );
376 271 }
377 272 }
378 273
379 274 $forms[] = apply_filters( 'frm_usage_form', $new_form, compact( 'form' ) );
380 - }//end foreach
275 + }
381 276
382 277 // If the array uses numeric keys, reset them.
383 278 return $forms;
384 279 }
@@ -389,9 +284,9 @@
389 284 */
390 285 private function form_field_count( $form_id ) {
391 286 global $wpdb;
392 287
393 - $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)';
394 289
395 290 $field_query = array(
396 291 'or' => 1,
397 292 'fi.form_id' => $form_id,
@@ -422,14 +317,14 @@
422 317 * @since 3.06.04
423 318 * @return array
424 319 */
425 320 private function fields() {
426 - $args = array(
321 + $args = array(
427 322 'limit' => 50,
428 323 'order_by' => 'id DESC',
429 324 );
430 325
431 - $fields = FrmDb::get_results( 'frm_fields', array(), 'id, form_id, name, type, field_options', $args );
326 + $fields = FrmDb::get_results( 'frm_fields', array(), 'form_id, name, type, field_options', $args );
432 327 foreach ( $fields as $k => $field ) {
433 328 FrmAppHelper::unserialize_or_decode( $field->field_options );
434 329 $fields[ $k ]->field_options = json_encode( $field->field_options );
435 330 }
@@ -465,9 +360,10 @@
465 360 * @since 3.06.04
466 361 * @return bool
467 362 */
468 363 private function tracking_allowed() {
469 - return FrmUsageController::tracking_allowed();
364 + $settings = FrmAppHelper::get_settings();
365 + return $settings->tracking;
470 366 }
471 367
472 368 /**
473 369 * @since 3.06.04
@@ -476,4 +372,5 @@
476 372 private function maybe_json( $value ) {
477 373 return is_array( $value ) ? json_encode( $value ) : $value;
478 374 }
479 375 }
376 +