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

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