PluginProbe
Booking Calendar / 11.6
Booking Calendar v11.6
11.8.3 11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 10.11 10.11.2 All 203 releases
booking / includes / ui_settings / parts / ui__nav_top.php

ui__nav_top.php in Booking Calendar 11.6, at includes/ui_settings/parts/ui__nav_top.php

359 lines 12.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Admin Panel UI - Parts
4 *
5 * @version 1.2
6 * @package Any
7 * @category Page Structure in Admin Panel
8 * @author wpdevelop
9 *
10 * @web-site https://wpbookingcalendar.com/
11 * @email info@wpbookingcalendar.com
12 *
13 * @modified 2025-02-15
14 */
15
16 if ( ! defined( 'ABSPATH' ) ) {
17 exit; // Exit, if accessed directly.
18 }
19
20 /**
21 * Show Top Nav bar
22 *
23 * @param array $args - parameters.
24 *
25 * @return void
26 */
27 function wpbc_ui__top_nav( $args = array() ) {
28
29 $defaults = array(
30 'attr' => array(),
31 'is_full_screen_user_mode_enabled' => true,
32 );
33 $params = wp_parse_args( $args, $defaults );
34
35 echo '<div class="wpbc_ui_el wpbc_ui_el__top_nav">';
36
37 wpbc_ui__vert_left_bar__do_toggle();
38 wpbc_ui_el__divider_vertical( array( 'class' => 'wpbc_ui_el__vertical_line wpbc_ui__top_nav__btn_show_left_vertical_nav_divider' ) );
39
40 wpbc_ui__top_nav__dropdown__wpbc();
41
42 do_action( 'wpbc_ui_el__top_nav__content_start', $params['page_tag'], $params['active_page_tab'], $params['active_page_subtab'] );
43
44
45 ?><div class="wpbc_ui_el__make_space"></div><?php // Spacer.
46
47 do_action( 'wpbc_ui_el__top_nav__content_center', $params['page_tag'], $params['active_page_tab'], $params['active_page_subtab'] );
48
49 // Load Top News Message and "Search by ID" fields.
50 echo '<style type="text/css"> .wpbc_message_wrapper { margin-left: 0px !important; } </style>';
51 make_bk_action( 'wpbc_h1_header_content_end', $params['page_tag'], $params['active_page_tab'], $params['active_page_subtab'] );
52
53 ?><div class="wpbc_ui_el__make_space"></div><?php // Spacer.
54
55 do_action( 'wpbc_ui_el__top_nav__content_end', $params['page_tag'], $params['active_page_tab'], $params['active_page_subtab'] );
56
57 wpbc_ui_el__divider_vertical();
58
59 // Right sidebar toggle button.
60 wpbc_ui__vert_right_bar__do_toggle();
61 wpbc_ui_el__divider_vertical( array( 'class' => 'wpbc_ui_el__vertical_line wpbc_ui__top_nav__btn_show_right_vertical_nav_divider' ) );
62
63
64 // Full Screen Buttons.
65 wpbc_ui__top_nav__btn_full_screen( $params );
66 wpbc_ui__top_nav__btn_normal_screen( $params );
67
68 echo '</div>';
69 }
70
71
72
73 /**
74 * Show element - "WPBC - Main Dropdown"
75 *
76 * @return void
77 */
78 function wpbc_ui__top_nav__dropdown__wpbc() {
79
80 $svg_size = '22px';
81 $svg_icon_style = 'margin:5px 5px 0 0;'; // 'background-position: 0 0;background-size: ' . $svg_size . ' ' . $svg_size . ';width: ' . $svg_size . ';height: ' . $svg_size . ';'; //.
82 $svg_icon = wpbc_get_svg_logo_for_background( '#555', '#e5e5e5', '1.0' );
83
84 $wpbc_starter_pages = function_exists( 'wpbc_get_published_activation_booking_pages' ) ? wpbc_get_published_activation_booking_pages() : array();
85 $wp_post_booking_absolute = false;
86
87 if (
88 empty( $wpbc_starter_pages ) &&
89 function_exists( 'wpbc_stp_wiz__is_exist_published_page_with_booking_form' )
90 ) {
91 $wp_post_booking_absolute = wpbc_stp_wiz__is_exist_published_page_with_booking_form();
92 }
93
94 $el_arr = array(
95 // 'title' => 'Booking Calendar',
96 // 'font_icon' => 'wpbc-bi-calendar2-range',
97 'title_html' => '<span class="nav-tab-text" style="margin: -3px 0 0 5px;font-size: 16px;padding: 0;"><span style="position: absolute;font-size: 7px;margin-top: 13px;margin-left: 1px;">WP</span>Booking Calendar</span>',
98 'svg_icon' => $svg_icon,
99 'svg_icon_style' => $svg_icon_style,
100 'style' => 'display: flex;flex-flow:row nowrap;align-items: center;justify-content: flex-start; ',
101 'container_style' => 'padding: 0 15px 0 10px;',
102 'position' => 'left',
103 'has_down_arrow' => true,
104 'items' => array(),
105 );
106
107 if ( ! empty( $wpbc_starter_pages ) && is_array( $wpbc_starter_pages ) ) {
108 $el_arr['items'][] = array(
109 'type' => 'header',
110 'title' => __( 'Visit Booking Pages', 'booking' ),
111 );
112 $el_arr['items'][] = array(
113 'type' => 'link',
114 'title' => __( 'Visit Home Page', 'booking' ),
115 'url' => esc_url( home_url( '/' ) ),
116 );
117
118 foreach ( $wpbc_starter_pages as $wpbc_starter_page ) {
119 if ( empty( $wpbc_starter_page['url'] ) ) {
120 continue;
121 }
122
123 $wpbc_starter_page_title = __( 'Go to page with booking form', 'booking' );
124 if ( ! empty( $wpbc_starter_page['button_title'] ) ) {
125 $wpbc_starter_page_title = $wpbc_starter_page['button_title'];
126 } elseif ( ! empty( $wpbc_starter_page['page_title'] ) ) {
127 $wpbc_starter_page_title = $wpbc_starter_page['page_title'];
128 }
129
130 $el_arr['items'][] = array(
131 'type' => 'link',
132 'title' => $wpbc_starter_page_title,
133 'url' => esc_url( $wpbc_starter_page['url'] ),
134 );
135 }
136 } elseif ( ! empty( $wp_post_booking_absolute ) ) {
137 $el_arr['items'][] = array(
138 'type' => 'header',
139 'title' => __( 'Visit Booking Page', 'booking' ),
140 );
141 $el_arr['items'][] = array(
142 'type' => 'link',
143 'title' => __( 'Visit Home Page', 'booking' ),
144 'url' => esc_url( home_url( '/' ) ),
145 );
146 $el_arr['items'][] = array(
147 'type' => 'link',
148 'title' => __( 'Go to page with booking form', 'booking' ),
149 'url' => esc_url( $wp_post_booking_absolute ),
150 );
151 }
152 $el_arr['items'][] = array(
153 'type' => 'header',
154 'title' => __( 'Help', 'booking' ),
155 );
156 $el_arr['items'][] = array(
157 'type' => 'link',
158 'title' => __( 'FAQ', 'booking' ),
159 'url' => 'https://wpbookingcalendar.com/faq/',
160 );
161 $el_arr['items'][] = array(
162 'type' => 'header',
163 'title' => __( 'Support', 'booking' ),
164 );
165 $el_arr['items'][] = array(
166 'type' => 'link',
167 'title' => __( 'Support Forum', 'booking' ),
168 'url' => 'https://wpbookingcalendar.com/support/',
169 );
170 $el_arr['items'][] = array(
171 'type' => 'link',
172 'title' => __( 'Contact Support', 'booking' ),
173 'url' => 'mailto:support@wpbookingcalendar.com',
174 'attr' => array( 'style' => 'font-weight: 600;' ),
175 );
176 $el_arr['items'][] = array( 'type' => 'divider' );
177 $el_arr['items'][] = array(
178 'type' => 'link',
179 'title' => __( 'Release History', 'booking' ),
180 'url' => 'https://wpbookingcalendar.com/wn/',
181 );
182 $el_arr['items'][] = array(
183 'type' => 'link',
184 'title' => __( 'What\'s New', 'booking' ) . ' <span style="float:right">' . esc_attr( WP_BK_VERSION_NUM ) . '</span>',
185 'url' => esc_url( admin_url( add_query_arg( array( 'page' => 'wpbc-about' ), 'index.php' ) ) ),
186 );
187 // $el_arr['items'][] = array(
188 // 'type' => 'link',
189 // 'title' => __( 'About', 'booking' ),
190 // 'url' => 'https://wpbookingcalendar.com/',
191 // );
192
193
194 $is_show_up = wpbc_is_show_up();
195
196 if ( $is_show_up ) {
197 $el_arr['items'][] = array( 'type' => 'divider' );
198 $el_arr['items'][] = array(
199 'type' => 'link',
200 'title' => ( class_exists( 'wpdev_bk_personal' ) )
201 ? __( 'View Upgrade Options', 'booking' )
202 : __( 'Upgrade to Pro', 'booking' ),
203 'url' => wpbc_up_link(),
204 'attr' => array(
205 'class' => 'wpbc_ui_el_upgrade_button wpbc_button_light wpbc_button_green',
206 'style' => 'color:#fff;font-weight: 600;',
207 ),
208 );
209 }
210
211 wpbc_ui_el__dropdown_menu( $el_arr );
212 }
213
214
215 /**
216 * Show element - "Full Screen"
217 *
218 * @return void
219 */
220 function wpbc_ui__top_nav__btn_full_screen( $args = array() ) {
221
222 $defaults = array(
223 'is_full_screen_user_mode_enabled' => true,
224 );
225 $params = wp_parse_args( $args, $defaults );
226
227 $el_arr = array();
228
229 $el_arr['onclick'] = 'wpbc_admin_ui__full_screen__do_on( this, ' . ( $params['is_full_screen_user_mode_enabled'] ? 'true' : 'false' ) . ' );';
230
231 $el_arr['font_icon'] = 'wpbc-bi-arrows-fullscreen';
232 $el_arr['hint'] = array(
233 'title' => __( 'Full Screen', 'booking' ),
234 'position' => 'top',
235 );
236
237 $el_arr['container_class'] = 'wpbc_ui__top_nav__btn_full_screen';
238
239 if ( ( ! wpbc_is_setup_wizard_page() ) && ( $params['is_full_screen_user_mode_enabled'] ) ) {
240
241 // Params for saving user option.
242 $user_cust_option = 'is_full_screen';
243 $nonce_action = $user_cust_option . '_nonce_act';
244
245 $el_arr['attr'] = array(
246 'data-wpbc-u-save-name' => $user_cust_option,
247 'data-wpbc-u-save-value' => 'On',
248 'data-wpbc-u-save-nonce' => wp_create_nonce( $nonce_action ), // do not need to make escaping the values because: wpbc_get_custom_attr() should handle escaping.
249 'data-wpbc-u-save-user-id' => wpbc_get_current_user_id(),
250 'data-wpbc-u-save-action' => $nonce_action,
251 );
252 ?><script type="text/javascript"><?php
253
254 $is_full_screen = WPBC_User_Custom_Data_Saver::get_user_data_value( wpbc_get_current_user_id(), $user_cust_option );
255 $is_full_screen = ( 'On' === wpbc_ui__get_full_screen_mode_from_cookie( $is_full_screen ) );
256
257 echo wpbc_jq_ready_start(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
258
259 if ( $is_full_screen ) {
260 echo " jQuery( '.wpbc_ui__top_nav__btn_full_screen,.wpbc_ui__top_nav__btn_normal_screen' ).toggleClass( 'wpbc_ui__hide' ); ";
261 }
262 echo ' wpbc_check_full_screen_mode(); ';
263 echo wpbc_jq_ready_end(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
264
265 ?></script><?php
266 }
267 wpbc_ui_el__a( $el_arr );
268 }
269
270
271 /**
272 * Show element - "Normal Screen"
273 *
274 * @return void
275 */
276 function wpbc_ui__top_nav__btn_normal_screen( $args = array() ) {
277
278 $defaults = array(
279 'is_full_screen_user_mode_enabled' => true,
280 );
281 $params = wp_parse_args( $args, $defaults );
282
283 $el_arr = array();
284
285 $el_arr['onclick'] = 'wpbc_admin_ui__full_screen__do_off( this, ' . ( $params['is_full_screen_user_mode_enabled'] ? 'true' : 'false' ) . ' );';
286
287 $el_arr['title'] = '';
288 $el_arr['font_icon'] = 'wpbc-bi-arrows-angle-contract';
289 $el_arr['hint'] = array(
290 'title' => __( 'Exit Full Screen', 'booking' ),
291 'position' => 'top',
292 );
293 $el_arr['container_class'] = 'wpbc_ui__top_nav__btn_normal_screen wpbc_ui__hide';
294
295 if ( $params['is_full_screen_user_mode_enabled'] ) {
296 // Params for saving user option.
297 $user_cust_option = 'is_full_screen';
298 $nonce_action = $user_cust_option . '_nonce_act';
299 $el_arr['attr'] = array(
300 'data-wpbc-u-save-name' => $user_cust_option,
301 'data-wpbc-u-save-value' => 'Off',
302 'data-wpbc-u-save-nonce' => wp_create_nonce( $nonce_action ), // do not need to make escaping the values because: wpbc_get_custom_attr() should handle escaping.
303 'data-wpbc-u-save-user-id' => wpbc_get_current_user_id(),
304 'data-wpbc-u-save-action' => $nonce_action,
305 );
306 }
307
308 wpbc_ui_el__a( $el_arr );
309 }
310
311
312 /**
313 * Get Full Screen mode from the immediate browser cookie, falling back to saved user meta value.
314 *
315 * @param string $saved_value Saved user-meta value.
316 *
317 * @return string 'On', 'Off', or empty string.
318 */
319 function wpbc_ui__get_full_screen_mode_from_cookie( $saved_value = '' ) {
320
321 $saved_value = in_array( $saved_value, array( 'On', 'Off' ), true ) ? $saved_value : '';
322
323 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash
324 if ( ! isset( $_COOKIE['wpbc_admin_full_screen'] ) ) {
325 return $saved_value;
326 }
327
328 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash
329 $cookie_value = sanitize_text_field( $_COOKIE['wpbc_admin_full_screen'] );
330
331 if ( in_array( $cookie_value, array( 'On', 'Off' ), true ) ) {
332 return $cookie_value;
333 }
334
335 return $saved_value;
336 }
337
338
339 /**
340 * Set the admin full screen class
341 *
342 * @param bool $classes Body classes.
343 *
344 * @return array
345 */
346 function wpbc_check_full_screen_mode_on_loading( $classes ) {
347
348 $is_full_screen = WPBC_User_Custom_Data_Saver::get_user_data_value( wpbc_get_current_user_id(), 'is_full_screen' );
349 $is_full_screen = wpbc_ui__get_full_screen_mode_from_cookie( $is_full_screen );
350 $is_full_screen = ( 'On' === $is_full_screen );
351
352 if ( ( wpbc_is_this_plugin_page() ) && ( $is_full_screen ) && ( ! wpbc_is_setup_wizard_page() ) ) {
353 $classes .= ' wpbc_admin_full_screen';
354 }
355
356 return $classes;
357 }
358 add_filter( 'admin_body_class', 'wpbc_check_full_screen_mode_on_loading' );
359