| @@ -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,41 +15,28 @@ | ||
| 17 | 15 | if ( ! $this->tracking_allowed() ) { |
| 18 | 16 | return; |
| 19 | 17 | } |
| 20 | 18 | |
| 21 | - $snapshot = $this->snapshot(); | |
| 22 | - $this->clean_before_send( $snapshot ); | |
| 23 | - | |
| 24 | - $ep = 'aHR0cHM6Ly91c2FnZTIuZm9ybWlkYWJsZWZvcm1zLmNvbS9zbmFwc2hvdA=='; | |
| 19 | + $ep = 'aHR0cHM6Ly9mcm0tdXNlci10cmFja2luZy5oZXJva3VhcHAuY29tL3NuYXBzaG90'; | |
| 25 | 20 | // $ep = base64_encode( 'http://localhost:4567/snapshot' ); // Uncomment for testing |
| 26 | - $body = json_encode( $snapshot ); | |
| 21 | + $body = json_encode( $this->snapshot() ); | |
| 27 | 22 | |
| 28 | 23 | // Setup variable for wp_remote_request. |
| 29 | 24 | $post = array( |
| 30 | - 'method' => 'POST', | |
| 31 | - 'headers' => array( | |
| 25 | + 'method' => 'POST', | |
| 26 | + 'headers' => array( | |
| 32 | 27 | 'Accept' => 'application/json', |
| 33 | 28 | 'Content-Type' => 'application/json', |
| 34 | 29 | 'Content-Length' => strlen( $body ), |
| 35 | 30 | ), |
| 36 | - 'body' => $body, | |
| 37 | - // Without this, Debug Log catches the `http_request_failed` error. | |
| 38 | - 'timeout' => 45, | |
| 31 | + 'body' => $body, | |
| 39 | 32 | ); |
| 40 | 33 | |
| 41 | - // Remove time limit to execute this function. | |
| 42 | - if ( function_exists( 'set_time_limit' ) ) { | |
| 43 | - set_time_limit( 0 ); | |
| 44 | - } | |
| 45 | - | |
| 46 | 34 | wp_remote_request( base64_decode( $ep ), $post ); |
| 47 | 35 | } |
| 48 | 36 | |
| 49 | 37 | /** |
| 50 | 38 | * @since 3.06.04 |
| 51 | - * | |
| 52 | - * @param bool $regenerate | |
| 53 | - * | |
| 54 | 39 | * @return string |
| 55 | 40 | */ |
| 56 | 41 | public function uuid( $regenerate = false ) { |
| 57 | 42 | $uuid_key = 'frm-usage-uuid'; |
| @@ -56,13 +41,13 @@ | ||
| 56 | 41 | public function uuid( $regenerate = false ) { |
| 57 | 42 | $uuid_key = 'frm-usage-uuid'; |
| 58 | 43 | $uuid = get_option( $uuid_key ); |
| 59 | 44 | |
| 60 | - if ( $regenerate || ! $uuid ) { | |
| 45 | + if ( $regenerate || empty( $uuid ) ) { | |
| 61 | 46 | // Definitely not cryptographically secure but |
| 62 | - // close enough to provide a unique id | |
| 47 | + // close enough to provide an unique id | |
| 63 | 48 | $uuid = md5( uniqid() . site_url() ); |
| 64 | - update_option( $uuid_key, $uuid, false ); | |
| 49 | + update_option( $uuid_key, $uuid, 'no' ); | |
| 65 | 50 | } |
| 66 | 51 | |
| 67 | 52 | return $uuid; |
| 68 | 53 | } |
| @@ -68,9 +53,8 @@ | ||
| 68 | 53 | } |
| 69 | 54 | |
| 70 | 55 | /** |
| 71 | 56 | * @since 3.06.04 |
| 72 | - * | |
| 73 | 57 | * @return array |
| 74 | 58 | */ |
| 75 | 59 | public function snapshot() { |
| 76 | 60 | global $wpdb, $wp_version; |
| @@ -78,241 +62,48 @@ | ||
| 78 | 62 | $theme_data = wp_get_theme(); |
| 79 | 63 | $form_counts = FrmForm::get_count(); |
| 80 | 64 | |
| 81 | 65 | $snap = array( |
| 82 | - 'uuid' => $this->uuid(), | |
| 83 | - 'wp_version' => $wp_version, | |
| 84 | - 'php_version' => phpversion(), | |
| 85 | - 'mysql_version' => $wpdb->db_version(), | |
| 86 | - 'os' => FrmAppHelper::get_server_os(), | |
| 87 | - '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(), | |
| 88 | 73 | |
| 89 | - 'active_license' => FrmAppHelper::pro_is_installed(), | |
| 90 | - 'form_count' => $form_counts->published, | |
| 91 | - 'entry_count' => FrmEntry::getRecordCount(), | |
| 92 | - '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' ), | |
| 93 | 78 | |
| 94 | - 'theme_name' => is_object( $theme_data ) ? $theme_data->Name : '', // phpcs:ignore WordPress.NamingConventions | |
| 95 | - 'plugins' => $this->plugins(), | |
| 96 | - 'settings' => array( | |
| 79 | + 'theme_name' => is_object( $theme_data ) ? $theme_data->Name : '', // phpcs:ignore WordPress.NamingConventions | |
| 80 | + 'plugins' => $this->plugins(), | |
| 81 | + 'settings' => array( | |
| 97 | 82 | $this->settings(), |
| 98 | 83 | ), |
| 99 | - 'forms' => $this->forms(), | |
| 100 | - 'fields' => $this->fields(), | |
| 101 | - 'actions' => $this->actions(), | |
| 102 | - | |
| 103 | - 'onboarding-wizard' => $this->onboarding_wizard(), | |
| 104 | - 'welcome-tour' => FrmWelcomeTourController::get_usage_data(), | |
| 105 | - 'flows' => FrmUsageController::get_flows_data(), | |
| 106 | - 'payments' => $this->payments(), | |
| 107 | - 'subscriptions' => $this->payments( 'frm_subscriptions' ), | |
| 84 | + 'forms' => $this->forms(), | |
| 85 | + 'fields' => $this->fields(), | |
| 86 | + 'actions' => $this->actions(), | |
| 108 | 87 | ); |
| 109 | 88 | |
| 110 | - if ( method_exists( 'FrmProAddonsController', 'get_readable_license_type' ) ) { | |
| 111 | - $snap['active_license'] = FrmProAddonsController::get_readable_license_type(); | |
| 112 | - } | |
| 113 | - | |
| 114 | 89 | return apply_filters( 'frm_usage_snapshot', $snap ); |
| 115 | 90 | } |
| 116 | 91 | |
| 117 | 92 | /** |
| 118 | - * Cleans the snapshot data before sending. | |
| 119 | - * | |
| 120 | - * @param array $data Snapshot data. | |
| 121 | - * | |
| 122 | - * @return void | |
| 123 | - */ | |
| 124 | - private function clean_before_send( &$data ) { | |
| 125 | - $skip_keys = array( | |
| 126 | - 'plan_id', | |
| 127 | - 'paypal_item_name', | |
| 128 | - 'account_num', | |
| 129 | - 'routing_num', | |
| 130 | - 'bank_name', | |
| 131 | - 'business_email', | |
| 132 | - | |
| 133 | - // Form action settings. | |
| 134 | - 'quiz', | |
| 135 | - 'email_to', | |
| 136 | - 'cc', | |
| 137 | - 'bcc', | |
| 138 | - 'from', | |
| 139 | - 'email_subject', | |
| 140 | - 'email_msg', | |
| 141 | - 'email_message', | |
| 142 | - 'success_msg', | |
| 143 | - 'success_url', | |
| 144 | - 'success_page_id', | |
| 145 | - 'redirect_msg', | |
| 146 | - 'conditions', | |
| 147 | - 'list_id', | |
| 148 | - 'api_key', | |
| 149 | - 'url', | |
| 150 | - 'data_fields', | |
| 151 | - 'reg_email_msg', | |
| 152 | - | |
| 153 | - // Form settings. | |
| 154 | - 'form_id', | |
| 155 | - 'description', | |
| 156 | - 'submit_conditions-hide_field', | |
| 157 | - 'submit_conditions-hide_field_cond', | |
| 158 | - 'submit_conditions-hide_opt', | |
| 159 | - 'submit_conditions-show_hide', | |
| 160 | - 'submit_conditions-any_all', | |
| 161 | - | |
| 162 | - // Field settings. | |
| 163 | - 'show_hide', | |
| 164 | - 'any_all', | |
| 165 | - 'hide_field', | |
| 166 | - 'hide_field_cond', | |
| 167 | - 'hide_opt', | |
| 168 | - 'custom_html', | |
| 169 | - 'blank', | |
| 170 | - 'required_indicator', | |
| 171 | - 'invalid', | |
| 172 | - 'unique_msg', | |
| 173 | - 'edit_text', | |
| 174 | - 'start_over_label', | |
| 175 | - 'add_label', | |
| 176 | - 'remove_label', | |
| 177 | - 'draft', | |
| 178 | - ); | |
| 179 | - | |
| 180 | - /** | |
| 181 | - * Filter the keys to skip when cleaning the snapshot data before sending. | |
| 182 | - * | |
| 183 | - * @since 6.28 | |
| 184 | - * | |
| 185 | - * @param array $skip_keys Data keys. | |
| 186 | - */ | |
| 187 | - $skip_keys = apply_filters( 'frm_usage_skip_keys', $skip_keys ); | |
| 188 | - | |
| 189 | - $long_text_keys = array( 'description' ); | |
| 190 | - | |
| 191 | - /** | |
| 192 | - * Filter the keys to replace with a long text placeholder before sending. | |
| 193 | - * | |
| 194 | - * @since 6.28 | |
| 195 | - * | |
| 196 | - * @paramm array $long_text_keys Data keys. | |
| 197 | - */ | |
| 198 | - $long_text_keys = apply_filters( 'frm_usage_long_text_keys', $long_text_keys ); | |
| 199 | - | |
| 200 | - foreach ( $data as $key => &$value ) { | |
| 201 | - if ( ! $value ) { | |
| 202 | - continue; | |
| 203 | - } | |
| 204 | - | |
| 205 | - if ( in_array( $key, $skip_keys, true ) || str_ends_with( $key, '_url' ) ) { | |
| 206 | - unset( $data[ $key ] ); | |
| 207 | - continue; | |
| 208 | - } | |
| 209 | - | |
| 210 | - if ( is_object( $value ) ) { | |
| 211 | - $value = '{{object}}'; | |
| 212 | - continue; | |
| 213 | - } | |
| 214 | - | |
| 215 | - if ( is_array( $value ) ) { | |
| 216 | - $this->clean_before_send( $value ); | |
| 217 | - continue; | |
| 218 | - } | |
| 219 | - | |
| 220 | - if ( in_array( $key, $long_text_keys, true ) || str_ends_with( $key, '_msg' ) ) { | |
| 221 | - // Replace it with a placeholder. | |
| 222 | - $value = '{{long_text}}'; | |
| 223 | - continue; | |
| 224 | - } | |
| 225 | - | |
| 226 | - // If key ends with `_email`, or value contains `@`, this might contain an email address. | |
| 227 | - if ( str_ends_with( $key, '_email' ) || str_contains( $value, '@' ) ) { | |
| 228 | - // Replace it with a placeholder. | |
| 229 | - $value = '{{contain_email}}'; | |
| 230 | - } | |
| 231 | - }//end foreach | |
| 232 | - } | |
| 233 | - | |
| 234 | - /** | |
| 235 | - * Gets onboarding wizard data. | |
| 236 | - * | |
| 237 | - * @since 6.16.1 | |
| 238 | - * | |
| 239 | - * @return array | |
| 240 | - */ | |
| 241 | - private function onboarding_wizard() { | |
| 242 | - $data = FrmOnboardingWizardController::get_usage_data(); | |
| 243 | - $skipped_keys = array( | |
| 244 | - 'default_email', | |
| 245 | - 'is_subscribed', | |
| 246 | - 'allows_tracking', | |
| 247 | - 'summary_emails', | |
| 248 | - 'installed_addons', | |
| 249 | - ); | |
| 250 | - | |
| 251 | - foreach ( $skipped_keys as $skipped_key ) { | |
| 252 | - unset( $data[ $skipped_key ] ); | |
| 253 | - } | |
| 254 | - | |
| 255 | - return $data; | |
| 256 | - } | |
| 257 | - | |
| 258 | - /** | |
| 259 | - * Gets payments data. | |
| 260 | - * | |
| 261 | - * @since 6.16.1 | |
| 262 | - * | |
| 263 | - * @param string $table Database table name. | |
| 264 | - * | |
| 265 | - * @return array | |
| 266 | - */ | |
| 267 | - private function payments( $table = 'frm_payments' ) { | |
| 268 | - $allowed_tables = array( 'frm_payments', 'frm_subscriptions' ); | |
| 269 | - | |
| 270 | - if ( ! in_array( $table, $allowed_tables, true ) ) { | |
| 271 | - return array(); | |
| 272 | - } | |
| 273 | - | |
| 274 | - if ( ! FrmTransLiteAppHelper::payments_table_exists() ) { | |
| 275 | - return array(); | |
| 276 | - } | |
| 277 | - | |
| 278 | - global $wpdb; | |
| 279 | - $rows = $wpdb->get_results( | |
| 280 | - $wpdb->prepare( | |
| 281 | - 'SELECT amount, status, paysys, created_at FROM %1$s', | |
| 282 | - $wpdb->prefix . $table | |
| 283 | - ) | |
| 284 | - ); | |
| 285 | - | |
| 286 | - $payments = array(); | |
| 287 | - | |
| 288 | - foreach ( $rows as $row ) { | |
| 289 | - $payments[] = array( | |
| 290 | - 'amount' => (float) $row->amount, | |
| 291 | - 'status' => $row->status, | |
| 292 | - 'gateway' => $row->paysys, | |
| 293 | - 'created_at' => $row->created_at, | |
| 294 | - ); | |
| 295 | - } | |
| 296 | - | |
| 297 | - return $payments; | |
| 298 | - } | |
| 299 | - | |
| 300 | - /** | |
| 301 | 93 | * @since 3.06.04 |
| 302 | - * | |
| 303 | 94 | * @return array |
| 304 | 95 | */ |
| 305 | 96 | private function plugins() { |
| 306 | - $plugin_list = FrmAppHelper::get_plugins(); | |
| 307 | - $plugins = array(); | |
| 97 | + $plugin_list = get_plugins(); | |
| 308 | 98 | |
| 99 | + $plugins = array(); | |
| 309 | 100 | foreach ( $plugin_list as $slug => $info ) { |
| 310 | 101 | $plugins[] = array( |
| 311 | - 'name' => $info['Name'], | |
| 312 | - 'slug' => $slug, | |
| 313 | - 'version' => $info['Version'], | |
| 314 | - 'active' => is_plugin_active( $slug ), | |
| 102 | + 'name' => $info['Name'], | |
| 103 | + 'slug' => $slug, | |
| 104 | + 'version' => $info['Version'], | |
| 105 | + 'active' => is_plugin_active( $slug ), | |
| 315 | 106 | ); |
| 316 | 107 | } |
| 317 | 108 | |
| 318 | 109 | return $plugins; |
| @@ -321,20 +112,22 @@ | ||
| 321 | 112 | /** |
| 322 | 113 | * Add global settings to tracking data. |
| 323 | 114 | * |
| 324 | 115 | * @since 3.06.04 |
| 325 | - * | |
| 326 | 116 | * @return array |
| 327 | 117 | */ |
| 328 | 118 | private function settings() { |
| 329 | - $settings_list = FrmAppHelper::get_settings(); | |
| 330 | - $settings = array( | |
| 119 | + $settings_list = FrmAppHelper::get_settings(); | |
| 120 | + $settings = array( | |
| 331 | 121 | 'messages' => $this->messages( $settings_list ), |
| 332 | 122 | 'permissions' => $this->permissions( $settings_list ), |
| 333 | 123 | ); |
| 334 | 124 | $pass_settings = array( |
| 335 | 125 | 'load_style', |
| 126 | + 'use_html', | |
| 127 | + 'old_css', | |
| 336 | 128 | 'fade_form', |
| 129 | + 'jquery_css', | |
| 337 | 130 | 're_type', |
| 338 | 131 | 're_lang', |
| 339 | 132 | 're_multi', |
| 340 | 133 | 'menu', |
| @@ -339,20 +132,11 @@ | ||
| 339 | 132 | 're_multi', |
| 340 | 133 | 'menu', |
| 341 | 134 | 'mu_menu', |
| 342 | 135 | 'no_ips', |
| 343 | - 'custom_header_ip', | |
| 344 | - 'enable_gdpr', | |
| 345 | - 'no_gdpr_cookies', | |
| 346 | 136 | 'btsp_css', |
| 347 | - 'btsp_version', | |
| 137 | + 'btsp_errors', | |
| 348 | 138 | 'admin_bar', |
| 349 | - 'summary_emails', | |
| 350 | - 'active_captcha', | |
| 351 | - 'honeypot', | |
| 352 | - 'wp_spam_check', | |
| 353 | - 'denylist_check', | |
| 354 | - 'email_style', | |
| 355 | 139 | ); |
| 356 | 140 | |
| 357 | 141 | foreach ( $pass_settings as $setting ) { |
| 358 | 142 | if ( isset( $settings_list->$setting ) ) { |
| @@ -371,11 +155,8 @@ | ||
| 371 | 155 | /** |
| 372 | 156 | * Include the permissions settings for each capability. |
| 373 | 157 | * |
| 374 | 158 | * @since 3.06.04 |
| 375 | - * | |
| 376 | - * @param FrmSettings $settings_list | |
| 377 | - * | |
| 378 | 159 | * @return array |
| 379 | 160 | */ |
| 380 | 161 | private function messages( $settings_list ) { |
| 381 | 162 | $messages = array( |
| @@ -388,13 +169,11 @@ | ||
| 388 | 169 | 'login_msg', |
| 389 | 170 | 'admin_permission', |
| 390 | 171 | ); |
| 391 | 172 | |
| 392 | - $default = $settings_list->default_options(); | |
| 393 | 173 | $message_settings = array(); |
| 394 | - | |
| 395 | 174 | foreach ( $messages as $message ) { |
| 396 | - $message_settings[ 'changed-' . $message ] = $settings_list->$message === $default[ $message ] ? 0 : 1; | |
| 175 | + $message_settings[ $message ] = $settings_list->$message; | |
| 397 | 176 | } |
| 398 | 177 | |
| 399 | 178 | return $message_settings; |
| 400 | 179 | } |
| @@ -402,11 +181,8 @@ | ||
| 402 | 181 | /** |
| 403 | 182 | * Include the permissions settings for each capability. |
| 404 | 183 | * |
| 405 | 184 | * @since 3.06.04 |
| 406 | - * | |
| 407 | - * @param FrmSettings $settings_list | |
| 408 | - * | |
| 409 | 185 | * @return array |
| 410 | 186 | */ |
| 411 | 187 | private function permissions( $settings_list ) { |
| 412 | 188 | $permissions = array(); |
| @@ -422,16 +198,15 @@ | ||
| 422 | 198 | } |
| 423 | 199 | |
| 424 | 200 | /** |
| 425 | 201 | * @since 3.06.04 |
| 426 | - * | |
| 427 | 202 | * @return array |
| 428 | 203 | */ |
| 429 | 204 | private function forms() { |
| 430 | 205 | $s_query = array( |
| 431 | 206 | array( |
| 432 | - 'or' => 1, | |
| 433 | - 'parent_form_id' => null, | |
| 207 | + 'or' => 1, | |
| 208 | + 'parent_form_id' => null, | |
| 434 | 209 | 'parent_form_id <' => 1, |
| 435 | 210 | ), |
| 436 | 211 | ); |
| 437 | 212 | |
| @@ -439,10 +214,10 @@ | ||
| 439 | 214 | $forms = array(); |
| 440 | 215 | $settings = array( |
| 441 | 216 | 'form_class', |
| 442 | 217 | 'akismet', |
| 218 | + 'honeypot', | |
| 443 | 219 | 'antispam', |
| 444 | - 'stopforumspam', | |
| 445 | 220 | 'custom_style', |
| 446 | 221 | 'success_action', |
| 447 | 222 | 'show_form', |
| 448 | 223 | 'no_save', |
| @@ -471,48 +246,28 @@ | ||
| 471 | 246 | 'prev_value', |
| 472 | 247 | 'submit_conditions', |
| 473 | 248 | ); |
| 474 | 249 | |
| 475 | - $style = new FrmStyle(); | |
| 476 | - | |
| 477 | 250 | foreach ( $saved_forms as $form ) { |
| 478 | 251 | $new_form = array( |
| 479 | - 'form_id' => $form->id, | |
| 480 | - 'description' => $form->description, | |
| 481 | - 'logged_in' => $form->logged_in, | |
| 482 | - 'editable' => $form->editable, | |
| 483 | - 'is_template' => $form->is_template, | |
| 484 | - 'entry_count' => FrmEntry::getRecordCount( $form->id ), | |
| 485 | - 'field_count' => $this->form_field_count( $form->id ), | |
| 252 | + 'form_id' => $form->id, | |
| 253 | + 'description' => $form->description, | |
| 254 | + 'logged_in' => $form->logged_in, | |
| 255 | + 'editable' => $form->editable, | |
| 256 | + 'is_template' => $form->is_template, | |
| 257 | + 'entry_count' => FrmEntry::getRecordCount( $form->id ), | |
| 258 | + 'field_count' => $this->form_field_count( $form->id ), | |
| 486 | 259 | 'form_action_count' => $this->form_action_count( $form->id ), |
| 487 | 260 | ); |
| 488 | 261 | |
| 489 | 262 | foreach ( $settings as $setting ) { |
| 490 | - if ( ! isset( $form->options[ $setting ] ) ) { | |
| 491 | - continue; | |
| 492 | - } | |
| 493 | - | |
| 494 | - if ( 'custom_style' !== $setting ) { | |
| 263 | + if ( isset( $form->options[ $setting ] ) ) { | |
| 495 | 264 | $new_form[ $setting ] = $this->maybe_json( $form->options[ $setting ] ); |
| 496 | - continue; | |
| 497 | 265 | } |
| 266 | + } | |
| 498 | 267 | |
| 499 | - $style->id = $form->options[ $setting ]; | |
| 500 | - | |
| 501 | - if ( ! $style->id ) { | |
| 502 | - $style_name = 0; | |
| 503 | - } elseif ( 1 === intval( $style->id ) ) { | |
| 504 | - $style_name = 'formidable-style'; | |
| 505 | - } else { | |
| 506 | - $style_post = $style->get_one(); | |
| 507 | - $style_name = $style_post ? $style_post->post_name : 'formidable-style'; | |
| 508 | - } | |
| 509 | - | |
| 510 | - $new_form[ $setting ] = $style_name; | |
| 511 | - }//end foreach | |
| 512 | - | |
| 513 | 268 | $forms[] = apply_filters( 'frm_usage_form', $new_form, compact( 'form' ) ); |
| 514 | - }//end foreach | |
| 269 | + } | |
| 515 | 270 | |
| 516 | 271 | // If the array uses numeric keys, reset them. |
| 517 | 272 | return $forms; |
| 518 | 273 | } |
| @@ -518,17 +273,14 @@ | ||
| 518 | 273 | } |
| 519 | 274 | |
| 520 | 275 | /** |
| 521 | 276 | * @since 3.06.04 |
| 522 | - * | |
| 523 | - * @param int|string $form_id Form ID. | |
| 524 | - * | |
| 525 | 277 | * @return int |
| 526 | 278 | */ |
| 527 | 279 | private function form_field_count( $form_id ) { |
| 528 | 280 | global $wpdb; |
| 529 | 281 | |
| 530 | - $join = $wpdb->prefix . 'frm_fields fi JOIN ' . $wpdb->prefix . 'frm_forms fo ON (fi.form_id=fo.id)'; | |
| 282 | + $join = $wpdb->prefix . 'frm_fields fi LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fo ON (fi.form_id=fo.id)'; | |
| 531 | 283 | |
| 532 | 284 | $field_query = array( |
| 533 | 285 | 'or' => 1, |
| 534 | 286 | 'fi.form_id' => $form_id, |
| @@ -539,11 +291,8 @@ | ||
| 539 | 291 | } |
| 540 | 292 | |
| 541 | 293 | /** |
| 542 | 294 | * @since 3.06.04 |
| 543 | - * | |
| 544 | - * @param int|string $form_id Form ID. | |
| 545 | - * | |
| 546 | 295 | * @return int |
| 547 | 296 | */ |
| 548 | 297 | private function form_action_count( $form_id ) { |
| 549 | 298 | $args = array( |
| @@ -559,30 +308,26 @@ | ||
| 559 | 308 | /** |
| 560 | 309 | * Get the last 100 fields created. |
| 561 | 310 | * |
| 562 | 311 | * @since 3.06.04 |
| 563 | - * | |
| 564 | 312 | * @return array |
| 565 | 313 | */ |
| 566 | 314 | private function fields() { |
| 567 | - $args = array( | |
| 315 | + $args = array( | |
| 568 | 316 | 'limit' => 50, |
| 569 | 317 | 'order_by' => 'id DESC', |
| 570 | 318 | ); |
| 571 | 319 | |
| 572 | - $fields = FrmDb::get_results( 'frm_fields', array(), 'id, form_id, name, type, field_options', $args ); | |
| 573 | - | |
| 320 | + $fields = FrmDb::get_results( 'frm_fields', array(), 'form_id, name, type, field_options', $args ); | |
| 574 | 321 | foreach ( $fields as $k => $field ) { |
| 575 | 322 | FrmAppHelper::unserialize_or_decode( $field->field_options ); |
| 576 | - $fields[ $k ]->field_options = $field->field_options; | |
| 323 | + $fields[ $k ]->field_options = json_encode( $field->field_options ); | |
| 577 | 324 | } |
| 578 | - | |
| 579 | 325 | return $fields; |
| 580 | 326 | } |
| 581 | 327 | |
| 582 | 328 | /** |
| 583 | 329 | * @since 3.06.04 |
| 584 | - * | |
| 585 | 330 | * @return array |
| 586 | 331 | */ |
| 587 | 332 | private function actions() { |
| 588 | 333 | $args = array( |
| @@ -589,17 +334,17 @@ | ||
| 589 | 334 | 'post_type' => FrmFormActionsController::$action_post_type, |
| 590 | 335 | 'numberposts' => 100, |
| 591 | 336 | ); |
| 592 | 337 | |
| 593 | - $actions = array(); | |
| 338 | + $actions = array(); | |
| 339 | + | |
| 594 | 340 | $saved_actions = FrmDb::check_cache( json_encode( $args ), 'frm_actions', $args, 'get_posts' ); |
| 595 | - | |
| 596 | 341 | foreach ( $saved_actions as $action ) { |
| 597 | 342 | $actions[] = array( |
| 598 | 343 | 'form_id' => $action->menu_order, |
| 599 | 344 | 'type' => $action->post_excerpt, |
| 600 | 345 | 'status' => $action->post_status, |
| 601 | - 'settings' => FrmAppHelper::maybe_json_decode( $action->post_content ), | |
| 346 | + 'settings' => $action->post_content, | |
| 602 | 347 | ); |
| 603 | 348 | } |
| 604 | 349 | |
| 605 | 350 | return $actions; |
| @@ -606,20 +351,17 @@ | ||
| 606 | 351 | } |
| 607 | 352 | |
| 608 | 353 | /** |
| 609 | 354 | * @since 3.06.04 |
| 610 | - * | |
| 611 | 355 | * @return bool |
| 612 | 356 | */ |
| 613 | 357 | private function tracking_allowed() { |
| 614 | - return FrmUsageController::tracking_allowed(); | |
| 358 | + $settings = FrmAppHelper::get_settings(); | |
| 359 | + return $settings->tracking; | |
| 615 | 360 | } |
| 616 | 361 | |
| 617 | 362 | /** |
| 618 | 363 | * @since 3.06.04 |
| 619 | - * | |
| 620 | - * @param mixed $value Value. | |
| 621 | - * | |
| 622 | 364 | * @return string |
| 623 | 365 | */ |
| 624 | 366 | private function maybe_json( $value ) { |
| 625 | 367 | return is_array( $value ) ? json_encode( $value ) : $value; |
| @@ -624,4 +366,5 @@ | ||
| 624 | 366 | private function maybe_json( $value ) { |
| 625 | 367 | return is_array( $value ) ? json_encode( $value ) : $value; |
| 626 | 368 | } |
| 627 | 369 | } |
| 370 | + | |