/* ========================================================== ✅ FORCE SHOW Contact Bar on Product Page (Call + WhatsApp) Guaranteed output even if theme ignores WooCommerce hooks Phone: +974 66513777 ========================================================== */ add_action('wp_footer', 'wostin_force_contact_bar_footer', 9999); function wostin_force_contact_bar_footer() { // حاولنا نحدد "صفحة المنتج" بأكثر من طريقة: // 1) WooCommerce product page // 2) أي صفحة URL فيها /product/ أو /products/ // 3) أي صفحة فيها add-to-cart في الرابط (شائع بصفحات المنتجات) $is_product = false; if (function_exists('is_product') && is_product()) { $is_product = true; } $req = isset($_SERVER['REQUEST_URI']) ? strtolower($_SERVER['REQUEST_URI']) : ''; if (strpos($req, '/product/') !== false || strpos($req, '/products/') !== false) { $is_product = true; } if (isset($_GET['add-to-cart'])) { $is_product = true; } if (!$is_product) return; // رقمك $phone_display = '+974 66513777'; $phone_tel = '+97466513777'; $whatsapp = '97466513777'; // لغة الصفحة (WPML/Polylang/RTL fallback) $lang = 'en'; if (defined('ICL_LANGUAGE_CODE') && ICL_LANGUAGE_CODE) { $lang = ICL_LANGUAGE_CODE; } elseif (function_exists('pll_current_language')) { $lang = pll_current_language('slug'); } elseif (is_rtl()) { $lang = 'ar'; } $is_ar = (strpos($lang, 'ar') !== false); $call = $is_ar ? '📞 اتصال' : '📞 Call'; $wa = $is_ar ? '💬 واتساب' : '💬 WhatsApp'; // رسالة واتساب (لو ما في عنوان/رابط، بنبعتها عامة) $title = function_exists('get_the_title') ? get_the_title() : ''; $url = function_exists('get_permalink') ? get_permalink() : ''; $msg = $is_ar ? "مرحبا، عندي استفسار: {$title} - {$url}" : "Hi, I have a question: {$title} - {$url}"; $wa_url = 'https://wa.me/' . $whatsapp . '?text=' . rawurlencode($msg); // HTML echo '
' . esc_html($call) . ' ' . esc_html($wa) . ' ' . esc_html($phone_display) . '
'; } /* CSS للبار (ينحقن تلقائياً) */ add_action('wp_head', 'wostin_contact_bar_css', 9999); function wostin_contact_bar_css() { echo ' '; }