| 1 |
<?php |
| 2 |
|
| 3 |
namespace SyncBasalam\Utilities; |
| 4 |
|
| 5 |
use SyncBasalam\Admin\Settings\SettingsConfig; |
| 6 |
|
| 7 |
defined('ABSPATH') || exit; |
| 8 |
|
| 9 |
class ChatWidget |
| 10 |
{ |
| 11 |
public static function shouldLoadWidget() |
| 12 |
{ |
| 13 |
$token = syncBasalamSettings()->hasToken(); |
| 14 |
if (!$token) return false; |
| 15 |
|
| 16 |
return true; |
| 17 |
} |
| 18 |
|
| 19 |
public static function addTokenToWidgetScript($tag, $handle, $src) |
| 20 |
{ |
| 21 |
if ($handle !== 'basalam-chat-widget-script') return $tag; |
| 22 |
|
| 23 |
$token = syncBasalamSettings()->getSettings(SettingsConfig::TOKEN); |
| 24 |
|
| 25 |
return sprintf('<script src="%s" token="%s"></script>', esc_url($src), esc_attr($token)); |
| 26 |
} |
| 27 |
} |
| 28 |
|