PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.21
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.21
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 +150 -51 6.4.26.21 View file →
@@ -17,23 +17,30 @@
17 17 if ( ! $this->tracking_allowed() ) {
18 18 return;
19 19 }
20 20
21 - $ep = 'aHR0cHM6Ly9mcm0tdXNlci10cmFja2luZy5oZXJva3VhcHAuY29tL3NuYXBzaG90';
21 + $ep = 'aHR0cHM6Ly91c2FnZTIuZm9ybWlkYWJsZWZvcm1zLmNvbS9zbmFwc2hvdA==';
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,
33 + 'body' => $body,
34 + // Without this, Debug Log catches the `http_request_failed` error.
35 + 'timeout' => 45,
34 36 );
35 37
38 + // Remove time limit to execute this function.
39 + if ( function_exists( 'set_time_limit' ) ) {
40 + set_time_limit( 0 );
41 + }
42 +
36 43 wp_remote_request( base64_decode( $ep ), $post );
37 44 }
38 45
39 46 /**
@@ -64,35 +71,108 @@
64 71 $theme_data = wp_get_theme();
65 72 $form_counts = FrmForm::get_count();
66 73
67 74 $snap = array(
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(),
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(),
75 83
76 - 'active_license' => FrmAppHelper::pro_is_installed(),
77 - 'form_count' => $form_counts->published,
78 - 'entry_count' => FrmEntry::getRecordCount(),
79 - 'timestamp' => gmdate( 'c' ),
84 + 'active_license' => FrmAppHelper::pro_is_installed(),
85 + 'form_count' => $form_counts->published,
86 + 'entry_count' => FrmEntry::getRecordCount(),
87 + 'timestamp' => gmdate( 'c' ),
80 88
81 - 'theme_name' => is_object( $theme_data ) ? $theme_data->Name : '', // phpcs:ignore WordPress.NamingConventions
82 - 'plugins' => $this->plugins(),
83 - 'settings' => array(
89 + 'theme_name' => is_object( $theme_data ) ? $theme_data->Name : '', // phpcs:ignore WordPress.NamingConventions
90 + 'plugins' => $this->plugins(),
91 + 'settings' => array(
84 92 $this->settings(),
85 93 ),
86 - 'forms' => $this->forms(),
87 - 'fields' => $this->fields(),
88 - 'actions' => $this->actions(),
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' ),
89 102 );
90 103
104 + if ( method_exists( 'FrmProAddonsController', 'get_readable_license_type' ) ) {
105 + $snap['active_license'] = FrmProAddonsController::get_readable_license_type();
106 + }
107 +
91 108 return apply_filters( 'frm_usage_snapshot', $snap );
92 109 }
93 110
94 111 /**
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 + /**
95 175 * @since 3.06.04
96 176 * @return array
97 177 */
98 178 private function plugins() {
@@ -100,12 +180,12 @@
100 180
101 181 $plugins = array();
102 182 foreach ( $plugin_list as $slug => $info ) {
103 183 $plugins[] = array(
104 - 'name' => $info['Name'],
105 - 'slug' => $slug,
106 - 'version' => $info['Version'],
107 - 'active' => is_plugin_active( $slug ),
184 + 'name' => $info['Name'],
185 + 'slug' => $slug,
186 + 'version' => $info['Version'],
187 + 'active' => is_plugin_active( $slug ),
108 188 );
109 189 }
110 190
111 191 return $plugins;
@@ -117,18 +197,16 @@
117 197 * @since 3.06.04
118 198 * @return array
119 199 */
120 200 private function settings() {
121 - $settings_list = FrmAppHelper::get_settings();
122 - $settings = array(
201 + $settings_list = FrmAppHelper::get_settings();
202 + $settings = array(
123 203 'messages' => $this->messages( $settings_list ),
124 204 'permissions' => $this->permissions( $settings_list ),
125 205 );
126 206 $pass_settings = array(
127 207 'load_style',
128 - 'use_html',
129 208 'fade_form',
130 - 'jquery_css',
131 209 're_type',
132 210 're_lang',
133 211 're_multi',
134 212 'menu',
@@ -133,11 +211,18 @@
133 211 're_multi',
134 212 'menu',
135 213 'mu_menu',
136 214 'no_ips',
215 + 'custom_header_ip',
216 + 'enable_gdpr',
217 + 'no_gdpr_cookies',
137 218 'btsp_css',
138 - 'btsp_errors',
219 + 'btsp_version',
139 220 'admin_bar',
221 + 'summary_emails',
222 + 'active_captcha',
223 + 'honeypot',
224 + 'wp_spam_check',
140 225 );
141 226
142 227 foreach ( $pass_settings as $setting ) {
143 228 if ( isset( $settings_list->$setting ) ) {
@@ -157,10 +242,8 @@
157 242 * Include the permissions settings for each capability.
158 243 *
159 244 * @since 3.06.04
160 245 *
161 - * @return array
162 - *
163 246 * @param FrmSettings $settings_list
164 247 * @return array
165 248 */
166 249 private function messages( $settings_list ) {
@@ -174,11 +257,13 @@
174 257 'login_msg',
175 258 'admin_permission',
176 259 );
177 260
261 + $default = $settings_list->default_options();
262 +
178 263 $message_settings = array();
179 264 foreach ( $messages as $message ) {
180 - $message_settings[ $message ] = $settings_list->$message;
265 + $message_settings[ 'changed-' . $message ] = $settings_list->$message === $default[ $message ] ? 0 : 1;
181 266 }
182 267
183 268 return $message_settings;
184 269 }
@@ -210,10 +295,10 @@
210 295 */
211 296 private function forms() {
212 297 $s_query = array(
213 298 array(
214 - 'or' => 1,
215 - 'parent_form_id' => null,
299 + 'or' => 1,
300 + 'parent_form_id' => null,
216 301 'parent_form_id <' => 1,
217 302 ),
218 303 );
219 304
@@ -221,10 +306,10 @@
221 306 $forms = array();
222 307 $settings = array(
223 308 'form_class',
224 309 'akismet',
225 - 'honeypot',
226 310 'antispam',
311 + 'stopforumspam',
227 312 'custom_style',
228 313 'success_action',
229 314 'show_form',
230 315 'no_save',
@@ -253,28 +338,44 @@
253 338 'prev_value',
254 339 'submit_conditions',
255 340 );
256 341
342 + $style = new FrmStyle();
257 343 foreach ( $saved_forms as $form ) {
258 344 $new_form = array(
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 ),
345 + 'form_id' => $form->id,
346 + 'description' => $form->description,
347 + 'logged_in' => $form->logged_in,
348 + 'editable' => $form->editable,
349 + 'is_template' => $form->is_template,
350 + 'entry_count' => FrmEntry::getRecordCount( $form->id ),
351 + 'field_count' => $this->form_field_count( $form->id ),
266 352 'form_action_count' => $this->form_action_count( $form->id ),
267 353 );
268 354
269 355 foreach ( $settings as $setting ) {
270 356 if ( isset( $form->options[ $setting ] ) ) {
271 - $new_form[ $setting ] = $this->maybe_json( $form->options[ $setting ] );
357 + if ( 'custom_style' === $setting ) {
358 + $style->id = $form->options[ $setting ];
359 +
360 + if ( ! $style->id ) {
361 + $style_name = 0;
362 + } elseif ( 1 === intval( $style->id ) ) {
363 + $style_name = 'formidable-style';
364 + } else {
365 + $style_post = $style->get_one();
366 + $style_name = $style_post ? $style_post->post_name : 'formidable-style';
367 + }
368 +
369 + $new_form[ $setting ] = $style_name;
370 + } else {
371 + $new_form[ $setting ] = $this->maybe_json( $form->options[ $setting ] );
372 + }
272 373 }
273 374 }
274 375
275 376 $forms[] = apply_filters( 'frm_usage_form', $new_form, compact( 'form' ) );
276 - }
377 + }//end foreach
277 378
278 379 // If the array uses numeric keys, reset them.
279 380 return $forms;
280 381 }
@@ -285,9 +386,9 @@
285 386 */
286 387 private function form_field_count( $form_id ) {
287 388 global $wpdb;
288 389
289 - $join = $wpdb->prefix . 'frm_fields fi LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fo ON (fi.form_id=fo.id)';
390 + $join = $wpdb->prefix . 'frm_fields fi JOIN ' . $wpdb->prefix . 'frm_forms fo ON (fi.form_id=fo.id)';
290 391
291 392 $field_query = array(
292 393 'or' => 1,
293 394 'fi.form_id' => $form_id,
@@ -318,14 +419,14 @@
318 419 * @since 3.06.04
319 420 * @return array
320 421 */
321 422 private function fields() {
322 - $args = array(
423 + $args = array(
323 424 'limit' => 50,
324 425 'order_by' => 'id DESC',
325 426 );
326 427
327 - $fields = FrmDb::get_results( 'frm_fields', array(), 'form_id, name, type, field_options', $args );
428 + $fields = FrmDb::get_results( 'frm_fields', array(), 'id, form_id, name, type, field_options', $args );
328 429 foreach ( $fields as $k => $field ) {
329 430 FrmAppHelper::unserialize_or_decode( $field->field_options );
330 431 $fields[ $k ]->field_options = json_encode( $field->field_options );
331 432 }
@@ -361,10 +462,9 @@
361 462 * @since 3.06.04
362 463 * @return bool
363 464 */
364 465 private function tracking_allowed() {
365 - $settings = FrmAppHelper::get_settings();
366 - return $settings->tracking;
466 + return FrmUsageController::tracking_allowed();
367 467 }
368 468
369 469 /**
370 470 * @since 3.06.04
@@ -373,5 +473,4 @@
373 473 private function maybe_json( $value ) {
374 474 return is_array( $value ) ? json_encode( $value ) : $value;
375 475 }
376 476 }
377 -