PluginProbe
Booktics – Appointment Booking Calendar for Service Businesses / 1.0.27
Booktics – Appointment Booking Calendar for Service Businesses v1.0.27
1.0.29 1.0.28 1.0.27 1.0.26 1.0.25 1.0.24 1.0.23 1.0.22 1.0.21 1.0.20 1.0.19 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.2 1.0.3 All 31 releases
← All changes | core/assets/admin-assets.php +73 -1 1.0.3 → 1.0.27 View file →
@@ -1,8 +1,10 @@
1 1 <?php
2 2
3 3 namespace Booktics\Assets;
4 4
5 +if ( ! defined( 'ABSPATH' ) ) exit;
6 +
5 7 /**
6 8 * Manage all admin scripts and styles
7 9 */
8 10 class Admin_Assets extends Base_Assets {
@@ -16,8 +18,9 @@
16 18 $this,
17 19 'register_styles_scripts'
18 20 ] );
19 21 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ] );
22 + add_action( 'admin_footer', [ $this, 'admin_helpscout_beacon' ] );
20 23 }
21 24
22 25 /**
23 26 * Enqueue scripts and styles
@@ -24,8 +27,13 @@
24 27 *
25 28 * @return void
26 29 */
27 30 public function enqueue() {
31 + $screen = get_current_screen();
32 + if ( $screen->base !== 'toplevel_page_booktics') {
33 + return;
34 + }
35 + $this->enqueue_i18n_loader();
28 36 wp_enqueue_style( 'wp-color-picker' );
29 37 wp_enqueue_style( 'booktics-admin-style' );
30 38 wp_enqueue_style( 'booktics-vendor' );
31 39
@@ -35,8 +43,13 @@
35 43 wp_enqueue_script( 'booktics-dashboard-scripts' );
36 44
37 45 wp_localize_script( 'booktics-packages', 'booktics', Localize::get_admin() );
38 46 wp_localize_script( 'booktics-packages', 'booktics_enabled_modules', booktics_get_enabled_modules() );
47 +
48 + if ( function_exists( 'wp_set_script_translations' ) ) {
49 + wp_set_script_translations( 'booktics-dashboard-scripts', 'booktics' );
50 + }
51 +
39 52 }
40 53
41 54 /**
42 55 * Get all scripts
@@ -60,9 +73,12 @@
60 73 'deps' => [
61 74 'wp-api-fetch',
62 75 'wp-components',
63 76 'wp-compose',
64 - 'wp-i18n'
77 + 'wp-i18n',
78 + 'wp-element',
79 + 'wp-data',
80 + 'wp-hooks',
65 81 ],
66 82 'in_footer' => true,
67 83 ],
68 84 ];
@@ -85,6 +101,62 @@
85 101 ],
86 102 ];
87 103
88 104 return apply_filters( 'booktics_admin_styles', $styles );
105 + }
106 +
107 + /**
108 + * Add HelpScout script to admin footer
109 + *
110 + * @return void
111 + */
112 + public function admin_helpscout_beacon() {
113 + $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null;
114 + $is_booktics_screen = false;
115 +
116 + if ( $screen ) {
117 + $screen_id = isset( $screen->id ) ? $screen->id : '';
118 +
119 + // Check: only load on Booktics top-level admin page
120 + if ( 'toplevel_page_booktics' === $screen_id ) {
121 + $is_booktics_screen = true;
122 + }
123 + }
124 +
125 + // Allow overriding detection via filter.
126 + $is_booktics_screen = apply_filters( 'booktics_is_admin_screen', $is_booktics_screen, $screen );
127 +
128 + if ( ! $is_booktics_screen ) {
129 + return;
130 + }
131 + ?>
132 +<script type="text/javascript">
133 +! function(e, t, n) {
134 + function a() {
135 + var e = t.getElementsByTagName("script")[0],
136 + n = t.createElement("script");
137 + n.type = "text/javascript", n.async = !0, n.src = "https://beacon-v2.helpscout.net", e.parentNode.insertBefore(
138 + n, e)
139 + }
140 + if (e.Beacon = n = function(t, n, a) {
141 + e.Beacon.readyQueue.push({
142 + method: t,
143 + options: n,
144 + data: a
145 + })
146 + }, n.readyQueue = [], "complete" === t.readyState) a();
147 + else if (e.attachEvent) e.attachEvent("onload", a);
148 + else e.addEventListener("load", a, !1)
149 +}(window, document, window.Beacon || function() {});
150 +</script>
151 +<script type="text/javascript">
152 +window.Beacon('config', {
153 + color: "#22B855",
154 +});
155 +window.Beacon('init', '0f1a82db-0aa9-4bac-accc-ee1bb81d4940');
156 +window.Beacon('on', 'ready', function() {
157 + window.Beacon('close');
158 +});
159 +</script>
160 +<?php
89 161 }
90 162 }