PluginProbe
Booktics – Appointment Booking Calendar for Service Businesses / 1.0.13
Booktics – Appointment Booking Calendar for Service Businesses v1.0.13
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.13, at core/assets/admin-assets.php

151 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 ],
71 'in_footer' => true,
72 ],
73 ];
74
75 return apply_filters( 'booktics_admin_assets', $scripts );
76 }
77
78 /**
79 * List of register styles
80 *
81 * @return array
82 */
83 public function get_styles(): array {
84 $styles = [
85 'booktics-admin-style' => [
86 'src' => booktics()->assets_url . '/build/css/admin.css',
87 ],
88 'booktics-vendor' => [
89 'src' => booktics()->assets_url . '/build/css/vendor.css',
90 ],
91 ];
92
93 return apply_filters( 'booktics_admin_styles', $styles );
94 }
95
96 /**
97 * Add HelpScout script to admin footer
98 *
99 * @return void
100 */
101 public function admin_helpscout_beacon() {
102 $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null;
103 $is_booktics_screen = false;
104
105 if ( $screen ) {
106 $screen_id = isset( $screen->id ) ? $screen->id : '';
107
108 // Check: only load on Booktics top-level admin page
109 if ( 'toplevel_page_booktics' === $screen_id ) {
110 $is_booktics_screen = true;
111 }
112 }
113
114 // Allow overriding detection via filter.
115 $is_booktics_screen = apply_filters( 'booktics_is_admin_screen', $is_booktics_screen, $screen );
116
117 if ( ! $is_booktics_screen ) {
118 return;
119 }
120 ?>
121 <script type="text/javascript">
122 ! function(e, t, n) {
123 function a() {
124 var e = t.getElementsByTagName("script")[0],
125 n = t.createElement("script");
126 n.type = "text/javascript", n.async = !0, n.src = "https://beacon-v2.helpscout.net", e.parentNode.insertBefore(
127 n, e)
128 }
129 if (e.Beacon = n = function(t, n, a) {
130 e.Beacon.readyQueue.push({
131 method: t,
132 options: n,
133 data: a
134 })
135 }, n.readyQueue = [], "complete" === t.readyState) a();
136 else if (e.attachEvent) e.attachEvent("onload", a);
137 else e.addEventListener("load", a, !1)
138 }(window, document, window.Beacon || function() {});
139 </script>
140 <script type="text/javascript">
141 window.Beacon('config', {
142 color: "#22B855",
143 });
144 window.Beacon('init', '0f1a82db-0aa9-4bac-accc-ee1bb81d4940');
145 window.Beacon('on', 'ready', function() {
146 window.Beacon('show');
147 });
148 </script>
149 <?php
150 }
151 }