__( 'General', 'fillnova' ), 'ai' => __( 'AI', 'fillnova' ), 'spam' => __( 'Security & Protection', 'fillnova' ), 'validation' => __( 'Validation', 'fillnova' ), 'login' => __( 'Login/Registration', 'fillnova' ), 'mcp' => __( 'MCP (AI assistants)', 'fillnova' ), ) ); } /** * Field descriptors per tab. * * @return array */ public static function fields() { $fields = array( 'general' => array( array( 'key' => 'admin_email', 'type' => 'email', 'label' => __( 'Default notification email', 'fillnova' ), 'help' => __( 'Used when a form has no recipient set.', 'fillnova' ) ), array( 'key' => 'from_name', 'type' => 'text', 'label' => __( 'Email “From” name', 'fillnova' ) ), array( 'key' => 'from_email', 'type' => 'email', 'label' => __( 'Email “From” address', 'fillnova' ), 'help' => __( 'Use an address on your own domain to avoid spam folders. Leave empty to use the WordPress default.', 'fillnova' ) ), array( 'key' => 'load_css', 'type' => 'select', 'label' => __( 'Form styling', 'fillnova' ), 'options' => array( 'yes' => __( 'Use Fillnova styles', 'fillnova' ), 'no' => __( 'Disable (theme styles only)', 'fillnova' ) ) ), array( 'key' => 'disable_ip', 'type' => 'toggle', 'label' => __( 'Don’t save IP addresses', 'fillnova' ), 'help' => __( 'Entries are stored without the visitor’s IP address (more privacy-friendly). Spam rate limiting still works.', 'fillnova' ) ), array( 'key' => 'delete_data', 'type' => 'toggle', 'label' => __( 'Delete all data on uninstall', 'fillnova' ), 'help' => __( 'Removes forms, entries and settings when the plugin is deleted.', 'fillnova' ) ), ), 'ai' => array( array( 'key' => 'ai_provider', 'type' => 'select', 'label' => __( 'AI', 'fillnova' ), 'options' => array( 'offline' => __( 'Built-in generator only – no external service (default)', 'fillnova' ), 'auto' => __( 'Fillnova AI – connects to fillnova.com (opt-in)', 'fillnova' ) ), 'help' => __( 'The built-in generator runs on your server and sends nothing externally. Choosing "Fillnova AI" opts in to the generation service at fillnova.com: only when you click Generate, your form description, site address, plugin version and locale are sent to fillnova.com. Your visitors\' form entries never leave your site. See the External services notice in the readme.', 'fillnova' ) ), ), 'spam' => array( array( 'key' => 'honeypot_enabled', 'type' => 'toggle', 'default' => 1, 'label' => __( 'Enable honeypot protection', 'fillnova' ), 'help' => __( 'A hidden field that people never see but bots fill in. Catches most spam without bothering visitors.', 'fillnova' ) ), array( 'key' => 'time_trap', 'type' => 'toggle', 'default' => 1, 'label' => __( 'Block too-fast submissions', 'fillnova' ), 'help' => __( 'Rejects forms sent less than 2 seconds after the page loaded – real people are never that fast.', 'fillnova' ) ), array( 'key' => 'rate_limit', 'type' => 'number', 'default' => 10, 'label' => __( 'Max submissions per visitor per hour', 'fillnova' ), 'help' => __( 'Per form and IP address. 0 = no limit.', 'fillnova' ) ), array( 'key' => 'show_branding', 'type' => 'toggle', 'default' => 0, 'label' => __( 'Show a “Powered by Fillnova” link on your forms', 'fillnova' ), 'help' => __( 'Off by default. Turn this on if you’d like to display a small “Powered by Fillnova” link under your forms and help support the plugin.', 'fillnova' ) ), array( 'type' => 'heading', 'label' => __( 'CAPTCHA services', 'fillnova' ), 'help' => __( 'Add keys for any service you want to use, then pick it per form in the builder (Settings → Spam protection).', 'fillnova' ) ), array( 'type' => 'heading', 'label' => 'Google reCAPTCHA v2', 'help' => __( 'Google reCAPTCHA is a free service that protects your site from spam and abuse. Get keys at google.com/recaptcha/admin (choose “Checkbox”).', 'fillnova' ) ), array( 'key' => 'recaptcha_site_key', 'type' => 'text', 'label' => __( 'Site key', 'fillnova' ) ), array( 'key' => 'recaptcha_secret_key', 'type' => 'password', 'label' => __( 'Secret key', 'fillnova' ) ), array( 'type' => 'heading', 'label' => 'hCaptcha', 'help' => __( 'Privacy-focused CAPTCHA. Get keys at dashboard.hcaptcha.com.', 'fillnova' ), 'link' => 'https://dashboard.hcaptcha.com/' ), array( 'key' => 'hcaptcha_site_key', 'type' => 'text', 'label' => __( 'Site key', 'fillnova' ) ), array( 'key' => 'hcaptcha_secret_key', 'type' => 'password', 'label' => __( 'Secret key', 'fillnova' ) ), array( 'type' => 'heading', 'label' => 'Cloudflare Turnstile', 'help' => __( 'Free and usually invisible to visitors. Get keys in your Cloudflare dashboard → Turnstile.', 'fillnova' ) ), array( 'key' => 'turnstile_site_key', 'type' => 'text', 'label' => __( 'Site key', 'fillnova' ) ), array( 'key' => 'turnstile_secret_key', 'type' => 'password', 'label' => __( 'Secret key', 'fillnova' ) ), ), ); $fields['validation'] = array( array( 'type' => 'heading', 'label' => __( 'Validation messages', 'fillnova' ), 'help' => __( 'Change the error messages visitors see. Leave a box empty to use the default (shown in grey). Placeholders: {label} = field name, {limit} = the limit you set.', 'fillnova' ) ), ); foreach ( fillnova_message_defaults() as $k => $m ) { $fields['validation'][] = array( 'key' => 'msg_' . $k, 'type' => 'text', 'label' => $m[0], 'placeholder' => $m[1] ); } $pages = array( '' => __( '— Choose a page —', 'fillnova' ) ); foreach ( get_pages( array( 'post_status' => 'publish' ) ) as $pg ) { $pages[ (string) $pg->ID ] = $pg->post_title; } $fields['login'] = array( array( 'type' => 'heading', 'label' => __( 'Custom login & sign-up pages', 'fillnova' ), 'help' => __( 'Put the [fillnova_login] or [fillnova_register] shortcode (or the blocks) on a page, choose it here, and WordPress links point to your page instead of wp-login.php.', 'fillnova' ) ), array( 'key' => 'login_enabled', 'type' => 'toggle', 'label' => __( 'Enable custom login page', 'fillnova' ), 'help' => __( 'Assign your login page for a branded log-in experience.', 'fillnova' ) ), array( 'key' => 'login_page', 'type' => 'select', 'label' => __( 'Login page', 'fillnova' ), 'options' => $pages ), array( 'key' => 'login_redirect', 'type' => 'url', 'label' => __( 'After login go to', 'fillnova' ), 'placeholder' => home_url( '/' ), 'help' => __( 'Leave empty to send people back to the page they came from.', 'fillnova' ) ), array( 'key' => 'register_enabled', 'type' => 'toggle', 'label' => __( 'Enable custom registration page', 'fillnova' ), 'help' => __( 'Assign your sign-up page. Registration must also be allowed in Settings → General → “Anyone can register”.', 'fillnova' ) ), array( 'key' => 'register_page', 'type' => 'select', 'label' => __( 'Registration page', 'fillnova' ), 'options' => $pages ), array( 'key' => 'register_redirect', 'type' => 'url', 'label' => __( 'After sign-up go to', 'fillnova' ), 'placeholder' => home_url( '/' ) ), ); $fields['mcp'] = array( array( 'key' => 'mcp_enabled', 'type' => 'toggle', 'label' => __( 'Allow AI assistants', 'fillnova' ), 'help' => __( 'Lets AI clients (Claude, ChatGPT, Cursor, VS Code…) work with your forms through the WordPress Abilities API, signed in as a WordPress user.', 'fillnova' ) ), array( 'key' => 'mcp_entries', 'type' => 'toggle', 'label' => __( 'Allow reading entries', 'fillnova' ), 'help' => __( 'Off = assistants can see forms and counts, but never the answers people submitted.', 'fillnova' ) ), array( 'key' => 'mcp_write', 'type' => 'toggle', 'label' => __( 'Allow creating and editing forms', 'fillnova' ), 'help' => __( 'New forms are always created as drafts.', 'fillnova' ) ), array( 'key' => 'mcp_delete', 'type' => 'toggle', 'label' => __( 'Allow deleting', 'fillnova' ), 'help' => __( 'Off by default. Deleting cannot be undone.', 'fillnova' ) ), ); return apply_filters( 'fillnova_settings_fields', $fields ); } /** * Pro sections shown (as information only) when Pro is not active. * * @return array */ public static function pro_tabs() { return array( 'messengers' => array( 'label' => __( 'Telegram & WhatsApp', 'fillnova' ), 'title' => __( 'Get every entry on your phone', 'fillnova' ), 'text' => __( 'A customer books or sends a message – WhatsApp or Telegram pings you a second later with all the details.', 'fillnova' ), 'items' => array( __( 'Telegram bot set up in two minutes', 'fillnova' ), __( 'WhatsApp with CallMeBot, the Meta Cloud API or Twilio', 'fillnova' ), __( 'Booking date, time and status in the first line', 'fillnova' ), __( 'Your own message with smart tags, on or off per form', 'fillnova' ) ), ), 'bookings' => array( 'label' => __( 'Bookings', 'fillnova' ), 'title' => __( 'A real booking system in your forms', 'fillnova' ), 'text' => __( 'For clinics, salons, restaurants, rentals and any business that takes appointments.', 'fillnova' ), 'items' => array( __( 'Live calendar with only free dates and times', 'fillnova' ), __( 'Approve or decline with one click', 'fillnova' ), __( 'Customer emails with a link to view or cancel', 'fillnova' ), __( 'Calendar sync with Airbnb, Booking.com & Google', 'fillnova' ), __( '19 ready booking and price card designs', 'fillnova' ) ), ), 'payments' => array( 'label' => __( 'Payments', 'fillnova' ), 'title' => __( 'Take payments in your forms', 'fillnova' ), 'text' => __( 'Sell services, take deposits and collect donations without a shop plugin.', 'fillnova' ), 'items' => array( __( 'Stripe card payments and PayPal checkout', 'fillnova' ), __( 'Fixed, user-defined or calculated amounts', 'fillnova' ), __( 'Amounts verified on your server', 'fillnova' ), __( 'Payment status in every entry', 'fillnova' ) ), ), 'integrations' => array( 'label' => __( 'Integrations', 'fillnova' ), 'title' => __( 'Send entries to your tools', 'fillnova' ), 'text' => __( 'Connect forms to the apps you already use.', 'fillnova' ), 'items' => array( __( 'Webhooks and Zapier', 'fillnova' ), __( 'Google Sheets sync', 'fillnova' ), __( 'Mailchimp audiences', 'fillnova' ), __( 'Create WordPress posts from entries', 'fillnova' ) ), ), 'sms' => array( 'label' => __( 'SMS Gateway', 'fillnova' ), 'title' => __( 'Get a text message for every new entry', 'fillnova' ), 'text' => __( 'Upgrade to unlock SMS Gateway settings and many other powerful features.', 'fillnova' ), 'items' => array( __( 'SMS alerts through Twilio', 'fillnova' ), __( 'Any local SMS provider with an HTTP API', 'fillnova' ), __( 'Your own message with smart tags', 'fillnova' ), __( 'Turn alerts on or off per form', 'fillnova' ) ), ), 'analytics' => array( 'label' => __( 'Analytics', 'fillnova' ), 'title' => __( 'See what your forms do', 'fillnova' ), 'text' => __( 'Find out where visitors drop off and which forms convert.', 'fillnova' ), 'items' => array( __( 'Views, starts, completions and conversion rate', 'fillnova' ), __( 'Save & resume incomplete entries', 'fillnova' ), __( 'Answer charts and NPS reports', 'fillnova' ), __( 'Unlimited AI forms and “Refine with AI”', 'fillnova' ) ), ), ); } /** * Render page. */ public static function page() { $tabs = self::tabs(); $promos = fillnova_is_pro() ? array() : self::pro_tabs(); $tab = isset( $_GET['tab'] ) ? sanitize_key( $_GET['tab'] ) : 'general'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( ! isset( $tabs[ $tab ] ) && ! isset( $promos[ $tab ] ) ) { $tab = 'general'; } $icons = array( 'general' => 'admin-generic', 'ai' => 'superhero-alt', 'spam' => 'shield-alt', 'payments' => 'money-alt', 'integrations' => 'admin-plugins', 'license' => 'admin-network', 'sms' => 'smartphone', 'validation' => 'yes-alt', 'login' => 'admin-users', 'mcp' => 'rest-api', 'analytics' => 'chart-area', 'messengers' => 'format-chat', 'bookings' => 'calendar-alt', ); $fields = self::fields(); $settings = get_option( 'fillnova_settings', array() ); ?>

= 0 ) { echo esc_html( '' === $st['resets'] /* translators: 1: remaining, 2: limit */ ? sprintf( __( 'Using Fillnova AI: %1$d of %2$d free AI forms left. Pro gives you 5 AI forms every day.', 'fillnova' ), $st['remaining'], $st['limit'] ) /* translators: 1: remaining, 2: limit */ : sprintf( __( 'Using Fillnova AI: %1$d of %2$d AI forms left this month. Pro gives you 5 AI forms every day.', 'fillnova' ), $st['remaining'], $st['limit'] ) ); } else { /* translators: 1: AI source, 2: forms generated */ echo esc_html( sprintf( __( 'Using %1$s. AI forms generated this month: %2$d.', 'fillnova' ), $st['label'], Fillnova_AI::usage() ) ); } ?>

