-
Notifications
You must be signed in to change notification settings - Fork 0
Kirby WhatsApp Button
Ahmet Bora edited this page Sep 15, 2022
·
1 revision
This is a very simple floating WhatsApp button plugin for Kirby 3.
- Download the latest release
- Unzip downloaded file
- Copy/paste unzipped folder in your
/site/plugins
folder
You can use sample basic snippet of plugin:
<?php snippet('whatsapp-button') ?>
The default values of the package are:
Option | Type | Default | Description |
---|---|---|---|
enabled | bool|closure | true | Enable/disable the button |
phone | string | Whatsapp number (required) | |
position | string | right | Button position (left-right) |
showBadge | bool | true | Enable/disable badge of button |
countBadge | int | 1 | Badge text of button |
timeoutBadge | int | 1500 | Badge delay time (ms) |
alwaysOpen | bool | false | Sets chat window whether to be always on |
alwaysOpenTimeout | int | 2500 | After the specified time (ms), chat window will always open |
autoOpen | bool | true | Chat window opens automatically |
autoOpenTimeout | int | 5000 | After the specified time (ms), the chat window opens automatically |
doNotDisturb | bool | false | When enabled chat window will not open automatically on every page load |
name | string | Site title | Shows your/site name in the header of the chat window |
avatar | string | Placeholder of site title | Show your/site image in the header of the chat window |
status | string | online | Show status text under the name |
showStatus | bool | true | Enable/disable the status text |
messages | string|array | Hello, how can we help you? | Preloaded messages when the chat window is opened |
placeholder | string | Type here... | Placeholder of input in the chat window |
defaultMessage | string | Hello | Text to be sent to WhatsApp API if user leaves input blank |
All the values can be updated in the config.php
file and prefixed with owebstudio.whatsapp-button.
<?php
// /site/config/config.php
return [
'owebstudio.whatsapp-button' => [
'phone' => '4912345678',
]
];
<?php
// /site/config/config.php
return [
'debug' => true,
'owebstudio.whatsapp-button' => [
'phone' => '4912345678',
'enabled' => function () {
// enabled only weekdays and 08:00-17:00
return date('N') <= 5 && date('G') >= 8 && date('G') <= 17;
},
],
];
<?php
// /site/config/config.php
return [
'debug' => true,
'owebstudio.whatsapp-button' => [
'phone' => '4912345678',
'messages' => [
'Welcome to our site!',
'How can I help you?'
],
],
];
<?php
snippet('whatsapp-button', ['options' => [
'name' => 'John Doe',
'phone' => '4912345678'
]])
?>