-
Notifications
You must be signed in to change notification settings - Fork 3
/
tawk_to.module
58 lines (50 loc) · 1.8 KB
/
tawk_to.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
/**
* @file
* Hooks for tawk.to module.
*/
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\tawk_to\core\TawktoGenerator;
/**
* Implements hook_help().
*/
function tawk_to_help($route_name, RouteMatchInterface $route_match) {
if ($route_name !== 'tawk_to.help') {
return;
}
$links = [
':homepage' => 'https://tawk.to',
':dashboard' => 'https://dashboard.tawk.to',
':project_page' => 'https://www.drupal.org/sandbox/tawk/2205433',
':mail_link' => '[email protected]',
];
$output = '';
$output .= '<h3>' . t('About tawk.to') . '</h3>';
$output .= '<p>' . t('tawk.to Drupal module allows you to easily choose which one of your tawk.to widgets you
want to use on your drupal page. To create account please visit <a href=":project">https://tawk.to</a>.<br />
To answer chat go to <a href="dashboard">https://dashboard.tawk.to</a>.<br />
* For a full description of the module, visit the project page:<br />
<a href=":project_page">https://www.drupal.org/sandbox/tawk/2205433</a><br /><br />
* To submit bug reports and feature suggestions, or to track changes please email [email protected]
', $links) . '</p>';
return $output;
}
/**
* Shows chat widget on every page except admin pages.
*/
function tawk_to_page_bottom(array &$page_bottom) {
$route = \Drupal::routeMatch()->getRouteObject();
$is_admin_route = \Drupal::service('router.admin_context')->isAdminRoute($route);
$has_node_operation_option = $route->getOption('_node_operation_route');
$is_admin = ($is_admin_route || $has_node_operation_option);
if (!$is_admin) {
$generator = new TawktoGenerator();
$page_bottom['tawk_to'] = [
'#type' => 'inline_template',
'#template' => $generator->widget(),
'#cache' => [
'tags' => ['tawk_widget'],
],
];
}
}