' . esc_html( $f['label'] ) . '

' . ( ! empty( $f['help'] ) ? '

' . esc_html( $f['help'] ) . ( ! empty( $f['link'] ) ? ' ' . esc_html__( 'Get keys', 'fillnova' ) . ' ↗' : '' ) . '

' : '' ) . ''; return; } if ( 'html' === $f['type'] ) { echo '
' . wp_kses_post( $f['html'] ) . '
'; return; } $key = $f['key']; $val = isset( $settings[ $key ] ) ? $settings[ $key ] : ( isset( $f['default'] ) ? $f['default'] : '' ); $id = 'fy-set-' . $key; $name = 'settings[' . $key . ']'; $ph = isset( $f['placeholder'] ) ? ' placeholder="' . esc_attr( $f['placeholder'] ) . '"' : ''; echo '
'; switch ( $f['type'] ) { case 'select': echo ''; break; case 'toggle': echo ''; break; case 'textarea': echo ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped break; case 'password': $saved = '' !== (string) $val; echo ''; if ( $saved ) { echo ''; } break; default: echo ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } if ( ! empty( $f['help'] ) ) { echo '

' . esc_html( $f['help'] ) . '

'; } echo '
'; } /** * Save. */ public static function save() { if ( ! current_user_can( Fillnova_Admin::cap() ) || ! check_admin_referer( 'fillnova_settings' ) ) { wp_die( esc_html__( 'Not allowed.', 'fillnova' ) ); } $tab = isset( $_POST['tab'] ) ? sanitize_key( $_POST['tab'] ) : 'general'; $fields = self::fields(); $settings = get_option( 'fillnova_settings', array() ); $input = isset( $_POST['settings'] ) ? map_deep( wp_unslash( (array) $_POST['settings'] ), 'sanitize_textarea_field' ) : array(); $clear = isset( $_POST['clear'] ) ? array_map( 'sanitize_key', array_keys( map_deep( wp_unslash( (array) $_POST['clear'] ), 'sanitize_text_field' ) ) ) : array(); $secrets = apply_filters( 'fillnova_secret_settings', self::$secrets ); foreach ( isset( $fields[ $tab ] ) ? $fields[ $tab ] : array() as $f ) { if ( empty( $f['key'] ) ) { continue; } $k = $f['key']; $raw = isset( $input[ $k ] ) ? $input[ $k ] : ''; if ( 'password' === $f['type'] || in_array( $k, $secrets, true ) ) { if ( in_array( $k, $clear, true ) ) { $settings[ $k ] = ''; } elseif ( '' !== trim( (string) $raw ) ) { $settings[ $k ] = sanitize_text_field( $raw ); } continue; } switch ( $f['type'] ) { case 'email': $settings[ $k ] = sanitize_email( $raw ); break; case 'url': $settings[ $k ] = esc_url_raw( $raw ); break; case 'toggle': $settings[ $k ] = ! empty( $raw ) ? 1 : 0; break; case 'textarea': $settings[ $k ] = sanitize_textarea_field( $raw ); break; case 'select': $settings[ $k ] = array_key_exists( $raw, $f['options'] ) ? $raw : ''; break; default: $settings[ $k ] = sanitize_text_field( $raw ); } } $settings = apply_filters( 'fillnova_save_settings', $settings, $tab, $input ); update_option( 'fillnova_settings', $settings ); do_action( 'fillnova_settings_saved', $tab, $settings ); wp_safe_redirect( admin_url( 'admin.php?page=fillnova-settings&tab=' . $tab . '&fy_msg=saved' ) ); exit; } /** * AJAX: test AI connection. */ public static function ai_test() { check_ajax_referer( 'fillnova_ai_test' ); if ( ! current_user_can( Fillnova_Admin::cap() ) ) { wp_send_json_error( array( 'message' => __( 'Not allowed.', 'fillnova' ) ) ); } $source = Fillnova_AI::source(); if ( 'offline' === $source ) { wp_send_json_error( array( 'message' => __( 'AI is switched off. Choose Automatic or Fillnova AI above, or add an API key.', 'fillnova' ) ) ); } if ( 'cloud' === $source ) { $st = Fillnova_AI::status( true ); if ( null === $st['limit'] ) { wp_send_json_error( array( 'message' => __( 'Fillnova AI could not be reached. Check that your server can connect to fillnova.com.', 'fillnova' ) ) ); } $msg = $st['remaining'] < 0 ? __( 'Connected to Fillnova AI – 5 AI forms every day with Pro.', 'fillnova' ) /* translators: 1: remaining, 2: limit */ : sprintf( '' === $st['resets'] ? __( 'Connected to Fillnova AI – %1$d of %2$d free AI forms left.', 'fillnova' ) : __( 'Connected to Fillnova AI – %1$d of %2$d AI forms left this month.', 'fillnova' ), $st['remaining'], $st['limit'] ); wp_send_json_success( array( 'message' => $msg ) ); } $res = Fillnova_AI::request( 'Reply with the JSON {"ok":true} and nothing else.', 'ping' ); if ( is_wp_error( $res ) ) { wp_send_json_error( array( 'message' => $res->get_error_message() ) ); } wp_send_json_success( array( 'message' => __( 'Connected! AI is ready.', 'fillnova' ) ) ); } }