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

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