admin_url('admin-ajax.php'),
'nonce' => wp_create_nonce('accua_theme_helper'),
'pluginCssUrl' => plugins_url('assets/css/frontend.css', ACCUA_FORMS_FILE),
'i18n' => array(
'scanning' => __('Scanning...', 'contact-forms'),
'noConflicts' => __('No CSS conflicts detected!', 'contact-forms'),
'conflictsFound' => __('CSS conflicts found:', 'contact-forms'),
'scanComplete' => __('Scan complete', 'contact-forms'),
'scanError' => __('Error scanning URL', 'contact-forms'),
'enterUrl' => __('Enter a URL to scan', 'contact-forms'),
'fetchingCss' => __('Fetching CSS from URL...', 'contact-forms'),
),
'monitoredClasses' => accua_forms_get_monitored_css_classes(),
'criticalProperties' => array(
'padding', 'padding-top', 'padding-right', 'padding-bottom', 'padding-left',
'margin', 'margin-top', 'margin-right', 'margin-bottom', 'margin-left',
'display', 'position', 'visibility', 'overflow',
'width', 'height', 'min-width', 'min-height', 'max-width', 'max-height',
'flex', 'flex-direction', 'flex-wrap', 'align-items', 'justify-content',
'border', 'border-width', 'border-style',
'float', 'clear', 'z-index', 'opacity',
),
));
// Localize script with AJAX URL, nonce, and translations
wp_localize_script('accua-forms-settings-page', 'accuaFormsSettings', array(
'ajaxUrl' => admin_url('admin-ajax.php'),
'nonce' => wp_create_nonce('accua_forms_restore_default'),
'dangerNonce' => wp_create_nonce('accua_forms_danger_zone'),
'siteDomain' => wp_parse_url( home_url(), PHP_URL_HOST ),
'i18n' => array(
'confirmRestore' => __('Are you sure you want to restore the default value for this message? This will overwrite your current content.', 'contact-forms'),
'restoring' => __('Restoring...', 'contact-forms'),
'restored' => __('Restored!', 'contact-forms'),
'error' => __('Error restoring default', 'contact-forms'),
'restoreDefault' => __('Restore default', 'contact-forms'),
'anonymizing' => __('Anonymizing...', 'contact-forms'),
'loading' => __('Loading...', 'contact-forms'),
'deleting' => __('Deleting...', 'contact-forms'),
'noSubmissionsFound' => __('No submissions found matching the specified period.', 'contact-forms'),
/* translators: %d: total number of submissions that will be anonymized */
'previewHeading' => __('The following %d submissions will be anonymized:', 'contact-forms'),
'formColumn' => __('Form', 'contact-forms'),
'submissionsColumn' => __('Submissions', 'contact-forms'),
'totalLabel' => __('Total', 'contact-forms'),
'confirmAnonymize' => __('Confirm anonymization', 'contact-forms'),
'cancel' => __('Cancel', 'contact-forms'),
'confirmDeletePrompt' => sprintf(
/* translators: %s: site domain */
__( 'This will permanently delete ALL Contact Forms data (settings, forms, submissions, uploaded files). This cannot be undone. Type "%s" to confirm:', 'contact-forms' ),
wp_parse_url( home_url(), PHP_URL_HOST )
),
),
));
}
function accua_forms_settings_page() {
?>
'',
'error_message' => '',
'emails_from_name' => '',
'emails_from' => '',
'admin_emails_to' => '',
'emails_bcc' => '',
'admin_emails_subject' => '',
'admin_emails_message' => '',
'confirmation_emails_subject' => '',
'confirmation_emails_message' => '',
'layout' => 'sidebyside',
'style_margin' => '',
'style_border_color' => '',
'style_border_width' => '',
'style_border_radius' => '',
'style_background_color' => '',
'style_padding' => '',
'style_color' => '',
'style_font_size' => '',
'style_field_spacing' => '',
'style_field_border_color' => '',
'style_field_border_width' => '',
'style_field_border_radius' => '',
'style_field_background_color' => '',
'style_field_padding' => '',
'style_field_color' => '',
'style_submit_border_color' => '',
'style_submit_border_width' => '',
'style_submit_border_radius' => '',
'style_submit_background_color' => '',
'style_submit_padding' => '',
'style_submit_color' => '',
'style_submit_font_size' => '',
);
$empty_file_data = array(
'valid_extensions' => '',
'max_size' => '',
'dest_path' => '',
);
$empty_captcha_data = array(
'recaptcha_force_v1' => '',
'recaptcha_public_key' => '',
'recaptcha_private_key' => '',
'recaptcha_v3_public_key' => '',
'recaptcha_v3_private_key' => '',
'recaptcha_v3_score_threshold' => '',
'recaptcha_v3_badge' => '',
'captcha_spam_action' => '',
'captcha_spam_action_v2' => '',
'captcha_hide_title' => '',
'cap_instance_url' => '',
'cap_site_key' => '',
'cap_secret_key' => '',
);
$empty_analytics_data = array(
'analytics_track_submit' => false,
'analytics_track_fields' => false,
);
$empty_anonymize_ip_data = array(
'anonymize_ip_bytes' => 0,
);
$empty_retention_data = array(
'retention_value' => 0,
'retention_unit' => 'months',
'retention_mode' => 'anonymize',
);
$empty_spam_data = array(
'email_blocklist' => '',
);
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated -- REQUEST_METHOD is always set by server
if ( isset( $_SERVER['REQUEST_METHOD'] ) && 'POST' === $_SERVER['REQUEST_METHOD'] && ! empty( $_POST['accua_form_save_form_settings'] ) ) {
check_admin_referer('accua_form_save_settings', '_nonce_accua_form_save_settings');
$post = stripslashes_deep($_POST);
$post += $empty_form_data;
$post += $empty_file_data;
$post += $empty_captcha_data;
$post += $empty_analytics_data;
$post += $empty_anonymize_ip_data;
$post += $empty_retention_data;
$post += $empty_spam_data;
$form_data = array();
$file_data = array();
$captcha_data = array();
$analytics_data = array();
$anonymize_ip_data = array();
$retention_data = array();
$spam_data = array();
foreach($empty_form_data as $key=>$val){
$form_data[$key] = $post[$key];
}
$form_data = accua_forms_filter_settings($form_data);
$file_data['valid_extensions'] = accua_forms_filter_extensions($post['valid_extensions']);
$file_data['max_size'] = $post['max_size'];
if (current_user_can('edit_files') || current_user_can('install_plugins')) {
$file_data['dest_path'] = $post['dest_path'];
} else {
$old_file_data = get_option('accua_forms_default_file_field_data',array());
$file_data['dest_path'] = isset($old_file_data['dest_path']) ? $old_file_data['dest_path'] : '';
}
$captcha_data['recaptcha_force_v1'] = (bool) $post['recaptcha_force_v1'];
$captcha_data['recaptcha_public_key'] = sanitize_text_field($post['recaptcha_public_key']);
$captcha_data['recaptcha_private_key'] = sanitize_text_field($post['recaptcha_private_key']);
$captcha_data['recaptcha_v3_public_key'] = sanitize_text_field($post['recaptcha_v3_public_key']);
$captcha_data['recaptcha_v3_private_key'] = sanitize_text_field($post['recaptcha_v3_private_key']);
$captcha_data['recaptcha_v3_score_threshold'] = accua_forms_recaptcha3_clamp_score($post['recaptcha_v3_score_threshold']);
$recaptcha_v3_badge = sanitize_text_field($post['recaptcha_v3_badge']);
$captcha_data['recaptcha_v3_badge'] = isset(accua_forms_recaptcha3_badge_options()[$recaptcha_v3_badge]) ? $recaptcha_v3_badge : 'bottomright';
$captcha_spam_action = sanitize_text_field($post['captcha_spam_action']);
$captcha_data['captcha_spam_action'] = isset(accua_forms_captcha_spam_action_options()[$captcha_spam_action]) ? $captcha_spam_action : 'spam';
$captcha_spam_action_v2 = sanitize_text_field($post['captcha_spam_action_v2']);
$captcha_data['captcha_spam_action_v2'] = isset(accua_forms_captcha_spam_action_options()[$captcha_spam_action_v2]) ? $captcha_spam_action_v2 : 'reject';
$captcha_data['captcha_hide_title'] = empty($post['captcha_hide_title']) ? 0 : 1;
$captcha_data['cap_instance_url'] = esc_url_raw(trim($post['cap_instance_url']));
$captcha_data['cap_site_key'] = sanitize_text_field($post['cap_site_key']);
$captcha_data['cap_secret_key'] = sanitize_text_field($post['cap_secret_key']);
foreach($empty_analytics_data as $key=>$val){
$analytics_data[$key] = (bool) $post[$key];
}
$anonymize_ip_bytes = (int) $post['anonymize_ip_bytes'];
if ($anonymize_ip_bytes < 0) {
$anonymize_ip_bytes = 0;
} elseif ($anonymize_ip_bytes > 4) {
$anonymize_ip_bytes = 4;
}
$anonymize_ip_data['anonymize_ip_bytes'] = $anonymize_ip_bytes;
update_option('accua_forms_default_form_data', $form_data);
update_option('accua_forms_default_file_field_data', $file_data);
update_option('accua_forms_default_captcha_field_data', $captcha_data);
update_option('accua_forms_default_analytics_data', $analytics_data);
update_option('accua_forms_anonymize_ip_data', $anonymize_ip_data);
// Opt-in to data deletion on uninstall. Only administrators see the Danger
// Zone that carries the checkbox, so only they can change it; for anybody
// else the stored value is left exactly as it is instead of being read as
// an unticked box.
if ( current_user_can( 'manage_options' ) ) {
update_option( ACCUA_FORMS_UNINSTALL_OPTION, empty( $post['delete_data_on_uninstall'] ) ? 0 : 1 );
}
$retention_data['retention_value'] = max( 0, (int) $post['retention_value'] );
$retention_data['retention_unit'] = in_array( $post['retention_unit'], array( 'days', 'months', 'years' ), true ) ? $post['retention_unit'] : 'months';
$retention_data['retention_mode'] = in_array( $post['retention_mode'], array( 'anonymize', 'delete' ), true ) ? $post['retention_mode'] : 'anonymize';
update_option('accua_forms_retention_data', $retention_data);
// Kept as the text that was typed (see includes/spam-blocklist.php): the
// textarea round-trips it, comments and order included.
$spam_data['email_blocklist'] = accua_forms_filter_email_blocklist($post['email_blocklist']);
update_option('accua_forms_spam_data', $spam_data);
if (!empty($post['delete_previous_ip_values'])) {
global $wpdb;
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Admin-only IP anonymization action, no caching needed
$wpdb->query("UPDATE `{$wpdb->prefix}accua_forms_submissions` SET afs_ip = ''");
}
} else {
$form_data = get_option('accua_forms_default_form_data',array()) + $empty_form_data;
$file_data = get_option('accua_forms_default_file_field_data',array()) + $empty_file_data;
$captcha_data = get_option('accua_forms_default_captcha_field_data',array()) + $empty_captcha_data;
$analytics_data = get_option('accua_forms_default_analytics_data',array()) + $empty_analytics_data;
$anonymize_ip_data = get_option('accua_forms_anonymize_ip_data',array()) + $empty_anonymize_ip_data;
$retention_data = get_option('accua_forms_retention_data',array()) + $empty_retention_data;
$spam_data = accua_forms_spam_settings();
}
$delete_on_uninstall = accua_forms_delete_data_on_uninstall();
if ($captcha_data['recaptcha_force_v1']) {
$captcha_data = $empty_captcha_data;
}
?>
0) {
_e( 'This value is limited by server upload limits of ', 'contact-forms');
echo AccuaForm_Element_File::format_size($server_max_size).". ";
_e( 'If you need a greater limit you should ask to the server administrator.', 'contact-forms');
}
?>
:
.
*/ ?>
-