/**
* Snippet Name: WhatsApp Floating Button
* Snippet Author: coding-bunny.com
* Description: Adds a simple WhatsApp floating button in your website.
*/
function cbwfb_button() {
$position = 'right';
$bg_color = '#25D366';
$svg_color = '#ffffff';
$size = '50px';
$shape = 'circle';
$phone = '391234567890';
$message = 'Hi! I would like to get some information.';
$link_url = 'https://wa.me/' . $phone . '?text=' . urlencode($message);
$border_radius = ($shape === 'circle') ? '50%' : '8px';
$svg_icon = '<svg width="32" height="32" viewBox="0 0 32 32" fill="white" xmlns="http://www.w3.org/2000/svg">
<circle cx="16" cy="16" r="16" fill="none"/>
<path d="M16 3C9.372 3 4 8.372 4 15c0 2.428.8 4.745 2.294 6.705L4 29l7.465-2.255C13.203 27.58 14.582 28 16 28c6.628 0 12-5.372 12-12S22.628 3 16 3zm7.313 17.313c-.312.875-1.563 1.688-2.125 1.75-.563.063-1.25.125-2.25-.25-.5-.188-1.125-.375-1.938-.75-3.375-1.438-5.563-4.938-5.75-5.188-.188-.25-1.375-1.813-1.375-3.438 0-1.625.813-2.375 1.125-2.625.312-.25.687-.312.938-.312.25 0 .438.001.625.012.188.012.469-.075.75.563.281.638.938 2.188 1.019 2.344.081.156.131.344.025.562-.106.219-.157.344-.312.531-.156.187-.331.413-.469.563-.156.169-.319.356-.131.7.188.344.844 1.394 1.813 2.262 1.25 1.094 2.294 1.438 2.638 1.594.344.156.544.131.744-.075.2-.206.875-1.019 1.106-1.375.231-.356.463-.294.75-.175.287.119 1.813.856 2.131 1.019.319.163.531.244.606.381.075.137.075.8-.237 1.675z" fill="white"/>
</svg>';
echo "
<style>
.cbwfb-svg {
position: fixed;
bottom: 20px;
{$position}: 20px;
width: {$size};
height: {$size};
background-color: {$bg_color};
color: {$svg_color};
border: none;
border-radius: {$border_radius};
display: flex;
align-items: center;
justify-content: center;
text-decoration: none;
box-shadow: 0 4px 8px rgba(0,0,0,0.3);
z-index: 9999;
transition: transform 0.3s ease;
font-size: 2em;
padding: 0;
}
.cbwfb-svg:hover {
transform: scale(1.1);
background-color: #128C7E;
}
.cbwfb-svg svg {
width: 60%;
height: 60%;
display: block;
}
</style>
<a href=\"{$link_url}\" class=\"cbwfb-svg\" target=\"_blank\" rel=\"noopener\">
{$svg_icon}
</a>
";
}
add_action('wp_footer', 'cbwfb_button');WhatsApp Floating Button
Adds a simple WhatsApp floating button in your website.


