if (!function_exists('lcasc_ai_quick_grounded_reply')) { function lcasc_ai_quick_grounded_reply($message, $settings, $context = []) { $q = mb_strtolower(wp_strip_all_tags((string)$message), 'UTF-8'); $product_name = trim((string)($context['product_name'] ?? $context['page_title'] ?? '')); $price = trim((string)($context['product_price'] ?? '')); $regular = trim((string)($context['product_regular_price'] ?? $context['regular_price'] ?? '')); $stock = trim((string)($context['product_stock_status'] ?? '')); $is_english = preg_match('/[A-Za-z]/', $message) && !preg_match('/[\x{0980}-\x{09FF}]/u', $message); $is_price = preg_match('/(price|cost|rate|দাম|মূল্য|কত|কতো|প্রাইস|টাকা|offer|discount|অফার|ডিসকাউন্ট)/u', $q); $is_product_question = $product_name || !empty($context['product_url']) || ((!empty($context['current_page_type'])) && $context['current_page_type'] === 'product'); if ($is_price && $is_product_question) { $name = $product_name !== '' ? $product_name : ($is_english ? 'This product' : 'এই প্রোডাক্ট'); if ($price !== '') { if ($regular !== '' && $regular !== $price) { return $is_english ? "{$name} current price is {$price}. Old price was {$regular}." : "{$name} এর বর্তমান দাম {$price}। আগের দাম ছিল {$regular}।"; } return $is_english ? "{$name} price is {$price}." : "{$name} এর দাম {$price}।"; } return $is_english ? "I cannot see the exact product price right now. Please contact support for the correct price." : "এই প্রোডাক্টের সঠিক দাম এখন দেখা যাচ্ছে না। সঠিক দামের জন্য সাপোর্টে যোগাযোগ করুন।"; } $is_stock = preg_match('/(stock|available|availability|in stock|স্টক|আছে|এভেইলেবল|মজুদ)/u', $q); if ($is_stock && $is_product_question && $stock !== '') { $name = $product_name !== '' ? $product_name : ($is_english ? 'This product' : 'এই প্রোডাক্ট'); return $is_english ? "{$name} stock status: {$stock}." : "{$name} এর স্টক স্ট্যাটাস: {$stock}।"; } $is_contact = preg_match('/(contact|support|call|phone|whatsapp|messenger|telegram|যোগাযোগ|সাপোর্ট|কল|ফোন|হোয়াটসঅ্যাপ|মেসেঞ্জার|টেলিগ্রাম)/u', $q); if ($is_contact) { $parts = []; if (!empty($settings['whatsapp_enabled']) && !empty($settings['whatsapp_number'])) $parts[] = 'WhatsApp: ' . sanitize_text_field($settings['whatsapp_number']); if (!empty($settings['messenger_enabled']) && !empty($settings['messenger_url'])) $parts[] = 'Messenger'; if (!empty($settings['telegram_enabled']) && !empty($settings['telegram_username'])) $parts[] = 'Telegram: @' . ltrim(sanitize_text_field($settings['telegram_username']), '@'); if (!empty($settings['admin_email']) && is_email($settings['admin_email'])) $parts[] = 'Email: ' . sanitize_email($settings['admin_email']); if ($parts) { $joined = implode(', ', $parts); return $is_english ? "You can contact us via {$joined}." : "আপনি আমাদের সাথে যোগাযোগ করতে পারেন: {$joined}।"; } } return ''; } } if (!function_exists('lcasc_finish_sentence')) { function lcasc_finish_sentence($text, $limit) { $text = trim((string)$text); if ($text === '') return $text; $len = function_exists('mb_strlen') ? mb_strlen($text, 'UTF-8') : strlen($text); if ($len <= $limit) return $text; $cut = function_exists('mb_substr') ? mb_substr($text, 0, $limit, 'UTF-8') : substr($text, 0, $limit); $last = -1; foreach (['।', '.', '!', '?'] as $mark) { $pos = function_exists('mb_strrpos') ? mb_strrpos($cut, $mark, 0, 'UTF-8') : strrpos($cut, $mark); if ($pos !== false && $pos > $last) $last = $pos; } if ($last > 80) return trim(function_exists('mb_substr') ? mb_substr($cut, 0, $last + 1, 'UTF-8') : substr($cut, 0, $last + 1)); $cut = preg_replace('/\s+\S*$/u', '', $cut); return trim($cut) . '।'; } } https://dhaka-digital.com/wp-sitemap-posts-post-1.xmlhttps://dhaka-digital.com/wp-sitemap-posts-page-1.xmlhttps://dhaka-digital.com/wp-sitemap-posts-product-1.xmlhttps://dhaka-digital.com/wp-sitemap-posts-elementor-hf-1.xmlhttps://dhaka-digital.com/wp-sitemap-taxonomies-category-1.xmlhttps://dhaka-digital.com/wp-sitemap-taxonomies-product_cat-1.xmlhttps://dhaka-digital.com/wp-sitemap-taxonomies-product_tag-1.xmlhttps://dhaka-digital.com/wp-sitemap-users-1.xml