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