PluginProbe ʕ •ᴥ•ʔ
VikAppointments Services Booking Calendar / 1.2.21
VikAppointments Services Booking Calendar v1.2.21
1.2.21 1.2.20 trunk 1.2.17 1.2.18 1.2.19
vikappointments / libraries / html / overrides / bc.php
vikappointments / libraries / html / overrides Last commit date
bc.php 2 days ago config.php 2 days ago
bc.php
185 lines
1 <?php
2 /**
3 * @package VikAppointments - Libraries
4 * @subpackage html.overrides
5 * @author E4J s.r.l.
6 * @copyright Copyright (C) 2024 E4J s.r.l. All Rights Reserved.
7 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
8 * @link https://vikwp.com
9 */
10
11 // No direct access
12 defined('ABSPATH') or die('No script kiddies please!');
13
14 // use Toast script to displayed "Copied" message
15 JHtml::fetch('vaphtml.assets.toast', 'bottom-right');
16
17 $files = isset($displayData['files']) ? (array) $displayData['files'] : [];
18 $plain = '';
19
20 ?>
21
22 <div class="breaking-changes">
23
24 <!-- heading -->
25
26 <h3 style="margin-top: 0;">
27 <?php _e('Breaking Changes', 'vikappointments'); ?>
28 </h3>
29
30 <!-- what's this warning? -->
31
32 <p>
33 <?php
34 _e(
35 'The following overrides have been automatically unpublished in order to avoid possible errors due to deprecated code.',
36 'vikappointments'
37 );
38 ?>
39 </p>
40
41 <!-- unpublished files list -->
42
43 <?php
44 foreach ($files as $client => $list)
45 {
46 $plain .= ($plain ? "\n\n" : '') . "### " . strtoupper($client) . "\n";
47
48 ?>
49 <h4 style="margin: 0;"><?php echo ucwords($client); ?></h4>
50
51 <ul style="padding-left: 10px;">
52 <?php
53 foreach ($list as $file)
54 {
55 $plain .= "\n- " . $file;
56
57 ?>
58 <li style="display: flex; align-items: center;">
59 <input
60 type="checkbox"
61 id="override-<?php echo md5($file); ?>"
62 class="breaking-changes-override-check"
63 data-file="<?php echo $this->escape($file); ?>"
64 style="margin: 0;"
65 />
66
67 <label for="override-<?php echo md5($file); ?>" style="margin: 0 6px;">
68 <code><?php echo str_replace(ABSPATH, '', (string) $file); ?></code>
69 </label>
70
71 <a
72 href="admin.php?page=vikappointments&view=overrides&client=<?php echo $client; ?>&overridefile=<?php echo base64_encode($file); ?>"
73 target="_blank"
74 style="margin: 0;"
75 ><i class="fas fa-external-link-square-alt" style="font-size: 18px;"></i></a>
76 </li>
77 <?php
78 }
79 ?>
80 </ul>
81 <?php
82 }
83 ?>
84
85 <ul>
86
87 </ul>
88
89 <!-- what should I do? -->
90
91 <p>
92 <?php
93 _e(
94 'Please review the unpublished overrides if you wish to keep the changes you made. You can tick the box of the reviewed files to remove them from the list.',
95 'vikappointments'
96 );
97 ?>
98 </p>
99
100 <!--
101 Create CSS rule to "hide" the textarea by keeping it
102 active to allow the browser to copy its contents.
103 -->
104
105 <style>
106 .breaking-changes textarea.keep-active-but-hidden {
107 width: 0 !important;
108 height: 0 !important;
109 opacity: 0 !important;
110 float: right;
111 cursor: default;
112 }
113 </style>
114
115 <textarea class="keep-active-but-hidden"><?php echo $plain; ?></textarea>
116
117 <!-- define button to copy the files -->
118
119 <button class="button" id="breaking-changes-copy"><?php _e('Copy'); ?></button>
120
121 <!-- define button to dismiss the warning -->
122
123 <button class="button" id="breaking-changes-dismiss"><?php _e('Dismiss', 'vikappointments'); ?></button>
124
125 </div>
126
127 <script>
128 (function($) {
129 'use strict';
130
131 const unregisterBreakingChanges = (files) => {
132 UIAjax.do(
133 'admin-ajax.php?action=vikappointments&task=override.dismissbc',
134 {
135 // can be an array of files, a single file (string) or null/undefined to dismiss all the files
136 files: files,
137 }
138 );
139 }
140
141 $(function($) {
142 // implement copy callback
143 $('#breaking-changes-copy').on('click', function() {
144 // copy path within the clipboard
145 copyToClipboard($(this).prev('textarea')).then(() => {
146 // display successful message on copy
147 VAPToast.dispatch(new VAPToastMessageOS({
148 body: '<?php echo addslashes(__('Copied!')); ?>',
149 status: VAPToast.SUCCESS_STATUS,
150 delay: 'auto',
151 }));
152 }).catch(() => {
153 // cannot copy
154 VAPToast.dispatch(new VAPToastMessageOS({
155 body: '<?php echo addslashes(__('Cannot copy the files! Please proceed manually.', 'vikappointments')); ?>',
156 status: VAPToast.ERROR_STATUS,
157 delay: 'auto',
158 }));
159 });
160 });
161
162 // implement dismiss callback
163 $('#breaking-changes-dismiss').on('click', function() {
164 // hide the alert
165 $(this).closest('.notice').find('.notice-dismiss').trigger('click');
166
167 // dismiss breaking changes in background
168 unregisterBreakingChanges();
169 });
170
171 // auto-hide only the selected file from the list of the breaking changes
172 $('.breaking-changes-override-check').on('change', function() {
173 $(this).prop('disabled', true);
174
175 if ($('.breaking-changes-override-check').not(':disabled').length > 0) {
176 // dismiss only this file
177 unregisterBreakingChanges($(this).data('file'));
178 } else {
179 // this is the last file, we can dismiss the whole warning
180 $('#breaking-changes-dismiss').trigger('click');
181 }
182 });
183 });
184 })(jQuery);
185 </script>