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