| Server IP : 127.0.0.1 / Your IP : 192.168.99.1 Web Server : Apache/2.4.35 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9 System : Windows NT WIN-JEJMB9EN0L0 10.0 build 14393 (Windows Server 2016) AMD64 User : Administrator ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /bpkd_29052026/includes/ |
Upload File : |
<?php
/**
* WhatsApp Floating Button
* Muncul di pojok kanan bawah jika diaktifkan di settings
*/
// Gunakan global $settings
global $settings, $conn;
// Jika $settings belum di-load, ambil dari database
if (empty($settings)) {
$settings = [];
$result = $conn->query("SELECT * FROM settings");
if ($result) {
while($row = $result->fetch_assoc()) {
$settings[$row['setting_key']] = $row['setting_value'];
}
}
}
// Cek apakah WhatsApp aktif
$wa_active = isset($settings['whatsapp_active']) && $settings['whatsapp_active'] == '1';
// Jika tidak aktif, jangan tampilkan
if (!$wa_active) return;
$wa_number = $settings['whatsapp_number'] ?? '6281234567890';
$wa_message = urlencode($settings['whatsapp_message'] ?? 'Halo, saya ingin bertanya tentang layanan di website ini');
$wa_text = $settings['whatsapp_text'] ?? 'Chat via WhatsApp';
$wa_url = "https://wa.me/{$wa_number}?text={$wa_message}";
// Bersihkan nomor WhatsApp (hapus karakter non-digit)
$wa_number_clean = preg_replace('/[^0-9]/', '', $wa_number);
$wa_url_clean = "https://wa.me/{$wa_number_clean}?text={$wa_message}";
?>
<!-- WhatsApp Floating Button -->
<div class="whatsapp-float">
<?php if (!empty($wa_text)): ?>
<span class="whatsapp-text"><?php echo htmlspecialchars($wa_text); ?></span>
<?php endif; ?>
<a href="<?php echo $wa_url_clean; ?>" class="whatsapp-button" target="_blank" rel="noopener noreferrer"
aria-label="Chat via WhatsApp"
title="<?php echo htmlspecialchars($wa_text); ?>">
<i class="fab fa-whatsapp"></i>
</a>
</div>
<style>
/* WhatsApp Floating Button Styles */
.whatsapp-float {
position: fixed;
bottom: 30px;
right: 30px;
z-index: 999;
display: flex;
flex-direction: column;
align-items: flex-end;
}
.whatsapp-button {
display: flex;
align-items: center;
justify-content: center;
width: 60px;
height: 60px;
background: linear-gradient(135deg, #25d366 0%, #128C7E 100%);
color: white;
border-radius: 50%;
text-decoration: none;
box-shadow: 0 5px 20px rgba(37, 211, 102, 0.3);
transition: all 0.3s ease;
position: relative;
}
.whatsapp-button:hover {
transform: scale(1.1);
box-shadow: 0 10px 30px rgba(37, 211, 102, 0.5);
color: white;
}
.whatsapp-button i {
font-size: 30px;
}
.whatsapp-text {
background: white;
color: #333;
padding: 8px 15px;
border-radius: 50px;
font-size: 0.9rem;
font-weight: 500;
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
margin-bottom: 10px;
opacity: 0;
visibility: hidden;
transform: translateX(10px);
transition: all 0.3s ease;
white-space: nowrap;
border: 1px solid #eee;
}
.whatsapp-float:hover .whatsapp-text {
opacity: 1;
visibility: visible;
transform: translateX(0);
}
/* Pulse Animation */
.whatsapp-button {
animation: pulse-wa 2s infinite;
}
@keyframes pulse-wa {
0% {
box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.5);
}
70% {
box-shadow: 0 0 0 15px rgba(37, 211, 102, 0);
}
100% {
box-shadow: 0 0 0 0 rgba(37, 211, 102, 0);
}
}
/* Responsive untuk mobile */
@media (max-width: 768px) {
.whatsapp-float {
bottom: 20px;
right: 20px;
}
.whatsapp-button {
width: 50px;
height: 50px;
}
.whatsapp-button i {
font-size: 25px;
}
.whatsapp-text {
display: none; /* Sembunyikan teks di mobile */
}
}
/* Posisi berbeda jika ada back to top button */
.back-to-top.show ~ .whatsapp-float {
bottom: 100px;
}
</style>
<script>
// Tracking klik WhatsApp (opsional)
document.addEventListener('DOMContentLoaded', function() {
const waButton = document.querySelector('.whatsapp-button');
if (waButton) {
waButton.addEventListener('click', function() {
console.log('WhatsApp button clicked');
// Bisa ditambahkan Google Analytics tracking di sini
});
}
});
</script>