PluginProbe
Booktics – Appointment Booking Calendar for Service Businesses / 1.0.15
Booktics – Appointment Booking Calendar for Service Businesses v1.0.15
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
booktics / core / assets / admin-assets.php

admin-assets.php in Booktics – Appointment Booking Calendar for Service Businesses 1.0.15, at core/assets/admin-assets.php

153 lines 4.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Booktics\Assets;
4
5 /**
6 * Manage all admin scripts and styles
7 */
8 class Admin_Assets extends Base_Assets {
9 /**
10 * Register single service
11 *
12 * @return void
13 */
14 public function register() {
15 add_action( 'admin_enqueue_scripts', [
16 $this,
17 'register_styles_scripts'
18 ] );
19 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ] );
20 add_action( 'admin_footer', [ $this, 'admin_helpscout_beacon' ] );
21 }
22
23 /**
24 * Enqueue scripts and styles
25 *
26 * @return void
27 */
28 public function enqueue() {
29 $screen = get_current_screen();
30 if ( $screen->base !== 'toplevel_page_booktics') {
31 return;
32 }
33 wp_enqueue_style( 'wp-color-picker' );
34 wp_enqueue_style( 'booktics-admin-style' );
35 wp_enqueue_style( 'booktics-vendor' );
36
37 wp_enqueue_media();
38 wp_enqueue_script( 'booktics-flatpickr-scripts' );
39 wp_enqueue_script( 'booktics-packages' );
40 wp_enqueue_script( 'booktics-dashboard-scripts' );
41
42 wp_localize_script( 'booktics-packages', 'booktics', Localize::get_admin() );
43 wp_localize_script( 'booktics-packages', 'booktics_enabled_modules', booktics_get_enabled_modules() );
44 }
45
46 /**
47 * Get all scripts
48 *
49 * @return array List register scripts
50 */
51 public function get_scripts(): array {
52 $scripts = [
53 'booktics-dashboard-scripts' => [
54 'src' => booktics()->assets_url . '/build/js/dashboard.js',
55 'deps' => [ 'booktics-packages' ],
56 'in_footer' => true,
57 ],
58 'booktics-flatpickr-scripts' => [
59 'src' => booktics()->assets_url . '/js/vendors/flatpickr.js',
60 'deps' => [],
61 'in_footer' => true,
62 ],
63 'booktics-packages' => [
64 'src' => booktics()->assets_url . '/build/js/packages.js',
65 'deps' => [
66 'wp-api-fetch',
67 'wp-components',
68 'wp-compose',
69 'wp-i18n',
70 'wp-element',
71 'wp-data'
72 ],
73 'in_footer' => true,
74 ],
75 ];
76
77 return apply_filters( 'booktics_admin_assets', $scripts );
78 }
79
80 /**
81 * List of register styles
82 *
83 * @return array
84 */
85 public function get_styles(): array {
86 $styles = [
87 'booktics-admin-style' => [
88 'src' => booktics()->assets_url . '/build/css/admin.css',
89 ],
90 'booktics-vendor' => [
91 'src' => booktics()->assets_url . '/build/css/vendor.css',
92 ],
93 ];
94
95 return apply_filters( 'booktics_admin_styles', $styles );
96 }
97
98 /**
99 * Add HelpScout script to admin footer
100 *
101 * @return void
102 */
103 public function admin_helpscout_beacon() {
104 $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null;
105 $is_booktics_screen = false;
106
107 if ( $screen ) {
108 $screen_id = isset( $screen->id ) ? $screen->id : '';
109
110 // Check: only load on Booktics top-level admin page
111 if ( 'toplevel_page_booktics' === $screen_id ) {
112 $is_booktics_screen = true;
113 }
114 }
115
116 // Allow overriding detection via filter.
117 $is_booktics_screen = apply_filters( 'booktics_is_admin_screen', $is_booktics_screen, $screen );
118
119 if ( ! $is_booktics_screen ) {
120 return;
121 }
122 ?>
123 <script type="text/javascript">
124 ! function(e, t, n) {
125 function a() {
126 var e = t.getElementsByTagName("script")[0],
127 n = t.createElement("script");
128 n.type = "text/javascript", n.async = !0, n.src = "https://beacon-v2.helpscout.net", e.parentNode.insertBefore(
129 n, e)
130 }
131 if (e.Beacon = n = function(t, n, a) {
132 e.Beacon.readyQueue.push({
133 method: t,
134 options: n,
135 data: a
136 })
137 }, n.readyQueue = [], "complete" === t.readyState) a();
138 else if (e.attachEvent) e.attachEvent("onload", a);
139 else e.addEventListener("load", a, !1)
140 }(window, document, window.Beacon || function() {});
141 </script>
142 <script type="text/javascript">
143 window.Beacon('config', {
144 color: "#22B855",
145 });
146 window.Beacon('init', '0f1a82db-0aa9-4bac-accc-ee1bb81d4940');
147 window.Beacon('on', 'ready', function() {
148 window.Beacon('show');
149 });
150 </script>
151 <?php
152 }
153 }