Candlear" page with exactly the fields used by * the Candlear dashboard snippet: API key, title, greeting, position and * privacy policy URL. Also registers the suggested privacy policy text. */ class Candlear_Widget_Settings { const PAGE_SLUG = 'candlear-booking-widget'; const OPTION_GROUP = 'candlear_widget_settings_group'; /** * Registers hooks. */ public static function init() { add_action( 'admin_menu', array( __CLASS__, 'register_menu' ) ); add_action( 'admin_init', array( __CLASS__, 'register_settings' ) ); add_action( 'admin_init', array( __CLASS__, 'register_privacy_policy_content' ) ); add_action( 'admin_notices', array( __CLASS__, 'maybe_show_privacy_notice' ) ); } /** * Adds the sub page under "Settings". */ public static function register_menu() { add_options_page( __( 'Candlear Booking Widget', 'candlear-booking-widget' ), __( 'Candlear', 'candlear-booking-widget' ), 'manage_options', self::PAGE_SLUG, array( __CLASS__, 'render_page' ) ); } /** * Registers setting, section and fields via the WordPress Settings API. */ public static function register_settings() { register_setting( self::OPTION_GROUP, CANDLEAR_WIDGET_OPTION_KEY, array( 'type' => 'array', 'sanitize_callback' => array( __CLASS__, 'sanitize_options' ), 'default' => array(), ) ); add_settings_section( 'candlear_widget_main_section', __( 'Widget settings', 'candlear-booking-widget' ), array( __CLASS__, 'render_section_intro' ), self::PAGE_SLUG ); $fields = array( 'api_key' => __( 'API key', 'candlear-booking-widget' ), 'title' => __( 'Widget title', 'candlear-booking-widget' ), 'greeting' => __( 'Greeting', 'candlear-booking-widget' ), 'position' => __( 'Position', 'candlear-booking-widget' ), 'privacy_url' => __( 'Privacy policy URL', 'candlear-booking-widget' ), ); foreach ( $fields as $field_key => $field_label ) { add_settings_field( 'candlear_widget_field_' . $field_key, $field_label, array( __CLASS__, 'render_field_' . $field_key ), self::PAGE_SLUG, 'candlear_widget_main_section' ); } } /** * Registers the suggested text shown under Settings -> Privacy -> Policy Guide, * so site owners can copy it into their privacy policy. */ public static function register_privacy_policy_content() { if ( ! function_exists( 'wp_add_privacy_policy_content' ) ) { return; } $content = '
' . esc_html__( 'Suggested text for your privacy policy. Please review it and adapt it to your website and your legal basis. This is not legal advice.', 'candlear-booking-widget' ) . '
'; $content .= '' . esc_html__( 'Suggested text:', 'candlear-booking-widget' ) . ' '; $content .= esc_html__( 'Our website uses a chatbot (Candlear) that helps you book appointments. The chatbot is provided by Synergic Systems - Jannick Mueller, Maria-Hilf-Strasse 11, 50677 Cologne, Germany, which processes the data on our behalf (data processing agreement under Art. 28 GDPR). When you use the chat, the messages you enter (for example name, contact details, desired appointment) and technical data such as your IP address are transmitted to the provider. Your messages are processed by an AI service (Google Gemini, Google LLC, USA, based on standard contractual clauses) to answer your requests, and you are chatting with an AI assistant. Chat sessions are deleted 24 hours after the last interaction; technical logs are kept for a maximum of 30 days. The legal basis is Art. 6(1)(b) GDPR (pre-contractual measures, appointment booking) or, if applicable, Art. 6(1)(f) GDPR. You have the rights of access, rectification, erasure, restriction, data portability and objection under Art. 15 to 21 GDPR and the right to lodge a complaint with a supervisory authority.', 'candlear-booking-widget' ); $content .= '
'; wp_add_privacy_policy_content( 'Candlear Booking Widget', wp_kses_post( wpautop( $content, false ) ) ); } /** * Warns on the plugin settings page when an API key is saved but no privacy * policy URL is available, because then the widget is not shown. */ public static function maybe_show_privacy_notice() { $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null; if ( ! $screen || 'settings_page_' . self::PAGE_SLUG !== $screen->id ) { return; } $options = candlear_widget_get_options(); if ( empty( $options['api_key'] ) || '' !== candlear_widget_get_privacy_url() ) { return; } echo '' . esc_html__( 'The chat widget is not shown yet: please enter your privacy policy URL below. Visitors must be informed about the chatbot before they use it.', 'candlear-booking-widget' ) . '
' . esc_html__( 'Enter the API key from your Candlear dashboard (Chat bot -> Embed widget). The widget then loads automatically in the footer of every page - no code in theme files needed. A privacy policy URL is required.', 'candlear-booking-widget' ) . '
'; } /** * Renders the complete options page. */ public static function render_page() { if ( ! current_user_can( 'manage_options' ) ) { return; } ?>Embed widget. Treat it like a password.', 'candlear-booking-widget' ); ?>
Privacy -> Policy Guide).', 'candlear-booking-widget' ); ?>