| @@ -7,8 +7,9 @@ | ||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | namespace SRFM\Inc\Global_Settings; |
| 10 | 10 | |
| 11 | +use SRFM\Inc\Client_Logger; | |
| 11 | 12 | use SRFM\Inc\Events_Scheduler; |
| 12 | 13 | use SRFM\Inc\Helper; |
| 13 | 14 | use SRFM\Inc\Payments\Payment_Helper; |
| 14 | 15 | use SRFM\Inc\Traits\Get_Instance; |
| @@ -147,17 +148,23 @@ | ||
| 147 | 148 | * @since 0.0.1 |
| 148 | 149 | */ |
| 149 | 150 | public static function srfm_save_general_settings( $setting_options ) { |
| 150 | 151 | |
| 151 | - $srfm_ip_log = $setting_options['srfm_ip_log'] ?? false; | |
| 152 | - $srfm_form_analytics = $setting_options['srfm_form_analytics'] ?? false; | |
| 153 | - $srfm_bsf_analytics = $setting_options['srfm_bsf_analytics'] ?? false; | |
| 154 | - $srfm_admin_notification = isset( $setting_options['srfm_admin_notification'] ) ? (bool) $setting_options['srfm_admin_notification'] : true; | |
| 152 | + $srfm_ip_log = $setting_options['srfm_ip_log'] ?? false; | |
| 153 | + $srfm_form_analytics = $setting_options['srfm_form_analytics'] ?? false; | |
| 154 | + $srfm_bsf_analytics = $setting_options['srfm_bsf_analytics'] ?? false; | |
| 155 | + $srfm_admin_notification = isset( $setting_options['srfm_admin_notification'] ) ? (bool) $setting_options['srfm_admin_notification'] : true; | |
| 156 | + $srfm_form_views_tracking = isset( $setting_options['srfm_form_views_tracking'] ) ? (bool) $setting_options['srfm_form_views_tracking'] : false; | |
| 157 | + // Absent means on, matching Client_Logger::is_enabled(). A save that omits | |
| 158 | + // the key must not be read as the site opting out. | |
| 159 | + $srfm_enable_logs = isset( $setting_options['srfm_enable_logs'] ) ? (bool) $setting_options['srfm_enable_logs'] : true; | |
| 155 | 160 | |
| 156 | 161 | $settings = [ |
| 157 | - 'srfm_ip_log' => $srfm_ip_log, | |
| 158 | - 'srfm_form_analytics' => $srfm_form_analytics, | |
| 159 | - 'srfm_admin_notification' => $srfm_admin_notification, | |
| 162 | + 'srfm_ip_log' => $srfm_ip_log, | |
| 163 | + 'srfm_form_analytics' => $srfm_form_analytics, | |
| 164 | + 'srfm_admin_notification' => $srfm_admin_notification, | |
| 165 | + 'srfm_form_views_tracking' => $srfm_form_views_tracking, | |
| 166 | + 'srfm_enable_logs' => $srfm_enable_logs, | |
| 160 | 167 | ]; |
| 161 | 168 | |
| 162 | 169 | /** |
| 163 | 170 | * We are updating sureforms_analytics_optin option from the general settings as it has been introduced |
| @@ -224,8 +231,10 @@ | ||
| 224 | 231 | 'srfm_valid_url', |
| 225 | 232 | 'srfm_confirm_email_same', |
| 226 | 233 | 'srfm_valid_email', |
| 227 | 234 | 'srfm_textarea_min_chars', |
| 235 | + 'srfm_email_local_max_length', | |
| 236 | + 'srfm_email_domain_max_length', | |
| 228 | 237 | 'srfm_input_min_value', |
| 229 | 238 | 'srfm_input_max_value', |
| 230 | 239 | 'srfm_dropdown_min_selections', |
| 231 | 240 | 'srfm_dropdown_max_selections', |
| @@ -657,11 +666,13 @@ | ||
| 657 | 666 | } |
| 658 | 667 | |
| 659 | 668 | if ( empty( $global_setting_options['srfm_general_settings_options'] ) || ! is_array( $global_setting_options['srfm_general_settings_options'] ) ) { |
| 660 | 669 | $global_setting_options['srfm_general_settings_options'] = [ |
| 661 | - 'srfm_ip_log' => false, | |
| 662 | - 'srfm_form_analytics' => false, | |
| 663 | - 'srfm_admin_notification' => true, | |
| 670 | + 'srfm_ip_log' => false, | |
| 671 | + 'srfm_form_analytics' => false, | |
| 672 | + 'srfm_admin_notification' => true, | |
| 673 | + 'srfm_form_views_tracking' => false, | |
| 674 | + 'srfm_enable_logs' => true, | |
| 664 | 675 | ]; |
| 665 | 676 | } |
| 666 | 677 | |
| 667 | 678 | if ( ! isset( $global_setting_options['srfm_general_settings_options']['srfm_admin_notification'] ) ) { |
| @@ -666,8 +677,20 @@ | ||
| 666 | 677 | |
| 667 | 678 | if ( ! isset( $global_setting_options['srfm_general_settings_options']['srfm_admin_notification'] ) ) { |
| 668 | 679 | $global_setting_options['srfm_general_settings_options']['srfm_admin_notification'] = true; |
| 669 | 680 | } |
| 681 | + | |
| 682 | + if ( ! isset( $global_setting_options['srfm_general_settings_options']['srfm_form_views_tracking'] ) ) { | |
| 683 | + $global_setting_options['srfm_general_settings_options']['srfm_form_views_tracking'] = false; | |
| 684 | + } | |
| 685 | + | |
| 686 | + // Back-fill for installs whose option predates the setting. Logging is on by | |
| 687 | + // default, so an absent key means on, not off. | |
| 688 | + if ( ! isset( $global_setting_options['srfm_general_settings_options']['srfm_enable_logs'] ) ) { | |
| 689 | + $global_setting_options['srfm_general_settings_options']['srfm_enable_logs'] = true; | |
| 690 | + } | |
| 691 | + | |
| 692 | + $global_setting_options['srfm_log_file_size'] = Client_Logger::get_file_size(); | |
| 670 | 693 | |
| 671 | 694 | /** |
| 672 | 695 | * We have introduced toggle for analytics optin in the general settings. |
| 673 | 696 | * Hence retrieving the option sureforms_analytics_optin to get current status. |