PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.16.1
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.16.1
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 +127 -42 6.36.16.1 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,29 +71,35 @@
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' => php_uname( 's' ),
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
91 104 return apply_filters( 'frm_usage_snapshot', $snap );
92 105 }
@@ -91,8 +104,67 @@
91 104 return apply_filters( 'frm_usage_snapshot', $snap );
92 105 }
93 106
94 107 /**
108 + * Gets onboarding wizard data.
109 + *
110 + * @since 6.16.1
111 + *
112 + * @return array
113 + */
114 + private function onboarding_wizard() {
115 + $data = FrmOnboardingWizardController::get_usage_data();
116 + $skipped_keys = array(
117 + 'default_email',
118 + 'is_subscribed',
119 + 'allows_tracking',
120 + 'summary_emails',
121 + 'installed_addons',
122 + );
123 +
124 + foreach ( $skipped_keys as $skipped_key ) {
125 + unset( $data[ $skipped_key ] );
126 + }
127 +
128 + return $data;
129 + }
130 +
131 + /**
132 + * Gets payments data.
133 + *
134 + * @since 6.16.1
135 + *
136 + * @param string $table Database table name.
137 + * @return array
138 + */
139 + private function payments( $table = 'frm_payments' ) {
140 + $allowed_tables = array( 'frm_payments', 'frm_subscriptions' );
141 + if ( ! in_array( $table, $allowed_tables, true ) ) {
142 + return array();
143 + }
144 +
145 + global $wpdb;
146 + $rows = $wpdb->get_results(
147 + $wpdb->prepare(
148 + 'SELECT amount, status, paysys, created_at FROM %1$s',
149 + $wpdb->prefix . $table
150 + )
151 + );
152 +
153 + $payments = array();
154 + foreach ( $rows as $row ) {
155 + $payments[] = array(
156 + 'amount' => (float) $row->amount,
157 + 'status' => $row->status,
158 + 'gateway' => $row->paysys,
159 + 'created_at' => $row->created_at,
160 + );
161 + }
162 +
163 + return $payments;
164 + }
165 +
166 + /**
95 167 * @since 3.06.04
96 168 * @return array
97 169 */
98 170 private function plugins() {
@@ -100,12 +172,12 @@
100 172
101 173 $plugins = array();
102 174 foreach ( $plugin_list as $slug => $info ) {
103 175 $plugins[] = array(
104 - 'name' => $info['Name'],
105 - 'slug' => $slug,
106 - 'version' => $info['Version'],
107 - 'active' => is_plugin_active( $slug ),
176 + 'name' => $info['Name'],
177 + 'slug' => $slug,
178 + 'version' => $info['Version'],
179 + 'active' => is_plugin_active( $slug ),
108 180 );
109 181 }
110 182
111 183 return $plugins;
@@ -117,10 +189,10 @@
117 189 * @since 3.06.04
118 190 * @return array
119 191 */
120 192 private function settings() {
121 - $settings_list = FrmAppHelper::get_settings();
122 - $settings = array(
193 + $settings_list = FrmAppHelper::get_settings();
194 + $settings = array(
123 195 'messages' => $this->messages( $settings_list ),
124 196 'permissions' => $this->permissions( $settings_list ),
125 197 );
126 198 $pass_settings = array(
@@ -157,10 +229,8 @@
157 229 * Include the permissions settings for each capability.
158 230 *
159 231 * @since 3.06.04
160 232 *
161 - * @return array
162 - *
163 233 * @param FrmSettings $settings_list
164 234 * @return array
165 235 */
166 236 private function messages( $settings_list ) {
@@ -210,10 +280,10 @@
210 280 */
211 281 private function forms() {
212 282 $s_query = array(
213 283 array(
214 - 'or' => 1,
215 - 'parent_form_id' => null,
284 + 'or' => 1,
285 + 'parent_form_id' => null,
216 286 'parent_form_id <' => 1,
217 287 ),
218 288 );
219 289
@@ -253,28 +323,44 @@
253 323 'prev_value',
254 324 'submit_conditions',
255 325 );
256 326
327 + $style = new FrmStyle();
257 328 foreach ( $saved_forms as $form ) {
258 329 $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 ),
330 + 'form_id' => $form->id,
331 + 'description' => $form->description,
332 + 'logged_in' => $form->logged_in,
333 + 'editable' => $form->editable,
334 + 'is_template' => $form->is_template,
335 + 'entry_count' => FrmEntry::getRecordCount( $form->id ),
336 + 'field_count' => $this->form_field_count( $form->id ),
266 337 'form_action_count' => $this->form_action_count( $form->id ),
267 338 );
268 339
269 340 foreach ( $settings as $setting ) {
270 341 if ( isset( $form->options[ $setting ] ) ) {
271 - $new_form[ $setting ] = $this->maybe_json( $form->options[ $setting ] );
342 + if ( 'custom_style' === $setting ) {
343 + $style->id = $form->options[ $setting ];
344 +
345 + if ( ! $style->id ) {
346 + $style_name = 0;
347 + } elseif ( 1 === intval( $style->id ) ) {
348 + $style_name = 'formidable-style';
349 + } else {
350 + $style_post = $style->get_one();
351 + $style_name = $style_post ? $style_post->post_name : 'formidable-style';
352 + }
353 +
354 + $new_form[ $setting ] = $style_name;
355 + } else {
356 + $new_form[ $setting ] = $this->maybe_json( $form->options[ $setting ] );
357 + }
272 358 }
273 359 }
274 360
275 361 $forms[] = apply_filters( 'frm_usage_form', $new_form, compact( 'form' ) );
276 - }
362 + }//end foreach
277 363
278 364 // If the array uses numeric keys, reset them.
279 365 return $forms;
280 366 }
@@ -318,9 +404,9 @@
318 404 * @since 3.06.04
319 405 * @return array
320 406 */
321 407 private function fields() {
322 - $args = array(
408 + $args = array(
323 409 'limit' => 50,
324 410 'order_by' => 'id DESC',
325 411 );
326 412
@@ -373,5 +459,4 @@
373 459 private function maybe_json( $value ) {
374 460 return is_array( $value ) ? json_encode( $value ) : $value;
375 461 }
376 462 }
377 -