PluginProbe
VikBooking Hotel Booking Engine & PMS / trunk
VikBooking Hotel Booking Engine & PMS vtrunk
1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 1.7.3 All 36 releases
vikbooking / libraries / html / overrides / bc.php

bc.php in VikBooking Hotel Booking Engine & PMS trunk, at libraries/html/overrides/bc.php

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