get_chatbots(); $current_review_chatbot = get_option('a1ai_review_chatbot_id', 0); $current_rating_system = get_option('a1ai_rating_system', '5-star'); $current_intro_text = get_option('a1ai_review_intro_text', 'Thank you for taking the time to review us, please let us know how your experience has been!'); // Handle review chatbot selection if (isset($_POST['action']) && $_POST['action'] === 'select_review_chatbot') { if (isset($_POST['a1ai_review_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['a1ai_review_nonce'])), 'a1ai_select_review_chatbot')) { $review_chatbot_id = isset($_POST['review_chatbot_id']) ? intval($_POST['review_chatbot_id']) : 0; $rating_system = isset($_POST['rating_system']) ? sanitize_text_field(wp_unslash($_POST['rating_system'])) : '5-star'; $intro_text = isset($_POST['intro_text']) ? sanitize_textarea_field(wp_unslash($_POST['intro_text'])) : ''; // Handle external review links $google_link = isset($_POST['google_review_link']) ? esc_url_raw(wp_unslash($_POST['google_review_link'])) : ''; $yelp_link = isset($_POST['yelp_review_link']) ? esc_url_raw(wp_unslash($_POST['yelp_review_link'])) : ''; $facebook_link = isset($_POST['facebook_review_link']) ? esc_url_raw(wp_unslash($_POST['facebook_review_link'])) : ''; $other_link = isset($_POST['other_review_link']) ? esc_url_raw(wp_unslash($_POST['other_review_link'])) : ''; $other_name = isset($_POST['other_review_name']) ? sanitize_text_field(wp_unslash($_POST['other_review_name'])) : 'Other Platform'; // Handle minimum thresholds $min_star_threshold = isset($_POST['min_star_threshold']) ? intval($_POST['min_star_threshold']) : 3; $min_scale_threshold = isset($_POST['min_scale_threshold']) ? intval($_POST['min_scale_threshold']) : 6; update_option('a1ai_review_chatbot_id', $review_chatbot_id); update_option('a1ai_rating_system', $rating_system); update_option('a1ai_review_intro_text', $intro_text); update_option('a1ai_review_google_link', $google_link); update_option('a1ai_review_yelp_link', $yelp_link); update_option('a1ai_review_facebook_link', $facebook_link); update_option('a1ai_review_other_link', $other_link); update_option('a1ai_review_other_name', $other_name); update_option('a1ai_min_star_threshold', $min_star_threshold); update_option('a1ai_min_scale_threshold', $min_scale_threshold); $current_review_chatbot = $review_chatbot_id; // Update the current variable $current_intro_text = $intro_text; // Update the current variable // Show success message echo '
'; if ($review_chatbot_id > 0) { $selected_chatbot = array_filter($chatbots, function($c) use ($review_chatbot_id) { return $c['id'] == $review_chatbot_id; }); $chatbot_name = !empty($selected_chatbot) ? reset($selected_chatbot)['name'] : 'Unknown'; $rating_display = ($rating_system === '10-scale') ? '1-10 Scale' : '5-Star'; // translators: %1$s is the chatbot name, %2$s is the rating system type echo sprintf(esc_html__('Successfully set "%1$s" as the review chatbot with %2$s rating system!', 'a1ai-chatbot'), esc_html($chatbot_name), esc_html($rating_display)); } else { echo esc_html__('Review chatbot selection cleared.', 'a1ai-chatbot'); } echo '