PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.4
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.4
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 +50 -159 6.255.4 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,30 +15,23 @@
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 /**
@@ -71,121 +62,48 @@
71 62 $theme_data = wp_get_theme();
72 63 $form_counts = FrmForm::get_count();
73 64
74 65 $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(),
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(),
83 73
84 - 'active_license' => FrmAppHelper::pro_is_installed(),
85 - 'form_count' => $form_counts->published,
86 - 'entry_count' => FrmEntry::getRecordCount(),
87 - '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' ),
88 78
89 - 'theme_name' => is_object( $theme_data ) ? $theme_data->Name : '', // phpcs:ignore WordPress.NamingConventions
90 - 'plugins' => $this->plugins(),
91 - 'settings' => array(
79 + 'theme_name' => is_object( $theme_data ) ? $theme_data->Name : '', // phpcs:ignore WordPress.NamingConventions
80 + 'plugins' => $this->plugins(),
81 + 'settings' => array(
92 82 $this->settings(),
93 83 ),
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' ),
84 + 'forms' => $this->forms(),
85 + 'fields' => $this->fields(),
86 + 'actions' => $this->actions(),
102 87 );
103 88
104 - if ( method_exists( 'FrmProAddonsController', 'get_readable_license_type' ) ) {
105 - $snap['active_license'] = FrmProAddonsController::get_readable_license_type();
106 - }
107 -
108 89 return apply_filters( 'frm_usage_snapshot', $snap );
109 90 }
110 91
111 92 /**
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 93 * @since 3.06.04
176 94 * @return array
177 95 */
178 96 private function plugins() {
179 - $plugin_list = FrmAppHelper::get_plugins();
97 + $plugin_list = get_plugins();
180 98
181 99 $plugins = array();
182 100 foreach ( $plugin_list as $slug => $info ) {
183 101 $plugins[] = array(
184 - 'name' => $info['Name'],
185 - 'slug' => $slug,
186 - 'version' => $info['Version'],
187 - 'active' => is_plugin_active( $slug ),
102 + 'name' => $info['Name'],
103 + 'slug' => $slug,
104 + 'version' => $info['Version'],
105 + 'active' => is_plugin_active( $slug ),
188 106 );
189 107 }
190 108
191 109 return $plugins;
@@ -197,16 +115,18 @@
197 115 * @since 3.06.04
198 116 * @return array
199 117 */
200 118 private function settings() {
201 - $settings_list = FrmAppHelper::get_settings();
202 - $settings = array(
119 + $settings_list = FrmAppHelper::get_settings();
120 + $settings = array(
203 121 'messages' => $this->messages( $settings_list ),
204 122 'permissions' => $this->permissions( $settings_list ),
205 123 );
206 124 $pass_settings = array(
207 125 'load_style',
126 + 'use_html',
208 127 'fade_form',
128 + 'jquery_css',
209 129 're_type',
210 130 're_lang',
211 131 're_multi',
212 132 'menu',
@@ -211,20 +131,11 @@
211 131 're_multi',
212 132 'menu',
213 133 'mu_menu',
214 134 'no_ips',
215 - 'custom_header_ip',
216 - 'enable_gdpr',
217 - 'no_gdpr_cookies',
218 135 'btsp_css',
219 - 'btsp_version',
136 + 'btsp_errors',
220 137 'admin_bar',
221 - 'summary_emails',
222 - 'active_captcha',
223 - 'honeypot',
224 - 'wp_spam_check',
225 - 'denylist_check',
226 - 'email_style',
227 138 );
228 139
229 140 foreach ( $pass_settings as $setting ) {
230 141 if ( isset( $settings_list->$setting ) ) {
@@ -243,10 +154,8 @@
243 154 /**
244 155 * Include the permissions settings for each capability.
245 156 *
246 157 * @since 3.06.04
247 - *
248 - * @param FrmSettings $settings_list
249 158 * @return array
250 159 */
251 160 private function messages( $settings_list ) {
252 161 $messages = array(
@@ -259,13 +168,11 @@
259 168 'login_msg',
260 169 'admin_permission',
261 170 );
262 171
263 - $default = $settings_list->default_options();
264 -
265 172 $message_settings = array();
266 173 foreach ( $messages as $message ) {
267 - $message_settings[ 'changed-' . $message ] = $settings_list->$message === $default[ $message ] ? 0 : 1;
174 + $message_settings[ $message ] = $settings_list->$message;
268 175 }
269 176
270 177 return $message_settings;
271 178 }
@@ -273,10 +180,8 @@
273 180 /**
274 181 * Include the permissions settings for each capability.
275 182 *
276 183 * @since 3.06.04
277 - *
278 - * @param FrmSettings $settings_list
279 184 * @return array
280 185 */
281 186 private function permissions( $settings_list ) {
282 187 $permissions = array();
@@ -297,10 +202,10 @@
297 202 */
298 203 private function forms() {
299 204 $s_query = array(
300 205 array(
301 - 'or' => 1,
302 - 'parent_form_id' => null,
206 + 'or' => 1,
207 + 'parent_form_id' => null,
303 208 'parent_form_id <' => 1,
304 209 ),
305 210 );
306 211
@@ -308,10 +213,10 @@
308 213 $forms = array();
309 214 $settings = array(
310 215 'form_class',
311 216 'akismet',
217 + 'honeypot',
312 218 'antispam',
313 - 'stopforumspam',
314 219 'custom_style',
315 220 'success_action',
316 221 'show_form',
317 222 'no_save',
@@ -340,44 +245,28 @@
340 245 'prev_value',
341 246 'submit_conditions',
342 247 );
343 248
344 - $style = new FrmStyle();
345 249 foreach ( $saved_forms as $form ) {
346 250 $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 ),
251 + 'form_id' => $form->id,
252 + 'description' => $form->description,
253 + 'logged_in' => $form->logged_in,
254 + 'editable' => $form->editable,
255 + 'is_template' => $form->is_template,
256 + 'entry_count' => FrmEntry::getRecordCount( $form->id ),
257 + 'field_count' => $this->form_field_count( $form->id ),
354 258 'form_action_count' => $this->form_action_count( $form->id ),
355 259 );
356 260
357 261 foreach ( $settings as $setting ) {
358 262 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 - }
263 + $new_form[ $setting ] = $this->maybe_json( $form->options[ $setting ] );
375 264 }
376 265 }
377 266
378 267 $forms[] = apply_filters( 'frm_usage_form', $new_form, compact( 'form' ) );
379 - }//end foreach
268 + }
380 269
381 270 // If the array uses numeric keys, reset them.
382 271 return $forms;
383 272 }
@@ -388,9 +277,9 @@
388 277 */
389 278 private function form_field_count( $form_id ) {
390 279 global $wpdb;
391 280
392 - $join = $wpdb->prefix . 'frm_fields fi JOIN ' . $wpdb->prefix . 'frm_forms fo ON (fi.form_id=fo.id)';
281 + $join = $wpdb->prefix . 'frm_fields fi LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fo ON (fi.form_id=fo.id)';
393 282
394 283 $field_query = array(
395 284 'or' => 1,
396 285 'fi.form_id' => $form_id,
@@ -421,14 +310,14 @@
421 310 * @since 3.06.04
422 311 * @return array
423 312 */
424 313 private function fields() {
425 - $args = array(
314 + $args = array(
426 315 'limit' => 50,
427 316 'order_by' => 'id DESC',
428 317 );
429 318
430 - $fields = FrmDb::get_results( 'frm_fields', array(), 'id, form_id, name, type, field_options', $args );
319 + $fields = FrmDb::get_results( 'frm_fields', array(), 'form_id, name, type, field_options', $args );
431 320 foreach ( $fields as $k => $field ) {
432 321 FrmAppHelper::unserialize_or_decode( $field->field_options );
433 322 $fields[ $k ]->field_options = json_encode( $field->field_options );
434 323 }
@@ -464,9 +353,10 @@
464 353 * @since 3.06.04
465 354 * @return bool
466 355 */
467 356 private function tracking_allowed() {
468 - return FrmUsageController::tracking_allowed();
357 + $settings = FrmAppHelper::get_settings();
358 + return $settings->tracking;
469 359 }
470 360
471 361 /**
472 362 * @since 3.06.04
@@ -475,4 +365,5 @@
475 365 private function maybe_json( $value ) {
476 366 return is_array( $value ) ? json_encode( $value ) : $value;
477 367 }
478 368 }
369 +